@shopify/react-native-skia 2.0.7 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/android/CMakeLists.txt +20 -1
  2. package/cpp/api/JsiSkApi.h +3 -0
  3. package/cpp/api/JsiSkImageFilterFactory.h +478 -39
  4. package/cpp/api/JsiSkSkottie.h +590 -0
  5. package/cpp/api/JsiSkottieFactory.h +65 -0
  6. package/cpp/api/recorder/Command.h +1 -0
  7. package/cpp/api/recorder/Convertor.h +32 -0
  8. package/cpp/api/recorder/Drawings.h +23 -0
  9. package/cpp/api/recorder/ImageFilters.h +20 -0
  10. package/cpp/api/recorder/JsiRecorder.h +6 -0
  11. package/cpp/api/recorder/RNRecorder.h +15 -0
  12. package/cpp/api/third_party/SkottieUtils.cpp +333 -0
  13. package/cpp/api/third_party/SkottieUtils.h +172 -0
  14. package/cpp/skia/modules/jsonreader/SkJSONReader.cpp +980 -0
  15. package/cpp/skia/modules/jsonreader/SkJSONReader.h +389 -0
  16. package/cpp/skia/modules/skottie/include/ExternalLayer.h +56 -0
  17. package/cpp/skia/modules/skottie/include/Skottie.h +313 -0
  18. package/cpp/skia/modules/skottie/include/SkottieProperty.h +190 -0
  19. package/cpp/skia/modules/skottie/include/SlotManager.h +113 -0
  20. package/cpp/skia/modules/skottie/include/TextShaper.h +200 -0
  21. package/cpp/skia/modules/skottie/src/SkottieValue.h +56 -0
  22. package/cpp/skia/modules/skottie/src/animator/Animator.h +89 -0
  23. package/cpp/skia/modules/skottie/src/text/Font.h +82 -0
  24. package/cpp/skia/modules/skottie/src/text/TextAdapter.h +155 -0
  25. package/cpp/skia/modules/skottie/src/text/TextAnimator.h +121 -0
  26. package/cpp/skia/modules/skottie/src/text/TextValue.h +28 -0
  27. package/cpp/skia/modules/sksg/include/SkSGClipEffect.h +61 -0
  28. package/cpp/skia/modules/sksg/include/SkSGColorFilter.h +135 -0
  29. package/cpp/skia/modules/sksg/include/SkSGDraw.h +57 -0
  30. package/cpp/skia/modules/sksg/include/SkSGEffectNode.h +50 -0
  31. package/cpp/skia/modules/sksg/include/SkSGGeometryEffect.h +181 -0
  32. package/cpp/skia/modules/sksg/include/SkSGGeometryNode.h +54 -0
  33. package/cpp/skia/modules/sksg/include/SkSGGradient.h +108 -0
  34. package/cpp/skia/modules/sksg/include/SkSGGroup.h +65 -0
  35. package/cpp/skia/modules/sksg/include/SkSGImage.h +59 -0
  36. package/cpp/skia/modules/sksg/include/SkSGInvalidationController.h +46 -0
  37. package/cpp/skia/modules/sksg/include/SkSGMaskEffect.h +65 -0
  38. package/cpp/skia/modules/sksg/include/SkSGMerge.h +74 -0
  39. package/cpp/skia/modules/sksg/include/SkSGNode.h +128 -0
  40. package/cpp/skia/modules/sksg/include/SkSGOpacityEffect.h +54 -0
  41. package/cpp/skia/modules/sksg/include/SkSGPaint.h +112 -0
  42. package/cpp/skia/modules/sksg/include/SkSGPath.h +68 -0
  43. package/cpp/skia/modules/sksg/include/SkSGPlane.h +47 -0
  44. package/cpp/skia/modules/sksg/include/SkSGRect.h +122 -0
  45. package/cpp/skia/modules/sksg/include/SkSGRenderEffect.h +283 -0
  46. package/cpp/skia/modules/sksg/include/SkSGRenderNode.h +157 -0
  47. package/cpp/skia/modules/sksg/include/SkSGScene.h +47 -0
  48. package/cpp/skia/modules/sksg/include/SkSGText.h +82 -0
  49. package/cpp/skia/modules/sksg/include/SkSGTransform.h +127 -0
  50. package/cpp/skia/src/base/SkArenaAlloc.h +371 -0
  51. package/lib/commonjs/dom/nodes/datatypes/Gradient.d.ts +15 -15
  52. package/lib/commonjs/dom/types/Drawings.d.ts +8 -1
  53. package/lib/commonjs/dom/types/Drawings.js.map +1 -1
  54. package/lib/commonjs/dom/types/NodeType.d.ts +3 -1
  55. package/lib/commonjs/dom/types/NodeType.js +4 -0
  56. package/lib/commonjs/dom/types/NodeType.js.map +1 -1
  57. package/lib/commonjs/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
  58. package/lib/commonjs/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
  59. package/lib/commonjs/renderer/__tests__/e2e/ImageFilter.spec.d.ts +1 -0
  60. package/lib/commonjs/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
  61. package/lib/commonjs/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
  62. package/lib/commonjs/renderer/__tests__/setup.d.ts +5 -0
  63. package/lib/commonjs/renderer/components/ImageFilter.d.ts +4 -0
  64. package/lib/commonjs/renderer/components/ImageFilter.js +13 -0
  65. package/lib/commonjs/renderer/components/ImageFilter.js.map +1 -0
  66. package/lib/commonjs/renderer/components/Skottie.d.ts +4 -0
  67. package/lib/commonjs/renderer/components/Skottie.js +13 -0
  68. package/lib/commonjs/renderer/components/Skottie.js.map +1 -0
  69. package/lib/commonjs/renderer/components/index.d.ts +2 -0
  70. package/lib/commonjs/renderer/components/index.js +22 -0
  71. package/lib/commonjs/renderer/components/index.js.map +1 -1
  72. package/lib/commonjs/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
  73. package/lib/commonjs/skia/types/ImageFilter/ImageFilterFactory.js.map +1 -1
  74. package/lib/commonjs/skia/types/Matrix4.d.ts +11 -2
  75. package/lib/commonjs/skia/types/Matrix4.js +42 -1
  76. package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
  77. package/lib/commonjs/skia/types/Recorder.d.ts +2 -1
  78. package/lib/commonjs/skia/types/Recorder.js.map +1 -1
  79. package/lib/commonjs/skia/types/Skia.d.ts +2 -0
  80. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  81. package/lib/commonjs/skia/types/Skottie.d.ts +223 -0
  82. package/lib/commonjs/skia/types/Skottie.js +73 -0
  83. package/lib/commonjs/skia/types/Skottie.js.map +1 -0
  84. package/lib/commonjs/skia/types/index.d.ts +1 -0
  85. package/lib/commonjs/skia/types/index.js +11 -0
  86. package/lib/commonjs/skia/types/index.js.map +1 -1
  87. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
  88. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +88 -19
  89. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  90. package/lib/commonjs/skia/web/JsiSkia.js +2 -0
  91. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  92. package/lib/commonjs/skia/web/JsiSkottieAnimation.d.ts +59 -0
  93. package/lib/commonjs/skia/web/JsiSkottieAnimation.js +243 -0
  94. package/lib/commonjs/skia/web/JsiSkottieAnimation.js.map +1 -0
  95. package/lib/commonjs/skia/web/JsiSkottieFactory.d.ts +9 -0
  96. package/lib/commonjs/skia/web/JsiSkottieFactory.js +26 -0
  97. package/lib/commonjs/skia/web/JsiSkottieFactory.js.map +1 -0
  98. package/lib/commonjs/sksg/Elements.d.ts +3 -1
  99. package/lib/commonjs/sksg/Elements.js.map +1 -1
  100. package/lib/commonjs/sksg/Node.d.ts +1 -1
  101. package/lib/commonjs/sksg/Node.js +1 -1
  102. package/lib/commonjs/sksg/Node.js.map +1 -1
  103. package/lib/commonjs/sksg/Recorder/Core.d.ts +4 -2
  104. package/lib/commonjs/sksg/Recorder/Core.js +1 -0
  105. package/lib/commonjs/sksg/Recorder/Core.js.map +1 -1
  106. package/lib/commonjs/sksg/Recorder/Player.js +2 -0
  107. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  108. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
  109. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +4 -0
  110. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  111. package/lib/commonjs/sksg/Recorder/Recorder.d.ts +2 -1
  112. package/lib/commonjs/sksg/Recorder/Recorder.js +6 -0
  113. package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
  114. package/lib/commonjs/sksg/Recorder/Visitor.js +3 -0
  115. package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
  116. package/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +2 -2
  117. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +11 -4
  118. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  119. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js +12 -2
  120. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
  121. package/lib/module/dom/nodes/datatypes/Gradient.d.ts +15 -15
  122. package/lib/module/dom/types/Drawings.d.ts +8 -1
  123. package/lib/module/dom/types/Drawings.js.map +1 -1
  124. package/lib/module/dom/types/NodeType.d.ts +3 -1
  125. package/lib/module/dom/types/NodeType.js +4 -0
  126. package/lib/module/dom/types/NodeType.js.map +1 -1
  127. package/lib/module/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
  128. package/lib/module/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
  129. package/lib/module/renderer/__tests__/e2e/ImageFilter.spec.d.ts +1 -0
  130. package/lib/module/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
  131. package/lib/module/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
  132. package/lib/module/renderer/__tests__/setup.d.ts +5 -0
  133. package/lib/module/renderer/components/ImageFilter.d.ts +4 -0
  134. package/lib/module/renderer/components/ImageFilter.js +5 -0
  135. package/lib/module/renderer/components/ImageFilter.js.map +1 -0
  136. package/lib/module/renderer/components/Skottie.d.ts +4 -0
  137. package/lib/module/renderer/components/Skottie.js +5 -0
  138. package/lib/module/renderer/components/Skottie.js.map +1 -0
  139. package/lib/module/renderer/components/index.d.ts +2 -0
  140. package/lib/module/renderer/components/index.js +2 -0
  141. package/lib/module/renderer/components/index.js.map +1 -1
  142. package/lib/module/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
  143. package/lib/module/skia/types/ImageFilter/ImageFilterFactory.js.map +1 -1
  144. package/lib/module/skia/types/Matrix4.d.ts +11 -2
  145. package/lib/module/skia/types/Matrix4.js +40 -0
  146. package/lib/module/skia/types/Matrix4.js.map +1 -1
  147. package/lib/module/skia/types/Recorder.d.ts +2 -1
  148. package/lib/module/skia/types/Recorder.js.map +1 -1
  149. package/lib/module/skia/types/Skia.d.ts +2 -0
  150. package/lib/module/skia/types/Skia.js.map +1 -1
  151. package/lib/module/skia/types/Skottie.d.ts +223 -0
  152. package/lib/module/skia/types/Skottie.js +74 -0
  153. package/lib/module/skia/types/Skottie.js.map +1 -0
  154. package/lib/module/skia/types/index.d.ts +1 -0
  155. package/lib/module/skia/types/index.js +1 -0
  156. package/lib/module/skia/types/index.js.map +1 -1
  157. package/lib/module/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
  158. package/lib/module/skia/web/JsiSkImageFilterFactory.js +88 -19
  159. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  160. package/lib/module/skia/web/JsiSkia.js +2 -0
  161. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  162. package/lib/module/skia/web/JsiSkottieAnimation.d.ts +59 -0
  163. package/lib/module/skia/web/JsiSkottieAnimation.js +236 -0
  164. package/lib/module/skia/web/JsiSkottieAnimation.js.map +1 -0
  165. package/lib/module/skia/web/JsiSkottieFactory.d.ts +9 -0
  166. package/lib/module/skia/web/JsiSkottieFactory.js +19 -0
  167. package/lib/module/skia/web/JsiSkottieFactory.js.map +1 -0
  168. package/lib/module/sksg/Elements.d.ts +3 -1
  169. package/lib/module/sksg/Elements.js.map +1 -1
  170. package/lib/module/sksg/Node.d.ts +1 -1
  171. package/lib/module/sksg/Node.js +1 -1
  172. package/lib/module/sksg/Node.js.map +1 -1
  173. package/lib/module/sksg/Recorder/Core.d.ts +4 -2
  174. package/lib/module/sksg/Recorder/Core.js +1 -0
  175. package/lib/module/sksg/Recorder/Core.js.map +1 -1
  176. package/lib/module/sksg/Recorder/Player.js +3 -1
  177. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  178. package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
  179. package/lib/module/sksg/Recorder/ReanimatedRecorder.js +4 -0
  180. package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  181. package/lib/module/sksg/Recorder/Recorder.d.ts +2 -1
  182. package/lib/module/sksg/Recorder/Recorder.js +6 -0
  183. package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
  184. package/lib/module/sksg/Recorder/Visitor.js +3 -0
  185. package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
  186. package/lib/module/sksg/Recorder/commands/Drawing.d.ts +2 -2
  187. package/lib/module/sksg/Recorder/commands/Drawing.js +9 -2
  188. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  189. package/lib/module/sksg/Recorder/commands/ImageFilters.js +12 -2
  190. package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
  191. package/lib/typescript/lib/commonjs/renderer/components/ImageFilter.d.ts +2 -0
  192. package/lib/typescript/lib/commonjs/renderer/components/Skottie.d.ts +2 -0
  193. package/lib/typescript/lib/commonjs/skia/types/Matrix4.d.ts +1 -0
  194. package/lib/typescript/lib/commonjs/skia/types/Skottie.d.ts +6 -0
  195. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFilterFactory.d.ts +22 -5
  196. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
  197. package/lib/typescript/lib/commonjs/skia/web/JsiSkottieAnimation.d.ts +48 -0
  198. package/lib/typescript/lib/commonjs/skia/web/JsiSkottieFactory.d.ts +6 -0
  199. package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  200. package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -0
  201. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +1 -1
  202. package/lib/typescript/lib/module/mock/index.d.ts +8 -0
  203. package/lib/typescript/lib/module/renderer/components/ImageFilter.d.ts +2 -0
  204. package/lib/typescript/lib/module/renderer/components/Skottie.d.ts +2 -0
  205. package/lib/typescript/lib/module/renderer/components/index.d.ts +2 -0
  206. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -0
  207. package/lib/typescript/lib/module/skia/types/Matrix4.d.ts +1 -0
  208. package/lib/typescript/lib/module/skia/types/Skottie.d.ts +5 -0
  209. package/lib/typescript/lib/module/skia/types/index.d.ts +1 -0
  210. package/lib/typescript/lib/module/skia/web/JsiSkImageFilterFactory.d.ts +22 -5
  211. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
  212. package/lib/typescript/lib/module/skia/web/JsiSkottieAnimation.d.ts +47 -0
  213. package/lib/typescript/lib/module/skia/web/JsiSkottieFactory.d.ts +5 -0
  214. package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  215. package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -0
  216. package/lib/typescript/lib/module/sksg/Recorder/commands/Drawing.d.ts +1 -1
  217. package/lib/typescript/src/dom/nodes/datatypes/Gradient.d.ts +15 -15
  218. package/lib/typescript/src/dom/types/Drawings.d.ts +8 -1
  219. package/lib/typescript/src/dom/types/NodeType.d.ts +3 -1
  220. package/lib/typescript/src/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
  221. package/lib/typescript/src/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
  222. package/lib/typescript/src/renderer/__tests__/e2e/ImageFilter.spec.d.ts +1 -0
  223. package/lib/typescript/src/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
  224. package/lib/typescript/src/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
  225. package/lib/typescript/src/renderer/__tests__/setup.d.ts +5 -0
  226. package/lib/typescript/src/renderer/components/ImageFilter.d.ts +4 -0
  227. package/lib/typescript/src/renderer/components/Skottie.d.ts +4 -0
  228. package/lib/typescript/src/renderer/components/index.d.ts +2 -0
  229. package/lib/typescript/src/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
  230. package/lib/typescript/src/skia/types/Matrix4.d.ts +11 -2
  231. package/lib/typescript/src/skia/types/Recorder.d.ts +2 -1
  232. package/lib/typescript/src/skia/types/Skia.d.ts +2 -0
  233. package/lib/typescript/src/skia/types/Skottie.d.ts +223 -0
  234. package/lib/typescript/src/skia/types/index.d.ts +1 -0
  235. package/lib/typescript/src/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
  236. package/lib/typescript/src/skia/web/JsiSkottieAnimation.d.ts +59 -0
  237. package/lib/typescript/src/skia/web/JsiSkottieFactory.d.ts +9 -0
  238. package/lib/typescript/src/sksg/Elements.d.ts +3 -1
  239. package/lib/typescript/src/sksg/Node.d.ts +1 -1
  240. package/lib/typescript/src/sksg/Recorder/Core.d.ts +4 -2
  241. package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
  242. package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +2 -1
  243. package/lib/typescript/src/sksg/Recorder/commands/Drawing.d.ts +2 -2
  244. package/libs/android/arm64-v8a/libjsonreader.a +0 -0
  245. package/libs/android/armeabi-v7a/libjsonreader.a +0 -0
  246. package/libs/android/x86/libjsonreader.a +0 -0
  247. package/libs/android/x86_64/libjsonreader.a +0 -0
  248. package/libs/apple/libpathops.xcframework/Info.plist +8 -8
  249. package/libs/apple/libskia.xcframework/Info.plist +14 -14
  250. package/libs/apple/libskottie.xcframework/Info.plist +14 -14
  251. package/libs/apple/libskparagraph.xcframework/Info.plist +16 -16
  252. package/libs/apple/libsksg.xcframework/Info.plist +5 -5
  253. package/libs/apple/libskshaper.xcframework/Info.plist +14 -14
  254. package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +14 -14
  255. package/libs/apple/libsvg.xcframework/Info.plist +14 -14
  256. package/package.json +1 -1
  257. package/react-native-skia.podspec +4 -2
  258. package/src/__tests__/snapshots/matrix4/camera-corner.png +0 -0
  259. package/src/__tests__/snapshots/matrix4/camera-offset.png +0 -0
  260. package/src/__tests__/snapshots/matrix4/camera-top-left-center.png +0 -0
  261. package/src/__tests__/snapshots/matrix4/camera-zoom-out.png +0 -0
  262. package/src/__tests__/snapshots/matrix4/full-rect.png +0 -0
  263. package/src/__tests__/snapshots/matrix4/rect.png +0 -0
  264. package/src/__tests__/snapshots/matrix4/scaled-rect.png +0 -0
  265. package/src/__tests__/snapshots/matrix4/test-perspective.png +0 -0
  266. package/src/__tests__/snapshots/matrix4/test-perspective2.png +0 -0
  267. package/src/dom/types/Drawings.ts +11 -0
  268. package/src/dom/types/NodeType.ts +4 -0
  269. package/src/renderer/__tests__/e2e/AdvancedImageFilters.spec.tsx +492 -0
  270. package/src/renderer/__tests__/e2e/Camera.spec.tsx +475 -0
  271. package/src/renderer/__tests__/e2e/ImageFilter.spec.tsx +99 -0
  272. package/src/renderer/__tests__/e2e/LightingImageFilters.spec.tsx +1478 -0
  273. package/src/renderer/__tests__/e2e/Skottie.spec.tsx +440 -0
  274. package/src/renderer/__tests__/e2e/setup/skottie/basic_slots.json +1118 -0
  275. package/src/renderer/__tests__/e2e/setup/skottie/color-props.json +1 -0
  276. package/src/renderer/__tests__/e2e/setup/skottie/confetti.json +5899 -0
  277. package/src/renderer/__tests__/e2e/setup/skottie/drinks.json +43857 -0
  278. package/src/renderer/__tests__/e2e/setup/skottie/fingerprint.json +1 -0
  279. package/src/renderer/__tests__/e2e/setup/skottie/lego_loader.json +29540 -0
  280. package/src/renderer/__tests__/e2e/setup/skottie/new-drop.json +1 -0
  281. package/src/renderer/__tests__/e2e/setup/skottie/onboarding.json +1 -0
  282. package/src/renderer/__tests__/e2e/setup/skottie/text-layer.json +1 -0
  283. package/src/renderer/__tests__/setup.tsx +31 -0
  284. package/src/renderer/components/ImageFilter.tsx +8 -0
  285. package/src/renderer/components/Skottie.tsx +8 -0
  286. package/src/renderer/components/index.ts +2 -0
  287. package/src/skia/__tests__/assets/Avenir-Heavy.ttf +0 -0
  288. package/src/skia/types/ImageFilter/ImageFilterFactory.ts +391 -21
  289. package/src/skia/types/Matrix4.ts +108 -2
  290. package/src/skia/types/Recorder.ts +2 -0
  291. package/src/skia/types/Skia.ts +2 -0
  292. package/src/skia/types/Skottie.ts +266 -0
  293. package/src/skia/types/index.ts +1 -0
  294. package/src/skia/web/JsiSkImageFilterFactory.ts +266 -31
  295. package/src/skia/web/JsiSkia.ts +2 -0
  296. package/src/skia/web/JsiSkottieAnimation.ts +259 -0
  297. package/src/skia/web/JsiSkottieFactory.ts +25 -0
  298. package/src/sksg/Elements.tsx +4 -0
  299. package/src/sksg/Node.ts +1 -0
  300. package/src/sksg/Recorder/Core.ts +3 -0
  301. package/src/sksg/Recorder/Player.ts +3 -0
  302. package/src/sksg/Recorder/ReanimatedRecorder.ts +6 -0
  303. package/src/sksg/Recorder/Recorder.ts +5 -0
  304. package/src/sksg/Recorder/Visitor.ts +3 -0
  305. package/src/sksg/Recorder/commands/Drawing.ts +7 -3
  306. package/src/sksg/Recorder/commands/ImageFilters.ts +15 -2
@@ -0,0 +1,200 @@
1
+ /*
2
+ * Copyright 2019 Google Inc.
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkottieTextShaper_DEFINED
9
+ #define SkottieTextShaper_DEFINED
10
+
11
+ #include "include/core/SkFont.h"
12
+ #include "include/core/SkPoint.h"
13
+ #include "include/core/SkRefCnt.h"
14
+ #include "include/core/SkScalar.h"
15
+ #include "include/core/SkTypes.h"
16
+ #include "include/private/base/SkTypeTraits.h"
17
+ #include "include/utils/SkTextUtils.h"
18
+
19
+ #include <cstddef>
20
+ #include <cstdint>
21
+ #include <type_traits>
22
+ #include <vector>
23
+
24
+ class SkCanvas;
25
+ class SkFontMgr;
26
+ class SkPaint;
27
+ class SkString;
28
+ class SkTypeface;
29
+ struct SkRect;
30
+
31
+ namespace SkShapers { class Factory; }
32
+
33
+ namespace skottie {
34
+
35
+ // Helper implementing After Effects text shaping semantics on top of SkShaper.
36
+
37
+ class Shaper final {
38
+ public:
39
+ struct RunRec {
40
+ SkFont fFont;
41
+ size_t fSize;
42
+
43
+ static_assert(::sk_is_trivially_relocatable<decltype(fFont)>::value);
44
+
45
+ using sk_is_trivially_relocatable = std::true_type;
46
+ };
47
+
48
+ struct ShapedGlyphs {
49
+ std::vector<RunRec> fRuns;
50
+
51
+ // Consolidated storage for all runs.
52
+ std::vector<SkGlyphID> fGlyphIDs;
53
+ std::vector<SkPoint> fGlyphPos;
54
+
55
+ // fClusters[i] is an input string index, pointing to the start of the UTF sequence
56
+ // associated with fGlyphs[i]. The number of entries matches the number of glyphs.
57
+ // Only available with Flags::kClusters.
58
+ std::vector<size_t> fClusters;
59
+
60
+ enum class BoundsType { kConservative, kTight };
61
+ SkRect computeBounds(BoundsType) const;
62
+
63
+ void draw(SkCanvas*, const SkPoint& origin, const SkPaint&) const;
64
+ };
65
+
66
+ struct Fragment {
67
+ ShapedGlyphs fGlyphs;
68
+ SkPoint fOrigin;
69
+
70
+ // Only valid for kFragmentGlyphs
71
+ float fAdvance,
72
+ fAscent;
73
+ uint32_t fLineIndex; // 0-based index for the line this fragment belongs to.
74
+ bool fIsWhitespace; // True if the first code point in the corresponding
75
+ // cluster is whitespace.
76
+ };
77
+
78
+ struct Result {
79
+ std::vector<Fragment> fFragments;
80
+ size_t fMissingGlyphCount = 0;
81
+ // Relative text size scale, when using an auto-scaling ResizePolicy
82
+ // (otherwise 1.0). This is informative of the final text size, and is
83
+ // not required to render the Result.
84
+ float fScale = 1.0f;
85
+
86
+ SkRect computeVisualBounds() const;
87
+ };
88
+
89
+ enum class VAlign : uint8_t {
90
+ // Align the first line typographical top with the text box top (AE box text).
91
+ kTop,
92
+ // Align the first line typographical baseline with the text box top (AE point text).
93
+ kTopBaseline,
94
+
95
+ // Skottie vertical alignment extensions
96
+
97
+ // These are based on a hybrid extent box defined (in Y) as
98
+ //
99
+ // ------------------------------------------------------
100
+ // MIN(visual_top_extent , typographical_top_extent )
101
+ //
102
+ // ...
103
+ //
104
+ // MAX(visual_bottom_extent, typographical_bottom_extent)
105
+ // ------------------------------------------------------
106
+ kHybridTop, // extent box top -> text box top
107
+ kHybridCenter, // extent box center -> text box center
108
+ kHybridBottom, // extent box bottom -> text box bottom
109
+
110
+ // Visual alignement modes -- these are using tight visual bounds for the paragraph.
111
+ kVisualTop, // visual top -> text box top
112
+ kVisualCenter, // visual center -> text box center
113
+ kVisualBottom, // visual bottom -> text box bottom
114
+ };
115
+
116
+ enum class ResizePolicy : uint8_t {
117
+ // Use the specified text size.
118
+ kNone,
119
+ // Resize the text such that the extent box fits (snuggly) in the text box,
120
+ // both horizontally and vertically.
121
+ kScaleToFit,
122
+ // Same kScaleToFit if the text doesn't fit at the specified font size.
123
+ // Otherwise, same as kNone.
124
+ kDownscaleToFit,
125
+ };
126
+
127
+ enum class LinebreakPolicy : uint8_t {
128
+ // Break lines such that they fit in a non-empty paragraph box, horizontally.
129
+ kParagraph,
130
+ // Only break lines when requested explicitly (\r), regardless of paragraph box dimensions.
131
+ kExplicit,
132
+ };
133
+
134
+ // Initial text direction.
135
+ enum class Direction : uint8_t { kLTR, kRTL };
136
+
137
+ enum class Capitalization {
138
+ kNone,
139
+ kUpperCase,
140
+ };
141
+
142
+ enum Flags : uint32_t {
143
+ kNone = 0x00,
144
+
145
+ // Split out individual glyphs into separate Fragments
146
+ // (useful when the caller intends to manipulate glyphs independently).
147
+ kFragmentGlyphs = 0x01,
148
+
149
+ // Compute the advance and ascent for each fragment.
150
+ kTrackFragmentAdvanceAscent = 0x02,
151
+
152
+ // Return cluster information.
153
+ kClusters = 0x04,
154
+ };
155
+
156
+ struct TextDesc {
157
+ const sk_sp<SkTypeface>& fTypeface;
158
+ SkScalar fTextSize = 0,
159
+ fMinTextSize = 0, // when auto-sizing
160
+ fMaxTextSize = 0, // when auto-sizing
161
+ fLineHeight = 0,
162
+ fLineShift = 0,
163
+ fAscent = 0;
164
+ SkTextUtils::Align fHAlign = SkTextUtils::kLeft_Align;
165
+ VAlign fVAlign = Shaper::VAlign::kTop;
166
+ ResizePolicy fResize = Shaper::ResizePolicy::kNone;
167
+ LinebreakPolicy fLinebreak = Shaper::LinebreakPolicy::kExplicit;
168
+ Direction fDirection = Shaper::Direction::kLTR ;
169
+ Capitalization fCapitalization = Shaper::Capitalization::kNone;
170
+ size_t fMaxLines = 0; // when auto-sizing, 0 -> no max
171
+ uint32_t fFlags = 0;
172
+ const char* fLocale = nullptr;
173
+ const char* fFontFamily = nullptr;
174
+ };
175
+
176
+ // Performs text layout along an infinite horizontal line, starting at |point|.
177
+ // Only explicit line breaks (\r) are observed.
178
+ static Result Shape(const SkString& text, const TextDesc& desc, const SkPoint& point,
179
+ const sk_sp<SkFontMgr>&, const sk_sp<SkShapers::Factory>&);
180
+
181
+ // Performs text layout within |box|, injecting line breaks as needed to ensure
182
+ // horizontal fitting. The result is *not* guaranteed to fit vertically (it may extend
183
+ // below the box bottom).
184
+ static Result Shape(const SkString& text, const TextDesc& desc, const SkRect& box,
185
+ const sk_sp<SkFontMgr>&, const sk_sp<SkShapers::Factory>&);
186
+
187
+ #if !defined(SK_DISABLE_LEGACY_SHAPER_FACTORY)
188
+ static Result Shape(const SkString& text, const TextDesc& desc, const SkPoint& point,
189
+ const sk_sp<SkFontMgr>&);
190
+ static Result Shape(const SkString& text, const TextDesc& desc, const SkRect& box,
191
+ const sk_sp<SkFontMgr>&);
192
+ #endif
193
+
194
+ private:
195
+ Shaper() = delete;
196
+ };
197
+
198
+ } // namespace skottie
199
+
200
+ #endif // SkottieTextShaper_DEFINED
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Copyright 2017 Google Inc.
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkottieValue_DEFINED
9
+ #define SkottieValue_DEFINED
10
+
11
+ #include "include/core/SkColor.h"
12
+ #include "include/core/SkM44.h"
13
+ #include "include/core/SkPath.h"
14
+
15
+ #include <initializer_list>
16
+ #include <vector>
17
+
18
+ namespace skjson { class Value; }
19
+
20
+ namespace skottie {
21
+
22
+ using ScalarValue = SkScalar;
23
+ using Vec2Value = SkV2;
24
+
25
+ class VectorValue : public std::vector<float> {
26
+ public:
27
+ VectorValue() = default;
28
+
29
+ VectorValue(std::initializer_list<float> l) : INHERITED(l) {}
30
+
31
+ operator SkV3() const;
32
+ private:
33
+ using INHERITED = std::vector<float>;
34
+ };
35
+
36
+ class ColorValue final : public VectorValue {
37
+ public:
38
+ ColorValue() = default;
39
+
40
+ ColorValue(std::initializer_list<float> l) : INHERITED(l) {}
41
+
42
+ operator SkColor() const;
43
+ operator SkColor4f() const;
44
+
45
+ private:
46
+ using INHERITED = VectorValue;
47
+ };
48
+
49
+ class ShapeValue final : public std::vector<float> {
50
+ public:
51
+ operator SkPath() const;
52
+ };
53
+
54
+ } // namespace skottie
55
+
56
+ #endif // SkottieValue_DEFINED
@@ -0,0 +1,89 @@
1
+ /*
2
+ * Copyright 2020 Google Inc.
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkottieAnimator_DEFINED
9
+ #define SkottieAnimator_DEFINED
10
+
11
+ #include "include/core/SkRefCnt.h"
12
+
13
+ #include <vector>
14
+
15
+ struct SkV2;
16
+
17
+ namespace skjson {
18
+
19
+ class ObjectValue;
20
+
21
+ } // namespace skjson
22
+
23
+ namespace skottie {
24
+
25
+ class SlotManager;
26
+
27
+ namespace internal {
28
+
29
+ class AnimationBuilder;
30
+ class AnimatorBuilder;
31
+
32
+ class Animator : public SkRefCnt {
33
+ public:
34
+ using StateChanged = bool;
35
+ StateChanged seek(float t) { return this->onSeek(t); }
36
+
37
+ protected:
38
+ Animator() = default;
39
+
40
+ virtual StateChanged onSeek(float t) = 0;
41
+
42
+ private:
43
+ Animator(const Animator&) = delete;
44
+ Animator& operator=(const Animator&) = delete;
45
+ };
46
+
47
+ class AnimatablePropertyContainer : public Animator {
48
+ public:
49
+ // This is the workhorse for property binding: depending on whether the property is animated,
50
+ // it will either apply immediately or instantiate and attach a keyframe animator, scoped to
51
+ // this container.
52
+ template <typename T>
53
+ bool bind(const AnimationBuilder&, const skjson::ObjectValue*, T*);
54
+
55
+ template <typename T>
56
+ bool bind(const AnimationBuilder& abuilder, const skjson::ObjectValue* jobject, T& v) {
57
+ return this->bind<T>(abuilder, jobject, &v);
58
+ }
59
+
60
+ // A flavor of bind<Vec2Value> which drives an additional/optional orientation target
61
+ // (rotation in degrees), when bound to a motion path property.
62
+ bool bindAutoOrientable(const AnimationBuilder& abuilder,
63
+ const skjson::ObjectValue* jobject,
64
+ SkV2* v, float* orientation);
65
+
66
+ bool isStatic() const { return fAnimators.empty() && !fHasSlotID; }
67
+
68
+ protected:
69
+ friend class skottie::SlotManager;
70
+ virtual void onSync() = 0;
71
+
72
+ void shrink_to_fit();
73
+
74
+ void attachDiscardableAdapter(sk_sp<AnimatablePropertyContainer>);
75
+
76
+ private:
77
+ StateChanged onSeek(float) final;
78
+
79
+ bool bindImpl(const AnimationBuilder&, const skjson::ObjectValue*, AnimatorBuilder&);
80
+
81
+ std::vector<sk_sp<Animator>> fAnimators;
82
+ bool fHasSynced = false;
83
+ bool fHasSlotID = false;
84
+ };
85
+
86
+ } // namespace internal
87
+ } // namespace skottie
88
+
89
+ #endif // SkottieAnimator_DEFINED
@@ -0,0 +1,82 @@
1
+ /*
2
+ * Copyright 2022 Google Inc.
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkottieFont_DEFINED
9
+ #define SkottieFont_DEFINED
10
+
11
+ #include "include/core/SkRefCnt.h"
12
+ #include "include/core/SkTypes.h"
13
+ #include "include/private/base/SkNoncopyable.h"
14
+ #include "include/utils/SkCustomTypeface.h"
15
+ #include "modules/sksg/include/SkSGRenderNode.h"
16
+ #include "src/core/SkTHash.h"
17
+
18
+ #include <memory>
19
+ #include <utility>
20
+ #include <vector>
21
+
22
+ class SkPath;
23
+ class SkTypeface;
24
+ struct SkSize;
25
+
26
+ namespace skjson { class ObjectValue; }
27
+
28
+ namespace skottie::internal {
29
+
30
+ class AnimationBuilder;
31
+
32
+ // Font backed by Lottie character data (glyph paths and glyph compositions).
33
+ class CustomFont final : SkNoncopyable {
34
+ public:
35
+ ~CustomFont();
36
+
37
+ using GlyphCompMap = skia_private::THashMap<SkGlyphID, sk_sp<sksg::RenderNode>>;
38
+
39
+ class Builder final : SkNoncopyable {
40
+ public:
41
+ bool parseGlyph(const AnimationBuilder*, const skjson::ObjectValue&);
42
+ std::unique_ptr<CustomFont> detach();
43
+
44
+ private:
45
+ static bool ParseGlyphPath(const AnimationBuilder*, const skjson::ObjectValue&, SkPath*);
46
+ static sk_sp<sksg::RenderNode> ParseGlyphComp(const AnimationBuilder*,
47
+ const skjson::ObjectValue&,
48
+ SkSize*);
49
+
50
+ GlyphCompMap fGlyphComps;
51
+ SkCustomTypefaceBuilder fCustomBuilder;
52
+ };
53
+
54
+ // Helper for resolving (SkTypeface, SkGlyphID) tuples to a composition root.
55
+ // Used post-shaping, to substitute composition glyphs in the rendering tree.
56
+ class GlyphCompMapper final : public SkRefCnt {
57
+ public:
58
+ explicit GlyphCompMapper(std::vector<std::unique_ptr<CustomFont>>&& fonts)
59
+ : fFonts(std::move(fonts)) {}
60
+
61
+ ~GlyphCompMapper() override = default;
62
+
63
+ sk_sp<sksg::RenderNode> getGlyphComp(const SkTypeface*, SkGlyphID) const;
64
+
65
+ private:
66
+ const std::vector<std::unique_ptr<CustomFont>> fFonts;
67
+ };
68
+
69
+ const sk_sp<SkTypeface>& typeface() const { return fTypeface; }
70
+
71
+ int glyphCompCount() const { return fGlyphComps.count(); }
72
+
73
+ private:
74
+ CustomFont(GlyphCompMap&&, sk_sp<SkTypeface> tf);
75
+
76
+ const GlyphCompMap fGlyphComps;
77
+ const sk_sp<SkTypeface> fTypeface;
78
+ };
79
+
80
+ } // namespace skottie::internal
81
+
82
+ #endif // SkottieFont_DEFINED
@@ -0,0 +1,155 @@
1
+ /*
2
+ * Copyright 2019 Google Inc.
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkottieTextAdapter_DEFINED
9
+ #define SkottieTextAdapter_DEFINED
10
+
11
+ #include "include/core/SkM44.h"
12
+ #include "include/core/SkPoint.h"
13
+ #include "include/core/SkRefCnt.h"
14
+ #include "modules/skottie/include/TextShaper.h"
15
+ #include "modules/skottie/src/SkottieValue.h"
16
+ #include "modules/skottie/src/animator/Animator.h"
17
+ #include "modules/skottie/src/text/Font.h"
18
+ #include "modules/skottie/src/text/TextAnimator.h"
19
+ #include "modules/skottie/src/text/TextValue.h"
20
+ #include "modules/sksg/include/SkSGPaint.h"
21
+ #include "modules/sksg/include/SkSGRenderEffect.h"
22
+ #include "modules/sksg/include/SkSGTransform.h"
23
+
24
+ #include <cstdint>
25
+ #include <memory>
26
+ #include <vector>
27
+
28
+ class SkFontMgr;
29
+
30
+ namespace skjson {
31
+ class ObjectValue;
32
+ }
33
+ namespace skottie {
34
+ class Logger;
35
+ }
36
+ namespace sksg {
37
+ class Group;
38
+ class RenderNode;
39
+ } // namespace sksg
40
+
41
+ namespace SkShapers { class Factory; }
42
+
43
+ namespace skottie {
44
+ namespace internal {
45
+ class AnimationBuilder;
46
+
47
+ class TextAdapter final : public AnimatablePropertyContainer {
48
+ public:
49
+ static sk_sp<TextAdapter> Make(const skjson::ObjectValue&,
50
+ const AnimationBuilder*,
51
+ sk_sp<SkFontMgr>,
52
+ sk_sp<CustomFont::GlyphCompMapper>,
53
+ sk_sp<Logger>,
54
+ sk_sp<::SkShapers::Factory>);
55
+
56
+ ~TextAdapter() override;
57
+
58
+ const sk_sp<sksg::Group>& node() const { return fRoot; }
59
+
60
+ const TextValue& getText() const { return fText.fCurrentValue; }
61
+ void setText(const TextValue&);
62
+
63
+ protected:
64
+ void onSync() override;
65
+
66
+ private:
67
+ class GlyphDecoratorNode;
68
+
69
+ enum class AnchorPointGrouping : uint8_t {
70
+ kCharacter,
71
+ kWord,
72
+ kLine,
73
+ kAll,
74
+ };
75
+
76
+ TextAdapter(sk_sp<SkFontMgr>,
77
+ sk_sp<CustomFont::GlyphCompMapper>,
78
+ sk_sp<Logger>,
79
+ sk_sp<SkShapers::Factory>,
80
+ AnchorPointGrouping);
81
+
82
+ struct FragmentRec {
83
+ SkPoint fOrigin; // fragment position
84
+
85
+ const Shaper::ShapedGlyphs* fGlyphs = nullptr;
86
+ sk_sp<sksg::Matrix<SkM44>> fMatrixNode;
87
+ sk_sp<sksg::Color> fFillColorNode,
88
+ fStrokeColorNode;
89
+ sk_sp<sksg::BlurImageFilter> fBlur;
90
+
91
+ float fAdvance, // used for transform anchor point calculations
92
+ fAscent; // ^
93
+ };
94
+
95
+ void reshape();
96
+ void addFragment(Shaper::Fragment&, sksg::Group* container);
97
+ void buildDomainMaps(const Shaper::Result&);
98
+ std::vector<sk_sp<sksg::RenderNode>> buildGlyphCompNodes(Shaper::ShapedGlyphs&) const;
99
+
100
+ void pushPropsToFragment(const TextAnimator::ResolvedProps&, const FragmentRec&,
101
+ const SkV2& frag_offset, const SkV2& grouping_alignment,
102
+ const TextAnimator::DomainSpan*) const;
103
+
104
+ SkV2 fragmentAnchorPoint(const FragmentRec&, const SkV2&,
105
+ const TextAnimator::DomainSpan*) const;
106
+ uint32_t shaperFlags() const;
107
+
108
+ SkM44 fragmentMatrix(const TextAnimator::ResolvedProps&, const FragmentRec&, const SkV2&) const;
109
+
110
+ const sk_sp<sksg::Group> fRoot;
111
+ const sk_sp<SkFontMgr> fFontMgr;
112
+ const sk_sp<CustomFont::GlyphCompMapper> fCustomGlyphMapper;
113
+ sk_sp<Logger> fLogger;
114
+ sk_sp<SkShapers::Factory> fShapingFactory;
115
+ const AnchorPointGrouping fAnchorPointGrouping;
116
+
117
+ std::vector<sk_sp<TextAnimator>> fAnimators;
118
+ std::vector<FragmentRec> fFragments;
119
+ TextAnimator::DomainMaps fMaps;
120
+
121
+ // Helps detect external value changes.
122
+ struct TextValueTracker {
123
+ TextValue fCurrentValue;
124
+
125
+ bool hasChanged() const {
126
+ if (fCurrentValue != fPrevValue) {
127
+ fPrevValue = fCurrentValue;
128
+ return true;
129
+ }
130
+ return false;
131
+ }
132
+
133
+ const TextValue* operator->() const { return &fCurrentValue; }
134
+
135
+ private:
136
+ mutable TextValue fPrevValue;
137
+ };
138
+
139
+ TextValueTracker fText;
140
+ Vec2Value fGroupingAlignment = {0,0};
141
+ float fTextShapingScale = 1; // size adjustment from auto-scaling
142
+
143
+ // Optional text path.
144
+ struct PathInfo;
145
+ std::unique_ptr<PathInfo> fPathInfo;
146
+
147
+ bool fHasBlurAnimator : 1,
148
+ fRequiresAnchorPoint : 1,
149
+ fRequiresLineAdjustments : 1;
150
+ };
151
+
152
+ } // namespace internal
153
+ } // namespace skottie
154
+
155
+ #endif // SkottieTextAdapter_DEFINED
@@ -0,0 +1,121 @@
1
+ /*
2
+ * Copyright 2019 Google Inc.
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkottieTextAnimator_DEFINED
9
+ #define SkottieTextAnimator_DEFINED
10
+
11
+ #include "include/core/SkColor.h"
12
+ #include "include/core/SkM44.h"
13
+ #include "include/core/SkRefCnt.h"
14
+ #include "modules/skottie/src/SkottieValue.h"
15
+
16
+ #include <cstddef>
17
+ #include <vector>
18
+
19
+ namespace skjson {
20
+ class ObjectValue;
21
+ }
22
+
23
+ namespace skottie {
24
+ namespace internal {
25
+ class AnimatablePropertyContainer;
26
+ class AnimationBuilder;
27
+ class RangeSelector;
28
+
29
+ class TextAnimator final : public SkNVRefCnt<TextAnimator> {
30
+ public:
31
+ static sk_sp<TextAnimator> Make(const skjson::ObjectValue*,
32
+ const AnimationBuilder*,
33
+ AnimatablePropertyContainer* acontainer);
34
+
35
+ // Direct mapping of AE properties.
36
+ struct AnimatedProps {
37
+ VectorValue position,
38
+ scale = { 100, 100, 100 };
39
+ ColorValue fill_color,
40
+ stroke_color;
41
+ // unlike pos/scale which are animated vectors, rotation is separated in each dimension.
42
+ SkV3 rotation = { 0, 0, 0 };
43
+ Vec2Value blur = { 0, 0 },
44
+ line_spacing = { 0, 0 };
45
+ ScalarValue opacity = 100,
46
+ fill_opacity = 100,
47
+ stroke_opacity = 100,
48
+ tracking = 0,
49
+ stroke_width = 0;
50
+ };
51
+
52
+ struct ResolvedProps {
53
+ SkV3 position = { 0, 0, 0 },
54
+ scale = { 1, 1, 1 },
55
+ rotation = { 0, 0, 0 };
56
+ float opacity = 1,
57
+ tracking = 0,
58
+ stroke_width = 0;
59
+ SkColor fill_color = SK_ColorTRANSPARENT,
60
+ stroke_color = SK_ColorTRANSPARENT;
61
+ SkV2 blur = { 0, 0 },
62
+ line_spacing = { 0, 0 };
63
+ };
64
+
65
+ struct AnimatedPropsModulator {
66
+ ResolvedProps props; // accumulates properties across *all* animators
67
+ float coverage; // accumulates range selector coverage for a given animator
68
+ };
69
+ using ModulatorBuffer = std::vector<AnimatedPropsModulator>;
70
+
71
+ // Domain maps describe how a given index domain (words, lines, etc) relates
72
+ // to the full fragment index range.
73
+ //
74
+ // Each domain[i] represents a [domain[i].fOffset.. domain[i].fOffset+domain[i].fCount-1]
75
+ // fragment subset.
76
+ struct DomainSpan {
77
+ size_t fOffset,
78
+ fCount;
79
+ float fAdvance, // cumulative advance for all fragments in span
80
+ fAscent; // max ascent for all fragments in span
81
+ };
82
+ using DomainMap = std::vector<DomainSpan>;
83
+
84
+ struct DomainMaps {
85
+ DomainMap fNonWhitespaceMap,
86
+ fWordsMap,
87
+ fLinesMap;
88
+ };
89
+
90
+ void modulateProps(const DomainMaps&, ModulatorBuffer&) const;
91
+
92
+ bool hasBlur() const { return fHasBlur; }
93
+
94
+ bool requiresAnchorPoint() const { return fRequiresAnchorPoint; }
95
+ bool requiresLineAdjustments() const { return fRequiresLineAdjustments; }
96
+
97
+ private:
98
+ TextAnimator(std::vector<sk_sp<RangeSelector>>&&,
99
+ const skjson::ObjectValue&,
100
+ const AnimationBuilder*,
101
+ AnimatablePropertyContainer*);
102
+
103
+ ResolvedProps modulateProps(const ResolvedProps&, float amount) const;
104
+
105
+ const std::vector<sk_sp<RangeSelector>> fSelectors;
106
+
107
+ AnimatedProps fTextProps;
108
+ bool fHasFillColor : 1,
109
+ fHasStrokeColor : 1,
110
+ fHasFillOpacity : 1,
111
+ fHasStrokeOpacity : 1,
112
+ fHasOpacity : 1,
113
+ fHasBlur : 1,
114
+ fRequiresAnchorPoint : 1, // animator sensitive to transform origin?
115
+ fRequiresLineAdjustments : 1; // animator effects line-wide fragment adjustments
116
+ };
117
+
118
+ } // namespace internal
119
+ } // namespace skottie
120
+
121
+ #endif // SkottieTextAnimator_DEFINED