aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/graphics
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-08-07 16:49:20 +0200
committerEinar Johan Trøan Sømåen2012-08-07 16:49:20 +0200
commitd95a2ddef84bb786979affddd95074da79032560 (patch)
tree3d457daa96bef38fd5180a1b66d040eac856d0d2 /engines/wintermute/graphics
parent688f792c9f280a3cf1bb5b30149a05669ba4bfb5 (diff)
downloadscummvm-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')
-rw-r--r--engines/wintermute/graphics/transparent_surface.cpp62
-rw-r--r--engines/wintermute/graphics/transparent_surface.h5
2 files changed, 5 insertions, 62 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
diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h
index 20fd3c434e..5e70b63218 100644
--- a/engines/wintermute/graphics/transparent_surface.h
+++ b/engines/wintermute/graphics/transparent_surface.h
@@ -102,10 +102,9 @@ struct TransparentSurface : public Graphics::Surface {
uint color = BS_ARGB(255, 255, 255, 255),
int width = -1, int height = -1);
void applyColorKey(uint8 r, uint8 g, uint8 b, bool overwriteAlpha = false);
- TransparentSurface *scale(int xSize, int ySize) const;
// The following scale-code supports arbitrary scaling (i.e. no repeats of column 0 at the end of lines)
- TransparentSurface *scaleSafe(uint16 newWidth, uint16 newHeight) const;
- TransparentSurface *scaleSafe(const Common::Rect &srcRect, const Common::Rect &dstRect) const;
+ TransparentSurface *scale(uint16 newWidth, uint16 newHeight) const;
+ TransparentSurface *scale(const Common::Rect &srcRect, const Common::Rect &dstRect) const;
private:
static int *scaleLine(int size, int srcSize);
};