Merge "Reduce the number of conversion between std::string <-> VisaulUrl at interal...
authorEunki Hong <eunkiki.hong@samsung.com>
Mon, 26 Jul 2021 05:49:33 +0000 (05:49 +0000)
committerGerrit Code Review <gerrit@review>
Mon, 26 Jul 2021 05:49:33 +0000 (05:49 +0000)
1  2 
dali-toolkit/internal/visuals/texture-manager-impl.cpp

@@@ -30,6 -30,7 +30,7 @@@
  #include <string>
  
  // INTERNAL HEADERS
+ #include <dali-toolkit/internal/image-loader/async-image-loader-impl.h>
  #include <dali-toolkit/internal/image-loader/image-atlas-impl.h>
  #include <dali-toolkit/internal/visuals/image-atlas-manager.h>
  #include <dali-toolkit/internal/visuals/rendering-addon.h>
@@@ -519,7 -520,6 +520,7 @@@ TextureManager::TextureId TextureManage
  void TextureManager::Remove(const TextureManager::TextureId textureId, TextureUploadObserver* observer)
  {
    int textureInfoIndex = GetCacheIndexFromId(textureId);
 +
    if(textureInfoIndex != INVALID_INDEX)
    {
      TextureInfo& textureInfo(mTextureInfoContainer[textureInfoIndex]);
@@@ -661,7 -661,6 +662,7 @@@ std::string TextureManager::AddExternal
    info.textureId  = GenerateUniqueTextureId();
    info.textureSet = textureSet;
    mExternalTextures.emplace_back(info);
 +
    return VisualUrl::CreateTextureUrl(std::to_string(info.textureId));
  }
  
@@@ -670,9 -669,10 +671,9 @@@ TextureSet TextureManager::RemoveExtern
    if(url.size() > 0u)
    {
      // get the location from the Url
 -    VisualUrl parseUrl(url);
 -    if(VisualUrl::TEXTURE == parseUrl.GetProtocolType())
 +    if(VisualUrl::TEXTURE == VisualUrl::GetProtocolType(url))
      {
 -      std::string location = parseUrl.GetLocation();
 +      std::string location = VisualUrl::GetLocation(url);
        if(location.size() > 0u)
        {
          TextureId  id  = std::stoi(location);
            if(iter->textureId == id)
            {
              auto textureSet = iter->textureSet;
 -            mExternalTextures.erase(iter);
 +            if(--(iter->referenceCount) <= 0)
 +            {
 +              mExternalTextures.erase(iter);
 +            }
              return textureSet;
            }
          }
    return TextureSet();
  }
  
 +void TextureManager::UseExternalTexture(const VisualUrl& url)
 +{
 +  if(VisualUrl::TEXTURE == url.GetProtocolType())
 +  {
 +    std::string location = url.GetLocation();
 +    if(location.size() > 0u)
 +    {
 +      TextureId id = std::stoi(location);
 +      for(auto&& elem : mExternalTextures)
 +      {
 +        if(elem.textureId == id)
 +        {
 +          elem.referenceCount++;
 +          return;
 +        }
 +      }
 +    }
 +  }
 +}
 +
  void TextureManager::AddObserver(TextureManager::LifecycleObserver& observer)
  {
    // make sure an observer doesn't observe the same object twice
@@@ -1267,7 -1244,7 +1268,7 @@@ void TextureManager::AsyncLoadingHelper
                                                             uint32_t                   frameIndex)
  {
    mLoadingInfoContainer.push_back(AsyncLoadingInfo(textureId));
-   auto id                             = DevelAsyncImageLoader::LoadAnimatedImage(mLoader, animatedImageLoading, frameIndex);
+   auto id                             = GetImplementation(mLoader).LoadAnimatedImage(animatedImageLoading, frameIndex);
    mLoadingInfoContainer.back().loadId = id;
  }
  
@@@ -1280,7 -1257,7 +1281,7 @@@ void TextureManager::AsyncLoadingHelper
                                                DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad)
  {
    mLoadingInfoContainer.push_back(AsyncLoadingInfo(textureId));
-   auto id                             = DevelAsyncImageLoader::Load(mLoader, url.GetUrl(), desiredSize, fittingMode, samplingMode, orientationCorrection, preMultiplyOnLoad);
+   auto id                             = GetImplementation(mLoader).Load(url, desiredSize, fittingMode, samplingMode, orientationCorrection, preMultiplyOnLoad);
    mLoadingInfoContainer.back().loadId = id;
  }
  
@@@ -1292,7 -1269,7 +1293,7 @@@ void TextureManager::AsyncLoadingHelper
                                                     DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad)
  {
    mLoadingInfoContainer.push_back(AsyncLoadingInfo(textureId));
-   auto id                             = DevelAsyncImageLoader::ApplyMask(mLoader, pixelBuffer, maskPixelBuffer, contentScale, cropToMask, preMultiplyOnLoad);
+   auto id                             = GetImplementation(mLoader).ApplyMask(pixelBuffer, maskPixelBuffer, contentScale, cropToMask, preMultiplyOnLoad);
    mLoadingInfoContainer.back().loadId = id;
  }