X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-image%2Frolling-gif-image-cache.cpp;h=04f0f1d650652f078c1113ca1b01394fb9886096;hb=b31764bc76595c1ccd58cf4366dcde2cc78e72cf;hp=9f9e623882ee8295d356f9b0e623bfcb1f426300;hpb=b5dfb0468ead331593b706bb116d6a6aed97d88c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/animated-image/rolling-gif-image-cache.cpp b/dali-toolkit/internal/visuals/animated-image/rolling-gif-image-cache.cpp index 9f9e623..04f0f1d 100644 --- a/dali-toolkit/internal/visuals/animated-image/rolling-gif-image-cache.cpp +++ b/dali-toolkit/internal/visuals/animated-image/rolling-gif-image-cache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -84,16 +84,49 @@ RollingGifImageCache::~RollingGifImageCache() } } +TextureSet RollingGifImageCache::Frame( uint32_t frameIndex ) +{ + // If a frame of frameIndex is not loaded, clear the queue and remove all loaded textures. + if( mImageUrls[ frameIndex ].mTextureId == TextureManager::INVALID_TEXTURE_ID ) + { + mFrameIndex = frameIndex; + while( !mQueue.IsEmpty() ) + { + ImageFrame imageFrame = mQueue.PopFront(); + Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl ); + mImageUrls[ imageFrame.mFrameNumber ].mTextureId = TextureManager::INVALID_TEXTURE_ID; + } + LoadBatch(); + } + // If the frame is already loaded, remove previous frames of the frame in the queue + // and load new frames amount of removed frames. + else + { + bool popExist = false; + while( !mQueue.IsEmpty() && mQueue.Front().mFrameNumber != frameIndex ) + { + ImageFrame imageFrame = mQueue.PopFront(); + Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl ); + mImageUrls[ imageFrame.mFrameNumber ].mTextureId = TextureManager::INVALID_TEXTURE_ID; + popExist = true; + } + if( popExist ) + { + mFrameIndex = ( mQueue.Back().mFrameNumber + 1 ) % mFrameCount; + LoadBatch(); + } + } + + return GetFrontTextureSet(); +} TextureSet RollingGifImageCache::FirstFrame() { - return GetFrontTextureSet(); + return Frame( 0u ); } TextureSet RollingGifImageCache::NextFrame() { - TextureSet textureSet; - ImageFrame imageFrame = mQueue.PopFront(); Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl ); mImageUrls[ imageFrame.mFrameNumber ].mTextureId = TextureManager::INVALID_TEXTURE_ID; @@ -120,7 +153,7 @@ void RollingGifImageCache::LoadBatch() int batchSize = std::min( std::size_t(mBatchSize), mCacheSize - mQueue.Count() ); DALI_LOG_INFO( gAnimImgLogFilter, Debug::Concise, "RollingGifImageCache::LoadBatch() mFrameIndex:%d batchSize:%d\n", mFrameIndex, batchSize ); - if( mGifLoading.LoadNextNFrames( mFrameIndex, batchSize, pixelDataList) ) + if( mGifLoading.LoadNextNFrames( mFrameIndex, batchSize, pixelDataList) ) { unsigned int pixelDataListCount = pixelDataList.size(); @@ -151,12 +184,13 @@ void RollingGifImageCache::LoadBatch() AtlasUploadObserver* atlasObserver = nullptr; ImageAtlasManagerPtr imageAtlasManager = nullptr; Vector4 textureRect; + Dali::ImageDimensions textureRectSize; auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY; mTextureManager.LoadTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, maskInfo, - synchronousLoading, mImageUrls[ imageFrame.mFrameNumber ].mTextureId, textureRect, + synchronousLoading, mImageUrls[ imageFrame.mFrameNumber ].mTextureId, textureRect, textureRectSize, atlasingStatus, loadingStatus, Dali::WrapMode::Type::DEFAULT, Dali::WrapMode::Type::DEFAULT, NULL, atlasObserver, imageAtlasManager, ENABLE_ORIENTATION_CORRECTION, TextureManager::ReloadPolicy::CACHED, preMultiply );