diff options
author | Einar Johan Trøan Sømåen | 2012-08-07 16:49:20 +0200 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2012-08-07 16:49:20 +0200 |
commit | d95a2ddef84bb786979affddd95074da79032560 (patch) | |
tree | 3d457daa96bef38fd5180a1b66d040eac856d0d2 /engines/wintermute/graphics/transparent_surface.cpp | |
parent | 688f792c9f280a3cf1bb5b30149a05669ba4bfb5 (diff) | |
download | scummvm-rg350-d95a2ddef84bb786979affddd95074da79032560.tar.gz scummvm-rg350-d95a2ddef84bb786979affddd95074da79032560.tar.bz2 scummvm-rg350-d95a2ddef84bb786979affddd95074da79032560.zip |
WINTERMUTE: Use only one scaler for blitting, the faster one.
Diffstat (limited to 'engines/wintermute/graphics/transparent_surface.cpp')
-rw-r--r-- | engines/wintermute/graphics/transparent_surface.cpp | 62 |
1 files changed, 3 insertions, 59 deletions
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index 5faf313207..1662ff19af 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -369,14 +369,14 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p return retSize; } -TransparentSurface *TransparentSurface::scaleSafe(uint16 newWidth, uint16 newHeight) const { +TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight) const { Common::Rect srcRect(0, 0, (int16)w, (int16)h); Common::Rect dstRect(0, 0, (int16)newWidth, (int16)newHeight); - return scaleSafe(srcRect, dstRect); + return scale(srcRect, dstRect); } // Copied from clone2727's https://github.com/clone2727/scummvm/blob/pegasus/engines/pegasus/surface.cpp#L247 -TransparentSurface *TransparentSurface::scaleSafe(const Common::Rect &srcRect, const Common::Rect &dstRect) const { +TransparentSurface *TransparentSurface::scale(const Common::Rect &srcRect, const Common::Rect &dstRect) const { // I'm doing simple linear scaling here // dstRect(x, y) = srcRect(x * srcW / dstW, y * srcH / dstH); TransparentSurface *target = new TransparentSurface(); @@ -398,37 +398,6 @@ TransparentSurface *TransparentSurface::scaleSafe(const Common::Rect &srcRect, c return target; } -/** - * Scales a passed surface, creating a new surface with the result - * @param xSize target width. - * @param ySize target height. - * @remarks Caller is responsible for freeing the returned surface - */ -TransparentSurface *TransparentSurface::scale(int xSize, int ySize) const { - TransparentSurface *s = new TransparentSurface(); - s->create(xSize, ySize, this->format); - - int *horizUsage = scaleLine(xSize, this->w); - int *vertUsage = scaleLine(ySize, this->h); - - // Loop to create scaled version - for (int yp = 0; yp < ySize; ++yp) { - const byte *srcP = (const byte *)this->getBasePtr(0, vertUsage[yp]); - byte *destP = (byte *)s->getBasePtr(0, yp); - - for (int xp = 0; xp < xSize; ++xp) { - const byte *tempSrcP = srcP + (horizUsage[xp] * this->format.bytesPerPixel); - for (int byteCtr = 0; byteCtr < this->format.bytesPerPixel; ++byteCtr) { - *destP++ = *tempSrcP++; - } - } - } - - // Delete arrays and return surface - delete[] horizUsage; - delete[] vertUsage; - return s; -} /** * Writes a color key to the alpha channel of the surface @@ -455,29 +424,4 @@ void TransparentSurface::applyColorKey(uint8 rKey, uint8 gKey, uint8 bKey, bool } } -/** - * Returns an array indicating which pixels of a source image horizontally or vertically get - * included in a scaled image - */ -int *TransparentSurface::scaleLine(int size, int srcSize) { - int scale = 100 * size / srcSize; - assert(scale > 0); - int *v = new int[size]; - Common::fill(v, &v[size], 0); - - int distCtr = 0; - int *destP = v; - for (int distIndex = 0; distIndex < srcSize; ++distIndex) { - distCtr += scale; - while (distCtr >= 100) { - assert(destP < &v[size]); - *destP++ = distIndex; - distCtr -= 100; - } - } - - return v; -} - - } // End of namespace Graphics |