aboutsummaryrefslogtreecommitdiff
path: root/graphics/scaler
diff options
context:
space:
mode:
authorEric Culp2012-06-19 17:28:02 -0400
committerFilippos Karapetis2019-04-01 00:29:23 +0300
commit3d57c13af02dcd054c625f2adbd4347e20516814 (patch)
treeacdc4805924caf6010acdff9aaa4c9a93a3b0068 /graphics/scaler
parentc6ee138b74cf738d3aeabaa2176355ece81712f8 (diff)
downloadscummvm-rg350-3d57c13af02dcd054c625f2adbd4347e20516814.tar.gz
scummvm-rg350-3d57c13af02dcd054c625f2adbd4347e20516814.tar.bz2
scummvm-rg350-3d57c13af02dcd054c625f2adbd4347e20516814.zip
GRAPHICS: Add dummy specializations for some interpolate* functions
They use ColorMask values not present in 2-byte ColorMasks. Since they should never be used on 2-byte pixel data, the dummy implementations assert(0) and should be removed by any optimizing compiler since no code path can ever reach them.
Diffstat (limited to 'graphics/scaler')
-rw-r--r--graphics/scaler/intern.h43
1 files changed, 33 insertions, 10 deletions
diff --git a/graphics/scaler/intern.h b/graphics/scaler/intern.h
index 8ec7249263..4a832801ea 100644
--- a/graphics/scaler/intern.h
+++ b/graphics/scaler/intern.h
@@ -101,14 +101,14 @@ static inline uint32 interpolate32_7_1(uint32 p1, uint32 p2) {
*/
template<typename ColorMask>
static inline uint32 interpolate32_2_1_1(uint32 p1, uint32 p2, uint32 p3) {
- uint32 x = ((p1 & ColorMask::qHighBitsMask) >> 1)
- + ((p2 & ColorMask::qHighBitsMask) >> 2)
- + ((p3 & ColorMask::qHighBitsMask) >> 2);
- uint32 y = ((p1 & ColorMask::qLowBitsMask) << 1)
- + (p2 & ColorMask::qLowBitsMask)
- + (p2 & ColorMask::qLowBitsMask);
+ uint32 x = ((p1 & ColorMask::qhighBits) >> 1)
+ + ((p2 & ColorMask::qhighBits) >> 2)
+ + ((p3 & ColorMask::qhighBits) >> 2);
+ uint32 y = ((p1 & ColorMask::qlowBits) << 1)
+ + (p2 & ColorMask::qlowBits)
+ + (p2 & ColorMask::qlowBits);
y >>= 2;
- y &= ColorMask::qLowBits;
+ y &= ColorMask::qlowBits;
return x + y;
}
@@ -172,7 +172,7 @@ static inline uint32 interpolate32_2_3_3(uint32 p1, uint32 p2, uint32 p3) {
* @see interpolate32_3_1 for similar method
*/
template<typename ColorMask>
-static inline uint32 interpolate32_2_7_7(uint32 p1, uint32 p2, uint32 p3) {
+inline uint32 interpolate32_2_7_7(uint32 p1, uint32 p2, uint32 p3) {
uint32 x = ((p1 & ~ColorMask::kLow4Bits) >> 3)
+ (((p2 & ~ColorMask::kLow4Bits) >> 4)
+ ((p3 & ~ColorMask::kLow4Bits) >> 4)) * 7;
@@ -184,17 +184,28 @@ static inline uint32 interpolate32_2_7_7(uint32 p1, uint32 p2, uint32 p3) {
return x + y;
}
+// Dummy specializations.
+template<>
+inline uint32 interpolate32_2_7_7<Graphics::ColorMasks<555> >(uint32 p1, uint32 p2, uint32 p3) {
+ assert(0);
+}
+
+template<>
+inline uint32 interpolate32_2_7_7<Graphics::ColorMasks<565> >(uint32 p1, uint32 p2, uint32 p3) {
+ assert(0);
+}
+
/**
* Interpolate three 32 bit pixels with weights 14, 1, and 1, i.e., (14*p1+p2+p3)/16.
*
* @see interpolate32_3_1 for similar method
*/
template<typename ColorMask>
-static inline uint32 interpolate32_14_1_1(uint32 p1, uint32 p2, uint32 p3) {
+inline uint32 interpolate32_14_1_1(uint32 p1, uint32 p2, uint32 p3) {
uint32 x = ((p1 & ~ColorMask::kLow4Bits) >> 4) * 14
+ ((p2 & ~ColorMask::kLow4Bits) >> 4)
+ ((p3 & ~ColorMask::kLow4Bits) >> 4);
- uint32 y = (p1 & ColorMask::kLow4Bits) * 14;
+ uint32 y = (p1 & ColorMask::kLow4Bits) * 14
+ (p2 & ColorMask::kLow4Bits)
+ (p2 & ColorMask::kLow4Bits);
y >>= 4;
@@ -202,6 +213,18 @@ static inline uint32 interpolate32_14_1_1(uint32 p1, uint32 p2, uint32 p3) {
return x + y;
}
+
+// Dummy specializations.
+template<>
+inline uint32 interpolate32_14_1_1<Graphics::ColorMasks<555> >(uint32 p1, uint32 p2, uint32 p3) {
+ assert(0);
+}
+
+template<>
+inline uint32 interpolate32_14_1_1<Graphics::ColorMasks<565> >(uint32 p1, uint32 p2, uint32 p3) {
+ assert(0);
+}
+
/**
* Interpolate four 32 bit pixels with weights 1, 1, 1, and 1, i.e., (p1+p2+p3+p4)/4.
*