const Dali::WrapMode::Type& wrapModeV,
bool isSynchronousLoading,
bool preMultiplyOnLoad)
-: ImageCache(textureManager, size, fittingMode, samplingMode, maskingData, observer, batchSize, 0u),
+: ImageCache(textureManager, size, fittingMode, samplingMode, maskingData, observer, batchSize, 0u, preMultiplyOnLoad),
mImageUrl(animatedImageLoading.GetUrl()),
mAnimatedImageLoading(animatedImageLoading),
mFrameCount(SINGLE_IMAGE_COUNT),
mQueue(cacheSize),
mWrapModeU(wrapModeU),
mWrapModeV(wrapModeV),
- mIsSynchronousLoading(isSynchronousLoading),
- mPreMultiplyOnLoad(preMultiplyOnLoad)
+ mIsSynchronousLoading(isSynchronousLoading)
{
mTextureIds.resize(mFrameCount);
mIntervals.assign(mFrameCount, 0);
bool synchronouslyLoaded = false;
if(mIsSynchronousLoading && mQueue.IsEmpty())
{
- textureSet = RequestFrameLoading(frameIndex, true);
+ auto preMultiplyOnLoading = mPreMultiplyOnLoad ? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD
+ : TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
+
+ textureSet = RequestFrameLoading(frameIndex, true, preMultiplyOnLoading);
batchFrameIndex = (frameIndex + 1) % mFrameCount;
uint32_t interval = 0u;
if(textureSet)
synchronouslyLoaded = true;
interval = mAnimatedImageLoading.GetFrameInterval(mQueue.Back().mFrameNumber);
}
- MakeFrameReady(synchronouslyLoaded, textureSet, interval);
+ MakeFrameReady(synchronouslyLoaded, textureSet, interval, preMultiplyOnLoading == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD);
}
if(popExist || mQueue.IsEmpty() || synchronouslyLoaded)
return (!mQueue.IsEmpty() && mQueue.Front().mReady);
}
-TextureSet RollingAnimatedImageCache::RequestFrameLoading(uint32_t frameIndex, bool synchronousLoading)
+TextureSet RollingAnimatedImageCache::RequestFrameLoading(uint32_t frameIndex)
+{
+ auto preMultiplyOnLoading = mPreMultiplyOnLoad ? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD
+ : TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
+
+ return RequestFrameLoading(frameIndex, false, preMultiplyOnLoading);
+}
+
+TextureSet RollingAnimatedImageCache::RequestFrameLoading(uint32_t frameIndex, bool synchronousLoading, TextureManager::MultiplyOnLoad& preMultiplyOnLoading)
{
ImageFrame imageFrame;
imageFrame.mFrameNumber = frameIndex;
mLoadState = TextureManager::LoadState::LOADING;
- auto preMultiplyOnLoading = mPreMultiplyOnLoad ? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD
- : TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
-
TextureManager::TextureId loadTextureId = TextureManager::INVALID_TEXTURE_ID;
TextureSet textureSet = mTextureManager.LoadAnimatedImageTexture(mImageUrl,
mAnimatedImageLoading,
{
if(mLoadState != TextureManager::LoadState::LOADING)
{
- RequestFrameLoading(frameIndex, false);
+ RequestFrameLoading(frameIndex);
}
else
{
mLoadState = TextureManager::LoadState::NOT_STARTED;
}
-void RollingAnimatedImageCache::MakeFrameReady(bool loadSuccess, TextureSet textureSet, uint32_t interval)
+void RollingAnimatedImageCache::MakeFrameReady(bool loadSuccess, TextureSet textureSet, uint32_t interval, bool preMultiplied)
{
if(!loadSuccess)
{
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);
}
else
{
// If it is, notify frame ready to observer.
if(frontFrameReady == false && IsFrontReady())
{
- mObserver.FrameReady(textureSet, interval);
+ mObserver.FrameReady(textureSet, interval, preMultiplied);
}
}
}
textureInformation.textureSet.SetSampler(0u, sampler);
}
- MakeFrameReady(loadSuccess, textureInformation.textureSet, textureInformation.interval);
+ MakeFrameReady(loadSuccess, textureInformation.textureSet, textureInformation.interval, textureInformation.preMultiplied);
if(loadSuccess)
{
{
uint32_t loadingIndex = mLoadWaitingQueue.front();
mLoadWaitingQueue.erase(mLoadWaitingQueue.begin());
- RequestFrameLoading(loadingIndex, false);
+ RequestFrameLoading(loadingIndex);
}
else if(mQueue.Count() == 1u && textureInformation.frameCount > SINGLE_IMAGE_COUNT)
{