lottie: Fixed SVACE warning for uninitialized class member variable.
[platform/core/uifw/lottie-player.git] / inc / lottieanimation_capi.h
1 #ifndef _LOTTIE_ANIMATION_CAPI_H_
2 #define _LOTTIE_ANIMATION_CAPI_H_
3
4 #include <stddef.h>
5 #include <stdint.h>
6 #include <lottiecommon.h>
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 typedef struct Lottie_Animation_S Lottie_Animation;
13
14 /**
15  *  @brief Constructs an animation object from file path.
16  *
17  *  @param[in] path Lottie resource file path
18  *
19  *  @return Animation object that can build the contents of the
20  *          Lottie resource represented by file path.
21  *
22  *  @see lottie_animation_destroy()
23  *
24  *  @ingroup Lottie_Animation
25  *  @internal
26  */
27 LOT_EXPORT Lottie_Animation *lottie_animation_from_file(const char *path);
28
29 /**
30  *  @brief Constructs an animation object from JSON string data.
31  *
32  *  @param[in] data The JSON string data.
33  *  @param[in] key the string that will be used to cache the JSON string data.
34  *
35  *  @return Animation object that can build the contents of the
36  *          Lottie resource represented by JSON string data.
37  *
38  *  @ingroup Lottie_Animation
39  *  @internal
40  */
41 LOT_EXPORT Lottie_Animation *lottie_animation_from_data(const char *data, const char *key);
42
43 /**
44  *  @brief Free given Animation object resource.
45  *
46  *  @param[in] animation Animation object to free.
47  *
48  *  @see lottie_animation_from_file()
49  *  @see lottie_animation_from_data()
50  *
51  *  @ingroup Lottie_Animation
52  *  @internal
53  */
54 LOT_EXPORT void lottie_animation_destroy(Lottie_Animation *animation);
55
56 /**
57  *  @brief Returns default viewport size of the Lottie resource.
58  *
59  *  @param[in] animation Animation object.
60  *  @param[out] w default width of the viewport.
61  *  @param[out] h default height of the viewport.
62  *
63  *  @ingroup Lottie_Animation
64  *  @internal
65  */
66 LOT_EXPORT void lottie_animation_get_size(const Lottie_Animation *animation, size_t *width, size_t *height);
67
68 /**
69  *  @brief Returns total animation duration of Lottie resource in second.
70  *         it uses totalFrame() and frameRate() to calculate the duration.
71  *         duration = totalFrame() / frameRate().
72  *
73  *  @param[in] animation Animation object.
74  *
75  *  @return total animation duration in second.
76  *          @c 0 if the Lottie resource has no animation.
77  *
78  *  @see lottie_animation_get_totalframe()
79  *  @see lottie_animation_get_framerate()
80  *
81  *  @ingroup Lottie_Animation
82  *  @internal
83  */
84 LOT_EXPORT double lottie_animation_get_duration(const Lottie_Animation *animation);
85
86 /**
87  *  @brief Returns total number of frames present in the Lottie resource.
88  *
89  *  @param[in] animation Animation object.
90  *
91  *  @return frame count of the Lottie resource.*
92  *
93  *  @note frame number starts with 0.
94  *
95  *  @see lottie_animation_get_duration()
96  *  @see lottie_animation_get_framerate()
97  *
98  *  @ingroup Lottie_Animation
99  *  @internal
100  */
101 LOT_EXPORT size_t lottie_animation_get_totalframe(const Lottie_Animation *animation);
102
103 /**
104  *  @brief Returns default framerate of the Lottie resource.
105  *
106  *  @param[in] animation Animation object.
107  *
108  *  @return framerate of the Lottie resource
109  *
110  *  @ingroup Lottie_Animation
111  *  @internal
112  *
113  */
114 LOT_EXPORT double lottie_animation_get_framerate(const Lottie_Animation *animation);
115
116 /**
117  *  @brief Get the render tree which contains the snapshot of the animation object
118  *         at frame = @c frame_num, the content of the animation in that frame number.
119  *
120  *  @param[in] animation Animation object.
121  *  @param[in] width requested snapshot viewport width.
122  *  @param[in] height requested snapshot viewport height.
123  *
124  *  @return Animation snapshot tree.
125  *
126  * @note: User has to traverse the tree for rendering.
127  *
128  * @see LOTLayerNode
129  * @see LOTNode
130  *
131  *  @ingroup Lottie_Animation
132  *  @internal
133  */
134 LOT_EXPORT const LOTLayerNode * lottie_animation_render_tree(Lottie_Animation *animation,
135                                                              size_t frame_num,
136                                                              size_t width, size_t height);
137
138 /**
139  *  @brief Maps position to frame number and returns it.
140  *
141  *  @param[in] animation Animation object.
142  *  @param[in] pos position in the range [ 0.0 .. 1.0 ].
143  *
144  *  @return mapped frame numbe in the range [ start_frame .. end_frame ].
145  *          @c 0 if the Lottie resource has no animation.
146  *
147  *
148  *  @ingroup Lottie_Animation
149  *  @internal
150  */
151 LOT_EXPORT size_t lottie_animation_get_frame_at_pos(const Lottie_Animation *animation, float pos);
152
153 /**
154  *  @brief Request to render the content of the frame @p frame_num to buffer @p buffer asynchronously.
155  *
156  *  @param[in] animation Animation object.
157  *  @param[in] frame_num the frame number needs to be rendered.
158  *  @param[in] buffer surface buffer use for rendering.
159  *  @param[in] width width of the surface
160  *  @param[in] height height of the surface
161  *  @param[in] bytes_per_line stride of the surface in bytes.
162  *
163  *  @note user must call lottie_animation_render_flush() to make sure render is finished.
164  *
165  *  @ingroup Lottie_Animation
166  *  @internal
167  */
168 LOT_EXPORT void
169 lottie_animation_render_async(Lottie_Animation *animation,
170                               size_t frame_num,
171                               uint32_t *buffer,
172                               size_t width,
173                               size_t height,
174                               size_t bytes_per_line);
175
176 /**
177  *  @brief Request to finish the current async renderer job for this animation object.
178  *  If render is finished then this call returns immidiately.
179  *  If not, it waits till render job finish and then return.
180  *
181  *  @param[in] animation Animation object.
182  *
183  *  @warning User must call lottie_animation_render_async() and lottie_animation_render_flush()
184  *  in pair to get the benefit of async rendering.
185  *
186  *  @return the pixel buffer it finished rendering.
187  *
188  *  @ingroup Lottie_Animation
189  *  @internal
190  */
191 LOT_EXPORT uint32_t *
192 lottie_animation_render_flush(Lottie_Animation *animation);
193
194 #ifdef __cplusplus
195 }
196 #endif
197
198 #endif //_LOTTIE_ANIMATION_CAPI_H_
199