Caching texture instead of textureSet in TextureManager 35/276135/18
authortscholb <scholb.kim@samsung.com>
Fri, 10 Jun 2022 04:17:03 +0000 (13:17 +0900)
committertscholb <scholb.kim@samsung.com>
Thu, 25 Aug 2022 06:26:43 +0000 (15:26 +0900)
To avoid duplicate loading, Caching texture instead of textureSet in TextureManager.

Change-Id: Icb24284fd66ab1968de352453880b754a5d3c7f5

14 files changed:
automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp
dali-toolkit/internal/texture-manager/texture-cache-manager.cpp
dali-toolkit/internal/texture-manager/texture-cache-manager.h
dali-toolkit/internal/texture-manager/texture-manager-impl.cpp
dali-toolkit/internal/texture-manager/texture-manager-impl.h
dali-toolkit/internal/texture-manager/texture-manager-type.h
dali-toolkit/internal/texture-manager/texture-upload-observer.cpp
dali-toolkit/internal/texture-manager/texture-upload-observer.h
dali-toolkit/internal/visuals/animated-image/fixed-image-cache.cpp
dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp
dali-toolkit/internal/visuals/animated-image/rolling-image-cache.cpp
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/npatch/npatch-visual.cpp

index 1c8fea2..7478659 100644 (file)
@@ -599,8 +599,6 @@ int UtcTextureManagerUseInvalidMask(void)
     atlasRectSize,
     atlasingStatus,
     loadingStatus,
-    WrapMode::DEFAULT,
-    WrapMode::DEFAULT,
     &observer,
     atlasUploadObserver,
     atlasManager,
@@ -666,8 +664,6 @@ int UtcTextureManagerUseInvalidMaskAndMaskLoadedFirst(void)
     atlasRectSize,
     atlasingStatus,
     loadingStatus,
-    WrapMode::DEFAULT,
-    WrapMode::DEFAULT,
     &observer,
     atlasUploadObserver,
     atlasManager,
@@ -733,8 +729,6 @@ int UtcTextureManagerUseInvalidMaskAndMaskLoadedLater(void)
     atlasRectSize,
     atlasingStatus,
     loadingStatus,
-    WrapMode::DEFAULT,
-    WrapMode::DEFAULT,
     &observer,
     atlasUploadObserver,
     atlasManager,
@@ -820,8 +814,6 @@ int UtcTextureManagerSynchronousLoadingFail(void)
     atlasRectSize,
     atlasingStatus,
     loadingStatus,
-    WrapMode::DEFAULT,
-    WrapMode::DEFAULT,
     &observer,
     atlasUploadObserver,
     atlasManager,
@@ -876,8 +868,6 @@ int UtcTextureManagerCachingSynchronousLoading(void)
     atlasRectSize,
     atlasingStatus,
     loadingStatus,
-    WrapMode::DEFAULT,
-    WrapMode::DEFAULT,
     &observer,
     atlasUploadObserver,
     atlasManager,
@@ -908,8 +898,6 @@ int UtcTextureManagerCachingSynchronousLoading(void)
     atlasRectSize,
     atlasingStatus,
     loadingStatus,
-    WrapMode::DEFAULT,
-    WrapMode::DEFAULT,
     &asyncObserver,
     atlasUploadObserver,
     atlasManager,
@@ -968,8 +956,6 @@ int UtcTextureManagerAsyncSyncAsync(void)
     atlasRectSize,
     atlasingStatus,
     asyncLoadingStatus1,
-    WrapMode::DEFAULT,
-    WrapMode::DEFAULT,
     &asyncObserver1,
     atlasUploadObserver,
     atlasManager,
@@ -1000,8 +986,6 @@ int UtcTextureManagerAsyncSyncAsync(void)
     atlasRectSize,
     atlasingStatus,
     syncLoadingStatus,
-    WrapMode::DEFAULT,
-    WrapMode::DEFAULT,
     &syncObserver,
     atlasUploadObserver,
     atlasManager,
@@ -1037,8 +1021,6 @@ int UtcTextureManagerAsyncSyncAsync(void)
     atlasRectSize,
     atlasingStatus,
     asyncLoadingStatus2,
-    WrapMode::DEFAULT,
-    WrapMode::DEFAULT,
     &asyncObserver2,
     atlasUploadObserver,
     atlasManager,
@@ -1048,7 +1030,11 @@ int UtcTextureManagerAsyncSyncAsync(void)
 
   DALI_TEST_EQUALS(asyncLoadingStatus2, false, TEST_LOCATION); // texture is loaded by previous sync request
   DALI_TEST_CHECK(asyncTextureSet2);                           // texture is loaded
-  DALI_TEST_CHECK(asyncTextureSet2 == syncTextureSet);         // check loaded two texture is same.
+  Texture syncTexture   = syncTextureSet.GetTexture(0u);
+  Texture asyncTexture2 = asyncTextureSet2.GetTexture(0u);
+  DALI_TEST_CHECK(syncTexture);
+  DALI_TEST_CHECK(asyncTexture2);
+  DALI_TEST_CHECK(asyncTexture2 == syncTexture);               // check loaded two texture is same.
 
   // observer is called synchronously because the texture is cached.
   DALI_TEST_EQUALS(asyncObserver2.mLoaded, true, TEST_LOCATION);
@@ -1064,7 +1050,10 @@ int UtcTextureManagerAsyncSyncAsync(void)
   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
   DALI_TEST_EQUALS(asyncObserver1.mLoaded, true, TEST_LOCATION);
   DALI_TEST_EQUALS(asyncObserver1.mObserverCalled, true, TEST_LOCATION);
-  DALI_TEST_CHECK(asyncObserver1.mTextureSet == asyncTextureSet2); // check loaded two texture is same.
+  DALI_TEST_CHECK(asyncObserver1.mTextureSet);
+
+  Texture observerTexture = asyncObserver1.mTextureSet.GetTexture(0u);
+  DALI_TEST_CHECK(observerTexture == asyncTexture2); // check loaded two texture is same.
 
   // asyncObserver2 was already called so it isn't called here.
   DALI_TEST_EQUALS(asyncObserver2.mLoaded, false, TEST_LOCATION);
@@ -1165,8 +1154,6 @@ int UtcTextureManagerRemoveDuringApplyMasking(void)
     atlasRectSize,
     atlasingStatus,
     loadingStatus,
-    WrapMode::DEFAULT,
-    WrapMode::DEFAULT,
     &observer1,
     atlasUploadObserver,
     atlasManager,
index 2bfef0a..1fcd10d 100644 (file)
@@ -2402,9 +2402,9 @@ int UtcDaliImageVisualReleasePolicy08(void)
   DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
   textureTrace.Reset();
 
-  // Ensure TextureSet is same after detach/attach on stage when texture used the DESTROYED release policy
-  // 1. Get TextureSet
-  TextureSet textureSetBefore = actor.GetRendererAt(0u).GetTextures();
+  // Ensure Texture is same after detach/attach on stage when texture used the DESTROYED release policy
+  // 1. Get Texture
+  Texture textureBefore = actor.GetRendererAt(0u).GetTextures().GetTexture(0u);
 
   // 2.Remove actor from stage. In this case, renderer also is deleted.
   tet_infoline("Remove actor from stage");
@@ -2427,12 +2427,12 @@ int UtcDaliImageVisualReleasePolicy08(void)
   DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
   textureTrace.Reset();
 
-  // 4.Compare Texture with before and after. textureSet need to be same because release policy is the DESTROYED.
-  tet_infoline("Ensure a textureSet is not deleted because it is used the DESTROYED release policy");
-  TextureSet textureSetAfter = actor.GetRendererAt(0u).GetTextures();
-  DALI_TEST_CHECK(textureSetBefore == textureSetAfter);
-  textureSetBefore.Reset();
-  textureSetAfter.Reset();
+  // 4.Compare Texture with before and after. texture need to be same because release policy is the DESTROYED.
+  tet_infoline("Ensure a texture is not deleted because it is used the DESTROYED release policy");
+  Texture textureAfter = actor.GetRendererAt(0u).GetTextures().GetTexture(0u);
+  DALI_TEST_CHECK(textureBefore == textureAfter);
+  textureBefore.Reset();
+  textureAfter.Reset();
 
   dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
   DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
index 24a8ea2..87ef902 100644 (file)
@@ -167,22 +167,20 @@ TextureCacheManager::LoadState TextureCacheManager::GetTextureStateInternal(cons
   return loadState;
 }
 
-TextureSet TextureCacheManager::GetTextureSet(const TextureCacheManager::TextureId& textureId)
+Texture TextureCacheManager::GetTexture(const TextureCacheManager::TextureId& textureId, uint32_t textureIndex)
 {
-  TextureSet        textureSet; // empty handle
-  TextureCacheIndex cacheIndex = static_cast<TextureCacheIndex>(mTextureIdConverter[static_cast<std::uint32_t>(textureId)]);
+  Texture        texture; // empty handle
+  TextureCacheIndex cacheIndex = GetCacheIndexFromId(textureId);
 
   switch(static_cast<TextureCacheIndexType>(cacheIndex.detailValue.type))
   {
     case TextureCacheIndexType::TEXTURE_CACHE_INDEX_TYPE_LOCAL:
     {
       TextureInfo& cachedTextureInfo(mTextureInfoContainer[cacheIndex.GetIndex()]);
-      textureSet = cachedTextureInfo.textureSet;
-      break;
-    }
-    case TextureCacheIndexType::TEXTURE_CACHE_INDEX_TYPE_TEXTURE:
-    {
-      textureSet = mExternalTextures[cacheIndex.GetIndex()].textureSet;
+      if(textureIndex < static_cast<uint32_t>(cachedTextureInfo.textures.size()))
+      {
+        texture = cachedTextureInfo.textures[textureIndex];
+      }
       break;
     }
     default:
@@ -191,7 +189,7 @@ TextureSet TextureCacheManager::GetTextureSet(const TextureCacheManager::Texture
     }
   }
 
-  return textureSet;
+  return texture;
 }
 
 TextureSet TextureCacheManager::GetExternalTextureSet(const TextureCacheManager::TextureId& textureId)
index fb7dfd7..c68c233 100644 (file)
@@ -102,7 +102,7 @@ public:
   /**
    * @brief Get the current state of a texture
    * @note This API doesn't consider encodedimagebuffer.
-   * @param[in] textureId The texture id to query
+   * @param[in] textureId The texture id to query.defaul value is 0.
    * @return The loading state if the texture is valid, or NOT_STARTED if the textureId
    * is not valid.
    */
@@ -120,9 +120,10 @@ public:
   /**
    * @brief Get the associated texture set if the texture id is valid
    * @param[in] textureId The texture Id to look up
-   * @return the associated texture set, or an empty handle if textureId is not valid
+   * @param[in] textureIndex The texture index to query
+   * @return the associated texture, or an empty handle if textureId is not valid
    */
-  TextureSet GetTextureSet(const TextureCacheManager::TextureId& textureId);
+  Texture GetTexture(const TextureCacheManager::TextureId& textureId, uint32_t textureIndex = 0);
 
   /**
    * @brief Get the external texture set if the texture id is valid
index e23ee49..2bb79a2 100644 (file)
@@ -37,6 +37,9 @@ constexpr auto INITIAL_HASH_NUMBER                     = size_t{0u};
 constexpr auto DEFAULT_NUMBER_OF_LOCAL_LOADER_THREADS  = size_t{4u};
 constexpr auto DEFAULT_NUMBER_OF_REMOTE_LOADER_THREADS = size_t{8u};
 
+constexpr auto TEXTURE_INDEX       = 0u; ///< The Index for texture
+constexpr auto MASK_TEXTURE_INDEX  = 1u; ///< The Index for mask texture
+
 constexpr auto NUMBER_OF_LOCAL_LOADER_THREADS_ENV  = "DALI_TEXTURE_LOCAL_THREADS";
 constexpr auto NUMBER_OF_REMOTE_LOADER_THREADS_ENV = "DALI_TEXTURE_REMOTE_THREADS";
 constexpr auto LOAD_IMAGE_YUV_PLANES_ENV           = "DALI_LOAD_IMAGE_YUV_PLANES";
@@ -155,8 +158,6 @@ TextureSet TextureManager::LoadAnimatedImageTexture(
   TextureManager::TextureId&      textureId,
   MaskingDataPointer&             maskInfo,
   const Dali::SamplingMode::Type& samplingMode,
-  const Dali::WrapMode::Type&     wrapModeU,
-  const Dali::WrapMode::Type&     wrapModeV,
   const bool&                     synchronousLoading,
   TextureUploadObserver*          textureObserver,
   TextureManager::MultiplyOnLoad& preMultiplyOnLoad)
@@ -210,10 +211,10 @@ TextureSet TextureManager::LoadAnimatedImageTexture(
         Texture texture = Texture::New(Dali::TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight());
         texture.Upload(pixelData);
         textureSet = TextureSet::New();
-        textureSet.SetTexture(0u, texture);
+        textureSet.SetTexture(TEXTURE_INDEX, texture);
         if(maskTexture)
         {
-          textureSet.SetTexture(1u, maskTexture);
+          textureSet.SetTexture(MASK_TEXTURE_INDEX, maskTexture);
         }
       }
     }
@@ -244,13 +245,6 @@ TextureSet TextureManager::LoadAnimatedImageTexture(
     }
   }
 
-  if(textureSet)
-  {
-    Sampler sampler = Sampler::New();
-    sampler.SetWrapMode(wrapModeU, wrapModeV);
-    textureSet.SetSampler(0u, sampler);
-  }
-
   return textureSet;
 }
 
@@ -307,8 +301,6 @@ TextureSet TextureManager::LoadTexture(
   Dali::ImageDimensions&              textureRectSize,
   bool&                               atlasingStatus,
   bool&                               loadingStatus,
-  const Dali::WrapMode::Type&         wrapModeU,
-  const Dali::WrapMode::Type&         wrapModeV,
   TextureUploadObserver*              textureObserver,
   AtlasUploadObserver*                atlasObserver,
   ImageAtlasManagerPtr                imageAtlasManager,
@@ -444,7 +436,7 @@ TextureSet TextureManager::LoadTexture(
         if(loadState == TextureManager::LoadState::UPLOADED)
         {
           // LoadComplete has already been called - keep the same texture set
-          textureSet = mTextureCacheManager.GetTextureSet(textureId);
+          textureSet = GetTextureSet(textureId);
         }
 
         // If we are loading the texture, or waiting for the ready signal handler to complete, inform
@@ -463,13 +455,6 @@ TextureSet TextureManager::LoadTexture(
     }
   }
 
-  if(!atlasingStatus && textureSet)
-  {
-    Sampler sampler = Sampler::New();
-    sampler.SetWrapMode(wrapModeU, wrapModeV);
-    textureSet.SetSampler(0u, sampler);
-  }
-
   if(synchronousLoading)
   {
     loadingStatus = false;
@@ -683,10 +668,9 @@ TextureManager::TextureId TextureManager::RequestLoadInternal(
           {
             if(mTextureCacheManager[maskCacheIndex].storageType == StorageType::KEEP_TEXTURE)
             {
-              TextureSet maskTextures = mTextureCacheManager[maskCacheIndex].textureSet;
-              if(maskTextures && maskTextures.GetTextureCount())
+              if(!mTextureCacheManager[maskCacheIndex].textures.empty())
               {
-                maskTexture = maskTextures.GetTexture(0u);
+                maskTexture = mTextureCacheManager[maskCacheIndex].textures[0];
               }
             }
             else if(mTextureCacheManager[maskCacheIndex].storageType == StorageType::KEEP_PIXEL_BUFFER)
@@ -711,13 +695,10 @@ TextureManager::TextureId TextureManager::RequestLoadInternal(
 
         // Upload texture
         UploadTextures(pixelBuffers, textureInfo);
-        if(maskTexture && textureInfo.textureSet)
-        {
-          textureInfo.textureSet.SetTexture(1u, maskTexture);
-        }
       }
     }
   }
+
   return textureId;
 }
 
@@ -1014,11 +995,7 @@ void TextureManager::PostLoad(TextureManager::TextureInfo& textureInfo, std::vec
                   {
                     // Upload image texture. textureInfo.loadState will be UPLOADED.
                     UploadTextures(pixelBuffers, textureInfo);
-                    if(maskTextureInfo.textureSet.GetTextureCount() > 0u)
-                    {
-                      Texture maskTexture = maskTextureInfo.textureSet.GetTexture(0u);
-                      textureInfo.textureSet.SetTexture(1u, maskTexture);
-                    }
+
                     // notify mask texture set.
                     NotifyObservers(textureInfo, true);
                   }
@@ -1123,11 +1100,7 @@ void TextureManager::CheckForWaitingTexture(TextureManager::TextureInfo& maskTex
           std::vector<Devel::PixelBuffer> pixelBuffers;
           pixelBuffers.push_back(textureInfo.pixelBuffer);
           UploadTextures(pixelBuffers, textureInfo);
-          if(maskTextureInfo.textureSet.GetTextureCount() > 0u)
-          {
-            Texture maskTexture = maskTextureInfo.textureSet.GetTexture(0u);
-            textureInfo.textureSet.SetTexture(1u, maskTexture);
-          }
+
           // notify mask texture set.
           NotifyObservers(textureInfo, true);
         }
@@ -1180,19 +1153,15 @@ void TextureManager::UploadTextures(std::vector<Devel::PixelBuffer>& pixelBuffer
       renderingAddOn.CreateGeometry(textureInfo.textureId, pixelBuffers[0]);
     }
 
-    if(!textureInfo.textureSet)
-    {
-      textureInfo.textureSet = TextureSet::New();
-    }
+    // Remove previous textures and insert new textures
+    textureInfo.textures.clear();
 
-    uint32_t index = 0;
     for(auto&& pixelBuffer : pixelBuffers)
     {
       Texture texture = Texture::New(Dali::TextureType::TEXTURE_2D, pixelBuffer.GetPixelFormat(), pixelBuffer.GetWidth(), pixelBuffer.GetHeight());
-
       PixelData pixelData = Devel::PixelBuffer::Convert(pixelBuffer);
       texture.Upload(pixelData);
-      textureInfo.textureSet.SetTexture(index++, texture);
+      textureInfo.textures.push_back(texture);
     }
   }
 
@@ -1309,14 +1278,75 @@ void TextureManager::EmitLoadComplete(TextureUploadObserver* observer, TextureMa
   {
     observer->LoadComplete(success, TextureUploadObserver::TextureInformation(TextureUploadObserver::ReturnType::PIXEL_BUFFER, textureInfo.pixelBuffer, textureInfo.url.GetUrl(), textureInfo.preMultiplied));
   }
-  else if(textureInfo.isAnimatedImageFormat)
+  else
   {
-    observer->LoadComplete(success, TextureUploadObserver::TextureInformation(TextureUploadObserver::ReturnType::ANIMATED_IMAGE_TEXTURE, textureInfo.textureId, textureInfo.frameCount, textureInfo.frameInterval));
+    TextureSet textureSet = GetTextureSet(textureInfo);
+    if(textureInfo.isAnimatedImageFormat)
+    {
+      observer->LoadComplete(success, TextureUploadObserver::TextureInformation(TextureUploadObserver::ReturnType::ANIMATED_IMAGE_TEXTURE, textureInfo.textureId, textureSet, textureInfo.frameCount, textureInfo.frameInterval));
+    }
+    else
+    {
+      observer->LoadComplete(success, TextureUploadObserver::TextureInformation(TextureUploadObserver::ReturnType::TEXTURE, textureInfo.textureId, textureSet, (textureInfo.useAtlas == UseAtlas::USE_ATLAS) ? true : false, textureInfo.atlasRect, textureInfo.preMultiplied));
+    }
+  }
+}
+
+TextureSet TextureManager::GetTextureSet(const TextureManager::TextureId& textureId)
+{
+  TextureSet textureSet;
+  TextureManager::LoadState loadState = mTextureCacheManager.GetTextureStateInternal(textureId);
+  if(loadState == TextureManager::LoadState::UPLOADED)
+  {
+    // LoadComplete has already been called - keep the same texture set
+    TextureCacheIndex textureCacheIndex = mTextureCacheManager.GetCacheIndexFromId(textureId);
+    if(textureCacheIndex != INVALID_CACHE_INDEX)
+    {
+      TextureInfo& textureInfo(mTextureCacheManager[textureCacheIndex]);
+      textureSet = GetTextureSet(textureInfo);
+    }
   }
   else
   {
-    observer->LoadComplete(success, TextureUploadObserver::TextureInformation(TextureUploadObserver::ReturnType::TEXTURE, textureInfo.textureId, textureInfo.textureSet, (textureInfo.useAtlas == UseAtlas::USE_ATLAS) ? true : false, textureInfo.atlasRect, textureInfo.preMultiplied));
+    DALI_LOG_ERROR("GetTextureSet is failed. texture is not uploaded \n");
+  }
+  return textureSet;
+}
+
+TextureSet TextureManager::GetTextureSet(const TextureManager::TextureInfo& textureInfo)
+{
+  TextureSet textureSet;
+
+  // LoadComplete has already been called - keep the same texture set
+  textureSet = TextureSet::New();
+  if(!textureInfo.textures.empty())
+  {
+    if(textureInfo.textures.size() > 1) // For YUV case
+    {
+      uint32_t index = 0u;
+      for(auto&& texture : textureInfo.textures)
+      {
+        textureSet.SetTexture(index++, texture);
+      }
+    }
+    else
+    {
+      textureSet.SetTexture(TEXTURE_INDEX, textureInfo.textures[0]);
+      TextureCacheIndex maskCacheIndex = mTextureCacheManager.GetCacheIndexFromId(textureInfo.maskTextureId);
+      if(maskCacheIndex != INVALID_CACHE_INDEX)
+      {
+        TextureInfo& maskTextureInfo(mTextureCacheManager[maskCacheIndex]);
+        if(maskTextureInfo.storageType == StorageType::UPLOAD_TO_TEXTURE || maskTextureInfo.storageType == StorageType::KEEP_TEXTURE)
+        {
+          if(!maskTextureInfo.textures.empty())
+          {
+            textureSet.SetTexture(MASK_TEXTURE_INDEX, maskTextureInfo.textures[0]);
+          }
+        }
+      }
+    }
   }
+  return textureSet;
 }
 
 } // namespace Internal
index 5601052..777c4df 100644 (file)
@@ -120,8 +120,6 @@ public:
    * @param[out] textureId             The textureId of the frame
    * @param[in, out] maskInfo          Mask info structure
    * @param[in]  samplingMode          The SamplingMode to use
-   * @param[in]  wrapModeU             Horizontal Wrap mode
-   * @param[in]  wrapModeV             Vertical Wrap mode
    * @param[in]  synchronousLoading    true if the frame should be loaded synchronously
    * @param[in]  textureObserver       The client object should inherit from this and provide the "LoadCompleted" virtual.
    *                                   This is called when an image load completes (or fails).
@@ -136,8 +134,6 @@ public:
                                       TextureManager::TextureId&      textureId,
                                       MaskingDataPointer&             maskInfo,
                                       const Dali::SamplingMode::Type& samplingMode,
-                                      const Dali::WrapMode::Type&     wrapModeU,
-                                      const Dali::WrapMode::Type&     wrapModeV,
                                       const bool&                     synchronousLoading,
                                       TextureUploadObserver*          textureObserver,
                                       TextureManager::MultiplyOnLoad& preMultiplyOnLoad);
@@ -194,8 +190,6 @@ public:
    *                                  be loaded, and marked successful, but this will be set to false.
    *                                  If atlasing succeeds, this will be set to true.
    * @param[out] loadingStatus        The loading status of the texture
-   * @param[in] wrapModeU             Horizontal Wrap mode
-   * @param[in] wrapModeV             Vertical Wrap mode
    * @param[in] textureObserver       The client object should inherit from this and provide the "LoadCompleted" virtual.
    *                                  This is called when an image load completes (or fails).
    * @param[in] atlasObserver         This is used if the texture is atlased, and will be called instead of
@@ -220,8 +214,6 @@ public:
     Dali::ImageDimensions&              textureRectSize,
     bool&                               atlasingStatus,
     bool&                               loadingStatus,
-    const Dali::WrapMode::Type&         wrapModeU,
-    const Dali::WrapMode::Type&         wrapModeV,
     TextureUploadObserver*              textureObserver,
     AtlasUploadObserver*                atlasObserver,
     ImageAtlasManagerPtr                imageAtlasManager,
@@ -262,6 +254,20 @@ public:
    */
   Geometry GetRenderGeometry(const TextureManager::TextureId& textureId, std::uint32_t& frontElements, std::uint32_t& backElements);
 
+  /**
+   * @brief Returns the textureSet in texture manager.
+   * @param[in] textureId Id of the texture
+   * @return The textureSet in texture manager. These textures include YUV textures or images and masks.
+   */
+  TextureSet GetTextureSet(const TextureManager::TextureId& textureId);
+
+  /**
+   * @brief Returns the textureSet in texture manager.
+   * @param[in] textureInfo the information of the texture
+   * @return The textureSet in texture manager. These textures include YUV textures or images and masks.
+   */
+  TextureSet GetTextureSet(const TextureManager::TextureInfo& textureInfo);
+
 public:
   // API list that need to access TextureCacheManager.
 
@@ -274,11 +280,11 @@ public:
   }
 
   /**
-   * @copydoc TextureCacheManager::GetTextureSet
+   * @copydoc TextureCacheManager::GetTexture
    */
-  inline TextureSet GetTextureSet(const TextureManager::TextureId& textureId)
+  inline Texture GetTexture(const TextureManager::TextureId& textureId)
   {
-    return mTextureCacheManager.GetTextureSet(textureId);
+    return mTextureCacheManager.GetTexture(textureId);
   }
 
   /**
index 98c5baa..adffcf9 100644 (file)
@@ -281,7 +281,7 @@ struct TextureInfo
   ObserverListType           observerList;         ///< Container used to store all observer clients of this Texture
   Dali::Toolkit::ImageAtlas  atlas;                ///< The atlas this Texture lays within (if any)
   Dali::Devel::PixelBuffer   pixelBuffer;          ///< The PixelBuffer holding the image data (May be empty after upload)
-  Dali::TextureSet           textureSet;           ///< The TextureSet holding the Texture
+  std::vector<Dali::Texture> textures;             ///< The Textures
   VisualUrl                  url;                  ///< The URL of the image
   Dali::ImageDimensions      desiredSize;          ///< The size requested
   Dali::ImageDimensions      useSize;              ///< The size used
index 1e59c2d..ee8ff1c 100644 (file)
@@ -61,10 +61,10 @@ TextureUploadObserver::TextureInformation::TextureInformation(ReturnType returnT
 {
 }
 
-TextureUploadObserver::TextureInformation::TextureInformation(ReturnType returnType, int32_t textureId, uint32_t frameCount, uint32_t interval)
+TextureUploadObserver::TextureInformation::TextureInformation(ReturnType returnType, int32_t textureId, TextureSet textureSet, uint32_t frameCount, uint32_t interval)
 : returnType(returnType),
   textureId(textureId),
-  textureSet(),
+  textureSet(textureSet),
   useAtlasing(false),
   atlasRect(Vector4::ZERO),
   preMultiplied(false),
index 4180d20..82b6691 100644 (file)
@@ -54,7 +54,7 @@ public:
     TextureInformation(ReturnType returnType, int32_t textureId, TextureSet textureSet, bool useAtlasing, const Vector4& atlasRect, bool preMultiplied);
     TextureInformation(ReturnType returnType, int32_t textureId, TextureSet textureSet, const std::string& url, bool preMultiplied);
     TextureInformation(ReturnType returnType, Devel::PixelBuffer pixelBuffer, const std::string& url, bool preMultiplied);
-    TextureInformation(ReturnType returnType, int32_t textureId, uint32_t frameCount, uint32_t interval);
+    TextureInformation(ReturnType returnType, int32_t textureId, TextureSet textureSet, uint32_t frameCount, uint32_t interval);
 
     TextureInformation();
 
index 97b8d35..2831d6f 100644 (file)
@@ -132,16 +132,21 @@ void FixedImageCache::LoadBatch()
     Dali::ImageDimensions textureRectSize;
     auto                  preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
 
-    mTextureManager.LoadTexture(
-      url, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, mMaskingData, synchronousLoading, mImageUrls[frameIndex].mTextureId, textureRect, textureRectSize, atlasingStatus, loadingStatus, Dali::WrapMode::Type::DEFAULT, Dali::WrapMode::Type::DEFAULT, this, atlasObserver, imageAtlasManager, ENABLE_ORIENTATION_CORRECTION, TextureManager::ReloadPolicy::CACHED, preMultiply);
-
+    mTextureManager.LoadTexture(url, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, mMaskingData, synchronousLoading, mImageUrls[frameIndex].mTextureId, textureRect, textureRectSize, atlasingStatus, loadingStatus, this, atlasObserver, imageAtlasManager, ENABLE_ORIENTATION_CORRECTION, TextureManager::ReloadPolicy::CACHED, preMultiply);
     mRequestingLoad = false;
   }
 }
 
 TextureSet FixedImageCache::GetFrontTextureSet() const
 {
-  return mTextureManager.GetTextureSet(mImageUrls[mFront].mTextureId);
+  TextureSet textureSet = mTextureManager.GetTextureSet(mImageUrls[mFront].mTextureId);
+  if(textureSet)
+  {
+    Sampler sampler = Sampler::New();
+    sampler.SetWrapMode(Dali::WrapMode::Type::DEFAULT, Dali::WrapMode::Type::DEFAULT);
+    textureSet.SetSampler(0u, sampler);
+  }
+  return textureSet;
 }
 
 void FixedImageCache::CheckFrontFrame(bool wasReady)
index b8a6961..9838f08 100644 (file)
@@ -208,11 +208,15 @@ TextureSet RollingAnimatedImageCache::RequestFrameLoading(uint32_t frameIndex, b
                                                                    loadTextureId,
                                                                    mMaskingData,
                                                                    SamplingMode::BOX_THEN_LINEAR,
-                                                                   mWrapModeU,
-                                                                   mWrapModeV,
                                                                    synchronousLoading,
                                                                    this,
                                                                    preMultiplyOnLoading);
+  if(textureSet)
+  {
+    Sampler sampler = Sampler::New();
+    sampler.SetWrapMode(mWrapModeU, mWrapModeV);
+    textureSet.SetSampler(0u, sampler);
+  }
 
   mTextureIds[frameIndex] = loadTextureId;
 
@@ -260,7 +264,14 @@ TextureSet RollingAnimatedImageCache::GetFrontTextureSet() const
   DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "RollingAnimatedImageCache::GetFrontTextureSet() FrameNumber:%d\n", mQueue[0].mFrameNumber);
 
   TextureManager::TextureId textureId = GetCachedTextureId(0);
-  return mTextureManager.GetTextureSet(textureId);
+  TextureSet textureSet = mTextureManager.GetTextureSet(textureId);
+  if(textureSet)
+  {
+    Sampler sampler = Sampler::New();
+    sampler.SetWrapMode(mWrapModeU, mWrapModeV);
+    textureSet.SetSampler(0u, sampler);
+  }
+  return textureSet;
 }
 
 TextureManager::TextureId RollingAnimatedImageCache::GetCachedTextureId(int index) const
@@ -332,15 +343,14 @@ void RollingAnimatedImageCache::LoadComplete(bool loadSuccess, TextureInformatio
   DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "AnimatedImageVisual::LoadComplete(textureId:%d) start\n", textureInformation.textureId);
   LOG_CACHE;
 
-  TextureSet textureSet = mTextureManager.GetTextureSet(textureInformation.textureId);
-  if(textureSet)
+  if(textureInformation.textureSet)
   {
     Sampler sampler = Sampler::New();
     sampler.SetWrapMode(mWrapModeU, mWrapModeV);
-    textureSet.SetSampler(0u, sampler);
+    textureInformation.textureSet.SetSampler(0u, sampler);
   }
 
-  MakeFrameReady(loadSuccess, textureSet, textureInformation.interval);
+  MakeFrameReady(loadSuccess, textureInformation.textureSet, textureInformation.interval);
 
   if(loadSuccess)
   {
index 7a84f5b..0b8c4a4 100644 (file)
@@ -168,7 +168,7 @@ void RollingImageCache::LoadBatch(uint32_t frameIndex)
 
     TextureManager::TextureId loadTextureId = TextureManager::INVALID_TEXTURE_ID;
     TextureSet                textureSet    = mTextureManager.LoadTexture(
-      url, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, mMaskingData, synchronousLoading, loadTextureId, textureRect, textureRectSize, atlasingStatus, loadingStatus, Dali::WrapMode::Type::DEFAULT, Dali::WrapMode::Type::DEFAULT, this, atlasObserver, imageAtlasManager, ENABLE_ORIENTATION_CORRECTION, TextureManager::ReloadPolicy::CACHED, preMultiply);
+      url, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, mMaskingData, synchronousLoading, loadTextureId, textureRect, textureRectSize, atlasingStatus, loadingStatus, this, atlasObserver, imageAtlasManager, ENABLE_ORIENTATION_CORRECTION, TextureManager::ReloadPolicy::CACHED, preMultiply);
     mImageUrls[imageFrame.mUrlIndex].mTextureId = loadTextureId;
 
     mRequestingLoad = false;
@@ -181,7 +181,14 @@ void RollingImageCache::LoadBatch(uint32_t frameIndex)
 TextureSet RollingImageCache::GetFrontTextureSet() const
 {
   TextureManager::TextureId textureId = GetCachedTextureId(0);
-  return mTextureManager.GetTextureSet(textureId);
+  TextureSet textureSet = mTextureManager.GetTextureSet(textureId);
+  if(textureSet)
+  {
+    Sampler sampler = Sampler::New();
+    sampler.SetWrapMode(Dali::WrapMode::Type::DEFAULT, Dali::WrapMode::Type::DEFAULT);
+    textureSet.SetSampler(0u, sampler);
+  }
+  return textureSet;
 }
 
 TextureManager::TextureId RollingImageCache::GetCachedTextureId(int index) const
@@ -244,7 +251,13 @@ void RollingImageCache::LoadComplete(bool loadSuccess, TextureInformation textur
 
     if(!frontFrameReady && IsFrontReady())
     {
-      mObserver.FrameReady(mTextureManager.GetTextureSet(textureInformation.textureId), mInterval);
+      if(textureInformation.textureSet)
+      {
+        Sampler sampler = Sampler::New();
+        sampler.SetWrapMode(Dali::WrapMode::Type::DEFAULT, Dali::WrapMode::Type::DEFAULT);
+        textureInformation.textureSet.SetSampler(0u, sampler);
+      }
+      mObserver.FrameReady(textureInformation.textureSet, mInterval);
     }
   }
   else
index 87d6ea6..5c028ae 100644 (file)
@@ -618,7 +618,7 @@ void ImageVisual::LoadTexture(bool& atlasing, Vector4& atlasRect, TextureSet& te
   bool synchronousLoading = IsSynchronousLoadingRequired();
   bool loadingStatus;
 
-  textures = textureManager.LoadTexture(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, synchronousLoading, mTextureId, atlasRect, mAtlasRectSize, atlasing, loadingStatus, mWrapModeU, mWrapModeV, textureObserver, atlasUploadObserver, atlasManager, mOrientationCorrection, forceReload, preMultiplyOnLoad);
+  textures = textureManager.LoadTexture(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, synchronousLoading, mTextureId, atlasRect, mAtlasRectSize, atlasing, loadingStatus, textureObserver, atlasUploadObserver, atlasManager, mOrientationCorrection, forceReload, preMultiplyOnLoad);
 
   if(textures)
   {
@@ -632,6 +632,12 @@ void ImageVisual::LoadTexture(bool& atlasing, Vector4& atlasRect, TextureSet& te
     }
 
     EnablePreMultipliedAlpha(preMultiplyOnLoad == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD);
+    if(!atlasing)
+    {
+      Sampler sampler = Sampler::New();
+      sampler.SetWrapMode(mWrapModeU, mWrapModeV);
+      textures.SetSampler(0u, sampler);
+    }
   }
   else if(synchronousLoading)
   {
@@ -676,6 +682,12 @@ void ImageVisual::InitializeRenderer()
     else
     {
       mTextures = mFactoryCache.GetTextureManager().GetTextureSet(mTextureId);
+      if(!(mImpl->mFlags & Visual::Base::Impl::IS_ATLASING_APPLIED) && mTextures)
+      {
+        Sampler sampler = Sampler::New();
+        sampler.SetWrapMode(mWrapModeU, mWrapModeV);
+        mTextures.SetSampler(0u, sampler);
+      }
     }
   }
 
@@ -912,9 +924,13 @@ void ImageVisual::LoadComplete(bool loadingSuccess, TextureInformation textureIn
     }
     else
     {
-      Sampler sampler = Sampler::New();
-      sampler.SetWrapMode(mWrapModeU, mWrapModeV);
-      textureInformation.textureSet.SetSampler(0u, sampler);
+      if(!textureInformation.useAtlasing)
+      {
+        Sampler sampler = Sampler::New();
+        sampler.SetWrapMode(mWrapModeU, mWrapModeV);
+        textureInformation.textureSet.SetSampler(0u, sampler);
+      }
+
       mImpl->mRenderer.SetTextures(textureInformation.textureSet);
       ComputeTextureSize();
       CheckMaskTexture();
index f95a796..8b44d99 100644 (file)
@@ -102,7 +102,14 @@ void NPatchVisual::LoadImages()
     bool loadingStatus = false;
 
     // Load the auxiliary image
-    mAuxiliaryTextureSet = textureManager.LoadTexture(mAuxiliaryUrl, Dali::ImageDimensions(), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, maskingDataPtr, synchronousLoading, mAuxiliaryTextureId, atlasRect, atlasRectSize, atlasing, loadingStatus, WrapMode::DEFAULT, WrapMode::DEFAULT, this, nullptr, imageAtlasManagerPtr, true, TextureManager::ReloadPolicy::CACHED, preMultiplyOnLoad);
+    mAuxiliaryTextureSet = textureManager.LoadTexture(mAuxiliaryUrl, Dali::ImageDimensions(), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, maskingDataPtr, synchronousLoading, mAuxiliaryTextureId, atlasRect, atlasRectSize, atlasing, loadingStatus, this, nullptr, imageAtlasManagerPtr, true, TextureManager::ReloadPolicy::CACHED, preMultiplyOnLoad);
+
+    if(mAuxiliaryTextureSet)
+    {
+      Sampler sampler = Sampler::New();
+      sampler.SetWrapMode(WrapMode::DEFAULT, WrapMode::DEFAULT);
+      mAuxiliaryTextureSet.SetSampler(0u, sampler);
+    }
 
     // If synchronousLoading is true, we can check the auxiliaryResource's status now.
     if(synchronousLoading)
@@ -599,7 +606,14 @@ void NPatchVisual::LoadComplete(bool loadSuccess, TextureInformation textureInfo
     }
     if(loadSuccess)
     {
-      mAuxiliaryTextureSet     = textureInformation.textureSet;
+      mAuxiliaryTextureSet = textureInformation.textureSet;
+      if(mAuxiliaryTextureSet)
+      {
+        Sampler sampler = Sampler::New();
+        sampler.SetWrapMode(WrapMode::DEFAULT, WrapMode::DEFAULT);
+        mAuxiliaryTextureSet.SetSampler(0u, sampler);
+      }
+
       mAuxiliaryResourceStatus = Toolkit::Visual::ResourceStatus::READY;
     }
     else