@shopify/react-native-skia 2.5.5 → 2.6.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 (286) hide show
  1. package/android/CMakeLists.txt +0 -1
  2. package/android/cpp/jni/JniWebGPUView.cpp +3 -3
  3. package/android/cpp/rnskia-android/OpenGLContext.h +4 -5
  4. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +1 -1
  5. package/apple/MetalContext.h +5 -6
  6. package/apple/MetalWindowContext.mm +3 -4
  7. package/apple/RNSkApplePlatformContext.h +1 -1
  8. package/apple/RNSkApplePlatformContext.mm +4 -3
  9. package/apple/SkiaCVPixelBufferUtils.h +1 -1
  10. package/apple/SkiaCVPixelBufferUtils.mm +31 -30
  11. package/apple/SkiaPlatformContext.mm +2 -2
  12. package/apple/SkiaUIView.mm +1 -1
  13. package/apple/SkiaWebGPUView.mm +8 -4
  14. package/apple/WebGPUMetalView.h +1 -1
  15. package/apple/WebGPUMetalView.mm +1 -1
  16. package/cpp/api/CustomBlendModes.h +1 -0
  17. package/cpp/api/JsiSkApi.h +4 -0
  18. package/cpp/api/JsiSkCanvas.h +2 -2
  19. package/cpp/api/JsiSkColor.h +8 -4
  20. package/cpp/api/JsiSkContourMeasure.h +4 -3
  21. package/cpp/api/JsiSkContourMeasureIter.h +1 -1
  22. package/cpp/api/JsiSkImage.h +17 -9
  23. package/cpp/api/JsiSkParagraphBuilder.h +14 -1
  24. package/cpp/api/JsiSkPath.h +475 -357
  25. package/cpp/api/JsiSkPathBuilder.h +415 -0
  26. package/cpp/api/JsiSkPathBuilderFactory.h +53 -0
  27. package/cpp/api/JsiSkPathEffectFactory.h +3 -2
  28. package/cpp/api/JsiSkPathFactory.h +287 -20
  29. package/cpp/api/JsiSkShader.h +1 -1
  30. package/cpp/api/JsiSkShaderFactory.h +50 -26
  31. package/cpp/api/JsiSkSurfaceFactory.h +2 -1
  32. package/cpp/api/recorder/DataTypes.h +1 -1
  33. package/cpp/api/recorder/Drawings.h +11 -9
  34. package/cpp/api/recorder/Shaders.h +77 -22
  35. package/cpp/jsi2/JSIConverter.h +1 -1
  36. package/cpp/rnskia/RNDawnContext.h +29 -9
  37. package/cpp/rnskia/RNDawnUtils.h +112 -113
  38. package/cpp/rnskia/RNDawnWindowContext.h +1 -1
  39. package/cpp/rnskia/RNSkManager.cpp +5 -4
  40. package/cpp/rnskia/RNSkPlatformContext.h +2 -2
  41. package/cpp/rnwgpu/api/GPU.cpp +21 -0
  42. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +1 -1
  43. package/cpp/rnwgpu/api/GPUCanvasContext.h +2 -2
  44. package/cpp/rnwgpu/api/GPUFeatures.h +0 -9
  45. package/cpp/rnwgpu/api/GPUTexture.h +14 -2
  46. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +3 -4
  47. package/cpp/rnwgpu/api/RNWebGPU.h +1 -1
  48. package/cpp/rnwgpu/api/descriptors/Unions.h +0 -15
  49. package/cpp/skia/include/android/SkImageAndroid.h +7 -2
  50. package/cpp/skia/include/android/vk/AndroidVulkanMemoryAllocator.h +31 -0
  51. package/cpp/skia/include/codec/SkCodec.h +42 -15
  52. package/cpp/skia/include/config/SkUserConfig.h +8 -0
  53. package/cpp/skia/include/core/SkBitmap.h +0 -5
  54. package/cpp/skia/include/core/SkCanvas.h +2 -39
  55. package/cpp/skia/include/core/SkColor.h +12 -0
  56. package/cpp/skia/include/core/SkColorSpace.h +9 -0
  57. package/cpp/skia/include/core/SkContourMeasure.h +1 -5
  58. package/cpp/skia/include/core/SkData.h +8 -0
  59. package/cpp/skia/include/core/SkFont.h +1 -55
  60. package/cpp/skia/include/core/SkFontArguments.h +15 -0
  61. package/cpp/skia/include/core/SkGraphics.h +0 -5
  62. package/cpp/skia/include/core/SkImage.h +0 -4
  63. package/cpp/skia/include/core/SkImageGenerator.h +1 -4
  64. package/cpp/skia/include/core/SkMatrix.h +0 -37
  65. package/cpp/skia/include/core/SkMilestone.h +1 -1
  66. package/cpp/skia/include/core/SkPath.h +11 -911
  67. package/cpp/skia/include/core/SkPathBuilder.h +42 -32
  68. package/cpp/skia/include/core/SkPathEffect.h +0 -9
  69. package/cpp/skia/include/core/SkPathMeasure.h +1 -4
  70. package/cpp/skia/include/core/SkPathUtils.h +0 -10
  71. package/cpp/skia/include/core/SkRect.h +0 -12
  72. package/cpp/skia/include/core/SkRegion.h +1 -6
  73. package/cpp/skia/include/core/SkSerialProcs.h +4 -5
  74. package/cpp/skia/include/core/SkSurfaceProps.h +6 -0
  75. package/cpp/skia/include/core/SkTextBlob.h +0 -22
  76. package/cpp/skia/include/core/SkTypeface.h +14 -32
  77. package/cpp/skia/include/core/SkTypes.h +0 -8
  78. package/cpp/skia/include/docs/SkPDFDocument.h +19 -17
  79. package/cpp/skia/include/effects/SkDashPathEffect.h +0 -6
  80. package/cpp/skia/include/effects/SkGradient.h +206 -0
  81. package/cpp/skia/include/effects/SkHighContrastFilter.h +2 -2
  82. package/cpp/skia/include/gpu/GpuTypes.h +2 -0
  83. package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +5 -35
  84. package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +7 -106
  85. package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +0 -11
  86. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +0 -9
  87. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSemaphore.h +20 -0
  88. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSurface.h +59 -0
  89. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +28 -0
  90. package/cpp/skia/include/gpu/ganesh/gl/GrGLFunctions.h +4 -1
  91. package/cpp/skia/include/gpu/graphite/ContextOptions.h +4 -20
  92. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +32 -46
  93. package/cpp/skia/include/gpu/graphite/Recorder.h +1 -1
  94. package/cpp/skia/include/gpu/graphite/Surface.h +31 -0
  95. package/cpp/skia/include/gpu/graphite/TextureInfo.h +3 -10
  96. package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +3 -3
  97. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -1
  98. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +6 -6
  99. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +5 -3
  100. package/cpp/skia/include/gpu/graphite/vk/precompile/VulkanPrecompileShader.h +1 -1
  101. package/cpp/skia/include/gpu/vk/VulkanBackendContext.h +1 -1
  102. package/cpp/skia/include/gpu/vk/VulkanPreferredFeatures.h +8 -0
  103. package/cpp/skia/include/private/SkEncodedInfo.h +43 -105
  104. package/cpp/skia/include/private/SkHdrMetadata.h +165 -2
  105. package/cpp/skia/include/private/SkPathRef.h +0 -457
  106. package/cpp/skia/include/private/base/SkFeatures.h +4 -0
  107. package/cpp/skia/include/private/base/SkFloatingPoint.h +1 -2
  108. package/cpp/skia/include/private/base/SkLoadUserConfig.h +2 -1
  109. package/cpp/skia/include/private/base/SkLog.h +68 -0
  110. package/cpp/skia/include/private/base/SkLogPriority.h +35 -0
  111. package/cpp/skia/include/private/base/SkMacros.h +9 -0
  112. package/cpp/skia/include/private/base/SkTArray.h +1 -1
  113. package/cpp/skia/include/private/gpu/ganesh/GrD3DTypesMinimal.h +10 -24
  114. package/cpp/skia/include/utils/SkEventTracer.h +5 -7
  115. package/cpp/skia/modules/skottie/include/TextShaper.h +0 -7
  116. package/cpp/skia/modules/skparagraph/include/FontCollection.h +6 -20
  117. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +0 -6
  118. package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +4 -19
  119. package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +2 -3
  120. package/cpp/skia/modules/skunicode/include/SkUnicode_icu.h +18 -0
  121. package/cpp/skia/modules/skunicode/include/SkUnicode_libgrapheme.h +19 -0
  122. package/cpp/skia/src/base/SkMathPriv.h +27 -132
  123. package/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
  124. package/lib/commonjs/animation/functions/interpolatePaths.js +5 -4
  125. package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
  126. package/lib/commonjs/external/reanimated/interpolators.d.ts +11 -2
  127. package/lib/commonjs/external/reanimated/interpolators.js +21 -4
  128. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  129. package/lib/commonjs/skia/types/Path/PathBuilder.d.ts +201 -0
  130. package/lib/commonjs/skia/types/Path/PathBuilder.js +6 -0
  131. package/lib/commonjs/skia/types/Path/PathBuilder.js.map +1 -0
  132. package/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  133. package/lib/commonjs/skia/types/Path/PathBuilderFactory.js +6 -0
  134. package/lib/commonjs/skia/types/Path/PathBuilderFactory.js.map +1 -0
  135. package/lib/commonjs/skia/types/Path/PathFactory.d.ts +87 -1
  136. package/lib/commonjs/skia/types/Path/PathFactory.js.map +1 -1
  137. package/lib/commonjs/skia/types/Path/index.d.ts +2 -0
  138. package/lib/commonjs/skia/types/Path/index.js +22 -0
  139. package/lib/commonjs/skia/types/Path/index.js.map +1 -1
  140. package/lib/commonjs/skia/types/Skia.d.ts +2 -1
  141. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  142. package/lib/commonjs/skia/web/Host.js +1 -3
  143. package/lib/commonjs/skia/web/Host.js.map +1 -1
  144. package/lib/commonjs/skia/web/JsiSkCanvas.js +6 -2
  145. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  146. package/lib/commonjs/skia/web/JsiSkContourMeasure.js +4 -1
  147. package/lib/commonjs/skia/web/JsiSkContourMeasure.js.map +1 -1
  148. package/lib/commonjs/skia/web/JsiSkPath.d.ts +42 -30
  149. package/lib/commonjs/skia/web/JsiSkPath.js +302 -111
  150. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  151. package/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +45 -0
  152. package/lib/commonjs/skia/web/JsiSkPathBuilder.js +192 -0
  153. package/lib/commonjs/skia/web/JsiSkPathBuilder.js.map +1 -0
  154. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  155. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js +26 -0
  156. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
  157. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +6 -2
  158. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  159. package/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +13 -1
  160. package/lib/commonjs/skia/web/JsiSkPathFactory.js +140 -5
  161. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  162. package/lib/commonjs/skia/web/JsiSkia.js +8 -1
  163. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  164. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +18 -6
  165. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  166. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  167. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js +2 -3
  168. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  169. package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -2
  170. package/lib/commonjs/specs/WebGPUViewNativeComponent.js +2 -3
  171. package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +1 -1
  172. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +2 -0
  173. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +1 -1
  174. package/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
  175. package/lib/module/animation/functions/interpolatePaths.js +5 -4
  176. package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
  177. package/lib/module/external/reanimated/interpolators.d.ts +11 -2
  178. package/lib/module/external/reanimated/interpolators.js +21 -4
  179. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  180. package/lib/module/skia/types/Path/PathBuilder.d.ts +201 -0
  181. package/lib/module/skia/types/Path/PathBuilder.js +2 -0
  182. package/lib/module/skia/types/Path/PathBuilder.js.map +1 -0
  183. package/lib/module/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  184. package/lib/module/skia/types/Path/PathBuilderFactory.js +2 -0
  185. package/lib/module/skia/types/Path/PathBuilderFactory.js.map +1 -0
  186. package/lib/module/skia/types/Path/PathFactory.d.ts +87 -1
  187. package/lib/module/skia/types/Path/PathFactory.js.map +1 -1
  188. package/lib/module/skia/types/Path/index.d.ts +2 -0
  189. package/lib/module/skia/types/Path/index.js +2 -0
  190. package/lib/module/skia/types/Path/index.js.map +1 -1
  191. package/lib/module/skia/types/Skia.d.ts +2 -1
  192. package/lib/module/skia/types/Skia.js.map +1 -1
  193. package/lib/module/skia/web/Host.js +1 -3
  194. package/lib/module/skia/web/Host.js.map +1 -1
  195. package/lib/module/skia/web/JsiSkCanvas.js +6 -2
  196. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  197. package/lib/module/skia/web/JsiSkContourMeasure.js +4 -1
  198. package/lib/module/skia/web/JsiSkContourMeasure.js.map +1 -1
  199. package/lib/module/skia/web/JsiSkPath.d.ts +42 -30
  200. package/lib/module/skia/web/JsiSkPath.js +300 -110
  201. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  202. package/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
  203. package/lib/module/skia/web/JsiSkPathBuilder.js +186 -0
  204. package/lib/module/skia/web/JsiSkPathBuilder.js.map +1 -0
  205. package/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  206. package/lib/module/skia/web/JsiSkPathBuilderFactory.js +19 -0
  207. package/lib/module/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
  208. package/lib/module/skia/web/JsiSkPathEffectFactory.js +6 -2
  209. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  210. package/lib/module/skia/web/JsiSkPathFactory.d.ts +13 -1
  211. package/lib/module/skia/web/JsiSkPathFactory.js +141 -6
  212. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  213. package/lib/module/skia/web/JsiSkia.js +8 -1
  214. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  215. package/lib/module/sksg/Recorder/commands/Drawing.js +18 -6
  216. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  217. package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  218. package/lib/module/specs/SkiaPictureViewNativeComponent.js +1 -1
  219. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  220. package/lib/module/specs/WebGPUViewNativeComponent.d.ts +2 -2
  221. package/lib/module/specs/WebGPUViewNativeComponent.js +1 -1
  222. package/lib/module/specs/WebGPUViewNativeComponent.js.map +1 -1
  223. package/lib/module/specs/WebGPUViewNativeComponent.web.js +2 -0
  224. package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +1 -1
  225. package/lib/typescript/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
  226. package/lib/typescript/lib/commonjs/external/reanimated/interpolators.d.ts +1 -1
  227. package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilder.d.ts +1 -0
  228. package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +1 -0
  229. package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +33 -25
  230. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +46 -0
  231. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +7 -0
  232. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +12 -0
  233. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
  234. package/lib/typescript/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -1
  235. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -1
  236. package/lib/typescript/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
  237. package/lib/typescript/lib/module/external/reanimated/interpolators.d.ts +1 -1
  238. package/lib/typescript/lib/module/mock/index.d.ts +1 -1
  239. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -0
  240. package/lib/typescript/lib/module/skia/types/Path/PathBuilder.d.ts +1 -0
  241. package/lib/typescript/lib/module/skia/types/Path/PathBuilderFactory.d.ts +1 -0
  242. package/lib/typescript/lib/module/skia/types/Path/index.d.ts +2 -0
  243. package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +38 -25
  244. package/lib/typescript/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
  245. package/lib/typescript/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +6 -0
  246. package/lib/typescript/lib/module/skia/web/JsiSkPathFactory.d.ts +12 -0
  247. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
  248. package/lib/typescript/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +1 -1
  249. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +1 -1
  250. package/lib/typescript/src/animation/functions/interpolatePaths.d.ts +1 -1
  251. package/lib/typescript/src/external/reanimated/interpolators.d.ts +11 -2
  252. package/lib/typescript/src/skia/types/Path/PathBuilder.d.ts +201 -0
  253. package/lib/typescript/src/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  254. package/lib/typescript/src/skia/types/Path/PathFactory.d.ts +87 -1
  255. package/lib/typescript/src/skia/types/Path/index.d.ts +2 -0
  256. package/lib/typescript/src/skia/types/Skia.d.ts +2 -1
  257. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +42 -30
  258. package/lib/typescript/src/skia/web/JsiSkPathBuilder.d.ts +45 -0
  259. package/lib/typescript/src/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  260. package/lib/typescript/src/skia/web/JsiSkPathFactory.d.ts +13 -1
  261. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  262. package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +2 -2
  263. package/package.json +7 -6
  264. package/scripts/install-libs.js +16 -6
  265. package/src/animation/functions/interpolatePaths.ts +5 -6
  266. package/src/external/reanimated/interpolators.ts +25 -5
  267. package/src/skia/types/Path/PathBuilder.ts +303 -0
  268. package/src/skia/types/Path/PathBuilderFactory.ts +15 -0
  269. package/src/skia/types/Path/PathFactory.ts +108 -1
  270. package/src/skia/types/Path/index.ts +2 -0
  271. package/src/skia/types/Skia.ts +2 -1
  272. package/src/skia/web/Host.ts +7 -1
  273. package/src/skia/web/JsiSkCanvas.ts +6 -6
  274. package/src/skia/web/JsiSkContourMeasure.ts +4 -4
  275. package/src/skia/web/JsiSkPath.ts +451 -168
  276. package/src/skia/web/JsiSkPathBuilder.ts +293 -0
  277. package/src/skia/web/JsiSkPathBuilderFactory.ts +32 -0
  278. package/src/skia/web/JsiSkPathEffectFactory.ts +6 -2
  279. package/src/skia/web/JsiSkPathFactory.ts +231 -8
  280. package/src/skia/web/JsiSkia.ts +11 -8
  281. package/src/sksg/Recorder/commands/Drawing.ts +20 -7
  282. package/src/specs/SkiaPictureViewNativeComponent.ts +1 -2
  283. package/src/specs/WebGPUViewNativeComponent.ts +2 -2
  284. package/src/specs/WebGPUViewNativeComponent.web.ts +2 -0
  285. package/cpp/skia/include/effects/SkGradientShader.h +0 -359
  286. package/cpp/skia/include/gpu/graphite/LogPriority.h +0 -36
@@ -0,0 +1,415 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <utility>
5
+ #include <vector>
6
+
7
+ #include <jsi/jsi.h>
8
+
9
+ #include "JsiSkHostObjects.h"
10
+ #include "JsiSkMatrix.h"
11
+ #include "JsiSkPath.h"
12
+ #include "JsiSkPoint.h"
13
+ #include "JsiSkRRect.h"
14
+ #include "JsiSkRect.h"
15
+
16
+ #pragma clang diagnostic push
17
+ #pragma clang diagnostic ignored "-Wdocumentation"
18
+
19
+ #include "include/core/SkPath.h"
20
+ #include "include/core/SkPathBuilder.h"
21
+ #include "include/core/SkPathTypes.h"
22
+
23
+ #pragma clang diagnostic pop
24
+
25
+ namespace RNSkia {
26
+
27
+ namespace jsi = facebook::jsi;
28
+
29
+ class JsiSkPathBuilder
30
+ : public JsiSkWrappingSharedPtrHostObject<SkPathBuilder> {
31
+ public:
32
+ // Movement methods
33
+ JSI_HOST_FUNCTION(moveTo) {
34
+ SkScalar x = arguments[0].asNumber();
35
+ SkScalar y = arguments[1].asNumber();
36
+ getObject()->moveTo(x, y);
37
+ return thisValue.getObject(runtime);
38
+ }
39
+
40
+ JSI_HOST_FUNCTION(rMoveTo) {
41
+ SkScalar x = arguments[0].asNumber();
42
+ SkScalar y = arguments[1].asNumber();
43
+ getObject()->rMoveTo({x, y});
44
+ return thisValue.getObject(runtime);
45
+ }
46
+
47
+ JSI_HOST_FUNCTION(lineTo) {
48
+ SkScalar x = arguments[0].asNumber();
49
+ SkScalar y = arguments[1].asNumber();
50
+ getObject()->lineTo(x, y);
51
+ return thisValue.getObject(runtime);
52
+ }
53
+
54
+ JSI_HOST_FUNCTION(rLineTo) {
55
+ SkScalar x = arguments[0].asNumber();
56
+ SkScalar y = arguments[1].asNumber();
57
+ getObject()->rLineTo(x, y);
58
+ return thisValue.getObject(runtime);
59
+ }
60
+
61
+ // Curve methods
62
+ JSI_HOST_FUNCTION(quadTo) {
63
+ auto x1 = arguments[0].asNumber();
64
+ auto y1 = arguments[1].asNumber();
65
+ auto x2 = arguments[2].asNumber();
66
+ auto y2 = arguments[3].asNumber();
67
+ getObject()->quadTo(x1, y1, x2, y2);
68
+ return thisValue.getObject(runtime);
69
+ }
70
+
71
+ JSI_HOST_FUNCTION(rQuadTo) {
72
+ auto x1 = arguments[0].asNumber();
73
+ auto y1 = arguments[1].asNumber();
74
+ auto x2 = arguments[2].asNumber();
75
+ auto y2 = arguments[3].asNumber();
76
+ getObject()->rQuadTo(x1, y1, x2, y2);
77
+ return thisValue.getObject(runtime);
78
+ }
79
+
80
+ JSI_HOST_FUNCTION(conicTo) {
81
+ auto x1 = arguments[0].asNumber();
82
+ auto y1 = arguments[1].asNumber();
83
+ auto x2 = arguments[2].asNumber();
84
+ auto y2 = arguments[3].asNumber();
85
+ auto w = arguments[4].asNumber();
86
+ getObject()->conicTo(x1, y1, x2, y2, w);
87
+ return thisValue.getObject(runtime);
88
+ }
89
+
90
+ JSI_HOST_FUNCTION(rConicTo) {
91
+ auto x1 = arguments[0].asNumber();
92
+ auto y1 = arguments[1].asNumber();
93
+ auto x2 = arguments[2].asNumber();
94
+ auto y2 = arguments[3].asNumber();
95
+ auto w = arguments[4].asNumber();
96
+ getObject()->rConicTo(x1, y1, x2, y2, w);
97
+ return thisValue.getObject(runtime);
98
+ }
99
+
100
+ JSI_HOST_FUNCTION(cubicTo) {
101
+ auto x1 = arguments[0].asNumber();
102
+ auto y1 = arguments[1].asNumber();
103
+ auto x2 = arguments[2].asNumber();
104
+ auto y2 = arguments[3].asNumber();
105
+ auto x3 = arguments[4].asNumber();
106
+ auto y3 = arguments[5].asNumber();
107
+ getObject()->cubicTo(x1, y1, x2, y2, x3, y3);
108
+ return thisValue.getObject(runtime);
109
+ }
110
+
111
+ JSI_HOST_FUNCTION(rCubicTo) {
112
+ auto x1 = arguments[0].asNumber();
113
+ auto y1 = arguments[1].asNumber();
114
+ auto x2 = arguments[2].asNumber();
115
+ auto y2 = arguments[3].asNumber();
116
+ auto x3 = arguments[4].asNumber();
117
+ auto y3 = arguments[5].asNumber();
118
+ getObject()->rCubicTo(x1, y1, x2, y2, x3, y3);
119
+ return thisValue.getObject(runtime);
120
+ }
121
+
122
+ JSI_HOST_FUNCTION(close) {
123
+ getObject()->close();
124
+ return thisValue.getObject(runtime);
125
+ }
126
+
127
+ // Arc methods
128
+ JSI_HOST_FUNCTION(arcToOval) {
129
+ auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
130
+ auto start = arguments[1].asNumber();
131
+ auto sweep = arguments[2].asNumber();
132
+ auto forceMoveTo = arguments[3].getBool();
133
+ getObject()->arcTo(*rect, start, sweep, forceMoveTo);
134
+ return thisValue.getObject(runtime);
135
+ }
136
+
137
+ JSI_HOST_FUNCTION(arcToRotated) {
138
+ auto rx = arguments[0].asNumber();
139
+ auto ry = arguments[1].asNumber();
140
+ auto xAxisRotate = arguments[2].asNumber();
141
+ auto useSmallArc = arguments[3].getBool();
142
+ auto arcSize = useSmallArc ? SkPathBuilder::ArcSize::kSmall_ArcSize
143
+ : SkPathBuilder::ArcSize::kLarge_ArcSize;
144
+ auto sweep =
145
+ arguments[4].getBool() ? SkPathDirection::kCCW : SkPathDirection::kCW;
146
+ auto x = arguments[5].asNumber();
147
+ auto y = arguments[6].asNumber();
148
+ getObject()->arcTo(SkPoint::Make(rx, ry), xAxisRotate, arcSize, sweep,
149
+ SkPoint::Make(x, y));
150
+ return thisValue.getObject(runtime);
151
+ }
152
+
153
+ JSI_HOST_FUNCTION(rArcTo) {
154
+ auto rx = arguments[0].asNumber();
155
+ auto ry = arguments[1].asNumber();
156
+ auto xAxisRotate = arguments[2].asNumber();
157
+ auto useSmallArc = arguments[3].getBool();
158
+ auto arcSize = useSmallArc ? SkPathBuilder::ArcSize::kSmall_ArcSize
159
+ : SkPathBuilder::ArcSize::kLarge_ArcSize;
160
+ auto sweep =
161
+ arguments[4].getBool() ? SkPathDirection::kCCW : SkPathDirection::kCW;
162
+ auto dx = arguments[5].asNumber();
163
+ auto dy = arguments[6].asNumber();
164
+ SkPoint r(rx, ry);
165
+ SkVector d(dx, dy);
166
+ getObject()->rArcTo(r, xAxisRotate, arcSize, sweep, d);
167
+ return thisValue.getObject(runtime);
168
+ }
169
+
170
+ JSI_HOST_FUNCTION(arcToTangent) {
171
+ auto x1 = arguments[0].asNumber();
172
+ auto y1 = arguments[1].asNumber();
173
+ auto x2 = arguments[2].asNumber();
174
+ auto y2 = arguments[3].asNumber();
175
+ auto r = arguments[4].asNumber();
176
+ getObject()->arcTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), r);
177
+ return thisValue.getObject(runtime);
178
+ }
179
+
180
+ // Shape methods
181
+ JSI_HOST_FUNCTION(addRect) {
182
+ auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
183
+ auto direction = SkPathDirection::kCW;
184
+ if (count >= 2 && arguments[1].getBool()) {
185
+ direction = SkPathDirection::kCCW;
186
+ }
187
+ getObject()->addRect(*rect, direction);
188
+ return thisValue.getObject(runtime);
189
+ }
190
+
191
+ JSI_HOST_FUNCTION(addOval) {
192
+ auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
193
+ auto direction = SkPathDirection::kCW;
194
+ if (count >= 2 && arguments[1].getBool()) {
195
+ direction = SkPathDirection::kCCW;
196
+ }
197
+ unsigned startIndex = count < 3 ? 0 : arguments[2].asNumber();
198
+ getObject()->addOval(*rect, direction, startIndex);
199
+ return thisValue.getObject(runtime);
200
+ }
201
+
202
+ JSI_HOST_FUNCTION(addArc) {
203
+ auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
204
+ auto start = arguments[1].asNumber();
205
+ auto sweep = arguments[2].asNumber();
206
+ getObject()->addArc(*rect, start, sweep);
207
+ return thisValue.getObject(runtime);
208
+ }
209
+
210
+ JSI_HOST_FUNCTION(addRRect) {
211
+ auto rrect = JsiSkRRect::fromValue(runtime, arguments[0]);
212
+ auto direction = SkPathDirection::kCW;
213
+ if (count >= 2 && arguments[1].getBool()) {
214
+ direction = SkPathDirection::kCCW;
215
+ }
216
+ getObject()->addRRect(*rrect, direction);
217
+ return thisValue.getObject(runtime);
218
+ }
219
+
220
+ JSI_HOST_FUNCTION(addCircle) {
221
+ auto x = arguments[0].asNumber();
222
+ auto y = arguments[1].asNumber();
223
+ auto r = arguments[2].asNumber();
224
+ auto direction = SkPathDirection::kCW;
225
+ if (count >= 4 && arguments[3].getBool()) {
226
+ direction = SkPathDirection::kCCW;
227
+ }
228
+ getObject()->addCircle(x, y, r, direction);
229
+ return thisValue.getObject(runtime);
230
+ }
231
+
232
+ JSI_HOST_FUNCTION(addPoly) {
233
+ std::vector<SkPoint> points;
234
+ auto jsiPoints = arguments[0].asObject(runtime).asArray(runtime);
235
+ auto close = arguments[1].getBool();
236
+ auto pointsSize = jsiPoints.size(runtime);
237
+ points.reserve(pointsSize);
238
+ for (int i = 0; i < pointsSize; i++) {
239
+ std::shared_ptr<SkPoint> point = JsiSkPoint::fromValue(
240
+ runtime, jsiPoints.getValueAtIndex(runtime, i).asObject(runtime));
241
+ points.push_back(*point.get());
242
+ }
243
+ getObject()->addPolygon(SkSpan(points.data(), points.size()), close);
244
+ return thisValue.getObject(runtime);
245
+ }
246
+
247
+ JSI_HOST_FUNCTION(addPath) {
248
+ auto src = JsiSkPath::fromValue(runtime, arguments[0]);
249
+ auto srcPath = src->snapshot();
250
+ auto matrix =
251
+ count > 1 && !arguments[1].isUndefined() && !arguments[1].isNull()
252
+ ? JsiSkMatrix::fromValue(runtime, arguments[1])
253
+ : nullptr;
254
+ auto mode = count > 2 && arguments[2].isBool() && arguments[2].getBool()
255
+ ? SkPath::kExtend_AddPathMode
256
+ : SkPath::kAppend_AddPathMode;
257
+ if (matrix == nullptr) {
258
+ getObject()->addPath(srcPath, mode);
259
+ } else {
260
+ getObject()->addPath(srcPath, *matrix, mode);
261
+ }
262
+ return thisValue.getObject(runtime);
263
+ }
264
+
265
+ // Configuration methods
266
+ JSI_HOST_FUNCTION(setFillType) {
267
+ auto ft = (SkPathFillType)arguments[0].asNumber();
268
+ getObject()->setFillType(ft);
269
+ return thisValue.getObject(runtime);
270
+ }
271
+
272
+ JSI_HOST_FUNCTION(setIsVolatile) {
273
+ auto v = arguments[0].getBool();
274
+ getObject()->setIsVolatile(v);
275
+ return thisValue.getObject(runtime);
276
+ }
277
+
278
+ JSI_HOST_FUNCTION(reset) {
279
+ getObject()->reset();
280
+ return thisValue.getObject(runtime);
281
+ }
282
+
283
+ JSI_HOST_FUNCTION(offset) {
284
+ SkScalar dx = arguments[0].asNumber();
285
+ SkScalar dy = arguments[1].asNumber();
286
+ getObject()->offset(dx, dy);
287
+ return thisValue.getObject(runtime);
288
+ }
289
+
290
+ JSI_HOST_FUNCTION(transform) {
291
+ auto m3 = *JsiSkMatrix::fromValue(runtime, arguments[0]);
292
+ // Create a path from current state, transform, then rebuild
293
+ auto path = getObject()->snapshot().makeTransform(m3);
294
+ *getObject() = SkPathBuilder(path);
295
+ return thisValue.getObject(runtime);
296
+ }
297
+
298
+ // Query methods
299
+ JSI_HOST_FUNCTION(computeBounds) {
300
+ auto path = getObject()->snapshot();
301
+ auto result = path.getBounds();
302
+ auto hostObjectInstance = std::make_shared<JsiSkRect>(getContext(), result);
303
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
304
+ runtime, hostObjectInstance, getContext());
305
+ }
306
+
307
+ JSI_HOST_FUNCTION(isEmpty) {
308
+ return jsi::Value(getObject()->snapshot().isEmpty());
309
+ }
310
+
311
+ JSI_HOST_FUNCTION(getLastPt) {
312
+ SkPoint last;
313
+ getObject()->snapshot().getLastPt(&last);
314
+ auto point = jsi::Object(runtime);
315
+ point.setProperty(runtime, "x", static_cast<double>(last.fX));
316
+ point.setProperty(runtime, "y", static_cast<double>(last.fY));
317
+ return point;
318
+ }
319
+
320
+ JSI_HOST_FUNCTION(countPoints) {
321
+ auto points = getObject()->snapshot().countPoints();
322
+ return jsi::Value(points);
323
+ }
324
+
325
+ // Build methods
326
+ JSI_HOST_FUNCTION(build) {
327
+ // snapshot() returns a copy without resetting the builder
328
+ auto path = getObject()->snapshot();
329
+ auto hostObjectInstance =
330
+ std::make_shared<JsiSkPath>(getContext(), std::move(path));
331
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
332
+ runtime, hostObjectInstance, getContext());
333
+ }
334
+
335
+ JSI_HOST_FUNCTION(detach) {
336
+ // detach() returns the path and resets the builder
337
+ auto path = getObject()->detach();
338
+ auto hostObjectInstance =
339
+ std::make_shared<JsiSkPath>(getContext(), std::move(path));
340
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
341
+ runtime, hostObjectInstance, getContext());
342
+ }
343
+
344
+ EXPORT_JSI_API_TYPENAME(JsiSkPathBuilder, PathBuilder)
345
+
346
+ JSI_EXPORT_FUNCTIONS(
347
+ // Movement
348
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, moveTo),
349
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, rMoveTo),
350
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, lineTo),
351
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, rLineTo),
352
+ // Curves
353
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, quadTo),
354
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, rQuadTo),
355
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, conicTo),
356
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, rConicTo),
357
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, cubicTo),
358
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, rCubicTo),
359
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, close),
360
+ // Arcs
361
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, arcToOval),
362
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, arcToRotated),
363
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, rArcTo),
364
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, arcToTangent),
365
+ // Shapes
366
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, addRect),
367
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, addOval),
368
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, addArc),
369
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, addRRect),
370
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, addCircle),
371
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, addPoly),
372
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, addPath),
373
+ // Config
374
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, setFillType),
375
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, setIsVolatile),
376
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, reset),
377
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, offset),
378
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, transform),
379
+ // Query
380
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, computeBounds),
381
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, isEmpty),
382
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, getLastPt),
383
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, countPoints),
384
+ // Build
385
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, build),
386
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, detach),
387
+ JSI_EXPORT_FUNC(JsiSkPathBuilder, dispose))
388
+
389
+ JsiSkPathBuilder(std::shared_ptr<RNSkPlatformContext> context,
390
+ SkPathBuilder builder)
391
+ : JsiSkWrappingSharedPtrHostObject<SkPathBuilder>(
392
+ std::move(context),
393
+ std::make_shared<SkPathBuilder>(std::move(builder))) {}
394
+
395
+ size_t getMemoryPressure() const override {
396
+ auto builder = getObject();
397
+ if (!builder)
398
+ return 0;
399
+ // Estimate memory usage based on snapshot
400
+ return builder->snapshot().approximateBytesUsed();
401
+ }
402
+
403
+ std::string getObjectType() const override { return "JsiSkPathBuilder"; }
404
+
405
+ static jsi::Value toValue(jsi::Runtime &runtime,
406
+ std::shared_ptr<RNSkPlatformContext> context,
407
+ const SkPathBuilder &builder) {
408
+ auto hostObjectInstance =
409
+ std::make_shared<JsiSkPathBuilder>(context, builder);
410
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
411
+ runtime, hostObjectInstance, context);
412
+ }
413
+ };
414
+
415
+ } // namespace RNSkia
@@ -0,0 +1,53 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <utility>
5
+
6
+ #include <jsi/jsi.h>
7
+
8
+ #include "JsiSkHostObjects.h"
9
+ #include "JsiSkPathBuilder.h"
10
+
11
+ #pragma clang diagnostic push
12
+ #pragma clang diagnostic ignored "-Wdocumentation"
13
+
14
+ #include "include/core/SkPath.h"
15
+ #include "include/core/SkPathBuilder.h"
16
+
17
+ #pragma clang diagnostic pop
18
+
19
+ namespace RNSkia {
20
+
21
+ namespace jsi = facebook::jsi;
22
+
23
+ class JsiSkPathBuilderFactory : public JsiSkHostObject {
24
+ public:
25
+ JSI_HOST_FUNCTION(Make) {
26
+ auto hostObjectInstance =
27
+ std::make_shared<JsiSkPathBuilder>(getContext(), SkPathBuilder());
28
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
29
+ runtime, hostObjectInstance, getContext());
30
+ }
31
+
32
+ JSI_HOST_FUNCTION(MakeFromPath) {
33
+ auto path = JsiSkPath::fromValue(runtime, arguments[0]);
34
+ auto hostObjectInstance =
35
+ std::make_shared<JsiSkPathBuilder>(getContext(), SkPathBuilder(*path));
36
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
37
+ runtime, hostObjectInstance, getContext());
38
+ }
39
+
40
+ size_t getMemoryPressure() const override { return 1024; }
41
+
42
+ std::string getObjectType() const override {
43
+ return "JsiSkPathBuilderFactory";
44
+ }
45
+
46
+ JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPathBuilderFactory, Make),
47
+ JSI_EXPORT_FUNC(JsiSkPathBuilderFactory, MakeFromPath))
48
+
49
+ explicit JsiSkPathBuilderFactory(std::shared_ptr<RNSkPlatformContext> context)
50
+ : JsiSkHostObject(std::move(context)) {}
51
+ };
52
+
53
+ } // namespace RNSkia
@@ -92,7 +92,8 @@ public:
92
92
  auto style =
93
93
  static_cast<SkPath1DPathEffect::Style>(arguments[3].asNumber());
94
94
  auto pathEffect = std::make_shared<JsiSkPathEffect>(
95
- getContext(), SkPath1DPathEffect::Make(*path, advance, phase, style));
95
+ getContext(),
96
+ SkPath1DPathEffect::Make(path->snapshot(), advance, phase, style));
96
97
  return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, pathEffect,
97
98
  getContext());
98
99
  }
@@ -101,7 +102,7 @@ public:
101
102
  auto matrix = JsiSkMatrix::fromValue(runtime, arguments[0]);
102
103
  auto path = JsiSkPath::fromValue(runtime, arguments[1]);
103
104
  auto pathEffect = std::make_shared<JsiSkPathEffect>(
104
- getContext(), SkPath2DPathEffect::Make(*matrix, *path));
105
+ getContext(), SkPath2DPathEffect::Make(*matrix, path->snapshot()));
105
106
  return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, pathEffect,
106
107
  getContext());
107
108
  }