1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
|
/*
* Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _RLOTTIE_CAPI_H_
#define _RLOTTIE_CAPI_H_
#include <stddef.h>
#include <stdint.h>
#include <rlottiecommon.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
LOTTIE_ANIMATION_PROPERTY_FILLCOLOR, /*!< Color property of Fill object , value type is float [0 ... 1] */
LOTTIE_ANIMATION_PROPERTY_FILLOPACITY, /*!< Opacity property of Fill object , value type is float [ 0 .. 100] */
LOTTIE_ANIMATION_PROPERTY_STROKECOLOR, /*!< Color property of Stroke object , value type is float [0 ... 1] */
LOTTIE_ANIMATION_PROPERTY_STROKEOPACITY, /*!< Opacity property of Stroke object , value type is float [ 0 .. 100] */
LOTTIE_ANIMATION_PROPERTY_STROKEWIDTH, /*!< stroke with property of Stroke object , value type is float */
LOTTIE_ANIMATION_PROPERTY_TR_ANCHOR, /*!< Transform Anchor property of Layer and Group object , value type is int */
LOTTIE_ANIMATION_PROPERTY_TR_POSITION, /*!< Transform Position property of Layer and Group object , value type is int */
LOTTIE_ANIMATION_PROPERTY_TR_SCALE, /*!< Transform Scale property of Layer and Group object , value type is float range[0 ..100] */
LOTTIE_ANIMATION_PROPERTY_TR_ROTATION, /*!< Transform Scale property of Layer and Group object , value type is float. range[0 .. 360] in degrees*/
LOTTIE_ANIMATION_PROPERTY_TR_OPACITY /*!< Transform Opacity property of Layer and Group object , value type is float [ 0 .. 100] */
}Lottie_Animation_Property;
typedef struct Lottie_Animation_S Lottie_Animation;
/**
* @brief Constructs an animation object from file path.
*
* @param[in] path Lottie resource file path
*
* @return Animation object that can build the contents of the
* Lottie resource represented by file path.
*
* @see lottie_animation_destroy()
*
* @ingroup Lottie_Animation
* @internal
*/
LOT_EXPORT Lottie_Animation *lottie_animation_from_file(const char *path);
/**
* @brief Constructs an animation object from JSON string data.
*
* @param[in] data The JSON string data.
* @param[in] key the string that will be used to cache the JSON string data.
* @param[in] resource_path the path that will be used to load external resource needed by the JSON data.
*
* @return Animation object that can build the contents of the
* Lottie resource represented by JSON string data.
*
* @ingroup Lottie_Animation
* @internal
*/
LOT_EXPORT Lottie_Animation *lottie_animation_from_data(const char *data, const char *key, const char *resource_path);
/**
* @brief Free given Animation object resource.
*
* @param[in] animation Animation object to free.
*
* @see lottie_animation_from_file()
* @see lottie_animation_from_data()
*
* @ingroup Lottie_Animation
* @internal
*/
LOT_EXPORT void lottie_animation_destroy(Lottie_Animation *animation);
/**
* @brief Returns default viewport size of the Lottie resource.
*
* @param[in] animation Animation object.
* @param[out] w default width of the viewport.
* @param[out] h default height of the viewport.
*
* @ingroup Lottie_Animation
* @internal
*/
LOT_EXPORT void lottie_animation_get_size(const Lottie_Animation *animation, size_t *width, size_t *height);
/**
* @brief Returns total animation duration of Lottie resource in second.
* it uses totalFrame() and frameRate() to calculate the duration.
* duration = totalFrame() / frameRate().
*
* @param[in] animation Animation object.
*
* @return total animation duration in second.
* @c 0 if the Lottie resource has no animation.
*
* @see lottie_animation_get_totalframe()
* @see lottie_animation_get_framerate()
*
* @ingroup Lottie_Animation
* @internal
*/
LOT_EXPORT double lottie_animation_get_duration(const Lottie_Animation *animation);
/**
* @brief Returns total number of frames present in the Lottie resource.
*
* @param[in] animation Animation object.
*
* @return frame count of the Lottie resource.*
*
* @note frame number starts with 0.
*
* @see lottie_animation_get_duration()
* @see lottie_animation_get_framerate()
*
* @ingroup Lottie_Animation
* @internal
*/
LOT_EXPORT size_t lottie_animation_get_totalframe(const Lottie_Animation *animation);
/**
* @brief Returns default framerate of the Lottie resource.
*
* @param[in] animation Animation object.
*
* @return framerate of the Lottie resource
*
* @ingroup Lottie_Animation
* @internal
*
*/
LOT_EXPORT double lottie_animation_get_framerate(const Lottie_Animation *animation);
/**
* @brief Get the render tree which contains the snapshot of the animation object
* at frame = @c frame_num, the content of the animation in that frame number.
*
* @param[in] animation Animation object.
* @param[in] frame_num Content corresponds to the @p frame_num needs to be drawn
* @param[in] width requested snapshot viewport width.
* @param[in] height requested snapshot viewport height.
*
* @return Animation snapshot tree.
*
* @note: User has to traverse the tree for rendering.
*
* @see LOTLayerNode
* @see LOTNode
*
* @ingroup Lottie_Animation
* @internal
*/
LOT_EXPORT const LOTLayerNode *lottie_animation_render_tree(Lottie_Animation *animation, size_t frame_num, size_t width, size_t height);
/**
* @brief Maps position to frame number and returns it.
*
* @param[in] animation Animation object.
* @param[in] pos position in the range [ 0.0 .. 1.0 ].
*
* @return mapped frame numbe in the range [ start_frame .. end_frame ].
* @c 0 if the Lottie resource has no animation.
*
*
* @ingroup Lottie_Animation
* @internal
*/
LOT_EXPORT size_t lottie_animation_get_frame_at_pos(const Lottie_Animation *animation, float pos);
/**
* @brief Request to render the content of the frame @p frame_num to buffer @p buffer.
*
* @param[in] animation Animation object.
* @param[in] frame_num the frame number needs to be rendered.
* @param[in] buffer surface buffer use for rendering.
* @param[in] width width of the surface
* @param[in] height height of the surface
* @param[in] bytes_per_line stride of the surface in bytes.
*
*
* @ingroup Lottie_Animation
* @internal
*/
LOT_EXPORT void lottie_animation_render(Lottie_Animation *animation, size_t frame_num, uint32_t *buffer, size_t width, size_t height, size_t bytes_per_line);
/**
* @brief Request to render the content of the frame @p frame_num to buffer @p buffer asynchronously.
*
* @param[in] animation Animation object.
* @param[in] frame_num the frame number needs to be rendered.
* @param[in] buffer surface buffer use for rendering.
* @param[in] width width of the surface
* @param[in] height height of the surface
* @param[in] bytes_per_line stride of the surface in bytes.
*
* @note user must call lottie_animation_render_flush() to make sure render is finished.
*
* @ingroup Lottie_Animation
* @internal
*/
LOT_EXPORT void lottie_animation_render_async(Lottie_Animation *animation, size_t frame_num, uint32_t *buffer, size_t width, size_t height, size_t bytes_per_line);
/**
* @brief Request to finish the current async renderer job for this animation object.
* If render is finished then this call returns immidiately.
* If not, it waits till render job finish and then return.
*
* @param[in] animation Animation object.
*
* @warning User must call lottie_animation_render_async() and lottie_animation_render_flush()
* in pair to get the benefit of async rendering.
*
* @return the pixel buffer it finished rendering.
*
* @ingroup Lottie_Animation
* @internal
*/
LOT_EXPORT uint32_t *lottie_animation_render_flush(Lottie_Animation *animation);
/**
* @brief Request to change the properties of this animation object.
* Keypath should conatin object names separated by (.) and can handle globe(**) or wildchar(*)
*
* @usage
* To change fillcolor property of fill1 object in the layer1->group1->fill1 hirarchy to RED color
*
* lottie_animation_property_override(animation, LOTTIE_ANIMATION_PROPERTY_FILLCOLOR, "layer1.group1.fill1", 1.0, 0.0, 0.0);
*
* if all the color property inside group1 needs to be changed to GREEN color
*
* lottie_animation_property_override(animation, LOTTIE_ANIMATION_PROPERTY_FILLCOLOR, "**.group1.**", 1.0, 0.0, 0.0);
*
* @param[in] animation Animation object.
* @param[in] type Property type. (@p Lottie_Animation_Property)
* @param[in] keypath Specific content of target.
* @param[in] ... Property values.
*
* @ingroup Lottie_Animation
* @internal
* */
LOT_EXPORT void lottie_animation_property_override(Lottie_Animation *animation, const Lottie_Animation_Property type, const char *keypath, ...);
/**
* @brief Returns list of markers in the Lottie resource
* @p LOTMarkerList has a @p LOTMarker list and size of list
* @p LOTMarker has the marker's name, start frame, and end frame.
*
* @param[in] animation Animation object.
*
* @return The list of marker. If there is no marker, return null.
*
* @ingroup Lottie_Animation
* @internal
* */
LOT_EXPORT const LOTMarkerList* lottie_animation_get_markerlist(Lottie_Animation *animation);
#ifdef __cplusplus
}
#endif
#endif //_RLOTTIE_CAPI_H_
|