add rlottiePlayer Project
[platform/core/uifw/lottie-player.git] / example / rlottiePlayer / rlottiecommon.h
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
3
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10
11  * The above copyright notice and this permission notice shall be included in all
12  * copies or substantial portions of the Software.
13
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22
23 #ifndef _RLOTTIE_COMMON_H_
24 #define _RLOTTIE_COMMON_H_
25
26 #if defined _WIN32 || defined __CYGWIN__
27   #ifdef RLOTTIE_BUILD
28     #define RLOTTIE_API __declspec(dllexport)
29   #else
30     #define RLOTTIE_API __declspec(dllimport)
31   #endif
32 #else
33   #ifdef RLOTTIE_BUILD
34       #define RLOTTIE_API __attribute__ ((visibility ("default")))
35   #else
36       #define RLOTTIE_API
37   #endif
38 #endif
39
40
41 /**
42  * @defgroup Lottie_Animation Lottie_Animation
43  *
44  * Lottie Animation is a modern style vector based animation design. Its animation
45  * resource(within json format) could be generated by Adobe After Effect using
46  * bodymovin plugin. You can find a good examples in Lottie Community which
47  * shares many free resources(see: www.lottiefiles.com).
48  *
49  * This Lottie_Animation is a common engine to manipulate, control Lottie
50  * Animation from the Lottie resource - json file. It provides a scene-graph
51  * node tree per frames by user demand as well as rasterized frame images.
52  *
53  */
54
55 /**
56  * @ingroup Lottie_Animation
57  */
58
59 typedef enum
60 {
61     BrushSolid = 0,
62     BrushGradient
63 } LOTBrushType;
64
65 typedef enum
66 {
67     FillEvenOdd = 0,
68     FillWinding
69 } LOTFillRule;
70
71 typedef enum
72 {
73     JoinMiter = 0,
74     JoinBevel,
75     JoinRound
76 } LOTJoinStyle;
77
78 typedef enum
79 {
80     CapFlat = 0,
81     CapSquare,
82     CapRound
83 } LOTCapStyle;
84
85 typedef enum
86 {
87     GradientLinear = 0,
88     GradientRadial
89 } LOTGradientType;
90
91 typedef struct LOTGradientStop
92 {
93     float         pos;
94     unsigned char r, g, b, a;
95 } LOTGradientStop;
96
97 typedef enum
98 {
99     MaskAdd = 0,
100     MaskSubstract,
101     MaskIntersect,
102     MaskDifference
103 } LOTMaskType;
104
105 typedef struct LOTMask {
106     struct {
107         const float *ptPtr;
108         size_t       ptCount;
109         const char*  elmPtr;
110         size_t       elmCount;
111     } mPath;
112     LOTMaskType mMode;
113     unsigned char mAlpha;
114 }LOTMask;
115
116 typedef enum
117 {
118     MatteNone = 0,
119     MatteAlpha,
120     MatteAlphaInv,
121     MatteLuma,
122     MatteLumaInv
123 } LOTMatteType;
124
125 typedef struct LOTMarker {
126    char *name;
127    size_t startframe;
128    size_t endframe;
129 } LOTMarker;
130
131 typedef struct LOTMarkerList {
132    LOTMarker *ptr;
133    size_t size;
134 } LOTMarkerList;
135
136 typedef struct LOTNode {
137
138 #define ChangeFlagNone 0x0000
139 #define ChangeFlagPath 0x0001
140 #define ChangeFlagPaint 0x0010
141 #define ChangeFlagAll (ChangeFlagPath & ChangeFlagPaint)
142
143     struct {
144         const float *ptPtr;
145         size_t       ptCount;
146         const char  *elmPtr;
147         size_t       elmCount;
148     } mPath;
149
150     struct {
151         unsigned char r, g, b, a;
152     } mColor;
153
154     struct {
155         unsigned char  enable;
156         float       width;
157         LOTCapStyle  cap;
158         LOTJoinStyle join;
159         float       miterLimit;
160         float    *dashArray;
161         int       dashArraySize;
162     } mStroke;
163
164     struct {
165         LOTGradientType  type;
166         LOTGradientStop *stopPtr;
167         size_t           stopCount;
168         struct {
169             float x, y;
170         } start, end, center, focal;
171         float cradius;
172         float fradius;
173     } mGradient;
174
175     struct {
176         unsigned char *data;
177         size_t width;
178         size_t height;
179         unsigned char mAlpha;
180         struct {
181            float m11; float m12; float m13;
182            float m21; float m22; float m23;
183            float m31; float m32; float m33;
184         } mMatrix;
185     } mImageInfo;
186
187     int       mFlag;
188     LOTBrushType mBrushType;
189     LOTFillRule  mFillRule;
190
191     const char  *keypath;
192 } LOTNode;
193
194
195
196 typedef struct LOTLayerNode {
197
198     struct {
199         LOTMask        *ptr;
200         size_t          size;
201     } mMaskList;
202
203     struct {
204         const float *ptPtr;
205         size_t       ptCount;
206         const char  *elmPtr;
207         size_t       elmCount;
208     } mClipPath;
209
210     struct {
211         struct LOTLayerNode   **ptr;
212         size_t                  size;
213     } mLayerList;
214
215     struct {
216         LOTNode        **ptr;
217         size_t           size;
218     } mNodeList;
219
220     LOTMatteType mMatte;
221     int          mVisible;
222     unsigned char mAlpha;
223     const char  *keypath;
224
225 } LOTLayerNode;
226
227 /**
228  * @}
229  */
230
231 #endif  // _RLOTTIE_COMMON_H_