aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2003-05-25 12:08:01 +0000
committerMax Horn2003-05-25 12:08:01 +0000
commit9b70fee5f39d02b3ea99c9aef4519f00ea433a58 (patch)
treedaa052515ac117e8e6fceae69016e6bd338611e6 /common
parente827a569d2cb7936bd01b349e788fabd5c244f41 (diff)
downloadscummvm-rg350-9b70fee5f39d02b3ea99c9aef4519f00ea433a58.tar.gz
scummvm-rg350-9b70fee5f39d02b3ea99c9aef4519f00ea433a58.tar.bz2
scummvm-rg350-9b70fee5f39d02b3ea99c9aef4519f00ea433a58.zip
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)
svn-id: r7939
Diffstat (limited to 'common')
-rw-r--r--common/scaler.cpp50
-rw-r--r--common/scaler.h5
2 files changed, 29 insertions, 26 deletions
diff --git a/common/scaler.cpp b/common/scaler.cpp
index aef1d07ffe..9c8e471965 100644
--- a/common/scaler.cpp
+++ b/common/scaler.cpp
@@ -155,8 +155,8 @@ static inline uint32 Q_INTERPOLATE(uint32 A, uint32 B, uint32 C, uint32 D) {
#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 @@ void Super2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
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 Super2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
}
}
-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 @@ void SuperEagle(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
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 SuperEagle(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
}
}
-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 @@ void _2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int
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 @@ static uint32 Bilinear4(uint32 A, uint32 B, uint32 C, uint32 D, uint32 x, uint32
// 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 @@ void Scale_2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
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 Scale_2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
}
}
-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 AdvMame2x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
}
}
-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 AdvMame3x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
}
}
-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 Normal1x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
}
}
-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 Normal2x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
}
}
-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 @@ void Normal3x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
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 Normal3x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
}
}
-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 @@ static inline uint16 DOT_16(uint16 c, int j, int i) {
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;
diff --git a/common/scaler.h b/common/scaler.h
index 668b02cb95..a743ee063e 100644
--- a/common/scaler.h
+++ b/common/scaler.h
@@ -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);