[Tizen]Save textureId directly at RequsetLoad() resf/for/tizen_6.5
authorsunghyun kim <scholb.kim@samsung.com>
Wed, 30 Mar 2022 01:10:54 +0000 (10:10 +0900)
committersunghyun kim <scholb.kim@samsung.com>
Wed, 30 Mar 2022 06:42:12 +0000 (15:42 +0900)
if new animated image visual use previous texture, textureId is not updated properly some case.
To solve this problem, i changed the RequestLoad() can save texture id directly.

Change-Id: I56e8475384f101360c4f45f563e3d3d3e1b9d213

dali-toolkit/internal/visuals/texture-manager-impl.cpp
dali-toolkit/internal/visuals/texture-manager-impl.h

index 9a50a00..3d13c5a 100644 (file)
@@ -211,7 +211,7 @@ TextureSet TextureManager::LoadAnimatedImageTexture(Dali::AnimatedImageLoading a
     bool      cropToMask         = false;
     if(maskInfo && maskInfo->mAlphaMaskUrl.IsValid())
     {
-      maskInfo->mAlphaMaskId = RequestMaskLoad(maskInfo->mAlphaMaskUrl, maskInfo->mPreappliedMasking ? StorageType::KEEP_PIXEL_BUFFER : StorageType::KEEP_TEXTURE);
+      RequestMaskLoad(maskInfo->mAlphaMaskUrl, maskInfo->mPreappliedMasking ? StorageType::KEEP_PIXEL_BUFFER : StorageType::KEEP_TEXTURE, maskInfo->mAlphaMaskId);
       alphaMaskId            = maskInfo->mAlphaMaskId;
       contentScaleFactor     = maskInfo->mContentScaleFactor;
       cropToMask             = maskInfo->mCropToMask;
@@ -219,23 +219,24 @@ TextureSet TextureManager::LoadAnimatedImageTexture(Dali::AnimatedImageLoading a
 
     loadingStatus    = true;
     auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
-    textureId        = RequestLoadInternal(animatedImageLoading.GetUrl(),
-                                    alphaMaskId,
-                                    contentScaleFactor,
-                                    cropToMask,
-                                    desiredSize,
-                                    FittingMode::SCALE_TO_FILL,
-                                    samplingMode,
-                                    TextureManager::NO_ATLAS,
-                                    StorageType::UPLOAD_TO_TEXTURE,
-                                    textureObserver,
-                                    true,
-                                    TextureManager::ReloadPolicy::CACHED,
-                                    preMultiply,
-                                    animatedImageLoading,
-                                    frameIndex,
-                                    useCache,
-                                    false);
+    RequestLoadInternal(animatedImageLoading.GetUrl(),
+                        alphaMaskId,
+                        contentScaleFactor,
+                        cropToMask,
+                        desiredSize,
+                        FittingMode::SCALE_TO_FILL,
+                        samplingMode,
+                        TextureManager::NO_ATLAS,
+                        StorageType::UPLOAD_TO_TEXTURE,
+                        textureObserver,
+                        true,
+                        TextureManager::ReloadPolicy::CACHED,
+                        preMultiply,
+                        animatedImageLoading,
+                        frameIndex,
+                        useCache,
+                        false,
+                        textureId);
 
     TextureManager::LoadState loadState = GetTextureStateInternal(textureId);
     if(loadState == TextureManager::LoadState::UPLOADED)
@@ -292,7 +293,8 @@ Devel::PixelBuffer TextureManager::LoadPixelBuffer(
   }
   else
   {
-    RequestLoadInternal(url, INVALID_TEXTURE_ID, 1.0f, false, desiredSize, fittingMode, samplingMode, TextureManager::NO_ATLAS, StorageType::RETURN_PIXEL_BUFFER, textureObserver, orientationCorrection, TextureManager::ReloadPolicy::FORCED, preMultiplyOnLoad, Dali::AnimatedImageLoading(), 0u, false, false);
+    TextureManager::TextureId textureId = INVALID_TEXTURE_ID;
+    RequestLoadInternal(url, INVALID_TEXTURE_ID, 1.0f, false, desiredSize, fittingMode, samplingMode, TextureManager::NO_ATLAS, StorageType::RETURN_PIXEL_BUFFER, textureObserver, orientationCorrection, TextureManager::ReloadPolicy::FORCED, preMultiplyOnLoad, Dali::AnimatedImageLoading(), 0u, false, false, textureId);
   }
 
   return pixelBuffer;
@@ -409,23 +411,24 @@ TextureSet TextureManager::LoadTexture(const VisualUrl&                url,
       atlasingStatus = false;
       if(!maskInfo || !maskInfo->mAlphaMaskUrl.IsValid())
       {
-        textureId = RequestLoad(url, desiredSize, fittingMode, samplingMode, TextureManager::NO_ATLAS, textureObserver, orientationCorrection, reloadPolicy, preMultiplyOnLoad);
+        RequestLoad(url, desiredSize, fittingMode, samplingMode, TextureManager::NO_ATLAS, textureObserver, orientationCorrection, reloadPolicy, preMultiplyOnLoad, textureId);
       }
       else
       {
-        maskInfo->mAlphaMaskId = RequestMaskLoad(maskInfo->mAlphaMaskUrl, maskInfo->mPreappliedMasking ? StorageType::KEEP_PIXEL_BUFFER : StorageType::KEEP_TEXTURE);
-        textureId              = RequestLoad(url,
-                                maskInfo->mAlphaMaskId,
-                                maskInfo->mContentScaleFactor,
-                                desiredSize,
-                                fittingMode,
-                                samplingMode,
-                                TextureManager::NO_ATLAS,
-                                maskInfo->mCropToMask,
-                                textureObserver,
-                                orientationCorrection,
-                                reloadPolicy,
-                                preMultiplyOnLoad);
+        RequestMaskLoad(maskInfo->mAlphaMaskUrl, maskInfo->mPreappliedMasking ? StorageType::KEEP_PIXEL_BUFFER : StorageType::KEEP_TEXTURE, maskInfo->mAlphaMaskId);
+        RequestLoad(url,
+                    maskInfo->mAlphaMaskId,
+                    maskInfo->mContentScaleFactor,
+                    desiredSize,
+                    fittingMode,
+                    samplingMode,
+                    TextureManager::NO_ATLAS,
+                    maskInfo->mCropToMask,
+                    textureObserver,
+                    orientationCorrection,
+                    reloadPolicy,
+                    preMultiplyOnLoad,
+                    textureId);
       }
 
       TextureManager::LoadState loadState = GetTextureStateInternal(textureId);
@@ -460,7 +463,7 @@ TextureSet TextureManager::LoadTexture(const VisualUrl&                url,
   return textureSet;
 }
 
-TextureManager::TextureId TextureManager::RequestLoad(
+void TextureManager::RequestLoad(
   const VisualUrl&                url,
   const ImageDimensions           desiredSize,
   FittingMode::Type               fittingMode,
@@ -469,12 +472,13 @@ TextureManager::TextureId TextureManager::RequestLoad(
   TextureUploadObserver*          observer,
   bool                            orientationCorrection,
   TextureManager::ReloadPolicy    reloadPolicy,
-  TextureManager::MultiplyOnLoad& preMultiplyOnLoad)
+  TextureManager::MultiplyOnLoad& preMultiplyOnLoad,
+  TextureId&                      textureId)
 {
-  return RequestLoadInternal(url, INVALID_TEXTURE_ID, 1.0f, false, desiredSize, fittingMode, samplingMode, useAtlas, StorageType::UPLOAD_TO_TEXTURE, observer, orientationCorrection, reloadPolicy, preMultiplyOnLoad, Dali::AnimatedImageLoading(), 0u, true, true);
+  RequestLoadInternal(url, INVALID_TEXTURE_ID, 1.0f, false, desiredSize, fittingMode, samplingMode, useAtlas, StorageType::UPLOAD_TO_TEXTURE, observer, orientationCorrection, reloadPolicy, preMultiplyOnLoad, Dali::AnimatedImageLoading(), 0u, true, true, textureId);
 }
 
-TextureManager::TextureId TextureManager::RequestLoad(
+void TextureManager::RequestLoad(
   const VisualUrl&                url,
   TextureId                       maskTextureId,
   float                           contentScale,
@@ -486,20 +490,21 @@ TextureManager::TextureId TextureManager::RequestLoad(
   TextureUploadObserver*          observer,
   bool                            orientationCorrection,
   TextureManager::ReloadPolicy    reloadPolicy,
-  TextureManager::MultiplyOnLoad& preMultiplyOnLoad)
+  TextureManager::MultiplyOnLoad& preMultiplyOnLoad,
+  TextureId&                      textureId)
 {
   bool loadYuvPlanes = (maskTextureId == INVALID_TEXTURE_ID) ? true : false;
-  return RequestLoadInternal(url, maskTextureId, contentScale, cropToMask, desiredSize, fittingMode, samplingMode, useAtlas, StorageType::UPLOAD_TO_TEXTURE, observer, orientationCorrection, reloadPolicy, preMultiplyOnLoad, Dali::AnimatedImageLoading(), 0u, true, loadYuvPlanes);
+  RequestLoadInternal(url, maskTextureId, contentScale, cropToMask, desiredSize, fittingMode, samplingMode, useAtlas, StorageType::UPLOAD_TO_TEXTURE, observer, orientationCorrection, reloadPolicy, preMultiplyOnLoad, Dali::AnimatedImageLoading(), 0u, true, loadYuvPlanes, textureId);
 }
 
-TextureManager::TextureId TextureManager::RequestMaskLoad(const VisualUrl& maskUrl, StorageType storageType)
+void TextureManager::RequestMaskLoad(const VisualUrl& maskUrl, StorageType storageType, TextureId& textureId)
 {
   // Use the normal load procedure to get the alpha mask.
   auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
-  return RequestLoadInternal(maskUrl, INVALID_TEXTURE_ID, 1.0f, false, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, NO_ATLAS, storageType, NULL, true, TextureManager::ReloadPolicy::CACHED, preMultiply, Dali::AnimatedImageLoading(), 0u, true, false);
+  RequestLoadInternal(maskUrl, INVALID_TEXTURE_ID, 1.0f, false, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, NO_ATLAS, storageType, NULL, true, TextureManager::ReloadPolicy::CACHED, preMultiply, Dali::AnimatedImageLoading(), 0u, true, false, textureId);
 }
 
-TextureManager::TextureId TextureManager::RequestLoadInternal(
+void TextureManager::RequestLoadInternal(
   const VisualUrl&                url,
   TextureId                       maskTextureId,
   float                           contentScale,
@@ -516,7 +521,8 @@ TextureManager::TextureId TextureManager::RequestLoadInternal(
   Dali::AnimatedImageLoading      animatedImageLoading,
   uint32_t                        frameIndex,
   bool                            useCache,
-  bool                            loadYuvPlanes)
+  bool                            loadYuvPlanes,
+  TextureId&                      textureId)
 {
   // First check if the requested Texture is cached.
   TextureHash textureHash = INITIAL_CACHE_NUMBER;
@@ -529,7 +535,7 @@ TextureManager::TextureId TextureManager::RequestLoadInternal(
     cacheIndex = FindCachedTexture(textureHash, url.GetUrl(), desiredSize, fittingMode, samplingMode, useAtlas, storageType, maskTextureId, preMultiplyOnLoad, (animatedImageLoading) ? true : false, cropToMask);
   }
 
-  TextureManager::TextureId textureId = INVALID_TEXTURE_ID;
+  textureId = INVALID_TEXTURE_ID;
   // Check if the requested Texture exists in the cache.
   if(cacheIndex != INVALID_CACHE_INDEX)
   {
@@ -652,9 +658,6 @@ TextureManager::TextureId TextureManager::RequestLoadInternal(
       break;
     }
   }
-
-  // Return the TextureId for which this Texture can now be referenced by externally.
-  return textureId;
 }
 
 void TextureManager::Remove(const TextureManager::TextureId textureId, TextureUploadObserver* observer)
index 2ef7801..5e46a02 100644 (file)
@@ -303,9 +303,9 @@ public:
    * @param[in] orientationCorrection Whether to rotate image to match embedded orientation data
    * @param[in] reloadPolicy          Forces a reload of the texture even if already cached
    * @param[in,out] preMultiplyOnLoad     True if the image color should be multiplied by it's alpha. Set to false if the image has no alpha channel
-   * @return                          A TextureId to use as a handle to reference this Texture
+   * @param[out] textureId            The TextureId to use as a handle to reference this Texture
    */
-  TextureId RequestLoad(const VisualUrl&             url,
+  void      RequestLoad(const VisualUrl&             url,
                         const ImageDimensions        desiredSize,
                         FittingMode::Type            fittingMode,
                         Dali::SamplingMode::Type     samplingMode,
@@ -313,7 +313,8 @@ public:
                         TextureUploadObserver*       observer,
                         bool                         orientationCorrection,
                         TextureManager::ReloadPolicy reloadPolicy,
-                        MultiplyOnLoad&              preMultiplyOnLoad);
+                        MultiplyOnLoad&              preMultiplyOnLoad,
+                        TextureId&                   textureId);
 
   /**
    * @brief Requests an image load of the given URL, when the texture has
@@ -345,9 +346,9 @@ public:
    * @param[in] reloadPolicy          Forces a reload of the texture even if already cached
    * @param[in] preMultiplyOnLoad     True if the image color should be multiplied by it's alpha. Set to false if the
    *                                  image has no alpha channel
-   * @return                          A TextureId to use as a handle to reference this Texture
+   * @param[out] textureId            The TextureId to use as a handle to reference this Texture
    */
-  TextureId RequestLoad(const VisualUrl&             url,
+  void      RequestLoad(const VisualUrl&             url,
                         TextureId                    maskTextureId,
                         float                        contentScale,
                         const ImageDimensions        desiredSize,
@@ -358,13 +359,14 @@ public:
                         TextureUploadObserver*       observer,
                         bool                         orientationCorrection,
                         TextureManager::ReloadPolicy reloadPolicy,
-                        MultiplyOnLoad&              preMultiplyOnLoad);
+                        MultiplyOnLoad&              preMultiplyOnLoad,
+                        TextureId&                   textureId);
 
   /**
    * Requests a masking image to be loaded. This mask is not uploaded to GL,
    * instead, it is stored in CPU memory, and can be used for CPU blending.
    */
-  TextureId RequestMaskLoad(const VisualUrl& maskUrl, StorageType storageType);
+  void RequestMaskLoad(const VisualUrl& maskUrl, StorageType storageType, TextureId& textureId);
 
   /**
    * @brief Remove a Texture from the TextureManager.
@@ -502,9 +504,11 @@ private:
    *                                  there is no alpha
    * @param[in] animatedImageLoading  The AnimatedImageLoading to load animated image
    * @param[in] frameIndex            The frame index of a frame to be loaded frame
-   * @return                          A TextureId to use as a handle to reference this Texture
+   * @param[in] useCache              True if use cached
+   * @param[in] loadYuvPlanes         The YUV Planes
+   * @param[out] textureId            The TextureId to use as a handle to reference this Texture
    */
-  TextureId RequestLoadInternal(
+  void RequestLoadInternal(
     const VisualUrl&             url,
     TextureId                    maskTextureId,
     float                        contentScale,
@@ -521,7 +525,8 @@ private:
     Dali::AnimatedImageLoading   animatedImageLoading,
     uint32_t                     frameIndex,
     bool                         useCache,
-    bool                         loadYuvPlanes);
+    bool                         loadYuvPlanes,
+    TextureId&                   textureId);
 
   /**
    * @brief Get the current state of a texture