1 #ifndef DALI_TOOLKIT_INTERNAL_ROLLING_IMAGE_CACHE_H
2 #define DALI_TOOLKIT_INTERNAL_ROLLING_IMAGE_CACHE_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 #include <dali-toolkit/internal/texture-manager/texture-manager-impl.h>
22 #include <dali-toolkit/internal/visuals/animated-image/image-cache.h>
23 #include <dali/devel-api/common/circular-queue.h>
32 * Class to manage a rolling cache of images, where the cache size
33 * is smaller than the total number of images.
35 class RollingImageCache : public ImageCache, public TextureUploadObserver
40 * @param[in] textureManager The texture manager
41 * @param[in] urlList List of urls to cache
42 * @param[in] maskingData Masking data to be applied.
43 * @param[in] observer FrameReady observer
44 * @param[in] cacheSize The size of the cache
45 * @param[in] batchSize The size of a batch to load
46 * @param[in] interval Time interval between each frame
48 * This will start loading textures immediately, according to the
49 * batch and cache sizes.
51 RollingImageCache(TextureManager& textureManager,
53 TextureManager::MaskingDataPointer& maskingData,
54 ImageCache::FrameReadyObserver& observer,
62 ~RollingImageCache() override;
65 * @copydoc Internal::ImageCache::Frame()
67 TextureSet Frame(uint32_t frameIndex) override;
70 * @copydoc Internal::ImageCache::FirstFrame()
72 TextureSet FirstFrame() override;
75 * @copydoc Internal::ImageCache::GetFrameInterval()
77 uint32_t GetFrameInterval(uint32_t frameIndex) const override;
80 * @copydoc Internal::ImageCache::GetCurrentFrameIndex()
82 int32_t GetCurrentFrameIndex() const override;
85 * @copydoc Internal::ImageCache::GetTotalFrameCount()
87 int32_t GetTotalFrameCount() const override;
90 * @copydoc Internal::ImageCache::ClearCache()
92 void ClearCache() override;
96 * @brief Check whether the front frame is ready or not.
98 * @return true if the front frame is ready
100 bool IsFrontReady() const;
103 * @brief Load the next batch of images
105 * @param[in] frameIndex starting frame index of batch to be loaded.
107 void LoadBatch(uint32_t frameIndex);
110 * @brief Get the texture set of the front frame.
112 * @return the texture set of the front of Cache.
114 TextureSet GetFrontTextureSet() const;
117 * @brief Get the texture id of the given index
119 * @param[in] index index of the queue.
121 TextureManager::TextureId GetCachedTextureId(int index) const;
124 * @brief Pop front entity of Cache.
126 void PopFrontCache();
130 * @copydoc Toolkit::TextureUploadObserver::LoadComplete()
132 void LoadComplete(bool loadSuccess, TextureInformation textureInformation) override;
136 * Secondary class to hold readiness and index into url
140 unsigned int mUrlIndex = 0u;
144 std::vector<UrlStore>& mImageUrls;
145 CircularQueue<ImageFrame> mQueue;
148 } // namespace Internal
149 } // namespace Toolkit