const Dali::FittingMode::Type& fittingMode,
const Dali::SamplingMode::Type& samplingMode,
const TextureCacheManager::UseAtlas& useAtlas,
- const TextureCacheManager::TextureId& maskTextureId)
+ const TextureCacheManager::TextureId& maskTextureId,
+ const bool& cropToMask)
{
std::vector<std::uint8_t> hashTarget(url.begin(), url.end());
const size_t urlLength = url.length();
if(maskTextureId != INVALID_TEXTURE_ID)
{
auto textureIdIndex = hashTarget.size();
- hashTarget.resize(hashTarget.size() + sizeof(TextureId));
+ hashTarget.resize(hashTarget.size() + sizeof(TextureId) + 1u);
std::uint8_t* hashTargetPtr = reinterpret_cast<std::uint8_t*>(&(hashTarget[textureIdIndex]));
// Append the texture id to the end of the URL byte by byte:
*hashTargetPtr++ = saltedMaskTextureId & 0xff;
saltedMaskTextureId >>= 8u;
}
+ *hashTargetPtr++ = (cropToMask ? 'C' : 'M');
}
return Dali::CalculateHash(hashTarget);
const TextureCacheManager::UseAtlas& useAtlas,
const TextureCacheManager::TextureId& maskTextureId,
const TextureCacheManager::MultiplyOnLoad& preMultiplyOnLoad,
- bool isAnimatedImage)
+ bool isAnimatedImage,
+ const bool& cropToMask)
{
// Default to an invalid ID, in case we do not find a match.
TextureCacheIndex cacheIndex = INVALID_CACHE_INDEX;
if((url == textureInfo.url.GetUrl()) &&
(useAtlas == textureInfo.useAtlas) &&
(maskTextureId == textureInfo.maskTextureId) &&
+ (cropToMask == textureInfo.cropToMask) &&
(size == textureInfo.desiredSize) &&
(isAnimatedImage == textureInfo.isAnimatedImageFormat) &&
((size.GetWidth() == 0 && size.GetHeight() == 0) ||
* @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.
*/
TextureCacheManager::TextureHash GenerateHash(
const Dali::FittingMode::Type& fittingMode,
const Dali::SamplingMode::Type& samplingMode,
const TextureCacheManager::UseAtlas& useAtlas,
- const TextureCacheManager::TextureId& maskTextureId);
+ const TextureCacheManager::TextureId& maskTextureId,
+ const bool& cropToMask);
/**
* @brief Looks up a cached texture by its hash.
* @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 TextureCacheId of a cached Texture if found. Or INVALID_CACHE_INDEX if not found.
*/
TextureCacheManager::TextureCacheIndex FindCachedTexture(
const TextureCacheManager::UseAtlas& useAtlas,
const TextureCacheManager::TextureId& maskTextureId,
const TextureCacheManager::MultiplyOnLoad& preMultiplyOnLoad,
- bool isAnimatedImage);
+ bool isAnimatedImage,
+ const bool& cropToMask);
/**
* @brief Append a Texture to the TextureCacheManager.
TextureCacheIndex cacheIndex = INVALID_CACHE_INDEX;
if(storageType != StorageType::RETURN_PIXEL_BUFFER && useCache)
{
- textureHash = mTextureCacheManager.GenerateHash(url.GetUrl(), desiredSize, fittingMode, samplingMode, useAtlas, maskTextureId);
+ textureHash = mTextureCacheManager.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 = mTextureCacheManager.FindCachedTexture(textureHash, url.GetUrl(), desiredSize, fittingMode, samplingMode, useAtlas, maskTextureId, preMultiplyOnLoad, (animatedImageLoading) ? true : false);
+ cacheIndex = mTextureCacheManager.FindCachedTexture(textureHash, url.GetUrl(), desiredSize, fittingMode, samplingMode, useAtlas, maskTextureId, preMultiplyOnLoad, (animatedImageLoading) ? true : false, cropToMask);
}
TextureManager::TextureId textureId = INVALID_TEXTURE_ID;