Add AllowTextPrediction/IsTextPredictionAllowed api
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / gif-loading.h
1 #ifndef __DALI_INTERNAL_GIF_LOADING_H__
2 #define __DALI_INTERNAL_GIF_LOADING_H__
3
4 /*
5  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20 // EXTERNAL INCLUDES
21 #include <cstdint>
22 #include <memory>
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>
27
28 // INTERNAL INCLUDES
29 #include <dali/public-api/dali-adaptor-common.h>
30
31 namespace Dali
32 {
33 class PixelData;
34 typedef Dali::Uint16Pair ImageDimensions;
35
36 /**
37  * Class to manage loading frames of an animated gif in small chunks. Lazy initializes only when
38  * data is actually needed.
39  * Note, once the GIF has loaded, the undecoded data will reside in memory until this object
40  * is released. (This is to speed up frame loads, which would otherwise have to re-acquire the
41  * data from disk)
42  */
43 class DALI_ADAPTOR_API GifLoading
44 {
45 public:
46
47   /**
48    * Create a GifLoading with the given url and resourceType.
49    * @param[in] url The url of the gif image to load
50    * @param[in] isLocalResource The true or false whether this is a local resource.
51    * @return A newly created GifLoading.
52    */
53   static std::unique_ptr<GifLoading> New( const std::string& url, bool isLocalResource );
54
55   /**
56    * @brief Constructor
57    *
58    * Construct a Loader with the given URL
59    * @param[in] url The url of the gif image to load
60    * @param[in] isLocalResource The true or false whether this is a local resource.
61    */
62   GifLoading( const std::string& url, bool isLocalResource );
63
64   // Moveable but not copyable
65
66   GifLoading( const GifLoading& ) = delete;
67   GifLoading& operator=( const GifLoading& ) = delete;
68   GifLoading( GifLoading&& ) = default;
69   GifLoading& operator=( GifLoading&& ) = default;
70
71   /**
72    * @brief Destructor
73    */
74   ~GifLoading();
75
76   /**
77    * @brief Load the next N Frames of the gif.
78    *
79    * @note This function will load the entire gif into memory if not already loaded.
80    * @param[in] frameStartIndex The frame counter to start from. Will usually be the next frame
81    * after the previous invocation of this method, or 0 to start.
82    * @param[in] count The number of frames to load
83    * @param[out] pixelData The vector in which to return the frame data
84    * @return True if the frame data was successfully loaded
85    */
86   bool LoadNextNFrames( int frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData );
87
88   /**
89    * @brief Load all frames of an animated gif file.
90    *
91    * @note This function will load the entire gif into memory if not already loaded.
92    *
93    * @param[out] pixelData The loaded pixel data for each frame.
94    * @param[out] frameDelays The loaded delay time for each frame.
95    *
96    * @return True if the loading succeeded, false otherwise.
97    */
98   bool LoadAllFrames( std::vector<Dali::PixelData>& pixelData, Dali::Vector<uint32_t>& frameDelays );
99
100   /**
101    * @brief Get the size of a gif image.
102    *
103    * @note This function will load the entire gif into memory if not already loaded.
104    *
105    * @return The width and height in pixels of the gif image.
106    */
107   ImageDimensions GetImageSize();
108
109   /**
110    * @brief Get the number of frames in this gif.
111    *
112    * @note This function will load the entire gif into memory if not already loaded.
113    */
114   int GetImageCount();
115
116   /**
117    * @brief Load the frame delay counts into the provided array.
118    *
119    * @note This function will load the entire gif into memory if not already loaded.
120    * @param[in] frameDelays a vector to write the frame delays into
121    * @return true if the frame delays were successfully loaded
122    */
123   bool LoadFrameDelays( Dali::Vector<uint32_t>& frameDelays );
124
125 private:
126   struct Impl;
127   Impl* mImpl;
128 };
129
130 } // namespace Dali
131
132 #endif // __DALI_INTERNAL_GIF_LOADING_H__