/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// CLASS HEADER
-#include "texture-cache-manager.h"
+#include <dali-toolkit/internal/texture-manager/texture-cache-manager.h>
// EXTERNAL HEADERS
#include <dali/devel-api/common/hash.h>
loadState == TextureManagerType::LoadState::MASK_APPLIED ? "MASK_APPLIED" : \
loadState == TextureManagerType::LoadState::UPLOADED ? "UPLOADED" : \
loadState == TextureManagerType::LoadState::CANCELLED ? "CANCELLED" : \
+ loadState == TextureManagerType::LoadState::MASK_CANCELLED ? "MASK_CANCELLED" : \
loadState == TextureManagerType::LoadState::LOAD_FAILED ? "LOAD_FAILED" : \
"Unknown"
// clang-format on
Texture TextureCacheManager::GetTexture(const TextureCacheManager::TextureId& textureId, uint32_t textureIndex)
{
- Texture texture; // empty handle
+ Texture texture; // empty handle
TextureCacheIndex cacheIndex = GetCacheIndexFromId(textureId);
switch(static_cast<TextureCacheIndexType>(cacheIndex.detailValue.type))
return texture;
}
-TextureSet TextureCacheManager::GetExternalTextureSet(const TextureCacheManager::TextureId& textureId)
+TextureCacheManager::ExternalTextureInfo& TextureCacheManager::GetExternalTextureInfo(const TextureCacheManager::TextureId& textureId)
{
- TextureSet textureSet; // empty handle
TextureCacheIndex cacheIndex = GetCacheIndexFromExternalTextureId(textureId);
- if(cacheIndex != INVALID_CACHE_INDEX)
- {
- textureSet = mExternalTextures[cacheIndex.GetIndex()].textureSet;
- }
- return textureSet;
+ DALI_ASSERT_ALWAYS(cacheIndex != INVALID_CACHE_INDEX);
+
+ return mExternalTextures[cacheIndex.GetIndex()];
}
EncodedImageBuffer TextureCacheManager::GetEncodedImageBuffer(const TextureCacheManager::TextureId& bufferId)
return encodedImageBuffer;
}
-std::string TextureCacheManager::AddExternalTexture(const TextureSet& textureSet)
+std::string TextureCacheManager::AddExternalTexture(const TextureSet& textureSet, bool preMultiplied)
{
TextureId textureId = GenerateTextureId(TextureCacheIndex(TextureCacheIndexType::TEXTURE_CACHE_INDEX_TYPE_TEXTURE, mExternalTextures.size()));
- TextureCacheManager::ExternalTextureInfo textureInfo(textureId, textureSet);
+ TextureCacheManager::ExternalTextureInfo textureInfo(textureId, textureSet, preMultiplied);
mExternalTextures.emplace_back(textureInfo);
- DALI_LOG_INFO(gTextureManagerLogFilter, Debug::Concise, "TextureCacheManager::AddExternalTexture() : New texture registered. textureId:%d\n", textureInfo.textureId);
+ DALI_LOG_INFO(gTextureManagerLogFilter, Debug::Concise, "TextureCacheManager::AddExternalTexture() : New texture registered. textureId:%d, preMultiplied:%d\n", textureInfo.textureId, preMultiplied);
return VisualUrl::CreateTextureUrl(std::to_string(textureInfo.textureId));
}
void TextureCacheManager::RemoveCache(TextureCacheManager::TextureInfo& textureInfo)
{
- TextureCacheIndex textureInfoIndex = GetCacheIndexFromId(textureInfo.textureId);
- bool removeTextureInfo = false;
+ TextureCacheIndex textureInfoIndex = GetCacheIndexFromId(textureInfo.textureId);
+ bool removeTextureInfo = false;
DALI_LOG_INFO(gTextureManagerLogFilter, Debug::Concise, "TextureCacheManager::Remove(textureId:%d) url:%s\n cacheIdx:%d loadState:%s reference count = %d\n", textureInfo.textureId, textureInfo.url.GetUrl().c_str(), textureInfoIndex.GetIndex(), GET_LOAD_STATE_STRING(textureInfo.loadState), textureInfo.referenceCount);
}
removeTextureInfo = true;
}
- else if(textureInfo.loadState == LoadState::LOADING || textureInfo.loadState == LoadState::MASK_APPLYING)
+ else if(textureInfo.loadState == LoadState::LOADING)
{
// We mark the textureInfo for removal.
// Once the load has completed, this method will be called again.
textureInfo.loadState = LoadState::CANCELLED;
}
+ else if(textureInfo.loadState == LoadState::MASK_APPLYING)
+ {
+ // We mark the textureInfo for removal.
+ // Once the load has completed, this method will be called again.
+ textureInfo.loadState = LoadState::MASK_CANCELLED;
+ }
else
{
// In other states, we are not waiting for a load so we are safe to remove the TextureInfo data.