From: start1a Date: Sun, 27 Sep 2020 10:02:18 +0000 (+0900) Subject: add an example of win32 app that play rlottie animation by vs2019 X-Git-Tag: accepted/tizen/unified/20201102.124239~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8f7f7c7892156319cc356c4c3cb74e36d7e34e8;p=platform%2Fcore%2Fuifw%2Flottie-player.git add an example of win32 app that play rlottie animation by vs2019 --- diff --git a/example/rlottiePlayer/Source.cpp b/example/rlottiePlayer/Source.cpp index 9f112cb..2db0ba3 100644 --- a/example/rlottiePlayer/Source.cpp +++ b/example/rlottiePlayer/Source.cpp @@ -47,4 +47,9 @@ size_t getTotalFrame() bool isAnimNULL() { return anim == NULL; +} + +void freeAnimation() +{ + free(buffer); } \ No newline at end of file diff --git a/example/rlottiePlayer/resource.h b/example/rlottiePlayer/resource.h index 7674dde..ac46939 100644 --- a/example/rlottiePlayer/resource.h +++ b/example/rlottiePlayer/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}} -// Microsoft Visual C++¿¡¼­ »ý¼ºÇÑ Æ÷ÇÔ ÆÄÀÏÀÔ´Ï´Ù. -// rlottiePlayer.rc¿¡¼­ »ç¿ëµÇ°í ÀÖ½À´Ï´Ù. +// This is an include file generated by Microsoft Visual C++. +// It is being used in rlottiePlayer.rc. // #define IDC_MYICON 2 #define IDD_RLOTTIEPLAYER_DIALOG 102 diff --git a/example/rlottiePlayer/rlottie.h b/example/rlottiePlayer/rlottie.h deleted file mode 100644 index 12c413b..0000000 --- a/example/rlottiePlayer/rlottie.h +++ /dev/null @@ -1,525 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. - - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _RLOTTIE_H_ -#define _RLOTTIE_H_ - -#include -#include -#include - -#if defined _WIN32 || defined __CYGWIN__ - #ifdef RLOTTIE_BUILD - #define RLOTTIE_API __declspec(dllexport) - #else - #define RLOTTIE_API __declspec(dllimport) - #endif -#else - #ifdef RLOTTIE_BUILD - #define RLOTTIE_API __attribute__ ((visibility ("default"))) - #else - #define RLOTTIE_API - #endif -#endif - -class AnimationImpl; -struct LOTNode; -struct LOTLayerNode; - -namespace rlottie { - -/** - * @brief Configures rlottie model cache policy. - * - * Provides Library level control to configure model cache - * policy. Setting it to 0 will disable - * the cache as well as flush all the previously cached content. - * - * @param[in] cacheSize Maximum Model Cache size. - * - * @note to disable Caching configure with 0 size. - * @note to flush the current Cache content configure it with 0 and - * then reconfigure with the new size. - * - * @internal - */ -RLOTTIE_API void configureModelCacheSize(size_t cacheSize); - -struct Color { - Color() = default; - Color(float r, float g , float b):_r(r), _g(g), _b(b){} - float r() const {return _r;} - float g() const {return _g;} - float b() const {return _b;} -private: - float _r{0}; - float _g{0}; - float _b{0}; -}; - -struct Size { - Size() = default; - Size(float w, float h):_w(w), _h(h){} - float w() const {return _w;} - float h() const {return _h;} -private: - float _w{0}; - float _h{0}; -}; - -struct Point { - Point() = default; - Point(float x, float y):_x(x), _y(y){} - float x() const {return _x;} - float y() const {return _y;} -private: - float _x{0}; - float _y{0}; -}; - -struct FrameInfo { - explicit FrameInfo(uint32_t frame): _frameNo(frame){} - uint32_t curFrame() const {return _frameNo;} -private: - uint32_t _frameNo; -}; - -enum class Property { - FillColor, /*!< Color property of Fill object , value type is rlottie::Color */ - FillOpacity, /*!< Opacity property of Fill object , value type is float [ 0 .. 100] */ - StrokeColor, /*!< Color property of Stroke object , value type is rlottie::Color */ - StrokeOpacity, /*!< Opacity property of Stroke object , value type is float [ 0 .. 100] */ - StrokeWidth, /*!< stroke with property of Stroke object , value type is float */ - TrAnchor, /*!< Transform Anchor property of Layer and Group object , value type is rlottie::Point */ - TrPosition, /*!< Transform Position property of Layer and Group object , value type is rlottie::Point */ - TrScale, /*!< Transform Scale property of Layer and Group object , value type is rlottie::Size. range[0 ..100] */ - TrRotation, /*!< Transform Scale property of Layer and Group object , value type is float. range[0 .. 360] in degrees*/ - TrOpacity /*!< Transform Opacity property of Layer and Group object , value type is float [ 0 .. 100] */ -}; - -struct Color_Type{}; -struct Point_Type{}; -struct Size_Type{}; -struct Float_Type{}; -template struct MapType; - -class RLOTTIE_API 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 Sets the Draw Area available on the Surface. - * - * Lottie will use the draw region size to generate frame image - * and will update only the draw rgion of the surface. - * - * @param[in] x region area x position. - * @param[in] y region area y position. - * @param[in] width region area width. - * @param[in] height region area height. - * - * @note Default surface format is ARGB32_Premultiplied. - * @note Default draw region area is [ 0 , 0, surface width , surface height] - * - * @internal - */ - void setDrawRegion(size_t x, size_t y, size_t width, size_t height); - - /** - * @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 Returns drawable area width of the surface. - * - * @return drawable area width - * - * @note Default value is width() of the surface - * - * @internal - * - */ - size_t drawRegionWidth() const {return mDrawArea.w;} - - /** - * @brief Returns drawable area height of the surface. - * - * @return drawable area height - * - * @note Default value is height() of the surface - * - * @internal - */ - size_t drawRegionHeight() const {return mDrawArea.h;} - - /** - * @brief Returns drawable area's x position of the surface. - * - * @return drawable area's x potition. - * - * @note Default value is 0 - * - * @internal - */ - size_t drawRegionPosX() const {return mDrawArea.x;} - - /** - * @brief Returns drawable area's y position of the surface. - * - * @return drawable area's y potition. - * - * @note Default value is 0 - * - * @internal - */ - size_t drawRegionPosY() const {return mDrawArea.y;} - - /** - * @brief Default constructor. - */ - Surface() = default; -private: - uint32_t *mBuffer{nullptr}; - size_t mWidth{0}; - size_t mHeight{0}; - size_t mBytesPerLine{0}; - struct { - size_t x{0}; - size_t y{0}; - size_t w{0}; - size_t h{0}; - }mDrawArea; -}; - -using MarkerList = std::vector>; -/** - * @brief https://helpx.adobe.com/after-effects/using/layer-markers-composition-markers.html - * Markers exported form AE are used to describe a segmnet of an animation {comment/tag , startFrame, endFrame} - * Marker can be use to devide a resource in to separate animations by tagging the segment with comment string , - * start frame and duration of that segment. - */ - -using LayerInfoList = std::vector>; - - -using ColorFilter = std::function; - -class RLOTTIE_API Animation { -public: - - /** - * @brief Constructs an animation object from file path. - * - * @param[in] path Lottie resource file path - * @param[in] cachePolicy whether to cache or not the model data. - * use only when need to explicit disabl caching for a - * particular resource. To disable caching at library level - * use @see configureModelCacheSize() instead. - * - * @return Animation object that can render the contents of the - * Lottie resource represented by file path. - * - * @internal - */ - static std::unique_ptr - loadFromFile(const std::string &path, bool cachePolicy=true); - - /** - * @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. - * @param[in] resourcePath the path will be used to search for external resource. - * @param[in] cachePolicy whether to cache or not the model data. - * use only when need to explicit disabl caching for a - * particular resource. To disable caching at library level - * use @see configureModelCacheSize() instead. - * - * @return Animation object that can render the contents of the - * Lottie resource represented by JSON string data. - * - * @internal - */ - static std::unique_ptr - loadFromData(std::string jsonData, const std::string &key, - const std::string &resourcePath="", bool cachePolicy=true); - - /** - * @brief Constructs an animation object from JSON string data and update. - * the color properties using ColorFilter. - - * @param[in] jsonData The JSON string data. - * @param[in] resourcePath the path will be used to search for external resource. - * @param[in] filter The color filter that will be applied for each color property - * found during parsing. - - * @return Animation object that can render the contents of the - * Lottie resource represented by JSON string data. - * - * @internal - */ - static std::unique_ptr - loadFromData(std::string jsonData, std::string resourcePath, ColorFilter filter); - - /** - * @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 - * @param[in] keepAspectRatio whether to keep the aspect ratio while scaling the content. - * - * @return future that will hold the result when rendering finished. - * - * for Synchronus rendering @see renderSync - * - * @see Surface - * @internal - */ - std::future render(size_t frameNo, Surface surface, bool keepAspectRatio=true); - - /** - * @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 - * @param[in] keepAspectRatio whether to keep the aspect ratio while scaling the content. - * - * @internal - */ - void renderSync(size_t frameNo, Surface surface, bool keepAspectRatio=true); - - /** - * @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 Returns Composition Markers. - * - * - * @return returns MarkerList of the Composition. - * - * @see MarkerList - * @internal - */ - const MarkerList& markers() const; - - /** - * @brief Returns Layer information{name, inFrame, outFrame} of all the child layers of the composition. - * - * - * @return List of Layer Information of the Composition. - * - * @see LayerInfoList - * @internal - */ - const LayerInfoList& layers() const; - - /** - * @brief Sets property value for the specified {@link KeyPath}. This {@link KeyPath} can resolve - * to multiple contents. In that case, the callback's value will apply to all of them. - * - * 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 - * - * player->setValue("layer1.group1.fill1", rlottie::Color(1, 0, 0); - * - * if all the color property inside group1 needs to be changed to GREEN color - * - * player->setValue("**.group1.**", rlottie::Color(0, 1, 0); - * - * @internal - */ - template - void setValue(const std::string &keypath, AnyValue value) - { - setValue(MapType>{}, prop, keypath, value); - } - - /** - * @brief default destructor - * - * @internal - */ - ~Animation(); - -private: - void setValue(Color_Type, Property, const std::string &, Color); - void setValue(Float_Type, Property, const std::string &, float); - void setValue(Size_Type, Property, const std::string &, Size); - void setValue(Point_Type, Property, const std::string &, Point); - - void setValue(Color_Type, Property, const std::string &, std::function &&); - void setValue(Float_Type, Property, const std::string &, std::function &&); - void setValue(Size_Type, Property, const std::string &, std::function &&); - void setValue(Point_Type, Property, const std::string &, std::function &&); - /** - * @brief default constructor - * - * @internal - */ - Animation(); - - std::unique_ptr d; -}; - -//Map Property to Value type -template<> struct MapType>: Color_Type{}; -template<> struct MapType>: Color_Type{}; -template<> struct MapType>: Float_Type{}; -template<> struct MapType>: Float_Type{}; -template<> struct MapType>: Float_Type{}; -template<> struct MapType>: Float_Type{}; -template<> struct MapType>: Float_Type{}; -template<> struct MapType>: Point_Type{}; -template<> struct MapType>: Point_Type{}; -template<> struct MapType>: Size_Type{}; - - -} // namespace lotplayer - -#endif // _RLOTTIE_H_ diff --git a/example/rlottiePlayer/rlottiePlayer.cpp b/example/rlottiePlayer/rlottiePlayer.cpp index db2c9bf..ed6a200 100644 --- a/example/rlottiePlayer/rlottiePlayer.cpp +++ b/example/rlottiePlayer/rlottiePlayer.cpp @@ -9,7 +9,7 @@ using namespace Gdiplus; #define MAX_LOADSTRING 100 // Global Variables: -HINSTANCE hInst; // current instance +HINSTANCE hInst; // current instance WCHAR szTitle[MAX_LOADSTRING]; // The title bar text WCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name HWND mainWindow; // Main Window Instance @@ -270,6 +270,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } case WM_DESTROY: + freeAnimation(); PostQuitMessage(0); break; diff --git a/example/rlottiePlayer/rlottiePlayer.h b/example/rlottiePlayer/rlottiePlayer.h index 4200862..404d97b 100644 --- a/example/rlottiePlayer/rlottiePlayer.h +++ b/example/rlottiePlayer/rlottiePlayer.h @@ -1,10 +1,10 @@ #pragma once #include "resource.h" -#include // OPENFILENAME -#include "atlconv.h" // String cast. ex) LPWSTR <-> LPSTR +#include // OPENFILENAME +#include "atlconv.h" // String cast. (ex. LPWSTR <-> LPSTR) #include -#include // slider handle +#include // slider handle #include // interval @@ -28,6 +28,7 @@ uint32_t* renderRLottieAnimation(uint32_t frameNum); size_t getTotalFrame(); bool isAnimNULL(); void setAnimationColor(int r, int g, int b); +void freeAnimation(); typedef struct RlottieBitmap { diff --git a/example/rlottiePlayer/rlottiePlayer.vcxproj b/example/rlottiePlayer/rlottiePlayer.vcxproj index 1e6eeb2..700b030 100644 --- a/example/rlottiePlayer/rlottiePlayer.vcxproj +++ b/example/rlottiePlayer/rlottiePlayer.vcxproj @@ -78,6 +78,7 @@ true + ..\..\inc;$(IncludePath) false diff --git a/example/rlottiePlayer/rlottiePlayer.vcxproj.user b/example/rlottiePlayer/rlottiePlayer.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/example/rlottiePlayer/rlottiePlayer.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/example/rlottiePlayer/rlottie_capi.h b/example/rlottiePlayer/rlottie_capi.h deleted file mode 100644 index 9bdf336..0000000 --- a/example/rlottiePlayer/rlottie_capi.h +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. - - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _RLOTTIE_CAPI_H_ -#define _RLOTTIE_CAPI_H_ - -#include -#include -#include - -#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 - */ -RLOTTIE_API 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 - */ -RLOTTIE_API 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 - */ -RLOTTIE_API 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 - */ -RLOTTIE_API 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 - */ -RLOTTIE_API 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 - */ -RLOTTIE_API 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 - * - */ -RLOTTIE_API 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 - */ -RLOTTIE_API 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 - */ -RLOTTIE_API 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 - */ -RLOTTIE_API 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 - */ -RLOTTIE_API 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 - */ -RLOTTIE_API 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 - * */ -RLOTTIE_API 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 - * */ -RLOTTIE_API const LOTMarkerList* lottie_animation_get_markerlist(Lottie_Animation *animation); - -#ifdef __cplusplus -} -#endif - -#endif //_RLOTTIE_CAPI_H_ - diff --git a/example/rlottiePlayer/rlottiecommon.h b/example/rlottiePlayer/rlottiecommon.h deleted file mode 100644 index 784fbe2..0000000 --- a/example/rlottiePlayer/rlottiecommon.h +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. - - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _RLOTTIE_COMMON_H_ -#define _RLOTTIE_COMMON_H_ - -#if defined _WIN32 || defined __CYGWIN__ - #ifdef RLOTTIE_BUILD - #define RLOTTIE_API __declspec(dllexport) - #else - #define RLOTTIE_API __declspec(dllimport) - #endif -#else - #ifdef RLOTTIE_BUILD - #define RLOTTIE_API __attribute__ ((visibility ("default"))) - #else - #define RLOTTIE_API - #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 - */ - -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 -{ - MaskAdd = 0, - MaskSubstract, - MaskIntersect, - MaskDifference -} LOTMaskType; - -typedef struct LOTMask { - struct { - const float *ptPtr; - size_t ptCount; - const char* elmPtr; - size_t elmCount; - } mPath; - LOTMaskType mMode; - unsigned char mAlpha; -}LOTMask; - -typedef enum -{ - MatteNone = 0, - MatteAlpha, - MatteAlphaInv, - MatteLuma, - MatteLumaInv -} LOTMatteType; - -typedef struct LOTMarker { - char *name; - size_t startframe; - size_t endframe; -} LOTMarker; - -typedef struct LOTMarkerList { - LOTMarker *ptr; - size_t size; -} LOTMarkerList; - -typedef struct LOTNode { - -#define ChangeFlagNone 0x0000 -#define ChangeFlagPath 0x0001 -#define ChangeFlagPaint 0x0010 -#define ChangeFlagAll (ChangeFlagPath & ChangeFlagPaint) - - struct { - const float *ptPtr; - size_t ptCount; - const char *elmPtr; - size_t elmCount; - } mPath; - - struct { - unsigned char r, g, b, a; - } mColor; - - struct { - unsigned char enable; - float width; - LOTCapStyle cap; - LOTJoinStyle join; - float miterLimit; - float *dashArray; - int dashArraySize; - } mStroke; - - struct { - LOTGradientType type; - LOTGradientStop *stopPtr; - size_t stopCount; - struct { - float x, y; - } start, end, center, focal; - float cradius; - float fradius; - } mGradient; - - struct { - unsigned char *data; - size_t width; - size_t height; - unsigned char mAlpha; - struct { - float m11; float m12; float m13; - float m21; float m22; float m23; - float m31; float m32; float m33; - } mMatrix; - } mImageInfo; - - int mFlag; - LOTBrushType mBrushType; - LOTFillRule mFillRule; - - const char *keypath; -} LOTNode; - - - -typedef struct LOTLayerNode { - - struct { - LOTMask *ptr; - size_t size; - } mMaskList; - - struct { - const float *ptPtr; - size_t ptCount; - const char *elmPtr; - size_t elmCount; - } mClipPath; - - struct { - struct LOTLayerNode **ptr; - size_t size; - } mLayerList; - - struct { - LOTNode **ptr; - size_t size; - } mNodeList; - - LOTMatteType mMatte; - int mVisible; - unsigned char mAlpha; - const char *keypath; - -} LOTLayerNode; - -/** - * @} - */ - -#endif // _RLOTTIE_COMMON_H_