From f35618999fbdf13535e6d93ddd3fb45ff0e5fef3 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 5 Jan 2023 12:23:34 -0800 Subject: [PATCH] Allocate to the size of source surface instead Otherwise it will slow down since the destination surface is usually pretty big. --- desktop_version/src/GraphicsUtil.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/desktop_version/src/GraphicsUtil.cpp b/desktop_version/src/GraphicsUtil.cpp index 1822ee76..845d7de5 100644 --- a/desktop_version/src/GraphicsUtil.cpp +++ b/desktop_version/src/GraphicsUtil.cpp @@ -221,7 +221,7 @@ static void BlitSurfaceTransform( } /* FIXME: Find a way to do this without allocating... */ - SDL_Surface* tempsurface = RecreateSurface(dest); + SDL_Surface* tempsurface = RecreateSurfaceWithDimensions(src, orig_rect.w, orig_rect.h); if (tempsurface == NULL) { return; @@ -245,11 +245,12 @@ static void BlitSurfaceTransform( } const SDL_Color result = transform(pixel, color); - DrawPixel(tempsurface, blit_x + x, blit_y + y, result); + DrawPixel(tempsurface, x, y, result); } } - SDL_BlitSurface(tempsurface, NULL, dest, NULL); + SDL_Rect final_rect = {blit_x, blit_y, 0, 0}; + SDL_BlitSurface(tempsurface, NULL, dest, &final_rect); VVV_freefunc(SDL_FreeSurface, tempsurface); }