From: tscholb Date: Mon, 14 Feb 2022 08:09:43 +0000 (+0900) Subject: [Tizen] Caching cropToMask in texture manager X-Git-Tag: submit/tizen_6.5/20220222.065506^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F51%2F271151%2F4;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git [Tizen] Caching cropToMask in texture manager cropToMask need to be cahing, so i added this patch Change-Id: I9efd84a1aa03b2050aed97071e123b9fec91167d --- diff --git a/dali-toolkit/internal/visuals/texture-manager-impl.cpp b/dali-toolkit/internal/visuals/texture-manager-impl.cpp index 7334cf7..9a50a00 100644 --- a/dali-toolkit/internal/visuals/texture-manager-impl.cpp +++ b/dali-toolkit/internal/visuals/texture-manager-impl.cpp @@ -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(&(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) && diff --git a/dali-toolkit/internal/visuals/texture-manager-impl.h b/dali-toolkit/internal/visuals/texture-manager-impl.h index 40e4bbd..2ef7801 100644 --- a/dali-toolkit/internal/visuals/texture-manager-impl.h +++ b/dali-toolkit/internal/visuals/texture-manager-impl.h @@ -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: /**