From ddde576886168e542b7c61901a5933a3d3aed952 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 17 Aug 2018 17:19:08 +0900 Subject: [PATCH] lotplayer: improve header format. 1. add namespace. 2. remove unnecessary export attribute. 3. hide prviate member. This is one ongoing improvement. Change-Id: I342e4d5e65370190ac55972b02f2fede1aee6d06 --- example/lottieview.cpp | 2 ++ example/lottieview.h | 3 +- inc/lottieplayer.h | 78 ++++++++++++++++++++++++--------------------- src/lottie/lottieplayer.cpp | 2 ++ 4 files changed, 47 insertions(+), 38 deletions(-) diff --git a/example/lottieview.cpp b/example/lottieview.cpp index 5b30fd9..4ec334d 100644 --- a/example/lottieview.cpp +++ b/example/lottieview.cpp @@ -1,6 +1,8 @@ #include"lottieview.h" #include"lottieplayer.h" +using namespace lotplayer; + static Eina_Bool animator(void *data , double pos) { diff --git a/example/lottieview.h b/example/lottieview.h index 681fb8b..44543ab 100644 --- a/example/lottieview.h +++ b/example/lottieview.h @@ -16,7 +16,6 @@ #include #include"lottieplayer.h" #include -class LOTPlayer; class LottieView { public: @@ -54,7 +53,7 @@ public: Evas_Object *mVg; int mRepeatCount; LottieView::RepeatMode mRepeatMode; - LOTPlayer *mPlayer; + lotplayer::LOTPlayer *mPlayer; Ecore_Animator *mAnimator{nullptr}; bool mLoop; int mCurCount; diff --git a/inc/lottieplayer.h b/inc/lottieplayer.h index ee981ae..3dbbbc6 100644 --- a/inc/lottieplayer.h +++ b/inc/lottieplayer.h @@ -1,5 +1,5 @@ -#ifndef LOTPLAYER_H -#define LOTPLAYER_H +#ifndef _LOTPLAYER_H_ +#define _LOTPLAYER_H_ #include #include @@ -26,47 +26,18 @@ #endif #endif +//TODO: Hide this. class LOTPlayerPrivate; -class LOTNode; +#define _LOTPLAYER_DECLARE_PRIVATE(A) \ + class A##Private *d; -struct LOT_EXPORT LOTBuffer { - uint32_t *buffer = nullptr; - int width = 0; - int height = 0; - int bytesPerLine = 0; - bool clear = true; -}; - -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); - -public: - LOTPlayerPrivate *d; -}; +struct LOTNode { #define ChangeFlagNone 0x0000 #define ChangeFlagPath 0x0001 #define ChangeFlagPaint 0x0010 #define ChangeFlagAll (ChangeFlagPath & ChangeFlagPaint) -struct LOTNode { - enum BrushType { BrushSolid, BrushGradient }; enum FillRule { EvenOdd, Winding }; enum JoinStyle { MiterJoin, BevelJoin, RoundJoin }; @@ -112,4 +83,39 @@ struct LOTNode { Gradient mGradient; }; -#endif // LOTPLAYER_H +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/src/lottie/lottieplayer.cpp b/src/lottie/lottieplayer.cpp index 39f30b2..ecb2c88 100644 --- a/src/lottie/lottieplayer.cpp +++ b/src/lottie/lottieplayer.cpp @@ -6,6 +6,8 @@ #include +using namespace lotplayer; + class LOTPlayerPrivate { public: -- 2.7.4