X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-image%2Frolling-animated-image-cache.h;h=e1d201b72ce6a3376460df8607e6b0f42c6643bd;hp=503f65e8b9afd2caeb2572b2a9bb2097e88b8022;hb=57f2c014e61cff22236c0459757c41134fc7785f;hpb=e0a22e262eed4f4ed32fa3f88783e99a3380eb42 diff --git a/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.h b/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.h index 503f65e..e1d201b 100644 --- a/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.h +++ b/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_ROLLING_ANIMATED_IMAGE_CACHE_H /* - * 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. @@ -18,10 +18,10 @@ */ // EXTERNAL INCLUDES -#include -#include #include #include +#include +#include namespace Dali { @@ -29,7 +29,6 @@ namespace Toolkit { namespace Internal { - /** * Class to manage a rolling cache of Animated images, where the cache size * is smaller than the total number of images. @@ -37,7 +36,7 @@ namespace Internal * Frames are always ready, so the observer.FrameReady callback is never triggered; * the FirstFrame and NextFrame APIs will always return a texture. */ -class RollingAnimatedImageCache : public ImageCache +class RollingAnimatedImageCache : public ImageCache, public TextureUploadObserver { public: /** @@ -48,27 +47,29 @@ public: * @param[in] observer FrameReady observer * @param[in] cacheSize The size of the cache * @param[in] batchSize The size of a batch to load + * @param[in] isSynchronousLoading The flag to define whether to load first frame synchronously * * This will start loading textures immediately, according to the * batch and cache sizes. */ - RollingAnimatedImageCache( TextureManager& textureManager, - AnimatedImageLoading& animatedImageLoader, - uint32_t frameCount, - ImageCache::FrameReadyObserver& observer, - uint16_t cacheSize, - uint16_t batchSize ); + RollingAnimatedImageCache(TextureManager& textureManager, + AnimatedImageLoading& animatedImageLoader, + uint32_t frameCount, + ImageCache::FrameReadyObserver& observer, + uint16_t cacheSize, + uint16_t batchSize, + bool isSynchronousLoading); /** * Destructor */ - virtual ~RollingAnimatedImageCache(); + ~RollingAnimatedImageCache() override; /** * Get the Nth frame. If it's not ready, this will trigger the * sending of FrameReady() when the image becomes ready. */ - TextureSet Frame( uint32_t frameIndex ) override; + TextureSet Frame(uint32_t frameIndex) override; /** * Get the first frame. If it's not ready, this will trigger the @@ -77,9 +78,26 @@ public: TextureSet FirstFrame() override; /** + * Get the next frame. If it's not ready, this will trigger the + * sending of FrameReady() when the image becomes ready. + */ + TextureSet NextFrame() override; + + /** * Get the interval of Nth frame. */ - uint32_t GetFrameInterval( uint32_t frameIndex ) override; + uint32_t GetFrameInterval(uint32_t frameIndex) const override; + + /** + * Get the current rendered frame index. + * If there isn't any loaded frame, returns -1. + */ + int32_t GetCurrentFrameIndex() const override; + + /** + * Get total frame count of the animated image file. + */ + int32_t GetTotalFrameCount() const override; private: /** @@ -88,11 +106,21 @@ private: bool IsFrontReady() const; /** + * Request to Load a frame + */ + void RequestFrameLoading(uint32_t frameIndex); + + /** * Load the next batch of images */ void LoadBatch(); /** + * Find the matching image frame, and set it to ready + */ + void SetImageFrameReady(TextureManager::TextureId textureId); + + /** * Get the texture set of the front frame. * @return the texture set */ @@ -101,7 +129,16 @@ private: /** * Get the texture id of the given index */ - TextureManager::TextureId GetCachedTextureId( int index ) const; + TextureManager::TextureId GetCachedTextureId(int index) const; + + /** + * Check if the front frame has become ready - if so, inform observer + * @param[in] wasReady Readiness before call. + */ + void CheckFrontFrame(bool wasReady); + +protected: + void LoadComplete(bool loadSuccess, TextureInformation textureInformation) override; private: /** @@ -110,14 +147,19 @@ private: struct ImageFrame { unsigned int mFrameNumber = 0u; + bool mReady = false; }; - Dali::AnimatedImageLoading& mAnimatedImageLoading; + Dali::AnimatedImageLoading mAnimatedImageLoading; uint32_t mFrameCount; int mFrameIndex; + int mCacheSize; std::vector mImageUrls; - uint16_t mCacheSize; + std::vector mIntervals; + std::vector mLoadWaitingQueue; CircularQueue mQueue; + bool mIsSynchronousLoading; + bool mOnLoading; }; } // namespace Internal