From 4431f40818f832e2cbae061927bdf59904cf5d3b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 3 Jun 2017 23:41:16 +0300 Subject: Imrove compound images update speed in software mode and fix memory leak. --- src/being/compoundsprite.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp index 4f5c6bf3e..ae62ead8f 100644 --- a/src/being/compoundsprite.cpp +++ b/src/being/compoundsprite.cpp @@ -366,20 +366,15 @@ void CompoundSprite::redraw() const delete2(graphics); - SDL_Surface *const surfaceA = MSDL_CreateRGBSurface(SDL_HWSURFACE, - BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask); - SDL_SetAlpha(surface, 0, SDL_ALPHA_OPAQUE); - SDL_BlitSurface(surface, nullptr, surfaceA, nullptr); - delete mImage; delete mAlphaImage; - mImage = imageHelper->loadSurface(surface); - MSDL_FreeSurface(surface); - if (ImageHelper::mEnableAlpha) { + SDL_Surface *const surfaceA = MSDL_CreateRGBSurface(SDL_HWSURFACE, + BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask); + SDL_BlitSurface(surface, nullptr, surfaceA, nullptr); mAlphaImage = imageHelper->loadSurface(surfaceA); MSDL_FreeSurface(surfaceA); } @@ -387,6 +382,10 @@ void CompoundSprite::redraw() const { mAlphaImage = nullptr; } + + delete mImage; + mImage = imageHelper->loadSurface(surface); + MSDL_FreeSurface(surface); #endif // USE_SDL2 } -- cgit v1.2.3-60-g2f50