aboutsummaryrefslogtreecommitdiff
path: root/common/scaler.cpp
diff options
context:
space:
mode:
authorMax Horn2003-09-27 23:59:09 +0000
committerMax Horn2003-09-27 23:59:09 +0000
commit1d40ce68c2fd93abdef86989ae534b124f175068 (patch)
tree76b264029090f9903eb5f2053e6736d449da68ac /common/scaler.cpp
parent4dcb829e78f969a4e492e9e777b51715c1309e9e (diff)
downloadscummvm-rg350-1d40ce68c2fd93abdef86989ae534b124f175068.tar.gz
scummvm-rg350-1d40ce68c2fd93abdef86989ae534b124f175068.tar.bz2
scummvm-rg350-1d40ce68c2fd93abdef86989ae534b124f175068.zip
get rid of explicit redMask/blueMask and use redBlueMask instead (this will be useful should we choose to templatize the scalers for 555/565 mode optimizations)
svn-id: r10451
Diffstat (limited to 'common/scaler.cpp')
-rw-r--r--common/scaler.cpp31
1 files changed, 13 insertions, 18 deletions
diff --git a/common/scaler.cpp b/common/scaler.cpp
index 082afc6d76..e0f17e22ea 100644
--- a/common/scaler.cpp
+++ b/common/scaler.cpp
@@ -39,9 +39,7 @@ static uint32 lowPixelMask = 0x08210821;
static uint32 qcolorMask = 0xE79CE79C;
static uint32 qlowpixelMask = 0x18631863;
static uint32 redblueMask = 0xF81F;
-static uint32 redMask = 0xF800;
static uint32 greenMask = 0x07E0;
-static uint32 blueMask = 0x001F;
static const uint16 dotmatrix_565[16] = {
0x01E0, 0x0007, 0x3800, 0x0000,
@@ -66,9 +64,7 @@ void InitScalers(uint32 BitFormat) {
qcolorMask = 0xE79CE79C;
qlowpixelMask = 0x18631863;
redblueMask = 0xF81F;
- redMask = 0xF800;
greenMask = 0x07E0;
- blueMask = 0x001F;
dotmatrix = dotmatrix_565;
} else if (BitFormat == 555) {
colorMask = 0x7BDE7BDE;
@@ -76,9 +72,7 @@ void InitScalers(uint32 BitFormat) {
qcolorMask = 0x739C739C;
qlowpixelMask = 0x0C630C63;
redblueMask = 0x7C1F;
- redMask = 0x7C00;
greenMask = 0x03E0;
- blueMask = 0x001F;
dotmatrix = dotmatrix_555;
} else {
error("Unknwon bit format %d\n", BitFormat);
@@ -5531,15 +5525,17 @@ void InitLUT(uint32 BitFormat) {
#if ASPECT_MODE == kSlowAndPerfectAspectMode
+
template<int scale>
static inline uint16 interpolate5(uint16 A, uint16 B) {
- uint16 r = (uint16)(((A & redMask) * scale + (B & redMask) * (5 - scale)) / 5);
+ uint16 r = (uint16)(((A & redblueMask & 0xFF00) * scale + (B & redblueMask & 0xFF00) * (5 - scale)) / 5);
uint16 g = (uint16)(((A & greenMask) * scale + (B & greenMask) * (5 - scale)) / 5);
- uint16 b = (uint16)(((A & blueMask) * scale + (B & blueMask) * (5 - scale)) / 5);
+ uint16 b = (uint16)(((A & redblueMask & 0x00FF) * scale + (B & redblueMask & 0x00FF) * (5 - scale)) / 5);
- return (uint16)((r & redMask) | (g & greenMask) | (b & blueMask));
+ return (uint16)((r & redblueMask & 0xFF00) | (g & greenMask) | (b & redblueMask & 0x00FF));
}
+
template<int scale>
static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint16 *srcB, int width) {
// Accurate but slightly slower code
@@ -5552,15 +5548,14 @@ static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint1
#if ASPECT_MODE == kFastAndNiceAspectMode
template<int scale>
static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint16 *srcB, int width) {
- // For efficiency reasons we blit two pixels at a time, so it is
- // important that makeRectStretchable() guarantees that the width is
- // even and that the rect starts on a well-aligned address. (Even
- // where unaligned memory access is allowed there may be a speed
- // penalty for it.)
-
- // These asserts are disabled for maximal speed; but I leave them in here in case
- // other people want to test if the memory alignment (to an address divisibl by 4)
- // are really effective.
+ // For efficiency reasons we blit two pixels at a time, so it is important
+ // that makeRectStretchable() guarantees that the width is even and that
+ // the rect starts on a well-aligned address. (Even where unaligned memory
+ // access is allowed there may be a speed penalty for it.)
+
+ // These asserts are disabled for maximal speed; but I leave them in here
+ // in case other people want to test if the memory alignment (to an
+ // address divisible by 4) is really working properly.
//assert(((int)dst & 3) == 0);
//assert(((int)srcA & 3) == 0);
//assert(((int)srcB & 3) == 0);