X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-image%2Frolling-animated-image-cache.cpp;h=b6a9ae85b3911d1999d8d053191cfd6698559c4e;hb=30f8b41af892e67e267525b3d98eca2eac0c8980;hp=c4303209a0de7de5ef35491b1436c42a564011a6;hpb=6a957043921b7a50ce14db1d03d370b11c0ac63d;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp b/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp index c430320..b6a9ae8 100644 --- a/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp +++ b/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp @@ -28,6 +28,7 @@ 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() << " [ "; \ @@ -42,9 +43,6 @@ Debug::Filter* gAnimImgLogFilter = Debug::Filter::New(Debug::NoLogging, false, " #else #define LOG_CACHE #endif - -static constexpr bool ENABLE_ORIENTATION_CORRECTION(true); - } // namespace namespace Dali @@ -60,22 +58,28 @@ static constexpr uint32_t FIRST_FRAME_INDEX = 0u; } // namespace RollingAnimatedImageCache::RollingAnimatedImageCache(TextureManager& textureManager, + ImageDimensions size, + Dali::FittingMode::Type fittingMode, + Dali::SamplingMode::Type samplingMode, AnimatedImageLoading& animatedImageLoading, TextureManager::MaskingDataPointer& maskingData, ImageCache::FrameReadyObserver& observer, uint16_t cacheSize, uint16_t batchSize, + const Dali::WrapMode::Type& wrapModeU, + const Dali::WrapMode::Type& wrapModeV, bool isSynchronousLoading, bool preMultiplyOnLoad) -: ImageCache(textureManager, maskingData, observer, batchSize, 0u), +: ImageCache(textureManager, size, fittingMode, samplingMode, maskingData, observer, batchSize, 0u, preMultiplyOnLoad), mImageUrl(animatedImageLoading.GetUrl()), mAnimatedImageLoading(animatedImageLoading), mFrameCount(SINGLE_IMAGE_COUNT), mFrameIndex(FIRST_FRAME_INDEX), mCacheSize(cacheSize), mQueue(cacheSize), - mIsSynchronousLoading(isSynchronousLoading), - mPreMultiplyOnLoad(preMultiplyOnLoad) + mWrapModeU(wrapModeU), + mWrapModeV(wrapModeV), + mIsSynchronousLoading(isSynchronousLoading) { mTextureIds.resize(mFrameCount); mIntervals.assign(mFrameCount, 0); @@ -103,7 +107,10 @@ TextureSet RollingAnimatedImageCache::Frame(uint32_t frameIndex) 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) @@ -111,7 +118,7 @@ TextureSet RollingAnimatedImageCache::Frame(uint32_t frameIndex) 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) @@ -183,7 +190,15 @@ bool RollingAnimatedImageCache::IsFrontReady() const 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; @@ -193,21 +208,24 @@ TextureSet RollingAnimatedImageCache::RequestFrameLoading(uint32_t frameIndex, b 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, frameIndex, loadTextureId, mMaskingData, - SamplingMode::BOX_THEN_LINEAR, - Dali::WrapMode::Type::DEFAULT, - Dali::WrapMode::Type::DEFAULT, + mDesiredSize, + mFittingMode, + mSamplingMode, synchronousLoading, this, preMultiplyOnLoading); + if(textureSet) + { + Sampler sampler = Sampler::New(); + sampler.SetWrapMode(mWrapModeU, mWrapModeV); + textureSet.SetSampler(0u, sampler); + } mTextureIds[frameIndex] = loadTextureId; @@ -224,7 +242,7 @@ void RollingAnimatedImageCache::LoadBatch(uint32_t frameIndex) { if(mLoadState != TextureManager::LoadState::LOADING) { - RequestFrameLoading(frameIndex, false); + RequestFrameLoading(frameIndex); } else { @@ -254,8 +272,15 @@ TextureSet RollingAnimatedImageCache::GetFrontTextureSet() const { DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "RollingAnimatedImageCache::GetFrontTextureSet() FrameNumber:%d\n", mQueue[0].mFrameNumber); - 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(mWrapModeU, mWrapModeV); + textureSet.SetSampler(0u, sampler); + } + return textureSet; } TextureManager::TextureId RollingAnimatedImageCache::GetCachedTextureId(int index) const @@ -271,7 +296,6 @@ void RollingAnimatedImageCache::PopFrontCache() if(mMaskingData && mMaskingData->mAlphaMaskId != TextureManager::INVALID_TEXTURE_ID) { - mTextureManager.Remove(mMaskingData->mAlphaMaskId, this); if(mQueue.IsEmpty()) { mMaskingData->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID; @@ -289,12 +313,13 @@ void RollingAnimatedImageCache::ClearCache() 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 { @@ -317,7 +342,7 @@ void RollingAnimatedImageCache::MakeFrameReady(bool loadSuccess, TextureSet text // If it is, notify frame ready to observer. if(frontFrameReady == false && IsFrontReady()) { - mObserver.FrameReady(textureSet, interval); + mObserver.FrameReady(textureSet, interval, preMultiplied); } } } @@ -327,7 +352,14 @@ void RollingAnimatedImageCache::LoadComplete(bool loadSuccess, TextureInformatio DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "AnimatedImageVisual::LoadComplete(textureId:%d) start\n", textureInformation.textureId); LOG_CACHE; - MakeFrameReady(loadSuccess, mTextureManager.GetTextureSet(textureInformation.textureId), textureInformation.interval); + if(textureInformation.textureSet) + { + Sampler sampler = Sampler::New(); + sampler.SetWrapMode(mWrapModeU, mWrapModeV); + textureInformation.textureSet.SetSampler(0u, sampler); + } + + MakeFrameReady(loadSuccess, textureInformation.textureSet, textureInformation.interval, textureInformation.preMultiplied); if(loadSuccess) { @@ -338,7 +370,7 @@ void RollingAnimatedImageCache::LoadComplete(bool loadSuccess, TextureInformatio { uint32_t loadingIndex = mLoadWaitingQueue.front(); mLoadWaitingQueue.erase(mLoadWaitingQueue.begin()); - RequestFrameLoading(loadingIndex, false); + RequestFrameLoading(loadingIndex); } else if(mQueue.Count() == 1u && textureInformation.frameCount > SINGLE_IMAGE_COUNT) {