@shopify/react-native-skia 2.10.0 → 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 (329) hide show
  1. package/android/CMakeLists.txt +7 -41
  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 +14 -20
  5. package/cpp/api/JsiSkAnimatedImage.h +13 -16
  6. package/cpp/api/JsiSkAnimatedImageFactory.h +9 -7
  7. package/cpp/api/JsiSkApi.h +94 -90
  8. package/cpp/api/JsiSkCanvas.h +108 -251
  9. package/cpp/api/JsiSkColorFilterFactory.h +45 -63
  10. package/cpp/api/JsiSkContourMeasure.h +19 -29
  11. package/cpp/api/JsiSkContourMeasureIter.h +6 -6
  12. package/cpp/api/JsiSkConverters.h +410 -0
  13. package/cpp/api/JsiSkDataFactory.h +9 -15
  14. package/cpp/api/JsiSkFont.h +99 -180
  15. package/cpp/api/JsiSkFontMgr.h +19 -21
  16. package/cpp/api/JsiSkFontMgrFactory.h +4 -5
  17. package/cpp/api/JsiSkImage.h +66 -66
  18. package/cpp/api/JsiSkImageFactory.h +66 -63
  19. package/cpp/api/JsiSkImageFilterFactory.h +354 -608
  20. package/cpp/api/JsiSkImageInfo.h +10 -13
  21. package/cpp/api/JsiSkMaskFilterFactory.h +8 -11
  22. package/cpp/api/JsiSkMatrix.h +36 -73
  23. package/cpp/api/JsiSkNativeObjects.h +60 -92
  24. package/cpp/api/JsiSkPaint.h +73 -131
  25. package/cpp/api/JsiSkParagraph.h +36 -53
  26. package/cpp/api/JsiSkParagraphBuilder.h +36 -64
  27. package/cpp/api/JsiSkParagraphBuilderFactory.h +11 -16
  28. package/cpp/api/JsiSkPath.h +216 -349
  29. package/cpp/api/JsiSkPathBuilder.h +133 -269
  30. package/cpp/api/JsiSkPathBuilderFactory.h +11 -11
  31. package/cpp/api/JsiSkPathEffectFactory.h +52 -72
  32. package/cpp/api/JsiSkPathFactory.h +129 -195
  33. package/cpp/api/JsiSkPicture.h +12 -18
  34. package/cpp/api/JsiSkPictureRecorder.h +14 -15
  35. package/cpp/api/JsiSkPoint.h +4 -4
  36. package/cpp/api/JsiSkRRect.h +7 -8
  37. package/cpp/api/JsiSkRSXform.h +10 -23
  38. package/cpp/api/JsiSkRect.h +23 -31
  39. package/cpp/api/JsiSkRuntimeEffect.h +67 -83
  40. package/cpp/api/JsiSkRuntimeEffectFactory.h +6 -10
  41. package/cpp/api/JsiSkRuntimeShaderBuilder.h +5 -14
  42. package/cpp/api/JsiSkSVG.h +4 -4
  43. package/cpp/api/JsiSkShaderFactory.h +153 -225
  44. package/cpp/api/JsiSkSkottie.h +104 -126
  45. package/cpp/api/JsiSkSurface.h +11 -14
  46. package/cpp/api/JsiSkSurfaceFactory.h +6 -7
  47. package/cpp/api/JsiSkTextBlobFactory.h +31 -54
  48. package/cpp/api/JsiSkTypeface.h +8 -12
  49. package/cpp/api/JsiSkTypefaceFactory.h +9 -7
  50. package/cpp/api/JsiSkTypefaceFontProvider.h +22 -23
  51. package/cpp/api/JsiSkTypefaceFontProviderFactory.h +5 -6
  52. package/cpp/api/JsiSkVertices.h +6 -8
  53. package/cpp/api/JsiSkiaContext.h +10 -11
  54. package/cpp/api/JsiVideo.h +31 -71
  55. package/cpp/jsi/JSIConverter.h +0 -31
  56. package/cpp/jsi/NativeObject.h +11 -6
  57. package/cpp/rnskia/RNDawnContext.h +18 -2
  58. package/cpp/rnskia/RNDawnInterop.cpp +19 -0
  59. package/cpp/rnskia/RNDawnUtils.h +18 -1
  60. package/cpp/rnskia/RNSkManager.cpp +5 -162
  61. package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkaroundsAutogen.h +2 -0
  62. package/lib/commonjs/mock/index.js +0 -1
  63. package/lib/commonjs/mock/index.js.map +1 -1
  64. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +15 -6
  65. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  66. package/lib/commonjs/skia/types/Skia.d.ts +5 -15
  67. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  68. package/lib/commonjs/skia/types/index.d.ts +0 -1
  69. package/lib/commonjs/skia/types/index.js +0 -11
  70. package/lib/commonjs/skia/types/index.js.map +1 -1
  71. package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
  72. package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
  73. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  74. package/lib/commonjs/skia/web/JsiSkia.js +1 -4
  75. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  76. package/lib/commonjs/views/index.d.ts +0 -1
  77. package/lib/commonjs/views/index.js +0 -11
  78. package/lib/commonjs/views/index.js.map +1 -1
  79. package/lib/module/mock/index.js +0 -1
  80. package/lib/module/mock/index.js.map +1 -1
  81. package/lib/module/skia/types/Image/ImageFactory.d.ts +15 -6
  82. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  83. package/lib/module/skia/types/Skia.d.ts +5 -15
  84. package/lib/module/skia/types/Skia.js.map +1 -1
  85. package/lib/module/skia/types/index.d.ts +0 -1
  86. package/lib/module/skia/types/index.js +0 -1
  87. package/lib/module/skia/types/index.js.map +1 -1
  88. package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
  89. package/lib/module/skia/web/JsiSkImageFactory.js +2 -2
  90. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  91. package/lib/module/skia/web/JsiSkia.js +1 -4
  92. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  93. package/lib/module/views/index.d.ts +0 -1
  94. package/lib/module/views/index.js +0 -1
  95. package/lib/module/views/index.js.map +1 -1
  96. package/lib/typescript/lib/commonjs/mock/index.d.ts +0 -1
  97. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
  98. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +1 -2
  99. package/lib/typescript/lib/module/mock/index.d.ts +0 -2
  100. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -2
  101. package/lib/typescript/lib/module/skia/types/index.d.ts +0 -1
  102. package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
  103. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +1 -2
  104. package/lib/typescript/lib/module/views/index.d.ts +0 -1
  105. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +15 -6
  106. package/lib/typescript/src/skia/types/Skia.d.ts +5 -15
  107. package/lib/typescript/src/skia/types/index.d.ts +0 -1
  108. package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -2
  109. package/lib/typescript/src/views/index.d.ts +0 -1
  110. package/package.json +3 -4
  111. package/react-native-skia.podspec +38 -4
  112. package/src/mock/index.ts +0 -1
  113. package/src/skia/types/Image/ImageFactory.ts +15 -6
  114. package/src/skia/types/Skia.ts +5 -15
  115. package/src/skia/types/index.ts +0 -1
  116. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  117. package/src/skia/web/JsiSkia.ts +2 -5
  118. package/src/views/index.ts +0 -1
  119. package/android/cpp/jni/JniWebGPUView.cpp +0 -112
  120. package/android/cpp/rnskia-android/SkiaPlatformContext.h +0 -26
  121. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUSurfaceView.java +0 -43
  122. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUTextureView.java +0 -50
  123. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUView.java +0 -98
  124. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewAPI.java +0 -19
  125. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewManager.java +0 -58
  126. package/apple/RNWebGPUAppleNativeBuffer.mm +0 -33
  127. package/apple/SkiaPlatformContext.h +0 -20
  128. package/apple/SkiaPlatformContext.mm +0 -21
  129. package/apple/SkiaWebGPUView.mm +0 -81
  130. package/apple/WebGPUMetalView.mm +0 -136
  131. package/cpp/rnwgpu/ArrayBuffer.h +0 -116
  132. package/cpp/rnwgpu/Canvas.h +0 -52
  133. package/cpp/rnwgpu/PlatformContext.h +0 -18
  134. package/cpp/rnwgpu/SurfaceRegistry.h +0 -605
  135. package/cpp/rnwgpu/api/AppleNativeBuffer.h +0 -22
  136. package/cpp/rnwgpu/api/Convertors.h +0 -783
  137. package/cpp/rnwgpu/api/External.h +0 -12
  138. package/cpp/rnwgpu/api/GPU.cpp +0 -162
  139. package/cpp/rnwgpu/api/GPU.h +0 -60
  140. package/cpp/rnwgpu/api/GPUAdapter.cpp +0 -239
  141. package/cpp/rnwgpu/api/GPUAdapter.h +0 -60
  142. package/cpp/rnwgpu/api/GPUAdapterInfo.h +0 -57
  143. package/cpp/rnwgpu/api/GPUBindGroup.cpp +0 -3
  144. package/cpp/rnwgpu/api/GPUBindGroup.h +0 -51
  145. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +0 -52
  146. package/cpp/rnwgpu/api/GPUBuffer.cpp +0 -107
  147. package/cpp/rnwgpu/api/GPUBuffer.h +0 -88
  148. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +0 -75
  149. package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -70
  150. package/cpp/rnwgpu/api/GPUCommandBuffer.h +0 -45
  151. package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +0 -179
  152. package/cpp/rnwgpu/api/GPUCommandEncoder.h +0 -111
  153. package/cpp/rnwgpu/api/GPUCompilationInfo.h +0 -79
  154. package/cpp/rnwgpu/api/GPUCompilationMessage.h +0 -36
  155. package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +0 -60
  156. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +0 -85
  157. package/cpp/rnwgpu/api/GPUComputePipeline.cpp +0 -12
  158. package/cpp/rnwgpu/api/GPUComputePipeline.h +0 -60
  159. package/cpp/rnwgpu/api/GPUDevice.cpp +0 -613
  160. package/cpp/rnwgpu/api/GPUDevice.h +0 -258
  161. package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +0 -7
  162. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +0 -40
  163. package/cpp/rnwgpu/api/GPUError.h +0 -35
  164. package/cpp/rnwgpu/api/GPUExtent3D.h +0 -66
  165. package/cpp/rnwgpu/api/GPUExternalTexture.cpp +0 -139
  166. package/cpp/rnwgpu/api/GPUExternalTexture.h +0 -95
  167. package/cpp/rnwgpu/api/GPUFeatures.h +0 -203
  168. package/cpp/rnwgpu/api/GPUInternalError.h +0 -31
  169. package/cpp/rnwgpu/api/GPUOrigin2D.h +0 -55
  170. package/cpp/rnwgpu/api/GPUOrigin3D.h +0 -62
  171. package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +0 -33
  172. package/cpp/rnwgpu/api/GPUPipelineLayout.h +0 -45
  173. package/cpp/rnwgpu/api/GPUQuerySet.cpp +0 -11
  174. package/cpp/rnwgpu/api/GPUQuerySet.h +0 -73
  175. package/cpp/rnwgpu/api/GPUQueue.cpp +0 -179
  176. package/cpp/rnwgpu/api/GPUQueue.h +0 -84
  177. package/cpp/rnwgpu/api/GPURenderBundle.h +0 -44
  178. package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +0 -131
  179. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +0 -110
  180. package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +0 -165
  181. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +0 -130
  182. package/cpp/rnwgpu/api/GPURenderPipeline.cpp +0 -13
  183. package/cpp/rnwgpu/api/GPURenderPipeline.h +0 -61
  184. package/cpp/rnwgpu/api/GPUSampler.h +0 -44
  185. package/cpp/rnwgpu/api/GPUShaderModule.cpp +0 -56
  186. package/cpp/rnwgpu/api/GPUShaderModule.h +0 -66
  187. package/cpp/rnwgpu/api/GPUSharedFence.cpp +0 -80
  188. package/cpp/rnwgpu/api/GPUSharedFence.h +0 -53
  189. package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +0 -135
  190. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +0 -75
  191. package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +0 -129
  192. package/cpp/rnwgpu/api/GPUSupportedLimits.h +0 -131
  193. package/cpp/rnwgpu/api/GPUTexture.cpp +0 -47
  194. package/cpp/rnwgpu/api/GPUTexture.h +0 -162
  195. package/cpp/rnwgpu/api/GPUTextureView.h +0 -44
  196. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +0 -60
  197. package/cpp/rnwgpu/api/GPUValidationError.h +0 -32
  198. package/cpp/rnwgpu/api/ImageBitmap.h +0 -62
  199. package/cpp/rnwgpu/api/NativeBufferUtils.h +0 -87
  200. package/cpp/rnwgpu/api/RNWebGPU.h +0 -82
  201. package/cpp/rnwgpu/api/WebGPUConstants.h +0 -36
  202. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +0 -64
  203. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +0 -78
  204. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +0 -56
  205. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +0 -97
  206. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +0 -57
  207. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +0 -52
  208. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +0 -56
  209. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +0 -56
  210. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +0 -59
  211. package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +0 -39
  212. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +0 -76
  213. package/cpp/rnwgpu/api/descriptors/GPUColor.h +0 -66
  214. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +0 -58
  215. package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +0 -29
  216. package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +0 -45
  217. package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +0 -45
  218. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +0 -56
  219. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +0 -58
  220. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +0 -67
  221. package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +0 -56
  222. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +0 -103
  223. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +0 -109
  224. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +0 -38
  225. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +0 -90
  226. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +0 -73
  227. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +0 -62
  228. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +0 -63
  229. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +0 -65
  230. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +0 -81
  231. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +0 -54
  232. package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +0 -22
  233. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +0 -54
  234. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +0 -57
  235. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +0 -69
  236. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +0 -61
  237. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +0 -55
  238. package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +0 -43
  239. package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +0 -45
  240. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +0 -80
  241. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +0 -81
  242. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +0 -101
  243. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +0 -92
  244. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +0 -58
  245. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +0 -103
  246. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +0 -51
  247. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +0 -45
  248. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +0 -110
  249. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +0 -60
  250. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +0 -62
  251. package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +0 -25
  252. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +0 -58
  253. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +0 -51
  254. package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +0 -73
  255. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +0 -64
  256. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +0 -59
  257. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +0 -59
  258. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +0 -91
  259. package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +0 -29
  260. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +0 -91
  261. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +0 -64
  262. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +0 -53
  263. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +0 -62
  264. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +0 -73
  265. package/cpp/rnwgpu/api/descriptors/Unions.h +0 -1969
  266. package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +0 -213
  267. package/cpp/rnwgpu/async/AsyncTaskHandle.h +0 -58
  268. package/cpp/rnwgpu/async/RuntimeContext.cpp +0 -199
  269. package/cpp/rnwgpu/async/RuntimeContext.h +0 -134
  270. package/lib/commonjs/skia/types/WebGPU.d.ts +0 -184
  271. package/lib/commonjs/skia/types/WebGPU.js +0 -105
  272. package/lib/commonjs/skia/types/WebGPU.js.map +0 -1
  273. package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -8
  274. package/lib/commonjs/specs/WebGPUViewNativeComponent.js +0 -10
  275. package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +0 -1
  276. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  277. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +0 -103
  278. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +0 -1
  279. package/lib/commonjs/specs/utils.d.ts +0 -1
  280. package/lib/commonjs/specs/utils.js +0 -11
  281. package/lib/commonjs/specs/utils.js.map +0 -1
  282. package/lib/commonjs/views/WebGPUCanvas.d.ts +0 -33
  283. package/lib/commonjs/views/WebGPUCanvas.js +0 -79
  284. package/lib/commonjs/views/WebGPUCanvas.js.map +0 -1
  285. package/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -23
  286. package/lib/commonjs/views/WebGPUCanvas.web.js +0 -20
  287. package/lib/commonjs/views/WebGPUCanvas.web.js.map +0 -1
  288. package/lib/module/skia/types/WebGPU.d.ts +0 -184
  289. package/lib/module/skia/types/WebGPU.js +0 -99
  290. package/lib/module/skia/types/WebGPU.js.map +0 -1
  291. package/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -8
  292. package/lib/module/specs/WebGPUViewNativeComponent.js +0 -4
  293. package/lib/module/specs/WebGPUViewNativeComponent.js.map +0 -1
  294. package/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  295. package/lib/module/specs/WebGPUViewNativeComponent.web.js +0 -96
  296. package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +0 -1
  297. package/lib/module/specs/utils.d.ts +0 -1
  298. package/lib/module/specs/utils.js +0 -5
  299. package/lib/module/specs/utils.js.map +0 -1
  300. package/lib/module/views/WebGPUCanvas.d.ts +0 -33
  301. package/lib/module/views/WebGPUCanvas.js +0 -70
  302. package/lib/module/views/WebGPUCanvas.js.map +0 -1
  303. package/lib/module/views/WebGPUCanvas.web.d.ts +0 -23
  304. package/lib/module/views/WebGPUCanvas.web.js +0 -12
  305. package/lib/module/views/WebGPUCanvas.web.js.map +0 -1
  306. package/lib/typescript/lib/commonjs/skia/types/WebGPU.d.ts +0 -2
  307. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -4
  308. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -3
  309. package/lib/typescript/lib/commonjs/specs/utils.d.ts +0 -2
  310. package/lib/typescript/lib/commonjs/views/WebGPUCanvas.d.ts +0 -6
  311. package/lib/typescript/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -6
  312. package/lib/typescript/lib/module/skia/types/WebGPU.d.ts +0 -31
  313. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -2
  314. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -2
  315. package/lib/typescript/lib/module/specs/utils.d.ts +0 -1
  316. package/lib/typescript/lib/module/views/WebGPUCanvas.d.ts +0 -7
  317. package/lib/typescript/lib/module/views/WebGPUCanvas.web.d.ts +0 -8
  318. package/lib/typescript/src/skia/types/WebGPU.d.ts +0 -184
  319. package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +0 -8
  320. package/lib/typescript/src/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  321. package/lib/typescript/src/specs/utils.d.ts +0 -1
  322. package/lib/typescript/src/views/WebGPUCanvas.d.ts +0 -33
  323. package/lib/typescript/src/views/WebGPUCanvas.web.d.ts +0 -23
  324. package/src/skia/types/WebGPU.ts +0 -226
  325. package/src/specs/WebGPUViewNativeComponent.ts +0 -11
  326. package/src/specs/WebGPUViewNativeComponent.web.ts +0 -110
  327. package/src/specs/utils.ts +0 -4
  328. package/src/views/WebGPUCanvas.tsx +0 -125
  329. package/src/views/WebGPUCanvas.web.tsx +0 -36
@@ -1,12 +1,17 @@
1
1
  #pragma once
2
2
 
3
3
  #include <memory>
4
+ #include <optional>
4
5
  #include <utility>
6
+ #include <variant>
5
7
  #include <vector>
6
8
 
7
9
  #include <jsi/jsi.h>
8
10
 
11
+ #include "JsiSkConverters.h"
12
+ #include "JsiSkMatrix.h"
9
13
  #include "JsiSkNativeObjects.h"
14
+ #include "JsiSkPath.h"
10
15
  #include "JsiSkPathEffect.h"
11
16
 
12
17
  #pragma clang diagnostic push
@@ -30,104 +35,79 @@ class JsiSkPathEffectFactory
30
35
  public:
31
36
  static constexpr const char *CLASS_NAME = "PathEffectFactory";
32
37
 
33
- JSI_HOST_FUNCTION(MakeCorner) {
34
- int radius = arguments[0].asNumber();
35
- auto pathEffect = std::make_shared<JsiSkPathEffect>(
36
- getContext(), SkCornerPathEffect::Make(radius));
37
- return makeJsiObject(runtime, std::move(pathEffect));
38
+ std::shared_ptr<JsiSkPathEffect> MakeCorner(int radius) {
39
+ return std::make_shared<JsiSkPathEffect>(getContext(),
40
+ SkCornerPathEffect::Make(radius));
38
41
  }
39
42
 
40
- JSI_HOST_FUNCTION(MakeDash) {
41
- auto jsiIntervals = arguments[0].asObject(runtime).asArray(runtime);
42
- auto size = static_cast<int>(jsiIntervals.size(runtime));
43
- std::vector<SkScalar> intervals;
44
- intervals.reserve(size);
45
- for (int i = 0; i < size; i++) {
46
- SkScalar interval = jsiIntervals.getValueAtIndex(runtime, i).asNumber();
47
- intervals.push_back(interval);
48
- }
49
- int phase =
50
- count >= 2 && !arguments[1].isUndefined() && !arguments[1].isNull()
51
- ? arguments[1].asNumber()
52
- : 0;
43
+ std::shared_ptr<JsiSkPathEffect>
44
+ MakeDash(std::vector<float> intervals, JsiOptional<double> phaseValue) {
45
+ int phase = phaseValue.has_value() ? *phaseValue : 0;
53
46
  auto i = SkSpan(intervals.data(), intervals.size());
54
- auto pathEffect = std::make_shared<JsiSkPathEffect>(
55
- getContext(), SkDashPathEffect::Make(i, phase));
56
- return makeJsiObject(runtime, std::move(pathEffect));
47
+ return std::make_shared<JsiSkPathEffect>(getContext(),
48
+ SkDashPathEffect::Make(i, phase));
57
49
  }
58
50
 
59
- JSI_HOST_FUNCTION(MakeDiscrete) {
60
- int segLength = arguments[0].asNumber();
61
- int dec = arguments[1].asNumber();
62
- int seedAssist = arguments[2].asNumber();
63
- auto pathEffect = std::make_shared<JsiSkPathEffect>(
51
+ std::shared_ptr<JsiSkPathEffect> MakeDiscrete(int segLength, int dec,
52
+ int seedAssist) {
53
+ return std::make_shared<JsiSkPathEffect>(
64
54
  getContext(), SkDiscretePathEffect::Make(segLength, dec, seedAssist));
65
- return makeJsiObject(runtime, std::move(pathEffect));
66
55
  }
67
56
 
68
- JSI_HOST_FUNCTION(MakeCompose) {
69
- auto outer = JsiSkPathEffect::fromValue(runtime, arguments[0]);
70
- auto inner = JsiSkPathEffect::fromValue(runtime, arguments[1]);
71
- auto pathEffect = std::make_shared<JsiSkPathEffect>(
57
+ std::shared_ptr<JsiSkPathEffect> MakeCompose(sk_sp<SkPathEffect> outer,
58
+ sk_sp<SkPathEffect> inner) {
59
+ return std::make_shared<JsiSkPathEffect>(
72
60
  getContext(),
73
61
  SkPathEffect::MakeCompose(std::move(outer), std::move(inner)));
74
- return makeJsiObject(runtime, std::move(pathEffect));
75
62
  }
76
63
 
77
- JSI_HOST_FUNCTION(MakeSum) {
78
- auto outer = JsiSkPathEffect::fromValue(runtime, arguments[0]);
79
- auto inner = JsiSkPathEffect::fromValue(runtime, arguments[1]);
80
- auto pathEffect = std::make_shared<JsiSkPathEffect>(
64
+ std::shared_ptr<JsiSkPathEffect> MakeSum(sk_sp<SkPathEffect> outer,
65
+ sk_sp<SkPathEffect> inner) {
66
+ return std::make_shared<JsiSkPathEffect>(
81
67
  getContext(),
82
68
  SkPathEffect::MakeSum(std::move(outer), std::move(inner)));
83
- return makeJsiObject(runtime, std::move(pathEffect));
84
69
  }
85
70
 
86
- JSI_HOST_FUNCTION(MakePath1D) {
87
- auto path = JsiSkPath::fromValue(runtime, arguments[0]);
88
- auto advance = arguments[1].asNumber();
89
- auto phase = arguments[2].asNumber();
90
- auto style =
91
- static_cast<SkPath1DPathEffect::Style>(arguments[3].asNumber());
92
- auto pathEffect = std::make_shared<JsiSkPathEffect>(
71
+ std::shared_ptr<JsiSkPathEffect>
72
+ MakePath1D(std::shared_ptr<SkPathBuilder> path, double advance, double phase,
73
+ double style) {
74
+ return std::make_shared<JsiSkPathEffect>(
93
75
  getContext(),
94
- SkPath1DPathEffect::Make(path->snapshot(), advance, phase, style));
95
- return makeJsiObject(runtime, std::move(pathEffect));
76
+ SkPath1DPathEffect::Make(
77
+ path->snapshot(), advance, phase,
78
+ static_cast<SkPath1DPathEffect::Style>(style)));
96
79
  }
97
80
 
98
- JSI_HOST_FUNCTION(MakePath2D) {
99
- auto matrix = JsiSkMatrix::fromValue(runtime, arguments[0]);
100
- auto path = JsiSkPath::fromValue(runtime, arguments[1]);
101
- auto pathEffect = std::make_shared<JsiSkPathEffect>(
81
+ std::shared_ptr<JsiSkPathEffect>
82
+ MakePath2D(std::shared_ptr<SkMatrix> matrix,
83
+ std::shared_ptr<SkPathBuilder> path) {
84
+ return std::make_shared<JsiSkPathEffect>(
102
85
  getContext(), SkPath2DPathEffect::Make(*matrix, path->snapshot()));
103
- return makeJsiObject(runtime, std::move(pathEffect));
104
86
  }
105
87
 
106
- JSI_HOST_FUNCTION(MakeLine2D) {
107
- auto width = arguments[0].asNumber();
108
- auto matrix = JsiSkMatrix::fromValue(runtime, arguments[1]);
109
- auto pathEffect = std::make_shared<JsiSkPathEffect>(
88
+ std::shared_ptr<JsiSkPathEffect>
89
+ MakeLine2D(double width, std::shared_ptr<SkMatrix> matrix) {
90
+ return std::make_shared<JsiSkPathEffect>(
110
91
  getContext(), SkLine2DPathEffect::Make(width, *matrix));
111
- return makeJsiObject(runtime, std::move(pathEffect));
112
92
  }
113
93
 
114
94
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
115
- installHostMethod(runtime, prototype, "MakeCorner",
116
- &JsiSkPathEffectFactory::MakeCorner);
117
- installHostMethod(runtime, prototype, "MakeDash",
118
- &JsiSkPathEffectFactory::MakeDash);
119
- installHostMethod(runtime, prototype, "MakeDiscrete",
120
- &JsiSkPathEffectFactory::MakeDiscrete);
121
- installHostMethod(runtime, prototype, "MakeCompose",
122
- &JsiSkPathEffectFactory::MakeCompose);
123
- installHostMethod(runtime, prototype, "MakeSum",
124
- &JsiSkPathEffectFactory::MakeSum);
125
- installHostMethod(runtime, prototype, "MakeLine2D",
126
- &JsiSkPathEffectFactory::MakeLine2D);
127
- installHostMethod(runtime, prototype, "MakePath1D",
128
- &JsiSkPathEffectFactory::MakePath1D);
129
- installHostMethod(runtime, prototype, "MakePath2D",
130
- &JsiSkPathEffectFactory::MakePath2D);
95
+ installMethod(runtime, prototype, "MakeCorner",
96
+ &JsiSkPathEffectFactory::MakeCorner);
97
+ installMethod(runtime, prototype, "MakeDash",
98
+ &JsiSkPathEffectFactory::MakeDash);
99
+ installMethod(runtime, prototype, "MakeDiscrete",
100
+ &JsiSkPathEffectFactory::MakeDiscrete);
101
+ installMethod(runtime, prototype, "MakeCompose",
102
+ &JsiSkPathEffectFactory::MakeCompose);
103
+ installMethod(runtime, prototype, "MakeSum",
104
+ &JsiSkPathEffectFactory::MakeSum);
105
+ installMethod(runtime, prototype, "MakeLine2D",
106
+ &JsiSkPathEffectFactory::MakeLine2D);
107
+ installMethod(runtime, prototype, "MakePath1D",
108
+ &JsiSkPathEffectFactory::MakePath1D);
109
+ installMethod(runtime, prototype, "MakePath2D",
110
+ &JsiSkPathEffectFactory::MakePath2D);
131
111
  }
132
112
 
133
113
  size_t getMemoryPressure() override { return 1024; }
@@ -2,13 +2,18 @@
2
2
 
3
3
  #include <algorithm>
4
4
  #include <memory>
5
+ #include <string>
5
6
  #include <utility>
7
+ #include <variant>
6
8
  #include <vector>
7
9
 
8
10
  #include <jsi/jsi.h>
9
11
 
12
+ #include "JsiSkConverters.h"
13
+ #include "JsiSkFont.h"
10
14
  #include "JsiSkMatrix.h"
11
15
  #include "JsiSkNativeObjects.h"
16
+ #include "JsiSkPath.h"
12
17
  #include "JsiSkPathEffect.h"
13
18
  #include "JsiSkPoint.h"
14
19
  #include "JsiSkRRect.h"
@@ -42,107 +47,83 @@ class JsiSkPathFactory : public JsiSkNativeObject<JsiSkPathFactory> {
42
47
  static const int CUBIC = 4;
43
48
  static const int CLOSE = 5;
44
49
 
50
+ using NullablePath = std::variant<std::nullptr_t, std::shared_ptr<JsiSkPath>>;
51
+
45
52
  public:
46
53
  static constexpr const char *CLASS_NAME = "PathFactory";
47
54
 
48
- JSI_HOST_FUNCTION(Make) {
49
- return makeJsiObject(runtime,
50
- std::make_shared<JsiSkPath>(getContext(), SkPath()));
55
+ std::shared_ptr<JsiSkPath> Make() {
56
+ return std::make_shared<JsiSkPath>(getContext(), SkPath());
51
57
  }
52
58
 
53
- JSI_HOST_FUNCTION(MakeFromSVGString) {
54
- auto svgString = arguments[0].asString(runtime).utf8(runtime);
59
+ std::shared_ptr<JsiSkPath> MakeFromSVGString(std::string svgString) {
55
60
  auto result = SkParsePath::FromSVGString(svgString.c_str());
56
61
  if (!result.has_value()) {
57
- throw jsi::JSError(runtime, "Could not parse Svg path");
58
- return jsi::Value(nullptr);
62
+ throw std::runtime_error("Could not parse Svg path");
59
63
  }
60
- return makeJsiObject(runtime, std::make_shared<JsiSkPath>(
61
- getContext(), std::move(result.value())));
64
+ return std::make_shared<JsiSkPath>(getContext(),
65
+ std::move(result.value()));
62
66
  }
63
67
 
64
- JSI_HOST_FUNCTION(MakeFromOp) {
65
- auto one = JsiSkPath::fromValue(runtime, arguments[0])->snapshot();
66
- auto two = JsiSkPath::fromValue(runtime, arguments[1])->snapshot();
67
- SkPathOp op = (SkPathOp)arguments[2].asNumber();
68
- auto result = Op(one, two, op);
68
+ NullablePath MakeFromOp(std::shared_ptr<SkPathBuilder> pathOne,
69
+ std::shared_ptr<SkPathBuilder> pathTwo, double op) {
70
+ auto one = pathOne->snapshot();
71
+ auto two = pathTwo->snapshot();
72
+ auto result = Op(one, two, static_cast<SkPathOp>(op));
69
73
  if (!result.has_value()) {
70
- return jsi::Value(nullptr);
74
+ return nullptr;
71
75
  }
72
- return makeJsiObject(runtime, std::make_shared<JsiSkPath>(
73
- getContext(), std::move(result.value())));
76
+ return std::make_shared<JsiSkPath>(getContext(),
77
+ std::move(result.value()));
74
78
  }
75
79
 
76
- JSI_HOST_FUNCTION(MakeFromCmds) {
80
+ NullablePath MakeFromCmds(std::vector<std::vector<double>> cmds) {
77
81
  SkPathBuilder builder;
78
- auto cmds = arguments[0].asObject(runtime).asArray(runtime);
79
- auto cmdCount = cmds.size(runtime);
80
- for (int i = 0; i < cmdCount; i++) {
81
- auto cmd =
82
- cmds.getValueAtIndex(runtime, i).asObject(runtime).asArray(runtime);
83
- if (cmd.size(runtime) < 1) {
82
+ for (const auto &cmd : cmds) {
83
+ if (cmd.size() < 1) {
84
84
  RNSkLogger::logToConsole("Invalid command found (got an empty array)");
85
- return jsi::Value::null();
85
+ return nullptr;
86
86
  }
87
- auto verb = static_cast<int>(cmd.getValueAtIndex(runtime, 0).asNumber());
87
+ auto verb = static_cast<int>(cmd[0]);
88
88
  switch (verb) {
89
89
  case MOVE: {
90
- if (cmd.size(runtime) < 3) {
90
+ if (cmd.size() < 3) {
91
91
  RNSkLogger::logToConsole("Invalid move command found");
92
- return jsi::Value::null();
92
+ return nullptr;
93
93
  }
94
- auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
95
- auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
96
- builder.moveTo(x, y);
94
+ builder.moveTo(cmd[1], cmd[2]);
97
95
  break;
98
96
  }
99
97
  case LINE: {
100
- if (cmd.size(runtime) < 3) {
98
+ if (cmd.size() < 3) {
101
99
  RNSkLogger::logToConsole("Invalid line command found");
102
- return jsi::Value::null();
100
+ return nullptr;
103
101
  }
104
- auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
105
- auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
106
- builder.lineTo(x, y);
102
+ builder.lineTo(cmd[1], cmd[2]);
107
103
  break;
108
104
  }
109
105
  case QUAD: {
110
- if (cmd.size(runtime) < 5) {
106
+ if (cmd.size() < 5) {
111
107
  RNSkLogger::logToConsole("Invalid line command found");
112
- return jsi::Value::null();
108
+ return nullptr;
113
109
  }
114
- auto x1 = cmd.getValueAtIndex(runtime, 1).asNumber();
115
- auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
116
- auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
117
- auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
118
- builder.quadTo(x1, y1, x2, y2);
110
+ builder.quadTo(cmd[1], cmd[2], cmd[3], cmd[4]);
119
111
  break;
120
112
  }
121
113
  case CONIC: {
122
- if (cmd.size(runtime) < 6) {
114
+ if (cmd.size() < 6) {
123
115
  RNSkLogger::logToConsole("Invalid line command found");
124
- return jsi::Value::null();
116
+ return nullptr;
125
117
  }
126
- auto x1 = cmd.getValueAtIndex(runtime, 1).asNumber();
127
- auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
128
- auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
129
- auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
130
- auto w = cmd.getValueAtIndex(runtime, 5).asNumber();
131
- builder.conicTo(x1, y1, x2, y2, w);
118
+ builder.conicTo(cmd[1], cmd[2], cmd[3], cmd[4], cmd[5]);
132
119
  break;
133
120
  }
134
121
  case CUBIC: {
135
- if (cmd.size(runtime) < 7) {
122
+ if (cmd.size() < 7) {
136
123
  RNSkLogger::logToConsole("Invalid line command found");
137
- return jsi::Value::null();
124
+ return nullptr;
138
125
  }
139
- auto x1 = cmd.getValueAtIndex(runtime, 1).asNumber();
140
- auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
141
- auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
142
- auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
143
- auto x3 = cmd.getValueAtIndex(runtime, 5).asNumber();
144
- auto y3 = cmd.getValueAtIndex(runtime, 6).asNumber();
145
- builder.cubicTo(x1, y1, x2, y2, x3, y3);
126
+ builder.cubicTo(cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6]);
146
127
  break;
147
128
  }
148
129
  case CLOSE: {
@@ -151,102 +132,68 @@ public:
151
132
  }
152
133
  default: {
153
134
  RNSkLogger::logToConsole("Found an unknown command");
154
- return jsi::Value::null();
135
+ return nullptr;
155
136
  }
156
137
  }
157
138
  }
158
- return makeJsiObject(
159
- runtime, std::make_shared<JsiSkPath>(getContext(), builder.snapshot()));
139
+ return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
160
140
  }
161
141
 
162
- JSI_HOST_FUNCTION(MakeFromText) {
163
- auto text = arguments[0].asString(runtime).utf8(runtime);
164
- auto x = arguments[1].asNumber();
165
- auto y = arguments[2].asNumber();
166
- auto font = JsiSkFont::fromValue(runtime, arguments[3]);
142
+ std::shared_ptr<JsiSkPath> MakeFromText(std::string text, double x, double y,
143
+ std::shared_ptr<SkFont> font) {
167
144
  SkPath path;
168
145
  SkTextUtils::GetPath(text.c_str(), strlen(text.c_str()),
169
146
  SkTextEncoding::kUTF8, x, y, *font, &path);
170
- return makeJsiObject(
171
- runtime, std::make_shared<JsiSkPath>(getContext(), std::move(path)));
147
+ return std::make_shared<JsiSkPath>(getContext(), std::move(path));
172
148
  }
173
149
 
174
150
  // Static shape factories
175
- JSI_HOST_FUNCTION(Rect) {
176
- auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
177
- auto direction = SkPathDirection::kCW;
178
- if (count >= 2 && arguments[1].getBool()) {
179
- direction = SkPathDirection::kCCW;
180
- }
151
+ std::shared_ptr<JsiSkPath> Rect(SkRect rect, JsiOptional<bool> isCCW) {
181
152
  SkPathBuilder builder;
182
- builder.addRect(*rect, direction);
183
- return makeJsiObject(
184
- runtime, std::make_shared<JsiSkPath>(getContext(), builder.snapshot()));
153
+ builder.addRect(rect, toDirection(isCCW));
154
+ return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
185
155
  }
186
156
 
187
- JSI_HOST_FUNCTION(Oval) {
188
- auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
189
- auto direction = SkPathDirection::kCW;
190
- if (count >= 2 && arguments[1].getBool()) {
191
- direction = SkPathDirection::kCCW;
192
- }
193
- unsigned startIndex = count < 3 ? 0 : arguments[2].asNumber();
157
+ std::shared_ptr<JsiSkPath> Oval(SkRect rect, JsiOptional<bool> isCCW,
158
+ JsiOptional<double> startIndex) {
194
159
  SkPathBuilder builder;
195
- builder.addOval(*rect, direction, startIndex);
196
- return makeJsiObject(
197
- runtime, std::make_shared<JsiSkPath>(getContext(), builder.snapshot()));
160
+ builder.addOval(rect, toDirection(isCCW),
161
+ startIndex.has_value()
162
+ ? static_cast<unsigned>(*startIndex)
163
+ : 0);
164
+ return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
198
165
  }
199
166
 
200
- JSI_HOST_FUNCTION(Circle) {
201
- auto x = arguments[0].asNumber();
202
- auto y = arguments[1].asNumber();
203
- auto r = arguments[2].asNumber();
167
+ std::shared_ptr<JsiSkPath> Circle(double x, double y, double r) {
204
168
  SkPathBuilder builder;
205
169
  builder.addCircle(x, y, r);
206
- return makeJsiObject(
207
- runtime, std::make_shared<JsiSkPath>(getContext(), builder.snapshot()));
170
+ return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
208
171
  }
209
172
 
210
- JSI_HOST_FUNCTION(RRect) {
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
- }
173
+ std::shared_ptr<JsiSkPath> RRect(std::shared_ptr<SkRRect> rrect,
174
+ JsiOptional<bool> isCCW) {
216
175
  SkPathBuilder builder;
217
- builder.addRRect(*rrect, direction);
218
- return makeJsiObject(
219
- runtime, std::make_shared<JsiSkPath>(getContext(), builder.snapshot()));
176
+ builder.addRRect(*rrect, toDirection(isCCW));
177
+ return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
220
178
  }
221
179
 
222
- JSI_HOST_FUNCTION(Line) {
223
- auto p1 = JsiSkPoint::fromValue(runtime, arguments[0].asObject(runtime));
224
- auto p2 = JsiSkPoint::fromValue(runtime, arguments[1].asObject(runtime));
180
+ std::shared_ptr<JsiSkPath> Line(SkPoint p1, SkPoint p2) {
225
181
  SkPathBuilder builder;
226
- builder.moveTo(*p1);
227
- builder.lineTo(*p2);
228
- return makeJsiObject(
229
- runtime, std::make_shared<JsiSkPath>(getContext(), builder.snapshot()));
182
+ builder.moveTo(p1);
183
+ builder.lineTo(p2);
184
+ return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
230
185
  }
231
186
 
232
- JSI_HOST_FUNCTION(Polygon) {
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
- }
187
+ std::shared_ptr<JsiSkPath> Polygon(std::vector<SkPoint> points, bool close) {
243
188
  SkPathBuilder builder;
244
189
  builder.addPolygon(SkSpan(points), close);
245
- return makeJsiObject(
246
- runtime, std::make_shared<JsiSkPath>(getContext(), builder.snapshot()));
190
+ return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
247
191
  }
248
192
 
249
193
  // Static path operations
194
+
195
+ // Stays raw: the options object is read leniently property by property
196
+ // (unknown properties and non-numeric values are ignored).
250
197
  JSI_HOST_FUNCTION(Stroke) {
251
198
  auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
252
199
  SkPath path = srcPath->snapshot();
@@ -303,128 +250,115 @@ public:
303
250
  return jsi::Value::null();
304
251
  }
305
252
 
306
- JSI_HOST_FUNCTION(Trim) {
307
- auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
308
- float start =
309
- std::clamp(static_cast<float>(arguments[1].asNumber()), 0.0f, 1.0f);
310
- float end =
311
- std::clamp(static_cast<float>(arguments[2].asNumber()), 0.0f, 1.0f);
312
- auto isComplement = arguments[3].getBool();
253
+ NullablePath Trim(std::shared_ptr<SkPathBuilder> srcPath, double startValue,
254
+ double endValue, bool isComplement) {
255
+ float start = std::clamp(static_cast<float>(startValue), 0.0f, 1.0f);
256
+ float end = std::clamp(static_cast<float>(endValue), 0.0f, 1.0f);
313
257
  // If requesting the full path in normal mode, just return a copy
314
258
  if (start <= 0 && end >= 1 && !isComplement) {
315
- SkPath result = srcPath->snapshot();
316
- return makeJsiObject(runtime, std::make_shared<JsiSkPath>(
317
- getContext(), std::move(result)));
259
+ return std::make_shared<JsiSkPath>(getContext(), srcPath->snapshot());
318
260
  }
319
261
  SkPath path = srcPath->snapshot();
320
262
  auto mode = isComplement ? SkTrimPathEffect::Mode::kInverted
321
263
  : SkTrimPathEffect::Mode::kNormal;
322
264
  auto pe = SkTrimPathEffect::Make(start, end, mode);
323
265
  if (!pe) {
324
- return jsi::Value::null();
266
+ return nullptr;
325
267
  }
326
268
  SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
327
269
  SkPathBuilder resultBuilder;
328
270
  if (pe->filterPath(&resultBuilder, path, &rec)) {
329
- auto result = resultBuilder.detach();
330
- return makeJsiObject(runtime, std::make_shared<JsiSkPath>(
331
- getContext(), std::move(result)));
271
+ return std::make_shared<JsiSkPath>(getContext(), resultBuilder.detach());
332
272
  }
333
- return jsi::Value::null();
273
+ return nullptr;
334
274
  }
335
275
 
336
- JSI_HOST_FUNCTION(Simplify) {
337
- auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
276
+ NullablePath Simplify(std::shared_ptr<SkPathBuilder> srcPath) {
338
277
  auto result = ::Simplify(srcPath->snapshot());
339
278
  if (result.has_value()) {
340
- return makeJsiObject(
341
- runtime,
342
- std::make_shared<JsiSkPath>(getContext(), std::move(result.value())));
279
+ return std::make_shared<JsiSkPath>(getContext(),
280
+ std::move(result.value()));
343
281
  }
344
- return jsi::Value::null();
282
+ return nullptr;
345
283
  }
346
284
 
347
- JSI_HOST_FUNCTION(Dash) {
348
- auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
349
- SkScalar on = arguments[1].asNumber();
350
- SkScalar off = arguments[2].asNumber();
351
- auto phase = arguments[3].asNumber();
352
- SkScalar intervals[] = {on, off};
285
+ NullablePath Dash(std::shared_ptr<SkPathBuilder> srcPath, double on,
286
+ double off, double phase) {
287
+ SkScalar intervals[] = {static_cast<SkScalar>(on),
288
+ static_cast<SkScalar>(off)};
353
289
  auto i = SkSpan(intervals, 2);
354
290
  auto pe = SkDashPathEffect::Make(i, phase);
355
291
  if (!pe) {
356
- return jsi::Value::null();
292
+ return nullptr;
357
293
  }
358
294
  SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
359
295
  SkPathBuilder resultBuilder;
360
296
  if (pe->filterPath(&resultBuilder, srcPath->snapshot(), &rec)) {
361
- auto result = resultBuilder.detach();
362
- return makeJsiObject(runtime, std::make_shared<JsiSkPath>(
363
- getContext(), std::move(result)));
297
+ return std::make_shared<JsiSkPath>(getContext(), resultBuilder.detach());
364
298
  }
365
- return jsi::Value::null();
299
+ return nullptr;
366
300
  }
367
301
 
368
- JSI_HOST_FUNCTION(AsWinding) {
369
- auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
302
+ NullablePath AsWinding(std::shared_ptr<SkPathBuilder> srcPath) {
370
303
  auto result = ::AsWinding(srcPath->snapshot());
371
304
  if (result.has_value()) {
372
- return makeJsiObject(
373
- runtime,
374
- std::make_shared<JsiSkPath>(getContext(), std::move(result.value())));
305
+ return std::make_shared<JsiSkPath>(getContext(),
306
+ std::move(result.value()));
375
307
  }
376
- return jsi::Value::null();
308
+ return nullptr;
377
309
  }
378
310
 
379
- JSI_HOST_FUNCTION(Interpolate) {
380
- auto path1 = JsiSkPath::fromValue(runtime, arguments[0]);
381
- auto path2 = JsiSkPath::fromValue(runtime, arguments[1]);
382
- auto weight = arguments[2].asNumber();
383
- auto p1 = path1->snapshot();
384
- auto p2 = path2->snapshot();
311
+ NullablePath Interpolate(std::shared_ptr<SkPathBuilder> pathOne,
312
+ std::shared_ptr<SkPathBuilder> pathTwo,
313
+ double weight) {
314
+ auto p1 = pathOne->snapshot();
315
+ auto p2 = pathTwo->snapshot();
385
316
  SkPath result;
386
317
  auto succeed = p1.interpolate(p2, weight, &result);
387
318
  if (!succeed) {
388
- return jsi::Value::null();
319
+ return nullptr;
389
320
  }
390
- return makeJsiObject(
391
- runtime, std::make_shared<JsiSkPath>(getContext(), std::move(result)));
321
+ return std::make_shared<JsiSkPath>(getContext(), std::move(result));
392
322
  }
393
323
 
394
324
  size_t getMemoryPressure() override { return 1024; }
395
325
 
396
326
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
397
- installHostMethod(runtime, prototype, "Make", &JsiSkPathFactory::Make);
398
- installHostMethod(runtime, prototype, "MakeFromSVGString",
399
- &JsiSkPathFactory::MakeFromSVGString);
400
- installHostMethod(runtime, prototype, "MakeFromOp",
401
- &JsiSkPathFactory::MakeFromOp);
402
- installHostMethod(runtime, prototype, "MakeFromCmds",
403
- &JsiSkPathFactory::MakeFromCmds);
404
- installHostMethod(runtime, prototype, "MakeFromText",
405
- &JsiSkPathFactory::MakeFromText);
327
+ installMethod(runtime, prototype, "Make", &JsiSkPathFactory::Make);
328
+ installMethod(runtime, prototype, "MakeFromSVGString",
329
+ &JsiSkPathFactory::MakeFromSVGString);
330
+ installMethod(runtime, prototype, "MakeFromOp",
331
+ &JsiSkPathFactory::MakeFromOp);
332
+ installMethod(runtime, prototype, "MakeFromCmds",
333
+ &JsiSkPathFactory::MakeFromCmds);
334
+ installMethod(runtime, prototype, "MakeFromText",
335
+ &JsiSkPathFactory::MakeFromText);
406
336
  // Static shape factories
407
- installHostMethod(runtime, prototype, "Rect", &JsiSkPathFactory::Rect);
408
- installHostMethod(runtime, prototype, "Oval", &JsiSkPathFactory::Oval);
409
- installHostMethod(runtime, prototype, "Circle", &JsiSkPathFactory::Circle);
410
- installHostMethod(runtime, prototype, "RRect", &JsiSkPathFactory::RRect);
411
- installHostMethod(runtime, prototype, "Line", &JsiSkPathFactory::Line);
412
- installHostMethod(runtime, prototype, "Polygon",
413
- &JsiSkPathFactory::Polygon);
337
+ installMethod(runtime, prototype, "Rect", &JsiSkPathFactory::Rect);
338
+ installMethod(runtime, prototype, "Oval", &JsiSkPathFactory::Oval);
339
+ installMethod(runtime, prototype, "Circle", &JsiSkPathFactory::Circle);
340
+ installMethod(runtime, prototype, "RRect", &JsiSkPathFactory::RRect);
341
+ installMethod(runtime, prototype, "Line", &JsiSkPathFactory::Line);
342
+ installMethod(runtime, prototype, "Polygon", &JsiSkPathFactory::Polygon);
414
343
  // Static path operations
415
344
  installHostMethod(runtime, prototype, "Stroke", &JsiSkPathFactory::Stroke);
416
- installHostMethod(runtime, prototype, "Trim", &JsiSkPathFactory::Trim);
417
- installHostMethod(runtime, prototype, "Simplify",
418
- &JsiSkPathFactory::Simplify);
419
- installHostMethod(runtime, prototype, "Dash", &JsiSkPathFactory::Dash);
420
- installHostMethod(runtime, prototype, "AsWinding",
421
- &JsiSkPathFactory::AsWinding);
422
- installHostMethod(runtime, prototype, "Interpolate",
423
- &JsiSkPathFactory::Interpolate);
345
+ installMethod(runtime, prototype, "Trim", &JsiSkPathFactory::Trim);
346
+ installMethod(runtime, prototype, "Simplify", &JsiSkPathFactory::Simplify);
347
+ installMethod(runtime, prototype, "Dash", &JsiSkPathFactory::Dash);
348
+ installMethod(runtime, prototype, "AsWinding",
349
+ &JsiSkPathFactory::AsWinding);
350
+ installMethod(runtime, prototype, "Interpolate",
351
+ &JsiSkPathFactory::Interpolate);
424
352
  }
425
353
 
426
354
  explicit JsiSkPathFactory(std::shared_ptr<RNSkPlatformContext> context)
427
355
  : JsiSkNativeObject<JsiSkPathFactory>(std::move(context)) {}
356
+
357
+ private:
358
+ static SkPathDirection toDirection(const JsiOptional<bool> &isCCW) {
359
+ return isCCW.has_value() && *isCCW ? SkPathDirection::kCCW
360
+ : SkPathDirection::kCW;
361
+ }
428
362
  };
429
363
 
430
364
  } // namespace RNSkia