Utility: Rework PixelFormat (WIP)

Former-commit-id: bb48562e5f5caac023fcfca7840931aaae7a7821
This commit is contained in:
Lynix
2016-05-17 14:23:45 +02:00
parent 4ecc701ad2
commit 8a38bb767d
9 changed files with 306 additions and 561 deletions

View File

@@ -23,33 +23,36 @@ namespace Nz
{
struct PixelFormatInfo
{
PixelFormatInfo() :
bitsPerPixel(0)
{
}
inline PixelFormatInfo();
inline PixelFormatInfo(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType);
inline PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType);
inline PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType);
inline PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp = 0);
PixelFormatInfo(UInt8 bpp, PixelFormatSubType subType) :
bitsPerPixel(bpp),
redType(subType),
greenType(subType),
blueType(subType),
alphaType(subType)
{
}
inline void Clear();
// Warning: Bit Endian
inline bool IsCompressed() const;
inline bool IsValid() const;
inline void RecomputeBitsPerPixel();
inline bool Validate() const;
// Warning: Masks bit order is reversed
Bitset<> redMask;
Bitset<> greenMask;
Bitset<> blueMask;
Bitset<> alphaMask;
PixelFormatContent content;
PixelFormatSubType redType;
PixelFormatSubType greenType;
PixelFormatSubType blueType;
PixelFormatSubType alphaType;
String name;
UInt8 bitsPerPixel;
};
class PixelFormat
class NAZARA_UTILITY_API PixelFormat
{
friend class Utility;
@@ -59,34 +62,35 @@ namespace Nz
static inline std::size_t ComputeSize(PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth);
static bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* src, void* dst);
static bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* start, const void* end, void* dst);
static inline bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* src, void* dst);
static inline bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* start, const void* end, void* dst);
static bool Flip(PixelFlipping flipping, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst);
static inline bool Flip(PixelFlipping flipping, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst);
static UInt8 GetBitsPerPixel(PixelFormatType format);
static UInt8 GetBytesPerPixel(PixelFormatType format);
static PixelFormatTypeType GetType(PixelFormatType format);
static inline UInt8 GetBitsPerPixel(PixelFormatType format);
static inline PixelFormatContent GetContent(PixelFormatType format);
static inline UInt8 GetBytesPerPixel(PixelFormatType format);
static inline const PixelFormatInfo& GetInfo(PixelFormatType format);
static inline const String& GetName(PixelFormatType format);
static bool HasAlpha(PixelFormatType format);
static inline bool HasAlpha(PixelFormatType format);
static PixelFormatType IdentifyFormat(const PixelFormatInfo& info);
static bool IsCompressed(PixelFormatType format);
static bool IsConversionSupported(PixelFormatType srcFormat, PixelFormatType dstFormat);
static bool IsValid(PixelFormatType format);
static inline bool IsCompressed(PixelFormatType format);
static inline bool IsConversionSupported(PixelFormatType srcFormat, PixelFormatType dstFormat);
static inline bool IsValid(PixelFormatType format);
static void SetConvertFunction(PixelFormatType srcFormat, PixelFormatType dstFormat, ConvertFunction func);
static void SetFlipFunction(PixelFlipping flipping, PixelFormatType format, FlipFunction func);
static String ToString(PixelFormatType format);
static inline void SetConvertFunction(PixelFormatType srcFormat, PixelFormatType dstFormat, ConvertFunction func);
static inline void SetFlipFunction(PixelFlipping flipping, PixelFormatType format, FlipFunction func);
private:
static bool Initialize();
static void Uninitialize();
static NAZARA_UTILITY_API ConvertFunction s_convertFunctions[PixelFormatType_Max+1][PixelFormatType_Max+1];
static NAZARA_UTILITY_API std::map<PixelFormatType, FlipFunction> s_flipFunctions[PixelFlipping_Max+1];
static PixelFormatInfo s_pixelFormatInfos[PixelFormatType_Max + 1];
static ConvertFunction s_convertFunctions[PixelFormatType_Max+1][PixelFormatType_Max+1];
static std::map<PixelFormatType, FlipFunction> s_flipFunctions[PixelFlipping_Max+1];
};
}