/*
- * Copyright (c) 2022 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
{
namespace Internal
{
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)
-: ImageCache(textureManager, maskingData, observer, batchSize, interval),
+ uint32_t interval,
+ bool preMultiplyOnLoad)
+: ImageCache(textureManager, size, fittingMode, samplingMode, maskingData, observer, batchSize, interval, preMultiplyOnLoad),
mImageUrls(urlList),
mQueue(cacheSize)
{
// 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);
}
ImageAtlasManagerPtr imageAtlasManager = nullptr;
Vector4 textureRect;
Dali::ImageDimensions textureRectSize;
- auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
+
+ 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, mMaskingData, synchronousLoading, loadTextureId, textureRect, textureRectSize, atlasingStatus, loadingStatus, 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);
- TextureSet textureSet = mTextureManager.GetTextureSet(textureId);
+ TextureManager::TextureId textureId = GetCachedTextureId(0);
+ TextureSet textureSet = mTextureManager.GetTextureSet(textureId);
if(textureSet)
{
Sampler sampler = Sampler::New();
void RollingImageCache::PopFrontCache()
{
ImageFrame imageFrame = mQueue.PopFront();
- mTextureManager.Remove(mImageUrls[imageFrame.mUrlIndex].mTextureId, this);
+
+ mTextureManager.RequestRemove(mImageUrls[imageFrame.mUrlIndex].mTextureId, this);
mImageUrls[imageFrame.mUrlIndex].mTextureId = TextureManager::INVALID_TEXTURE_ID;
if(mMaskingData && mMaskingData->mAlphaMaskId != TextureManager::INVALID_TEXTURE_ID)
{
- mTextureManager.Remove(mMaskingData->mAlphaMaskId, this);
if(mQueue.IsEmpty())
{
mMaskingData->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID;
void RollingImageCache::ClearCache()
{
- while(mTextureManagerAlive && !mQueue.IsEmpty())
+ while(Dali::Adaptor::IsAvailable() && !mQueue.IsEmpty())
{
PopFrontCache();
}
if(!frontFrameReady && IsFrontReady())
{
- if(textureInformation.textureSet)
- {
- Sampler sampler = Sampler::New();
- sampler.SetWrapMode(Dali::WrapMode::Type::DEFAULT, Dali::WrapMode::Type::DEFAULT);
- textureInformation.textureSet.SetSampler(0u, sampler);
- }
- mObserver.FrameReady(textureInformation.textureSet, 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;