1 #ifndef DALI_ANIMATED_IMAGE_LOADING_H
2 #define DALI_ANIMATED_IMAGE_LOADING_H
5 * Copyright (c) 2020 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/public-api/common/dali-vector.h>
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/math/uint-16-pair.h>
24 #include <dali/public-api/object/base-handle.h>
27 #include <dali/public-api/dali-adaptor-common.h>
33 typedef Dali::Uint16Pair ImageDimensions;
36 * @addtogroup dali_adaptor_framework
40 namespace Internal DALI_INTERNAL
44 class AnimatedImageLoading;
49 * Class to manage loading frames of an animated image in small chunks. Lazy initializes only when
50 * data is actually needed.
51 * Note, once the Animated Image has loaded, the undecoded data will reside in memory until this object
52 * is released. (This is to speed up frame loads, which would otherwise have to re-acquire the
55 class DALI_ADAPTOR_API AnimatedImageLoading : public BaseHandle
60 * Create a GifLoading with the given url and resourceType.
61 * @param[in] url The url of the animated image to load
62 * @param[in] isLocalResource The true or false whether this is a local resource.
63 * @return A newly created GifLoading.
65 static AnimatedImageLoading New( const std::string& url, bool isLocalResource );
70 AnimatedImageLoading();
73 * @brief Downcast an Object handle to Capture handle.
75 * If handle points to a Capture object the downcast produces valid
76 * handle. If not the returned handle is left uninitialized.
78 * @param[in] handle to An object.
79 * @return handle to a Capture object or an uninitialized handle.
81 static AnimatedImageLoading DownCast( BaseHandle handle );
85 * @brief Copy constructor.
87 * @param[in] copy The AnimatedImageLoading to copy
89 AnimatedImageLoading(const AnimatedImageLoading& copy) = default;
92 * @brief Assignment operator
94 * @param[in] rhs The AnimatedImageLoading to copy
95 * @return A reference to this
97 AnimatedImageLoading& operator=(const AnimatedImageLoading& rhs) = default;
102 ~AnimatedImageLoading();
105 * @brief Load the next N Frames of the animated image.
107 * @note This function will load the entire animated image into memory if not already loaded.
108 * @param[in] frameStartIndex The frame counter to start from. Will usually be the next frame
109 * after the previous invocation of this method, or 0 to start.
110 * @param[in] count The number of frames to load
111 * @param[out] pixelData The vector in which to return the frame data
112 * @return True if the frame data was successfully loaded
114 bool LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData );
117 * @brief Get the size of a animated image.
119 * @return The width and height in pixels of the animated image.
121 ImageDimensions GetImageSize() const;
124 * @brief Get the number of frames in this animated image.
126 uint32_t GetImageCount() const;
129 * @brief Get the frame interval of the frame index
131 * @note The frame is needed to be loaded before this function is called.
133 * @return The time interval of the frame(microsecond).
135 uint32_t GetFrameInterval( uint32_t frameIndex ) const;
137 public: // Not intended for application developers
140 * @brief This constructor is used by New() methods.
142 * @param[in] internal A pointer to a newly allocated Dali resource.
144 explicit DALI_INTERNAL AnimatedImageLoading( Internal::Adaptor::AnimatedImageLoading* internal );
150 #endif // DALI_ANIMATED_IMAGE_LOADING_H