From 2a96e3ade39348f9f2835fb658d581f9f6d65edd Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Wed, 27 Dec 2023 14:11:43 +0900 Subject: [PATCH] Reset EmptyTexture object when application stopped We should not re-use old texture item if application stoped and re-start. This can be happened when we use offscreen application Change-Id: I162d380259d7644fe0f817412581658010df0d47 Signed-off-by: Eunki, Hong --- dali-scene3d/internal/common/image-resource-loader.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dali-scene3d/internal/common/image-resource-loader.cpp b/dali-scene3d/internal/common/image-resource-loader.cpp index f5d15c5..99b7ed5 100644 --- a/dali-scene3d/internal/common/image-resource-loader.cpp +++ b/dali-scene3d/internal/common/image-resource-loader.cpp @@ -32,7 +32,7 @@ #include #include ///< for std::function -#include ///< for std::shared_ptr +#include ///< for std::shared_ptr #include #include #include ///< for std::pair @@ -506,6 +506,7 @@ private: }; static std::shared_ptr gCacheImpl{nullptr}; +static Dali::Texture gEmptyTextureWhiteRGB{}; std::shared_ptr GetCacheImpl() { @@ -519,6 +520,9 @@ std::shared_ptr GetCacheImpl() void DestroyCacheImpl() { gCacheImpl.reset(); + + // Remove texture object when application stopped. + gEmptyTextureWhiteRGB.Reset(); } } // namespace @@ -536,14 +540,13 @@ Dali::PixelData GetEmptyPixelDataWhiteRGB() Dali::Texture GetEmptyTextureWhiteRGB() { - static Dali::PixelData emptyPixelData = GetEmptyPixelDataWhiteRGB(); - static Dali::Texture emptyTexture = Dali::Texture(); - if(!emptyTexture) + if(!gEmptyTextureWhiteRGB) { - emptyTexture = Texture::New(TextureType::TEXTURE_2D, emptyPixelData.GetPixelFormat(), emptyPixelData.GetWidth(), emptyPixelData.GetHeight()); - emptyTexture.Upload(emptyPixelData, 0, 0, 0, 0, emptyPixelData.GetWidth(), emptyPixelData.GetHeight()); + Dali::PixelData emptyPixelData = GetEmptyPixelDataWhiteRGB(); + gEmptyTextureWhiteRGB = Texture::New(TextureType::TEXTURE_2D, emptyPixelData.GetPixelFormat(), emptyPixelData.GetWidth(), emptyPixelData.GetHeight()); + gEmptyTextureWhiteRGB.Upload(emptyPixelData, 0, 0, 0, 0, emptyPixelData.GetWidth(), emptyPixelData.GetHeight()); } - return emptyTexture; + return gEmptyTextureWhiteRGB; } Dali::Texture GetCachedTexture(Dali::PixelData pixelData, bool mipmapRequired) -- 2.7.4