Reduce the number of conversion between std::string <-> VisaulUrl at interal 64/260664/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Thu, 1 Jul 2021 07:13:07 +0000 (16:13 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Thu, 1 Jul 2021 07:14:19 +0000 (16:14 +0900)
Change-Id: I602e070cd948e17edec3b25b1de52b9f49e08ea7
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-toolkit/internal/image-loader/image-atlas-impl.cpp
dali-toolkit/internal/image-loader/image-atlas-impl.h
dali-toolkit/internal/visuals/image-atlas-manager.cpp
dali-toolkit/internal/visuals/image-atlas-manager.h
dali-toolkit/internal/visuals/npatch-data.cpp
dali-toolkit/internal/visuals/npatch-data.h
dali-toolkit/internal/visuals/npatch-loader.cpp
dali-toolkit/internal/visuals/npatch-loader.h
dali-toolkit/internal/visuals/npatch/npatch-visual.cpp
dali-toolkit/internal/visuals/texture-manager-impl.cpp

index 8c4dba6..31c3351 100644 (file)
@@ -24,6 +24,9 @@
 #include <dali/public-api/signals/callback.h>
 #include <string.h>
 
+// INTERNAL HEADERS
+#include <dali-toolkit/internal/image-loader/async-image-loader-impl.h>
+
 namespace Dali
 {
 namespace Toolkit
@@ -130,7 +133,7 @@ void ImageAtlas::SetBrokenImage(const std::string& brokenImageUrl)
 }
 
 bool ImageAtlas::Upload(Vector4&             textureRect,
-                        const std::string&   url,
+                        const VisualUrl&     url,
                         ImageDimensions      size,
                         FittingMode::Type    fittingMode,
                         bool                 orientationCorrection,
@@ -140,7 +143,7 @@ bool ImageAtlas::Upload(Vector4&             textureRect,
   ImageDimensions zero;
   if(size == zero) // image size not provided
   {
-    dimensions = Dali::GetClosestImageSize(url);
+    dimensions = Dali::GetClosestImageSize(url.GetUrl());
     if(dimensions == zero) // Fail to read the image & broken image file exists
     {
       if(!mBrokenImageUrl.empty())
@@ -159,7 +162,7 @@ bool ImageAtlas::Upload(Vector4&             textureRect,
   unsigned int packPositionY = 0;
   if(mPacker.Pack(dimensions.GetWidth(), dimensions.GetHeight(), packPositionX, packPositionY))
   {
-    unsigned short loadId = mAsyncLoader.Load(url, size, fittingMode, SamplingMode::BOX_THEN_LINEAR, orientationCorrection);
+    unsigned short loadId = GetImplementation(mAsyncLoader).Load(url, size, fittingMode, SamplingMode::BOX_THEN_LINEAR, orientationCorrection, DevelAsyncImageLoader::PreMultiplyOnLoad::OFF);
     mLoadingTaskInfoContainer.PushBack(new LoadingTaskInfo(loadId, packPositionX, packPositionY, dimensions.GetWidth(), dimensions.GetHeight(), atlasUploadObserver));
     // apply the half pixel correction
     textureRect.x = (static_cast<float>(packPositionX) + 0.5f) / mWidth;                      // left
index 49dd3ef..eab1551 100644 (file)
@@ -27,6 +27,7 @@
 #include <dali-toolkit/devel-api/image-loader/image-atlas.h>
 #include <dali-toolkit/internal/image-loader/atlas-packer.h>
 #include <dali-toolkit/public-api/image-loader/async-image-loader.h>
+#include <dali-toolkit/internal/visuals/visual-url.h>
 
 namespace Dali
 {
@@ -78,7 +79,7 @@ public:
    * @copydoc Toolkit::ImageAtlas::Upload( Vector4&, const std::string&, ImageDimensions,FittingMode::Type, bool )
    */
   bool Upload(Vector4&             textureRect,
-              const std::string&   url,
+              const VisualUrl&     url,
               ImageDimensions      size,
               FittingMode::Type    fittingMode,
               bool                 orientationCorrection,
index 1f634e1..a8de5a8 100644 (file)
@@ -21,6 +21,9 @@
 // EXTERNAL HEADER
 #include <dali/devel-api/adaptor-framework/image-loading.h>
 
+// INTERNAL HEADERS
+#include <dali-toolkit/internal/image-loader/image-atlas-impl.h>
+
 namespace Dali
 {
 namespace Toolkit
@@ -44,7 +47,7 @@ ImageAtlasManager::~ImageAtlasManager()
 }
 
 TextureSet ImageAtlasManager::Add(Vector4&             textureRect,
-                                  const std::string&   url,
+                                  const VisualUrl&     url,
                                   ImageDimensions&     size,
                                   FittingMode::Type    fittingMode,
                                   bool                 orientationCorrection,
@@ -54,7 +57,7 @@ TextureSet ImageAtlasManager::Add(Vector4&             textureRect,
   ImageDimensions zero;
   if(size == zero)
   {
-    dimensions = Dali::GetClosestImageSize(url);
+    dimensions = Dali::GetClosestImageSize(url.GetUrl());
   }
 
   // big image, atlasing is not applied
@@ -67,7 +70,7 @@ TextureSet ImageAtlasManager::Add(Vector4&             textureRect,
   unsigned int i = 0;
   for(AtlasContainer::iterator iter = mAtlasList.begin(); iter != mAtlasList.end(); ++iter)
   {
-    if((*iter).Upload(textureRect, url, size, fittingMode, orientationCorrection, atlasUploadObserver))
+    if(GetImplementation(*iter).Upload(textureRect, url, size, fittingMode, orientationCorrection, atlasUploadObserver))
     {
       return mTextureSetList[i];
     }
@@ -75,7 +78,7 @@ TextureSet ImageAtlasManager::Add(Vector4&             textureRect,
   }
 
   CreateNewAtlas();
-  mAtlasList.back().Upload(textureRect, url, size, fittingMode, orientationCorrection, atlasUploadObserver);
+  GetImplementation(mAtlasList.back()).Upload(textureRect, url, size, fittingMode, orientationCorrection, atlasUploadObserver);
   return mTextureSetList.back();
 }
 
index 3c2f52c..b8f5a11 100644 (file)
@@ -25,6 +25,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/image-loader/image-atlas.h>
+#include <dali-toolkit/internal/visuals/visual-url.h>
 
 namespace Dali
 {
@@ -67,7 +68,7 @@ public:
    * @return The texture set containing the image.
    */
   TextureSet Add(Vector4&             textureRect,
-                 const std::string&   url,
+                 const VisualUrl&     url,
                  ImageDimensions&     size,
                  FittingMode::Type    fittingMode           = FittingMode::DEFAULT,
                  bool                 orientationCorrection = true,
index 45cb99f..cb144b8 100644 (file)
@@ -85,12 +85,12 @@ uint32_t NPatchData::GetObserverCount() const
   return mObserverList.Count();
 }
 
-void NPatchData::SetUrl(const std::string url)
+void NPatchData::SetUrl(const VisualUrl& url)
 {
   mUrl = url;
 }
 
-std::string NPatchData::GetUrl() const
+VisualUrl NPatchData::GetUrl() const
 {
   return mUrl;
 }
index a807d39..7a052c4 100644 (file)
@@ -25,6 +25,7 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/utility/npatch-utilities.h>
 #include <dali-toolkit/internal/visuals/texture-manager-impl.h>
+#include <dali-toolkit/internal/visuals/visual-url.h>
 
 namespace Dali
 {
@@ -100,14 +101,14 @@ public:
    *
    * @param [in] url NPatch image url
    */
-  void SetUrl(const std::string url);
+  void SetUrl(const VisualUrl& url);
 
   /**
    * @brief Retrieve the image url.
    *
    * @return Return the image url.
    */
-  std::string GetUrl() const;
+  VisualUrl GetUrl() const;
 
   /**
    * @brief Set texture set on the cache data
@@ -274,7 +275,7 @@ private:
 
   NPatchDataId                 mId;
   ObserverListType             mObserverList;      ///< Container used to store all observer clients of this Texture
-  std::string                  mUrl;               ///< Url of the N-Patch
+  VisualUrl                    mUrl;               ///< Url of the N-Patch
   TextureSet                   mTextureSet;        ///< Texture containing the cropped image
   NPatchUtility::StretchRanges mStretchPixelsX;    ///< X stretch pixels
   NPatchUtility::StretchRanges mStretchPixelsY;    ///< Y stretch pixels
index a7734da..5f8ddff 100644 (file)
@@ -52,9 +52,9 @@ NPatchData::NPatchDataId NPatchLoader::GenerateUniqueNPatchDataId()
   return mCurrentNPatchDataId++;
 }
 
-std::size_t NPatchLoader::Load(TextureManager& textureManager, TextureUploadObserver* textureObserver, const std::string& url, const Rect<int>& border, bool& preMultiplyOnLoad, bool synchronousLoading)
+std::size_t NPatchLoader::Load(TextureManager& textureManager, TextureUploadObserver* textureObserver, const VisualUrl& url, const Rect<int>& border, bool& preMultiplyOnLoad, bool synchronousLoading)
 {
-  std::size_t                                 hash  = CalculateHash(url);
+  std::size_t                                 hash  = CalculateHash(url.GetUrl());
   OwnerContainer<NPatchData*>::SizeType       index = UNINITIALIZED_ID;
   const OwnerContainer<NPatchData*>::SizeType count = mCache.Count();
 
@@ -63,7 +63,7 @@ std::size_t NPatchLoader::Load(TextureManager& textureManager, TextureUploadObse
     if(mCache[index]->GetHash() == hash)
     {
       // hash match, check url as well in case of hash collision
-      if(mCache[index]->GetUrl() == url)
+      if(mCache[index]->GetUrl().GetUrl() == url.GetUrl())
       {
         // Use cached data
         if(mCache[index]->GetBorder() == border)
index 50c24d3..dd7f022 100644 (file)
@@ -27,6 +27,7 @@
 #include <dali-toolkit/devel-api/utility/npatch-utilities.h>
 #include <dali-toolkit/internal/visuals/npatch-data.h>
 #include <dali-toolkit/internal/visuals/texture-manager-impl.h>
+#include <dali-toolkit/internal/visuals/visual-url.h>
 
 namespace Dali
 {
@@ -68,7 +69,7 @@ public:
    * @param [in] synchronousLoading True if the image will be loaded in synchronous time.
    * @return id of the texture.
    */
-  std::size_t Load(TextureManager& textureManager, TextureUploadObserver* textureObserver, const std::string& url, const Rect<int>& border, bool& preMultiplyOnLoad, bool synchronousLoading);
+  std::size_t Load(TextureManager& textureManager, TextureUploadObserver* textureObserver, const VisualUrl& url, const Rect<int>& border, bool& preMultiplyOnLoad, bool synchronousLoading);
 
   /**
    * @brief Set loaded PixelBuffer and its information
index bbee1d4..6ef02cc 100644 (file)
@@ -156,7 +156,7 @@ void NPatchVisual::LoadImages()
   if(mId == NPatchData::INVALID_NPATCH_DATA_ID && mImageUrl.IsLocalResource())
   {
     bool preMultiplyOnLoad = IsPreMultipliedAlphaEnabled() && !mImpl->mCustomShader ? true : false;
-    mId                    = mLoader.Load(textureManager, this, mImageUrl.GetUrl(), mBorder, preMultiplyOnLoad, synchronousLoading);
+    mId                    = mLoader.Load(textureManager, this, mImageUrl, mBorder, preMultiplyOnLoad, synchronousLoading);
 
     const NPatchData* data;
     if(mLoader.GetNPatchData(mId, data) && data->GetLoadingState() == NPatchData::LoadingState::LOAD_COMPLETE)
index a449997..f9ccacc 100644 (file)
@@ -30,6 +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>
@@ -1243,7 +1244,7 @@ void TextureManager::AsyncLoadingHelper::LoadAnimatedImage(TextureId
                                                            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;
 }
 
@@ -1256,7 +1257,7 @@ void TextureManager::AsyncLoadingHelper::Load(TextureId
                                               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;
 }
 
@@ -1268,7 +1269,7 @@ void TextureManager::AsyncLoadingHelper::ApplyMask(TextureId
                                                    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;
 }