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