From e3dc861932eab0c2a1533e6ee72f6944aaed4035 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Tue, 10 Dec 2019 18:07:40 +0100 Subject: [PATCH] Clear intermediate texture before blitting. --- .vscode/settings.json | 3 ++- src/common/sdl_blitter/HqBlitter.cxx | 5 +++++ src/common/sdl_blitter/HqBlitter.hxx | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index f355019cf..fb31d406b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,6 +23,7 @@ "tuple": "cpp", "utility": "cpp", "*.tcc": "cpp", - "functional": "cpp" + "functional": "cpp", + "iomanip": "cpp" } } diff --git a/src/common/sdl_blitter/HqBlitter.cxx b/src/common/sdl_blitter/HqBlitter.cxx index a47cd003b..ae1baea06 100644 --- a/src/common/sdl_blitter/HqBlitter.cxx +++ b/src/common/sdl_blitter/HqBlitter.cxx @@ -106,6 +106,8 @@ void HqBlitter::blitToIntermediate() SDL_Rect r = mySrcRect; r.x = r.y = 0; + SDL_UpdateTexture(myIntermediateTexture, nullptr, myBlankBuffer.get(), 4 * myIntermediateRect.w); + SDL_SetRenderTarget(myFB.renderer(), myIntermediateTexture); SDL_RenderCopy(myFB.renderer(), mySrcTexture, &r, &myIntermediateRect); @@ -138,6 +140,9 @@ void HqBlitter::recreateTexturesIfNecessary() mySrcTexture = SDL_CreateTexture(myFB.renderer(), myFB.pixelFormat().format, texAccess, mySrcRect.w, mySrcRect.h); + myBlankBuffer = make_unique(4 * myIntermediateRect.w * myIntermediateRect.h); + memset(myBlankBuffer.get(), 0, 4 * myIntermediateRect.w * myIntermediateRect.h); + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, myAttributes.smoothing ? "1" : "0"); myIntermediateTexture = SDL_CreateTexture(myFB.renderer(), myFB.pixelFormat().format, diff --git a/src/common/sdl_blitter/HqBlitter.hxx b/src/common/sdl_blitter/HqBlitter.hxx index 745f869b1..8c60de00e 100644 --- a/src/common/sdl_blitter/HqBlitter.hxx +++ b/src/common/sdl_blitter/HqBlitter.hxx @@ -54,6 +54,7 @@ class HqBlitter : public Blitter { bool myRecreateTextures; SDL_Surface* myStaticData; + unique_ptr myBlankBuffer; FrameBufferSDL2& myFB;