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;
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();
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:
*hashTargetPtr++ = maskTextureId & 0xff;
maskTextureId >>= 8u;
}
+ *hashTargetPtr++ = (cropToMask ? 'C' : 'M');
}
return Dali::CalculateHash(hashTarget);
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;
if((url == textureInfo.url.GetUrl()) &&
(useAtlas == textureInfo.useAtlas) &&
(maskTextureId == textureInfo.maskTextureId) &&
+ (cropToMask == textureInfo.cropToMask) &&
(size == textureInfo.desiredSize) &&
(isAnimatedImage == textureInfo.isAnimatedImageFormat) &&
(storageType == textureInfo.storageType) &&
* @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.
* @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(
StorageType storageType,
TextureId maskTextureId,
MultiplyOnLoad preMultiplyOnLoad,
- bool isAnimatedImage);
+ bool isAnimatedImage,
+ bool cropToMask);
private:
/**