From d49fb641e0fda579f6aee2f6d63e1c268c83f00a Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 17 Aug 2018 18:41:34 +0900 Subject: [PATCH] refactor infrastructure. Split common delcaration from lottieplayer.h This common delcaration will be used in c interface header files. Change-Id: Icb3e3f182b2f27fc2d7c9bed36ac29c45c813b66 --- example/lottieview.cpp | 1 - example/lottieview.h | 2 +- inc/{lottieplayer.h => lotcommon.h} | 51 +++++------------------------ inc/lotplayer.h | 41 +++++++++++++++++++++++ inc/meson.build | 2 +- src/lottie/lottieitem.h | 2 +- src/lottie/lottieplayer.cpp | 2 +- 7 files changed, 53 insertions(+), 48 deletions(-) rename inc/{lottieplayer.h => lotcommon.h} (60%) create mode 100644 inc/lotplayer.h 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/lottieplayer.h b/inc/lotcommon.h similarity index 60% rename from inc/lottieplayer.h rename to inc/lotcommon.h index 3dbbbc6..b8efeb6 100644 --- a/inc/lottieplayer.h +++ b/inc/lotcommon.h @@ -1,8 +1,5 @@ -#ifndef _LOTPLAYER_H_ -#define _LOTPLAYER_H_ - -#include -#include +#ifndef _LOTCOMMON_H_ +#define _LOTCOMMON_H_ #ifdef _WIN32 #ifdef LOT_BUILD @@ -26,11 +23,6 @@ #endif #endif -//TODO: Hide this. -class LOTPlayerPrivate; -#define _LOTPLAYER_DECLARE_PRIVATE(A) \ - class A##Private *d; - struct LOTNode { #define ChangeFlagNone 0x0000 @@ -84,38 +76,11 @@ struct LOTNode { }; 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); + uint32_t *buffer; + int width; + int height; + int bytesPerLine; + bool clear; }; -} // namespace lotplayer - -#endif // _LOTPLAYER_H_ +#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/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" -- 2.34.1