lottie: add lottie_animation_render_tree() c api .
[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 LOT_EXPORT Lottie_Animation *lottie_animation_from_file(const char *file);
16 LOT_EXPORT Lottie_Animation *lottie_animation_from_data(const char *data, const char *key);
17 LOT_EXPORT void lottie_animation_destroy(Lottie_Animation *animation);
18 LOT_EXPORT void lottie_animation_get_size(const Lottie_Animation *animation, size_t *w, size_t *h);
19 LOT_EXPORT double lottie_animation_get_duration(const Lottie_Animation *animation);
20 LOT_EXPORT size_t lottie_animation_get_totalframe(const Lottie_Animation *animation);
21 LOT_EXPORT double lottie_animation_get_framerate(const Lottie_Animation *animation);
22
23
24 /*
25  * Request to update the content of the frame $frame_number in to Animation object.
26  * frame_number, the content of the animation in that frame number
27  * width  , width of the viewbox
28  * height , height of the viewbox
29  *
30  * PS : user must call lottie_animation_get_node_count and  lottie_animation_get_node
31  * to get the renderlist.
32  */
33 LOT_EXPORT size_t lottie_animation_prepare_frame(Lottie_Animation *animation,
34                                                  size_t frameNo,
35                                                  size_t w, size_t h);
36 LOT_EXPORT size_t lottie_animation_get_node_count(const Lottie_Animation *animation);
37 LOT_EXPORT const LOTNode* lottie_animation_get_node(Lottie_Animation *animation, size_t idx);
38
39
40 /*
41  * Get the render tree which contains the snapshot of the animation object at frame $frame_number
42  * frame_number, the content of the animation in that frame number
43  * width  , width of the viewbox
44  * height , height of the viewbox
45  *
46  * PS : user has to traverse the tree for rendering. @see LOTLayerNode and @see LOTNode
47  */
48 LOT_EXPORT const LOTLayerNode * lottie_animation_render_tree(Lottie_Animation *animation,
49                                                              size_t frameNo,
50                                                              size_t w, size_t h);
51
52 /*
53  * Request to render the content of the frame $frame_number to buffer $buffer asynchronously.
54  * frame_number, the frame number needs to be rendered.
55  * buffer , surface buffer use for rendering
56  * width  , width of the surface
57  * height , height of the surface
58  * bytes_per_line, stride of the surface in bytes.
59  *
60  * PS : user must call lottie_animation_render_flush to make sure render is finished.
61  */
62 LOT_EXPORT void
63 lottie_animation_render_async(Lottie_Animation *animation,
64                               size_t frame_number,
65                               uint32_t *buffer,
66                               size_t width,
67                               size_t height,
68                               size_t bytes_per_line);
69
70
71 /*
72  * Request to finish the current asyn renderer job for this animation object.
73  * if render is finished then this call returns immidiately
74  * if not it waits till render job finish and then return.
75  * user must use lottie_animation_render_async and lottie_animation_render_flush
76  * together to get the benefit of async rendering.
77  */
78 LOT_EXPORT void
79 lottie_animation_render_flush(Lottie_Animation *animation);
80
81 #ifdef __cplusplus
82 }
83 #endif
84
85 #endif //_LOTTIE_ANIMATION_CAPI_H_
86