[Scummvm-cvs-logs] CVS: scummvm/common scaler.cpp,1.13,1.14 scaler.h,1.8,1.9

Max Horn fingolfin at users.sourceforge.net
Sun May 25 05:09:02 CEST 2003


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

Modified Files:
	scaler.cpp scaler.h 
Log Message:
changed scaler proc signature so that srcPtr is const (this can help optimizer by simplifying aliasing detection; thanks to Bertrand Augereau for pointing this out)

Index: scaler.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/scaler.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- scaler.cpp	16 May 2003 00:11:35 -0000	1.13
+++ scaler.cpp	25 May 2003 12:08:01 -0000	1.14
@@ -155,8 +155,8 @@
 #define RED_MASK555 0x7C007C00
 #define GREEN_MASK555 0x03E003E0
 
-void Super2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
-	uint16 *bP;
+void Super2xSaI(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
+	const uint16 *bP;
 	uint8 *dP;
 	uint32 inc_bP;
 
@@ -165,7 +165,7 @@
 		inc_bP = 1;
 
 		while (height--) {
-			bP = (uint16 *)srcPtr;
+			bP = (const uint16 *)srcPtr;
 			dP = (uint8 *)dstPtr;
 
 			for (uint32 finish = width; finish; finish -= inc_bP) {
@@ -271,9 +271,9 @@
 	}
 }
 
-void SuperEagle(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
+void SuperEagle(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
 	uint8 *dP;
-	uint16 *bP;
+	const uint16 *bP;
 	uint32 inc_bP;
 
 	{
@@ -282,7 +282,7 @@
 		uint32 Nextline = srcPitch >> 1;
 
 		while (height--) {
-			bP = (uint16 *)srcPtr;
+			bP = (const uint16 *)srcPtr;
 			dP = dstPtr;
 			for (uint32 finish = width; finish; finish -= inc_bP) {
 				uint32 color4, color5, color6;
@@ -388,9 +388,9 @@
 	}
 }
 
-void _2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
+void _2xSaI(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
 	uint8 *dP;
-	uint16 *bP;
+	const uint16 *bP;
 	uint32 inc_bP;
 
 	{
@@ -399,7 +399,7 @@
 		uint32 Nextline = srcPitch >> 1;
 
 		while (height--) {
-			bP = (uint16 *)srcPtr;
+			bP = (const uint16 *)srcPtr;
 			dP = dstPtr;
 
 			for (uint32 finish = width; finish; finish -= inc_bP) {
@@ -582,10 +582,10 @@
 // FIXME: Scale_2xSaI is not used anywhere; however, contrary to the _2xSaI function,
 // it seems to allow for arbitrary scale factors, not just 2x... hence I leave this in
 // for now, as that seems to be a very useful feature
-void Scale_2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
+void Scale_2xSaI(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
 								 uint32 dstWidth, uint32 dstHeight, int width, int height) {
 	uint8 *dP;
-	uint16 *bP;
+	const uint16 *bP;
 
 	uint32 w;
 	uint32 h;
@@ -605,7 +605,7 @@
 		uint32 y1, y2;
 
 		y1 = h & 0xffff;						// fraction part of fixed point
-		bP = (uint16 *)(srcPtr + ((h >> 16) * srcPitch));
+		bP = (const uint16 *)(srcPtr + ((h >> 16) * srcPitch));
 		dP = dstPtr;
 		y2 = 0x10000 - y1;
 
@@ -713,10 +713,10 @@
 	}
 }
 
-void AdvMame2x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
+void AdvMame2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
 							 int width, int height) {
 	unsigned int nextlineSrc = srcPitch / sizeof(uint16);
-	uint16 *p = (uint16 *)srcPtr;
+	const uint16 *p = (const uint16 *)srcPtr;
 
 	unsigned int nextlineDst = dstPitch / sizeof(uint16);
 	uint16 *q = (uint16 *)dstPtr;
@@ -749,10 +749,10 @@
 	}
 }
 
-void AdvMame3x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
+void AdvMame3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
 							 int width, int height) {
 	unsigned int nextlineSrc = srcPitch / sizeof(uint16);
-	uint16 *p = (uint16 *)srcPtr;
+	const uint16 *p = (const uint16 *)srcPtr;
 
 	unsigned int nextlineDst = dstPitch / sizeof(uint16);
 	uint16 *q = (uint16 *)dstPtr;
@@ -790,7 +790,7 @@
 	}
 }
 
-void Normal1x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
+void Normal1x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
 							int width, int height) {
 	while (height--) {
 		memcpy(dstPtr, srcPtr, 2 * width);
@@ -799,14 +799,14 @@
 	}
 }
 
-void Normal2x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
+void Normal2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
 							int width, int height) {
 	uint8 *r;
 
 	while (height--) {
 		r = dstPtr;
 		for (int i = 0; i < width; ++i, r += 4) {
-			uint16 color = *(((uint16 *)srcPtr) + i);
+			uint16 color = *(((const uint16 *)srcPtr) + i);
 
 			*(uint16 *)(r + 0) = color;
 			*(uint16 *)(r + 2) = color;
@@ -818,7 +818,7 @@
 	}
 }
 
-void Normal3x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
+void Normal3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
 							int width, int height) {
 	uint8 *r;
 	uint32 dstPitch2 = dstPitch * 2;
@@ -827,7 +827,7 @@
 	while (height--) {
 		r = dstPtr;
 		for (int i = 0; i < width; ++i, r += 6) {
-			uint16 color = *(((uint16 *)srcPtr) + i);
+			uint16 color = *(((const uint16 *)srcPtr) + i);
 
 			*(uint16 *)(r + 0) = color;
 			*(uint16 *)(r + 2) = color;
@@ -844,10 +844,10 @@
 	}
 }
 
-void TV2x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, 
+void TV2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, 
 					int width, int height) {
 	unsigned int nextlineSrc = srcPitch / sizeof(uint16);
-	uint16 *p = (uint16 *)srcPtr;
+	const uint16 *p = (const uint16 *)srcPtr;
 
 	unsigned int nextlineDst = dstPitch / sizeof(uint16);
 	uint16 *q = (uint16 *)dstPtr;
@@ -874,11 +874,11 @@
   return c - ((c >> 2) & *(dotmatrix + ((j & 3) << 2) + (i & 3)));
 }
 
-void DotMatrix(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
+void DotMatrix(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
 					int width, int height)
 {
 	unsigned int nextlineSrc = srcPitch / sizeof(uint16);
-	uint16 *p = (uint16 *)srcPtr;
+	const uint16 *p = (const uint16 *)srcPtr;
 
 	unsigned int nextlineDst = dstPitch / sizeof(uint16);
 	uint16 *q = (uint16 *)dstPtr;

Index: scaler.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/scaler.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- scaler.h	9 May 2003 22:44:16 -0000	1.8
+++ scaler.h	25 May 2003 12:08:01 -0000	1.9
@@ -23,8 +23,11 @@
 
 extern int Init_2xSaI (uint32 BitFormat);
 
+typedef void ScalerProc(const uint8 *srcPtr, uint32 srcPitch,
+							uint8 *dstPtr, uint32 dstPitch, int width, int height);
+
 #define DECLARE_SCALER(x)	\
-	extern void x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, \
+	extern void x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, \
 					uint32 dstPitch, int width, int height)
 
 DECLARE_SCALER(_2xSaI);





More information about the Scummvm-git-logs mailing list