From 01733cd6cda8a1195ab916d2e9a0c57affcccb41 Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Tue, 13 Nov 2018 15:16:48 +0900 Subject: [PATCH] lottie: add lottie_animation_render_tree() c api . Change-Id: I23004c1c2a4aed7e285624e095295ee8e4b18894 --- inc/lottieanimation_capi.h | 13 +++++++++++++ src/binding/c/lottieanimation_capi.cpp | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/inc/lottieanimation_capi.h b/inc/lottieanimation_capi.h index 86a7bfc..89b94cd 100644 --- a/inc/lottieanimation_capi.h +++ b/inc/lottieanimation_capi.h @@ -36,6 +36,19 @@ LOT_EXPORT size_t lottie_animation_prepare_frame(Lottie_Animation *animation, LOT_EXPORT size_t lottie_animation_get_node_count(const Lottie_Animation *animation); LOT_EXPORT const LOTNode* lottie_animation_get_node(Lottie_Animation *animation, size_t idx); + +/* + * Get the render tree which contains the snapshot of the animation object at frame $frame_number + * frame_number, the content of the animation in that frame number + * width , width of the viewbox + * height , height of the viewbox + * + * PS : user has to traverse the tree for rendering. @see LOTLayerNode and @see LOTNode + */ +LOT_EXPORT const LOTLayerNode * lottie_animation_render_tree(Lottie_Animation *animation, + size_t frameNo, + size_t w, size_t h); + /* * Request to render the content of the frame $frame_number to buffer $buffer asynchronously. * frame_number, the frame number needs to be rendered. diff --git a/src/binding/c/lottieanimation_capi.cpp b/src/binding/c/lottieanimation_capi.cpp index a619389..2d7efc3 100644 --- a/src/binding/c/lottieanimation_capi.cpp +++ b/src/binding/c/lottieanimation_capi.cpp @@ -99,6 +99,16 @@ LOT_EXPORT const LOTNode* lottie_animation_get_node(const Lottie_Animation_S *an return animation->mAnimation->renderList(animation->mFrameNo, animation->mWidth, animation->mHeight)[idx]; } +LOT_EXPORT const LOTLayerNode * lottie_animation_render_tree(Lottie_Animation_S *animation, size_t frameNo, size_t w, size_t h) +{ + if (!animation) return nullptr; + + animation->mFrameNo = frameNo; + animation->mWidth = w; + animation->mHeight = h; + return animation->mAnimation->renderTree(frameNo, w, h); +} + LOT_EXPORT void lottie_animation_render_async(Lottie_Animation_S *animation, size_t frame_number, -- 2.7.4