Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WINTERMUTE: Speed up scale()
This is a tweaked version of a patch from eriktorbjorn.
  • Loading branch information
wjp committed Oct 4, 2013
1 parent b90e76f commit 0e2cf28
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions engines/wintermute/graphics/transparent_surface.cpp
Expand Up @@ -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;

}
Expand Down

0 comments on commit 0e2cf28

Please sign in to comment.