/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
// INTERNAL HEADERS
#include <dali-toolkit/internal/visuals/image-atlas-manager.h> // For ImageAtlasManagerPtr
-#include <dali/integration-api/debug.h>
// EXTERNAL HEADERS
+#include <dali/integration-api/adaptor-framework/adaptor.h>
+#include <dali/integration-api/debug.h>
namespace
{
Debug::Filter* gAnimImgLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ANIMATED_IMAGE");
#define LOG_CACHE \
+ if(gAnimImgLogFilter->IsEnabledFor(Debug::Concise)) \
{ \
std::ostringstream oss; \
oss << "Size:" << mQueue.Count() << " [ "; \
{
namespace Internal
{
-RollingImageCache::RollingImageCache(
- TextureManager& textureManager, UrlList& urlList, ImageCache::FrameReadyObserver& observer, uint16_t cacheSize, uint16_t batchSize, uint32_t interval)
-: ImageCache(textureManager, observer, batchSize, interval),
+RollingImageCache::RollingImageCache(TextureManager& textureManager,
+ ImageDimensions size,
+ Dali::FittingMode::Type fittingMode,
+ Dali::SamplingMode::Type samplingMode,
+ UrlList& urlList,
+ TextureManager::MaskingDataPointer& maskingData,
+ ImageCache::FrameReadyObserver& observer,
+ uint16_t cacheSize,
+ uint16_t batchSize,
+ uint32_t interval,
+ bool preMultiplyOnLoad)
+: ImageCache(textureManager, size, fittingMode, samplingMode, maskingData, observer, batchSize, interval, preMultiplyOnLoad),
mImageUrls(urlList),
mQueue(cacheSize)
{
bool popExist = false;
while(!mQueue.IsEmpty() && mQueue.Front().mUrlIndex != frameIndex)
{
- ImageFrame imageFrame = mQueue.PopFront();
- mTextureManager.Remove(mImageUrls[imageFrame.mUrlIndex].mTextureId, this);
- mImageUrls[imageFrame.mUrlIndex].mTextureId = TextureManager::INVALID_TEXTURE_ID;
- popExist = true;
+ PopFrontCache();
+ popExist = true;
}
// TODO: synchronous loading of first frame.
// If the frame of frameIndex was already loaded, load batch from the last frame of queue
if(!mQueue.IsEmpty())
{
- batchFrameIndex = (mQueue.Back().mUrlIndex + 1) % mImageUrls.size();
+ batchFrameIndex = (mQueue.Back().mUrlIndex + 1) % static_cast<uint32_t>(mImageUrls.size());
}
LoadBatch(batchFrameIndex);
}
{
ImageFrame imageFrame;
- std::string& url = mImageUrls[frameIndex].mUrl;
+ VisualUrl& url = mImageUrls[frameIndex].mUrl;
imageFrame.mUrlIndex = frameIndex;
imageFrame.mReady = false;
// from within this method. This means it won't yet have a texture id, so we
// need to account for this inside the LoadComplete method using mRequestingLoad.
mRequestingLoad = true;
- mLoadState = TextureManager::LoadState::LOADING;
-
- bool synchronousLoading = false;
- bool atlasingStatus = false;
- bool loadingStatus = false;
- TextureManager::MaskingDataPointer maskInfo = nullptr;
- AtlasUploadObserver* atlasObserver = nullptr;
- ImageAtlasManagerPtr imageAtlasManager = nullptr;
- Vector4 textureRect;
- Dali::ImageDimensions textureRectSize;
- auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
+ mLoadState = TextureManager::LoadState::LOADING;
+
+ bool synchronousLoading = false;
+ bool atlasingStatus = false;
+ bool loadingStatus = false;
+ AtlasUploadObserver* atlasObserver = nullptr;
+ ImageAtlasManagerPtr imageAtlasManager = nullptr;
+ Vector4 textureRect;
+ Dali::ImageDimensions textureRectSize;
+
+ auto preMultiplyOnLoading = mPreMultiplyOnLoad ? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD
+ : TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
TextureManager::TextureId loadTextureId = TextureManager::INVALID_TEXTURE_ID;
TextureSet textureSet = mTextureManager.LoadTexture(
- url, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, maskInfo, synchronousLoading, loadTextureId, textureRect, textureRectSize, atlasingStatus, loadingStatus, Dali::WrapMode::Type::DEFAULT, Dali::WrapMode::Type::DEFAULT, this, atlasObserver, imageAtlasManager, ENABLE_ORIENTATION_CORRECTION, TextureManager::ReloadPolicy::CACHED, preMultiply);
+ url, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, synchronousLoading, loadTextureId, textureRect, textureRectSize, atlasingStatus, loadingStatus, this, atlasObserver, imageAtlasManager, ENABLE_ORIENTATION_CORRECTION, TextureManager::ReloadPolicy::CACHED, preMultiplyOnLoading);
mImageUrls[imageFrame.mUrlIndex].mTextureId = loadTextureId;
mRequestingLoad = false;
TextureSet RollingImageCache::GetFrontTextureSet() const
{
- TextureManager::TextureId textureId = GetCachedTextureId(0);
- return mTextureManager.GetTextureSet(textureId);
+ TextureManager::TextureId textureId = GetCachedTextureId(0);
+ TextureSet textureSet = mTextureManager.GetTextureSet(textureId);
+ if(textureSet)
+ {
+ Sampler sampler = Sampler::New();
+ sampler.SetWrapMode(Dali::WrapMode::Type::DEFAULT, Dali::WrapMode::Type::DEFAULT);
+ textureSet.SetSampler(0u, sampler);
+ }
+ return textureSet;
}
TextureManager::TextureId RollingImageCache::GetCachedTextureId(int index) const
return mImageUrls[mQueue[index].mUrlIndex].mTextureId;
}
+void RollingImageCache::PopFrontCache()
+{
+ ImageFrame imageFrame = mQueue.PopFront();
+
+ mTextureManager.RequestRemove(mImageUrls[imageFrame.mUrlIndex].mTextureId, this);
+ mImageUrls[imageFrame.mUrlIndex].mTextureId = TextureManager::INVALID_TEXTURE_ID;
+
+ if(mMaskingData && mMaskingData->mAlphaMaskId != TextureManager::INVALID_TEXTURE_ID)
+ {
+ if(mQueue.IsEmpty())
+ {
+ mMaskingData->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID;
+ }
+ }
+}
+
void RollingImageCache::ClearCache()
{
- while(mTextureManagerAlive && !mQueue.IsEmpty())
+ while(Dali::Adaptor::IsAvailable() && !mQueue.IsEmpty())
{
- ImageFrame imageFrame = mQueue.PopFront();
- mTextureManager.Remove(mImageUrls[imageFrame.mUrlIndex].mTextureId, this);
- mImageUrls[imageFrame.mUrlIndex].mTextureId = TextureManager::INVALID_TEXTURE_ID;
+ PopFrontCache();
}
mLoadState = TextureManager::LoadState::NOT_STARTED;
}
if(loadSuccess)
{
- mLoadState = TextureManager::LoadState::LOAD_FINISHED;
+ mLoadState = TextureManager::LoadState::LOAD_FINISHED;
bool frontFrameReady = IsFrontReady();
if(!mRequestingLoad)
{
if(!frontFrameReady && IsFrontReady())
{
- mObserver.FrameReady(mTextureManager.GetTextureSet(textureInformation.textureId), mInterval);
+ mObserver.FrameReady(textureInformation.textureSet, mInterval, textureInformation.preMultiplied);
}
}
else
{
mLoadState = TextureManager::LoadState::LOAD_FAILED;
- mObserver.FrameReady(TextureSet(), 0);
+ // preMultiplied should be false because broken image don't premultiply alpha on load
+ mObserver.FrameReady(TextureSet(), 0, false);
}
LOG_CACHE;