@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
@@ -5,14 +5,17 @@
5
5
 
6
6
  #include <jsi/jsi.h>
7
7
 
8
+ #include "JsiSkNativeObjects.h"
8
9
  #include "JsiSkSkottie.h"
9
10
 
10
11
  namespace RNSkia {
11
12
 
12
13
  namespace jsi = facebook::jsi;
13
14
 
14
- class JsiSkottieFactory : public JsiSkHostObject {
15
+ class JsiSkottieFactory : public JsiSkNativeObject<JsiSkottieFactory> {
15
16
  public:
17
+ static constexpr const char *CLASS_NAME = "SkottieFactory";
18
+
16
19
  JSI_HOST_FUNCTION(Make) {
17
20
  auto fontMgr = JsiSkFontMgrFactory::getFontMgr(getContext());
18
21
  auto json = arguments[0].asString(runtime).utf8(runtime);
@@ -34,13 +37,10 @@ public:
34
37
  auto jsObject = jsValue.asObject(runtime);
35
38
 
36
39
  // Check if the object is a SkData host object
37
- if (jsObject.isHostObject(runtime)) {
38
- auto hostObject = jsObject.getHostObject(runtime);
39
- auto skData = std::dynamic_pointer_cast<JsiSkData>(hostObject);
40
- if (skData) {
41
- std::string k = key;
42
- assets[k] = skData->getObject();
43
- }
40
+ auto skData = tryGetJsiObject<JsiSkData>(runtime, jsObject);
41
+ if (skData) {
42
+ std::string k = key;
43
+ assets[k] = skData->getObject();
44
44
  }
45
45
  }
46
46
  }
@@ -51,20 +51,19 @@ public:
51
51
  if (!managedAnimation->_animation) {
52
52
  return jsi::Value::null();
53
53
  }
54
- auto skottie = std::make_shared<JsiSkSkottie>(getContext(),
55
- std::move(managedAnimation));
56
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, skottie,
57
- getContext());
54
+ return makeJsiObject(
55
+ runtime, std::make_shared<JsiSkSkottie>(getContext(),
56
+ std::move(managedAnimation)));
58
57
  }
59
58
 
60
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkottieFactory, Make))
61
-
62
- size_t getMemoryPressure() const override { return 4096; }
59
+ size_t getMemoryPressure() override { return 4096; }
63
60
 
64
- std::string getObjectType() const override { return "JsiSkottieFactory"; }
61
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
62
+ installHostMethod(runtime, prototype, "Make", &JsiSkottieFactory::Make);
63
+ }
65
64
 
66
65
  explicit JsiSkottieFactory(std::shared_ptr<RNSkPlatformContext> context)
67
- : JsiSkHostObject(std::move(context)) {}
66
+ : JsiSkNativeObject<JsiSkottieFactory>(std::move(context)) {}
68
67
  };
69
68
 
70
69
  } // namespace RNSkia
@@ -1,119 +1,83 @@
1
1
  #pragma once
2
2
 
3
3
  #include <memory>
4
- #include <numeric>
5
4
  #include <utility>
6
- #include <vector>
5
+ #include <variant>
7
6
 
8
- #include "JsiSkHostObjects.h"
9
- #include "utils/RNSkLog.h"
7
+ #include "JsiSkNativeObjects.h"
10
8
  #include <jsi/jsi.h>
11
9
 
12
- #include "JsiSkPaint.h"
13
- #include "JsiSkPoint.h"
14
- #include "JsiSkRect.h"
15
- #include "JsiSkTypeface.h"
10
+ #include "JsiSkConverters.h"
11
+ #include "JsiSkImage.h"
16
12
 
17
13
  #include "rnskia/RNSkVideo.h"
18
14
 
19
- #pragma clang diagnostic push
20
- #pragma clang diagnostic ignored "-Wdocumentation"
21
-
22
- #include "include/core/SkFont.h"
23
- #include "include/core/SkFontMetrics.h"
24
-
25
- #pragma clang diagnostic pop
26
-
27
15
  namespace RNSkia {
28
16
 
29
17
  namespace jsi = facebook::jsi;
30
18
 
31
- class JsiVideo : public JsiSkWrappingSharedPtrHostObject<RNSkVideo> {
19
+ class JsiVideo
20
+ : public JsiSkWrappingSharedPtrNativeObject<JsiVideo, RNSkVideo> {
32
21
  public:
33
- EXPORT_JSI_API_TYPENAME(JsiVideo, Video)
22
+ static constexpr const char *CLASS_NAME = "Video";
34
23
 
35
- JSI_HOST_FUNCTION(nextImage) {
24
+ std::variant<std::nullptr_t, std::shared_ptr<JsiSkImage>> nextImage() {
36
25
  double timestamp = 0;
37
- auto video = getObject();
38
- auto image = video->nextImage(&timestamp);
26
+ auto image = getObject()->nextImage(&timestamp);
39
27
  if (!image) {
40
- return jsi::Value::null();
28
+ return nullptr;
41
29
  }
42
- auto hostObjectInstance =
43
- std::make_shared<JsiSkImage>(getContext(), std::move(image));
44
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
45
- runtime, hostObjectInstance, getContext());
30
+ return std::make_shared<JsiSkImage>(getContext(), std::move(image));
46
31
  }
47
32
 
48
- JSI_HOST_FUNCTION(duration) { return getObject()->duration(); }
33
+ double duration() { return getObject()->duration(); }
49
34
 
50
- JSI_HOST_FUNCTION(framerate) { return getObject()->framerate(); }
35
+ double framerate() { return getObject()->framerate(); }
51
36
 
52
- JSI_HOST_FUNCTION(currentTime) { return getObject()->currentTime(); }
37
+ double currentTime() { return getObject()->currentTime(); }
53
38
 
54
- JSI_HOST_FUNCTION(isPlaying) { return getObject()->isPlaying(); }
39
+ bool isPlaying() { return getObject()->isPlaying(); }
55
40
 
56
- JSI_HOST_FUNCTION(seek) {
57
- double timestamp = arguments[0].asNumber();
58
- getObject()->seek(timestamp);
59
- return jsi::Value::undefined();
60
- }
41
+ void seek(double timestamp) { getObject()->seek(timestamp); }
61
42
 
62
- JSI_HOST_FUNCTION(rotation) {
63
- auto context = getContext();
64
- auto rot = getObject()->getRotationInDegrees();
65
- return jsi::Value(static_cast<double>(rot));
43
+ double rotation() {
44
+ return static_cast<double>(getObject()->getRotationInDegrees());
66
45
  }
67
46
 
68
- JSI_HOST_FUNCTION(size) {
69
- auto context = getContext();
70
- auto size = getObject()->getSize();
71
- auto result = jsi::Object(runtime);
72
- result.setProperty(runtime, "width", static_cast<double>(size.width()));
73
- result.setProperty(runtime, "height", static_cast<double>(size.height()));
74
- return result;
75
- }
47
+ SkISize size() { return getObject()->getSize(); }
76
48
 
77
- JSI_HOST_FUNCTION(play) {
78
- getObject()->play();
79
- return jsi::Value::undefined();
80
- }
49
+ void play() { getObject()->play(); }
81
50
 
82
- JSI_HOST_FUNCTION(pause) {
83
- getObject()->pause();
84
- return jsi::Value::undefined();
85
- }
51
+ void pause() { getObject()->pause(); }
86
52
 
87
- JSI_HOST_FUNCTION(setVolume) {
88
- auto volume = arguments[0].asNumber();
53
+ void setVolume(double volume) {
89
54
  getObject()->setVolume(static_cast<float>(volume));
90
- return jsi::Value::undefined();
91
55
  }
92
56
 
93
- JSI_HOST_FUNCTION(setLooping) {
94
- auto looping = arguments[0].asBool();
95
- getObject()->setLooping(looping);
96
- return jsi::Value::undefined();
57
+ void setLooping(bool looping) { getObject()->setLooping(looping); }
58
+
59
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
60
+ installCommon(runtime, prototype);
61
+ installMethod(runtime, prototype, "nextImage", &JsiVideo::nextImage);
62
+ installMethod(runtime, prototype, "duration", &JsiVideo::duration);
63
+ installMethod(runtime, prototype, "framerate", &JsiVideo::framerate);
64
+ installMethod(runtime, prototype, "currentTime", &JsiVideo::currentTime);
65
+ installMethod(runtime, prototype, "isPlaying", &JsiVideo::isPlaying);
66
+ installMethod(runtime, prototype, "seek", &JsiVideo::seek);
67
+ installMethod(runtime, prototype, "rotation", &JsiVideo::rotation);
68
+ installMethod(runtime, prototype, "size", &JsiVideo::size);
69
+ installMethod(runtime, prototype, "play", &JsiVideo::play);
70
+ installMethod(runtime, prototype, "pause", &JsiVideo::pause);
71
+ installMethod(runtime, prototype, "setVolume", &JsiVideo::setVolume);
72
+ installMethod(runtime, prototype, "setLooping", &JsiVideo::setLooping);
97
73
  }
98
74
 
99
- JSI_EXPORT_FUNCTIONS(
100
- JSI_EXPORT_FUNC(JsiVideo, nextImage), JSI_EXPORT_FUNC(JsiVideo, duration),
101
- JSI_EXPORT_FUNC(JsiVideo, framerate),
102
- JSI_EXPORT_FUNC(JsiVideo, currentTime),
103
- JSI_EXPORT_FUNC(JsiVideo, isPlaying), JSI_EXPORT_FUNC(JsiVideo, seek),
104
- JSI_EXPORT_FUNC(JsiVideo, rotation), JSI_EXPORT_FUNC(JsiVideo, size),
105
- JSI_EXPORT_FUNC(JsiVideo, play), JSI_EXPORT_FUNC(JsiVideo, pause),
106
- JSI_EXPORT_FUNC(JsiVideo, setVolume),
107
- JSI_EXPORT_FUNC(JsiVideo, setLooping), JSI_EXPORT_FUNC(JsiVideo, dispose))
108
-
109
75
  JsiVideo(std::shared_ptr<RNSkPlatformContext> context,
110
76
  std::shared_ptr<RNSkVideo> video)
111
- : JsiSkWrappingSharedPtrHostObject(std::move(context), std::move(video)) {
112
- }
113
-
114
- size_t getMemoryPressure() const override { return 32768; }
77
+ : JsiSkWrappingSharedPtrNativeObject<JsiVideo, RNSkVideo>(
78
+ std::move(context), std::move(video)) {}
115
79
 
116
- std::string getObjectType() const override { return "JsiVideo"; }
80
+ size_t getMemoryPressure() override { return 32768; }
117
81
 
118
82
  /**
119
83
  * Creates the function for construction a new instance of the SkFont
@@ -128,10 +92,8 @@ public:
128
92
  auto url = arguments[0].asString(runtime).utf8(runtime);
129
93
  auto video = context->createVideo(url);
130
94
  // Return the newly constructed object
131
- auto videoObj =
132
- std::make_shared<JsiVideo>(std::move(context), std::move(video));
133
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, videoObj,
134
- context);
95
+ return makeJsiObject(runtime, std::make_shared<JsiVideo>(
96
+ std::move(context), std::move(video)));
135
97
  };
136
98
  }
137
99
  };
@@ -394,8 +394,7 @@ SkSamplingOptions getPropertyValue(jsi::Runtime &runtime,
394
394
  template <>
395
395
  SkFont getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
396
396
  if (value.isObject()) {
397
- auto font =
398
- value.asObject(runtime).asHostObject<JsiSkFont>(runtime)->getObject();
397
+ auto font = getJsiObject<JsiSkFont>(runtime, value)->getObject();
399
398
  return SkFont(*font);
400
399
  }
401
400
  throw std::runtime_error("Invalid prop value for SkFont received");
@@ -427,9 +426,7 @@ GlyphData getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
427
426
  template <>
428
427
  SkRSXform getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
429
428
  if (value.isObject()) {
430
- auto form = value.asObject(runtime)
431
- .asHostObject<JsiSkRSXform>(runtime)
432
- ->getObject();
429
+ auto form = getJsiObject<JsiSkRSXform>(runtime, value)->getObject();
433
430
  return SkRSXform::Make(form->fSCos, form->fSSin, form->fTx, form->fTy);
434
431
  }
435
432
  throw std::runtime_error("Invalid prop value for SkRSXform received");
@@ -438,13 +435,11 @@ SkRSXform getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
438
435
  template <>
439
436
  sk_sp<SkSVGDOM> getPropertyValue(jsi::Runtime &runtime,
440
437
  const jsi::Value &value) {
441
- if (value.isObject() && value.asObject(runtime).isHostObject(runtime)) {
442
- auto ptr = std::dynamic_pointer_cast<JsiSkSVG>(
443
- value.asObject(runtime).asHostObject(runtime));
444
- if (ptr != nullptr) {
445
- return ptr->getObject();
446
- }
447
- } else if (value.isNull()) {
438
+ auto ptr = tryGetJsiObject<JsiSkSVG>(runtime, value);
439
+ if (ptr != nullptr) {
440
+ return ptr->getObject();
441
+ }
442
+ if (value.isNull()) {
448
443
  return nullptr;
449
444
  }
450
445
  throw std::runtime_error(
@@ -454,13 +449,11 @@ sk_sp<SkSVGDOM> getPropertyValue(jsi::Runtime &runtime,
454
449
  template <>
455
450
  sk_sp<skottie::Animation> getPropertyValue(jsi::Runtime &runtime,
456
451
  const jsi::Value &value) {
457
- if (value.isObject() && value.asObject(runtime).isHostObject(runtime)) {
458
- auto ptr = std::dynamic_pointer_cast<JsiSkSkottie>(
459
- value.asObject(runtime).asHostObject(runtime));
460
- if (ptr != nullptr) {
461
- return ptr->getObject()->_animation;
462
- }
463
- } else if (value.isNull()) {
452
+ auto ptr = tryGetJsiObject<JsiSkSkottie>(runtime, value);
453
+ if (ptr != nullptr) {
454
+ return ptr->getObject()->_animation;
455
+ }
456
+ if (value.isNull()) {
464
457
  return nullptr;
465
458
  }
466
459
  throw std::runtime_error(
@@ -470,13 +463,11 @@ sk_sp<skottie::Animation> getPropertyValue(jsi::Runtime &runtime,
470
463
  template <>
471
464
  sk_sp<SkImageFilter> getPropertyValue(jsi::Runtime &runtime,
472
465
  const jsi::Value &value) {
473
- if (value.isObject() && value.asObject(runtime).isHostObject(runtime)) {
474
- auto ptr = std::dynamic_pointer_cast<JsiSkImageFilter>(
475
- value.asObject(runtime).asHostObject(runtime));
476
- if (ptr != nullptr) {
477
- return ptr->getObject();
478
- }
479
- } else if (value.isNull()) {
466
+ auto ptr = tryGetJsiObject<JsiSkImageFilter>(runtime, value);
467
+ if (ptr != nullptr) {
468
+ return ptr->getObject();
469
+ }
470
+ if (value.isNull()) {
480
471
  return nullptr;
481
472
  }
482
473
  throw std::runtime_error(
@@ -487,9 +478,7 @@ template <>
487
478
  sk_sp<SkPicture> getPropertyValue(jsi::Runtime &runtime,
488
479
  const jsi::Value &value) {
489
480
  if (value.isObject()) {
490
- auto picture = value.asObject(runtime)
491
- .asHostObject<JsiSkPicture>(runtime)
492
- ->getObject();
481
+ auto picture = getJsiObject<JsiSkPicture>(runtime, value)->getObject();
493
482
  return picture;
494
483
  }
495
484
  throw std::runtime_error("Invalid prop value for SkTextBlob received");
@@ -498,8 +487,7 @@ sk_sp<SkPicture> getPropertyValue(jsi::Runtime &runtime,
498
487
  template <>
499
488
  SkPaint getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
500
489
  if (value.isObject()) {
501
- auto paint =
502
- value.asObject(runtime).asHostObject<JsiSkPaint>(runtime)->getObject();
490
+ auto paint = getJsiObject<JsiSkPaint>(runtime, value)->getObject();
503
491
  return SkPaint(*paint);
504
492
  }
505
493
  throw std::runtime_error("Invalid prop value for SkPaint received");
@@ -508,28 +496,15 @@ SkPaint getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
508
496
  template <>
509
497
  std::shared_ptr<JsiSkParagraph> getPropertyValue(jsi::Runtime &runtime,
510
498
  const jsi::Value &value) {
511
- if (value.isObject()) {
512
- auto hostObject = value.asObject(runtime).asHostObject(runtime);
513
- if (!hostObject) {
514
- return nullptr;
515
- }
516
- auto para = std::dynamic_pointer_cast<JsiSkParagraph>(hostObject);
517
- if (!para) {
518
- return nullptr;
519
- }
520
- // Return a shared_ptr instead of raw pointer
521
- return para;
522
- }
523
- return nullptr;
499
+ // Return a shared_ptr instead of raw pointer
500
+ return tryGetJsiObject<JsiSkParagraph>(runtime, value);
524
501
  }
525
502
 
526
503
  template <>
527
504
  sk_sp<SkTextBlob> getPropertyValue(jsi::Runtime &runtime,
528
505
  const jsi::Value &value) {
529
506
  if (value.isObject()) {
530
- auto blob = value.asObject(runtime)
531
- .asHostObject<JsiSkTextBlob>(runtime)
532
- ->getObject();
507
+ auto blob = getJsiObject<JsiSkTextBlob>(runtime, value)->getObject();
533
508
  return blob;
534
509
  }
535
510
  throw std::runtime_error("Invalid prop value for SkTextBlob received");
@@ -539,9 +514,7 @@ template <>
539
514
  sk_sp<SkRuntimeEffect> getPropertyValue(jsi::Runtime &runtime,
540
515
  const jsi::Value &value) {
541
516
  if (value.isObject()) {
542
- auto effect = value.asObject(runtime)
543
- .asHostObject<JsiSkRuntimeEffect>(runtime)
544
- ->getObject();
517
+ auto effect = getJsiObject<JsiSkRuntimeEffect>(runtime, value)->getObject();
545
518
  return effect;
546
519
  }
547
520
  throw std::runtime_error("Invalid prop value for SkRuntimeEffect received");
@@ -552,8 +525,7 @@ sk_sp<SkImage> getPropertyValue(jsi::Runtime &runtime,
552
525
  const jsi::Value &value) {
553
526
 
554
527
  if (value.isObject()) {
555
- auto effect =
556
- value.asObject(runtime).asHostObject<JsiSkImage>(runtime)->getObject();
528
+ auto effect = getJsiObject<JsiSkImage>(runtime, value)->getObject();
557
529
  return effect;
558
530
  } else if (value.isNull()) {
559
531
  return nullptr;
@@ -564,11 +536,9 @@ sk_sp<SkImage> getPropertyValue(jsi::Runtime &runtime,
564
536
  template <>
565
537
  SkMatrix getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
566
538
  if (value.isObject()) {
567
- auto object = value.asObject(runtime);
568
-
569
- if (object.isHostObject(runtime)) {
570
- auto matrix =
571
- object.asHostObject<JsiSkMatrix>(runtime)->getObject().get();
539
+ auto ptr = tryGetJsiObject<JsiSkMatrix>(runtime, value);
540
+ if (ptr != nullptr) {
541
+ auto matrix = ptr->getObject().get();
572
542
  return SkMatrix(*matrix);
573
543
  } else {
574
544
  return JsiSkMatrix::getMatrix(runtime, value);
@@ -1008,10 +978,10 @@ Layer getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
1008
978
  if (value.isBool()) {
1009
979
  Layer layer = value.asBool();
1010
980
  return layer;
1011
- } else if (value.isObject() &&
1012
- value.asObject(runtime).isHostObject(runtime)) {
1013
- auto paint =
1014
- value.asObject(runtime).asHostObject<JsiSkPaint>(runtime)->getObject();
981
+ }
982
+ auto ptr = tryGetJsiObject<JsiSkPaint>(runtime, value);
983
+ if (ptr != nullptr) {
984
+ auto paint = ptr->getObject();
1015
985
  Layer layer = SkPaint(*paint);
1016
986
  return layer;
1017
987
  }
@@ -51,12 +51,9 @@ std::shared_ptr<SkRect> processRect(jsi::Runtime &runtime,
51
51
  const jsi::Value &value) {
52
52
  if (value.isObject()) {
53
53
  auto object = value.asObject(runtime);
54
- if (object.isHostObject(runtime)) {
55
- auto ptr = std::dynamic_pointer_cast<JsiSkRect>(
56
- value.asObject(runtime).asHostObject(runtime));
57
- if (ptr != nullptr) {
58
- return ptr->getObject();
59
- }
54
+ auto ptr = tryGetJsiObject<JsiSkRect>(runtime, object);
55
+ if (ptr != nullptr) {
56
+ return ptr->getObject();
60
57
  } else if (object.hasProperty(runtime, "x") &&
61
58
  object.hasProperty(runtime, "y") &&
62
59
  object.hasProperty(runtime, "width") &&
@@ -88,12 +85,9 @@ std::shared_ptr<SkRRect> processRRect(jsi::Runtime &runtime,
88
85
  const jsi::Value &value) {
89
86
  if (value.isObject()) {
90
87
  auto object = value.asObject(runtime);
91
- if (object.isHostObject(runtime)) {
92
- auto ptr = std::dynamic_pointer_cast<JsiSkRRect>(
93
- value.asObject(runtime).asHostObject(runtime));
94
- if (ptr != nullptr) {
95
- return ptr->getObject();
96
- }
88
+ auto ptr = tryGetJsiObject<JsiSkRRect>(runtime, object);
89
+ if (ptr != nullptr) {
90
+ return ptr->getObject();
97
91
  } else if (object.hasProperty(runtime, "rect") &&
98
92
  object.hasProperty(runtime, "rx") &&
99
93
  object.hasProperty(runtime, "ry")) {
@@ -136,10 +130,8 @@ std::shared_ptr<SkPath> processPath(jsi::Runtime &runtime,
136
130
  } else {
137
131
  throw std::runtime_error("Could not parse path from string.");
138
132
  }
139
- } else if (value.isObject() &&
140
- value.asObject(runtime).isHostObject(runtime)) {
141
- auto ptr = std::dynamic_pointer_cast<JsiSkPath>(
142
- value.asObject(runtime).asHostObject(runtime));
133
+ } else {
134
+ auto ptr = tryGetJsiObject<JsiSkPath>(runtime, value);
143
135
  if (ptr != nullptr) {
144
136
  return std::make_shared<SkPath>(ptr->getObject()->snapshot());
145
137
  }
@@ -6,7 +6,7 @@
6
6
  #include <vector>
7
7
 
8
8
  #include "api/JsiSkCanvas.h"
9
- #include "api/JsiSkHostObjects.h"
9
+ #include "api/JsiSkNativeObjects.h"
10
10
  #include "api/JsiSkPicture.h"
11
11
 
12
12
  #include "DrawingCtx.h"
@@ -19,11 +19,14 @@ namespace RNSkia {
19
19
 
20
20
  namespace jsi = facebook::jsi;
21
21
 
22
- class JsiRecorder : public JsiSkWrappingSharedPtrHostObject<Recorder> {
22
+ class JsiRecorder
23
+ : public JsiSkWrappingSharedPtrNativeObject<JsiRecorder, Recorder> {
23
24
  public:
25
+ static constexpr const char *CLASS_NAME = "Recorder";
26
+
24
27
  JsiRecorder(std::shared_ptr<RNSkPlatformContext> context)
25
- : JsiSkWrappingSharedPtrHostObject(std::move(context),
26
- std::make_shared<Recorder>()) {
28
+ : JsiSkWrappingSharedPtrNativeObject<JsiRecorder, Recorder>(
29
+ std::move(context), std::make_shared<Recorder>()) {
27
30
  getObject()->_context = getContext();
28
31
  }
29
32
 
@@ -61,7 +64,8 @@ public:
61
64
 
62
65
  // Get the JsiSkPicture from the argument
63
66
  auto pictureObject = arguments[0].asObject(runtime);
64
- auto pictureHostObject = pictureObject.asHostObject<JsiSkPicture>(runtime);
67
+ auto pictureHostObject =
68
+ tryGetJsiObject<JsiSkPicture>(runtime, pictureObject);
65
69
  if (!pictureHostObject) {
66
70
  throw jsi::JSError(runtime, "Invalid Picture object provided to play()");
67
71
  }
@@ -302,65 +306,89 @@ public:
302
306
  return jsi::Value::undefined();
303
307
  }
304
308
 
305
- EXPORT_JSI_API_TYPENAME(JsiRecorder, Recorder)
306
-
307
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiRecorder, saveGroup),
308
- JSI_EXPORT_FUNC(JsiRecorder, restoreGroup),
309
- JSI_EXPORT_FUNC(JsiRecorder, savePaint),
310
- JSI_EXPORT_FUNC(JsiRecorder, restorePaint),
311
- JSI_EXPORT_FUNC(JsiRecorder, restorePaintDeclaration),
312
- JSI_EXPORT_FUNC(JsiRecorder, materializePaint),
313
- JSI_EXPORT_FUNC(JsiRecorder, pushPathEffect),
314
- JSI_EXPORT_FUNC(JsiRecorder, pushImageFilter),
315
- JSI_EXPORT_FUNC(JsiRecorder, pushColorFilter),
316
- JSI_EXPORT_FUNC(JsiRecorder, pushShader),
317
- JSI_EXPORT_FUNC(JsiRecorder, pushBlurMaskFilter),
318
- JSI_EXPORT_FUNC(JsiRecorder, composePathEffect),
319
- JSI_EXPORT_FUNC(JsiRecorder, composeColorFilter),
320
- JSI_EXPORT_FUNC(JsiRecorder, composeImageFilter),
321
- JSI_EXPORT_FUNC(JsiRecorder, saveCTM),
322
- JSI_EXPORT_FUNC(JsiRecorder, restoreCTM),
323
- JSI_EXPORT_FUNC(JsiRecorder, drawPaint),
324
- JSI_EXPORT_FUNC(JsiRecorder, saveLayer),
325
- JSI_EXPORT_FUNC(JsiRecorder, saveBackdropFilter),
326
- JSI_EXPORT_FUNC(JsiRecorder, drawBox),
327
- JSI_EXPORT_FUNC(JsiRecorder, drawImage),
328
- JSI_EXPORT_FUNC(JsiRecorder, drawCircle),
329
- JSI_EXPORT_FUNC(JsiRecorder, drawPoints),
330
- JSI_EXPORT_FUNC(JsiRecorder, drawPath),
331
- JSI_EXPORT_FUNC(JsiRecorder, drawRect),
332
- JSI_EXPORT_FUNC(JsiRecorder, drawRRect),
333
- JSI_EXPORT_FUNC(JsiRecorder, drawOval),
334
- JSI_EXPORT_FUNC(JsiRecorder, drawLine),
335
- JSI_EXPORT_FUNC(JsiRecorder, drawPatch),
336
- JSI_EXPORT_FUNC(JsiRecorder, drawVertices),
337
- JSI_EXPORT_FUNC(JsiRecorder, drawDiffRect),
338
- JSI_EXPORT_FUNC(JsiRecorder, drawText),
339
- JSI_EXPORT_FUNC(JsiRecorder, drawTextPath),
340
- JSI_EXPORT_FUNC(JsiRecorder, drawTextBlob),
341
- JSI_EXPORT_FUNC(JsiRecorder, drawGlyphs),
342
- JSI_EXPORT_FUNC(JsiRecorder, drawPicture),
343
- JSI_EXPORT_FUNC(JsiRecorder, drawImageSVG),
344
- JSI_EXPORT_FUNC(JsiRecorder, drawParagraph),
345
- JSI_EXPORT_FUNC(JsiRecorder, drawAtlas),
346
- JSI_EXPORT_FUNC(JsiRecorder, drawSkottie),
347
- JSI_EXPORT_FUNC(JsiRecorder, play),
348
- JSI_EXPORT_FUNC(JsiRecorder, applyUpdates),
349
- JSI_EXPORT_FUNC(JsiRecorder, reset))
309
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
310
+ installCommon(runtime, prototype);
311
+ installHostMethod(runtime, prototype, "saveGroup", &JsiRecorder::saveGroup);
312
+ installHostMethod(runtime, prototype, "restoreGroup",
313
+ &JsiRecorder::restoreGroup);
314
+ installHostMethod(runtime, prototype, "savePaint", &JsiRecorder::savePaint);
315
+ installHostMethod(runtime, prototype, "restorePaint",
316
+ &JsiRecorder::restorePaint);
317
+ installHostMethod(runtime, prototype, "restorePaintDeclaration",
318
+ &JsiRecorder::restorePaintDeclaration);
319
+ installHostMethod(runtime, prototype, "materializePaint",
320
+ &JsiRecorder::materializePaint);
321
+ installHostMethod(runtime, prototype, "pushPathEffect",
322
+ &JsiRecorder::pushPathEffect);
323
+ installHostMethod(runtime, prototype, "pushImageFilter",
324
+ &JsiRecorder::pushImageFilter);
325
+ installHostMethod(runtime, prototype, "pushColorFilter",
326
+ &JsiRecorder::pushColorFilter);
327
+ installHostMethod(runtime, prototype, "pushShader",
328
+ &JsiRecorder::pushShader);
329
+ installHostMethod(runtime, prototype, "pushBlurMaskFilter",
330
+ &JsiRecorder::pushBlurMaskFilter);
331
+ installHostMethod(runtime, prototype, "composePathEffect",
332
+ &JsiRecorder::composePathEffect);
333
+ installHostMethod(runtime, prototype, "composeColorFilter",
334
+ &JsiRecorder::composeColorFilter);
335
+ installHostMethod(runtime, prototype, "composeImageFilter",
336
+ &JsiRecorder::composeImageFilter);
337
+ installHostMethod(runtime, prototype, "saveCTM", &JsiRecorder::saveCTM);
338
+ installHostMethod(runtime, prototype, "restoreCTM",
339
+ &JsiRecorder::restoreCTM);
340
+ installHostMethod(runtime, prototype, "drawPaint", &JsiRecorder::drawPaint);
341
+ installHostMethod(runtime, prototype, "saveLayer", &JsiRecorder::saveLayer);
342
+ installHostMethod(runtime, prototype, "saveBackdropFilter",
343
+ &JsiRecorder::saveBackdropFilter);
344
+ installHostMethod(runtime, prototype, "drawBox", &JsiRecorder::drawBox);
345
+ installHostMethod(runtime, prototype, "drawImage", &JsiRecorder::drawImage);
346
+ installHostMethod(runtime, prototype, "drawCircle",
347
+ &JsiRecorder::drawCircle);
348
+ installHostMethod(runtime, prototype, "drawPoints",
349
+ &JsiRecorder::drawPoints);
350
+ installHostMethod(runtime, prototype, "drawPath", &JsiRecorder::drawPath);
351
+ installHostMethod(runtime, prototype, "drawRect", &JsiRecorder::drawRect);
352
+ installHostMethod(runtime, prototype, "drawRRect", &JsiRecorder::drawRRect);
353
+ installHostMethod(runtime, prototype, "drawOval", &JsiRecorder::drawOval);
354
+ installHostMethod(runtime, prototype, "drawLine", &JsiRecorder::drawLine);
355
+ installHostMethod(runtime, prototype, "drawPatch", &JsiRecorder::drawPatch);
356
+ installHostMethod(runtime, prototype, "drawVertices",
357
+ &JsiRecorder::drawVertices);
358
+ installHostMethod(runtime, prototype, "drawDiffRect",
359
+ &JsiRecorder::drawDiffRect);
360
+ installHostMethod(runtime, prototype, "drawText", &JsiRecorder::drawText);
361
+ installHostMethod(runtime, prototype, "drawTextPath",
362
+ &JsiRecorder::drawTextPath);
363
+ installHostMethod(runtime, prototype, "drawTextBlob",
364
+ &JsiRecorder::drawTextBlob);
365
+ installHostMethod(runtime, prototype, "drawGlyphs",
366
+ &JsiRecorder::drawGlyphs);
367
+ installHostMethod(runtime, prototype, "drawPicture",
368
+ &JsiRecorder::drawPicture);
369
+ installHostMethod(runtime, prototype, "drawImageSVG",
370
+ &JsiRecorder::drawImageSVG);
371
+ installHostMethod(runtime, prototype, "drawParagraph",
372
+ &JsiRecorder::drawParagraph);
373
+ installHostMethod(runtime, prototype, "drawAtlas", &JsiRecorder::drawAtlas);
374
+ installHostMethod(runtime, prototype, "drawSkottie",
375
+ &JsiRecorder::drawSkottie);
376
+ installHostMethod(runtime, prototype, "play", &JsiRecorder::play);
377
+ installHostMethod(runtime, prototype, "applyUpdates",
378
+ &JsiRecorder::applyUpdates);
379
+ installHostMethod(runtime, prototype, "reset", &JsiRecorder::reset);
380
+ }
350
381
 
351
382
  // This has no basis in reality but since since these are private long-lived
352
383
  // objects, we think it is more than fine.
353
- size_t getMemoryPressure() const override { return 5 * 1024 * 1024; }
354
-
355
- std::string getObjectType() const override { return "JsiRecorder"; }
384
+ size_t getMemoryPressure() override { return 5 * 1024 * 1024; }
356
385
 
357
386
  static const jsi::HostFunctionType
358
387
  createCtor(std::shared_ptr<RNSkPlatformContext> context) {
359
388
  return JSI_HOST_FUNCTION_LAMBDA {
360
389
  // Return the newly constructed object
361
390
  auto recorder = std::make_shared<JsiRecorder>(std::move(context));
362
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, recorder,
363
- context);
391
+ return makeJsiObject(runtime, std::move(recorder));
364
392
  };
365
393
  }
366
394
  };
@@ -17,8 +17,8 @@
17
17
  #include "ImageFilters.h"
18
18
  #include "Paint.h"
19
19
  #include "PathEffects.h"
20
- #include "rnskia/RNSkPlatformContext.h"
21
20
  #include "Shaders.h"
21
+ #include "rnskia/RNSkPlatformContext.h"
22
22
 
23
23
  namespace RNSkia {
24
24