Disconnect relationship with VisualUrl and VisualFactory
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / texture-manager-impl.cpp
index dbb1230..093954e 100644 (file)
@@ -469,6 +469,10 @@ TextureManager::TextureId TextureManager::RequestLoadInternal(
       if(encodedImageBuffer)
       {
         textureId = targetId;
+
+        // Increase EncodedImageBuffer reference during it contains mTextureInfoContainer.
+        UseExternalResource(url.GetUrl());
+
         // Insert this buffer at mTextureInfoContainer.
         // This buffer will decode at ImageLoaderThread.
         bool preMultiply = (preMultiplyOnLoad == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD);
@@ -604,6 +608,11 @@ void TextureManager::Remove(const TextureManager::TextureId textureId, TextureUp
       // If the state allows us to remove the TextureInfo data, we do so.
       if(removeTextureInfo)
       {
+        // If url location is BUFFER, decrease reference count of EncodedImageBuffer.
+        if(textureInfo.url.IsBufferResource())
+        {
+          RemoveExternalEncodedImageBuffer(textureInfo.url.GetUrl());
+        }
         // Permanently remove the textureInfo struct.
         mTextureInfoContainer.erase(mTextureInfoContainer.begin() + textureInfoIndex);
       }
@@ -1419,8 +1428,16 @@ void TextureManager::AsyncLoadingHelper::Load(TextureId
                                               DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad)
 {
   mLoadingInfoContainer.push_back(AsyncLoadingInfo(textureId));
-  auto id                             = GetImplementation(mLoader).Load(url, desiredSize, fittingMode, samplingMode, orientationCorrection, preMultiplyOnLoad);
-  mLoadingInfoContainer.back().loadId = id;
+  if(DALI_UNLIKELY(url.IsBufferResource()))
+  {
+    auto id                             = GetImplementation(mLoader).LoadEncodedImageBuffer(mTextureManager.GetEncodedImageBuffer(url.GetUrl()), desiredSize, fittingMode, samplingMode, orientationCorrection, preMultiplyOnLoad);
+    mLoadingInfoContainer.back().loadId = id;
+  }
+  else
+  {
+    auto id                             = GetImplementation(mLoader).Load(url, desiredSize, fittingMode, samplingMode, orientationCorrection, preMultiplyOnLoad);
+    mLoadingInfoContainer.back().loadId = id;
+  }
 }
 
 void TextureManager::AsyncLoadingHelper::ApplyMask(TextureId                                textureId,