@shopify/react-native-skia 2.9.1-next.1 → 2.10.0

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 (273) hide show
  1. package/android/CMakeLists.txt +1 -5
  2. package/android/cpp/jni/JniWebGPUView.cpp +52 -7
  3. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUSurfaceView.java +3 -1
  4. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUTextureView.java +11 -5
  5. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUView.java +10 -7
  6. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewAPI.java +7 -2
  7. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewManager.java +1 -1
  8. package/apple/WebGPUMetalView.mm +49 -6
  9. package/cpp/api/JsiNativeBuffer.h +15 -10
  10. package/cpp/api/JsiSkAnimatedImage.h +21 -19
  11. package/cpp/api/JsiSkAnimatedImageFactory.h +13 -14
  12. package/cpp/api/JsiSkApi.h +246 -92
  13. package/cpp/api/JsiSkCanvas.h +76 -58
  14. package/cpp/api/JsiSkColor.h +7 -5
  15. package/cpp/api/JsiSkColorFilter.h +15 -8
  16. package/cpp/api/JsiSkColorFilterFactory.h +45 -45
  17. package/cpp/api/JsiSkContourMeasure.h +24 -21
  18. package/cpp/api/JsiSkContourMeasureIter.h +18 -21
  19. package/cpp/api/JsiSkData.h +13 -7
  20. package/cpp/api/JsiSkDataFactory.h +22 -21
  21. package/cpp/api/JsiSkFont.h +56 -44
  22. package/cpp/api/JsiSkFontMgr.h +22 -13
  23. package/cpp/api/JsiSkFontMgrFactory.h +12 -10
  24. package/cpp/api/JsiSkFontStyle.h +14 -12
  25. package/cpp/api/JsiSkImage.h +45 -34
  26. package/cpp/api/JsiSkImageFactory.h +47 -52
  27. package/cpp/api/JsiSkImageFilter.h +21 -11
  28. package/cpp/api/JsiSkImageFilterFactory.h +96 -96
  29. package/cpp/api/JsiSkImageInfo.h +22 -19
  30. package/cpp/api/JsiSkMaskFilter.h +21 -11
  31. package/cpp/api/JsiSkMaskFilterFactory.h +16 -13
  32. package/cpp/api/JsiSkMatrix.h +31 -31
  33. package/cpp/api/JsiSkNativeObjects.h +419 -0
  34. package/cpp/api/JsiSkPaint.h +59 -39
  35. package/cpp/api/JsiSkParagraph.h +39 -32
  36. package/cpp/api/JsiSkParagraphBuilder.h +24 -21
  37. package/cpp/api/JsiSkParagraphBuilderFactory.h +13 -12
  38. package/cpp/api/JsiSkParagraphStyle.h +20 -10
  39. package/cpp/api/JsiSkPath.h +95 -70
  40. package/cpp/api/JsiSkPathBuilder.h +83 -67
  41. package/cpp/api/JsiSkPathBuilderFactory.h +16 -17
  42. package/cpp/api/JsiSkPathEffect.h +21 -11
  43. package/cpp/api/JsiSkPathEffectFactory.h +33 -32
  44. package/cpp/api/JsiSkPathFactory.h +79 -103
  45. package/cpp/api/JsiSkPicture.h +24 -13
  46. package/cpp/api/JsiSkPictureFactory.h +21 -26
  47. package/cpp/api/JsiSkPictureRecorder.h +21 -22
  48. package/cpp/api/JsiSkPoint.h +19 -22
  49. package/cpp/api/JsiSkRRect.h +22 -29
  50. package/cpp/api/JsiSkRSXform.h +26 -30
  51. package/cpp/api/JsiSkRect.h +28 -30
  52. package/cpp/api/JsiSkRuntimeEffect.h +39 -30
  53. package/cpp/api/JsiSkRuntimeEffectFactory.h +12 -12
  54. package/cpp/api/JsiSkRuntimeShaderBuilder.h +25 -18
  55. package/cpp/api/JsiSkSVG.h +13 -13
  56. package/cpp/api/JsiSkSVGFactory.h +17 -20
  57. package/cpp/api/JsiSkShader.h +15 -8
  58. package/cpp/api/JsiSkShaderFactory.h +41 -48
  59. package/cpp/api/JsiSkSkottie.h +49 -39
  60. package/cpp/api/JsiSkStrutStyle.h +18 -8
  61. package/cpp/api/JsiSkSurface.h +24 -24
  62. package/cpp/api/JsiSkSurfaceFactory.h +15 -16
  63. package/cpp/api/JsiSkTextBlob.h +15 -8
  64. package/cpp/api/JsiSkTextBlobFactory.h +25 -28
  65. package/cpp/api/JsiSkTextStyle.h +34 -24
  66. package/cpp/api/JsiSkTypeface.h +19 -12
  67. package/cpp/api/JsiSkTypefaceFactory.h +12 -12
  68. package/cpp/api/JsiSkTypefaceFontProvider.h +30 -25
  69. package/cpp/api/JsiSkTypefaceFontProviderFactory.h +14 -12
  70. package/cpp/api/JsiSkVertices.h +21 -18
  71. package/cpp/api/JsiSkiaContext.h +17 -17
  72. package/cpp/api/JsiSkottieFactory.h +16 -17
  73. package/cpp/api/JsiVideo.h +27 -25
  74. package/cpp/api/recorder/Convertor.h +31 -61
  75. package/cpp/api/recorder/DataTypes.h +8 -16
  76. package/cpp/api/recorder/JsiRecorder.h +83 -55
  77. package/cpp/api/recorder/RNRecorder.h +1 -1
  78. package/cpp/jsi/BoxedNativeObject.h +146 -0
  79. package/cpp/{jsi2 → jsi}/EnumMapper.h +4 -1
  80. package/cpp/{jsi2 → jsi}/NativeObject.h +120 -146
  81. package/cpp/jsi/RuntimeAwareCache.cpp +1 -1
  82. package/cpp/jsi/RuntimeAwareCache.h +26 -8
  83. package/cpp/jsi/ViewProperty.h +5 -11
  84. package/cpp/rnskia/RNSkJsiViewApi.h +20 -11
  85. package/cpp/rnskia/RNSkManager.cpp +29 -25
  86. package/cpp/rnskia/RNSkPictureView.h +1 -1
  87. package/cpp/rnwgpu/ArrayBuffer.h +5 -6
  88. package/cpp/rnwgpu/Canvas.h +4 -2
  89. package/cpp/rnwgpu/SurfaceRegistry.h +469 -131
  90. package/cpp/rnwgpu/api/GPU.cpp +4 -4
  91. package/cpp/rnwgpu/api/GPU.h +1 -1
  92. package/cpp/rnwgpu/api/GPUAdapter.cpp +12 -6
  93. package/cpp/rnwgpu/api/GPUAdapter.h +5 -4
  94. package/cpp/rnwgpu/api/GPUAdapterInfo.h +1 -1
  95. package/cpp/rnwgpu/api/GPUBindGroup.h +1 -1
  96. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +1 -1
  97. package/cpp/rnwgpu/api/GPUBuffer.cpp +12 -2
  98. package/cpp/rnwgpu/api/GPUBuffer.h +4 -3
  99. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +33 -19
  100. package/cpp/rnwgpu/api/GPUCanvasContext.h +4 -2
  101. package/cpp/rnwgpu/api/GPUCommandBuffer.h +1 -1
  102. package/cpp/rnwgpu/api/GPUCommandEncoder.h +1 -1
  103. package/cpp/rnwgpu/api/GPUCompilationInfo.h +1 -1
  104. package/cpp/rnwgpu/api/GPUCompilationMessage.h +1 -1
  105. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +1 -1
  106. package/cpp/rnwgpu/api/GPUComputePipeline.h +1 -1
  107. package/cpp/rnwgpu/api/GPUDevice.cpp +38 -24
  108. package/cpp/rnwgpu/api/GPUDevice.h +12 -10
  109. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +1 -1
  110. package/cpp/rnwgpu/api/GPUError.h +1 -1
  111. package/cpp/rnwgpu/api/GPUExtent3D.h +1 -1
  112. package/cpp/rnwgpu/api/GPUExternalTexture.h +1 -1
  113. package/cpp/rnwgpu/api/GPUInternalError.h +1 -1
  114. package/cpp/rnwgpu/api/GPUOrigin2D.h +1 -1
  115. package/cpp/rnwgpu/api/GPUOrigin3D.h +1 -1
  116. package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +1 -1
  117. package/cpp/rnwgpu/api/GPUPipelineLayout.h +1 -1
  118. package/cpp/rnwgpu/api/GPUQuerySet.h +1 -1
  119. package/cpp/rnwgpu/api/GPUQueue.cpp +6 -2
  120. package/cpp/rnwgpu/api/GPUQueue.h +4 -4
  121. package/cpp/rnwgpu/api/GPURenderBundle.h +1 -1
  122. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +1 -1
  123. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +1 -1
  124. package/cpp/rnwgpu/api/GPURenderPipeline.h +1 -1
  125. package/cpp/rnwgpu/api/GPUSampler.h +1 -1
  126. package/cpp/rnwgpu/api/GPUShaderModule.cpp +8 -3
  127. package/cpp/rnwgpu/api/GPUShaderModule.h +4 -4
  128. package/cpp/rnwgpu/api/GPUSharedFence.h +1 -1
  129. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +1 -1
  130. package/cpp/rnwgpu/api/GPUSupportedLimits.h +1 -1
  131. package/cpp/rnwgpu/api/GPUTexture.h +1 -1
  132. package/cpp/rnwgpu/api/GPUTextureView.h +1 -1
  133. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +1 -1
  134. package/cpp/rnwgpu/api/GPUValidationError.h +1 -1
  135. package/cpp/rnwgpu/api/ImageBitmap.h +1 -1
  136. package/cpp/rnwgpu/api/RNWebGPU.h +21 -1
  137. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +1 -1
  138. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +1 -1
  139. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +1 -1
  140. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +1 -1
  141. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +1 -1
  142. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +1 -1
  143. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +1 -1
  144. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +1 -1
  145. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +1 -1
  146. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +1 -1
  147. package/cpp/rnwgpu/api/descriptors/GPUColor.h +1 -1
  148. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +1 -1
  149. package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +1 -1
  150. package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +1 -1
  151. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +1 -1
  152. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +1 -1
  153. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +1 -1
  154. package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +1 -1
  155. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +1 -1
  156. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +1 -1
  157. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +1 -1
  158. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +1 -1
  159. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +1 -1
  160. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +1 -1
  161. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +1 -1
  162. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +1 -1
  163. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +1 -1
  164. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +1 -1
  165. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +1 -1
  166. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +1 -1
  167. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +1 -1
  168. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +1 -1
  169. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +1 -1
  170. package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +1 -1
  171. package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +1 -1
  172. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +1 -1
  173. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +1 -1
  174. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +1 -1
  175. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +1 -1
  176. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +1 -1
  177. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +1 -1
  178. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +1 -1
  179. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +1 -1
  180. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +1 -1
  181. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +1 -1
  182. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +1 -1
  183. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +1 -1
  184. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +1 -1
  185. package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +1 -1
  186. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +1 -1
  187. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +1 -1
  188. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +1 -1
  189. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +1 -1
  190. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +1 -1
  191. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +1 -1
  192. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +1 -1
  193. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +1 -1
  194. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +1 -1
  195. package/cpp/rnwgpu/api/descriptors/Unions.h +1 -1
  196. package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +20 -21
  197. package/cpp/rnwgpu/async/RuntimeContext.cpp +5 -0
  198. package/cpp/rnwgpu/async/RuntimeContext.h +15 -2
  199. package/lib/commonjs/external/reanimated/renderHelpers.d.ts +15 -0
  200. package/lib/commonjs/external/reanimated/renderHelpers.js +30 -1
  201. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
  202. package/lib/commonjs/skia/NativeSetup.js +4 -0
  203. package/lib/commonjs/skia/NativeSetup.js.map +1 -1
  204. package/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +1 -0
  205. package/lib/commonjs/skia/SkiaWorkletSerialization.js +66 -0
  206. package/lib/commonjs/skia/SkiaWorkletSerialization.js.map +1 -0
  207. package/lib/commonjs/sksg/Container.native.js +20 -1
  208. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  209. package/lib/commonjs/views/WebGPUCanvas.d.ts +1 -0
  210. package/lib/commonjs/views/WebGPUCanvas.js +13 -0
  211. package/lib/commonjs/views/WebGPUCanvas.js.map +1 -1
  212. package/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
  213. package/lib/module/external/reanimated/renderHelpers.js +29 -0
  214. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  215. package/lib/module/skia/NativeSetup.js +4 -0
  216. package/lib/module/skia/NativeSetup.js.map +1 -1
  217. package/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
  218. package/lib/module/skia/SkiaWorkletSerialization.js +59 -0
  219. package/lib/module/skia/SkiaWorkletSerialization.js.map +1 -0
  220. package/lib/module/sksg/Container.native.js +21 -2
  221. package/lib/module/sksg/Container.native.js.map +1 -1
  222. package/lib/module/views/WebGPUCanvas.d.ts +1 -0
  223. package/lib/module/views/WebGPUCanvas.js +14 -1
  224. package/lib/module/views/WebGPUCanvas.js.map +1 -1
  225. package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +2 -0
  226. package/lib/typescript/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +2 -0
  227. package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
  228. package/lib/typescript/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
  229. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +15 -0
  230. package/lib/typescript/src/skia/SkiaWorkletSerialization.d.ts +1 -0
  231. package/lib/typescript/src/views/WebGPUCanvas.d.ts +1 -0
  232. package/package.json +12 -8
  233. package/react-native-skia.podspec +1 -2
  234. package/src/external/reanimated/renderHelpers.ts +30 -0
  235. package/src/skia/NativeSetup.ts +5 -0
  236. package/src/skia/SkiaWorkletSerialization.ts +67 -0
  237. package/src/sksg/Container.native.ts +40 -2
  238. package/src/views/WebGPUCanvas.tsx +17 -1
  239. package/cpp/api/JsiSkHostObjects.h +0 -257
  240. package/cpp/dawn/include/dawn/dawn_proc.h +0 -53
  241. package/cpp/dawn/include/dawn/dawn_proc_table.h +0 -330
  242. package/cpp/dawn/include/dawn/dawn_thread_dispatch_proc.h +0 -47
  243. package/cpp/dawn/include/dawn/dawn_version.h +0 -41
  244. package/cpp/dawn/include/dawn/native/D3D11Backend.h +0 -65
  245. package/cpp/dawn/include/dawn/native/D3D12Backend.h +0 -86
  246. package/cpp/dawn/include/dawn/native/D3DBackend.h +0 -56
  247. package/cpp/dawn/include/dawn/native/DawnNative.h +0 -369
  248. package/cpp/dawn/include/dawn/native/MetalBackend.h +0 -56
  249. package/cpp/dawn/include/dawn/native/NullBackend.h +0 -39
  250. package/cpp/dawn/include/dawn/native/OpenGLBackend.h +0 -89
  251. package/cpp/dawn/include/dawn/native/VulkanBackend.h +0 -183
  252. package/cpp/dawn/include/dawn/native/WebGPUBackend.h +0 -49
  253. package/cpp/dawn/include/dawn/native/dawn_native_export.h +0 -49
  254. package/cpp/dawn/include/dawn/platform/DawnPlatform.h +0 -210
  255. package/cpp/dawn/include/dawn/platform/dawn_platform_export.h +0 -49
  256. package/cpp/dawn/include/dawn/replay/Replay.h +0 -99
  257. package/cpp/dawn/include/dawn/replay/dawn_replay_export.h +0 -49
  258. package/cpp/dawn/include/dawn/webgpu_cpp_print.h +0 -2844
  259. package/cpp/dawn/include/tint/tint.h +0 -90
  260. package/cpp/dawn/include/webgpu/webgpu.h +0 -4987
  261. package/cpp/dawn/include/webgpu/webgpu_cpp.h +0 -10080
  262. package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +0 -57
  263. package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +0 -161
  264. package/cpp/dawn/include/webgpu/webgpu_glfw.h +0 -88
  265. package/cpp/jsi/JsiHostObject.cpp +0 -137
  266. package/cpp/jsi/JsiHostObject.h +0 -385
  267. package/cpp/skia/src/gpu/graphite/ContextOptionsPriv.h +0 -45
  268. package/cpp/skia/src/gpu/graphite/ResourceTypes.h +0 -360
  269. package/cpp/skia/src/gpu/graphite/TextureProxyView.h +0 -105
  270. package/libs/.graphite +0 -1
  271. /package/cpp/{jsi2 → jsi}/JSIConverter.h +0 -0
  272. /package/cpp/{jsi2 → jsi}/Promise.cpp +0 -0
  273. /package/cpp/{jsi2 → jsi}/Promise.h +0 -0
@@ -9,7 +9,7 @@
9
9
 
10
10
  #include "JsiSkCanvas.h"
11
11
  #include "JsiSkFont.h"
12
- #include "JsiSkHostObjects.h"
12
+ #include "JsiSkNativeObjects.h"
13
13
  #include "JsiSkPath.h"
14
14
  #include "JsiSkRect.h"
15
15
 
@@ -31,9 +31,10 @@ namespace para = skia::textlayout;
31
31
  * Implementation of the Paragraph object in JSI
32
32
  */
33
33
  class JsiSkParagraph
34
- : public JsiSkWrappingSharedPtrHostObject<para::Paragraph> {
34
+ : public JsiSkWrappingSharedPtrNativeObject<JsiSkParagraph,
35
+ para::Paragraph> {
35
36
  public:
36
- EXPORT_JSI_API_TYPENAME(JsiSkParagraph, Paragraph)
37
+ static constexpr const char *CLASS_NAME = "Paragraph";
37
38
 
38
39
  JSI_HOST_FUNCTION(layout) {
39
40
  auto width = getArgumentAsNumber(runtime, arguments, count, 0);
@@ -42,8 +43,8 @@ public:
42
43
  }
43
44
 
44
45
  JSI_HOST_FUNCTION(paint) {
45
- auto jsiCanvas =
46
- getArgumentAsHostObject<JsiSkCanvas>(runtime, arguments, count, 0);
46
+ auto jsiCanvas = getJsiObject<JsiSkCanvas>(
47
+ runtime, getArgument(runtime, arguments, count, 0));
47
48
  auto x = getArgumentAsNumber(runtime, arguments, count, 1);
48
49
  auto y = getArgumentAsNumber(runtime, arguments, count, 2);
49
50
  getObject()->paint(jsiCanvas->getCanvas(), x, y);
@@ -182,10 +183,8 @@ public:
182
183
  &rec);
183
184
  });
184
185
  SkPath path = builder.detach();
185
- auto hostObjectInstance =
186
- std::make_shared<JsiSkPath>(getContext(), std::move(path));
187
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
188
- runtime, hostObjectInstance, getContext());
186
+ return makeJsiObject(
187
+ runtime, std::make_shared<JsiSkPath>(getContext(), std::move(path)));
189
188
  }
190
189
 
191
190
  JSI_HOST_FUNCTION(extendedVisit) {
@@ -203,10 +202,9 @@ public:
203
202
  }
204
203
  auto value = jsi::Object(runtime);
205
204
 
206
- auto fontInstance = std::make_shared<JsiSkFont>(context, info->font);
207
205
  value.setProperty(runtime, "font",
208
- JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
209
- runtime, fontInstance, context));
206
+ makeJsiObject(runtime, std::make_shared<JsiSkFont>(
207
+ context, info->font)));
210
208
 
211
209
  auto origin = jsi::Object(runtime);
212
210
  origin.setProperty(runtime, "x",
@@ -269,29 +267,38 @@ public:
269
267
  return returnValue;
270
268
  }
271
269
 
272
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkParagraph, layout),
273
- JSI_EXPORT_FUNC(JsiSkParagraph, paint),
274
- JSI_EXPORT_FUNC(JsiSkParagraph, getMaxWidth),
275
- JSI_EXPORT_FUNC(JsiSkParagraph, getMinIntrinsicWidth),
276
- JSI_EXPORT_FUNC(JsiSkParagraph, getMaxIntrinsicWidth),
277
- JSI_EXPORT_FUNC(JsiSkParagraph, getLongestLine),
278
- JSI_EXPORT_FUNC(JsiSkParagraph, getHeight),
279
- JSI_EXPORT_FUNC(JsiSkParagraph, getRectsForPlaceholders),
280
- JSI_EXPORT_FUNC(JsiSkParagraph,
281
- getGlyphPositionAtCoordinate),
282
- JSI_EXPORT_FUNC(JsiSkParagraph, getRectsForRange),
283
- JSI_EXPORT_FUNC(JsiSkParagraph, getLineMetrics),
284
- JSI_EXPORT_FUNC(JsiSkParagraph, getPath),
285
- JSI_EXPORT_FUNC(JsiSkParagraph, extendedVisit),
286
- JSI_EXPORT_FUNC(JsiSkParagraph, dispose))
287
-
288
- size_t getMemoryPressure() const override { return 1024 * 1024; }
289
-
290
- std::string getObjectType() const override { return "JsiSkParagraph"; }
270
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
271
+ installCommon(runtime, prototype);
272
+ installHostMethod(runtime, prototype, "layout", &JsiSkParagraph::layout);
273
+ installHostMethod(runtime, prototype, "paint", &JsiSkParagraph::paint);
274
+ installHostMethod(runtime, prototype, "getMaxWidth",
275
+ &JsiSkParagraph::getMaxWidth);
276
+ installHostMethod(runtime, prototype, "getMinIntrinsicWidth",
277
+ &JsiSkParagraph::getMinIntrinsicWidth);
278
+ installHostMethod(runtime, prototype, "getMaxIntrinsicWidth",
279
+ &JsiSkParagraph::getMaxIntrinsicWidth);
280
+ installHostMethod(runtime, prototype, "getLongestLine",
281
+ &JsiSkParagraph::getLongestLine);
282
+ installHostMethod(runtime, prototype, "getHeight",
283
+ &JsiSkParagraph::getHeight);
284
+ installHostMethod(runtime, prototype, "getRectsForPlaceholders",
285
+ &JsiSkParagraph::getRectsForPlaceholders);
286
+ installHostMethod(runtime, prototype, "getGlyphPositionAtCoordinate",
287
+ &JsiSkParagraph::getGlyphPositionAtCoordinate);
288
+ installHostMethod(runtime, prototype, "getRectsForRange",
289
+ &JsiSkParagraph::getRectsForRange);
290
+ installHostMethod(runtime, prototype, "getLineMetrics",
291
+ &JsiSkParagraph::getLineMetrics);
292
+ installHostMethod(runtime, prototype, "getPath", &JsiSkParagraph::getPath);
293
+ installHostMethod(runtime, prototype, "extendedVisit",
294
+ &JsiSkParagraph::extendedVisit);
295
+ }
296
+
297
+ size_t getMemoryPressure() override { return 1024 * 1024; }
291
298
 
292
299
  explicit JsiSkParagraph(std::shared_ptr<RNSkPlatformContext> context,
293
300
  para::ParagraphBuilder *paragraphBuilder)
294
- : JsiSkWrappingSharedPtrHostObject<para::Paragraph>(
301
+ : JsiSkWrappingSharedPtrNativeObject<JsiSkParagraph, para::Paragraph>(
295
302
  std::move(context), paragraphBuilder->Build()) {}
296
303
  };
297
304
 
@@ -8,7 +8,7 @@
8
8
  #include "JsiSkFont.h"
9
9
  #include "JsiSkFontMgr.h"
10
10
  #include "JsiSkFontMgrFactory.h"
11
- #include "JsiSkHostObjects.h"
11
+ #include "JsiSkNativeObjects.h"
12
12
  #include "JsiSkParagraph.h"
13
13
  #include "JsiSkParagraphStyle.h"
14
14
  #include "JsiSkTextStyle.h"
@@ -36,15 +36,13 @@ namespace para = skia::textlayout;
36
36
  /**
37
37
  Implementation of the ParagraphBuilder object in JSI
38
38
  */
39
- class JsiSkParagraphBuilder : public JsiSkHostObject {
39
+ class JsiSkParagraphBuilder : public JsiSkNativeObject<JsiSkParagraphBuilder> {
40
40
  public:
41
- JSI_API_TYPENAME("ParagraphBuilder");
41
+ static constexpr const char *CLASS_NAME = "ParagraphBuilder";
42
42
 
43
43
  JSI_HOST_FUNCTION(build) {
44
- auto paragraph =
45
- std::make_shared<JsiSkParagraph>(getContext(), _builder.get());
46
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, paragraph,
47
- getContext());
44
+ return makeJsiObject(runtime, std::make_shared<JsiSkParagraph>(
45
+ getContext(), _builder.get()));
48
46
  }
49
47
 
50
48
  JSI_HOST_FUNCTION(reset) {
@@ -84,16 +82,16 @@ public:
84
82
  auto textStyle = JsiSkTextStyle::fromValue(runtime, arguments[0]);
85
83
  // Foreground paint
86
84
  if (count >= 2) {
87
- auto foreground =
88
- tryGetArgumentAsHostObject<JsiSkPaint>(runtime, arguments, count, 1);
85
+ auto foreground = tryGetJsiObject<JsiSkPaint>(
86
+ runtime, getArgument(runtime, arguments, count, 1));
89
87
  if (foreground) {
90
88
  textStyle.setForegroundPaint(*foreground->getObject().get());
91
89
  }
92
90
  }
93
91
  // Background paint
94
92
  if (count >= 3) {
95
- auto background =
96
- tryGetArgumentAsHostObject<JsiSkPaint>(runtime, arguments, count, 2);
93
+ auto background = tryGetJsiObject<JsiSkPaint>(
94
+ runtime, getArgument(runtime, arguments, count, 2));
97
95
  if (background) {
98
96
  textStyle.setBackgroundPaint(*background->getObject().get());
99
97
  }
@@ -109,21 +107,26 @@ public:
109
107
  return thisValue.asObject(runtime);
110
108
  }
111
109
 
112
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkParagraphBuilder, build),
113
- JSI_EXPORT_FUNC(JsiSkParagraphBuilder, reset),
114
- JSI_EXPORT_FUNC(JsiSkParagraphBuilder, addText),
115
- JSI_EXPORT_FUNC(JsiSkParagraphBuilder, addPlaceholder),
116
- JSI_EXPORT_FUNC(JsiSkParagraphBuilder, pushStyle),
117
- JSI_EXPORT_FUNC(JsiSkParagraphBuilder, pop))
118
-
119
- size_t getMemoryPressure() const override { return 1024 * 1024; }
110
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
111
+ installHostMethod(runtime, prototype, "build",
112
+ &JsiSkParagraphBuilder::build);
113
+ installHostMethod(runtime, prototype, "reset",
114
+ &JsiSkParagraphBuilder::reset);
115
+ installHostMethod(runtime, prototype, "addText",
116
+ &JsiSkParagraphBuilder::addText);
117
+ installHostMethod(runtime, prototype, "addPlaceholder",
118
+ &JsiSkParagraphBuilder::addPlaceholder);
119
+ installHostMethod(runtime, prototype, "pushStyle",
120
+ &JsiSkParagraphBuilder::pushStyle);
121
+ installHostMethod(runtime, prototype, "pop", &JsiSkParagraphBuilder::pop);
122
+ }
120
123
 
121
- std::string getObjectType() const override { return "JsiSkParagraphBuilder"; }
124
+ size_t getMemoryPressure() override { return 1024 * 1024; }
122
125
 
123
126
  explicit JsiSkParagraphBuilder(std::shared_ptr<RNSkPlatformContext> context,
124
127
  para::ParagraphStyle paragraphStyle,
125
128
  sk_sp<SkFontMgr> fontManager)
126
- : JsiSkHostObject(std::move(context)) {
129
+ : JsiSkNativeObject<JsiSkParagraphBuilder>(std::move(context)) {
127
130
  _fontCollection = sk_make_sp<para::FontCollection>();
128
131
  auto fontMgr = JsiSkFontMgrFactory::getFontMgr(getContext());
129
132
  _fontCollection->setDefaultFontManager(fontMgr);
@@ -5,6 +5,7 @@
5
5
 
6
6
  #include <jsi/jsi.h>
7
7
 
8
+ #include "JsiSkNativeObjects.h"
8
9
  #include "JsiSkParagraphBuilder.h"
9
10
  #include "JsiSkParagraphStyle.h"
10
11
 
@@ -25,8 +26,11 @@ namespace para = skia::textlayout;
25
26
  Implementation of the ParagraphBuilderFactory for making ParagraphBuilder JSI
26
27
  object
27
28
  */
28
- class JsiSkParagraphBuilderFactory : public JsiSkHostObject {
29
+ class JsiSkParagraphBuilderFactory
30
+ : public JsiSkNativeObject<JsiSkParagraphBuilderFactory> {
29
31
  public:
32
+ static constexpr const char *CLASS_NAME = "ParagraphBuilderFactory";
33
+
30
34
  JSI_HOST_FUNCTION(Make) {
31
35
  // Get paragraph style from params
32
36
  auto paragraphStyle =
@@ -39,23 +43,20 @@ public:
39
43
  : nullptr;
40
44
 
41
45
  // Create the paragraph builder
42
- auto builder = std::make_shared<JsiSkParagraphBuilder>(
43
- getContext(), paragraphStyle, fontMgr);
44
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, builder,
45
- getContext());
46
+ return makeJsiObject(runtime, std::make_shared<JsiSkParagraphBuilder>(
47
+ getContext(), paragraphStyle, fontMgr));
46
48
  }
47
49
 
48
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkParagraphBuilderFactory, Make))
49
-
50
- size_t getMemoryPressure() const override { return 1024 * 1024; }
51
-
52
- std::string getObjectType() const override {
53
- return "JsiSkParagraphBuilderFactory";
50
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
51
+ installHostMethod(runtime, prototype, "Make",
52
+ &JsiSkParagraphBuilderFactory::Make);
54
53
  }
55
54
 
55
+ size_t getMemoryPressure() override { return 1024 * 1024; }
56
+
56
57
  explicit JsiSkParagraphBuilderFactory(
57
58
  std::shared_ptr<RNSkPlatformContext> context)
58
- : JsiSkHostObject(std::move(context)) {}
59
+ : JsiSkNativeObject<JsiSkParagraphBuilderFactory>(std::move(context)) {}
59
60
  };
60
61
 
61
62
  } // namespace RNSkia
@@ -42,6 +42,16 @@ public:
42
42
  textHeightBehavior?: SkTextHeightBehavior;
43
43
  textStyle?: SkTextStyle;
44
44
  */
45
+ // A property set to undefined or null is treated as absent, like on web.
46
+ static bool hasValue(jsi::Runtime &runtime, const jsi::Object &object,
47
+ const char *name) {
48
+ if (!object.hasProperty(runtime, name)) {
49
+ return false;
50
+ }
51
+ auto propValue = object.getProperty(runtime, name);
52
+ return !propValue.isUndefined() && !propValue.isNull();
53
+ }
54
+
45
55
  static para::ParagraphStyle fromValue(jsi::Runtime &runtime,
46
56
  const jsi::Value &value) {
47
57
  para::ParagraphStyle retVal;
@@ -59,52 +69,52 @@ public:
59
69
 
60
70
  auto object = value.asObject(runtime);
61
71
 
62
- if (object.hasProperty(runtime, "disableHinting")) {
72
+ if (hasValue(runtime, object, "disableHinting")) {
63
73
  auto propValue = object.getProperty(runtime, "disableHinting");
64
74
  if (asBool(runtime, propValue)) {
65
75
  retVal.turnHintingOff();
66
76
  }
67
77
  }
68
- if (object.hasProperty(runtime, "ellipsis")) {
78
+ if (hasValue(runtime, object, "ellipsis")) {
69
79
  auto propValue = object.getProperty(runtime, "ellipsis");
70
80
  auto inStr = propValue.asString(runtime).utf8(runtime);
71
81
  std::u16string uStr;
72
82
  fromUTF8(inStr, uStr);
73
83
  retVal.setEllipsis(uStr);
74
84
  }
75
- if (object.hasProperty(runtime, "heightMultiplier")) {
85
+ if (hasValue(runtime, object, "heightMultiplier")) {
76
86
  auto propValue = object.getProperty(runtime, "heightMultiplier");
77
87
  retVal.setHeight(propValue.asNumber());
78
88
  }
79
- if (object.hasProperty(runtime, "maxLines")) {
89
+ if (hasValue(runtime, object, "maxLines")) {
80
90
  auto propValue = object.getProperty(runtime, "maxLines");
81
91
  if (propValue.asNumber() != 0) {
82
92
  retVal.setMaxLines(propValue.asNumber());
83
93
  }
84
94
  }
85
- if (object.hasProperty(runtime, "replaceTabCharacters")) {
95
+ if (hasValue(runtime, object, "replaceTabCharacters")) {
86
96
  auto propValue = object.getProperty(runtime, "replaceTabCharacters");
87
97
  retVal.setReplaceTabCharacters(asBool(runtime, propValue));
88
98
  }
89
- if (object.hasProperty(runtime, "textAlign")) {
99
+ if (hasValue(runtime, object, "textAlign")) {
90
100
  auto propValue = object.getProperty(runtime, "textAlign");
91
101
  retVal.setTextAlign(static_cast<para::TextAlign>(propValue.asNumber()));
92
102
  }
93
- if (object.hasProperty(runtime, "textDirection")) {
103
+ if (hasValue(runtime, object, "textDirection")) {
94
104
  auto propValue = object.getProperty(runtime, "textDirection");
95
105
  retVal.setTextDirection(
96
106
  static_cast<para::TextDirection>(propValue.asNumber()));
97
107
  }
98
- if (object.hasProperty(runtime, "textHeightBehavior")) {
108
+ if (hasValue(runtime, object, "textHeightBehavior")) {
99
109
  auto propValue = object.getProperty(runtime, "textHeightBehavior");
100
110
  retVal.setTextHeightBehavior(
101
111
  static_cast<para::TextHeightBehavior>(propValue.asNumber()));
102
112
  }
103
- if (object.hasProperty(runtime, "strutStyle")) {
113
+ if (hasValue(runtime, object, "strutStyle")) {
104
114
  auto propValue = object.getProperty(runtime, "strutStyle");
105
115
  retVal.setStrutStyle(JsiSkStrutStyle::fromValue(runtime, propValue));
106
116
  }
107
- if (object.hasProperty(runtime, "textStyle")) {
117
+ if (hasValue(runtime, object, "textStyle")) {
108
118
  auto propValue = object.getProperty(runtime, "textStyle");
109
119
  retVal.setTextStyle(JsiSkTextStyle::fromValue(runtime, propValue));
110
120
  }
@@ -9,8 +9,8 @@
9
9
 
10
10
  #include <jsi/jsi.h>
11
11
 
12
- #include "JsiSkHostObjects.h"
13
12
  #include "JsiSkMatrix.h"
13
+ #include "JsiSkNativeObjects.h"
14
14
  #include "JsiSkPoint.h"
15
15
  #include "JsiSkRRect.h"
16
16
  #include "JsiSkRect.h"
@@ -61,7 +61,11 @@ inline void warnDeprecatedPathMethod(jsi::Runtime &runtime,
61
61
  RNSkLogger::warnToJavascriptConsole(runtime, message);
62
62
  }
63
63
 
64
- class JsiSkPath : public JsiSkWrappingSharedPtrHostObject<SkPathBuilder> {
64
+ class JsiSkPath
65
+ : public JsiSkWrappingSharedPtrNativeObject<JsiSkPath, SkPathBuilder> {
66
+ public:
67
+ static constexpr const char *CLASS_NAME = "Path";
68
+
65
69
  private:
66
70
  static const int MOVE = 0;
67
71
  static const int LINE = 1;
@@ -529,16 +533,14 @@ public:
529
533
  JSI_HOST_FUNCTION(computeTightBounds) {
530
534
  auto path = asPath();
531
535
  auto result = path.computeTightBounds();
532
- auto hostObjectInstance = std::make_shared<JsiSkRect>(getContext(), result);
533
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
534
- runtime, hostObjectInstance, getContext());
536
+ return makeJsiObject(runtime,
537
+ std::make_shared<JsiSkRect>(getContext(), result));
535
538
  }
536
539
 
537
540
  JSI_HOST_FUNCTION(getBounds) {
538
541
  auto result = getObject()->computeBounds();
539
- auto hostObjectInstance = std::make_shared<JsiSkRect>(getContext(), result);
540
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
541
- runtime, hostObjectInstance, getContext());
542
+ return makeJsiObject(runtime,
543
+ std::make_shared<JsiSkRect>(getContext(), result));
542
544
  }
543
545
 
544
546
  JSI_HOST_FUNCTION(contains) {
@@ -557,9 +559,8 @@ public:
557
559
  JSI_HOST_FUNCTION(getPoint) {
558
560
  auto index = arguments[0].asNumber();
559
561
  auto point = asPath().getPoint(index);
560
- auto hostObjectInstance = std::make_shared<JsiSkPoint>(getContext(), point);
561
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
562
- runtime, hostObjectInstance, getContext());
562
+ return makeJsiObject(runtime,
563
+ std::make_shared<JsiSkPoint>(getContext(), point));
563
564
  }
564
565
 
565
566
  JSI_HOST_FUNCTION(isEmpty) { return jsi::Value(getObject()->isEmpty()); }
@@ -596,9 +597,8 @@ public:
596
597
 
597
598
  JSI_HOST_FUNCTION(copy) {
598
599
  auto path = asPath();
599
- auto hostObjectInstance = std::make_shared<JsiSkPath>(getContext(), path);
600
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
601
- runtime, hostObjectInstance, getContext());
600
+ return makeJsiObject(runtime,
601
+ std::make_shared<JsiSkPath>(getContext(), path));
602
602
  }
603
603
 
604
604
  JSI_HOST_FUNCTION(isInterpolatable) {
@@ -618,10 +618,8 @@ public:
618
618
  if (!succeed) {
619
619
  return jsi::Value::null();
620
620
  }
621
- auto hostObjectInstance =
622
- std::make_shared<JsiSkPath>(getContext(), std::move(result));
623
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
624
- runtime, hostObjectInstance, getContext());
621
+ return makeJsiObject(
622
+ runtime, std::make_shared<JsiSkPath>(getContext(), std::move(result)));
625
623
  }
626
624
 
627
625
  JSI_HOST_FUNCTION(toCmds) {
@@ -703,51 +701,76 @@ public:
703
701
  return cmds;
704
702
  }
705
703
 
706
- EXPORT_JSI_API_TYPENAME(JsiSkPath, Path)
707
-
708
- JSI_EXPORT_FUNCTIONS(
709
- // Mutable building methods
710
- JSI_EXPORT_FUNC(JsiSkPath, moveTo), JSI_EXPORT_FUNC(JsiSkPath, rMoveTo),
711
- JSI_EXPORT_FUNC(JsiSkPath, lineTo), JSI_EXPORT_FUNC(JsiSkPath, rLineTo),
712
- JSI_EXPORT_FUNC(JsiSkPath, quadTo), JSI_EXPORT_FUNC(JsiSkPath, rQuadTo),
713
- JSI_EXPORT_FUNC(JsiSkPath, conicTo), JSI_EXPORT_FUNC(JsiSkPath, rConicTo),
714
- JSI_EXPORT_FUNC(JsiSkPath, cubicTo), JSI_EXPORT_FUNC(JsiSkPath, rCubicTo),
715
- JSI_EXPORT_FUNC(JsiSkPath, close), JSI_EXPORT_FUNC(JsiSkPath, reset),
716
- JSI_EXPORT_FUNC(JsiSkPath, rewind), JSI_EXPORT_FUNC(JsiSkPath, addPath),
717
- JSI_EXPORT_FUNC(JsiSkPath, addArc), JSI_EXPORT_FUNC(JsiSkPath, addOval),
718
- JSI_EXPORT_FUNC(JsiSkPath, addRect), JSI_EXPORT_FUNC(JsiSkPath, addRRect),
719
- JSI_EXPORT_FUNC(JsiSkPath, addCircle),
720
- JSI_EXPORT_FUNC(JsiSkPath, addPoly),
721
- JSI_EXPORT_FUNC(JsiSkPath, arcToOval),
722
- JSI_EXPORT_FUNC(JsiSkPath, arcToRotated),
723
- JSI_EXPORT_FUNC(JsiSkPath, rArcTo),
724
- JSI_EXPORT_FUNC(JsiSkPath, arcToTangent),
725
- JSI_EXPORT_FUNC(JsiSkPath, setFillType),
726
- JSI_EXPORT_FUNC(JsiSkPath, setIsVolatile),
727
- // Mutable transform methods
728
- JSI_EXPORT_FUNC(JsiSkPath, transform), JSI_EXPORT_FUNC(JsiSkPath, offset),
729
- // Mutable path operations
730
- JSI_EXPORT_FUNC(JsiSkPath, simplify), JSI_EXPORT_FUNC(JsiSkPath, op),
731
- JSI_EXPORT_FUNC(JsiSkPath, makeAsWinding),
732
- JSI_EXPORT_FUNC(JsiSkPath, dash), JSI_EXPORT_FUNC(JsiSkPath, stroke),
733
- JSI_EXPORT_FUNC(JsiSkPath, trim),
734
- // Query methods
735
- JSI_EXPORT_FUNC(JsiSkPath, computeTightBounds),
736
- JSI_EXPORT_FUNC(JsiSkPath, getBounds),
737
- JSI_EXPORT_FUNC(JsiSkPath, contains),
738
- JSI_EXPORT_FUNC(JsiSkPath, getFillType),
739
- JSI_EXPORT_FUNC(JsiSkPath, isVolatile),
740
- JSI_EXPORT_FUNC(JsiSkPath, getPoint), JSI_EXPORT_FUNC(JsiSkPath, isEmpty),
741
- JSI_EXPORT_FUNC(JsiSkPath, countPoints),
742
- JSI_EXPORT_FUNC(JsiSkPath, getLastPt),
743
- JSI_EXPORT_FUNC(JsiSkPath, toSVGString),
744
- JSI_EXPORT_FUNC(JsiSkPath, equals), JSI_EXPORT_FUNC(JsiSkPath, copy),
745
- JSI_EXPORT_FUNC(JsiSkPath, isInterpolatable),
746
- JSI_EXPORT_FUNC(JsiSkPath, interpolate),
747
- JSI_EXPORT_FUNC(JsiSkPath, toCmds), JSI_EXPORT_FUNC(JsiSkPath, dispose))
704
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
705
+ installCommon(runtime, prototype);
706
+ // Mutable building methods
707
+ installHostMethod(runtime, prototype, "moveTo", &JsiSkPath::moveTo);
708
+ installHostMethod(runtime, prototype, "rMoveTo", &JsiSkPath::rMoveTo);
709
+ installHostMethod(runtime, prototype, "lineTo", &JsiSkPath::lineTo);
710
+ installHostMethod(runtime, prototype, "rLineTo", &JsiSkPath::rLineTo);
711
+ installHostMethod(runtime, prototype, "quadTo", &JsiSkPath::quadTo);
712
+ installHostMethod(runtime, prototype, "rQuadTo", &JsiSkPath::rQuadTo);
713
+ installHostMethod(runtime, prototype, "conicTo", &JsiSkPath::conicTo);
714
+ installHostMethod(runtime, prototype, "rConicTo", &JsiSkPath::rConicTo);
715
+ installHostMethod(runtime, prototype, "cubicTo", &JsiSkPath::cubicTo);
716
+ installHostMethod(runtime, prototype, "rCubicTo", &JsiSkPath::rCubicTo);
717
+ installHostMethod(runtime, prototype, "close", &JsiSkPath::close);
718
+ installHostMethod(runtime, prototype, "reset", &JsiSkPath::reset);
719
+ installHostMethod(runtime, prototype, "rewind", &JsiSkPath::rewind);
720
+ installHostMethod(runtime, prototype, "addPath", &JsiSkPath::addPath);
721
+ installHostMethod(runtime, prototype, "addArc", &JsiSkPath::addArc);
722
+ installHostMethod(runtime, prototype, "addOval", &JsiSkPath::addOval);
723
+ installHostMethod(runtime, prototype, "addRect", &JsiSkPath::addRect);
724
+ installHostMethod(runtime, prototype, "addRRect", &JsiSkPath::addRRect);
725
+ installHostMethod(runtime, prototype, "addCircle", &JsiSkPath::addCircle);
726
+ installHostMethod(runtime, prototype, "addPoly", &JsiSkPath::addPoly);
727
+ installHostMethod(runtime, prototype, "arcToOval", &JsiSkPath::arcToOval);
728
+ installHostMethod(runtime, prototype, "arcToRotated",
729
+ &JsiSkPath::arcToRotated);
730
+ installHostMethod(runtime, prototype, "rArcTo", &JsiSkPath::rArcTo);
731
+ installHostMethod(runtime, prototype, "arcToTangent",
732
+ &JsiSkPath::arcToTangent);
733
+ installHostMethod(runtime, prototype, "setFillType",
734
+ &JsiSkPath::setFillType);
735
+ installHostMethod(runtime, prototype, "setIsVolatile",
736
+ &JsiSkPath::setIsVolatile);
737
+ // Mutable transform methods
738
+ installHostMethod(runtime, prototype, "transform", &JsiSkPath::transform);
739
+ installHostMethod(runtime, prototype, "offset", &JsiSkPath::offset);
740
+ // Mutable path operations
741
+ installHostMethod(runtime, prototype, "simplify", &JsiSkPath::simplify);
742
+ installHostMethod(runtime, prototype, "op", &JsiSkPath::op);
743
+ installHostMethod(runtime, prototype, "makeAsWinding",
744
+ &JsiSkPath::makeAsWinding);
745
+ installHostMethod(runtime, prototype, "dash", &JsiSkPath::dash);
746
+ installHostMethod(runtime, prototype, "stroke", &JsiSkPath::stroke);
747
+ installHostMethod(runtime, prototype, "trim", &JsiSkPath::trim);
748
+ // Query methods
749
+ installHostMethod(runtime, prototype, "computeTightBounds",
750
+ &JsiSkPath::computeTightBounds);
751
+ installHostMethod(runtime, prototype, "getBounds", &JsiSkPath::getBounds);
752
+ installHostMethod(runtime, prototype, "contains", &JsiSkPath::contains);
753
+ installHostMethod(runtime, prototype, "getFillType",
754
+ &JsiSkPath::getFillType);
755
+ installHostMethod(runtime, prototype, "isVolatile", &JsiSkPath::isVolatile);
756
+ installHostMethod(runtime, prototype, "getPoint", &JsiSkPath::getPoint);
757
+ installHostMethod(runtime, prototype, "isEmpty", &JsiSkPath::isEmpty);
758
+ installHostMethod(runtime, prototype, "countPoints",
759
+ &JsiSkPath::countPoints);
760
+ installHostMethod(runtime, prototype, "getLastPt", &JsiSkPath::getLastPt);
761
+ installHostMethod(runtime, prototype, "toSVGString",
762
+ &JsiSkPath::toSVGString);
763
+ installHostMethod(runtime, prototype, "equals", &JsiSkPath::equals);
764
+ installHostMethod(runtime, prototype, "copy", &JsiSkPath::copy);
765
+ installHostMethod(runtime, prototype, "isInterpolatable",
766
+ &JsiSkPath::isInterpolatable);
767
+ installHostMethod(runtime, prototype, "interpolate",
768
+ &JsiSkPath::interpolate);
769
+ installHostMethod(runtime, prototype, "toCmds", &JsiSkPath::toCmds);
770
+ }
748
771
 
749
772
  JsiSkPath(std::shared_ptr<RNSkPlatformContext> context, SkPathBuilder builder)
750
- : JsiSkWrappingSharedPtrHostObject<SkPathBuilder>(
773
+ : JsiSkWrappingSharedPtrNativeObject<JsiSkPath, SkPathBuilder>(
751
774
  std::move(context),
752
775
  std::make_shared<SkPathBuilder>(std::move(builder))) {}
753
776
 
@@ -755,7 +778,7 @@ public:
755
778
  JsiSkPath(std::shared_ptr<RNSkPlatformContext> context, const SkPath &path)
756
779
  : JsiSkPath(std::move(context), SkPathBuilder(path)) {}
757
780
 
758
- size_t getMemoryPressure() const override {
781
+ size_t getMemoryPressure() override {
759
782
  auto builder = getObject();
760
783
  if (!builder)
761
784
  return 0;
@@ -763,7 +786,13 @@ public:
763
786
  return builder->snapshot().approximateBytesUsed();
764
787
  }
765
788
 
766
- std::string getObjectType() const override { return "JsiSkPath"; }
789
+ /**
790
+ Returns the underlying object from a host object of this type
791
+ */
792
+ static std::shared_ptr<SkPathBuilder> fromValue(jsi::Runtime &runtime,
793
+ const jsi::Value &obj) {
794
+ return objectFromValue(runtime, obj);
795
+ }
767
796
 
768
797
  static SkPath pathFromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
769
798
  return fromValue(runtime, obj)->snapshot();
@@ -772,18 +801,14 @@ public:
772
801
  static jsi::Value toValue(jsi::Runtime &runtime,
773
802
  std::shared_ptr<RNSkPlatformContext> context,
774
803
  const SkPath &path) {
775
- auto hostObjectInstance = std::make_shared<JsiSkPath>(context, path);
776
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
777
- runtime, hostObjectInstance, context);
804
+ return makeJsiObject(runtime, std::make_shared<JsiSkPath>(context, path));
778
805
  }
779
806
 
780
807
  static jsi::Value toValue(jsi::Runtime &runtime,
781
808
  std::shared_ptr<RNSkPlatformContext> context,
782
809
  SkPath &&path) {
783
- auto hostObjectInstance =
784
- std::make_shared<JsiSkPath>(context, std::move(path));
785
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
786
- runtime, hostObjectInstance, context);
810
+ return makeJsiObject(runtime,
811
+ std::make_shared<JsiSkPath>(context, std::move(path)));
787
812
  }
788
813
  };
789
814