aboutsummaryrefslogtreecommitdiff
path: root/graphics/nine_patch.cpp
diff options
context:
space:
mode:
authorBorja Lorente2016-08-25 13:21:42 +0200
committerBorja Lorente2016-08-25 13:26:02 +0200
commit5bba0897246de34318ac6049402b9d5f58722aa4 (patch)
tree7f0186b84af726b635559c29ee09981fc5af880b /graphics/nine_patch.cpp
parent9444a1864b8a12b1f0c0495e7a948db250870137 (diff)
downloadscummvm-rg350-5bba0897246de34318ac6049402b9d5f58722aa4.tar.gz
scummvm-rg350-5bba0897246de34318ac6049402b9d5f58722aa4.tar.bz2
scummvm-rg350-5bba0897246de34318ac6049402b9d5f58722aa4.zip
GRAPHICS: Fix big leak when blitting macgui borders
Diffstat (limited to 'graphics/nine_patch.cpp')
-rw-r--r--graphics/nine_patch.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/graphics/nine_patch.cpp b/graphics/nine_patch.cpp
index fa2ef20a6e..9cee90864a 100644
--- a/graphics/nine_patch.cpp
+++ b/graphics/nine_patch.cpp
@@ -230,25 +230,28 @@ void NinePatchBitmap::blit(Graphics::Surface &target, int dx, int dy, int dw, in
if (!palette)
warning("Trying to blit into a surface with 1bpp, you need the palette.");
- Surface srf;
- srf.create(target.w, target.h, _bmp->format);
+ Surface *srf = new Surface();
+ srf->create(target.w, target.h, _bmp->format);
- drawRegions(srf, dx, dy, dw, dh);
+ drawRegions(*srf, dx, dy, dw, dh);
//TODO: This can be further optimized by keeping the data between draws,
// and using a unique identifier for each palette, so that it only gets
// recalculated when the palette changes.
_cached_colors.clear();
- for (uint i = 0; i < srf.w; ++i) {
- for (uint j = 0; j < srf.h; ++j) {
- uint32 color = *(uint32*)srf.getBasePtr(i, j);
+ for (uint i = 0; i < srf->w; ++i) {
+ for (uint j = 0; j < srf->h; ++j) {
+ uint32 color = *(uint32*)srf->getBasePtr(i, j);
if (color > 0) {
*((byte *)target.getBasePtr(i, j)) = closestGrayscale(color, palette, numColors);
}
}
}
+ srf->free();
+ delete srf;
+
return;
}