INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
#install header
-install(FILES inc/lottieanimation.h inc/lottieanimation_capi.h inc/lottiecommon.h DESTINATION include)
+install(FILES
+ inc/rlottie.h
+ inc/rlottie_capi.h
+ inc/rlottiecommon.h
+ inc/lottieanimation.h
+ inc/lottieanimation_capi.h
+ inc/lottiecommon.h
+ DESTINATION include)
#install lib
install( TARGETS lottie-player EXPORT lottie-player-targets
#include <Evas.h>
#include <Ecore.h>
#include <Ecore_Evas.h>
-#include "lottieanimation.h"
-#include "lottieanimation_capi.h"
+#include "rlottie.h"
+#include "rlottie_capi.h"
#include<future>
#include <cmath>
class LottieView
-/*
- * 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 _LOTTIE_ANIMATION_H_
-#define _LOTTIE_ANIMATION_H_
-
-#include <future>
-#include <vector>
-#include <memory>
-
-#ifdef _WIN32
-#ifdef LOT_BUILD
-#ifdef DLL_EXPORT
-#define LOT_EXPORT __declspec(dllexport)
-#else
-#define LOT_EXPORT
-#endif
-#else
-#define LOT_EXPORT __declspec(dllimport)
-#endif
-#else
-#ifdef __GNUC__
-#if __GNUC__ >= 4
-#define LOT_EXPORT __attribute__((visibility("default")))
-#else
-#define LOT_EXPORT
-#endif
-#else
-#define LOT_EXPORT
-#endif
-#endif
-
-class AnimationImpl;
-struct LOTNode;
-struct LOTLayerNode;
-
-namespace lottie {
-
-class LOT_EXPORT Surface {
-public:
- /**
- * @brief Surface object constructor.
- *
- * @param[in] buffer surface buffer.
- * @param[in] width surface width.
- * @param[in] height surface height.
- * @param[in] bytesPerLine number of bytes in a surface scanline.
- *
- * @note Default surface format is ARGB32_Premultiplied.
- *
- * @internal
- */
- Surface(uint32_t *buffer, size_t width, size_t height, size_t bytesPerLine);
-
- /**
- * @brief Returns width of the surface.
- *
- * @return surface width
- *
- * @internal
- *
- */
- size_t width() const {return mWidth;}
-
- /**
- * @brief Returns height of the surface.
- *
- * @return surface height
- *
- * @internal
- */
- size_t height() const {return mHeight;}
-
- /**
- * @brief Returns number of bytes in the surface scanline.
- *
- * @return number of bytes in scanline.
- *
- * @internal
- */
- size_t bytesPerLine() const {return mBytesPerLine;}
-
- /**
- * @brief Returns buffer attached tp the surface.
- *
- * @return buffer attaced to the Surface.
- *
- * @internal
- */
- uint32_t *buffer() const {return mBuffer;}
-
- /**
- * @brief Default constructor.
- */
- Surface() = default;
-private:
- uint32_t *mBuffer{nullptr};
- size_t mWidth{0};
- size_t mHeight{0};
- size_t mBytesPerLine{0};
-};
-
-class LOT_EXPORT Animation {
-public:
-
- /**
- * @brief Constructs an animation object from file path.
- *
- * @param[in] path Lottie resource file path
- *
- * @return Animation object that can render the contents of the
- * Lottie resource represented by file path.
- *
- * @internal
- */
- static std::unique_ptr<Animation>
- loadFromFile(const std::string &path);
-
- /**
- * @brief Constructs an animation object from JSON string data.
- *
- * @param[in] jsonData The JSON string data.
- * @param[in] key the string that will be used to cache the JSON string data.
- *
- * @return Animation object that can render the contents of the
- * Lottie resource represented by JSON string data.
- *
- * @internal
- */
- static std::unique_ptr<Animation>
- loadFromData(std::string jsonData, const std::string &key);
-
- /**
- * @brief Returns default framerate of the Lottie resource.
- *
- * @return framerate of the Lottie resource
- *
- * @internal
- *
- */
- double frameRate() const;
-
- /**
- * @brief Returns total number of frames present in the Lottie resource.
- *
- * @return frame count of the Lottie resource.
- *
- * @note frame number starts with 0.
- *
- * @internal
- */
- size_t totalFrame() const;
-
- /**
- * @brief Returns default viewport size of the Lottie resource.
- *
- * @param[out] width default width of the viewport.
- * @param[out] height default height of the viewport.
- *
- * @internal
- *
- */
- void size(size_t &width, size_t &height) const;
-
- /**
- * @brief Returns total animation duration of Lottie resource in second.
- * it uses totalFrame() and frameRate() to calculate the duration.
- * duration = totalFrame() / frameRate().
- *
- * @return total animation duration in second.
- * @retval 0 if the Lottie resource has no animation.
- *
- * @see totalFrame()
- * @see frameRate()
- *
- * @internal
- */
- double duration() const;
-
- /**
- * @brief Returns frame number for a given position.
- * this function helps to map the position value retuned
- * by the animator to a frame number in side the Lottie resource.
- * frame_number = lerp(start_frame, endframe, pos);
- *
- * @param[in] pos normalized position value [0 ... 1]
- *
- * @return frame numer maps to the position value [startFrame .... endFrame]
- *
- * @internal
- */
- size_t frameAtPos(double pos);
-
- /**
- * @brief Renders the content to surface Asynchronously.
- * it gives a future in return to get the result of the
- * rendering at a future point.
- * To get best performance user has to start rendering as soon as
- * it finds that content at {frameNo} has to be rendered and get the
- * result from the future at the last moment when the surface is needed
- * to draw into the screen.
- *
- *
- * @param[in] frameNo Content corresponds to the @p frameNo needs to be drawn
- * @param[in] surface Surface in which content will be drawn
- *
- * @return future that will hold the result when rendering finished.
- *
- * for Synchronus rendering @see renderSync
- *
- * @see Surface
- * @internal
- */
- std::future<Surface> render(size_t frameNo, Surface surface);
-
- /**
- * @brief Renders the content to surface synchronously.
- * for performance use the async rendering @see render
- *
- * @param[in] frameNo Content corresponds to the @p frameNo needs to be drawn
- * @param[in] surface Surface in which content will be drawn
- *
- * @internal
- */
- void renderSync(size_t frameNo, Surface surface);
-
- /**
- * @brief Returns root layer of the composition updated with
- * content of the Lottie resource at frame number @p frameNo.
- *
- * @param[in] frameNo Content corresponds to the @p frameNo needs to be extracted.
- * @param[in] width content viewbox width
- * @param[in] height content viewbox height
- *
- * @return Root layer node.
- *
- * @internal
- */
- const LOTLayerNode * renderTree(size_t frameNo, size_t width, size_t height) const;
-
- /**
- * @brief default destructor
- *
- * @internal
- */
- ~Animation();
-
-private:
- /**
- * @brief default constructor
- *
- * @internal
- */
- Animation();
-
- std::unique_ptr<AnimationImpl> d;
-};
-
-} // namespace lotplayer
-
-#endif // _LOTTIE_ANIMATION_H_
+#include "rlottie.h"
\ No newline at end of file
-/*
- * 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 _LOTTIE_ANIMATION_CAPI_H_
-#define _LOTTIE_ANIMATION_CAPI_H_
-
-#include <stddef.h>
-#include <stdint.h>
-#include <lottiecommon.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-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.
- *
- * @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);
-
-/**
- * @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] 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 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);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //_LOTTIE_ANIMATION_CAPI_H_
-
+#include "rlottie_capi.h"
\ No newline at end of file
-/*
- * 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 _LOTTIE_COMMON_H_
-#define _LOTTIE_COMMON_H_
-
-#ifdef _WIN32
-#ifdef LOT_BUILD
-#ifdef DLL_EXPORT
-#define LOT_EXPORT __declspec(dllexport)
-#else
-#define LOT_EXPORT
-#endif
-#else
-#define LOT_EXPORT __declspec(dllimport)
-#endif
-#else
-#ifdef __GNUC__
-#if __GNUC__ >= 4
-#define LOT_EXPORT __attribute__((visibility("default")))
-#else
-#define LOT_EXPORT
-#endif
-#else
-#define LOT_EXPORT
-#endif
-#endif
-
-
-/**
- * @defgroup Lottie_Animation Lottie_Animation
- *
- * Lottie Animation is a modern style vector based animation design. Its animation
- * resource(within json format) could be generated by Adobe After Effect using
- * bodymovin plugin. You can find a good examples in Lottie Community which
- * shares many free resources(see: www.lottiefiles.com).
- *
- * This Lottie_Animation is a common engine to manipulate, control Lottie
- * Animation from the Lottie resource - json file. It provides a scene-graph
- * node tree per frames by user demand as well as rasterized frame images.
- *
- */
-
-/**
- * @ingroup Lottie_Animation
- */
-
-
-/**
- * @brief Enumeration for Lottie Player error code.
- */
-typedef enum
-{
- //TODO: Coding convention??
- LOT_ANIMATION_ERROR_NONE = 0,
- LOT_ANIMATION_ERROR_NOT_PERMITTED,
- LOT_ANIMATION_ERROR_OUT_OF_MEMORY,
- LOT_ANIMATION_ERROR_INVALID_PARAMETER,
- LOT_ANIMATION_ERROR_RESULT_OUT_OF_RANGE,
- LOT_ANIMATION_ERROR_ALREADY_IN_PROGRESS,
- LOT_ANIMATION_ERROR_UNKNOWN
-} LOTErrorType;
-
-typedef enum
-{
- BrushSolid = 0,
- BrushGradient
-} LOTBrushType;
-
-typedef enum
-{
- FillEvenOdd = 0,
- FillWinding
-} LOTFillRule;
-
-typedef enum
-{
- JoinMiter = 0,
- JoinBevel,
- JoinRound
-} LOTJoinStyle;
-
-typedef enum
-{
- CapFlat = 0,
- CapSquare,
- CapRound
-} LOTCapStyle;
-
-typedef enum
-{
- GradientLinear = 0,
- GradientRadial
-} LOTGradientType;
-
-typedef struct LOTGradientStop
-{
- float pos;
- unsigned char r, g, b, a;
-} LOTGradientStop;
-
-typedef enum
-{
- MaskModeAdd = 0,
- MaskModeSubstract,
- MaskModeIntersect,
- MaskModeDifference
-} LOTMaskMode;
-
-typedef struct LOTMask {
- struct {
- const float *ptPtr;
- int ptCount;
- const char* elmPtr;
- int elmCount;
- } mPath;
- LOTMaskMode mMode;
-}LOTMask;
-
-typedef enum
-{
- MatteNone = 0,
- MatteAlpha,
- MatteAlphaInv,
- MatteLuma,
- MatteLumaInv
-} LOTMatteType;
-
-typedef struct LOTNode {
-
-#define ChangeFlagNone 0x0000
-#define ChangeFlagPath 0x0001
-#define ChangeFlagPaint 0x0010
-#define ChangeFlagAll (ChangeFlagPath & ChangeFlagPaint)
-
- struct {
- const float *ptPtr;
- int ptCount;
- const char* elmPtr;
- int elmCount;
- } mPath;
-
- struct {
- unsigned char r, g, b, a;
- } mColor;
-
- struct {
- unsigned char enable;
- int width;
- LOTCapStyle cap;
- LOTJoinStyle join;
- int meterLimit;
- float* dashArray;
- int dashArraySize;
- } mStroke;
-
- struct {
- LOTGradientType type;
- LOTGradientStop *stopPtr;
- unsigned int stopCount;
- struct {
- float x, y;
- } start, end, center, focal;
- float cradius;
- float fradius;
- } mGradient;
-
- int mFlag;
- LOTBrushType mBrushType;
- LOTFillRule mFillRule;
-} LOTNode;
-
-
-
-typedef struct LOTLayerNode {
-
- struct {
- LOTMask *ptr;
- unsigned int size;
- } mMaskList;
-
- struct {
- const float *ptPtr;
- int ptCount;
- const char* elmPtr;
- int elmCount;
- } mClipPath;
-
- struct {
- struct LOTLayerNode **ptr;
- unsigned int size;
- } mLayerList;
-
- struct {
- LOTNode **ptr;
- unsigned int size;
- } mNodeList;
-
- LOTMatteType mMatte;
- int mVisible;
-
-} LOTLayerNode;
-
-/**
- * @}
- */
-
-#endif // _LOTTIE_COMMON_H_
+#include "rlottiecommon.h"
\ No newline at end of file
-install_headers(['lottieanimation.h',
+install_headers([
+ 'rlottie.h',
+ 'rlottie_capi.h',
+ 'rlottiecommon.h',
+ 'lottieanimation.h',
'lottiecommon.h',
- 'lottieanimation_capi.h'])
+ 'lottieanimation_capi.h'
+ ])
--- /dev/null
+/*
+ * 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_H_
+#define _RLOTTIE_H_
+
+#include <future>
+#include <vector>
+#include <memory>
+
+#ifdef _WIN32
+#ifdef LOT_BUILD
+#ifdef DLL_EXPORT
+#define LOT_EXPORT __declspec(dllexport)
+#else
+#define LOT_EXPORT
+#endif
+#else
+#define LOT_EXPORT __declspec(dllimport)
+#endif
+#else
+#ifdef __GNUC__
+#if __GNUC__ >= 4
+#define LOT_EXPORT __attribute__((visibility("default")))
+#else
+#define LOT_EXPORT
+#endif
+#else
+#define LOT_EXPORT
+#endif
+#endif
+
+class AnimationImpl;
+struct LOTNode;
+struct LOTLayerNode;
+
+namespace lottie {
+
+class LOT_EXPORT Surface {
+public:
+ /**
+ * @brief Surface object constructor.
+ *
+ * @param[in] buffer surface buffer.
+ * @param[in] width surface width.
+ * @param[in] height surface height.
+ * @param[in] bytesPerLine number of bytes in a surface scanline.
+ *
+ * @note Default surface format is ARGB32_Premultiplied.
+ *
+ * @internal
+ */
+ Surface(uint32_t *buffer, size_t width, size_t height, size_t bytesPerLine);
+
+ /**
+ * @brief Returns width of the surface.
+ *
+ * @return surface width
+ *
+ * @internal
+ *
+ */
+ size_t width() const {return mWidth;}
+
+ /**
+ * @brief Returns height of the surface.
+ *
+ * @return surface height
+ *
+ * @internal
+ */
+ size_t height() const {return mHeight;}
+
+ /**
+ * @brief Returns number of bytes in the surface scanline.
+ *
+ * @return number of bytes in scanline.
+ *
+ * @internal
+ */
+ size_t bytesPerLine() const {return mBytesPerLine;}
+
+ /**
+ * @brief Returns buffer attached tp the surface.
+ *
+ * @return buffer attaced to the Surface.
+ *
+ * @internal
+ */
+ uint32_t *buffer() const {return mBuffer;}
+
+ /**
+ * @brief Default constructor.
+ */
+ Surface() = default;
+private:
+ uint32_t *mBuffer{nullptr};
+ size_t mWidth{0};
+ size_t mHeight{0};
+ size_t mBytesPerLine{0};
+};
+
+class LOT_EXPORT Animation {
+public:
+
+ /**
+ * @brief Constructs an animation object from file path.
+ *
+ * @param[in] path Lottie resource file path
+ *
+ * @return Animation object that can render the contents of the
+ * Lottie resource represented by file path.
+ *
+ * @internal
+ */
+ static std::unique_ptr<Animation>
+ loadFromFile(const std::string &path);
+
+ /**
+ * @brief Constructs an animation object from JSON string data.
+ *
+ * @param[in] jsonData The JSON string data.
+ * @param[in] key the string that will be used to cache the JSON string data.
+ *
+ * @return Animation object that can render the contents of the
+ * Lottie resource represented by JSON string data.
+ *
+ * @internal
+ */
+ static std::unique_ptr<Animation>
+ loadFromData(std::string jsonData, const std::string &key);
+
+ /**
+ * @brief Returns default framerate of the Lottie resource.
+ *
+ * @return framerate of the Lottie resource
+ *
+ * @internal
+ *
+ */
+ double frameRate() const;
+
+ /**
+ * @brief Returns total number of frames present in the Lottie resource.
+ *
+ * @return frame count of the Lottie resource.
+ *
+ * @note frame number starts with 0.
+ *
+ * @internal
+ */
+ size_t totalFrame() const;
+
+ /**
+ * @brief Returns default viewport size of the Lottie resource.
+ *
+ * @param[out] width default width of the viewport.
+ * @param[out] height default height of the viewport.
+ *
+ * @internal
+ *
+ */
+ void size(size_t &width, size_t &height) const;
+
+ /**
+ * @brief Returns total animation duration of Lottie resource in second.
+ * it uses totalFrame() and frameRate() to calculate the duration.
+ * duration = totalFrame() / frameRate().
+ *
+ * @return total animation duration in second.
+ * @retval 0 if the Lottie resource has no animation.
+ *
+ * @see totalFrame()
+ * @see frameRate()
+ *
+ * @internal
+ */
+ double duration() const;
+
+ /**
+ * @brief Returns frame number for a given position.
+ * this function helps to map the position value retuned
+ * by the animator to a frame number in side the Lottie resource.
+ * frame_number = lerp(start_frame, endframe, pos);
+ *
+ * @param[in] pos normalized position value [0 ... 1]
+ *
+ * @return frame numer maps to the position value [startFrame .... endFrame]
+ *
+ * @internal
+ */
+ size_t frameAtPos(double pos);
+
+ /**
+ * @brief Renders the content to surface Asynchronously.
+ * it gives a future in return to get the result of the
+ * rendering at a future point.
+ * To get best performance user has to start rendering as soon as
+ * it finds that content at {frameNo} has to be rendered and get the
+ * result from the future at the last moment when the surface is needed
+ * to draw into the screen.
+ *
+ *
+ * @param[in] frameNo Content corresponds to the @p frameNo needs to be drawn
+ * @param[in] surface Surface in which content will be drawn
+ *
+ * @return future that will hold the result when rendering finished.
+ *
+ * for Synchronus rendering @see renderSync
+ *
+ * @see Surface
+ * @internal
+ */
+ std::future<Surface> render(size_t frameNo, Surface surface);
+
+ /**
+ * @brief Renders the content to surface synchronously.
+ * for performance use the async rendering @see render
+ *
+ * @param[in] frameNo Content corresponds to the @p frameNo needs to be drawn
+ * @param[in] surface Surface in which content will be drawn
+ *
+ * @internal
+ */
+ void renderSync(size_t frameNo, Surface surface);
+
+ /**
+ * @brief Returns root layer of the composition updated with
+ * content of the Lottie resource at frame number @p frameNo.
+ *
+ * @param[in] frameNo Content corresponds to the @p frameNo needs to be extracted.
+ * @param[in] width content viewbox width
+ * @param[in] height content viewbox height
+ *
+ * @return Root layer node.
+ *
+ * @internal
+ */
+ const LOTLayerNode * renderTree(size_t frameNo, size_t width, size_t height) const;
+
+ /**
+ * @brief default destructor
+ *
+ * @internal
+ */
+ ~Animation();
+
+private:
+ /**
+ * @brief default constructor
+ *
+ * @internal
+ */
+ Animation();
+
+ std::unique_ptr<AnimationImpl> d;
+};
+
+} // namespace lotplayer
+
+#endif // _RLOTTIE_H_
--- /dev/null
+/*
+ * 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 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.
+ *
+ * @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);
+
+/**
+ * @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] 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 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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //_RLOTTIE_CAPI_H_
+
--- /dev/null
+/*
+ * 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_COMMON_H_
+#define _RLOTTIE_COMMON_H_
+
+#ifdef _WIN32
+#ifdef LOT_BUILD
+#ifdef DLL_EXPORT
+#define LOT_EXPORT __declspec(dllexport)
+#else
+#define LOT_EXPORT
+#endif
+#else
+#define LOT_EXPORT __declspec(dllimport)
+#endif
+#else
+#ifdef __GNUC__
+#if __GNUC__ >= 4
+#define LOT_EXPORT __attribute__((visibility("default")))
+#else
+#define LOT_EXPORT
+#endif
+#else
+#define LOT_EXPORT
+#endif
+#endif
+
+
+/**
+ * @defgroup Lottie_Animation Lottie_Animation
+ *
+ * Lottie Animation is a modern style vector based animation design. Its animation
+ * resource(within json format) could be generated by Adobe After Effect using
+ * bodymovin plugin. You can find a good examples in Lottie Community which
+ * shares many free resources(see: www.lottiefiles.com).
+ *
+ * This Lottie_Animation is a common engine to manipulate, control Lottie
+ * Animation from the Lottie resource - json file. It provides a scene-graph
+ * node tree per frames by user demand as well as rasterized frame images.
+ *
+ */
+
+/**
+ * @ingroup Lottie_Animation
+ */
+
+
+/**
+ * @brief Enumeration for Lottie Player error code.
+ */
+typedef enum
+{
+ //TODO: Coding convention??
+ LOT_ANIMATION_ERROR_NONE = 0,
+ LOT_ANIMATION_ERROR_NOT_PERMITTED,
+ LOT_ANIMATION_ERROR_OUT_OF_MEMORY,
+ LOT_ANIMATION_ERROR_INVALID_PARAMETER,
+ LOT_ANIMATION_ERROR_RESULT_OUT_OF_RANGE,
+ LOT_ANIMATION_ERROR_ALREADY_IN_PROGRESS,
+ LOT_ANIMATION_ERROR_UNKNOWN
+} LOTErrorType;
+
+typedef enum
+{
+ BrushSolid = 0,
+ BrushGradient
+} LOTBrushType;
+
+typedef enum
+{
+ FillEvenOdd = 0,
+ FillWinding
+} LOTFillRule;
+
+typedef enum
+{
+ JoinMiter = 0,
+ JoinBevel,
+ JoinRound
+} LOTJoinStyle;
+
+typedef enum
+{
+ CapFlat = 0,
+ CapSquare,
+ CapRound
+} LOTCapStyle;
+
+typedef enum
+{
+ GradientLinear = 0,
+ GradientRadial
+} LOTGradientType;
+
+typedef struct LOTGradientStop
+{
+ float pos;
+ unsigned char r, g, b, a;
+} LOTGradientStop;
+
+typedef enum
+{
+ MaskModeAdd = 0,
+ MaskModeSubstract,
+ MaskModeIntersect,
+ MaskModeDifference
+} LOTMaskMode;
+
+typedef struct LOTMask {
+ struct {
+ const float *ptPtr;
+ int ptCount;
+ const char* elmPtr;
+ int elmCount;
+ } mPath;
+ LOTMaskMode mMode;
+}LOTMask;
+
+typedef enum
+{
+ MatteNone = 0,
+ MatteAlpha,
+ MatteAlphaInv,
+ MatteLuma,
+ MatteLumaInv
+} LOTMatteType;
+
+typedef struct LOTNode {
+
+#define ChangeFlagNone 0x0000
+#define ChangeFlagPath 0x0001
+#define ChangeFlagPaint 0x0010
+#define ChangeFlagAll (ChangeFlagPath & ChangeFlagPaint)
+
+ struct {
+ const float *ptPtr;
+ int ptCount;
+ const char* elmPtr;
+ int elmCount;
+ } mPath;
+
+ struct {
+ unsigned char r, g, b, a;
+ } mColor;
+
+ struct {
+ unsigned char enable;
+ int width;
+ LOTCapStyle cap;
+ LOTJoinStyle join;
+ int meterLimit;
+ float* dashArray;
+ int dashArraySize;
+ } mStroke;
+
+ struct {
+ LOTGradientType type;
+ LOTGradientStop *stopPtr;
+ unsigned int stopCount;
+ struct {
+ float x, y;
+ } start, end, center, focal;
+ float cradius;
+ float fradius;
+ } mGradient;
+
+ int mFlag;
+ LOTBrushType mBrushType;
+ LOTFillRule mFillRule;
+} LOTNode;
+
+
+
+typedef struct LOTLayerNode {
+
+ struct {
+ LOTMask *ptr;
+ unsigned int size;
+ } mMaskList;
+
+ struct {
+ const float *ptPtr;
+ int ptCount;
+ const char* elmPtr;
+ int elmCount;
+ } mClipPath;
+
+ struct {
+ struct LOTLayerNode **ptr;
+ unsigned int size;
+ } mLayerList;
+
+ struct {
+ LOTNode **ptr;
+ unsigned int size;
+ } mNodeList;
+
+ LOTMatteType mMatte;
+ int mVisible;
+
+} LOTLayerNode;
+
+/**
+ * @}
+ */
+
+#endif // _RLOTTIE_COMMON_H_
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "lottieanimation.h"
+#include "rlottie.h"
#include "vdebug.h"
using namespace lottie;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "lottieanimation.h"
+#include "rlottie.h"
#include "lottieitem.h"
#include "lottieloader.h"
#include "lottiemodel.h"
#include"vpath.h"
#include"vpoint.h"
#include"vpathmesure.h"
-#include"lottiecommon.h"
-#include"lottieanimation.h"
+#include"rlottiecommon.h"
+#include"rlottie.h"
#include"vpainter.h"
#include"vdrawable.h"
#include <gtest/gtest.h>
-#include "lottieanimation.h"
+#include "rlottie.h"
class AnimationTest : public ::testing::Test {
public: