X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-image%2Fimage-cache.h;h=aee80b27514901a40392ffbeaf63cbfc0d78d5de;hb=HEAD;hp=5061d7630278ac485233ed024251db8f48c967b4;hpb=46322a558e537267a6d3c48630c45afca91b5e27;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/animated-image/image-cache.h b/dali-toolkit/internal/visuals/animated-image/image-cache.h index 5061d76..aee80b2 100644 --- a/dali-toolkit/internal/visuals/animated-image/image-cache.h +++ b/dali-toolkit/internal/visuals/animated-image/image-cache.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_IMAGE_CACHE_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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,8 +18,8 @@ */ // EXTERNAL INCLUDES -#include -#include +#include +#include namespace Dali { @@ -27,8 +27,7 @@ namespace Toolkit { namespace Internal { - -class ImageCache : public TextureUploadObserver +class ImageCache { public: /** @@ -38,16 +37,18 @@ public: { public: /** - * Informs observer when the next texture set is ready to display + * @brief Informs observer when the next texture set is ready to display * @param[in] textureSet The ready texture set + * @param[in] interval interval(ms) for the frame + * @param[in] preMultiplied whether the texture is premultied alpha or not. */ - virtual void FrameReady( TextureSet textureSet ) = 0; + virtual void FrameReady(TextureSet textureSet, uint32_t interval, bool preMultiplied) = 0; }; struct UrlStore { - TextureManager::TextureId mTextureId; - std::string mUrl; + TextureManager::TextureId mTextureId = TextureManager::INVALID_TEXTURE_ID; + VisualUrl mUrl; }; /** @@ -57,47 +58,103 @@ public: public: /** - * Constructor. - * @param[in] textureManager The texture manager - * @param[in] urlList List of urls to cache - * @param[in] observer FrameReady observer - * @param[in] batchSize The size of a batch to load + * @brief Constructor. + * @param[in] textureManager The texture manager + * @param[in] size The width and height to fit the loaded image to. + * @param[in] fittingMode The FittingMode of the resource to load + * @param[in] samplingMode The SamplingMode of the resource to load + * @param[in] observer FrameReady observer + * @param[in] maskingData Masking data to be applied. + * @param[in] batchSize The size of a batch to load + * @param[in] interval Time interval(ms) between each frame + * @param[in] preMultiplyOnLoad The flag if image's color should be multiplied by it's alpha * * This will start loading textures immediately, according to the * batch and cache sizes. The cache is as large as the number of urls. */ - ImageCache( TextureManager& textureManager, - UrlList& urlList, - ImageCache::FrameReadyObserver& observer, - unsigned int batchSize ); + ImageCache(TextureManager& textureManager, + ImageDimensions size, + Dali::FittingMode::Type fittingMode, + Dali::SamplingMode::Type samplingMode, + TextureManager::MaskingDataPointer& maskingData, + ImageCache::FrameReadyObserver& observer, + uint32_t batchSize, + uint32_t interval, + bool preMultiplyOnLoad); virtual ~ImageCache(); /** - * Get the first frame. If it's not ready, this will trigger the + * @brief Get the first frame. If it's not ready, this will trigger the * sending of FrameReady() when the image becomes ready. + * + * @return TextureSet of the first frame. */ virtual TextureSet FirstFrame() = 0; /** - * Get the next frame. If it's not ready, this will trigger the + * @brief Get the Nth frame. If it's not ready, this will trigger the * sending of FrameReady() when the image becomes ready. - * This will trigger the loading of the next batch. + * + * @param[in] frameIndex required frame index to be returned. + * @return TextureSet of the frame index. + */ + virtual TextureSet Frame(uint32_t frameIndex) = 0; + + /** + * @brief Get the interval(ms) of Nth frame. + * + * @param[in] frameIndex frame index to get frame interval. + * @return Time interval in millisecond between frames of frameIndex and frameIndex + 1. + */ + virtual uint32_t GetFrameInterval(uint32_t frameIndex) const = 0; + + /** + * @brief Get the current rendered frame index. + * If there isn't any loaded frame, returns -1. + * + * @return Frame index of currently showing frame. */ - virtual TextureSet NextFrame() = 0; + virtual int32_t GetCurrentFrameIndex() const = 0; + + /** + * @brief Get total frame count of the animated image file. + * + * @return Total frame count of the animated image file. + */ + virtual int32_t GetTotalFrameCount() const = 0; + + /** + * @brief Clears animated image cache and remove loaded textures. + */ + virtual void ClearCache() = 0; + + /** + * @brief Set default interval(ms) between each frame. + * + * @param[in] interval time interval in millisecond to be used as default interval. + */ + virtual void SetInterval(uint32_t interval); + +private: + void AllocateMaskData(); protected: - TextureManager& mTextureManager; - FrameReadyObserver& mObserver; - std::vector& mImageUrls; - unsigned int mBatchSize; - unsigned int mUrlIndex; - bool mWaitingForReadyFrame:1; - bool mRequestingLoad:1; + TextureManager& mTextureManager; + FrameReadyObserver& mObserver; + TextureManager::MaskingDataPointer& mMaskingData; + Dali::ImageDimensions mDesiredSize; + Dali::FittingMode::Type mFittingMode : 3; + Dali::SamplingMode::Type mSamplingMode : 4; + uint32_t mBatchSize; + uint32_t mInterval; + TextureManager::LoadState mLoadState; + bool mRequestingLoad : 1; + bool mPreMultiplyOnLoad : 1; }; -} //namespace Internal -} //namespace Toolkit -} //namespace Dali +} // namespace Internal +} // namespace Toolkit +} // namespace Dali #endif // DALI_TOOLKIT_INTERNAL_IMAGE_CACHE_H