From 1741e6620c8d721469c18faca855b0bfa48910e7 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Wed, 18 Jan 2023 20:21:22 +0900 Subject: [PATCH] [Tizen] Resolve textureInfo validation for some cases 1. Alphamask image load failed 2. Multiply request same images during ResourceReady signal Change-Id: I923123711e3b1c64db72cce8e05b02711924bbec Signed-off-by: Eunki, Hong --- .../internal/visuals/texture-manager-impl.cpp | 49 ++++++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/dali-toolkit/internal/visuals/texture-manager-impl.cpp b/dali-toolkit/internal/visuals/texture-manager-impl.cpp index 64a874a..3623ef0 100644 --- a/dali-toolkit/internal/visuals/texture-manager-impl.cpp +++ b/dali-toolkit/internal/visuals/texture-manager-impl.cpp @@ -880,6 +880,12 @@ void TextureManager::ProcessQueuedTextures() { element.mObserver->LoadComplete( true, textureInfo.pixelBuffer, textureInfo.url, textureInfo.preMultiplied ); } + else if(textureInfo.loadState == LOADING) + { + // Note : LOADING state texture cannot be queue. + // This case be occured when same texture id are queue in mLoadQueue. + ObserveTexture( textureInfo, element.mObserver ); + } else { LoadTexture( textureInfo, element.mObserver ); @@ -1002,8 +1008,16 @@ void TextureManager::PostLoad( TextureInfo& textureInfo, Devel::PixelBuffer& pix { // @todo If the load was unsuccessful, upload the broken image. textureInfo.loadState = LOAD_FAILED; - CheckForWaitingTexture( textureInfo ); - NotifyObservers( textureInfo, false ); + if(textureInfo.storageType == StorageType::KEEP_PIXEL_BUFFER) + { + // Check if there was another texture waiting for this load to complete + // (e.g. if this was an image mask, and its load is on a different thread) + CheckForWaitingTexture(textureInfo); + } + else + { + NotifyObservers(textureInfo, false); + } } } @@ -1013,6 +1027,10 @@ void TextureManager::CheckForWaitingTexture( TextureInfo& maskTextureInfo ) // maskTextureId: const unsigned int size = mTextureInfoContainer.size(); + // Keep notify observer required textureIds. + // Note : NotifyObservers can change mTextureInfoContainer cache struct. We should check id's validation before notify. + std::vector notifyRequiredTextureIds; + for( unsigned int cacheIndex = 0; cacheIndex < size; ++cacheIndex ) { if( mTextureInfoContainer[cacheIndex].maskTextureId == maskTextureInfo.textureId && @@ -1025,14 +1043,37 @@ void TextureManager::CheckForWaitingTexture( TextureInfo& maskTextureInfo ) // Send New Task to Thread ApplyMask( textureInfo, maskTextureInfo.textureId ); } - else + else // maskTextureInfo.loadState == LoadState::LOAD_FAILED { + // Increase reference counts for notify required textureId. + // Now we can assume that we don't remove & re-assign this textureId + // during NotifyObserver signal emit. + textureInfo.referenceCount++; + textureInfo.pixelBuffer.Reset(); textureInfo.loadState = LOAD_FAILED; - NotifyObservers( textureInfo, false ); + + notifyRequiredTextureIds.push_back(textureInfo.textureId); } } } + + // Notify textures are masked + for(const auto textureId : notifyRequiredTextureIds) + { + int textureCacheIndex = GetCacheIndexFromId(textureId); + if(textureCacheIndex != INVALID_CACHE_INDEX) + { + TextureInfo& textureInfo(mTextureInfoContainer[textureCacheIndex]); + NotifyObservers(textureInfo, false); + } + } + + // Decrease reference count + for(const auto textureId : notifyRequiredTextureIds) + { + Remove(textureId, nullptr); + } } void TextureManager::ApplyMask( TextureInfo& textureInfo, TextureId maskTextureId ) -- 2.7.4