aboutsummaryrefslogtreecommitdiff
path: root/graphics/scaler
diff options
context:
space:
mode:
authorThierry Crozat2018-10-21 18:35:40 +0100
committerThierry Crozat2018-10-24 23:34:41 +0200
commit3b542cea53b94bc10592a618f60c4f813e518b60 (patch)
tree1a425d7228c2140611b720e89ff7ba26c6fbbbed /graphics/scaler
parent2aa7f71fc0be2d1776213fda79ea850c6547bbe5 (diff)
downloadscummvm-rg350-3b542cea53b94bc10592a618f60c4f813e518b60.tar.gz
scummvm-rg350-3b542cea53b94bc10592a618f60c4f813e518b60.tar.bz2
scummvm-rg350-3b542cea53b94bc10592a618f60c4f813e518b60.zip
SURFACESDL: Respect filtering setting when performing aspect ratio correction
Diffstat (limited to 'graphics/scaler')
-rw-r--r--graphics/scaler/aspect.cpp50
-rw-r--r--graphics/scaler/aspect.h6
2 files changed, 41 insertions, 15 deletions
diff --git a/graphics/scaler/aspect.cpp b/graphics/scaler/aspect.cpp
index b923442163..f85d043a83 100644
--- a/graphics/scaler/aspect.cpp
+++ b/graphics/scaler/aspect.cpp
@@ -158,8 +158,10 @@ static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint1
}
#endif
-void makeRectStretchable(int &x, int &y, int &w, int &h) {
+void makeRectStretchable(int &x, int &y, int &w, int &h, bool interpolate) {
#if ASPECT_MODE != kSuperFastAndUglyAspectMode
+ if (!interpolate)
+ return;
int m = real2Aspect(y) % 6;
// Ensure that the rect will start on a line that won't have its
@@ -203,8 +205,9 @@ void makeRectStretchable(int &x, int &y, int &w, int &h) {
* srcY + height - 1, and it should be stretched to Y coordinates srcY
* through real2Aspect(srcY + height - 1).
*/
+
template<typename ColorMask>
-int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY) {
+int stretch200To240Nearest(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY) {
int maxDstY = real2Aspect(origSrcY + height - 1);
int y;
const uint8 *startSrcPtr = buf + srcX * 2 + (srcY - origSrcY) * pitch;
@@ -212,13 +215,25 @@ int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, i
for (y = maxDstY; y >= srcY; y--) {
const uint8 *srcPtr = startSrcPtr + aspect2Real(y) * pitch;
-
-#if ASPECT_MODE == kSuperFastAndUglyAspectMode
if (srcPtr == dstPtr)
break;
memcpy(dstPtr, srcPtr, sizeof(uint16) * width);
-#else
- // Bilinear filter
+ dstPtr -= pitch;
+ }
+
+ return 1 + maxDstY - srcY;
+}
+
+
+template<typename ColorMask>
+int stretch200To240Interpolated(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY) {
+ int maxDstY = real2Aspect(origSrcY + height - 1);
+ int y;
+ const uint8 *startSrcPtr = buf + srcX * 2 + (srcY - origSrcY) * pitch;
+ uint8 *dstPtr = buf + srcX * 2 + maxDstY * pitch;
+
+ for (y = maxDstY; y >= srcY; y--) {
+ const uint8 *srcPtr = startSrcPtr + aspect2Real(y) * pitch;
switch (y % 6) {
case 0:
case 5:
@@ -238,22 +253,31 @@ int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, i
interpolate5Line<ColorMask, 1>((uint16 *)dstPtr, (const uint16 *)srcPtr, (const uint16 *)(srcPtr - pitch), width);
break;
}
-#endif
dstPtr -= pitch;
}
return 1 + maxDstY - srcY;
}
-int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY) {
+int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY, bool interpolate) {
extern int gBitFormat;
- if (gBitFormat == 565)
- return stretch200To240<Graphics::ColorMasks<565> >(buf, pitch, width, height, srcX, srcY, origSrcY);
- else // gBitFormat == 555
- return stretch200To240<Graphics::ColorMasks<555> >(buf, pitch, width, height, srcX, srcY, origSrcY);
+#if ASPECT_MODE != kSuperFastAndUglyAspectMode
+ if (interpolate) {
+ if (gBitFormat == 565)
+ return stretch200To240Interpolated<Graphics::ColorMasks<565> >(buf, pitch, width, height, srcX, srcY, origSrcY);
+ else // gBitFormat == 555
+ return stretch200To240Interpolated<Graphics::ColorMasks<555> >(buf, pitch, width, height, srcX, srcY, origSrcY);
+ } else {
+#endif
+ if (gBitFormat == 565)
+ return stretch200To240Nearest<Graphics::ColorMasks<565> >(buf, pitch, width, height, srcX, srcY, origSrcY);
+ else // gBitFormat == 555
+ return stretch200To240Nearest<Graphics::ColorMasks<555> >(buf, pitch, width, height, srcX, srcY, origSrcY);
+#if ASPECT_MODE != kSuperFastAndUglyAspectMode
+ }
+#endif
}
-
template<typename ColorMask>
void Normal1xAspectTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
diff --git a/graphics/scaler/aspect.h b/graphics/scaler/aspect.h
index 30e13c93cd..bb082ebba0 100644
--- a/graphics/scaler/aspect.h
+++ b/graphics/scaler/aspect.h
@@ -43,18 +43,20 @@ FORCEINLINE int aspect2Real(int y) {
/**
* TODO: explain
*/
-void makeRectStretchable(int &x, int &y, int &w, int &h);
+void makeRectStretchable(int &x, int &y, int &w, int &h, bool interpolate);
/**
* TODO: explain
*/
+
int stretch200To240(uint8 *buf,
uint32 pitch,
int width,
int height,
int srcX,
int srcY,
- int origSrcY);
+ int origSrcY,
+ bool interpolate);
/**