[Tizen] Caching cropToMask in texture manager 51/271151/4 submit/tizen_6.5/20220222.065506
authortscholb <scholb.kim@samsung.com>
Mon, 14 Feb 2022 08:09:43 +0000 (17:09 +0900)
committertscholb <scholb.kim@samsung.com>
Thu, 17 Feb 2022 04:57:27 +0000 (13:57 +0900)
cropToMask need to be cahing,
so i added this patch

Change-Id: I9efd84a1aa03b2050aed97071e123b9fec91167d

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

index 7334cf7..9a50a00 100644 (file)
@@ -523,10 +523,10 @@ TextureManager::TextureId TextureManager::RequestLoadInternal(
   int         cacheIndex  = INVALID_CACHE_INDEX;
   if(storageType != StorageType::RETURN_PIXEL_BUFFER && useCache)
   {
-    textureHash = GenerateHash(url.GetUrl(), desiredSize, fittingMode, samplingMode, useAtlas, maskTextureId);
+    textureHash = GenerateHash(url.GetUrl(), desiredSize, fittingMode, samplingMode, useAtlas, maskTextureId, cropToMask);
 
     // Look up the texture by hash. Note: The extra parameters are used in case of a hash collision.
-    cacheIndex = FindCachedTexture(textureHash, url.GetUrl(), desiredSize, fittingMode, samplingMode, useAtlas, storageType, maskTextureId, preMultiplyOnLoad, (animatedImageLoading) ? true : false);
+    cacheIndex = FindCachedTexture(textureHash, url.GetUrl(), desiredSize, fittingMode, samplingMode, useAtlas, storageType, maskTextureId, preMultiplyOnLoad, (animatedImageLoading) ? true : false, cropToMask);
   }
 
   TextureManager::TextureId textureId = INVALID_TEXTURE_ID;
@@ -1494,7 +1494,8 @@ TextureManager::TextureHash TextureManager::GenerateHash(
   const FittingMode::Type        fittingMode,
   const Dali::SamplingMode::Type samplingMode,
   const UseAtlas                 useAtlas,
-  TextureId                      maskTextureId)
+  TextureId                      maskTextureId,
+  bool                           cropToMask)
 {
   std::string    hashTarget(url);
   const size_t   urlLength = hashTarget.length();
@@ -1542,7 +1543,7 @@ TextureManager::TextureHash TextureManager::GenerateHash(
   if(maskTextureId != INVALID_TEXTURE_ID)
   {
     auto textureIdIndex = hashTarget.length();
-    hashTarget.resize(hashTarget.length() + sizeof(TextureId));
+    hashTarget.resize(hashTarget.length() + sizeof(TextureId) + 1u);
     unsigned char* hashTargetPtr = reinterpret_cast<unsigned char*>(&(hashTarget[textureIdIndex]));
 
     // Append the texture id to the end of the URL byte by byte:
@@ -1552,6 +1553,7 @@ TextureManager::TextureHash TextureManager::GenerateHash(
       *hashTargetPtr++ = maskTextureId & 0xff;
       maskTextureId >>= 8u;
     }
+    *hashTargetPtr++ = (cropToMask ? 'C' : 'M');
   }
 
   return Dali::CalculateHash(hashTarget);
@@ -1567,7 +1569,8 @@ int TextureManager::FindCachedTexture(
   StorageType                       storageType,
   TextureId                         maskTextureId,
   TextureManager::MultiplyOnLoad    preMultiplyOnLoad,
-  bool                              isAnimatedImage)
+  bool                              isAnimatedImage,
+  bool                              cropToMask)
 {
   // Default to an invalid ID, in case we do not find a match.
   int cacheIndex = INVALID_CACHE_INDEX;
@@ -1584,6 +1587,7 @@ int TextureManager::FindCachedTexture(
       if((url == textureInfo.url.GetUrl()) &&
          (useAtlas == textureInfo.useAtlas) &&
          (maskTextureId == textureInfo.maskTextureId) &&
+         (cropToMask == textureInfo.cropToMask) &&
          (size == textureInfo.desiredSize) &&
          (isAnimatedImage == textureInfo.isAnimatedImageFormat) &&
          (storageType == textureInfo.storageType) &&
index 40e4bbd..2ef7801 100644 (file)
@@ -796,9 +796,10 @@ private:
    * @param[in] samplingMode     The SamplingMode to use
    * @param[in] useAtlas         True if atlased
    * @param[in] maskTextureId    The masking texture id (or INVALID_TEXTURE_ID)
+   * @param[in] cropToMask       True if crop to mask
    * @return                     A hash of the provided data for caching.
    */
-  TextureHash GenerateHash(const std::string& url, const ImageDimensions size, const FittingMode::Type fittingMode, const Dali::SamplingMode::Type samplingMode, const UseAtlas useAtlas, TextureId maskTextureId);
+  TextureHash GenerateHash(const std::string& url, const ImageDimensions size, const FittingMode::Type fittingMode, const Dali::SamplingMode::Type samplingMode, const UseAtlas useAtlas, TextureId maskTextureId, bool cropToMask);
 
   /**
    * @brief Looks up a cached texture by its hash.
@@ -813,6 +814,7 @@ private:
    * @param[in] maskTextureId     Optional texture ID to use to mask this image
    * @param[in] preMultiplyOnLoad If the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha.
    * @param[in] isAnimatedImage   True if the texture is from animated image.
+   * @param[in] cropToMask        True if crop to mask.
    * @return                      A TextureId of a cached Texture if found. Or INVALID_TEXTURE_ID if not found.
    */
   TextureManager::TextureId FindCachedTexture(
@@ -825,7 +827,8 @@ private:
     StorageType                       storageType,
     TextureId                         maskTextureId,
     MultiplyOnLoad                    preMultiplyOnLoad,
-    bool                              isAnimatedImage);
+    bool                              isAnimatedImage,
+    bool                              cropToMask);
 
 private:
   /**