1 #ifndef DALI_INTERNAL_WEBP_LOADING_H
2 #define DALI_INTERNAL_WEBP_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.
23 #include <dali/public-api/math/rect.h>
24 #include <dali/public-api/common/dali-vector.h>
25 #include <dali/public-api/common/vector-wrapper.h>
26 #include <dali/public-api/math/uint-16-pair.h>
29 #include <dali/public-api/dali-adaptor-common.h>
30 #include <dali/internal/imaging/common/animated-image-loading-impl.h>
35 typedef Dali::Uint16Pair ImageDimensions;
44 * Class to manage loading frames of an animated webp in small chunks. Lazy initializes only when
45 * data is actually needed.
46 * Note, once the WEBP has loaded, the undecoded data will reside in memory until this object
47 * is released. (This is to speed up frame loads, which would otherwise have to re-acquire the
50 class WebPLoading: public Internal::Adaptor::AnimatedImageLoading
55 * Create a WebPLoading with the given url and resourceType.
56 * @param[in] url The url of the webp image to load
57 * @param[in] isLocalResource The true or false whether this is a local resource.
58 * @return A newly created WebPLoading.
60 static AnimatedImageLoadingPtr New( const std::string& url, bool isLocalResource );
65 * Construct a Loader with the given URL
66 * @param[in] url The url of the webp image to load
67 * @param[in] isLocalResource The true or false whether this is a local resource.
69 WebPLoading( const std::string& url, bool isLocalResource );
75 ~WebPLoading() override;
78 * @brief Load the next N Frames of the webp.
80 * @note This function will load the entire webp into memory if not already loaded.
81 * @param[in] frameStartIndex The frame counter to start from. Will usually be the next frame
82 * after the previous invocation of this method, or 0 to start.
83 * @param[in] count The number of frames to load
84 * @param[out] pixelData The vector in which to return the frame data
85 * @return True if the frame data was successfully loaded
87 bool LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData ) override;
90 * @brief Get the size of a webp image.
92 * @return The width and height in pixels of the webp image.
94 ImageDimensions GetImageSize() const override;
97 * @brief Get the number of frames in this webp.
99 uint32_t GetImageCount() const override;
102 * @brief Get the frame interval of the frame index
104 * @note The frame is needed to be loaded before this function is called.
106 * @return The time interval of the frame(microsecond).
108 uint32_t GetFrameInterval( uint32_t frameIndex ) const override;
115 } // namespace Adaptor
117 } // namespace Internal
121 #endif // DALI_INTERNAL_WEBP_LOADING_H