X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-image%2Frolling-animated-image-cache.cpp;h=eba93412a8b17e04c4e47fe9fab832b38ab85f96;hb=refs%2Fchanges%2F30%2F252830%2F5;hp=565252fb9567081df4f62ff1c51e42937f4a6194;hpb=f3e45e41c5f16ccc2538b283897ed6efb07e4ea9;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 565252f..eba9341 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -29,27 +29,25 @@ namespace #if defined(DEBUG_ENABLED) Debug::Filter* gAnimImgLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ANIMATED_IMAGE"); -#define LOG_CACHE \ - { \ - std::ostringstream oss; \ - oss<<"Size:"<(mCacheSize) && !mQueue.IsFull(); ++i ) + for(unsigned int i = 0; i < mBatchSize && mQueue.Count() + mLoadWaitingQueue.size() < static_cast(mCacheSize) && !mQueue.IsFull(); ++i) { - if( !mOnLoading ) + if(!mOnLoading) { mOnLoading = true; - RequestFrameLoading( mFrameIndex ); + RequestFrameLoading(mFrameIndex); } else { - mLoadWaitingQueue.push_back( mFrameIndex ); + mLoadWaitingQueue.push_back(mFrameIndex); } mFrameIndex++; mFrameIndex %= mFrameCount; } - CheckFrontFrame( frontFrameReady ); + CheckFrontFrame(frontFrameReady); LOG_CACHE; } -void RollingAnimatedImageCache::SetImageFrameReady( TextureManager::TextureId textureId ) +void RollingAnimatedImageCache::SetImageFrameReady(TextureManager::TextureId textureId) { - for( std::size_t i = 0; i < mQueue.Count() ; ++i ) + for(std::size_t i = 0; i < mQueue.Count(); ++i) { - if( GetCachedTextureId( i ) == textureId ) + if(GetCachedTextureId(i) == textureId) { mQueue[i].mReady = true; break; @@ -262,23 +254,23 @@ void RollingAnimatedImageCache::SetImageFrameReady( TextureManager::TextureId te TextureSet RollingAnimatedImageCache::GetFrontTextureSet() const { - DALI_LOG_INFO( gAnimImgLogFilter, Debug::Concise, "RollingAnimatedImageCache::GetFrontTextureSet() FrameNumber:%d\n", mQueue[ 0 ].mFrameNumber ); + 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); + return mTextureManager.GetTextureSet(textureId); } -TextureManager::TextureId RollingAnimatedImageCache::GetCachedTextureId( int index ) const +TextureManager::TextureId RollingAnimatedImageCache::GetCachedTextureId(int index) const { - return mImageUrls[ mQueue[ index ].mFrameNumber ].mTextureId; + return mImageUrls[mQueue[index].mFrameNumber].mTextureId; } -void RollingAnimatedImageCache::CheckFrontFrame( bool wasReady ) +void RollingAnimatedImageCache::CheckFrontFrame(bool wasReady) { - if( mWaitingForReadyFrame && wasReady == false && IsFrontReady() ) + if(mWaitingForReadyFrame && wasReady == false && IsFrontReady()) { mWaitingForReadyFrame = false; - mObserver.FrameReady( GetFrontTextureSet() ); + mObserver.FrameReady(GetFrontTextureSet()); } } @@ -288,18 +280,18 @@ void RollingAnimatedImageCache::UploadComplete( TextureSet textureSet, bool useAtlasing, const Vector4& atlasRect, - bool preMultiplied ) + bool preMultiplied) { - DALI_LOG_INFO(gAnimImgLogFilter,Debug::Concise,"AnimatedImageVisual::UploadComplete(textureId:%d) start\n", textureId); + DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "AnimatedImageVisual::UploadComplete(textureId:%d) start\n", textureId); LOG_CACHE; bool frontFrameReady = IsFrontReady(); - if( !mRequestingLoad ) + if(!mRequestingLoad) { - SetImageFrameReady( textureId ); + SetImageFrameReady(textureId); - CheckFrontFrame( frontFrameReady ); + CheckFrontFrame(frontFrameReady); } else { @@ -313,22 +305,22 @@ void RollingAnimatedImageCache::UploadComplete( // The frames of a single animated image can not be loaded parallelly. // Therefore, a frame is now loading, other orders are waiting. // And, after the frame is loaded, requests load of next order. - if( !mLoadWaitingQueue.empty() ) + if(!mLoadWaitingQueue.empty()) { uint32_t loadingIndex = mLoadWaitingQueue.front(); - mLoadWaitingQueue.erase( mLoadWaitingQueue.begin() ); + mLoadWaitingQueue.erase(mLoadWaitingQueue.begin()); mOnLoading = true; - RequestFrameLoading( loadingIndex ); + RequestFrameLoading(loadingIndex); } LOG_CACHE; } void RollingAnimatedImageCache::LoadComplete( - bool loadSuccess, + bool loadSuccess, Devel::PixelBuffer pixelBuffer, - const VisualUrl& url, - bool preMultiplied ) + const VisualUrl& url, + bool preMultiplied) { // LoadComplete is called if this TextureUploadObserver requested to load // an image that will be returned as a type of PixelBuffer by using a method