1 #ifndef _LOTTIE_ANIMATION_CAPI_H_
2 #define _LOTTIE_ANIMATION_CAPI_H_
7 #include <lottiecommon.h>
13 typedef struct Lottie_Animation_S Lottie_Animation;
16 * @brief Constructs an animation object from file path.
18 * @param[in] path Lottie resource file path
20 * @return Animation object that can build the contents of the
21 * Lottie resource represented by file path.
23 * @see lottie_animation_destroy()
25 * @ingroup Lottie_Animation
28 LOT_EXPORT Lottie_Animation *lottie_animation_from_file(const char *path);
31 * @brief Constructs an animation object from JSON string data.
33 * @param[in] data The JSON string data.
34 * @param[in] key the string that will be used to cache the JSON string data.
36 * @return Animation object that can build the contents of the
37 * Lottie resource represented by JSON string data.
39 * @ingroup Lottie_Animation
42 LOT_EXPORT Lottie_Animation *lottie_animation_from_data(const char *data, const char *key);
45 * @brief Free given Animation object resource.
47 * @param[in] animation Animation object to free.
49 * @see lottie_animation_from_file()
50 * @see lottie_animation_from_data()
52 * @ingroup Lottie_Animation
55 LOT_EXPORT void lottie_animation_destroy(Lottie_Animation *animation);
58 * @brief Returns default viewport size of the Lottie resource.
60 * @param[in] animation Animation object.
61 * @param[out] w default width of the viewport.
62 * @param[out] h default height of the viewport.
64 * @ingroup Lottie_Animation
67 LOT_EXPORT void lottie_animation_get_size(const Lottie_Animation *animation, size_t *width, size_t *height);
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().
74 * @param[in] animation Animation object.
76 * @return total animation duration in second.
77 * @c 0 if the Lottie resource has no animation.
79 * @see lottie_animation_get_totalframe()
80 * @see lottie_animation_get_framerate()
82 * @ingroup Lottie_Animation
85 LOT_EXPORT double lottie_animation_get_duration(const Lottie_Animation *animation);
88 * @brief Returns total number of frames present in the Lottie resource.
90 * @param[in] animation Animation object.
92 * @return frame count of the Lottie resource.*
94 * @note frame number starts with 0.
96 * @see lottie_animation_get_duration()
97 * @see lottie_animation_get_framerate()
99 * @ingroup Lottie_Animation
102 LOT_EXPORT size_t lottie_animation_get_totalframe(const Lottie_Animation *animation);
105 * @brief Returns default framerate of the Lottie resource.
107 * @param[in] animation Animation object.
109 * @return framerate of the Lottie resource
111 * @ingroup Lottie_Animation
115 LOT_EXPORT double lottie_animation_get_framerate(const Lottie_Animation *animation);
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.
121 * @param[in] animation Animation object.
122 * @param[in] width requested snapshot viewport width.
123 * @param[in] height requested snapshot viewport height.
125 * @return Animation snapshot tree.
127 * @note: User has to traverse the tree for rendering.
132 * @ingroup Lottie_Animation
135 LOT_EXPORT const LOTLayerNode * lottie_animation_render_tree(Lottie_Animation *animation,
137 size_t width, size_t height);
140 * @brief Request to render the content of the frame @p frame_num to buffer @p buffer asynchronously.
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.
149 * @note user must call lottie_animation_render_flush() to make sure render is finished.
151 * @ingroup Lottie_Animation
155 lottie_animation_render_async(Lottie_Animation *animation,
160 size_t bytes_per_line);
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.
167 * @param[in] animation Animation object.
169 * @warning User must call lottie_animation_render_async() and lottie_animation_render_flush()
170 * in pair to get the benefit of async rendering.
172 * @ingroup Lottie_Animation
176 lottie_animation_render_flush(Lottie_Animation *animation);
182 #endif //_LOTTIE_ANIMATION_CAPI_H_