[Tizen] Resolve textureInfo validation for some cases 18/287018/1 accepted/tizen/6.0/unified/20230125.103637 submit/tizen_6.0/20230119.043317 submit/tizen_6.0/20230125.025939
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 18 Jan 2023 11:21:22 +0000 (20:21 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 18 Jan 2023 11:21:22 +0000 (20:21 +0900)
1. Alphamask image load failed
2. Multiply request same images during ResourceReady signal

Change-Id: I923123711e3b1c64db72cce8e05b02711924bbec
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-toolkit/internal/visuals/texture-manager-impl.cpp

index 64a874a..3623ef0 100644 (file)
@@ -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<TextureId> 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 )