@shopify/react-native-skia 0.1.122 → 0.1.125

Sign up to get free protection for your applications and to get access to all the features.
Files changed (466) hide show
  1. package/android/CMakeLists.txt +6 -1
  2. package/android/build.gradle +1 -1
  3. package/android/cpp/jni/JniSkiaDrawView.cpp +14 -71
  4. package/android/cpp/jni/JniSkiaManager.cpp +1 -1
  5. package/android/cpp/jni/include/JniSkiaDrawView.h +18 -22
  6. package/android/cpp/jni/include/JniSkiaManager.h +4 -4
  7. package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +68 -0
  8. package/android/cpp/rnskia-android/RNSkDrawViewImpl.h +48 -0
  9. package/android/cpp/{jni/include/JniPlatformContextWrapper.h → rnskia-android/RNSkPlatformContextImpl.h} +4 -4
  10. package/android/cpp/{jni → rnskia-android}/SkiaOpenGLRenderer.cpp +39 -54
  11. package/android/cpp/{jni/include → rnskia-android}/SkiaOpenGLRenderer.h +2 -31
  12. package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaViewManager.java +1 -1
  13. package/android/src/main/java/com/shopify/reactnative/skia/SkiaDrawView.java +21 -28
  14. package/cpp/api/JsiSkApi.h +3 -1
  15. package/cpp/api/JsiSkCanvas.h +1 -1
  16. package/cpp/api/JsiSkColor.h +41 -7
  17. package/cpp/api/JsiSkColorFilterFactory.h +2 -1
  18. package/cpp/api/JsiSkImageFilter.h +0 -2
  19. package/cpp/api/JsiSkImageFilterFactory.h +37 -17
  20. package/cpp/api/JsiSkMatrix.h +44 -2
  21. package/cpp/api/JsiSkPaint.h +4 -7
  22. package/cpp/api/JsiSkRuntimeEffect.h +7 -0
  23. package/cpp/api/JsiSkRuntimeEffectFactory.h +3 -2
  24. package/cpp/api/JsiSkRuntimeShaderBuilder.h +70 -0
  25. package/cpp/api/JsiSkShaderFactory.h +2 -2
  26. package/cpp/api/JsiSkVertices.h +1 -1
  27. package/cpp/api/third_party/CSSColorParser.cpp +194 -0
  28. package/cpp/api/third_party/CSSColorParser.h +1 -191
  29. package/cpp/jsi/JsiSimpleValueWrapper.h +98 -0
  30. package/cpp/rnskia/RNSkAnimation.h +0 -2
  31. package/cpp/rnskia/RNSkDrawView.cpp +84 -126
  32. package/cpp/rnskia/RNSkDrawView.h +7 -37
  33. package/cpp/rnskia/RNSkJsiViewApi.h +8 -5
  34. package/cpp/rnskia/RNSkManager.cpp +2 -2
  35. package/cpp/rnskia/RNSkManager.h +2 -2
  36. package/cpp/rnskia/RNSkPlatformContext.h +1 -1
  37. package/cpp/rnskia/RNSkValueApi.h +6 -2
  38. package/cpp/rnskia/values/RNSkClockValue.h +18 -10
  39. package/cpp/rnskia/values/RNSkDerivedValue.h +12 -5
  40. package/cpp/rnskia/values/RNSkReadonlyValue.h +25 -17
  41. package/cpp/rnskia/values/RNSkValue.h +8 -3
  42. package/cpp/utils/RNSkTimingInfo.h +13 -1
  43. package/ios/RNSkia-iOS/PlatformContext.h +30 -4
  44. package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +8 -10
  45. package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +25 -10
  46. package/ios/RNSkia-iOS/SkiaDrawView.mm +22 -20
  47. package/lib/commonjs/{values/animation → animation}/decay/decay.js +0 -0
  48. package/lib/commonjs/{values/animation → animation}/decay/decay.js.map +0 -0
  49. package/lib/commonjs/{values/animation → animation}/decay/index.js +0 -0
  50. package/lib/commonjs/{values/animation → animation}/decay/index.js.map +0 -0
  51. package/lib/commonjs/{values/animation → animation}/decay/runDecay.js +1 -1
  52. package/lib/commonjs/animation/decay/runDecay.js.map +1 -0
  53. package/lib/commonjs/{values/animation → animation}/decay/types.js +0 -0
  54. package/lib/commonjs/{values/animation → animation}/decay/types.js.map +0 -0
  55. package/lib/commonjs/{values/animation → animation}/functions/index.js +0 -0
  56. package/lib/commonjs/{values/animation → animation}/functions/index.js.map +0 -0
  57. package/lib/commonjs/animation/functions/interpolate.js +141 -0
  58. package/lib/commonjs/animation/functions/interpolate.js.map +1 -0
  59. package/lib/commonjs/animation/functions/interpolateColors.js +39 -0
  60. package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -0
  61. package/lib/commonjs/{values/animation → animation}/index.js +0 -0
  62. package/lib/commonjs/{values/animation → animation}/index.js.map +0 -0
  63. package/lib/commonjs/{values/animation → animation}/spring/Spring.js +0 -0
  64. package/lib/commonjs/{values/animation → animation}/spring/Spring.js.map +0 -0
  65. package/lib/commonjs/{values/animation → animation}/spring/functions/index.js +0 -0
  66. package/lib/commonjs/{values/animation → animation}/spring/functions/index.js.map +0 -0
  67. package/lib/commonjs/{values/animation → animation}/spring/functions/spring.js +0 -0
  68. package/lib/commonjs/{values/animation → animation}/spring/functions/spring.js.map +0 -0
  69. package/lib/commonjs/{values/animation → animation}/spring/index.js +0 -0
  70. package/lib/commonjs/{values/animation → animation}/spring/index.js.map +0 -0
  71. package/lib/commonjs/{values/animation → animation}/spring/runSpring.js +0 -0
  72. package/lib/commonjs/animation/spring/runSpring.js.map +1 -0
  73. package/lib/commonjs/{values/animation → animation}/spring/types.js +0 -0
  74. package/lib/commonjs/{values/animation → animation}/spring/types.js.map +0 -0
  75. package/lib/commonjs/{values/animation → animation}/spring/useSpring.js +0 -0
  76. package/lib/commonjs/animation/spring/useSpring.js.map +1 -0
  77. package/lib/commonjs/{values/animation → animation}/timing/Easing.js +0 -0
  78. package/lib/commonjs/{values/animation → animation}/timing/Easing.js.map +0 -0
  79. package/lib/commonjs/{values/animation → animation}/timing/createTiming.js +1 -1
  80. package/lib/commonjs/animation/timing/createTiming.js.map +1 -0
  81. package/lib/commonjs/{values/animation → animation}/timing/functions/bezier.js +0 -0
  82. package/lib/commonjs/{values/animation → animation}/timing/functions/bezier.js.map +0 -0
  83. package/lib/commonjs/{values/animation → animation}/timing/functions/getResolvedParams.js +3 -3
  84. package/lib/commonjs/animation/timing/functions/getResolvedParams.js.map +1 -0
  85. package/lib/commonjs/{values/animation → animation}/timing/functions/index.js +0 -0
  86. package/lib/commonjs/{values/animation → animation}/timing/functions/index.js.map +0 -0
  87. package/lib/commonjs/{values/animation → animation}/timing/functions/timing.js +0 -0
  88. package/lib/commonjs/{values/animation → animation}/timing/functions/timing.js.map +1 -1
  89. package/lib/commonjs/{values/animation → animation}/timing/functions/types.js +0 -0
  90. package/lib/commonjs/{values/animation → animation}/timing/functions/types.js.map +0 -0
  91. package/lib/commonjs/{values/animation → animation}/timing/index.js +0 -0
  92. package/lib/commonjs/{values/animation → animation}/timing/index.js.map +0 -0
  93. package/lib/commonjs/{values/animation → animation}/timing/runTiming.js +0 -0
  94. package/lib/commonjs/animation/timing/runTiming.js.map +1 -0
  95. package/lib/commonjs/{values/animation → animation}/timing/useLoop.js +0 -0
  96. package/lib/commonjs/{values/animation → animation}/timing/useLoop.js.map +0 -0
  97. package/lib/commonjs/{values/animation → animation}/timing/useTiming.js +1 -1
  98. package/lib/commonjs/animation/timing/useTiming.js.map +1 -0
  99. package/lib/commonjs/{values/animation → animation}/types.js +0 -0
  100. package/lib/commonjs/{values/animation → animation}/types.js.map +0 -0
  101. package/lib/commonjs/index.js +13 -0
  102. package/lib/commonjs/index.js.map +1 -1
  103. package/lib/commonjs/renderer/Canvas.js +17 -8
  104. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  105. package/lib/commonjs/renderer/components/Paint.js +1 -1
  106. package/lib/commonjs/renderer/components/Paint.js.map +1 -1
  107. package/lib/commonjs/renderer/components/colorFilters/BlendColor.js.map +1 -1
  108. package/lib/commonjs/renderer/components/colorFilters/Lerp.js +1 -1
  109. package/lib/commonjs/renderer/components/colorFilters/Lerp.js.map +1 -1
  110. package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js +4 -2
  111. package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js.map +1 -1
  112. package/lib/commonjs/renderer/components/imageFilters/RuntimeShader.js +37 -0
  113. package/lib/commonjs/renderer/components/imageFilters/RuntimeShader.js.map +1 -0
  114. package/lib/commonjs/renderer/components/imageFilters/index.js +13 -0
  115. package/lib/commonjs/renderer/components/imageFilters/index.js.map +1 -1
  116. package/lib/commonjs/renderer/components/shaders/Gradient.js +1 -1
  117. package/lib/commonjs/renderer/components/shaders/Gradient.js.map +1 -1
  118. package/lib/commonjs/renderer/components/shaders/Shader.js +2 -2
  119. package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
  120. package/lib/commonjs/renderer/components/shapes/Path.js +9 -1
  121. package/lib/commonjs/renderer/components/shapes/Path.js.map +1 -1
  122. package/lib/commonjs/renderer/processors/Circles.js +3 -2
  123. package/lib/commonjs/renderer/processors/Circles.js.map +1 -1
  124. package/lib/commonjs/renderer/processors/Font.js +1 -1
  125. package/lib/commonjs/renderer/processors/Font.js.map +1 -1
  126. package/lib/commonjs/renderer/processors/Paint.js +6 -1
  127. package/lib/commonjs/renderer/processors/Paint.js.map +1 -1
  128. package/lib/commonjs/renderer/processors/Rects.js +11 -21
  129. package/lib/commonjs/renderer/processors/Rects.js.map +1 -1
  130. package/lib/commonjs/renderer/processors/math/Matrix3.js +42 -63
  131. package/lib/commonjs/renderer/processors/math/Matrix3.js.map +1 -1
  132. package/lib/commonjs/renderer/processors/math/Vector.js +4 -5
  133. package/lib/commonjs/renderer/processors/math/Vector.js.map +1 -1
  134. package/lib/commonjs/skia/Color.js +14 -38
  135. package/lib/commonjs/skia/Color.js.map +1 -1
  136. package/lib/commonjs/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
  137. package/lib/commonjs/skia/Matrix.js.map +1 -1
  138. package/lib/commonjs/skia/Paint/Paint.js +13 -1
  139. package/lib/commonjs/skia/Paint/Paint.js.map +1 -1
  140. package/lib/commonjs/skia/Paint/usePaint.js +2 -4
  141. package/lib/commonjs/skia/Paint/usePaint.js.map +1 -1
  142. package/lib/commonjs/skia/Shader/useShader.js +4 -1
  143. package/lib/commonjs/skia/Shader/useShader.js.map +1 -1
  144. package/lib/commonjs/skia/Skia.js +3 -43
  145. package/lib/commonjs/skia/Skia.js.map +1 -1
  146. package/lib/commonjs/skia/SkiaApi.js +4 -0
  147. package/lib/commonjs/skia/SkiaApi.js.map +1 -0
  148. package/lib/commonjs/values/api.js +4 -6
  149. package/lib/commonjs/values/api.js.map +1 -1
  150. package/lib/commonjs/values/api.web.js +18 -0
  151. package/lib/commonjs/values/api.web.js.map +1 -0
  152. package/lib/commonjs/values/index.js +0 -13
  153. package/lib/commonjs/values/index.js.map +1 -1
  154. package/lib/commonjs/values/web/RNSkAnimation.js +46 -0
  155. package/lib/commonjs/values/web/RNSkAnimation.js.map +1 -0
  156. package/lib/commonjs/values/web/RNSkClockValue.js +75 -0
  157. package/lib/commonjs/values/web/RNSkClockValue.js.map +1 -0
  158. package/lib/commonjs/values/web/RNSkDerivedValue.js +51 -0
  159. package/lib/commonjs/values/web/RNSkDerivedValue.js.map +1 -0
  160. package/lib/commonjs/values/web/RNSkReadonlyValue.js +45 -0
  161. package/lib/commonjs/values/web/RNSkReadonlyValue.js.map +1 -0
  162. package/lib/commonjs/values/web/RNSkValue.js +73 -0
  163. package/lib/commonjs/values/web/RNSkValue.js.map +1 -0
  164. package/lib/commonjs/values/web/api.js +31 -0
  165. package/lib/commonjs/values/web/api.js.map +1 -0
  166. package/lib/commonjs/values/web/index.js +19 -0
  167. package/lib/commonjs/values/web/index.js.map +1 -0
  168. package/lib/commonjs/views/SkiaView.js +13 -10
  169. package/lib/commonjs/views/SkiaView.js.map +1 -1
  170. package/lib/commonjs/views/api.js +11 -0
  171. package/lib/commonjs/views/api.js.map +1 -0
  172. package/lib/commonjs/views/types.js.map +1 -1
  173. package/lib/module/{values/animation → animation}/decay/decay.js +0 -0
  174. package/lib/module/{values/animation → animation}/decay/decay.js.map +0 -0
  175. package/lib/module/{values/animation → animation}/decay/index.js +0 -0
  176. package/lib/module/{values/animation → animation}/decay/index.js.map +0 -0
  177. package/lib/module/{values/animation → animation}/decay/runDecay.js +1 -1
  178. package/lib/module/animation/decay/runDecay.js.map +1 -0
  179. package/lib/module/{values/animation → animation}/decay/types.js +0 -0
  180. package/lib/module/{values/animation → animation}/decay/types.js.map +0 -0
  181. package/lib/module/{values/animation → animation}/functions/index.js +0 -0
  182. package/lib/module/{values/animation → animation}/functions/index.js.map +0 -0
  183. package/lib/module/animation/functions/interpolate.js +132 -0
  184. package/lib/module/animation/functions/interpolate.js.map +1 -0
  185. package/lib/module/animation/functions/interpolateColors.js +23 -0
  186. package/lib/module/animation/functions/interpolateColors.js.map +1 -0
  187. package/lib/module/{values/animation → animation}/index.js +0 -0
  188. package/lib/module/{values/animation → animation}/index.js.map +0 -0
  189. package/lib/module/{values/animation → animation}/spring/Spring.js +0 -0
  190. package/lib/module/{values/animation → animation}/spring/Spring.js.map +0 -0
  191. package/lib/module/{values/animation → animation}/spring/functions/index.js +0 -0
  192. package/lib/module/{values/animation → animation}/spring/functions/index.js.map +0 -0
  193. package/lib/module/{values/animation → animation}/spring/functions/spring.js +0 -0
  194. package/lib/module/{values/animation → animation}/spring/functions/spring.js.map +0 -0
  195. package/lib/module/{values/animation → animation}/spring/index.js +0 -0
  196. package/lib/module/{values/animation → animation}/spring/index.js.map +0 -0
  197. package/lib/module/{values/animation → animation}/spring/runSpring.js +0 -0
  198. package/lib/module/animation/spring/runSpring.js.map +1 -0
  199. package/lib/module/{values/animation → animation}/spring/types.js +0 -0
  200. package/lib/module/{values/animation → animation}/spring/types.js.map +0 -0
  201. package/lib/module/{values/animation → animation}/spring/useSpring.js +0 -0
  202. package/lib/module/animation/spring/useSpring.js.map +1 -0
  203. package/lib/module/{values/animation → animation}/timing/Easing.js +0 -0
  204. package/lib/module/{values/animation → animation}/timing/Easing.js.map +0 -0
  205. package/lib/module/{values/animation → animation}/timing/createTiming.js +1 -1
  206. package/lib/module/animation/timing/createTiming.js.map +1 -0
  207. package/lib/module/{values/animation → animation}/timing/functions/bezier.js +0 -0
  208. package/lib/module/{values/animation → animation}/timing/functions/bezier.js.map +0 -0
  209. package/lib/module/{values/animation → animation}/timing/functions/getResolvedParams.js +3 -3
  210. package/lib/module/animation/timing/functions/getResolvedParams.js.map +1 -0
  211. package/lib/module/{values/animation → animation}/timing/functions/index.js +0 -0
  212. package/lib/module/{values/animation → animation}/timing/functions/index.js.map +0 -0
  213. package/lib/module/{values/animation → animation}/timing/functions/timing.js +0 -0
  214. package/lib/module/{values/animation → animation}/timing/functions/timing.js.map +1 -1
  215. package/lib/module/{values/animation → animation}/timing/functions/types.js +0 -0
  216. package/lib/module/{values/animation → animation}/timing/functions/types.js.map +0 -0
  217. package/lib/module/{values/animation → animation}/timing/index.js +0 -0
  218. package/lib/module/{values/animation → animation}/timing/index.js.map +0 -0
  219. package/lib/module/{values/animation → animation}/timing/runTiming.js +0 -0
  220. package/lib/module/animation/timing/runTiming.js.map +1 -0
  221. package/lib/module/{values/animation → animation}/timing/useLoop.js +0 -0
  222. package/lib/module/{values/animation → animation}/timing/useLoop.js.map +0 -0
  223. package/lib/module/{values/animation → animation}/timing/useTiming.js +1 -1
  224. package/lib/module/animation/timing/useTiming.js.map +1 -0
  225. package/lib/module/{values/animation → animation}/types.js +0 -0
  226. package/lib/module/{values/animation → animation}/types.js.map +0 -0
  227. package/lib/module/index.js +1 -0
  228. package/lib/module/index.js.map +1 -1
  229. package/lib/module/renderer/Canvas.js +12 -6
  230. package/lib/module/renderer/Canvas.js.map +1 -1
  231. package/lib/module/renderer/components/Paint.js +2 -2
  232. package/lib/module/renderer/components/Paint.js.map +1 -1
  233. package/lib/module/renderer/components/colorFilters/BlendColor.js.map +1 -1
  234. package/lib/module/renderer/components/colorFilters/Lerp.js +1 -1
  235. package/lib/module/renderer/components/colorFilters/Lerp.js.map +1 -1
  236. package/lib/module/renderer/components/imageFilters/InnerShadow.js +3 -2
  237. package/lib/module/renderer/components/imageFilters/InnerShadow.js.map +1 -1
  238. package/lib/module/renderer/components/imageFilters/RuntimeShader.js +19 -0
  239. package/lib/module/renderer/components/imageFilters/RuntimeShader.js.map +1 -0
  240. package/lib/module/renderer/components/imageFilters/index.js +1 -0
  241. package/lib/module/renderer/components/imageFilters/index.js.map +1 -1
  242. package/lib/module/renderer/components/shaders/Gradient.js +2 -2
  243. package/lib/module/renderer/components/shaders/Gradient.js.map +1 -1
  244. package/lib/module/renderer/components/shaders/Shader.js +3 -2
  245. package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
  246. package/lib/module/renderer/components/shapes/Path.js +9 -2
  247. package/lib/module/renderer/components/shapes/Path.js.map +1 -1
  248. package/lib/module/renderer/processors/Circles.js +3 -2
  249. package/lib/module/renderer/processors/Circles.js.map +1 -1
  250. package/lib/module/renderer/processors/Font.js +1 -1
  251. package/lib/module/renderer/processors/Font.js.map +1 -1
  252. package/lib/module/renderer/processors/Paint.js +6 -1
  253. package/lib/module/renderer/processors/Paint.js.map +1 -1
  254. package/lib/module/renderer/processors/Rects.js +9 -21
  255. package/lib/module/renderer/processors/Rects.js.map +1 -1
  256. package/lib/module/renderer/processors/math/Matrix3.js +52 -72
  257. package/lib/module/renderer/processors/math/Matrix3.js.map +1 -1
  258. package/lib/module/renderer/processors/math/Vector.js +3 -5
  259. package/lib/module/renderer/processors/math/Vector.js.map +1 -1
  260. package/lib/module/skia/Color.js +9 -25
  261. package/lib/module/skia/Color.js.map +1 -1
  262. package/lib/module/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
  263. package/lib/module/skia/Matrix.js.map +1 -1
  264. package/lib/module/skia/Paint/Paint.js +6 -0
  265. package/lib/module/skia/Paint/Paint.js.map +1 -1
  266. package/lib/module/skia/Paint/usePaint.js +2 -3
  267. package/lib/module/skia/Paint/usePaint.js.map +1 -1
  268. package/lib/module/skia/Shader/useShader.js +4 -1
  269. package/lib/module/skia/Shader/useShader.js.map +1 -1
  270. package/lib/module/skia/Skia.js +2 -44
  271. package/lib/module/skia/Skia.js.map +1 -1
  272. package/lib/module/skia/SkiaApi.js +2 -0
  273. package/lib/module/skia/SkiaApi.js.map +1 -0
  274. package/lib/module/values/api.js +4 -6
  275. package/lib/module/values/api.js.map +1 -1
  276. package/lib/module/values/api.web.js +7 -0
  277. package/lib/module/values/api.web.js.map +1 -0
  278. package/lib/module/values/index.js +0 -1
  279. package/lib/module/values/index.js.map +1 -1
  280. package/lib/module/values/web/RNSkAnimation.js +36 -0
  281. package/lib/module/values/web/RNSkAnimation.js.map +1 -0
  282. package/lib/module/values/web/RNSkClockValue.js +65 -0
  283. package/lib/module/values/web/RNSkClockValue.js.map +1 -0
  284. package/lib/module/values/web/RNSkDerivedValue.js +41 -0
  285. package/lib/module/values/web/RNSkDerivedValue.js.map +1 -0
  286. package/lib/module/values/web/RNSkReadonlyValue.js +36 -0
  287. package/lib/module/values/web/RNSkReadonlyValue.js.map +1 -0
  288. package/lib/module/values/web/RNSkValue.js +63 -0
  289. package/lib/module/values/web/RNSkValue.js.map +1 -0
  290. package/lib/module/values/web/api.js +19 -0
  291. package/lib/module/values/web/api.js.map +1 -0
  292. package/lib/module/values/web/index.js +2 -0
  293. package/lib/module/values/web/index.js.map +1 -0
  294. package/lib/module/views/SkiaView.js +1 -3
  295. package/lib/module/views/SkiaView.js.map +1 -1
  296. package/lib/module/views/api.js +4 -0
  297. package/lib/module/views/api.js.map +1 -0
  298. package/lib/module/views/types.js.map +1 -1
  299. package/lib/typescript/src/{values/animation → animation}/decay/decay.d.ts +0 -0
  300. package/lib/typescript/src/{values/animation → animation}/decay/index.d.ts +0 -0
  301. package/lib/typescript/src/{values/animation → animation}/decay/runDecay.d.ts +2 -2
  302. package/lib/typescript/src/{values/animation → animation}/decay/types.d.ts +1 -1
  303. package/lib/typescript/src/{values/animation → animation}/functions/index.d.ts +0 -0
  304. package/lib/typescript/src/animation/functions/interpolate.d.ts +11 -0
  305. package/lib/typescript/src/animation/functions/interpolateColors.d.ts +3 -0
  306. package/lib/typescript/src/{values/animation → animation}/index.d.ts +0 -0
  307. package/lib/typescript/src/{values/animation → animation}/spring/Spring.d.ts +0 -0
  308. package/lib/typescript/src/{values/animation → animation}/spring/functions/index.d.ts +0 -0
  309. package/lib/typescript/src/{values/animation → animation}/spring/functions/spring.d.ts +0 -0
  310. package/lib/typescript/src/{values/animation → animation}/spring/index.d.ts +0 -0
  311. package/lib/typescript/src/{values/animation → animation}/spring/runSpring.d.ts +1 -1
  312. package/lib/typescript/src/{values/animation → animation}/spring/types.d.ts +0 -0
  313. package/lib/typescript/src/{values/animation → animation}/spring/useSpring.d.ts +1 -1
  314. package/lib/typescript/src/{values/animation → animation}/timing/Easing.d.ts +0 -0
  315. package/lib/typescript/src/{values/animation → animation}/timing/createTiming.d.ts +2 -2
  316. package/lib/typescript/src/{values/animation → animation}/timing/functions/bezier.d.ts +0 -0
  317. package/lib/typescript/src/{values/animation → animation}/timing/functions/getResolvedParams.d.ts +0 -0
  318. package/lib/typescript/src/{values/animation → animation}/timing/functions/index.d.ts +0 -0
  319. package/lib/typescript/src/{values/animation → animation}/timing/functions/timing.d.ts +1 -1
  320. package/lib/typescript/src/{values/animation → animation}/timing/functions/types.d.ts +0 -0
  321. package/lib/typescript/src/{values/animation → animation}/timing/index.d.ts +0 -0
  322. package/lib/typescript/src/{values/animation → animation}/timing/runTiming.d.ts +1 -1
  323. package/lib/typescript/src/{values/animation → animation}/timing/useLoop.d.ts +0 -0
  324. package/lib/typescript/src/{values/animation → animation}/timing/useTiming.d.ts +1 -1
  325. package/lib/typescript/src/{values/animation → animation}/types.d.ts +5 -5
  326. package/lib/typescript/src/index.d.ts +1 -0
  327. package/lib/typescript/src/renderer/Canvas.d.ts +6 -0
  328. package/lib/typescript/src/renderer/components/colorFilters/BlendColor.d.ts +1 -1
  329. package/lib/typescript/src/renderer/components/imageFilters/RuntimeShader.d.ts +7 -0
  330. package/lib/typescript/src/renderer/components/imageFilters/index.d.ts +1 -0
  331. package/lib/typescript/src/renderer/components/shaders/Gradient.d.ts +1 -1
  332. package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +2 -2
  333. package/lib/typescript/src/renderer/components/shapes/Circle.d.ts +1 -4
  334. package/lib/typescript/src/renderer/components/shapes/Path.d.ts +3 -1
  335. package/lib/typescript/src/renderer/processors/Paint.d.ts +2 -1
  336. package/lib/typescript/src/renderer/processors/Rects.d.ts +9 -41
  337. package/lib/typescript/src/renderer/processors/math/Matrix3.d.ts +1 -5
  338. package/lib/typescript/src/renderer/processors/math/Vector.d.ts +5 -17
  339. package/lib/typescript/src/skia/Color.d.ts +8 -9
  340. package/lib/typescript/src/skia/ImageFilter/ImageFilterFactory.d.ts +16 -0
  341. package/lib/typescript/src/skia/Matrix.d.ts +7 -1
  342. package/lib/typescript/src/skia/Paint/Paint.d.ts +1 -0
  343. package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffect.d.ts +2 -1
  344. package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffectFactory.d.ts +2 -2
  345. package/lib/typescript/src/skia/Shader/useShader.d.ts +1 -1
  346. package/lib/typescript/src/skia/Skia.d.ts +28 -95
  347. package/lib/typescript/src/skia/SkiaApi.d.ts +71 -0
  348. package/lib/typescript/src/skia/Surface/Surface.d.ts +1 -1
  349. package/lib/typescript/src/skia/Surface/SurfaceFactory.d.ts +2 -2
  350. package/lib/typescript/src/values/api.d.ts +2 -25
  351. package/lib/typescript/src/values/api.web.d.ts +2 -0
  352. package/lib/typescript/src/values/index.d.ts +0 -1
  353. package/lib/typescript/src/values/types.d.ts +24 -1
  354. package/lib/typescript/src/values/web/RNSkAnimation.d.ts +9 -0
  355. package/lib/typescript/src/values/web/RNSkClockValue.d.ts +13 -0
  356. package/lib/typescript/src/values/web/RNSkDerivedValue.d.ts +9 -0
  357. package/lib/typescript/src/values/web/RNSkReadonlyValue.d.ts +11 -0
  358. package/lib/typescript/src/values/web/RNSkValue.d.ts +14 -0
  359. package/lib/typescript/src/values/web/api.d.ts +2 -0
  360. package/lib/typescript/src/values/web/index.d.ts +1 -0
  361. package/lib/typescript/src/views/SkiaView.d.ts +3 -36
  362. package/lib/typescript/src/views/api.d.ts +5 -0
  363. package/lib/typescript/src/views/types.d.ts +32 -0
  364. package/package.json +2 -2
  365. package/src/{values/animation → animation}/decay/decay.ts +0 -0
  366. package/src/{values/animation → animation}/decay/index.ts +0 -0
  367. package/src/{values/animation → animation}/decay/runDecay.ts +2 -2
  368. package/src/{values/animation → animation}/decay/types.ts +1 -1
  369. package/src/{values/animation → animation}/functions/index.ts +0 -0
  370. package/src/animation/functions/interpolate.ts +182 -0
  371. package/src/animation/functions/interpolateColors.ts +58 -0
  372. package/src/{values/animation → animation}/index.ts +0 -0
  373. package/src/{values/animation → animation}/spring/Spring.ts +0 -0
  374. package/src/{values/animation → animation}/spring/functions/index.ts +0 -0
  375. package/src/{values/animation → animation}/spring/functions/spring.ts +0 -0
  376. package/src/{values/animation → animation}/spring/index.ts +0 -0
  377. package/src/{values/animation → animation}/spring/runSpring.ts +1 -1
  378. package/src/{values/animation → animation}/spring/types.ts +0 -0
  379. package/src/{values/animation → animation}/spring/useSpring.ts +1 -1
  380. package/src/{values/animation → animation}/timing/Easing.ts +0 -0
  381. package/src/{values/animation → animation}/timing/createTiming.ts +2 -2
  382. package/src/{values/animation → animation}/timing/functions/__tests__/timing.spec.ts +0 -0
  383. package/src/{values/animation → animation}/timing/functions/bezier.ts +0 -0
  384. package/src/{values/animation → animation}/timing/functions/getResolvedParams.ts +2 -2
  385. package/src/{values/animation → animation}/timing/functions/index.ts +0 -0
  386. package/src/{values/animation → animation}/timing/functions/timing.ts +1 -1
  387. package/src/{values/animation → animation}/timing/functions/types.ts +0 -0
  388. package/src/{values/animation → animation}/timing/index.ts +0 -0
  389. package/src/{values/animation → animation}/timing/runTiming.ts +1 -1
  390. package/src/{values/animation → animation}/timing/useLoop.ts +0 -0
  391. package/src/{values/animation → animation}/timing/useTiming.ts +2 -2
  392. package/src/{values/animation → animation}/types.ts +5 -5
  393. package/src/index.ts +1 -0
  394. package/src/renderer/Canvas.tsx +13 -6
  395. package/src/renderer/components/Paint.tsx +2 -2
  396. package/src/renderer/components/colorFilters/BlendColor.tsx +1 -1
  397. package/src/renderer/components/colorFilters/Lerp.tsx +1 -1
  398. package/src/renderer/components/imageFilters/InnerShadow.tsx +4 -2
  399. package/src/renderer/components/imageFilters/RuntimeShader.tsx +23 -0
  400. package/src/renderer/components/imageFilters/index.ts +1 -0
  401. package/src/renderer/components/shaders/Gradient.ts +2 -4
  402. package/src/renderer/components/shaders/Shader.tsx +3 -3
  403. package/src/renderer/components/shapes/Path.tsx +11 -3
  404. package/src/renderer/processors/Circles.ts +2 -1
  405. package/src/renderer/processors/Font.ts +1 -1
  406. package/src/renderer/processors/Paint.ts +5 -0
  407. package/src/renderer/processors/Rects.ts +9 -14
  408. package/src/renderer/processors/math/Matrix3.ts +24 -105
  409. package/src/renderer/processors/math/Vector.ts +3 -2
  410. package/src/skia/Color.ts +13 -27
  411. package/src/skia/ImageFilter/ImageFilterFactory.ts +20 -0
  412. package/src/skia/Matrix.ts +8 -1
  413. package/src/skia/Paint/Paint.ts +7 -0
  414. package/src/skia/Paint/usePaint.ts +2 -4
  415. package/src/skia/RuntimeEffect/RuntimeEffect.ts +3 -1
  416. package/src/skia/RuntimeEffect/RuntimeEffectFactory.ts +2 -2
  417. package/src/skia/Shader/useShader.ts +4 -1
  418. package/src/skia/Skia.ts +4 -123
  419. package/src/skia/SkiaApi.ts +86 -0
  420. package/src/skia/Surface/Surface.ts +1 -1
  421. package/src/skia/Surface/SurfaceFactory.ts +2 -2
  422. package/src/values/api.ts +3 -42
  423. package/src/values/api.web.ts +5 -0
  424. package/src/values/index.ts +0 -1
  425. package/src/values/types.ts +30 -1
  426. package/src/values/web/RNSkAnimation.ts +33 -0
  427. package/src/values/web/RNSkClockValue.ts +58 -0
  428. package/src/values/web/RNSkDerivedValue.ts +38 -0
  429. package/src/values/web/RNSkReadonlyValue.ts +32 -0
  430. package/src/values/web/RNSkValue.ts +57 -0
  431. package/src/values/web/__tests__/RNSkAnimation.spec.ts +21 -0
  432. package/src/values/web/__tests__/RNSkDerivedValue.spec.ts +15 -0
  433. package/src/values/web/__tests__/RNSkReadonlyValue.spec.ts +8 -0
  434. package/src/values/web/__tests__/RNSkValue.spec.ts +11 -0
  435. package/src/values/web/api.ts +33 -0
  436. package/src/values/web/index.ts +1 -0
  437. package/src/views/SkiaView.tsx +3 -49
  438. package/src/views/api.ts +7 -0
  439. package/src/views/types.ts +40 -0
  440. package/lib/commonjs/values/animation/decay/runDecay.js.map +0 -1
  441. package/lib/commonjs/values/animation/functions/interpolate.js +0 -139
  442. package/lib/commonjs/values/animation/functions/interpolate.js.map +0 -1
  443. package/lib/commonjs/values/animation/functions/interpolateColors.js +0 -47
  444. package/lib/commonjs/values/animation/functions/interpolateColors.js.map +0 -1
  445. package/lib/commonjs/values/animation/spring/runSpring.js.map +0 -1
  446. package/lib/commonjs/values/animation/spring/useSpring.js.map +0 -1
  447. package/lib/commonjs/values/animation/timing/createTiming.js.map +0 -1
  448. package/lib/commonjs/values/animation/timing/functions/getResolvedParams.js.map +0 -1
  449. package/lib/commonjs/values/animation/timing/runTiming.js.map +0 -1
  450. package/lib/commonjs/values/animation/timing/useTiming.js.map +0 -1
  451. package/lib/module/values/animation/decay/runDecay.js.map +0 -1
  452. package/lib/module/values/animation/functions/interpolate.js +0 -132
  453. package/lib/module/values/animation/functions/interpolate.js.map +0 -1
  454. package/lib/module/values/animation/functions/interpolateColors.js +0 -32
  455. package/lib/module/values/animation/functions/interpolateColors.js.map +0 -1
  456. package/lib/module/values/animation/spring/runSpring.js.map +0 -1
  457. package/lib/module/values/animation/spring/useSpring.js.map +0 -1
  458. package/lib/module/values/animation/timing/createTiming.js.map +0 -1
  459. package/lib/module/values/animation/timing/functions/getResolvedParams.js.map +0 -1
  460. package/lib/module/values/animation/timing/runTiming.js.map +0 -1
  461. package/lib/module/values/animation/timing/useTiming.js.map +0 -1
  462. package/lib/typescript/scripts/install-npm.d.ts +0 -1
  463. package/lib/typescript/src/values/animation/functions/interpolate.d.ts +0 -7
  464. package/lib/typescript/src/values/animation/functions/interpolateColors.d.ts +0 -3
  465. package/src/values/animation/functions/interpolate.ts +0 -169
  466. package/src/values/animation/functions/interpolateColors.ts +0 -62
@@ -31,13 +31,17 @@ add_library(
31
31
  "${PROJECT_SOURCE_DIR}/cpp/jni/JniSkiaManager.cpp"
32
32
  "${PROJECT_SOURCE_DIR}/cpp/jni/JniSkiaDrawView.cpp"
33
33
  "${PROJECT_SOURCE_DIR}/cpp/jni/JniPlatformContext.cpp"
34
- "${PROJECT_SOURCE_DIR}/cpp/jni/SkiaOpenGLRenderer.cpp"
34
+ "${PROJECT_SOURCE_DIR}/cpp/rnskia-android/RNSkDrawViewImpl.cpp"
35
+ "${PROJECT_SOURCE_DIR}/cpp/rnskia-android/SkiaOpenGLRenderer.cpp"
35
36
 
36
37
  "${PROJECT_SOURCE_DIR}/cpp/jsi/JsiHostObject.cpp"
37
38
 
38
39
  "${PROJECT_SOURCE_DIR}/cpp/rnskia/RNSkManager.cpp"
39
40
  "${PROJECT_SOURCE_DIR}/cpp/rnskia/RNSkDrawView.cpp"
40
41
  "${PROJECT_SOURCE_DIR}/cpp/rnskia/RNSkDispatchQueue.cpp"
42
+
43
+
44
+ "${PROJECT_SOURCE_DIR}/cpp/api/third_party/CSSColorParser.cpp"
41
45
 
42
46
  )
43
47
 
@@ -64,6 +68,7 @@ target_include_directories(
64
68
  cpp/api
65
69
  cpp/jsi
66
70
  cpp/jni/include
71
+ cpp/rnskia-android
67
72
  cpp/rnskia
68
73
  cpp/rnskia/values
69
74
  cpp/utils
@@ -175,7 +175,7 @@ dependencies {
175
175
  //noinspection GradleDynamicVersion
176
176
  extractJNI("com.facebook.fbjni:fbjni:0.2.2")
177
177
 
178
- def rnAAR = fileTree("${rootDir}/../node_modules/react-native/android").matching({ it.include "**/**/*.aar" }).singleFile
178
+ def rnAAR = fileTree("${nodeModules}/react-native/android").matching({ it.include "**/**/*.aar" }).singleFile
179
179
  extractJNI(files(rnAAR))
180
180
  }
181
181
 
@@ -31,16 +31,13 @@ namespace RNSkia
31
31
  /**** DTOR ***/
32
32
  JniSkiaDrawView::~JniSkiaDrawView()
33
33
  {
34
- #if LOG_ALL_DRAWING
35
- RNSkLogger::logToConsole("JniSkiaDrawView::~JniSkiaDrawView %i", getNativeId());
36
- #endif
37
34
  }
38
35
 
39
36
  /**** JNI ****/
40
37
 
41
38
  TSelf JniSkiaDrawView::initHybrid(
42
- alias_ref<HybridClass::jhybridobject> jThis,
43
- JavaSkiaManager skiaManager)
39
+ alias_ref<HybridClass::jhybridobject> jThis,
40
+ JavaSkiaManager skiaManager)
44
41
  {
45
42
  return makeCxxInstance(jThis, skiaManager);
46
43
  }
@@ -60,17 +57,17 @@ namespace RNSkia
60
57
  {
61
58
  if (mode.compare("continuous") == 0)
62
59
  {
63
- setDrawingMode(RNSkDrawingMode::Continuous);
60
+ _drawView->setDrawingMode(RNSkDrawingMode::Continuous);
64
61
  }
65
62
  else
66
63
  {
67
- setDrawingMode(RNSkDrawingMode::Default);
64
+ _drawView->setDrawingMode(RNSkDrawingMode::Default);
68
65
  }
69
66
  }
70
67
 
71
68
  void JniSkiaDrawView::setDebugMode(bool show)
72
69
  {
73
- setShowDebugOverlays(show);
70
+ _drawView->setShowDebugOverlays(show);
74
71
  }
75
72
 
76
73
  void JniSkiaDrawView::updateTouchPoints(jni::JArrayDouble touches)
@@ -78,7 +75,7 @@ namespace RNSkia
78
75
  // Create touch points
79
76
  std::vector<RNSkia::RNSkTouchPoint> points;
80
77
  auto pin = touches.pin();
81
- auto scale = getPlatformContext()->getPixelDensity();
78
+ auto scale = _drawView->getPixelDensity();
82
79
  points.reserve(pin.size() / 4);
83
80
  for (size_t i = 0; i < pin.size(); i += 4)
84
81
  {
@@ -89,81 +86,27 @@ namespace RNSkia
89
86
  point.type = (RNSkia::RNSkTouchType)pin[i + 3];
90
87
  points.push_back(point);
91
88
  }
92
- updateTouchState(std::move(points));
89
+ _drawView->updateTouchState(std::move(points));
93
90
  }
94
91
 
95
92
  void JniSkiaDrawView::surfaceAvailable(jobject surface, int width, int height)
96
93
  {
97
- #if LOG_ALL_DRAWING
98
- RNSkLogger::logToConsole("JniSkiaDrawView::surfaceAvailable %i", getNativeId());
99
- #endif
100
-
101
- _width = width;
102
- _height = height;
103
-
104
- if (_renderer == nullptr)
105
- {
106
- // Create renderer!
107
- _renderer = new SkiaOpenGLRenderer(
108
- ANativeWindow_fromSurface(Environment::current(), surface), getNativeId());
109
-
110
- // Set the draw function
111
- setNativeDrawFunc(std::bind(&JniSkiaDrawView::drawFrame, this, std::placeholders::_1));
112
-
113
- // Redraw
114
- requestRedraw();
115
- }
94
+ _drawView->surfaceAvailable(ANativeWindow_fromSurface(Environment::current(), surface), width, height);
116
95
  }
117
96
 
118
97
  void JniSkiaDrawView::surfaceSizeChanged(int width, int height)
119
98
  {
120
- #if LOG_ALL_DRAWING
121
- RNSkLogger::logToConsole("JniSkiaDrawView::surfaceSizeChanged %i", getNativeId());
122
- #endif
123
-
124
- _width = width;
125
- _height = height;
126
-
127
- // Redraw after size change
128
- requestRedraw();
99
+ _drawView->surfaceSizeChanged(width, height);
129
100
  }
130
101
 
131
102
  void JniSkiaDrawView::surfaceDestroyed()
132
103
  {
133
- #if LOG_ALL_DRAWING
134
- RNSkLogger::logToConsole("JniSkiaDrawView::surfaceDestroyed %i", getNativeId());
135
- #endif
136
- if (_renderer != nullptr)
137
- {
138
- // Turn off drawing
139
- setNativeDrawFunc(nullptr);
140
-
141
- // Start teardown
142
- _renderer->teardown();
143
-
144
- // Ask for a redraw to tear down the render pipeline. This
145
- // needs to be done on the render thread since OpenGL demands
146
- // same thread access for OpenGL contexts.
147
- getPlatformContext()->runOnRenderThread([this]()
148
- {
149
- if(_renderer != nullptr) {
150
- _renderer->run(nullptr, 0, 0);
151
- } });
152
-
153
- // Wait until the above render has finished.
154
- _renderer->waitForTeardown();
155
-
156
- // Delete renderer. All resources should be released during teardown.
157
- delete _renderer;
158
- _renderer = nullptr;
159
- }
104
+ _drawView->surfaceDestroyed();
160
105
  }
161
106
 
162
- /**** Render method ****/
163
-
164
- void JniSkiaDrawView::drawFrame(const sk_sp<SkPicture> picture)
165
- {
166
- // No need to check if the renderer is nullptr since we only get here if it is not.
167
- _renderer->run(picture, _width, _height);
107
+ void JniSkiaDrawView::releaseSurface() {
108
+ jni::ThreadScope ts;
109
+ static auto method = javaPart_->getClass()->getMethod<void(void)>("releaseSurface");
110
+ method(javaPart_.get());
168
111
  }
169
112
  } // namespace RNSkia
@@ -47,7 +47,7 @@ void JniSkiaManager::initializeRuntime() {
47
47
  }
48
48
 
49
49
  void JniSkiaManager::registerSkiaView(int viewTag, JniSkiaDrawView *skiaView) {
50
- _skManager->registerSkiaDrawView(viewTag, skiaView);
50
+ _skManager->registerSkiaDrawView(viewTag, skiaView->getDrawViewImpl());
51
51
  }
52
52
 
53
53
  void JniSkiaManager::unregisterSkiaView(int viewTag) {
@@ -5,17 +5,16 @@
5
5
  #include <thread>
6
6
  #include <string>
7
7
 
8
- #include <EGL/egl.h>
9
- #include <GLES2/gl2.h>
10
8
  #include <fbjni/fbjni.h>
11
9
  #include <jni.h>
12
10
  #include <jsi/jsi.h>
13
11
  #include <thread>
14
12
 
15
13
  #include <RNSkDrawView.h>
16
- #include "JniSkiaManager.h"
17
- #include "JniSkiaDrawView.h"
18
- #include "SkiaOpenGLRenderer.h"
14
+ #include <JniSkiaManager.h>
15
+ #include <JniSkiaDrawView.h>
16
+
17
+ #include <RNSkDrawViewImpl.h>
19
18
 
20
19
  #include <SkSurface.h>
21
20
  #include <SkRefCnt.h>
@@ -31,16 +30,15 @@ namespace RNSkia
31
30
 
32
31
  using JavaSkiaManager = jni::alias_ref<JniSkiaManager::javaobject>;
33
32
 
34
- class JniSkiaDrawView : public jni::HybridClass<JniSkiaDrawView>,
35
- public RNSkDrawView
33
+ class JniSkiaDrawView : public jni::HybridClass<JniSkiaDrawView>
36
34
  {
37
35
  public:
38
36
  static auto constexpr kJavaDescriptor = "Lcom/shopify/reactnative/skia/SkiaDrawView;";
39
37
  static auto constexpr TAG = "ReactNativeSkia";
40
38
 
41
39
  static jni::local_ref<jhybriddata> initHybrid(
42
- jni::alias_ref<jhybridobject>,
43
- JavaSkiaManager);
40
+ jni::alias_ref<jhybridobject>,
41
+ JavaSkiaManager);
44
42
 
45
43
  static void registerNatives();
46
44
 
@@ -52,30 +50,28 @@ namespace RNSkia
52
50
 
53
51
  ~JniSkiaDrawView();
54
52
 
55
- protected:
56
- int getWidth() override { return _width; }
57
- int getHeight() override { return _height; }
53
+ std::shared_ptr<RNSkDrawView> getDrawViewImpl() { return _drawView; }
54
+
55
+ void releaseSurface();
58
56
 
57
+ protected:
59
58
  void setMode(std::string mode);
60
59
  void setDebugMode(bool show);
61
60
 
62
61
  private:
63
62
  friend HybridBase;
64
63
 
65
- void drawFrame(const sk_sp<SkPicture> picture);
66
-
67
- int _width = 0;
68
- int _height = 0;
69
-
70
- SkiaOpenGLRenderer* _renderer = nullptr;
64
+ std::shared_ptr<RNSkDrawViewImpl> _drawView;
71
65
 
72
66
  jni::global_ref<JniSkiaDrawView::javaobject> javaPart_;
73
67
 
74
68
  explicit JniSkiaDrawView(
75
- jni::alias_ref<JniSkiaDrawView::jhybridobject> jThis,
76
- JavaSkiaManager skiaManager)
77
- : javaPart_(jni::make_global(jThis)),
78
- RNSkDrawView(skiaManager->cthis()->getPlatformContext()) {
69
+ jni::alias_ref<JniSkiaDrawView::jhybridobject> jThis,
70
+ JavaSkiaManager skiaManager)
71
+ : javaPart_(jni::make_global(jThis)),
72
+ _drawView(std::make_shared<RNSkDrawViewImpl>(skiaManager->cthis()->getPlatformContext(), [this]() {
73
+ releaseSurface();
74
+ })) {
79
75
  }
80
76
  };
81
77
 
@@ -7,7 +7,7 @@
7
7
  #include <memory>
8
8
 
9
9
  #include <JniPlatformContext.h>
10
- #include <JniPlatformContextWrapper.h>
10
+ #include <RNSkPlatformContextImpl.h>
11
11
 
12
12
  #include <RNSkLog.h>
13
13
 
@@ -48,14 +48,14 @@ class JniSkiaManager : public jni::HybridClass<JniSkiaManager> {
48
48
  : _javaPart(jni::make_global(jThis)),
49
49
  _jsRuntime(runtime),
50
50
  _jsCallInvoker(jsCallInvoker),
51
- _context(std::make_shared<JniPlatformContextWrapper>(platformContext, runtime, jsCallInvoker)) {
51
+ _context(std::make_shared<RNSkPlatformContextImpl>(platformContext, runtime, jsCallInvoker)) {
52
52
 
53
53
  }
54
54
 
55
55
  void registerSkiaView(int viewTag, JniSkiaDrawView *skiaView);
56
56
  void unregisterSkiaView(int viewTag);
57
57
 
58
- std::shared_ptr<JniPlatformContextWrapper> getPlatformContext() { return _context; }
58
+ std::shared_ptr<RNSkPlatformContextImpl> getPlatformContext() { return _context; }
59
59
 
60
60
  void invalidate() {
61
61
  _context->stopDrawLoop();
@@ -73,7 +73,7 @@ class JniSkiaManager : public jni::HybridClass<JniSkiaManager> {
73
73
 
74
74
  jsi::Runtime *_jsRuntime;
75
75
  std::shared_ptr<facebook::react::CallInvoker> _jsCallInvoker;
76
- std::shared_ptr<JniPlatformContextWrapper> _context;
76
+ std::shared_ptr<RNSkPlatformContextImpl> _context;
77
77
 
78
78
  void initializeRuntime();
79
79
  };
@@ -0,0 +1,68 @@
1
+ #include <RNSkDrawViewImpl.h>
2
+
3
+ #pragma clang diagnostic push
4
+ #pragma clang diagnostic ignored "-Wdocumentation"
5
+
6
+ #include <SkSurface.h>
7
+ #include <SkCanvas.h>
8
+
9
+ #pragma clang diagnostic pop
10
+
11
+ #include <RNSkLog.h>
12
+
13
+ namespace RNSkia {
14
+ RNSkDrawViewImpl::RNSkDrawViewImpl(std::shared_ptr <RNSkia::RNSkPlatformContext> context, std::function<void()> releaseSurfaceCallback) :
15
+ RNSkia::RNSkDrawView(context),
16
+ _releaseSurfaceCallback(std::move(releaseSurfaceCallback)) {}
17
+
18
+ void RNSkDrawViewImpl::surfaceAvailable(ANativeWindow* surface, int width, int height) {
19
+ _scaledWidth = width;
20
+ _scaledHeight = height;
21
+
22
+ if (_renderer == nullptr)
23
+ {
24
+ // Create renderer!
25
+ _renderer = std::make_unique<SkiaOpenGLRenderer>(surface, getNativeId());
26
+
27
+ // Redraw
28
+ requestRedraw();
29
+ }
30
+ }
31
+
32
+ void RNSkDrawViewImpl::surfaceDestroyed() {
33
+ if (_renderer != nullptr)
34
+ {
35
+ // Start teardown
36
+ _renderer->teardown();
37
+
38
+ // Teardown renderer on the render thread since OpenGL demands
39
+ // same thread access for OpenGL contexts.
40
+ getPlatformContext()->runOnRenderThread([weakSelf = weak_from_this()]() {
41
+ auto self = weakSelf.lock();
42
+ if(self) {
43
+ auto drawViewImpl = std::dynamic_pointer_cast<RNSkDrawViewImpl>(self);
44
+ if(drawViewImpl->_renderer != nullptr) {
45
+ drawViewImpl->_renderer->run(nullptr, 0, 0);
46
+ }
47
+ // Remove renderer
48
+ drawViewImpl->_renderer = nullptr;
49
+ drawViewImpl->_releaseSurfaceCallback();
50
+ }
51
+ });
52
+ }
53
+ }
54
+
55
+ void RNSkDrawViewImpl::surfaceSizeChanged(int width, int height) {
56
+ _scaledWidth = width;
57
+ _scaledHeight = height;
58
+
59
+ // Redraw after size change
60
+ requestRedraw();
61
+ }
62
+
63
+ void RNSkDrawViewImpl::drawPicture(const sk_sp <SkPicture> picture) {
64
+ if(_renderer != nullptr) {
65
+ _renderer->run(picture, _scaledWidth, _scaledHeight);
66
+ }
67
+ }
68
+ }
@@ -0,0 +1,48 @@
1
+ #pragma once
2
+
3
+ #include <RNSkDrawView.h>
4
+
5
+ #include <SkiaOpenGLRenderer.h>
6
+ #include <android/native_window.h>
7
+
8
+ #pragma clang diagnostic push
9
+ #pragma clang diagnostic ignored "-Wdocumentation"
10
+
11
+ #include <SkPicture.h>
12
+ #include <SkRefCnt.h>
13
+
14
+ #pragma clang diagnostic pop
15
+
16
+ namespace RNSkia {
17
+ class RNSkDrawViewImpl : public RNSkia::RNSkDrawView {
18
+ public:
19
+ RNSkDrawViewImpl(std::shared_ptr <RNSkia::RNSkPlatformContext> context,
20
+ std::function<void()> releaseSurfaceCallback);
21
+
22
+ void surfaceAvailable(ANativeWindow* surface, int, int);
23
+ void surfaceDestroyed();
24
+ void surfaceSizeChanged(int, int);
25
+
26
+ float getPixelDensity() {
27
+ return getPlatformContext()->getPixelDensity();
28
+ }
29
+
30
+ protected:
31
+ float getScaledWidth() override { return _scaledWidth; };
32
+
33
+ float getScaledHeight() override { return _scaledHeight; };
34
+
35
+ void drawPicture(const sk_sp <SkPicture> picture) override;
36
+
37
+ private:
38
+ bool createSkiaSurface();
39
+
40
+ std::unique_ptr<SkiaOpenGLRenderer> _renderer = nullptr;
41
+
42
+ int _nativeId;
43
+ float _scaledWidth = -1;
44
+ float _scaledHeight = -1;
45
+
46
+ std::function<void()> _releaseSurfaceCallback;
47
+ };
48
+ }
@@ -11,11 +11,11 @@
11
11
  namespace RNSkia {
12
12
  using namespace facebook;
13
13
 
14
- class JniPlatformContextWrapper: public RNSkPlatformContext {
14
+ class RNSkPlatformContextImpl: public RNSkPlatformContext {
15
15
  public:
16
- JniPlatformContextWrapper(JniPlatformContext* jniPlatformContext,
17
- jsi::Runtime *runtime,
18
- std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker) :
16
+ RNSkPlatformContextImpl(JniPlatformContext* jniPlatformContext,
17
+ jsi::Runtime *runtime,
18
+ std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker) :
19
19
  RNSkPlatformContext(runtime,
20
20
  jsCallInvoker,
21
21
  jniPlatformContext->getPixelDensity()),
@@ -1,9 +1,9 @@
1
1
  #include "SkiaOpenGLRenderer.h"
2
2
 
3
3
  #include <RNSkLog.h>
4
+
4
5
  namespace RNSkia
5
6
  {
6
-
7
7
  /** Static members */
8
8
  std::shared_ptr<DrawingContext> SkiaOpenGLRenderer::getThreadDrawingContext()
9
9
  {
@@ -20,6 +20,11 @@ namespace RNSkia
20
20
  return threadContexts.at(threadId);
21
21
  }
22
22
 
23
+ SkiaOpenGLRenderer::SkiaOpenGLRenderer(ANativeWindow *surface, size_t renderId):
24
+ _surfaceTexture(surface),
25
+ _renderId(renderId) {
26
+ }
27
+
23
28
  void SkiaOpenGLRenderer::run(const sk_sp<SkPicture> picture, int width, int height)
24
29
  {
25
30
  switch (_renderState)
@@ -73,7 +78,16 @@ namespace RNSkia
73
78
  }
74
79
  case RenderState::Finishing:
75
80
  {
76
- finish();
81
+ _renderState = RenderState::Done;
82
+
83
+ if (_glSurface != EGL_NO_SURFACE && getThreadDrawingContext()->glDisplay != EGL_NO_DISPLAY)
84
+ {
85
+ eglDestroySurface(getThreadDrawingContext()->glDisplay, _glSurface);
86
+ }
87
+
88
+ _skSurface = nullptr;
89
+ _surfaceTexture = nullptr;
90
+
77
91
  break;
78
92
  }
79
93
  case RenderState::Done:
@@ -107,58 +121,11 @@ namespace RNSkia
107
121
  return true;
108
122
  }
109
123
 
110
- void SkiaOpenGLRenderer::finish()
111
- {
112
- std::lock_guard<std::mutex> lock(_lock);
113
-
114
- if (_renderState != RenderState::Finishing)
115
- {
116
- _cv.notify_all();
117
- return;
118
- }
119
-
120
- finishGL();
121
- finishSkiaSurface();
122
-
123
- _renderState = RenderState::Done;
124
-
125
- _cv.notify_one();
126
- }
127
-
128
- void SkiaOpenGLRenderer::finishGL()
129
- {
130
- if (_glSurface != EGL_NO_SURFACE && getThreadDrawingContext()->glDisplay != EGL_NO_DISPLAY)
131
- {
132
- eglDestroySurface(getThreadDrawingContext()->glDisplay, _glSurface);
133
- }
134
- }
135
-
136
- void SkiaOpenGLRenderer::finishSkiaSurface()
137
- {
138
- if (_skSurface != nullptr)
139
- {
140
- _skSurface = nullptr;
141
- }
142
-
143
- if (_nativeWindow != nullptr)
144
- {
145
- ANativeWindow_release(_nativeWindow);
146
- _nativeWindow = nullptr;
147
- }
148
- }
149
-
150
124
  void SkiaOpenGLRenderer::teardown()
151
125
  {
152
126
  _renderState = RenderState::Finishing;
153
127
  }
154
128
 
155
- void SkiaOpenGLRenderer::waitForTeardown()
156
- {
157
- std::unique_lock<std::mutex> lock(_lock);
158
- _cv.wait(lock, [this]
159
- { return (_renderState == RenderState::Done); });
160
- }
161
-
162
129
  bool SkiaOpenGLRenderer::initStaticGLContext()
163
130
  {
164
131
  if (getThreadDrawingContext()->glContext != EGL_NO_CONTEXT)
@@ -212,7 +179,12 @@ namespace RNSkia
212
179
 
213
180
  EGLint contextAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
214
181
 
215
- getThreadDrawingContext()->glContext = eglCreateContext(getThreadDrawingContext()->glDisplay, getThreadDrawingContext()->glConfig, NULL, contextAttribs);
182
+ getThreadDrawingContext()->glContext = eglCreateContext(
183
+ getThreadDrawingContext()->glDisplay,
184
+ getThreadDrawingContext()->glConfig,
185
+ NULL,
186
+ contextAttribs);
187
+
216
188
  if (getThreadDrawingContext()->glContext == EGL_NO_CONTEXT)
217
189
  {
218
190
  RNSkLogger::logToConsole(
@@ -244,14 +216,18 @@ namespace RNSkia
244
216
 
245
217
  bool SkiaOpenGLRenderer::initGLSurface()
246
218
  {
247
- if (_nativeWindow == nullptr)
219
+ if (_surfaceTexture == nullptr)
248
220
  {
249
221
  return false;
250
222
  }
251
223
 
252
224
  if (_glSurface != EGL_NO_SURFACE)
253
225
  {
254
- if (!eglMakeCurrent(getThreadDrawingContext()->glDisplay, _glSurface, _glSurface, getThreadDrawingContext()->glContext))
226
+ if (!eglMakeCurrent(
227
+ getThreadDrawingContext()->glDisplay,
228
+ _glSurface,
229
+ _glSurface,
230
+ getThreadDrawingContext()->glContext))
255
231
  {
256
232
  RNSkLogger::logToConsole(
257
233
  "eglMakeCurrent failed: %d\n", eglGetError());
@@ -262,7 +238,12 @@ namespace RNSkia
262
238
 
263
239
  // Create the opengl surface
264
240
  _glSurface =
265
- eglCreateWindowSurface(getThreadDrawingContext()->glDisplay, getThreadDrawingContext()->glConfig, _nativeWindow, nullptr);
241
+ eglCreateWindowSurface(
242
+ getThreadDrawingContext()->glDisplay,
243
+ getThreadDrawingContext()->glConfig,
244
+ _surfaceTexture,
245
+ nullptr);
246
+
266
247
  if (_glSurface == EGL_NO_SURFACE)
267
248
  {
268
249
  RNSkLogger::logToConsole(
@@ -270,7 +251,11 @@ namespace RNSkia
270
251
  return false;
271
252
  }
272
253
 
273
- if (!eglMakeCurrent(getThreadDrawingContext()->glDisplay, _glSurface, _glSurface, getThreadDrawingContext()->glContext))
254
+ if (!eglMakeCurrent(
255
+ getThreadDrawingContext()->glDisplay,
256
+ _glSurface,
257
+ _glSurface,
258
+ getThreadDrawingContext()->glContext))
274
259
  {
275
260
  RNSkLogger::logToConsole("eglMakeCurrent failed: %d\n", eglGetError());
276
261
  return false;
@@ -7,7 +7,6 @@
7
7
  #include "GLES2/gl2.h"
8
8
 
9
9
  #include <condition_variable>
10
- #include <mutex>
11
10
  #include <thread>
12
11
  #include <unordered_map>
13
12
 
@@ -45,9 +44,7 @@ namespace RNSkia
45
44
  class SkiaOpenGLRenderer
46
45
  {
47
46
  public:
48
- SkiaOpenGLRenderer(ANativeWindow *nativeWindow, size_t renderId) :
49
- _nativeWindow(nativeWindow),
50
- _renderId(renderId) { }
47
+ SkiaOpenGLRenderer(ANativeWindow *surface, size_t renderId);
51
48
 
52
49
  /**
53
50
  * Initializes, renders and tears down the render pipeline depending on the state of the
@@ -71,14 +68,6 @@ namespace RNSkia
71
68
  */
72
69
  void teardown();
73
70
 
74
- /**
75
- * Wait for teardown to finish. This means that we'll wait until the next
76
- * render which will handle releasing all OpenGL and Skia resources used for
77
- * this renderer. After tearing down the render will do nothing if the render
78
- * method is called again.
79
- */
80
- void waitForTeardown();
81
-
82
71
  private:
83
72
  /**
84
73
  * Initializes all required OpenGL and Skia objects
@@ -117,21 +106,6 @@ namespace RNSkia
117
106
  */
118
107
  bool ensureSkiaSurface(int width, int height);
119
108
 
120
- /**
121
- * Finalizes and releases all resources used by this renderer
122
- */
123
- void finish();
124
-
125
- /**
126
- * Destroys the underlying OpenGL surface used for this renderer
127
- */
128
- void finishGL();
129
-
130
- /**
131
- * Destroys the underlying Skia surface used for this renderer
132
- */
133
- void finishSkiaSurface();
134
-
135
109
  /**
136
110
  * To be able to use static contexts (and avoid reloading the skia context for each
137
111
  * new view, we track the OpenGL and Skia drawing context per thread.
@@ -141,7 +115,7 @@ namespace RNSkia
141
115
 
142
116
  EGLSurface _glSurface = EGL_NO_SURFACE;
143
117
 
144
- ANativeWindow *_nativeWindow = nullptr;
118
+ ANativeWindow *_surfaceTexture = nullptr;
145
119
  GrBackendRenderTarget _skRenderTarget;
146
120
  sk_sp<SkSurface> _skSurface;
147
121
 
@@ -150,9 +124,6 @@ namespace RNSkia
150
124
 
151
125
  size_t _renderId;
152
126
 
153
- std::mutex _lock;
154
- std::condition_variable _cv;
155
-
156
127
  std::atomic<RenderState> _renderState = { RenderState::Initializing };
157
128
  };
158
129
 
@@ -61,7 +61,7 @@ public class RNSkiaViewManager extends BaseViewManager<SkiaDrawView, LayoutShado
61
61
  Integer nativeId = mViewMapping.get(view);
62
62
  skiaModule.getSkiaManager().unregister(nativeId);
63
63
  mViewMapping.remove(view);
64
- view.onRemoved();
64
+ view.onViewRemoved();
65
65
  }
66
66
 
67
67
  @NonNull