diff options
| author | Jody Northup | 2009-06-15 09:45:19 +0000 |
|---|---|---|
| committer | Jody Northup | 2009-06-15 09:45:19 +0000 |
| commit | 8d306ebccfa7e88b2e4f4635bff3987e550f98d3 (patch) | |
| tree | 937afc4b40b3d38da4a67fcd13cef91c097097cb /graphics | |
| parent | e6f874ee9508a6631635504808680e50a4f55c7f (diff) | |
| download | scummvm-rg350-8d306ebccfa7e88b2e4f4635bff3987e550f98d3.tar.gz scummvm-rg350-8d306ebccfa7e88b2e4f4635bff3987e550f98d3.tar.bz2 scummvm-rg350-8d306ebccfa7e88b2e4f4635bff3987e550f98d3.zip | |
Added kUnsupportedColorMode error code brought Scumm engine and SDL backend into compliance with API outlined in http://scummvmupthorn09.wordpress.com/2009/06/14/how-this-is-going-to-work/
Provided convenient Graphics::PixelFormat constructors for ColorMode enums, and bitformat integers.
Removed last vestiges (I think) of initial cursor hack.
svn-id: r41539
Diffstat (limited to 'graphics')
| -rw-r--r-- | graphics/pixelformat.h | 110 | ||||
| -rw-r--r-- | graphics/scaler.cpp | 14 |
2 files changed, 124 insertions, 0 deletions
diff --git a/graphics/pixelformat.h b/graphics/pixelformat.h index fa5925b1f9..ef856e8735 100644 --- a/graphics/pixelformat.h +++ b/graphics/pixelformat.h @@ -76,6 +76,116 @@ struct PixelFormat { byte rLoss, gLoss, bLoss, aLoss; /**< Precision loss of each color component. */ byte rShift, gShift, bShift, aShift; /**< Binary left shift of each color component in the pixel value. */ +#ifdef ENABLE_16BIT + inline PixelFormat() { + bytesPerPixel = + rLoss = gLoss = bLoss = aLoss = + rShift = gShift = bShift = aShift = 0; + } + + inline PixelFormat(int BytesPerPixel, + int RLoss, int GLoss, int BLoss, int ALoss, + int RShift, int GShift, int BShift, int AShift) { + bytesPerPixel = BytesPerPixel; + rLoss = RLoss, gLoss = GLoss, bLoss = BLoss, aLoss = ALoss; + rShift = RShift, gShift = GShift, bShift = BShift, aShift = AShift; + } + + //Copy constructor + //Is this necessary? + inline PixelFormat(const PixelFormat &format) { + bytesPerPixel = format.bytesPerPixel; + + rLoss = format.rLoss; + gLoss = format.gLoss; + bLoss = format.bLoss; + aLoss = format.aLoss; + + rShift = format.rShift; + gShift = format.gShift; + bShift = format.bShift; + aShift = format.aShift; + } + + //Convenience constructor from bitformat number + //TODO: BGR support + //TODO: Specify alpha position +/* PixelFormat(int bitFormat) { + bytesPerPixel = ColorMasks<bitFormat>::kBytesPerPixel; + + rLoss = 8 - ColorMasks<bitFormat>::kRedBits; + gLoss = 8 - ColorMasks<bitFormat>::kGreenBits; + bLoss = 8 - ColorMasks<bitFormat>::kBlueBits; + aLoss = 8 - ColorMasks<bitFormat>::kAlphaBits; + + rShift = ColorMasks<bitFormat>::kRedShift; + gShift = ColorMasks<bitFormat>::kGreenShift; + bShift = ColorMasks<bitFormat>::kBlueShift; + aShift = ColorMasks<bitFormat>::kAlphaShift; + };*/ + + //Convenience constructor from enum type + //TODO: BGR support + //TODO: Specify alpha position + inline PixelFormat(ColorMode mode) { + switch (mode) { + case kFormatRGB555: + aLoss = 8; + bytesPerPixel = 2; + rLoss = gLoss = bLoss = 3; + break; + case kFormatXRGB1555: + //Special case, alpha bit is always high in this mode. + aLoss = 7; + bytesPerPixel = 2; + rLoss = gLoss = bLoss = 3; + bShift = 0; + gShift = bShift + bBits(); + rShift = gShift + gBits(); + aShift = rShift + rBits(); + //FIXME: there should be a clean way to handle setting + //up the color order without prematurely returning. + //This will probably be handled when alpha position specification is possible + return; + case kFormatRGB565: + bytesPerPixel = 2; + aLoss = 8; + gLoss = 2; + rLoss = bLoss = 3; + break; + case kFormatRGBA4444: + bytesPerPixel = 2; + aLoss = gLoss = rLoss = bLoss = 4; + break; + case kFormatRGB888: + bytesPerPixel = 3; + aLoss = 8; + gLoss = rLoss = bLoss = 0; + break; + case kFormatRGBA6666: + bytesPerPixel = 3; + aLoss = gLoss = rLoss = bLoss = 2; + break; + case kFormatRGBA8888: + bytesPerPixel = 4; + aLoss = gLoss = rLoss = bLoss = 0; + break; + case kFormatCLUT8: + default: + bytesPerPixel = 1; + rShift = gShift = bShift = aShift = 0; + rLoss = gLoss = bLoss = aLoss = 8; + return; + } + + aShift = 0; + bShift = aBits(); + gShift = bShift + bBits(); + rShift = gShift + gBits(); + return; + } +#endif + inline bool operator==(const PixelFormat &fmt) const { // TODO: If aLoss==8, then the value of aShift is irrelevant, and should be ignored. return 0 == memcmp(this, &fmt, sizeof(PixelFormat)); diff --git a/graphics/scaler.cpp b/graphics/scaler.cpp index 11767848ed..3a2643ff91 100644 --- a/graphics/scaler.cpp +++ b/graphics/scaler.cpp @@ -30,17 +30,31 @@ int gBitFormat = 565; +#ifdef ENABLE_16BIT +static const Graphics::PixelFormat gPixelFormat555( +#else static const Graphics::PixelFormat gPixelFormat555 = { +#endif 2, 3, 3, 3, 8, 10, 5, 0, 0 +#ifdef ENABLE_16BIT + ); + +static const Graphics::PixelFormat gPixelFormat565( +#else }; static const Graphics::PixelFormat gPixelFormat565 = { +#endif 2, 3, 2, 3, 8, 11, 5, 0, 0 +#ifdef ENABLE_16BIT + ); +#else }; +#endif |
