[Scummvm-cvs-logs] SF.net SVN: scummvm: [21970] scummvm/trunk/graphics/scaler.cpp

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Apr 17 04:12:01 CEST 2006


Revision: 21970
Author:   fingolfin
Date:     2006-04-17 04:11:07 -0700 (Mon, 17 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21970&view=rev

Log Message:
-----------
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.

Modified Paths:
--------------
    scummvm/trunk/graphics/scaler.cpp
Modified: scummvm/trunk/graphics/scaler.cpp
===================================================================
--- scummvm/trunk/graphics/scaler.cpp	2006-04-17 11:09:21 UTC (rev 21969)
+++ scummvm/trunk/graphics/scaler.cpp	2006-04-17 11:11:07 UTC (rev 21970)
@@ -73,46 +73,40 @@
 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;
+	
+	assert(T::kBytesPerPixel == 2);
 
-	for (int i = 0; i < 65536; i++) {
-		LUT16to32[i] = ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3);
-	}
+	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;
 
-	if (BitFormat == 565) {
-		gInc = 256 >> 6;
-		gShift = 6 - 3;
-	} else {
-		gInc = 256 >> 5;
-		gShift = 5 - 3;
+		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
 
-	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.


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list