@shopify/react-native-skia 2.9.1 → 2.10.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 (387) hide show
  1. package/android/CMakeLists.txt +8 -46
  2. package/android/build.gradle +33 -0
  3. package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaPackage.java +1 -2
  4. package/cpp/api/JsiNativeBuffer.h +23 -24
  5. package/cpp/api/JsiSkAnimatedImage.h +24 -25
  6. package/cpp/api/JsiSkAnimatedImageFactory.h +18 -17
  7. package/cpp/api/JsiSkApi.h +254 -96
  8. package/cpp/api/JsiSkCanvas.h +141 -266
  9. package/cpp/api/JsiSkColor.h +7 -5
  10. package/cpp/api/JsiSkColorFilter.h +15 -8
  11. package/cpp/api/JsiSkColorFilterFactory.h +49 -67
  12. package/cpp/api/JsiSkContourMeasure.h +31 -38
  13. package/cpp/api/JsiSkContourMeasureIter.h +20 -23
  14. package/cpp/api/JsiSkConverters.h +410 -0
  15. package/cpp/api/JsiSkData.h +13 -7
  16. package/cpp/api/JsiSkDataFactory.h +27 -32
  17. package/cpp/api/JsiSkFont.h +123 -192
  18. package/cpp/api/JsiSkFontMgr.h +33 -26
  19. package/cpp/api/JsiSkFontMgrFactory.h +12 -11
  20. package/cpp/api/JsiSkFontStyle.h +14 -12
  21. package/cpp/api/JsiSkImage.h +90 -79
  22. package/cpp/api/JsiSkImageFactory.h +93 -95
  23. package/cpp/api/JsiSkImageFilter.h +21 -11
  24. package/cpp/api/JsiSkImageFilterFactory.h +375 -629
  25. package/cpp/api/JsiSkImageInfo.h +25 -25
  26. package/cpp/api/JsiSkMaskFilter.h +21 -11
  27. package/cpp/api/JsiSkMaskFilterFactory.h +17 -17
  28. package/cpp/api/JsiSkMatrix.h +51 -88
  29. package/cpp/api/JsiSkNativeObjects.h +387 -0
  30. package/cpp/api/JsiSkPaint.h +104 -142
  31. package/cpp/api/JsiSkParagraph.h +54 -64
  32. package/cpp/api/JsiSkParagraphBuilder.h +43 -68
  33. package/cpp/api/JsiSkParagraphBuilderFactory.h +20 -24
  34. package/cpp/api/JsiSkPath.h +242 -350
  35. package/cpp/api/JsiSkPathBuilder.h +153 -273
  36. package/cpp/api/JsiSkPathBuilderFactory.h +19 -20
  37. package/cpp/api/JsiSkPathEffect.h +21 -11
  38. package/cpp/api/JsiSkPathEffectFactory.h +61 -80
  39. package/cpp/api/JsiSkPathFactory.h +148 -238
  40. package/cpp/api/JsiSkPicture.h +32 -27
  41. package/cpp/api/JsiSkPictureFactory.h +21 -26
  42. package/cpp/api/JsiSkPictureRecorder.h +27 -29
  43. package/cpp/api/JsiSkPoint.h +20 -23
  44. package/cpp/api/JsiSkRRect.h +24 -32
  45. package/cpp/api/JsiSkRSXform.h +31 -48
  46. package/cpp/api/JsiSkRect.h +40 -50
  47. package/cpp/api/JsiSkRuntimeEffect.h +85 -92
  48. package/cpp/api/JsiSkRuntimeEffectFactory.h +14 -18
  49. package/cpp/api/JsiSkRuntimeShaderBuilder.h +28 -30
  50. package/cpp/api/JsiSkSVG.h +15 -15
  51. package/cpp/api/JsiSkSVGFactory.h +17 -20
  52. package/cpp/api/JsiSkShader.h +15 -8
  53. package/cpp/api/JsiSkShaderFactory.h +159 -238
  54. package/cpp/api/JsiSkSkottie.h +131 -143
  55. package/cpp/api/JsiSkSurface.h +29 -32
  56. package/cpp/api/JsiSkSurfaceFactory.h +18 -20
  57. package/cpp/api/JsiSkTextBlob.h +15 -8
  58. package/cpp/api/JsiSkTextBlobFactory.h +40 -66
  59. package/cpp/api/JsiSkTypeface.h +25 -22
  60. package/cpp/api/JsiSkTypefaceFactory.h +17 -15
  61. package/cpp/api/JsiSkTypefaceFontProvider.h +43 -39
  62. package/cpp/api/JsiSkTypefaceFontProviderFactory.h +13 -12
  63. package/cpp/api/JsiSkVertices.h +23 -22
  64. package/cpp/api/JsiSkiaContext.h +22 -23
  65. package/cpp/api/JsiSkottieFactory.h +16 -17
  66. package/cpp/api/JsiVideo.h +43 -81
  67. package/cpp/api/recorder/Convertor.h +31 -61
  68. package/cpp/api/recorder/DataTypes.h +8 -16
  69. package/cpp/api/recorder/JsiRecorder.h +83 -55
  70. package/cpp/api/recorder/RNRecorder.h +1 -1
  71. package/cpp/jsi/BoxedNativeObject.h +146 -0
  72. package/cpp/{jsi2 → jsi}/EnumMapper.h +4 -1
  73. package/cpp/{jsi2 → jsi}/JSIConverter.h +0 -31
  74. package/cpp/{jsi2 → jsi}/NativeObject.h +131 -152
  75. package/cpp/jsi/RuntimeAwareCache.cpp +1 -1
  76. package/cpp/jsi/RuntimeAwareCache.h +26 -8
  77. package/cpp/jsi/ViewProperty.h +5 -11
  78. package/cpp/rnskia/RNDawnContext.h +18 -2
  79. package/cpp/rnskia/RNDawnInterop.cpp +19 -0
  80. package/cpp/rnskia/RNDawnUtils.h +18 -1
  81. package/cpp/rnskia/RNSkJsiViewApi.h +20 -11
  82. package/cpp/rnskia/RNSkManager.cpp +9 -168
  83. package/cpp/rnskia/RNSkPictureView.h +1 -1
  84. package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkaroundsAutogen.h +2 -0
  85. package/lib/commonjs/external/reanimated/renderHelpers.d.ts +15 -0
  86. package/lib/commonjs/external/reanimated/renderHelpers.js +30 -1
  87. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
  88. package/lib/commonjs/mock/index.js +0 -1
  89. package/lib/commonjs/mock/index.js.map +1 -1
  90. package/lib/commonjs/skia/NativeSetup.js +4 -0
  91. package/lib/commonjs/skia/NativeSetup.js.map +1 -1
  92. package/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +1 -0
  93. package/lib/commonjs/skia/SkiaWorkletSerialization.js +66 -0
  94. package/lib/commonjs/skia/SkiaWorkletSerialization.js.map +1 -0
  95. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +15 -6
  96. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  97. package/lib/commonjs/skia/types/Skia.d.ts +5 -15
  98. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  99. package/lib/commonjs/skia/types/index.d.ts +0 -1
  100. package/lib/commonjs/skia/types/index.js +0 -11
  101. package/lib/commonjs/skia/types/index.js.map +1 -1
  102. package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
  103. package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
  104. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  105. package/lib/commonjs/skia/web/JsiSkia.js +1 -4
  106. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  107. package/lib/commonjs/sksg/Container.native.js +20 -1
  108. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  109. package/lib/commonjs/views/index.d.ts +0 -1
  110. package/lib/commonjs/views/index.js +0 -11
  111. package/lib/commonjs/views/index.js.map +1 -1
  112. package/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
  113. package/lib/module/external/reanimated/renderHelpers.js +29 -0
  114. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  115. package/lib/module/mock/index.js +0 -1
  116. package/lib/module/mock/index.js.map +1 -1
  117. package/lib/module/skia/NativeSetup.js +4 -0
  118. package/lib/module/skia/NativeSetup.js.map +1 -1
  119. package/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
  120. package/lib/module/skia/SkiaWorkletSerialization.js +59 -0
  121. package/lib/module/skia/SkiaWorkletSerialization.js.map +1 -0
  122. package/lib/module/skia/types/Image/ImageFactory.d.ts +15 -6
  123. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  124. package/lib/module/skia/types/Skia.d.ts +5 -15
  125. package/lib/module/skia/types/Skia.js.map +1 -1
  126. package/lib/module/skia/types/index.d.ts +0 -1
  127. package/lib/module/skia/types/index.js +0 -1
  128. package/lib/module/skia/types/index.js.map +1 -1
  129. package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
  130. package/lib/module/skia/web/JsiSkImageFactory.js +2 -2
  131. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  132. package/lib/module/skia/web/JsiSkia.js +1 -4
  133. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  134. package/lib/module/sksg/Container.native.js +21 -2
  135. package/lib/module/sksg/Container.native.js.map +1 -1
  136. package/lib/module/views/index.d.ts +0 -1
  137. package/lib/module/views/index.js +0 -1
  138. package/lib/module/views/index.js.map +1 -1
  139. package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +2 -0
  140. package/lib/typescript/lib/commonjs/mock/index.d.ts +0 -1
  141. package/lib/typescript/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +2 -0
  142. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
  143. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +1 -2
  144. package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
  145. package/lib/typescript/lib/module/mock/index.d.ts +0 -2
  146. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -2
  147. package/lib/typescript/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
  148. package/lib/typescript/lib/module/skia/types/index.d.ts +0 -1
  149. package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
  150. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +1 -2
  151. package/lib/typescript/lib/module/views/index.d.ts +0 -1
  152. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +15 -0
  153. package/lib/typescript/src/skia/SkiaWorkletSerialization.d.ts +1 -0
  154. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +15 -6
  155. package/lib/typescript/src/skia/types/Skia.d.ts +5 -15
  156. package/lib/typescript/src/skia/types/index.d.ts +0 -1
  157. package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -2
  158. package/lib/typescript/src/views/index.d.ts +0 -1
  159. package/package.json +8 -5
  160. package/react-native-skia.podspec +38 -5
  161. package/src/external/reanimated/renderHelpers.ts +30 -0
  162. package/src/mock/index.ts +0 -1
  163. package/src/skia/NativeSetup.ts +5 -0
  164. package/src/skia/SkiaWorkletSerialization.ts +67 -0
  165. package/src/skia/types/Image/ImageFactory.ts +15 -6
  166. package/src/skia/types/Skia.ts +5 -15
  167. package/src/skia/types/index.ts +0 -1
  168. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  169. package/src/skia/web/JsiSkia.ts +2 -5
  170. package/src/sksg/Container.native.ts +40 -2
  171. package/src/views/index.ts +0 -1
  172. package/android/cpp/jni/JniWebGPUView.cpp +0 -112
  173. package/android/cpp/rnskia-android/SkiaPlatformContext.h +0 -26
  174. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUSurfaceView.java +0 -43
  175. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUTextureView.java +0 -50
  176. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUView.java +0 -98
  177. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewAPI.java +0 -19
  178. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewManager.java +0 -58
  179. package/apple/RNWebGPUAppleNativeBuffer.mm +0 -33
  180. package/apple/SkiaPlatformContext.h +0 -20
  181. package/apple/SkiaPlatformContext.mm +0 -21
  182. package/apple/SkiaWebGPUView.mm +0 -81
  183. package/apple/WebGPUMetalView.mm +0 -136
  184. package/cpp/api/JsiSkHostObjects.h +0 -257
  185. package/cpp/jsi/JsiHostObject.cpp +0 -137
  186. package/cpp/jsi/JsiHostObject.h +0 -385
  187. package/cpp/rnwgpu/ArrayBuffer.h +0 -117
  188. package/cpp/rnwgpu/Canvas.h +0 -50
  189. package/cpp/rnwgpu/PlatformContext.h +0 -18
  190. package/cpp/rnwgpu/SurfaceRegistry.h +0 -605
  191. package/cpp/rnwgpu/api/AppleNativeBuffer.h +0 -22
  192. package/cpp/rnwgpu/api/Convertors.h +0 -783
  193. package/cpp/rnwgpu/api/External.h +0 -12
  194. package/cpp/rnwgpu/api/GPU.cpp +0 -162
  195. package/cpp/rnwgpu/api/GPU.h +0 -60
  196. package/cpp/rnwgpu/api/GPUAdapter.cpp +0 -240
  197. package/cpp/rnwgpu/api/GPUAdapter.h +0 -60
  198. package/cpp/rnwgpu/api/GPUAdapterInfo.h +0 -57
  199. package/cpp/rnwgpu/api/GPUBindGroup.cpp +0 -3
  200. package/cpp/rnwgpu/api/GPUBindGroup.h +0 -51
  201. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +0 -52
  202. package/cpp/rnwgpu/api/GPUBuffer.cpp +0 -107
  203. package/cpp/rnwgpu/api/GPUBuffer.h +0 -88
  204. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +0 -75
  205. package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -70
  206. package/cpp/rnwgpu/api/GPUCommandBuffer.h +0 -45
  207. package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +0 -179
  208. package/cpp/rnwgpu/api/GPUCommandEncoder.h +0 -111
  209. package/cpp/rnwgpu/api/GPUCompilationInfo.h +0 -79
  210. package/cpp/rnwgpu/api/GPUCompilationMessage.h +0 -36
  211. package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +0 -60
  212. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +0 -85
  213. package/cpp/rnwgpu/api/GPUComputePipeline.cpp +0 -12
  214. package/cpp/rnwgpu/api/GPUComputePipeline.h +0 -60
  215. package/cpp/rnwgpu/api/GPUDevice.cpp +0 -614
  216. package/cpp/rnwgpu/api/GPUDevice.h +0 -258
  217. package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +0 -7
  218. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +0 -40
  219. package/cpp/rnwgpu/api/GPUError.h +0 -35
  220. package/cpp/rnwgpu/api/GPUExtent3D.h +0 -66
  221. package/cpp/rnwgpu/api/GPUExternalTexture.cpp +0 -139
  222. package/cpp/rnwgpu/api/GPUExternalTexture.h +0 -95
  223. package/cpp/rnwgpu/api/GPUFeatures.h +0 -203
  224. package/cpp/rnwgpu/api/GPUInternalError.h +0 -31
  225. package/cpp/rnwgpu/api/GPUOrigin2D.h +0 -55
  226. package/cpp/rnwgpu/api/GPUOrigin3D.h +0 -62
  227. package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +0 -33
  228. package/cpp/rnwgpu/api/GPUPipelineLayout.h +0 -45
  229. package/cpp/rnwgpu/api/GPUQuerySet.cpp +0 -11
  230. package/cpp/rnwgpu/api/GPUQuerySet.h +0 -73
  231. package/cpp/rnwgpu/api/GPUQueue.cpp +0 -179
  232. package/cpp/rnwgpu/api/GPUQueue.h +0 -84
  233. package/cpp/rnwgpu/api/GPURenderBundle.h +0 -44
  234. package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +0 -131
  235. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +0 -110
  236. package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +0 -165
  237. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +0 -130
  238. package/cpp/rnwgpu/api/GPURenderPipeline.cpp +0 -13
  239. package/cpp/rnwgpu/api/GPURenderPipeline.h +0 -61
  240. package/cpp/rnwgpu/api/GPUSampler.h +0 -44
  241. package/cpp/rnwgpu/api/GPUShaderModule.cpp +0 -56
  242. package/cpp/rnwgpu/api/GPUShaderModule.h +0 -66
  243. package/cpp/rnwgpu/api/GPUSharedFence.cpp +0 -80
  244. package/cpp/rnwgpu/api/GPUSharedFence.h +0 -53
  245. package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +0 -135
  246. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +0 -75
  247. package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +0 -129
  248. package/cpp/rnwgpu/api/GPUSupportedLimits.h +0 -131
  249. package/cpp/rnwgpu/api/GPUTexture.cpp +0 -47
  250. package/cpp/rnwgpu/api/GPUTexture.h +0 -162
  251. package/cpp/rnwgpu/api/GPUTextureView.h +0 -44
  252. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +0 -60
  253. package/cpp/rnwgpu/api/GPUValidationError.h +0 -32
  254. package/cpp/rnwgpu/api/ImageBitmap.h +0 -62
  255. package/cpp/rnwgpu/api/NativeBufferUtils.h +0 -87
  256. package/cpp/rnwgpu/api/RNWebGPU.h +0 -82
  257. package/cpp/rnwgpu/api/WebGPUConstants.h +0 -36
  258. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +0 -64
  259. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +0 -78
  260. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +0 -56
  261. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +0 -97
  262. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +0 -57
  263. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +0 -52
  264. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +0 -56
  265. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +0 -56
  266. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +0 -59
  267. package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +0 -39
  268. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +0 -76
  269. package/cpp/rnwgpu/api/descriptors/GPUColor.h +0 -66
  270. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +0 -58
  271. package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +0 -29
  272. package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +0 -45
  273. package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +0 -45
  274. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +0 -56
  275. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +0 -58
  276. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +0 -67
  277. package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +0 -56
  278. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +0 -103
  279. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +0 -109
  280. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +0 -38
  281. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +0 -90
  282. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +0 -73
  283. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +0 -62
  284. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +0 -63
  285. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +0 -65
  286. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +0 -81
  287. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +0 -54
  288. package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +0 -22
  289. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +0 -54
  290. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +0 -57
  291. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +0 -69
  292. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +0 -61
  293. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +0 -55
  294. package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +0 -43
  295. package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +0 -45
  296. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +0 -80
  297. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +0 -81
  298. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +0 -101
  299. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +0 -92
  300. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +0 -58
  301. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +0 -103
  302. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +0 -51
  303. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +0 -45
  304. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +0 -110
  305. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +0 -60
  306. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +0 -62
  307. package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +0 -25
  308. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +0 -58
  309. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +0 -51
  310. package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +0 -73
  311. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +0 -64
  312. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +0 -59
  313. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +0 -59
  314. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +0 -91
  315. package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +0 -29
  316. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +0 -91
  317. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +0 -64
  318. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +0 -53
  319. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +0 -62
  320. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +0 -73
  321. package/cpp/rnwgpu/api/descriptors/Unions.h +0 -1969
  322. package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +0 -214
  323. package/cpp/rnwgpu/async/AsyncTaskHandle.h +0 -58
  324. package/cpp/rnwgpu/async/RuntimeContext.cpp +0 -199
  325. package/cpp/rnwgpu/async/RuntimeContext.h +0 -134
  326. package/lib/commonjs/skia/types/WebGPU.d.ts +0 -184
  327. package/lib/commonjs/skia/types/WebGPU.js +0 -105
  328. package/lib/commonjs/skia/types/WebGPU.js.map +0 -1
  329. package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -8
  330. package/lib/commonjs/specs/WebGPUViewNativeComponent.js +0 -10
  331. package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +0 -1
  332. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  333. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +0 -103
  334. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +0 -1
  335. package/lib/commonjs/specs/utils.d.ts +0 -1
  336. package/lib/commonjs/specs/utils.js +0 -11
  337. package/lib/commonjs/specs/utils.js.map +0 -1
  338. package/lib/commonjs/views/WebGPUCanvas.d.ts +0 -33
  339. package/lib/commonjs/views/WebGPUCanvas.js +0 -79
  340. package/lib/commonjs/views/WebGPUCanvas.js.map +0 -1
  341. package/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -23
  342. package/lib/commonjs/views/WebGPUCanvas.web.js +0 -20
  343. package/lib/commonjs/views/WebGPUCanvas.web.js.map +0 -1
  344. package/lib/module/skia/types/WebGPU.d.ts +0 -184
  345. package/lib/module/skia/types/WebGPU.js +0 -99
  346. package/lib/module/skia/types/WebGPU.js.map +0 -1
  347. package/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -8
  348. package/lib/module/specs/WebGPUViewNativeComponent.js +0 -4
  349. package/lib/module/specs/WebGPUViewNativeComponent.js.map +0 -1
  350. package/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  351. package/lib/module/specs/WebGPUViewNativeComponent.web.js +0 -96
  352. package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +0 -1
  353. package/lib/module/specs/utils.d.ts +0 -1
  354. package/lib/module/specs/utils.js +0 -5
  355. package/lib/module/specs/utils.js.map +0 -1
  356. package/lib/module/views/WebGPUCanvas.d.ts +0 -33
  357. package/lib/module/views/WebGPUCanvas.js +0 -70
  358. package/lib/module/views/WebGPUCanvas.js.map +0 -1
  359. package/lib/module/views/WebGPUCanvas.web.d.ts +0 -23
  360. package/lib/module/views/WebGPUCanvas.web.js +0 -12
  361. package/lib/module/views/WebGPUCanvas.web.js.map +0 -1
  362. package/lib/typescript/lib/commonjs/skia/types/WebGPU.d.ts +0 -2
  363. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -4
  364. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -3
  365. package/lib/typescript/lib/commonjs/specs/utils.d.ts +0 -2
  366. package/lib/typescript/lib/commonjs/views/WebGPUCanvas.d.ts +0 -6
  367. package/lib/typescript/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -6
  368. package/lib/typescript/lib/module/skia/types/WebGPU.d.ts +0 -31
  369. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -2
  370. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -2
  371. package/lib/typescript/lib/module/specs/utils.d.ts +0 -1
  372. package/lib/typescript/lib/module/views/WebGPUCanvas.d.ts +0 -7
  373. package/lib/typescript/lib/module/views/WebGPUCanvas.web.d.ts +0 -8
  374. package/lib/typescript/src/skia/types/WebGPU.d.ts +0 -184
  375. package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +0 -8
  376. package/lib/typescript/src/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  377. package/lib/typescript/src/specs/utils.d.ts +0 -1
  378. package/lib/typescript/src/views/WebGPUCanvas.d.ts +0 -33
  379. package/lib/typescript/src/views/WebGPUCanvas.web.d.ts +0 -23
  380. package/src/skia/types/WebGPU.ts +0 -226
  381. package/src/specs/WebGPUViewNativeComponent.ts +0 -11
  382. package/src/specs/WebGPUViewNativeComponent.web.ts +0 -110
  383. package/src/specs/utils.ts +0 -4
  384. package/src/views/WebGPUCanvas.tsx +0 -125
  385. package/src/views/WebGPUCanvas.web.tsx +0 -36
  386. /package/cpp/{jsi2 → jsi}/Promise.cpp +0 -0
  387. /package/cpp/{jsi2 → jsi}/Promise.h +0 -0
@@ -2,15 +2,18 @@
2
2
 
3
3
  #include <algorithm>
4
4
  #include <memory>
5
+ #include <optional>
5
6
  #include <set>
6
7
  #include <string>
7
8
  #include <utility>
9
+ #include <variant>
8
10
  #include <vector>
9
11
 
10
12
  #include <jsi/jsi.h>
11
13
 
12
- #include "JsiSkHostObjects.h"
14
+ #include "JsiSkConverters.h"
13
15
  #include "JsiSkMatrix.h"
16
+ #include "JsiSkNativeObjects.h"
14
17
  #include "JsiSkPoint.h"
15
18
  #include "JsiSkRRect.h"
16
19
  #include "JsiSkRect.h"
@@ -61,7 +64,11 @@ inline void warnDeprecatedPathMethod(jsi::Runtime &runtime,
61
64
  RNSkLogger::warnToJavascriptConsole(runtime, message);
62
65
  }
63
66
 
64
- class JsiSkPath : public JsiSkWrappingSharedPtrHostObject<SkPathBuilder> {
67
+ class JsiSkPath
68
+ : public JsiSkWrappingSharedPtrNativeObject<JsiSkPath, SkPathBuilder> {
69
+ public:
70
+ static constexpr const char *CLASS_NAME = "Path";
71
+
65
72
  private:
66
73
  static const int MOVE = 0;
67
74
  static const int LINE = 1;
@@ -73,338 +80,233 @@ private:
73
80
  SkPath asPath() const { return getObject()->snapshot(); }
74
81
 
75
82
  public:
76
- // Mutable building methods (deprecated)
83
+ // Mutable building methods (deprecated) — chainable, and they take the
84
+ // runtime for the JS console deprecation warning.
77
85
 
78
- JSI_HOST_FUNCTION(moveTo) {
86
+ void moveTo(jsi::Runtime &runtime, double x, double y) {
79
87
  warnDeprecatedPathMethod(runtime, "moveTo",
80
88
  "Use Skia.PathBuilder.Make().moveTo() instead.");
81
- SkScalar x = arguments[0].asNumber();
82
- SkScalar y = arguments[1].asNumber();
83
89
  getObject()->moveTo(x, y);
84
- return thisValue.getObject(runtime);
85
90
  }
86
91
 
87
- JSI_HOST_FUNCTION(rMoveTo) {
92
+ void rMoveTo(jsi::Runtime &runtime, double x, double y) {
88
93
  warnDeprecatedPathMethod(runtime, "rMoveTo",
89
94
  "Use Skia.PathBuilder.Make().rMoveTo() instead.");
90
- SkScalar x = arguments[0].asNumber();
91
- SkScalar y = arguments[1].asNumber();
92
- getObject()->rMoveTo({x, y});
93
- return thisValue.getObject(runtime);
95
+ getObject()->rMoveTo({static_cast<SkScalar>(x), static_cast<SkScalar>(y)});
94
96
  }
95
97
 
96
- JSI_HOST_FUNCTION(lineTo) {
98
+ void lineTo(jsi::Runtime &runtime, double x, double y) {
97
99
  warnDeprecatedPathMethod(runtime, "lineTo",
98
100
  "Use Skia.PathBuilder.Make().lineTo() instead.");
99
- SkScalar x = arguments[0].asNumber();
100
- SkScalar y = arguments[1].asNumber();
101
101
  getObject()->lineTo(x, y);
102
- return thisValue.getObject(runtime);
103
102
  }
104
103
 
105
- JSI_HOST_FUNCTION(rLineTo) {
104
+ void rLineTo(jsi::Runtime &runtime, double x, double y) {
106
105
  warnDeprecatedPathMethod(runtime, "rLineTo",
107
106
  "Use Skia.PathBuilder.Make().rLineTo() instead.");
108
- SkScalar x = arguments[0].asNumber();
109
- SkScalar y = arguments[1].asNumber();
110
107
  getObject()->rLineTo(x, y);
111
- return thisValue.getObject(runtime);
112
108
  }
113
109
 
114
- JSI_HOST_FUNCTION(quadTo) {
110
+ void quadTo(jsi::Runtime &runtime, double x1, double y1, double x2,
111
+ double y2) {
115
112
  warnDeprecatedPathMethod(runtime, "quadTo",
116
113
  "Use Skia.PathBuilder.Make().quadTo() instead.");
117
- SkScalar x1 = arguments[0].asNumber();
118
- SkScalar y1 = arguments[1].asNumber();
119
- SkScalar x2 = arguments[2].asNumber();
120
- SkScalar y2 = arguments[3].asNumber();
121
114
  getObject()->quadTo(x1, y1, x2, y2);
122
- return thisValue.getObject(runtime);
123
115
  }
124
116
 
125
- JSI_HOST_FUNCTION(rQuadTo) {
117
+ void rQuadTo(jsi::Runtime &runtime, double x1, double y1, double x2,
118
+ double y2) {
126
119
  warnDeprecatedPathMethod(runtime, "rQuadTo",
127
120
  "Use Skia.PathBuilder.Make().rQuadTo() instead.");
128
- SkScalar x1 = arguments[0].asNumber();
129
- SkScalar y1 = arguments[1].asNumber();
130
- SkScalar x2 = arguments[2].asNumber();
131
- SkScalar y2 = arguments[3].asNumber();
132
121
  getObject()->rQuadTo(x1, y1, x2, y2);
133
- return thisValue.getObject(runtime);
134
122
  }
135
123
 
136
- JSI_HOST_FUNCTION(conicTo) {
124
+ void conicTo(jsi::Runtime &runtime, double x1, double y1, double x2,
125
+ double y2, double w) {
137
126
  warnDeprecatedPathMethod(runtime, "conicTo",
138
127
  "Use Skia.PathBuilder.Make().conicTo() instead.");
139
- SkScalar x1 = arguments[0].asNumber();
140
- SkScalar y1 = arguments[1].asNumber();
141
- SkScalar x2 = arguments[2].asNumber();
142
- SkScalar y2 = arguments[3].asNumber();
143
- SkScalar w = arguments[4].asNumber();
144
128
  getObject()->conicTo(x1, y1, x2, y2, w);
145
- return thisValue.getObject(runtime);
146
129
  }
147
130
 
148
- JSI_HOST_FUNCTION(rConicTo) {
131
+ void rConicTo(jsi::Runtime &runtime, double x1, double y1, double x2,
132
+ double y2, double w) {
149
133
  warnDeprecatedPathMethod(runtime, "rConicTo",
150
134
  "Use Skia.PathBuilder.Make().rConicTo() instead.");
151
- SkScalar x1 = arguments[0].asNumber();
152
- SkScalar y1 = arguments[1].asNumber();
153
- SkScalar x2 = arguments[2].asNumber();
154
- SkScalar y2 = arguments[3].asNumber();
155
- SkScalar w = arguments[4].asNumber();
156
135
  getObject()->rConicTo(x1, y1, x2, y2, w);
157
- return thisValue.getObject(runtime);
158
136
  }
159
137
 
160
- JSI_HOST_FUNCTION(cubicTo) {
138
+ void cubicTo(jsi::Runtime &runtime, double x1, double y1, double x2,
139
+ double y2, double x3, double y3) {
161
140
  warnDeprecatedPathMethod(runtime, "cubicTo",
162
141
  "Use Skia.PathBuilder.Make().cubicTo() instead.");
163
- SkScalar x1 = arguments[0].asNumber();
164
- SkScalar y1 = arguments[1].asNumber();
165
- SkScalar x2 = arguments[2].asNumber();
166
- SkScalar y2 = arguments[3].asNumber();
167
- SkScalar x3 = arguments[4].asNumber();
168
- SkScalar y3 = arguments[5].asNumber();
169
142
  getObject()->cubicTo(x1, y1, x2, y2, x3, y3);
170
- return thisValue.getObject(runtime);
171
143
  }
172
144
 
173
- JSI_HOST_FUNCTION(rCubicTo) {
145
+ void rCubicTo(jsi::Runtime &runtime, double x1, double y1, double x2,
146
+ double y2, double x3, double y3) {
174
147
  warnDeprecatedPathMethod(runtime, "rCubicTo",
175
148
  "Use Skia.PathBuilder.Make().rCubicTo() instead.");
176
- SkScalar x1 = arguments[0].asNumber();
177
- SkScalar y1 = arguments[1].asNumber();
178
- SkScalar x2 = arguments[2].asNumber();
179
- SkScalar y2 = arguments[3].asNumber();
180
- SkScalar x3 = arguments[4].asNumber();
181
- SkScalar y3 = arguments[5].asNumber();
182
149
  getObject()->rCubicTo(x1, y1, x2, y2, x3, y3);
183
- return thisValue.getObject(runtime);
184
150
  }
185
151
 
186
- JSI_HOST_FUNCTION(close) {
152
+ void close(jsi::Runtime &runtime) {
187
153
  warnDeprecatedPathMethod(runtime, "close",
188
154
  "Use Skia.PathBuilder.Make().close() instead.");
189
155
  getObject()->close();
190
- return thisValue.getObject(runtime);
191
156
  }
192
157
 
193
- JSI_HOST_FUNCTION(reset) {
158
+ void reset(jsi::Runtime &runtime) {
194
159
  warnDeprecatedPathMethod(runtime, "reset",
195
160
  "Use Skia.PathBuilder.Make().reset() instead.");
196
161
  getObject()->reset();
197
- return thisValue.getObject(runtime);
198
162
  }
199
163
 
200
- JSI_HOST_FUNCTION(rewind) {
164
+ void rewind(jsi::Runtime &runtime) {
201
165
  warnDeprecatedPathMethod(runtime, "rewind",
202
166
  "Use Skia.PathBuilder.Make().reset() instead.");
203
167
  getObject()->reset();
204
- return thisValue.getObject(runtime);
205
168
  }
206
169
 
207
- JSI_HOST_FUNCTION(addPath) {
170
+ void addPath(jsi::Runtime &runtime, std::shared_ptr<SkPathBuilder> src,
171
+ JsiOptional<std::shared_ptr<SkMatrix>> matrix,
172
+ JsiOptional<bool> extend) {
208
173
  warnDeprecatedPathMethod(runtime, "addPath",
209
174
  "Use Skia.PathBuilder.Make().addPath() instead.");
210
- auto src = JsiSkPath::fromValue(runtime, arguments[0]);
211
175
  auto srcPath = src->snapshot();
212
- auto matrix =
213
- count > 1 && !arguments[1].isUndefined() && !arguments[1].isNull()
214
- ? JsiSkMatrix::fromValue(runtime, arguments[1])
215
- : nullptr;
216
- auto extend = count > 2 && arguments[2].getBool();
217
- auto mode =
218
- extend ? SkPath::kExtend_AddPathMode : SkPath::kAppend_AddPathMode;
219
- if (matrix) {
220
- getObject()->addPath(srcPath, *matrix, mode);
176
+ auto mode = extend.has_value() && *extend ? SkPath::kExtend_AddPathMode
177
+ : SkPath::kAppend_AddPathMode;
178
+ if (matrix.has_value()) {
179
+ getObject()->addPath(srcPath, **matrix, mode);
221
180
  } else {
222
181
  getObject()->addPath(srcPath, mode);
223
182
  }
224
- return thisValue.getObject(runtime);
225
183
  }
226
184
 
227
- JSI_HOST_FUNCTION(addArc) {
185
+ void addArc(jsi::Runtime &runtime, std::shared_ptr<SkRect> rect,
186
+ double start, double sweep) {
228
187
  warnDeprecatedPathMethod(runtime, "addArc",
229
188
  "Use Skia.PathBuilder.Make().addArc() instead.");
230
- auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
231
- auto start = arguments[1].asNumber();
232
- auto sweep = arguments[2].asNumber();
233
189
  getObject()->addArc(*rect, start, sweep);
234
- return thisValue.getObject(runtime);
235
190
  }
236
191
 
237
- JSI_HOST_FUNCTION(addOval) {
192
+ void addOval(jsi::Runtime &runtime, std::shared_ptr<SkRect> rect,
193
+ JsiOptional<bool> isCCW, JsiOptional<double> startIndex) {
238
194
  warnDeprecatedPathMethod(
239
195
  runtime, "addOval",
240
196
  "Use Skia.Path.Oval() or Skia.PathBuilder.Make().addOval() instead.");
241
- auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
242
- auto isCCW = count > 1 && arguments[1].getBool();
243
- auto startIndex =
244
- count > 2 ? static_cast<unsigned>(arguments[2].asNumber()) : 1;
245
- auto direction = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
246
- getObject()->addOval(*rect, direction, startIndex);
247
- return thisValue.getObject(runtime);
197
+ getObject()->addOval(*rect, toDirection(isCCW),
198
+ startIndex.has_value()
199
+ ? static_cast<unsigned>(*startIndex)
200
+ : 1);
248
201
  }
249
202
 
250
- JSI_HOST_FUNCTION(addRect) {
203
+ void addRect(jsi::Runtime &runtime, std::shared_ptr<SkRect> rect,
204
+ JsiOptional<bool> isCCW) {
251
205
  warnDeprecatedPathMethod(
252
206
  runtime, "addRect",
253
207
  "Use Skia.Path.Rect() or Skia.PathBuilder.Make().addRect() instead.");
254
- auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
255
- auto isCCW = count > 1 && arguments[1].getBool();
256
- auto direction = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
257
- getObject()->addRect(*rect, direction);
258
- return thisValue.getObject(runtime);
208
+ getObject()->addRect(*rect, toDirection(isCCW));
259
209
  }
260
210
 
261
- JSI_HOST_FUNCTION(addRRect) {
211
+ void addRRect(jsi::Runtime &runtime, std::shared_ptr<SkRRect> rrect,
212
+ JsiOptional<bool> isCCW) {
262
213
  warnDeprecatedPathMethod(
263
214
  runtime, "addRRect",
264
215
  "Use Skia.Path.RRect() or Skia.PathBuilder.Make().addRRect() instead.");
265
- auto rrect = JsiSkRRect::fromValue(runtime, arguments[0]);
266
- auto isCCW = count > 1 && arguments[1].getBool();
267
- auto direction = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
268
- getObject()->addRRect(*rrect, direction);
269
- return thisValue.getObject(runtime);
216
+ getObject()->addRRect(*rrect, toDirection(isCCW));
270
217
  }
271
218
 
272
- JSI_HOST_FUNCTION(addCircle) {
219
+ void addCircle(jsi::Runtime &runtime, double x, double y, double r) {
273
220
  warnDeprecatedPathMethod(
274
221
  runtime, "addCircle",
275
222
  "Use Skia.Path.Circle() or Skia.PathBuilder.Make().addCircle() "
276
223
  "instead.");
277
- SkScalar x = arguments[0].asNumber();
278
- SkScalar y = arguments[1].asNumber();
279
- SkScalar r = arguments[2].asNumber();
280
224
  getObject()->addCircle(x, y, r);
281
- return thisValue.getObject(runtime);
282
225
  }
283
226
 
284
- JSI_HOST_FUNCTION(addPoly) {
227
+ void addPoly(jsi::Runtime &runtime, std::vector<SkPoint> points,
228
+ bool close) {
285
229
  warnDeprecatedPathMethod(
286
230
  runtime, "addPoly",
287
231
  "Use Skia.Path.Polygon() or Skia.PathBuilder.Make().addPoly() "
288
232
  "instead.");
289
- auto jsiPoints = arguments[0].asObject(runtime).asArray(runtime);
290
- auto close = arguments[1].getBool();
291
- auto pointsSize = static_cast<int>(jsiPoints.size(runtime));
292
- std::vector<SkPoint> points;
293
- points.reserve(pointsSize);
294
- for (int i = 0; i < pointsSize; i++) {
295
- auto pt =
296
- JsiSkPoint::fromValue(runtime, jsiPoints.getValueAtIndex(runtime, i));
297
- points.push_back(*pt);
298
- }
299
233
  getObject()->addPolygon(SkSpan<const SkPoint>(points.data(), points.size()),
300
234
  close);
301
- return thisValue.getObject(runtime);
302
235
  }
303
236
 
304
- JSI_HOST_FUNCTION(arcToOval) {
237
+ void arcToOval(jsi::Runtime &runtime, std::shared_ptr<SkRect> rect,
238
+ double start, double sweep, bool forceMoveTo) {
305
239
  warnDeprecatedPathMethod(
306
240
  runtime, "arcToOval",
307
241
  "Use Skia.PathBuilder.Make().arcToOval() instead.");
308
- auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
309
- auto start = arguments[1].asNumber();
310
- auto sweep = arguments[2].asNumber();
311
- auto forceMoveTo = arguments[3].getBool();
312
242
  getObject()->arcTo(*rect, start, sweep, forceMoveTo);
313
- return thisValue.getObject(runtime);
314
243
  }
315
244
 
316
- JSI_HOST_FUNCTION(arcToRotated) {
245
+ void arcToRotated(jsi::Runtime &runtime, double rx, double ry,
246
+ double xAxisRotate, bool useSmallArc, bool isCCW, double x,
247
+ double y) {
317
248
  warnDeprecatedPathMethod(
318
249
  runtime, "arcToRotated",
319
250
  "Use Skia.PathBuilder.Make().arcToRotated() instead.");
320
- SkScalar rx = arguments[0].asNumber();
321
- SkScalar ry = arguments[1].asNumber();
322
- SkScalar xAxisRotate = arguments[2].asNumber();
323
- auto useSmallArc = arguments[3].getBool();
324
- auto isCCW = arguments[4].getBool();
325
- SkScalar x = arguments[5].asNumber();
326
- SkScalar y = arguments[6].asNumber();
327
251
  auto arcSize = useSmallArc ? SkPathBuilder::kSmall_ArcSize
328
252
  : SkPathBuilder::kLarge_ArcSize;
329
253
  auto sweep = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
330
254
  getObject()->arcTo(SkPoint::Make(rx, ry), xAxisRotate, arcSize, sweep,
331
255
  SkPoint::Make(x, y));
332
- return thisValue.getObject(runtime);
333
256
  }
334
257
 
335
- JSI_HOST_FUNCTION(rArcTo) {
258
+ void rArcTo(jsi::Runtime &runtime, double rx, double ry, double xAxisRotate,
259
+ bool useSmallArc, bool isCCW, double dx, double dy) {
336
260
  warnDeprecatedPathMethod(runtime, "rArcTo",
337
261
  "Use Skia.PathBuilder.Make().rArcTo() instead.");
338
- SkScalar rx = arguments[0].asNumber();
339
- SkScalar ry = arguments[1].asNumber();
340
- SkScalar xAxisRotate = arguments[2].asNumber();
341
- auto useSmallArc = arguments[3].getBool();
342
- auto isCCW = arguments[4].getBool();
343
- SkScalar dx = arguments[5].asNumber();
344
- SkScalar dy = arguments[6].asNumber();
345
262
  auto arcSize = useSmallArc ? SkPathBuilder::kSmall_ArcSize
346
263
  : SkPathBuilder::kLarge_ArcSize;
347
264
  auto sweep = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
348
265
  SkVector dxdy(dx, dy);
349
266
  SkPoint r(rx, ry);
350
267
  getObject()->rArcTo(r, xAxisRotate, arcSize, sweep, dxdy);
351
- return thisValue.getObject(runtime);
352
268
  }
353
269
 
354
- JSI_HOST_FUNCTION(arcToTangent) {
270
+ void arcToTangent(jsi::Runtime &runtime, double x1, double y1, double x2,
271
+ double y2, double r) {
355
272
  warnDeprecatedPathMethod(
356
273
  runtime, "arcToTangent",
357
274
  "Use Skia.PathBuilder.Make().arcToTangent() instead.");
358
- SkScalar x1 = arguments[0].asNumber();
359
- SkScalar y1 = arguments[1].asNumber();
360
- SkScalar x2 = arguments[2].asNumber();
361
- SkScalar y2 = arguments[3].asNumber();
362
- SkScalar r = arguments[4].asNumber();
363
275
  getObject()->arcTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), r);
364
- return thisValue.getObject(runtime);
365
276
  }
366
277
 
367
- JSI_HOST_FUNCTION(setFillType) {
278
+ void setFillType(jsi::Runtime &runtime, double ft) {
368
279
  warnDeprecatedPathMethod(
369
280
  runtime, "setFillType",
370
281
  "Use Skia.PathBuilder.Make().setFillType() instead.");
371
- auto ft = arguments[0].asNumber();
372
282
  getObject()->setFillType(static_cast<SkPathFillType>(static_cast<int>(ft)));
373
- return thisValue.getObject(runtime);
374
283
  }
375
284
 
376
- JSI_HOST_FUNCTION(setIsVolatile) {
285
+ void setIsVolatile(jsi::Runtime &runtime, bool v) {
377
286
  warnDeprecatedPathMethod(
378
287
  runtime, "setIsVolatile",
379
288
  "Use Skia.PathBuilder.Make().setIsVolatile() instead.");
380
- auto v = arguments[0].getBool();
381
289
  getObject()->setIsVolatile(v);
382
- return thisValue.getObject(runtime);
383
290
  }
384
291
 
385
292
  // Mutable transform methods (deprecated)
386
293
 
387
- JSI_HOST_FUNCTION(transform) {
294
+ void transform(jsi::Runtime &runtime, std::shared_ptr<SkMatrix> m3) {
388
295
  warnDeprecatedPathMethod(
389
296
  runtime, "transform",
390
297
  "Use Skia.PathBuilder.Make().transform() instead.");
391
- auto m3 = *JsiSkMatrix::fromValue(runtime, arguments[0]);
392
- getObject()->transform(m3);
393
- return thisValue.getObject(runtime);
298
+ getObject()->transform(*m3);
394
299
  }
395
300
 
396
- JSI_HOST_FUNCTION(offset) {
301
+ void offset(jsi::Runtime &runtime, double dx, double dy) {
397
302
  warnDeprecatedPathMethod(runtime, "offset",
398
303
  "Use Skia.PathBuilder.Make().offset() instead.");
399
- SkScalar dx = arguments[0].asNumber();
400
- SkScalar dy = arguments[1].asNumber();
401
304
  getObject()->offset(dx, dy);
402
- return thisValue.getObject(runtime);
403
305
  }
404
306
 
405
307
  // Mutable path operations (deprecated)
406
308
 
407
- JSI_HOST_FUNCTION(simplify) {
309
+ void simplify(jsi::Runtime &runtime) {
408
310
  warnDeprecatedPathMethod(runtime, "simplify",
409
311
  "Use Skia.Path.Simplify(path) instead.");
410
312
  auto path = asPath();
@@ -412,25 +314,22 @@ public:
412
314
  if (result.has_value()) {
413
315
  *getObject() = SkPathBuilder(result.value());
414
316
  }
415
- return thisValue.getObject(runtime);
416
317
  }
417
318
 
418
- JSI_HOST_FUNCTION(op) {
319
+ void op(jsi::Runtime &runtime, std::shared_ptr<SkPathBuilder> path2,
320
+ double pathOp) {
419
321
  warnDeprecatedPathMethod(runtime, "op",
420
322
  "Use Skia.Path.MakeFromOp() instead.");
421
- auto path2 = JsiSkPath::fromValue(runtime, arguments[0]);
422
- auto pathOp =
423
- static_cast<SkPathOp>(static_cast<int>(arguments[1].asNumber()));
424
323
  auto p1 = asPath();
425
324
  auto p2 = path2->snapshot();
426
- auto result = ::Op(p1, p2, pathOp);
325
+ auto result =
326
+ ::Op(p1, p2, static_cast<SkPathOp>(static_cast<int>(pathOp)));
427
327
  if (result.has_value()) {
428
328
  *getObject() = SkPathBuilder(result.value());
429
329
  }
430
- return thisValue.getObject(runtime);
431
330
  }
432
331
 
433
- JSI_HOST_FUNCTION(makeAsWinding) {
332
+ void makeAsWinding(jsi::Runtime &runtime) {
434
333
  warnDeprecatedPathMethod(runtime, "makeAsWinding",
435
334
  "Use Skia.Path.AsWinding(path) instead.");
436
335
  auto path = asPath();
@@ -438,17 +337,14 @@ public:
438
337
  if (result.has_value()) {
439
338
  *getObject() = SkPathBuilder(result.value());
440
339
  }
441
- return thisValue.getObject(runtime);
442
340
  }
443
341
 
444
- JSI_HOST_FUNCTION(dash) {
342
+ void dash(jsi::Runtime &runtime, double on, double off, double phase) {
445
343
  warnDeprecatedPathMethod(
446
344
  runtime, "dash", "Use Skia.Path.Dash(path, on, off, phase) instead.");
447
345
  auto path = asPath();
448
- SkScalar on = arguments[0].asNumber();
449
- SkScalar off = arguments[1].asNumber();
450
- auto phase = arguments[2].asNumber();
451
- SkScalar intervals[] = {on, off};
346
+ SkScalar intervals[] = {static_cast<SkScalar>(on),
347
+ static_cast<SkScalar>(off)};
452
348
  auto pe = SkDashPathEffect::Make(SkSpan(intervals, 2), phase);
453
349
  if (pe) {
454
350
  SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
@@ -457,9 +353,9 @@ public:
457
353
  *getObject() = std::move(resultBuilder);
458
354
  }
459
355
  }
460
- return thisValue.getObject(runtime);
461
356
  }
462
357
 
358
+ // Stays raw: the options object is read leniently property by property.
463
359
  JSI_HOST_FUNCTION(stroke) {
464
360
  warnDeprecatedPathMethod(runtime, "stroke",
465
361
  "Use Skia.Path.Stroke(path, opts) instead.");
@@ -501,16 +397,14 @@ public:
501
397
  return thisValue.getObject(runtime);
502
398
  }
503
399
 
504
- JSI_HOST_FUNCTION(trim) {
400
+ void trim(jsi::Runtime &runtime, double startValue, double endValue,
401
+ bool isComplement) {
505
402
  warnDeprecatedPathMethod(
506
403
  runtime, "trim",
507
404
  "Use Skia.Path.Trim(path, start, end, isComplement) instead.");
508
405
  auto path = asPath();
509
- float start =
510
- std::clamp(static_cast<float>(arguments[0].asNumber()), 0.0f, 1.0f);
511
- float end =
512
- std::clamp(static_cast<float>(arguments[1].asNumber()), 0.0f, 1.0f);
513
- auto isComplement = arguments[2].getBool();
406
+ float start = std::clamp(static_cast<float>(startValue), 0.0f, 1.0f);
407
+ float end = std::clamp(static_cast<float>(endValue), 0.0f, 1.0f);
514
408
  auto mode = isComplement ? SkTrimPathEffect::Mode::kInverted
515
409
  : SkTrimPathEffect::Mode::kNormal;
516
410
  auto pe = SkTrimPathEffect::Make(start, end, mode);
@@ -521,112 +415,77 @@ public:
521
415
  *getObject() = std::move(resultBuilder);
522
416
  }
523
417
  }
524
- return thisValue.getObject(runtime);
525
418
  }
526
419
 
527
420
  // Query methods
528
421
 
529
- JSI_HOST_FUNCTION(computeTightBounds) {
422
+ std::shared_ptr<JsiSkRect> computeTightBounds() {
530
423
  auto path = asPath();
531
- auto result = path.computeTightBounds();
532
- auto hostObjectInstance = std::make_shared<JsiSkRect>(getContext(), result);
533
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
534
- runtime, hostObjectInstance, getContext());
424
+ return std::make_shared<JsiSkRect>(getContext(),
425
+ path.computeTightBounds());
535
426
  }
536
427
 
537
- JSI_HOST_FUNCTION(getBounds) {
538
- auto result = getObject()->computeBounds();
539
- auto hostObjectInstance = std::make_shared<JsiSkRect>(getContext(), result);
540
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
541
- runtime, hostObjectInstance, getContext());
428
+ std::shared_ptr<JsiSkRect> getBounds() {
429
+ return std::make_shared<JsiSkRect>(getContext(),
430
+ getObject()->computeBounds());
542
431
  }
543
432
 
544
- JSI_HOST_FUNCTION(contains) {
545
- auto x = arguments[0].asNumber();
546
- auto y = arguments[1].asNumber();
547
- return jsi::Value(asPath().contains(x, y));
548
- }
433
+ bool contains(double x, double y) { return asPath().contains(x, y); }
549
434
 
550
- JSI_HOST_FUNCTION(getFillType) {
551
- auto fillType = getObject()->fillType();
552
- return jsi::Value(static_cast<int>(fillType));
553
- }
435
+ int getFillType() { return static_cast<int>(getObject()->fillType()); }
554
436
 
555
- JSI_HOST_FUNCTION(isVolatile) { return jsi::Value(asPath().isVolatile()); }
437
+ bool isVolatile() { return asPath().isVolatile(); }
556
438
 
557
- JSI_HOST_FUNCTION(getPoint) {
558
- auto index = arguments[0].asNumber();
439
+ std::shared_ptr<JsiSkPoint> getPoint(int index) {
559
440
  auto point = asPath().getPoint(index);
560
- auto hostObjectInstance = std::make_shared<JsiSkPoint>(getContext(), point);
561
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
562
- runtime, hostObjectInstance, getContext());
441
+ return std::make_shared<JsiSkPoint>(getContext(), point);
563
442
  }
564
443
 
565
- JSI_HOST_FUNCTION(isEmpty) { return jsi::Value(getObject()->isEmpty()); }
444
+ bool isEmpty() { return getObject()->isEmpty(); }
566
445
 
567
- JSI_HOST_FUNCTION(countPoints) {
568
- auto points = asPath().countPoints();
569
- return jsi::Value(points);
570
- }
446
+ int countPoints() { return asPath().countPoints(); }
571
447
 
572
- JSI_HOST_FUNCTION(getLastPt) {
448
+ SkPoint getLastPt() {
573
449
  auto last = getObject()->getLastPt();
574
- auto point = jsi::Object(runtime);
575
- if (last.has_value()) {
576
- point.setProperty(runtime, "x", static_cast<double>(last->fX));
577
- point.setProperty(runtime, "y", static_cast<double>(last->fY));
578
- } else {
579
- point.setProperty(runtime, "x", 0.0);
580
- point.setProperty(runtime, "y", 0.0);
581
- }
582
- return point;
450
+ return last.value_or(SkPoint::Make(0, 0));
583
451
  }
584
452
 
585
- JSI_HOST_FUNCTION(toSVGString) {
453
+ std::string toSVGString() {
586
454
  auto path = asPath();
587
455
  auto s = SkParsePath::ToSVGString(path);
588
- return jsi::String::createFromUtf8(runtime, s.c_str());
456
+ return std::string(s.c_str());
589
457
  }
590
458
 
591
- JSI_HOST_FUNCTION(equals) {
592
- auto p1 = JsiSkPath::fromValue(runtime, arguments[0]);
593
- auto p2 = JsiSkPath::fromValue(runtime, arguments[1]);
594
- return jsi::Value(p1->snapshot() == p2->snapshot());
459
+ bool equals(std::shared_ptr<SkPathBuilder> p1,
460
+ std::shared_ptr<SkPathBuilder> p2) {
461
+ return p1->snapshot() == p2->snapshot();
595
462
  }
596
463
 
597
- JSI_HOST_FUNCTION(copy) {
598
- auto path = asPath();
599
- auto hostObjectInstance = std::make_shared<JsiSkPath>(getContext(), path);
600
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
601
- runtime, hostObjectInstance, getContext());
464
+ std::shared_ptr<JsiSkPath> copy() {
465
+ return std::make_shared<JsiSkPath>(getContext(), asPath());
602
466
  }
603
467
 
604
- JSI_HOST_FUNCTION(isInterpolatable) {
605
- auto path2 = JsiSkPath::fromValue(runtime, arguments[0]);
468
+ bool isInterpolatable(std::shared_ptr<SkPathBuilder> path2) {
606
469
  auto p1 = asPath();
607
470
  auto p2 = path2->snapshot();
608
471
  return p1.isInterpolatable(p2);
609
472
  }
610
473
 
611
- JSI_HOST_FUNCTION(interpolate) {
612
- auto path2 = JsiSkPath::fromValue(runtime, arguments[0]);
613
- auto weight = arguments[1].asNumber();
474
+ std::variant<std::nullptr_t, std::shared_ptr<JsiSkPath>>
475
+ interpolate(std::shared_ptr<SkPathBuilder> path2, double weight) {
614
476
  auto p1 = asPath();
615
477
  auto p2 = path2->snapshot();
616
478
  SkPath result;
617
479
  auto succeed = p1.interpolate(p2, weight, &result);
618
480
  if (!succeed) {
619
- return jsi::Value::null();
481
+ return nullptr;
620
482
  }
621
- auto hostObjectInstance =
622
- std::make_shared<JsiSkPath>(getContext(), std::move(result));
623
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
624
- runtime, hostObjectInstance, getContext());
483
+ return std::make_shared<JsiSkPath>(getContext(), std::move(result));
625
484
  }
626
485
 
627
- JSI_HOST_FUNCTION(toCmds) {
486
+ std::vector<std::vector<double>> toCmds() {
628
487
  auto path = asPath();
629
- std::vector<jsi::Array> cmdList;
488
+ std::vector<std::vector<double>> cmds;
630
489
  SkPoint pts[4];
631
490
  SkPath::Iter iter(path, false);
632
491
  SkPath::Verb verb;
@@ -634,120 +493,145 @@ public:
634
493
  while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
635
494
  switch (verb) {
636
495
  case SkPath::kMove_Verb: {
637
- auto cmd = jsi::Array(runtime, 3);
638
- cmd.setValueAtIndex(runtime, 0, static_cast<double>(MOVE));
639
- cmd.setValueAtIndex(runtime, 1, static_cast<double>(pts[0].x()));
640
- cmd.setValueAtIndex(runtime, 2, static_cast<double>(pts[0].y()));
641
- cmdList.push_back(std::move(cmd));
496
+ cmds.push_back({static_cast<double>(MOVE),
497
+ static_cast<double>(pts[0].x()),
498
+ static_cast<double>(pts[0].y())});
642
499
  break;
643
500
  }
644
501
  case SkPath::kLine_Verb: {
645
- auto cmd = jsi::Array(runtime, 3);
646
- cmd.setValueAtIndex(runtime, 0, static_cast<double>(LINE));
647
- cmd.setValueAtIndex(runtime, 1, static_cast<double>(pts[1].x()));
648
- cmd.setValueAtIndex(runtime, 2, static_cast<double>(pts[1].y()));
649
- cmdList.push_back(std::move(cmd));
502
+ cmds.push_back({static_cast<double>(LINE),
503
+ static_cast<double>(pts[1].x()),
504
+ static_cast<double>(pts[1].y())});
650
505
  break;
651
506
  }
652
507
  case SkPath::kQuad_Verb: {
653
- auto cmd = jsi::Array(runtime, 5);
654
- cmd.setValueAtIndex(runtime, 0, static_cast<double>(QUAD));
655
- cmd.setValueAtIndex(runtime, 1, static_cast<double>(pts[1].x()));
656
- cmd.setValueAtIndex(runtime, 2, static_cast<double>(pts[1].y()));
657
- cmd.setValueAtIndex(runtime, 3, static_cast<double>(pts[2].x()));
658
- cmd.setValueAtIndex(runtime, 4, static_cast<double>(pts[2].y()));
659
- cmdList.push_back(std::move(cmd));
508
+ cmds.push_back(
509
+ {static_cast<double>(QUAD), static_cast<double>(pts[1].x()),
510
+ static_cast<double>(pts[1].y()), static_cast<double>(pts[2].x()),
511
+ static_cast<double>(pts[2].y())});
660
512
  break;
661
513
  }
662
514
  case SkPath::kConic_Verb: {
663
- auto cmd = jsi::Array(runtime, 6);
664
- cmd.setValueAtIndex(runtime, 0, static_cast<double>(CONIC));
665
- cmd.setValueAtIndex(runtime, 1, static_cast<double>(pts[1].x()));
666
- cmd.setValueAtIndex(runtime, 2, static_cast<double>(pts[1].y()));
667
- cmd.setValueAtIndex(runtime, 3, static_cast<double>(pts[2].x()));
668
- cmd.setValueAtIndex(runtime, 4, static_cast<double>(pts[2].y()));
669
- cmd.setValueAtIndex(runtime, 5,
670
- static_cast<double>(iter.conicWeight()));
671
- cmdList.push_back(std::move(cmd));
515
+ cmds.push_back(
516
+ {static_cast<double>(CONIC), static_cast<double>(pts[1].x()),
517
+ static_cast<double>(pts[1].y()), static_cast<double>(pts[2].x()),
518
+ static_cast<double>(pts[2].y()),
519
+ static_cast<double>(iter.conicWeight())});
672
520
  break;
673
521
  }
674
522
  case SkPath::kCubic_Verb: {
675
- auto cmd = jsi::Array(runtime, 7);
676
- cmd.setValueAtIndex(runtime, 0, static_cast<double>(CUBIC));
677
- cmd.setValueAtIndex(runtime, 1, static_cast<double>(pts[1].x()));
678
- cmd.setValueAtIndex(runtime, 2, static_cast<double>(pts[1].y()));
679
- cmd.setValueAtIndex(runtime, 3, static_cast<double>(pts[2].x()));
680
- cmd.setValueAtIndex(runtime, 4, static_cast<double>(pts[2].y()));
681
- cmd.setValueAtIndex(runtime, 5, static_cast<double>(pts[3].x()));
682
- cmd.setValueAtIndex(runtime, 6, static_cast<double>(pts[3].y()));
683
- cmdList.push_back(std::move(cmd));
523
+ cmds.push_back(
524
+ {static_cast<double>(CUBIC), static_cast<double>(pts[1].x()),
525
+ static_cast<double>(pts[1].y()), static_cast<double>(pts[2].x()),
526
+ static_cast<double>(pts[2].y()), static_cast<double>(pts[3].x()),
527
+ static_cast<double>(pts[3].y())});
684
528
  break;
685
529
  }
686
530
  case SkPath::kClose_Verb: {
687
- auto cmd = jsi::Array(runtime, 1);
688
- cmd.setValueAtIndex(runtime, 0, static_cast<double>(CLOSE));
689
- cmdList.push_back(std::move(cmd));
531
+ cmds.push_back({static_cast<double>(CLOSE)});
690
532
  break;
691
533
  }
692
534
  default:
693
535
  break;
694
536
  }
695
537
  }
696
-
697
- // Create the jsi::Array with the exact size
698
- auto cmds = jsi::Array(runtime, cmdList.size());
699
- for (size_t i = 0; i < cmdList.size(); ++i) {
700
- cmds.setValueAtIndex(runtime, i, cmdList[i]);
701
- }
702
-
703
538
  return cmds;
704
539
  }
705
540
 
706
- EXPORT_JSI_API_TYPENAME(JsiSkPath, Path)
707
-
708
- JSI_EXPORT_FUNCTIONS(
709
- // Mutable building methods
710
- JSI_EXPORT_FUNC(JsiSkPath, moveTo), JSI_EXPORT_FUNC(JsiSkPath, rMoveTo),
711
- JSI_EXPORT_FUNC(JsiSkPath, lineTo), JSI_EXPORT_FUNC(JsiSkPath, rLineTo),
712
- JSI_EXPORT_FUNC(JsiSkPath, quadTo), JSI_EXPORT_FUNC(JsiSkPath, rQuadTo),
713
- JSI_EXPORT_FUNC(JsiSkPath, conicTo), JSI_EXPORT_FUNC(JsiSkPath, rConicTo),
714
- JSI_EXPORT_FUNC(JsiSkPath, cubicTo), JSI_EXPORT_FUNC(JsiSkPath, rCubicTo),
715
- JSI_EXPORT_FUNC(JsiSkPath, close), JSI_EXPORT_FUNC(JsiSkPath, reset),
716
- JSI_EXPORT_FUNC(JsiSkPath, rewind), JSI_EXPORT_FUNC(JsiSkPath, addPath),
717
- JSI_EXPORT_FUNC(JsiSkPath, addArc), JSI_EXPORT_FUNC(JsiSkPath, addOval),
718
- JSI_EXPORT_FUNC(JsiSkPath, addRect), JSI_EXPORT_FUNC(JsiSkPath, addRRect),
719
- JSI_EXPORT_FUNC(JsiSkPath, addCircle),
720
- JSI_EXPORT_FUNC(JsiSkPath, addPoly),
721
- JSI_EXPORT_FUNC(JsiSkPath, arcToOval),
722
- JSI_EXPORT_FUNC(JsiSkPath, arcToRotated),
723
- JSI_EXPORT_FUNC(JsiSkPath, rArcTo),
724
- JSI_EXPORT_FUNC(JsiSkPath, arcToTangent),
725
- JSI_EXPORT_FUNC(JsiSkPath, setFillType),
726
- JSI_EXPORT_FUNC(JsiSkPath, setIsVolatile),
727
- // Mutable transform methods
728
- JSI_EXPORT_FUNC(JsiSkPath, transform), JSI_EXPORT_FUNC(JsiSkPath, offset),
729
- // Mutable path operations
730
- JSI_EXPORT_FUNC(JsiSkPath, simplify), JSI_EXPORT_FUNC(JsiSkPath, op),
731
- JSI_EXPORT_FUNC(JsiSkPath, makeAsWinding),
732
- JSI_EXPORT_FUNC(JsiSkPath, dash), JSI_EXPORT_FUNC(JsiSkPath, stroke),
733
- JSI_EXPORT_FUNC(JsiSkPath, trim),
734
- // Query methods
735
- JSI_EXPORT_FUNC(JsiSkPath, computeTightBounds),
736
- JSI_EXPORT_FUNC(JsiSkPath, getBounds),
737
- JSI_EXPORT_FUNC(JsiSkPath, contains),
738
- JSI_EXPORT_FUNC(JsiSkPath, getFillType),
739
- JSI_EXPORT_FUNC(JsiSkPath, isVolatile),
740
- JSI_EXPORT_FUNC(JsiSkPath, getPoint), JSI_EXPORT_FUNC(JsiSkPath, isEmpty),
741
- JSI_EXPORT_FUNC(JsiSkPath, countPoints),
742
- JSI_EXPORT_FUNC(JsiSkPath, getLastPt),
743
- JSI_EXPORT_FUNC(JsiSkPath, toSVGString),
744
- JSI_EXPORT_FUNC(JsiSkPath, equals), JSI_EXPORT_FUNC(JsiSkPath, copy),
745
- JSI_EXPORT_FUNC(JsiSkPath, isInterpolatable),
746
- JSI_EXPORT_FUNC(JsiSkPath, interpolate),
747
- JSI_EXPORT_FUNC(JsiSkPath, toCmds), JSI_EXPORT_FUNC(JsiSkPath, dispose))
541
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
542
+ installCommon(runtime, prototype);
543
+ // Mutable building methods
544
+ installChainableMethodWithRuntime(runtime, prototype, "moveTo",
545
+ &JsiSkPath::moveTo);
546
+ installChainableMethodWithRuntime(runtime, prototype, "rMoveTo",
547
+ &JsiSkPath::rMoveTo);
548
+ installChainableMethodWithRuntime(runtime, prototype, "lineTo",
549
+ &JsiSkPath::lineTo);
550
+ installChainableMethodWithRuntime(runtime, prototype, "rLineTo",
551
+ &JsiSkPath::rLineTo);
552
+ installChainableMethodWithRuntime(runtime, prototype, "quadTo",
553
+ &JsiSkPath::quadTo);
554
+ installChainableMethodWithRuntime(runtime, prototype, "rQuadTo",
555
+ &JsiSkPath::rQuadTo);
556
+ installChainableMethodWithRuntime(runtime, prototype, "conicTo",
557
+ &JsiSkPath::conicTo);
558
+ installChainableMethodWithRuntime(runtime, prototype, "rConicTo",
559
+ &JsiSkPath::rConicTo);
560
+ installChainableMethodWithRuntime(runtime, prototype, "cubicTo",
561
+ &JsiSkPath::cubicTo);
562
+ installChainableMethodWithRuntime(runtime, prototype, "rCubicTo",
563
+ &JsiSkPath::rCubicTo);
564
+ installChainableMethodWithRuntime(runtime, prototype, "close",
565
+ &JsiSkPath::close);
566
+ installChainableMethodWithRuntime(runtime, prototype, "reset",
567
+ &JsiSkPath::reset);
568
+ installChainableMethodWithRuntime(runtime, prototype, "rewind",
569
+ &JsiSkPath::rewind);
570
+ installChainableMethodWithRuntime(runtime, prototype, "addPath",
571
+ &JsiSkPath::addPath);
572
+ installChainableMethodWithRuntime(runtime, prototype, "addArc",
573
+ &JsiSkPath::addArc);
574
+ installChainableMethodWithRuntime(runtime, prototype, "addOval",
575
+ &JsiSkPath::addOval);
576
+ installChainableMethodWithRuntime(runtime, prototype, "addRect",
577
+ &JsiSkPath::addRect);
578
+ installChainableMethodWithRuntime(runtime, prototype, "addRRect",
579
+ &JsiSkPath::addRRect);
580
+ installChainableMethodWithRuntime(runtime, prototype, "addCircle",
581
+ &JsiSkPath::addCircle);
582
+ installChainableMethodWithRuntime(runtime, prototype, "addPoly",
583
+ &JsiSkPath::addPoly);
584
+ installChainableMethodWithRuntime(runtime, prototype, "arcToOval",
585
+ &JsiSkPath::arcToOval);
586
+ installChainableMethodWithRuntime(runtime, prototype, "arcToRotated",
587
+ &JsiSkPath::arcToRotated);
588
+ installChainableMethodWithRuntime(runtime, prototype, "rArcTo",
589
+ &JsiSkPath::rArcTo);
590
+ installChainableMethodWithRuntime(runtime, prototype, "arcToTangent",
591
+ &JsiSkPath::arcToTangent);
592
+ installChainableMethodWithRuntime(runtime, prototype, "setFillType",
593
+ &JsiSkPath::setFillType);
594
+ installChainableMethodWithRuntime(runtime, prototype, "setIsVolatile",
595
+ &JsiSkPath::setIsVolatile);
596
+ // Mutable transform methods
597
+ installChainableMethodWithRuntime(runtime, prototype, "transform",
598
+ &JsiSkPath::transform);
599
+ installChainableMethodWithRuntime(runtime, prototype, "offset",
600
+ &JsiSkPath::offset);
601
+ // Mutable path operations
602
+ installChainableMethodWithRuntime(runtime, prototype, "simplify",
603
+ &JsiSkPath::simplify);
604
+ installChainableMethodWithRuntime(runtime, prototype, "op",
605
+ &JsiSkPath::op);
606
+ installChainableMethodWithRuntime(runtime, prototype, "makeAsWinding",
607
+ &JsiSkPath::makeAsWinding);
608
+ installChainableMethodWithRuntime(runtime, prototype, "dash",
609
+ &JsiSkPath::dash);
610
+ installHostMethod(runtime, prototype, "stroke", &JsiSkPath::stroke);
611
+ installChainableMethodWithRuntime(runtime, prototype, "trim",
612
+ &JsiSkPath::trim);
613
+ // Query methods
614
+ installMethod(runtime, prototype, "computeTightBounds",
615
+ &JsiSkPath::computeTightBounds);
616
+ installMethod(runtime, prototype, "getBounds", &JsiSkPath::getBounds);
617
+ installMethod(runtime, prototype, "contains", &JsiSkPath::contains);
618
+ installMethod(runtime, prototype, "getFillType", &JsiSkPath::getFillType);
619
+ installMethod(runtime, prototype, "isVolatile", &JsiSkPath::isVolatile);
620
+ installMethod(runtime, prototype, "getPoint", &JsiSkPath::getPoint);
621
+ installMethod(runtime, prototype, "isEmpty", &JsiSkPath::isEmpty);
622
+ installMethod(runtime, prototype, "countPoints", &JsiSkPath::countPoints);
623
+ installMethod(runtime, prototype, "getLastPt", &JsiSkPath::getLastPt);
624
+ installMethod(runtime, prototype, "toSVGString", &JsiSkPath::toSVGString);
625
+ installMethod(runtime, prototype, "equals", &JsiSkPath::equals);
626
+ installMethod(runtime, prototype, "copy", &JsiSkPath::copy);
627
+ installMethod(runtime, prototype, "isInterpolatable",
628
+ &JsiSkPath::isInterpolatable);
629
+ installMethod(runtime, prototype, "interpolate", &JsiSkPath::interpolate);
630
+ installMethod(runtime, prototype, "toCmds", &JsiSkPath::toCmds);
631
+ }
748
632
 
749
633
  JsiSkPath(std::shared_ptr<RNSkPlatformContext> context, SkPathBuilder builder)
750
- : JsiSkWrappingSharedPtrHostObject<SkPathBuilder>(
634
+ : JsiSkWrappingSharedPtrNativeObject<JsiSkPath, SkPathBuilder>(
751
635
  std::move(context),
752
636
  std::make_shared<SkPathBuilder>(std::move(builder))) {}
753
637
 
@@ -755,7 +639,7 @@ public:
755
639
  JsiSkPath(std::shared_ptr<RNSkPlatformContext> context, const SkPath &path)
756
640
  : JsiSkPath(std::move(context), SkPathBuilder(path)) {}
757
641
 
758
- size_t getMemoryPressure() const override {
642
+ size_t getMemoryPressure() override {
759
643
  auto builder = getObject();
760
644
  if (!builder)
761
645
  return 0;
@@ -763,7 +647,13 @@ public:
763
647
  return builder->snapshot().approximateBytesUsed();
764
648
  }
765
649
 
766
- std::string getObjectType() const override { return "JsiSkPath"; }
650
+ /**
651
+ Returns the underlying object from a host object of this type
652
+ */
653
+ static std::shared_ptr<SkPathBuilder> fromValue(jsi::Runtime &runtime,
654
+ const jsi::Value &obj) {
655
+ return objectFromValue(runtime, obj);
656
+ }
767
657
 
768
658
  static SkPath pathFromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
769
659
  return fromValue(runtime, obj)->snapshot();
@@ -772,18 +662,20 @@ public:
772
662
  static jsi::Value toValue(jsi::Runtime &runtime,
773
663
  std::shared_ptr<RNSkPlatformContext> context,
774
664
  const SkPath &path) {
775
- auto hostObjectInstance = std::make_shared<JsiSkPath>(context, path);
776
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
777
- runtime, hostObjectInstance, context);
665
+ return makeJsiObject(runtime, std::make_shared<JsiSkPath>(context, path));
778
666
  }
779
667
 
780
668
  static jsi::Value toValue(jsi::Runtime &runtime,
781
669
  std::shared_ptr<RNSkPlatformContext> context,
782
670
  SkPath &&path) {
783
- auto hostObjectInstance =
784
- std::make_shared<JsiSkPath>(context, std::move(path));
785
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
786
- runtime, hostObjectInstance, context);
671
+ return makeJsiObject(runtime,
672
+ std::make_shared<JsiSkPath>(context, std::move(path)));
673
+ }
674
+
675
+ private:
676
+ static SkPathDirection toDirection(const JsiOptional<bool> &isCCW) {
677
+ return isCCW.has_value() && *isCCW ? SkPathDirection::kCCW
678
+ : SkPathDirection::kCW;
787
679
  }
788
680
  };
789
681