Utility/PixelFormat: use std::string_view to store name

This commit is contained in:
SirLynix
2023-05-30 12:33:40 +02:00
parent dfe6b2ddcf
commit 68b3e31eec
6 changed files with 17 additions and 17 deletions

View File

@@ -26,9 +26,9 @@ namespace Nz
{
inline PixelFormatDescription();
inline PixelFormatDescription(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType);
inline PixelFormatDescription(const std::string& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType);
inline PixelFormatDescription(const std::string& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType);
inline PixelFormatDescription(const std::string& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp = 0);
inline PixelFormatDescription(std::string_view formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType);
inline PixelFormatDescription(std::string_view formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType);
inline PixelFormatDescription(std::string_view formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp = 0);
inline void Clear();
@@ -39,7 +39,7 @@ namespace Nz
inline bool Validate() const;
std::string name;
std::string_view name;
// Warning: Masks bit order is reversed
Bitset<> redMask;
Bitset<> greenMask;
@@ -72,7 +72,7 @@ namespace Nz
static inline PixelFormatContent GetContent(PixelFormat format);
static inline UInt8 GetBytesPerPixel(PixelFormat format);
static inline const PixelFormatDescription& GetInfo(PixelFormat format);
static inline const std::string& GetName(PixelFormat format);
static inline std::string_view GetName(PixelFormat format);
static inline bool HasAlpha(PixelFormat format);

View File

@@ -26,7 +26,7 @@ namespace Nz
{
}
inline PixelFormatDescription::PixelFormatDescription(const std::string& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) :
inline PixelFormatDescription::PixelFormatDescription(std::string_view formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) :
name(formatName),
content(formatContent),
redType(subType),
@@ -37,12 +37,12 @@ namespace Nz
{
}
inline PixelFormatDescription::PixelFormatDescription(const std::string& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType) :
inline PixelFormatDescription::PixelFormatDescription(std::string_view formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType) :
PixelFormatDescription(formatName, formatContent, subType, rMask, subType, gMask, subType, bMask, subType, aMask)
{
}
inline PixelFormatDescription::PixelFormatDescription(const std::string& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp) :
inline PixelFormatDescription::PixelFormatDescription(std::string_view formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp) :
name(formatName),
redMask(rMask),
greenMask(gMask),
@@ -70,7 +70,7 @@ namespace Nz
blueMask.Clear();
greenMask.Clear();
redMask.Clear();
name.clear();
name = "";
}
inline bool PixelFormatDescription::IsCompressed() const
@@ -233,7 +233,7 @@ namespace Nz
return s_pixelFormatInfos[format];
}
inline const std::string& PixelFormatInfo::GetName(PixelFormat format)
inline std::string_view PixelFormatInfo::GetName(PixelFormat format)
{
return s_pixelFormatInfos[format].name;
}