Skip to content

Commit

Permalink
GRAPHICS: Fix big leak when blitting macgui borders
Browse files Browse the repository at this point in the history
  • Loading branch information
Borja Lorente committed Aug 25, 2016
1 parent 9444a18 commit 5bba089
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion graphics/macgui/macwindow.cpp
Expand Up @@ -336,7 +336,6 @@ void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, int lo
_macBorder.setOffsets(lo, ro, to, bo);

updateInnerDims();
source.free();
}

void MacWindow::setCloseable(bool closeable) {
Expand Down
1 change: 1 addition & 0 deletions graphics/macgui/macwindowborder.cpp
Expand Up @@ -112,6 +112,7 @@ void MacWindowBorder::blitBorderInto(ManagedSurface &destination, bool active) {

src->blit(srf, 0, 0, srf.w, srf.h, palette, kColorCount);
destination.transBlitFrom(srf, kColorGreen2);
srf.free();
}

} // End of namespace Graphics
15 changes: 9 additions & 6 deletions graphics/nine_patch.cpp
Expand Up @@ -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;
}

Expand Down

0 comments on commit 5bba089

Please sign in to comment.