rlottiecommon.h 5.1 KB

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