[Scummvm-cvs-logs] CVS: scummvm/common scaler.cpp,1.47,1.48

Max Horn fingolfin at users.sourceforge.net
Mon Sep 29 11:40:03 CEST 2003


Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv5779

Modified Files:
	scaler.cpp 
Log Message:
templatized more of the scalers; also introduced template struct ColorMasks (shortens/simplifies other code a bit)

Index: scaler.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/scaler.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- scaler.cpp	29 Sep 2003 16:02:46 -0000	1.47
+++ scaler.cpp	29 Sep 2003 18:38:51 -0000	1.48
@@ -23,24 +23,8 @@
 #include "common/scaler/intern.h"
 
 
-// TODO: get rid of the colorMask etc. variables and instead use templates.
-// This should give a respectable boost, since variable access (i.e. memory reads)
-// in the innermost loops of our operations would work with constant data instead.
-// That should help the inliner; reduce memory access; thus improve cache efficeny
-// etc. The drawback will be that each scaler will exist twice, once for 555 and
-// once for 555, resulting in the object file being twice as big (but thanks to
-// templates, no source code would be duplicated.
-
-
 int gBitFormat = 565;
 
-uint32 colorMask = 0xF7DEF7DE;
-uint32 lowPixelMask = 0x08210821;
-uint32 qcolorMask = 0xE79CE79C;
-uint32 qlowpixelMask = 0x18631863;
-static uint32 redblueMask = redblueMask_565;
-static uint32 greenMask = greenMask_565;
-
 // RGB-to-YUV lookup table
 int   RGBtoYUV[65536];
 
@@ -62,20 +46,8 @@
 
 void InitScalers(uint32 BitFormat) {
 	if (BitFormat == 565) {
-		colorMask = 0xF7DEF7DE;
-		lowPixelMask = 0x08210821;
-		qcolorMask = 0xE79CE79C;
-		qlowpixelMask = 0x18631863;
-		redblueMask = redblueMask_565;
-		greenMask = greenMask_565;
 		dotmatrix = dotmatrix_565;
 	} else if (BitFormat == 555) {
-		colorMask = 0x7BDE7BDE;
-		lowPixelMask = 0x04210421;
-		qcolorMask = 0x739C739C;
-		qlowpixelMask = 0x0C630C63;
-		redblueMask = redblueMask_555;
-		greenMask = greenMask_555;
 		dotmatrix = dotmatrix_555;
 	} else {
 		error("Unknwon bit format %d\n", BitFormat);
@@ -261,6 +233,7 @@
 	}
 }
 
+template<int bitFormat>
 void TV2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, 
 					int width, int height) {
 	const uint32 nextlineSrc = srcPitch / sizeof(uint16);
@@ -286,6 +259,7 @@
 		q += nextlineDst << 1;
 	}
 }
+MAKE_WRAPPER(TV2x)
 
 static inline uint16 DOT_16(uint16 c, int j, int i) {
   return c - ((c >> 2) & *(dotmatrix + ((j & 3) << 2) + (i & 3)));





More information about the Scummvm-git-logs mailing list