From: Hermet Park Date: Fri, 17 Aug 2018 09:41:34 +0000 (+0900) Subject: refactor infrastructure. X-Git-Tag: submit/tizen/20180917.042405~94 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d49fb641e0fda579f6aee2f6d63e1c268c83f00a;p=platform%2Fcore%2Fuifw%2Flottie-player.git refactor infrastructure. Split common delcaration from lottieplayer.h This common delcaration will be used in c interface header files. Change-Id: Icb3e3f182b2f27fc2d7c9bed36ac29c45c813b66 --- diff --git a/example/lottieview.cpp b/example/lottieview.cpp index 4ec334d..c9b68d6 100644 --- a/example/lottieview.cpp +++ b/example/lottieview.cpp @@ -1,5 +1,4 @@ #include"lottieview.h" -#include"lottieplayer.h" using namespace lotplayer; diff --git a/example/lottieview.h b/example/lottieview.h index d63d117..32122ac 100644 --- a/example/lottieview.h +++ b/example/lottieview.h @@ -14,7 +14,7 @@ #include #include #include -#include"lottieplayer.h" +#include"lotplayer.h" #include class LottieView { diff --git a/inc/lotcommon.h b/inc/lotcommon.h new file mode 100644 index 0000000..b8efeb6 --- /dev/null +++ b/inc/lotcommon.h @@ -0,0 +1,86 @@ +#ifndef _LOTCOMMON_H_ +#define _LOTCOMMON_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 + +struct LOTNode { + +#define ChangeFlagNone 0x0000 +#define ChangeFlagPath 0x0001 +#define ChangeFlagPaint 0x0010 +#define ChangeFlagAll (ChangeFlagPath & ChangeFlagPaint) + + enum BrushType { BrushSolid, BrushGradient }; + enum FillRule { EvenOdd, Winding }; + enum JoinStyle { MiterJoin, BevelJoin, RoundJoin }; + enum CapStyle { FlatCap, SquareCap, RoundCap }; + + struct PathData { + const float *ptPtr; + int ptCount; + const char* elmPtr; + int elmCount; + }; + + struct Color { + unsigned char r, g, b, a; + }; + + struct Stroke { + bool enable; + int width; + CapStyle cap; + JoinStyle join; + int meterLimit; + float* dashArray; + int dashArraySize; + }; + + struct Gradient { + enum Type { Linear = 1, Radial = 2 }; + Gradient::Type type; + struct { + float x, y; + } start, end, center, focal; + float cradius; + float fradius; + }; + + int mFlag; + BrushType mType; + FillRule mFillRule; + PathData mPath; + Color mColor; + Stroke mStroke; + Gradient mGradient; +}; + +struct LOTBuffer { + uint32_t *buffer; + int width; + int height; + int bytesPerLine; + bool clear; +}; + +#endif // _LOTCOMMON_H_ diff --git a/inc/lotplayer.h b/inc/lotplayer.h new file mode 100644 index 0000000..75ccaa4 --- /dev/null +++ b/inc/lotplayer.h @@ -0,0 +1,41 @@ +#ifndef _LOTPLAYER_H_ +#define _LOTPLAYER_H_ + +#include +#include + +#include "lotcommon.h" + +//TODO: Hide this. +class LOTPlayerPrivate; +#define _LOTPLAYER_DECLARE_PRIVATE(A) \ + class A##Private *d; + +namespace lotplayer { + +class LOT_EXPORT LOTPlayer { +public: + ~LOTPlayer(); + LOTPlayer(); + + bool setFilePath(const char *filePath); + + float playTime() const; + + float pos(); + + const std::vector &renderList(float pos) const; + + // TODO: Consider correct position... + void setSize(int width, int height); + void size(int &width, int &height) const; + std::future render(float pos, LOTBuffer buffer, bool forceRender = false); + bool renderSync(float pos, LOTBuffer buffer, bool forceRender = false); + +private: + _LOTPLAYER_DECLARE_PRIVATE(LOTPlayer); +}; + +} // namespace lotplayer + +#endif // _LOTPLAYER_H_ diff --git a/inc/lottieplayer.h b/inc/lottieplayer.h deleted file mode 100644 index 3dbbbc6..0000000 --- a/inc/lottieplayer.h +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef _LOTPLAYER_H_ -#define _LOTPLAYER_H_ - -#include -#include - -#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 - -//TODO: Hide this. -class LOTPlayerPrivate; -#define _LOTPLAYER_DECLARE_PRIVATE(A) \ - class A##Private *d; - -struct LOTNode { - -#define ChangeFlagNone 0x0000 -#define ChangeFlagPath 0x0001 -#define ChangeFlagPaint 0x0010 -#define ChangeFlagAll (ChangeFlagPath & ChangeFlagPaint) - - enum BrushType { BrushSolid, BrushGradient }; - enum FillRule { EvenOdd, Winding }; - enum JoinStyle { MiterJoin, BevelJoin, RoundJoin }; - enum CapStyle { FlatCap, SquareCap, RoundCap }; - - struct PathData { - const float *ptPtr; - int ptCount; - const char* elmPtr; - int elmCount; - }; - - struct Color { - unsigned char r, g, b, a; - }; - - struct Stroke { - bool enable; - int width; - CapStyle cap; - JoinStyle join; - int meterLimit; - float* dashArray; - int dashArraySize; - }; - - struct Gradient { - enum Type { Linear = 1, Radial = 2 }; - Gradient::Type type; - struct { - float x, y; - } start, end, center, focal; - float cradius; - float fradius; - }; - - int mFlag; - BrushType mType; - FillRule mFillRule; - PathData mPath; - Color mColor; - Stroke mStroke; - Gradient mGradient; -}; - -struct LOTBuffer { - uint32_t *buffer = nullptr; - int width = 0; - int height = 0; - int bytesPerLine = 0; - bool clear = true; -}; - -namespace lotplayer { - -class LOT_EXPORT LOTPlayer { -public: - ~LOTPlayer(); - LOTPlayer(); - - bool setFilePath(const char *filePath); - - float playTime() const; - - float pos(); - - const std::vector &renderList(float pos) const; - - // TODO: Consider correct position... - void setSize(int width, int height); - void size(int &width, int &height) const; - std::future render(float pos, LOTBuffer buffer, bool forceRender = false); - bool renderSync(float pos, LOTBuffer buffer, bool forceRender = false); - -private: - _LOTPLAYER_DECLARE_PRIVATE(LOTPlayer); -}; - -} // namespace lotplayer - -#endif // _LOTPLAYER_H_ diff --git a/inc/meson.build b/inc/meson.build index 0b4bb41..aa65f1f 100644 --- a/inc/meson.build +++ b/inc/meson.build @@ -1 +1 @@ -install_headers(['lottieplayer.h']) +install_headers(['lotplayer.h', 'lotcommon.h']) diff --git a/src/lottie/lottieitem.h b/src/lottie/lottieitem.h index a29875f..2cf17b4 100644 --- a/src/lottie/lottieitem.h +++ b/src/lottie/lottieitem.h @@ -9,7 +9,7 @@ #include"vpath.h" #include"vpoint.h" #include"vpathmesure.h" -#include"lottieplayer.h" +#include"lotcommon.h" #include"vpainter.h" #include"vdrawable.h" diff --git a/src/lottie/lottieplayer.cpp b/src/lottie/lottieplayer.cpp index 28a6123..825d84f 100644 --- a/src/lottie/lottieplayer.cpp +++ b/src/lottie/lottieplayer.cpp @@ -1,4 +1,4 @@ -#include +#include #include "lottieitem.h" #include "lottieloader.h"