aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/graphics
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2013-10-05 00:05:25 +0200
committerWillem Jan Palenstijn2013-10-05 00:10:09 +0200
commit0e2cf28d99a79a9ae84a4d48cf0e607deacb6653 (patch)
treee318153fa039a222362e210eaa7f109b76428d73 /engines/wintermute/graphics
parentb90e76f21f6cbbfd11ac266748789c1396383710 (diff)
downloadscummvm-rg350-0e2cf28d99a79a9ae84a4d48cf0e607deacb6653.tar.gz
scummvm-rg350-0e2cf28d99a79a9ae84a4d48cf0e607deacb6653.tar.bz2
scummvm-rg350-0e2cf28d99a79a9ae84a4d48cf0e607deacb6653.zip
WINTERMUTE: Speed up scale()
This is a tweaked version of a patch from eriktorbjorn.
Diffstat (limited to 'engines/wintermute/graphics')
-rw-r--r--engines/wintermute/graphics/transparent_surface.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index b03bc4264b..64102d7eb0 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -715,20 +715,28 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
target->create((uint16)dstW, (uint16)dstH, this->format);
-
- float projX;
- float projY;
+#if ENABLE_BILINEAR
for (int y = 0; y < dstH; y++) {
+ float projY = y / (float)dstH * srcH;
for (int x = 0; x < dstW; x++) {
- projX = x / (float)dstW * srcW;
- projY = y / (float)dstH * srcH;
-#if ENABLE_BILINEAR
+ float projX = x / (float)dstW * srcW;
copyPixelBilinear(projX, projY, x, y, srcRect, dstRect, this, target);
-#else
- copyPixelNearestNeighbor(projX, projY, x, y, srcRect, dstRect, this, target);
-#endif
}
}
+#else
+ int *scaleCacheX = new int[dstW];
+ for (int x = 0; x < dstW; x++)
+ scaleCacheX[x] = (x * srcW) / dstW;
+
+ for (int y = 0; y < dstH; y++) {
+ uint32 *destP = (uint32 *)target->getBasePtr(0, y);
+ const uint32 *srcP = (const uint32 *)getBasePtr(0, (y * srcH) / dstH);
+ for (int x = 0; x < dstW; x++)
+ *destP++ = srcP[scaleCacheX[x]];
+ }
+ delete[] scaleCacheX;
+#endif
+
return target;
}