1 #ifndef DALI_TOOLKIT_INTERNAL_ROLLING_IMAGE_CACHE_H
2 #define DALI_TOOLKIT_INTERNAL_ROLLING_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.
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.h>
34 * Class to manage a rolling cache of images, where the cache size
35 * is smaller than the total number of images.
37 class RollingImageCache : public ImageCache
42 * @param[in] textureManager The texture manager
43 * @param[in] urlList List of urls to cache
44 * @param[in] observer FrameReady observer
45 * @param[in] cacheSize The size of the cache
46 * @param[in] batchSize The size of a batch to load
48 * This will start loading textures immediately, according to the
49 * batch and cache sizes.
51 RollingImageCache( TextureManager& textureManager,
53 ImageCache::FrameReadyObserver& observer,
60 virtual ~RollingImageCache();
63 * Get the first frame. If it's not ready, this will trigger the
64 * sending of FrameReady() when the image becomes ready.
66 virtual TextureSet FirstFrame();
69 * Get the next frame. If it's not ready, this will trigger the
70 * sending of FrameReady() when the image becomes ready.
71 * This will trigger the loading of the next batch.
73 virtual TextureSet NextFrame();
77 * @return true if the front frame is ready
79 bool IsFrontReady() const;
82 * Load the next batch of images
87 * Find the matching image frame, and set it to ready
89 void SetImageFrameReady( TextureManager::TextureId textureId );
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;
103 * Check if the front frame has become ready - if so, inform observer
104 * @param[in] wasReady Readiness before call.
106 void CheckFrontFrame( bool wasReady );
109 virtual void UploadComplete(
112 TextureSet textureSet,
114 const Vector4& atlasRect );
118 * Secondary class to hold readiness and index into url
122 unsigned int mUrlIndex;
126 CircularQueue<ImageFrame> mQueue;
129 } // namespace Internal
130 } // namespace Toolkit