1 #ifndef DALI_TOOLKIT_INTERNAL_ROLLING_GIF_IMAGE_CACHE_H
2 #define DALI_TOOLKIT_INTERNAL_ROLLING_GIF_IMAGE_CACHE_H
5 * Copyright (c) 2017 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/devel-api/adaptor-framework/gif-loading.h>
22 #include <dali/devel-api/common/circular-queue.h>
23 #include <dali-toolkit/internal/visuals/animated-image/image-cache.h>
24 #include <dali-toolkit/internal/visuals/texture-manager-impl.h>
34 * Class to manage a rolling cache of GIF images, where the cache size
35 * is smaller than the total number of images.
37 * Frames are always ready, so the observer.FrameReady callback is never triggered;
38 * the FirstFrame and NextFrame APIs will always return a texture.
40 class RollingGifImageCache : public ImageCache
45 * @param[in] textureManager The texture manager
46 * @param[in] gifLoader The loaded gif image
47 * @param[in] frameCount The number of frames in the gif
48 * @param[in] observer FrameReady observer
49 * @param[in] cacheSize The size of the cache
50 * @param[in] batchSize The size of a batch to load
52 * This will start loading textures immediately, according to the
53 * batch and cache sizes.
55 RollingGifImageCache( TextureManager& textureManager,
56 GifLoading& gifLoader,
58 ImageCache::FrameReadyObserver& observer,
65 virtual ~RollingGifImageCache();
68 * Get the first frame. If it's not ready, this will trigger the
69 * sending of FrameReady() when the image becomes ready.
71 virtual TextureSet FirstFrame();
74 * Get the next frame. If it's not ready, this will trigger the
75 * sending of FrameReady() when the image becomes ready.
76 * This will trigger the loading of the next batch.
78 virtual TextureSet NextFrame();
82 * @return true if the front frame is ready
84 bool IsFrontReady() const;
87 * Load the next batch of images
92 * Get the texture set of the front frame.
93 * @return the texture set
95 TextureSet GetFrontTextureSet() const;
98 * Get the texture id of the given index
100 TextureManager::TextureId GetCachedTextureId( int index ) const;
104 * Secondary class to hold readiness and index into url
108 unsigned int mFrameNumber;
111 GifLoading& mGifLoading;
112 uint32_t mFrameCount;
114 std::vector<UrlStore> mImageUrls;
116 CircularQueue<ImageFrame> mQueue;
119 } // namespace Internal
120 } // namespace Toolkit