@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
@@ -1,14 +1,16 @@
1
1
  #pragma once
2
2
 
3
3
  #include <memory>
4
+ #include <string>
4
5
  #include <utility>
5
6
  #include <vector>
6
7
 
8
+ #include "JsiSkConverters.h"
7
9
  #include "JsiSkFont.h"
8
- #include "JsiSkHostObjects.h"
9
10
  #include "JsiSkImage.h"
10
11
  #include "JsiSkImageInfo.h"
11
12
  #include "JsiSkMatrix.h"
13
+ #include "JsiSkNativeObjects.h"
12
14
  #include "JsiSkPaint.h"
13
15
  #include "JsiSkPath.h"
14
16
  #include "JsiSkPicture.h"
@@ -49,31 +51,25 @@ namespace RNSkia {
49
51
 
50
52
  namespace jsi = facebook::jsi;
51
53
 
52
- class JsiSkCanvas : public JsiSkHostObject {
54
+ class JsiSkCanvas : public JsiSkNativeObject<JsiSkCanvas> {
53
55
  public:
54
- JSI_HOST_FUNCTION(drawPaint) {
55
- auto paint = JsiSkPaint::fromValue(runtime, arguments[0]);
56
+ static constexpr const char *CLASS_NAME = "Canvas";
57
+
58
+ void drawPaint(std::shared_ptr<SkPaint> paint) {
56
59
  _canvas->drawPaint(*paint);
57
- return jsi::Value::undefined();
58
60
  }
59
61
 
60
- JSI_HOST_FUNCTION(drawLine) {
61
- SkScalar x1 = arguments[0].asNumber();
62
- SkScalar y1 = arguments[1].asNumber();
63
- SkScalar x2 = arguments[2].asNumber();
64
- SkScalar y2 = arguments[3].asNumber();
65
- auto paint = JsiSkPaint::fromValue(runtime, arguments[4]);
62
+ void drawLine(double x1, double y1, double x2, double y2,
63
+ std::shared_ptr<SkPaint> paint) {
66
64
  _canvas->drawLine(x1, y1, x2, y2, *paint);
67
- return jsi::Value::undefined();
68
65
  }
69
66
 
70
- JSI_HOST_FUNCTION(drawRect) {
71
- auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
72
- auto paint = JsiSkPaint::fromValue(runtime, arguments[1]);
67
+ void drawRect(std::shared_ptr<SkRect> rect, std::shared_ptr<SkPaint> paint) {
73
68
  _canvas->drawRect(*rect, *paint);
74
- return jsi::Value::undefined();
75
69
  }
76
70
 
71
+ // The drawImage* variants stay raw: they dispatch on exact argument counts
72
+ // (count == 4 / count == 6) with null-tolerant trailing paints.
77
73
  JSI_HOST_FUNCTION(drawImage) {
78
74
  auto image = JsiSkImage::fromValue(runtime, arguments[0]);
79
75
  auto x = arguments[1].asNumber();
@@ -183,108 +179,55 @@ public:
183
179
  return jsi::Value::undefined();
184
180
  }
185
181
 
186
- JSI_HOST_FUNCTION(drawCircle) {
187
- SkScalar cx = arguments[0].asNumber();
188
- SkScalar cy = arguments[1].asNumber();
189
- SkScalar radius = arguments[2].asNumber();
190
-
191
- auto paint = JsiSkPaint::fromValue(runtime, arguments[3]);
182
+ void drawCircle(double cx, double cy, double radius,
183
+ std::shared_ptr<SkPaint> paint) {
192
184
  _canvas->drawCircle(cx, cy, radius, *paint);
193
-
194
- return jsi::Value::undefined();
195
185
  }
196
186
 
197
- JSI_HOST_FUNCTION(drawArc) {
198
- auto oval = JsiSkRect::fromValue(runtime, arguments[0]);
199
-
200
- SkScalar startAngle = arguments[1].asNumber();
201
- SkScalar sweepAngle = arguments[2].asNumber();
202
- bool useCenter = arguments[3].getBool();
203
-
204
- auto paint = JsiSkPaint::fromValue(runtime, arguments[4]);
187
+ void drawArc(std::shared_ptr<SkRect> oval, double startAngle,
188
+ double sweepAngle, bool useCenter,
189
+ std::shared_ptr<SkPaint> paint) {
205
190
  _canvas->drawArc(*oval, startAngle, sweepAngle, useCenter, *paint);
206
-
207
- return jsi::Value::undefined();
208
191
  }
209
192
 
210
- JSI_HOST_FUNCTION(drawRRect) {
211
- auto rect = JsiSkRRect::fromValue(runtime, arguments[0]);
212
- auto paint = JsiSkPaint::fromValue(runtime, arguments[1]);
213
-
193
+ void drawRRect(std::shared_ptr<SkRRect> rect,
194
+ std::shared_ptr<SkPaint> paint) {
214
195
  _canvas->drawRRect(*rect, *paint);
215
-
216
- return jsi::Value::undefined();
217
196
  }
218
197
 
219
- JSI_HOST_FUNCTION(drawDRRect) {
220
- auto outer = JsiSkRRect::fromValue(runtime, arguments[0]);
221
- auto inner = JsiSkRRect::fromValue(runtime, arguments[1]);
222
- auto paint = JsiSkPaint::fromValue(runtime, arguments[2]);
223
-
198
+ void drawDRRect(std::shared_ptr<SkRRect> outer,
199
+ std::shared_ptr<SkRRect> inner,
200
+ std::shared_ptr<SkPaint> paint) {
224
201
  _canvas->drawDRRect(*outer, *inner, *paint);
225
-
226
- return jsi::Value::undefined();
227
202
  }
228
203
 
229
- JSI_HOST_FUNCTION(drawOval) {
230
- auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
231
- auto paint = JsiSkPaint::fromValue(runtime, arguments[1]);
232
-
204
+ void drawOval(std::shared_ptr<SkRect> rect, std::shared_ptr<SkPaint> paint) {
233
205
  _canvas->drawOval(*rect, *paint);
234
-
235
- return jsi::Value::undefined();
236
206
  }
237
207
 
238
- JSI_HOST_FUNCTION(restoreToCount) {
239
- auto c = arguments[0].asNumber();
240
- _canvas->restoreToCount(c);
241
- return jsi::Value::undefined();
242
- }
208
+ void restoreToCount(double c) { _canvas->restoreToCount(c); }
243
209
 
244
- JSI_HOST_FUNCTION(getSaveCount) {
245
- return static_cast<int>(_canvas->getSaveCount());
246
- }
210
+ int getSaveCount() { return static_cast<int>(_canvas->getSaveCount()); }
247
211
 
248
- JSI_HOST_FUNCTION(getTotalMatrix) {
249
- auto matrix =
250
- std::make_shared<JsiSkMatrix>(getContext(), _canvas->getTotalMatrix());
251
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, matrix,
252
- getContext());
212
+ std::shared_ptr<JsiSkMatrix> getTotalMatrix() {
213
+ return std::make_shared<JsiSkMatrix>(getContext(),
214
+ _canvas->getTotalMatrix());
253
215
  }
254
216
 
255
- JSI_HOST_FUNCTION(drawPoints) {
256
- auto pointMode = arguments[0].asNumber();
257
- std::vector<SkPoint> points;
258
-
259
- auto jsiPoints = arguments[1].asObject(runtime).asArray(runtime);
260
- auto pointsSize = jsiPoints.size(runtime);
261
-
217
+ void drawPoints(double pointMode, std::vector<SkPoint> points,
218
+ std::shared_ptr<SkPaint> paint) {
262
219
  // Check if we have at least one point
263
- if (pointsSize == 0) {
220
+ if (points.empty()) {
264
221
  throw std::invalid_argument("Points array must not be empty");
265
222
  }
266
-
267
- points.reserve(pointsSize);
268
-
269
- for (int i = 0; i < pointsSize; i++) {
270
- std::shared_ptr<SkPoint> point = JsiSkPoint::fromValue(
271
- runtime, jsiPoints.getValueAtIndex(runtime, i).asObject(runtime));
272
- points.push_back(*point.get());
273
- }
274
-
275
- auto paint = JsiSkPaint::fromValue(runtime, arguments[2]);
276
223
  auto p = SkSpan(points.data(), points.size());
277
- _canvas->drawPoints((SkCanvas::PointMode)pointMode, p, *paint);
278
-
279
- return jsi::Value::undefined();
224
+ _canvas->drawPoints(static_cast<SkCanvas::PointMode>(pointMode), p, *paint);
280
225
  }
281
226
 
282
- JSI_HOST_FUNCTION(drawVertices) {
283
- auto vertices = JsiSkVertices::fromValue(runtime, arguments[0]);
284
- auto blendMode = (SkBlendMode)arguments[1].getNumber();
285
- auto paint = JsiSkPaint::fromValue(runtime, arguments[2]);
286
- _canvas->drawVertices(vertices, blendMode, *paint);
287
- return jsi::Value::undefined();
227
+ void drawVertices(sk_sp<SkVertices> vertices, double blendMode,
228
+ std::shared_ptr<SkPaint> paint) {
229
+ _canvas->drawVertices(vertices, static_cast<SkBlendMode>(blendMode),
230
+ *paint);
288
231
  }
289
232
 
290
233
  JSI_HOST_FUNCTION(drawPatch) {
@@ -352,118 +295,71 @@ public:
352
295
  return jsi::Value::undefined();
353
296
  }
354
297
 
355
- JSI_HOST_FUNCTION(drawPath) {
356
- auto path = JsiSkPath::fromValue(runtime, arguments[0]);
357
- auto paint = JsiSkPaint::fromValue(runtime, arguments[1]);
358
-
298
+ void drawPath(std::shared_ptr<SkPathBuilder> path,
299
+ std::shared_ptr<SkPaint> paint) {
359
300
  _canvas->drawPath(path->snapshot(), *paint);
360
-
361
- return jsi::Value::undefined();
362
301
  }
363
302
 
364
- JSI_HOST_FUNCTION(drawText) {
365
- auto textVal = arguments[0].asString(runtime).utf8(runtime);
303
+ void drawText(std::string textVal, double x, double y,
304
+ std::shared_ptr<SkPaint> paint, std::shared_ptr<SkFont> font) {
366
305
  auto text = textVal.c_str();
367
- SkScalar x = arguments[1].asNumber();
368
- SkScalar y = arguments[2].asNumber();
369
-
370
- auto paint = JsiSkPaint::fromValue(runtime, arguments[3]);
371
- auto font = JsiSkFont::fromValue(runtime, arguments[4]);
372
-
373
306
  _canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8, x, y,
374
307
  *font, *paint);
375
-
376
- return jsi::Value::undefined();
377
308
  }
378
309
 
379
- JSI_HOST_FUNCTION(drawTextBlob) {
380
- auto blob = JsiSkTextBlob::fromValue(runtime, arguments[0]);
381
- SkScalar x = arguments[1].asNumber();
382
- SkScalar y = arguments[2].asNumber();
383
- auto paint = JsiSkPaint::fromValue(runtime, arguments[3]);
310
+ void drawTextBlob(sk_sp<SkTextBlob> blob, double x, double y,
311
+ std::shared_ptr<SkPaint> paint) {
384
312
  _canvas->drawTextBlob(blob, x, y, *paint);
385
- return jsi::Value::undefined();
386
313
  }
387
314
 
388
- JSI_HOST_FUNCTION(drawGlyphs) {
389
- auto jsiGlyphs = arguments[0].asObject(runtime).asArray(runtime);
390
- auto jsiPositions = arguments[1].asObject(runtime).asArray(runtime);
391
- auto x = arguments[2].asNumber();
392
- auto y = arguments[3].asNumber();
393
- auto font = JsiSkFont::fromValue(runtime, arguments[4]);
394
- auto paint = JsiSkPaint::fromValue(runtime, arguments[5]);
315
+ void drawGlyphs(std::vector<int> glyphIds, std::vector<SkPoint> positions,
316
+ double x, double y, std::shared_ptr<SkFont> font,
317
+ std::shared_ptr<SkPaint> paint) {
395
318
  SkPoint origin = SkPoint::Make(x, y);
396
319
 
397
- std::vector<SkPoint> positions;
398
- int pointsSize = static_cast<int>(jsiPositions.size(runtime));
399
- positions.reserve(pointsSize);
400
- for (int i = 0; i < pointsSize; i++) {
401
- std::shared_ptr<SkPoint> point = JsiSkPoint::fromValue(
402
- runtime, jsiPositions.getValueAtIndex(runtime, i).asObject(runtime));
403
- positions.push_back(*point.get());
404
- }
405
-
406
- std::vector<SkGlyphID> glyphs;
407
- int glyphsSize = static_cast<int>(jsiGlyphs.size(runtime));
408
-
409
320
  // Validate that glyphs and positions arrays have the same size
410
- if (glyphsSize != pointsSize) {
321
+ if (glyphIds.size() != positions.size()) {
411
322
  throw std::invalid_argument(
412
323
  "Glyphs and positions arrays must have the same length");
413
324
  }
414
325
 
415
- glyphs.reserve(glyphsSize);
416
- for (int i = 0; i < glyphsSize; i++) {
417
- glyphs.push_back(jsiGlyphs.getValueAtIndex(runtime, i).asNumber());
326
+ std::vector<SkGlyphID> glyphs;
327
+ glyphs.reserve(glyphIds.size());
328
+ for (auto glyph : glyphIds) {
329
+ glyphs.push_back(static_cast<SkGlyphID>(glyph));
418
330
  }
419
331
 
420
332
  auto g = SkSpan(glyphs.data(), glyphs.size());
421
333
  auto p = SkSpan(positions.data(), positions.size());
422
334
  _canvas->drawGlyphs(g, p, origin, *font, *paint);
423
-
424
- return jsi::Value::undefined();
425
335
  }
426
336
 
427
- JSI_HOST_FUNCTION(drawSvg) {
428
- auto svgdom = JsiSkSVG::fromValue(runtime, arguments[0]);
429
- if (count == 3 && arguments[1].isNumber() && arguments[2].isNumber()) {
430
- // read size
431
- auto w = arguments[1].asNumber();
432
- auto h = arguments[2].asNumber();
433
- svgdom->setContainerSize(SkSize::Make(w, h));
337
+ void drawSvg(sk_sp<SkSVGDOM> svgdom, JsiOptional<double> w,
338
+ JsiOptional<double> h) {
339
+ if (w.has_value() && h.has_value()) {
340
+ svgdom->setContainerSize(SkSize::Make(*w, *h));
434
341
  } else {
435
342
  auto canvasSize = _canvas->getBaseLayerSize();
436
343
  svgdom->setContainerSize(SkSize::Make(canvasSize));
437
344
  }
438
345
  svgdom->render(_canvas);
439
- return jsi::Value::undefined();
440
346
  }
441
347
 
442
- JSI_HOST_FUNCTION(clipPath) {
443
- auto path = JsiSkPath::fromValue(runtime, arguments[0]);
444
- auto op = (SkClipOp)arguments[1].asNumber();
445
- auto doAntiAlias = arguments[2].getBool();
446
- _canvas->clipPath(path->snapshot(), op, doAntiAlias);
447
- return jsi::Value::undefined();
348
+ void clipPath(std::shared_ptr<SkPathBuilder> path, double op,
349
+ bool doAntiAlias) {
350
+ _canvas->clipPath(path->snapshot(), static_cast<SkClipOp>(op),
351
+ doAntiAlias);
448
352
  }
449
353
 
450
- JSI_HOST_FUNCTION(clipRect) {
451
- auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
452
- auto op = (SkClipOp)arguments[1].asNumber();
453
- auto doAntiAlias = arguments[2].getBool();
454
- _canvas->clipRect(*rect, op, doAntiAlias);
455
- return jsi::Value::undefined();
354
+ void clipRect(std::shared_ptr<SkRect> rect, double op, bool doAntiAlias) {
355
+ _canvas->clipRect(*rect, static_cast<SkClipOp>(op), doAntiAlias);
456
356
  }
457
357
 
458
- JSI_HOST_FUNCTION(clipRRect) {
459
- auto rrect = JsiSkRRect::fromValue(runtime, arguments[0]);
460
- auto op = (SkClipOp)arguments[1].asNumber();
461
- auto doAntiAlias = arguments[2].getBool();
462
- _canvas->clipRRect(*rrect, op, doAntiAlias);
463
- return jsi::Value::undefined();
358
+ void clipRRect(std::shared_ptr<SkRRect> rrect, double op, bool doAntiAlias) {
359
+ _canvas->clipRRect(*rrect, static_cast<SkClipOp>(op), doAntiAlias);
464
360
  }
465
361
 
466
- JSI_HOST_FUNCTION(save) { return jsi::Value(_canvas->save()); }
362
+ int save() { return _canvas->save(); }
467
363
 
468
364
  JSI_HOST_FUNCTION(saveLayer) {
469
365
  SkPaint *paint = (count >= 1 && !arguments[0].isUndefined())
@@ -482,67 +378,32 @@ public:
482
378
  SkCanvas::SaveLayerRec(bounds, paint, backdrop, flags)));
483
379
  }
484
380
 
485
- JSI_HOST_FUNCTION(restore) {
486
- _canvas->restore();
487
- return jsi::Value::undefined();
488
- }
381
+ void restore() { _canvas->restore(); }
489
382
 
490
- JSI_HOST_FUNCTION(rotate) {
491
- SkScalar degrees = arguments[0].asNumber();
492
- SkScalar rx = arguments[1].asNumber();
493
- SkScalar ry = arguments[2].asNumber();
383
+ void rotate(double degrees, double rx, double ry) {
494
384
  _canvas->rotate(degrees, rx, ry);
495
- return jsi::Value::undefined();
496
385
  }
497
386
 
498
- JSI_HOST_FUNCTION(translate) {
499
- SkScalar dx = arguments[0].asNumber();
500
- SkScalar dy = arguments[1].asNumber();
501
- _canvas->translate(dx, dy);
502
- return jsi::Value::undefined();
503
- }
387
+ void translate(double dx, double dy) { _canvas->translate(dx, dy); }
504
388
 
505
- JSI_HOST_FUNCTION(scale) {
506
- SkScalar sx = arguments[0].asNumber();
507
- SkScalar sy = arguments[1].asNumber();
508
- _canvas->scale(sx, sy);
509
- return jsi::Value::undefined();
510
- }
389
+ void scale(double sx, double sy) { _canvas->scale(sx, sy); }
511
390
 
512
- JSI_HOST_FUNCTION(skew) {
513
- SkScalar sx = arguments[0].asNumber();
514
- SkScalar sy = arguments[1].asNumber();
515
- _canvas->skew(sx, sy);
516
- return jsi::Value::undefined();
517
- }
391
+ void skew(double sx, double sy) { _canvas->skew(sx, sy); }
518
392
 
519
- JSI_HOST_FUNCTION(drawColor) {
520
- SkColor cl = JsiSkColor::fromValue(runtime, arguments[0]);
521
- if (count == 1) {
522
- _canvas->drawColor(cl);
393
+ void drawColor(JsiColor cl, JsiOptional<double> mode) {
394
+ if (mode.has_value()) {
395
+ _canvas->drawColor(cl, static_cast<SkBlendMode>(*mode));
523
396
  } else {
524
- auto mode = static_cast<SkBlendMode>(arguments[1].asNumber());
525
- _canvas->drawColor(cl, mode);
397
+ _canvas->drawColor(cl);
526
398
  }
527
- return jsi::Value::undefined();
528
399
  }
529
400
 
530
- JSI_HOST_FUNCTION(clear) {
531
- SkColor cl = JsiSkColor::fromValue(runtime, arguments[0]);
532
- _canvas->clear(cl);
533
- return jsi::Value::undefined();
534
- }
401
+ void clear(JsiColor cl) { _canvas->clear(cl); }
535
402
 
536
- JSI_HOST_FUNCTION(concat) {
537
- auto matrix = JsiSkMatrix::fromValue(runtime, arguments[0]);
538
- _canvas->concat(*matrix.get());
539
- return jsi::Value::undefined();
540
- }
403
+ void concat(std::shared_ptr<SkMatrix> matrix) { _canvas->concat(*matrix); }
541
404
 
542
- JSI_HOST_FUNCTION(drawPicture) {
543
- auto picture = JsiSkPicture::fromValue(runtime, arguments[0]);
405
+ void drawPicture(sk_sp<SkPicture> picture) {
544
406
  _canvas->drawPicture(picture);
545
- return jsi::Value::undefined();
546
407
  }
547
408
 
548
409
  JSI_HOST_FUNCTION(drawAtlas) {
@@ -651,9 +512,10 @@ public:
651
512
  #if defined(SK_GRAPHITE)
652
513
  // Graphite records draws lazily and offers no synchronous GPU readback. If
653
514
  // this canvas belongs to a surface, snap & submit its recording, snapshot
654
- // it to a CPU raster image and read from that (mirroring makeImageSnapshot).
655
- // A canvas without an owning surface (e.g. a picture-recording canvas) has
656
- // no texture to read back, so fall through to the raster canvas read below.
515
+ // it to a CPU raster image and read from that (mirroring
516
+ // makeImageSnapshot). A canvas without an owning surface (e.g. a
517
+ // picture-recording canvas) has no texture to read back, so fall through to
518
+ // the raster canvas read below.
657
519
  if (_surface) {
658
520
  // Snapshot first: makeImageSnapshot records a copy task into the recorder
659
521
  // that must be submitted before the texture can be read back (this is the
@@ -663,8 +525,8 @@ public:
663
525
  DawnContext::getInstance().submitRecording(recorder->snap().get());
664
526
  }
665
527
  auto raster = DawnContext::getInstance().MakeRasterImage(snapshot);
666
- if (!raster ||
667
- !raster->readPixels(nullptr, *info, bfrPtr, bytesPerRow, srcX, srcY)) {
528
+ if (!raster || !raster->readPixels(nullptr, *info, bfrPtr, bytesPerRow,
529
+ srcX, srcY)) {
668
530
  return jsi::Value::null();
669
531
  }
670
532
  return dest;
@@ -677,55 +539,68 @@ public:
677
539
  return dest;
678
540
  }
679
541
 
680
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkCanvas, drawPaint),
681
- JSI_EXPORT_FUNC(JsiSkCanvas, drawLine),
682
- JSI_EXPORT_FUNC(JsiSkCanvas, drawRect),
683
- JSI_EXPORT_FUNC(JsiSkCanvas, drawImage),
684
- JSI_EXPORT_FUNC(JsiSkCanvas, drawImageRect),
685
- JSI_EXPORT_FUNC(JsiSkCanvas, drawImageCubic),
686
- JSI_EXPORT_FUNC(JsiSkCanvas, drawImageOptions),
687
- JSI_EXPORT_FUNC(JsiSkCanvas, drawImageNine),
688
- JSI_EXPORT_FUNC(JsiSkCanvas, drawImageRectCubic),
689
- JSI_EXPORT_FUNC(JsiSkCanvas, drawImageRectOptions),
690
- JSI_EXPORT_FUNC(JsiSkCanvas, drawCircle),
691
- JSI_EXPORT_FUNC(JsiSkCanvas, drawArc),
692
- JSI_EXPORT_FUNC(JsiSkCanvas, drawRRect),
693
- JSI_EXPORT_FUNC(JsiSkCanvas, drawDRRect),
694
- JSI_EXPORT_FUNC(JsiSkCanvas, drawOval),
695
- JSI_EXPORT_FUNC(JsiSkCanvas, restoreToCount),
696
- JSI_EXPORT_FUNC(JsiSkCanvas, getSaveCount),
697
- JSI_EXPORT_FUNC(JsiSkCanvas, getTotalMatrix),
698
- JSI_EXPORT_FUNC(JsiSkCanvas, drawPoints),
699
- JSI_EXPORT_FUNC(JsiSkCanvas, drawPatch),
700
- JSI_EXPORT_FUNC(JsiSkCanvas, drawPath),
701
- JSI_EXPORT_FUNC(JsiSkCanvas, drawVertices),
702
- JSI_EXPORT_FUNC(JsiSkCanvas, drawText),
703
- JSI_EXPORT_FUNC(JsiSkCanvas, drawTextBlob),
704
- JSI_EXPORT_FUNC(JsiSkCanvas, drawGlyphs),
705
- JSI_EXPORT_FUNC(JsiSkCanvas, drawSvg),
706
- JSI_EXPORT_FUNC(JsiSkCanvas, clipPath),
707
- JSI_EXPORT_FUNC(JsiSkCanvas, clipRect),
708
- JSI_EXPORT_FUNC(JsiSkCanvas, clipRRect),
709
- JSI_EXPORT_FUNC(JsiSkCanvas, save),
710
- JSI_EXPORT_FUNC(JsiSkCanvas, saveLayer),
711
- JSI_EXPORT_FUNC(JsiSkCanvas, restore),
712
- JSI_EXPORT_FUNC(JsiSkCanvas, rotate),
713
- JSI_EXPORT_FUNC(JsiSkCanvas, translate),
714
- JSI_EXPORT_FUNC(JsiSkCanvas, scale),
715
- JSI_EXPORT_FUNC(JsiSkCanvas, skew),
716
- JSI_EXPORT_FUNC(JsiSkCanvas, drawColor),
717
- JSI_EXPORT_FUNC(JsiSkCanvas, clear),
718
- JSI_EXPORT_FUNC(JsiSkCanvas, concat),
719
- JSI_EXPORT_FUNC(JsiSkCanvas, drawPicture),
720
- JSI_EXPORT_FUNC(JsiSkCanvas, drawAtlas),
721
- JSI_EXPORT_FUNC(JsiSkCanvas, readPixels))
722
-
723
- size_t getMemoryPressure() const override { return 1024; }
724
-
725
- std::string getObjectType() const override { return "JsiSkCanvas"; }
542
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
543
+ installMethod(runtime, prototype, "drawPaint", &JsiSkCanvas::drawPaint);
544
+ installMethod(runtime, prototype, "drawLine", &JsiSkCanvas::drawLine);
545
+ installMethod(runtime, prototype, "drawRect", &JsiSkCanvas::drawRect);
546
+ installHostMethod(runtime, prototype, "drawImage", &JsiSkCanvas::drawImage);
547
+ installHostMethod(runtime, prototype, "drawImageRect",
548
+ &JsiSkCanvas::drawImageRect);
549
+ installHostMethod(runtime, prototype, "drawImageCubic",
550
+ &JsiSkCanvas::drawImageCubic);
551
+ installHostMethod(runtime, prototype, "drawImageOptions",
552
+ &JsiSkCanvas::drawImageOptions);
553
+ installHostMethod(runtime, prototype, "drawImageNine",
554
+ &JsiSkCanvas::drawImageNine);
555
+ installHostMethod(runtime, prototype, "drawImageRectCubic",
556
+ &JsiSkCanvas::drawImageRectCubic);
557
+ installHostMethod(runtime, prototype, "drawImageRectOptions",
558
+ &JsiSkCanvas::drawImageRectOptions);
559
+ installMethod(runtime, prototype, "drawCircle", &JsiSkCanvas::drawCircle);
560
+ installMethod(runtime, prototype, "drawArc", &JsiSkCanvas::drawArc);
561
+ installMethod(runtime, prototype, "drawRRect", &JsiSkCanvas::drawRRect);
562
+ installMethod(runtime, prototype, "drawDRRect", &JsiSkCanvas::drawDRRect);
563
+ installMethod(runtime, prototype, "drawOval", &JsiSkCanvas::drawOval);
564
+ installMethod(runtime, prototype, "restoreToCount",
565
+ &JsiSkCanvas::restoreToCount);
566
+ installMethod(runtime, prototype, "getSaveCount",
567
+ &JsiSkCanvas::getSaveCount);
568
+ installMethod(runtime, prototype, "getTotalMatrix",
569
+ &JsiSkCanvas::getTotalMatrix);
570
+ installMethod(runtime, prototype, "drawPoints", &JsiSkCanvas::drawPoints);
571
+ installHostMethod(runtime, prototype, "drawPatch", &JsiSkCanvas::drawPatch);
572
+ installMethod(runtime, prototype, "drawPath", &JsiSkCanvas::drawPath);
573
+ installMethod(runtime, prototype, "drawVertices",
574
+ &JsiSkCanvas::drawVertices);
575
+ installMethod(runtime, prototype, "drawText", &JsiSkCanvas::drawText);
576
+ installMethod(runtime, prototype, "drawTextBlob",
577
+ &JsiSkCanvas::drawTextBlob);
578
+ installMethod(runtime, prototype, "drawGlyphs", &JsiSkCanvas::drawGlyphs);
579
+ installMethod(runtime, prototype, "drawSvg", &JsiSkCanvas::drawSvg);
580
+ installMethod(runtime, prototype, "clipPath", &JsiSkCanvas::clipPath);
581
+ installMethod(runtime, prototype, "clipRect", &JsiSkCanvas::clipRect);
582
+ installMethod(runtime, prototype, "clipRRect", &JsiSkCanvas::clipRRect);
583
+ installMethod(runtime, prototype, "save", &JsiSkCanvas::save);
584
+ installHostMethod(runtime, prototype, "saveLayer", &JsiSkCanvas::saveLayer);
585
+ installMethod(runtime, prototype, "restore", &JsiSkCanvas::restore);
586
+ installMethod(runtime, prototype, "rotate", &JsiSkCanvas::rotate);
587
+ installMethod(runtime, prototype, "translate", &JsiSkCanvas::translate);
588
+ installMethod(runtime, prototype, "scale", &JsiSkCanvas::scale);
589
+ installMethod(runtime, prototype, "skew", &JsiSkCanvas::skew);
590
+ installMethod(runtime, prototype, "drawColor", &JsiSkCanvas::drawColor);
591
+ installMethod(runtime, prototype, "clear", &JsiSkCanvas::clear);
592
+ installMethod(runtime, prototype, "concat", &JsiSkCanvas::concat);
593
+ installMethod(runtime, prototype, "drawPicture",
594
+ &JsiSkCanvas::drawPicture);
595
+ installHostMethod(runtime, prototype, "drawAtlas", &JsiSkCanvas::drawAtlas);
596
+ installHostMethod(runtime, prototype, "readPixels",
597
+ &JsiSkCanvas::readPixels);
598
+ }
599
+
600
+ size_t getMemoryPressure() override { return 1024; }
726
601
 
727
602
  explicit JsiSkCanvas(std::shared_ptr<RNSkPlatformContext> context)
728
- : JsiSkHostObject(std::move(context)) {}
603
+ : JsiSkNativeObject<JsiSkCanvas>(std::move(context)) {}
729
604
 
730
605
  JsiSkCanvas(std::shared_ptr<RNSkPlatformContext> context, SkCanvas *canvas)
731
606
  : JsiSkCanvas(std::move(context)) {
@@ -6,7 +6,7 @@
6
6
 
7
7
  #include <jsi/jsi.h>
8
8
 
9
- #include "JsiSkHostObjects.h"
9
+ #include "JsiSkNativeObjects.h"
10
10
  #include "api/third_party/CSSColorParser.h"
11
11
 
12
12
  #pragma clang diagnostic push
@@ -20,11 +20,13 @@ namespace RNSkia {
20
20
 
21
21
  namespace jsi = facebook::jsi;
22
22
 
23
- class JsiSkColor : public RNJsi::JsiHostObject {
23
+ /**
24
+ * JsiSkColor is a pure utility class — colors are represented as
25
+ * Float32Arrays on the JS side, so there is no wrapper object.
26
+ */
27
+ class JsiSkColor {
24
28
  public:
25
- JsiSkColor() : JsiHostObject() {}
26
-
27
- ~JsiSkColor() override = default;
29
+ JsiSkColor() = default;
28
30
 
29
31
  static jsi::Object toValue(jsi::Runtime &runtime, SkColor color) {
30
32
  auto result = runtime.global()
@@ -1,6 +1,6 @@
1
1
  #pragma once
2
2
 
3
- #include "JsiSkHostObjects.h"
3
+ #include "JsiSkNativeObjects.h"
4
4
  #include <jsi/jsi.h>
5
5
  #include <memory>
6
6
  #include <utility>
@@ -16,19 +16,26 @@ namespace RNSkia {
16
16
 
17
17
  namespace jsi = facebook::jsi;
18
18
 
19
- class JsiSkColorFilter : public JsiSkWrappingSkPtrHostObject<SkColorFilter> {
19
+ class JsiSkColorFilter
20
+ : public JsiSkWrappingSkPtrNativeObject<JsiSkColorFilter, SkColorFilter> {
20
21
  public:
22
+ static constexpr const char *CLASS_NAME = "ColorFilter";
23
+
21
24
  JsiSkColorFilter(std::shared_ptr<RNSkPlatformContext> context,
22
25
  sk_sp<SkColorFilter> colorFilter)
23
- : JsiSkWrappingSkPtrHostObject<SkColorFilter>(std::move(context),
24
- std::move(colorFilter)) {}
26
+ : JsiSkWrappingSkPtrNativeObject<JsiSkColorFilter, SkColorFilter>(
27
+ std::move(context), std::move(colorFilter)) {}
25
28
 
26
- size_t getMemoryPressure() const override { return 2048; }
29
+ size_t getMemoryPressure() override { return 2048; }
27
30
 
28
- std::string getObjectType() const override { return "JsiSkColorFilter"; }
31
+ static sk_sp<SkColorFilter> fromValue(jsi::Runtime &runtime,
32
+ const jsi::Value &obj) {
33
+ return objectFromValue(runtime, obj);
34
+ }
29
35
 
30
- EXPORT_JSI_API_TYPENAME(JsiSkColorFilter, ColorFilter)
31
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkColorFilter, dispose))
36
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
37
+ installCommon(runtime, prototype);
38
+ }
32
39
  };
33
40
 
34
41
  } // namespace RNSkia