diff options
author | Max Horn | 2006-04-17 11:11:07 +0000 |
---|---|---|
committer | Max Horn | 2006-04-17 11:11:07 +0000 |
commit | 35a2fc402811b1dd047d62e571164f3d50d86393 (patch) | |
tree | f7e9d529ae4f52a9e7cc8ac348bb2fbcedc91a16 | |
parent | 2732ed3dcec40664a988c6ca43fff7996781624e (diff) | |
download | scummvm-rg350-35a2fc402811b1dd047d62e571164f3d50d86393.tar.gz scummvm-rg350-35a2fc402811b1dd047d62e571164f3d50d86393.tar.bz2 scummvm-rg350-35a2fc402811b1dd047d62e571164f3d50d86393.zip |
Modify InitLUT to make use of ColorMasks, making it easier to add support for other color modes eventually. This also fixes the computation of LUT16to32 which so far always assumed 565 mode.
svn-id: r21970
-rw-r--r-- | graphics/scaler.cpp | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/graphics/scaler.cpp b/graphics/scaler.cpp index 3311ba22e2..1853742ce2 100644 --- a/graphics/scaler.cpp +++ b/graphics/scaler.cpp @@ -73,46 +73,40 @@ uint RGBtoYUVstorage[65536]; uint *RGBtoYUV = RGBtoYUVstorage; uint LUT16to32[65536]; } -#endif - -static void InitLUT(uint32 BitFormat); -void InitScalers(uint32 BitFormat) { - gBitFormat = BitFormat; - InitLUT(gBitFormat); -} - -void InitLUT(uint32 BitFormat) { -#ifndef DISABLE_HQ_SCALERS +template<class T> +void InitLUT() { int r, g, b; int Y, u, v; - int gInc, gShift; - - for (int i = 0; i < 65536; i++) { - LUT16to32[i] = ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3); + + assert(T::kBytesPerPixel == 2); + + for (int color = 0; color < 65536; ++color) { + r = ((color & T::kRedMask) >> T::kRedShift) << (8 - T::kRedBits); + g = ((color & T::kGreenMask) >> T::kGreenShift) << (8 - T::kGreenBits); + b = ((color & T::kBlueMask) >> T::kBlueShift) << (8 - T::kBlueBits); + LUT16to32[color] = (r << 16) | (g << 8) | b; + + Y = (r + g + b) >> 2; + u = 128 + ((r - b) >> 2); + v = 128 + ((-r + 2 * g - b) >> 3); + RGBtoYUV[color] = (Y << 16) | (u << 8) | v; } +} +#endif - if (BitFormat == 565) { - gInc = 256 >> 6; - gShift = 6 - 3; - } else { - gInc = 256 >> 5; - gShift = 5 - 3; - } - for (r = 0; r < 256; r += 8) { - for (g = 0; g < 256; g += gInc) { - for (b = 0; b < 256; b += 8) { - Y = (r + g + b) >> 2; - u = 128 + ((r - b) >> 2); - v = 128 + ((-r + 2 * g - b) >> 3); - RGBtoYUV[ (r << (5 + gShift)) + (g << gShift) + (b >> 3) ] = (Y << 16) + (u << 8) + v; - } - } - } +void InitScalers(uint32 BitFormat) { + gBitFormat = BitFormat; +#ifndef DISABLE_HQ_SCALERS + if (gBitFormat == 555) + InitLUT<ColorMasks<555> >(); + if (gBitFormat == 565) + InitLUT<ColorMasks<565> >(); #endif } + /** * Trivial 'scaler' - in fact it doesn't do any scaling but just copies the * source to the destionation. |