lotplayer: improve header format.
[platform/core/uifw/lottie-player.git] / inc / lottieplayer.h
1 #ifndef _LOTPLAYER_H_
2 #define _LOTPLAYER_H_
3
4 #include <future>
5 #include <vector>
6
7 #ifdef _WIN32
8 #ifdef LOT_BUILD
9 #ifdef DLL_EXPORT
10 #define LOT_EXPORT __declspec(dllexport)
11 #else
12 #define LOT_EXPORT
13 #endif
14 #else
15 #define LOT_EXPORT __declspec(dllimport)
16 #endif
17 #else
18 #ifdef __GNUC__
19 #if __GNUC__ >= 4
20 #define LOT_EXPORT __attribute__((visibility("default")))
21 #else
22 #define LOT_EXPORT
23 #endif
24 #else
25 #define LOT_EXPORT
26 #endif
27 #endif
28
29 //TODO: Hide this.
30 class LOTPlayerPrivate;
31 #define _LOTPLAYER_DECLARE_PRIVATE(A) \
32    class A##Private *d;
33
34 struct LOTNode {
35
36 #define ChangeFlagNone 0x0000
37 #define ChangeFlagPath 0x0001
38 #define ChangeFlagPaint 0x0010
39 #define ChangeFlagAll (ChangeFlagPath & ChangeFlagPaint)
40
41     enum BrushType { BrushSolid, BrushGradient };
42     enum FillRule { EvenOdd, Winding };
43     enum JoinStyle { MiterJoin, BevelJoin, RoundJoin };
44     enum CapStyle { FlatCap, SquareCap, RoundCap };
45
46     struct PathData {
47         const float *ptPtr;
48         int          ptCount;
49         const char*  elmPtr;
50         int          elmCount;
51     };
52
53     struct Color {
54         unsigned char r, g, b, a;
55     };
56
57     struct Stroke {
58         bool      enable;
59         int       width;
60         CapStyle  cap;
61         JoinStyle join;
62         int       meterLimit;
63         float*    dashArray;
64         int       dashArraySize;
65     };
66
67     struct Gradient {
68         enum Type { Linear = 1, Radial = 2 };
69         Gradient::Type type;
70         struct {
71             float x, y;
72         } start, end, center, focal;
73         float cradius;
74         float fradius;
75     };
76
77     int       mFlag;
78     BrushType mType;
79     FillRule  mFillRule;
80     PathData  mPath;
81     Color     mColor;
82     Stroke    mStroke;
83     Gradient  mGradient;
84 };
85
86 struct LOTBuffer {
87     uint32_t *buffer = nullptr;
88     int       width = 0;
89     int       height = 0;
90     int       bytesPerLine = 0;
91     bool      clear = true;
92 };
93
94 namespace lotplayer {
95
96 class LOT_EXPORT LOTPlayer {
97 public:
98     ~LOTPlayer();
99     LOTPlayer();
100
101     bool setFilePath(const char *filePath);
102
103     float playTime() const;
104
105     float pos();
106
107     const std::vector<LOTNode *> &renderList(float pos) const;
108
109     // TODO: Consider correct position...
110     void              setSize(int width, int height);
111     void              size(int &width, int &height) const;
112     std::future<bool> render(float pos, LOTBuffer buffer, bool forceRender = false);
113     bool              renderSync(float pos, LOTBuffer buffer, bool forceRender = false);
114
115 private:
116     _LOTPLAYER_DECLARE_PRIVATE(LOTPlayer);
117 };
118
119 }  // namespace lotplayer
120
121 #endif  // _LOTPLAYER_H_