From fa993a0489aeb1c2d0924693ba8093c56da688f4 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 27 Dec 2021 21:24:34 +0100 Subject: [PATCH] Fixed a texture corruption issue caused by too aggressive optimizations. --- es-core/src/resources/TextureData.cpp | 6 +++--- es-core/src/resources/TextureResource.cpp | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/es-core/src/resources/TextureData.cpp b/es-core/src/resources/TextureData.cpp index 391cf8a37..25c5ce6b6 100644 --- a/es-core/src/resources/TextureData.cpp +++ b/es-core/src/resources/TextureData.cpp @@ -58,8 +58,8 @@ bool TextureData::initSVGFromMemory(const std::string& fileData) { std::unique_lock lock{mMutex}; - // If already initialized then don't process it again. - if (!mDataRGBA.empty()) + // If already initialized then don't process it again unless it needs to be rasterized. + if (!mDataRGBA.empty() && !mPendingRasterization) return true; NSVGimage* svgImage{nsvgParse(const_cast(fileData.c_str()), "px", DPI)}; @@ -282,7 +282,7 @@ float TextureData::sourceHeight() void TextureData::setSourceSize(float width, float height) { if (mScalable) { - if ((mSourceWidth != width) || (mSourceHeight != height)) { + if (mSourceWidth != width || mSourceHeight != height) { mSourceWidth = width; mSourceHeight = height; releaseVRAM(); diff --git a/es-core/src/resources/TextureResource.cpp b/es-core/src/resources/TextureResource.cpp index 8b1990100..bee1ba5df 100644 --- a/es-core/src/resources/TextureResource.cpp +++ b/es-core/src/resources/TextureResource.cpp @@ -197,7 +197,8 @@ void TextureResource::rasterizeAt(float width, float height) { if (mTextureData != nullptr) { glm::vec2 textureSize = mTextureData.get()->getSize(); - if (textureSize.x == width && textureSize.y == height) + if (textureSize.x == width && textureSize.y == height && + !mTextureData.get()->getPendingRasterization()) return; }