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%2Ffixed-image-cache.h;h=50632321634aa13c185a1a28fcf8a522ce030433;hp=b30a11a84ed1dea07b360c45cfd00b905e49cc4d;hb=HEAD;hpb=46322a558e537267a6d3c48630c45afca91b5e27 diff --git a/dali-toolkit/internal/visuals/animated-image/fixed-image-cache.h b/dali-toolkit/internal/visuals/animated-image/fixed-image-cache.h index b30a11a..4fc4ecc 100644 --- a/dali-toolkit/internal/visuals/animated-image/fixed-image-cache.h +++ b/dali-toolkit/internal/visuals/animated-image/fixed-image-cache.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_FIXED_IMAGE_CACHE_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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 namespace Dali { @@ -27,79 +27,110 @@ namespace Toolkit { namespace Internal { - -class FixedImageCache : public ImageCache +class FixedImageCache : public ImageCache, public TextureUploadObserver { 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 + * @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] urlList List of urls to cache + * @param[in] maskingData Masking data to be applied. + * @param[in] observer FrameReady observer + * @param[in] batchSize The size of a batch to load + * @param[in] interval Time interval 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. */ - FixedImageCache( TextureManager& textureManager, - UrlList& urlList, - ImageCache::FrameReadyObserver& observer, - unsigned int batchSize ); + FixedImageCache(TextureManager& textureManager, + ImageDimensions size, + Dali::FittingMode::Type fittingMode, + Dali::SamplingMode::Type samplingMode, + UrlList& urlList, + TextureManager::MaskingDataPointer& maskingData, + ImageCache::FrameReadyObserver& observer, + uint32_t batchSize, + uint32_t interval, + bool preMultiplyOnLoad); + + ~FixedImageCache() override; - virtual ~FixedImageCache(); + /** + * @copydoc Internal::ImageCache::Frame() + */ + TextureSet Frame(uint32_t frameIndex) override; /** - * Get the first frame. If it's not ready, this will trigger the - * sending of FrameReady() when the image becomes ready. + * @copydoc Internal::ImageCache::FirstFrame() */ - virtual TextureSet FirstFrame(); + TextureSet FirstFrame() override; /** - * Get the next 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. + * @copydoc Internal::ImageCache::GetFrameInterval() */ - virtual TextureSet NextFrame(); + uint32_t GetFrameInterval(uint32_t frameIndex) const override; -private: /** - * @return true if the front frame is ready + * @copydoc Internal::ImageCache::GetCurrentFrameIndex() */ - bool IsFrontReady() const; + int32_t GetCurrentFrameIndex() const override; /** - * Load the next batch of images + * @copydoc Internal::ImageCache::GetTotalFrameCount() */ - void LoadBatch(); + int32_t GetTotalFrameCount() const override; + + /** + * @copydoc Internal::ImageCache::ClearCache() + */ + void ClearCache() override; + +private: + /** + * @brief Check whether the frame is ready or not. + * @param[in] frameIndex The frame index to check the frame is ready or not. + * + * @return true if the frame is ready + */ + bool IsFrameReady(uint32_t frameIndex) const; /** - * Find the matching image frame, and set it to ready + * @brief Load the next batch of images */ - void SetImageFrameReady( TextureManager::TextureId textureId ); + void LoadBatch(); /** - * Get the texture set of the front frame. - * @return the texture set + * @brief Get the texture set at the input frame index + * @param[in] frameIndex The frame index to retrieve texture set. + * + * @return the texture set of the front of Cache. */ - TextureSet GetFrontTextureSet() const; + TextureSet GetTextureSet(uint32_t frameIndex) const; /** - * Check if the front frame has become ready - if so, inform observer + * @brief Check if the front frame has become ready - if so, inform observer + * * @param[in] wasReady Readiness before call. + * @param[in] frameIndex The frame index for this frame + * @param[in] preMultiplied whether the texture is premultied alpha or not. */ - void CheckFrontFrame( bool wasReady ); + void MakeReady(bool wasReady, uint32_t frameIndex, bool preMultiplied); protected: - virtual void UploadComplete( - bool loadSuccess, - int32_t textureId, - TextureSet textureSet, - bool useAtlasing, - const Vector4& atlasRect ); + /** + * @copydoc Toolkit::TextureUploadObserver::LoadComplete() + */ + void LoadComplete(bool loadSuccess, TextureInformation textureInformation) override; -protected: - std::vector mReadyFlags; - unsigned int mFront; +private: + std::vector& mImageUrls; + std::vector mReadyFlags; + std::vector mLoadStates; + uint32_t mCurrentFrameIndex; }; } //namespace Internal