@shopify/react-native-skia 2.9.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 (220) hide show
  1. package/android/CMakeLists.txt +1 -5
  2. package/cpp/api/JsiNativeBuffer.h +15 -10
  3. package/cpp/api/JsiSkAnimatedImage.h +21 -19
  4. package/cpp/api/JsiSkAnimatedImageFactory.h +13 -14
  5. package/cpp/api/JsiSkApi.h +246 -92
  6. package/cpp/api/JsiSkCanvas.h +76 -58
  7. package/cpp/api/JsiSkColor.h +7 -5
  8. package/cpp/api/JsiSkColorFilter.h +15 -8
  9. package/cpp/api/JsiSkColorFilterFactory.h +45 -45
  10. package/cpp/api/JsiSkContourMeasure.h +24 -21
  11. package/cpp/api/JsiSkContourMeasureIter.h +18 -21
  12. package/cpp/api/JsiSkData.h +13 -7
  13. package/cpp/api/JsiSkDataFactory.h +22 -21
  14. package/cpp/api/JsiSkFont.h +56 -44
  15. package/cpp/api/JsiSkFontMgr.h +22 -13
  16. package/cpp/api/JsiSkFontMgrFactory.h +12 -10
  17. package/cpp/api/JsiSkFontStyle.h +14 -12
  18. package/cpp/api/JsiSkImage.h +45 -34
  19. package/cpp/api/JsiSkImageFactory.h +47 -52
  20. package/cpp/api/JsiSkImageFilter.h +21 -11
  21. package/cpp/api/JsiSkImageFilterFactory.h +96 -96
  22. package/cpp/api/JsiSkImageInfo.h +22 -19
  23. package/cpp/api/JsiSkMaskFilter.h +21 -11
  24. package/cpp/api/JsiSkMaskFilterFactory.h +16 -13
  25. package/cpp/api/JsiSkMatrix.h +31 -31
  26. package/cpp/api/JsiSkNativeObjects.h +419 -0
  27. package/cpp/api/JsiSkPaint.h +59 -39
  28. package/cpp/api/JsiSkParagraph.h +39 -32
  29. package/cpp/api/JsiSkParagraphBuilder.h +24 -21
  30. package/cpp/api/JsiSkParagraphBuilderFactory.h +13 -12
  31. package/cpp/api/JsiSkPath.h +95 -70
  32. package/cpp/api/JsiSkPathBuilder.h +83 -67
  33. package/cpp/api/JsiSkPathBuilderFactory.h +16 -17
  34. package/cpp/api/JsiSkPathEffect.h +21 -11
  35. package/cpp/api/JsiSkPathEffectFactory.h +33 -32
  36. package/cpp/api/JsiSkPathFactory.h +79 -103
  37. package/cpp/api/JsiSkPicture.h +24 -13
  38. package/cpp/api/JsiSkPictureFactory.h +21 -26
  39. package/cpp/api/JsiSkPictureRecorder.h +21 -22
  40. package/cpp/api/JsiSkPoint.h +19 -22
  41. package/cpp/api/JsiSkRRect.h +22 -29
  42. package/cpp/api/JsiSkRSXform.h +26 -30
  43. package/cpp/api/JsiSkRect.h +28 -30
  44. package/cpp/api/JsiSkRuntimeEffect.h +39 -30
  45. package/cpp/api/JsiSkRuntimeEffectFactory.h +12 -12
  46. package/cpp/api/JsiSkRuntimeShaderBuilder.h +25 -18
  47. package/cpp/api/JsiSkSVG.h +13 -13
  48. package/cpp/api/JsiSkSVGFactory.h +17 -20
  49. package/cpp/api/JsiSkShader.h +15 -8
  50. package/cpp/api/JsiSkShaderFactory.h +41 -48
  51. package/cpp/api/JsiSkSkottie.h +49 -39
  52. package/cpp/api/JsiSkSurface.h +24 -24
  53. package/cpp/api/JsiSkSurfaceFactory.h +15 -16
  54. package/cpp/api/JsiSkTextBlob.h +15 -8
  55. package/cpp/api/JsiSkTextBlobFactory.h +25 -28
  56. package/cpp/api/JsiSkTypeface.h +19 -12
  57. package/cpp/api/JsiSkTypefaceFactory.h +12 -12
  58. package/cpp/api/JsiSkTypefaceFontProvider.h +30 -25
  59. package/cpp/api/JsiSkTypefaceFontProviderFactory.h +14 -12
  60. package/cpp/api/JsiSkVertices.h +21 -18
  61. package/cpp/api/JsiSkiaContext.h +17 -17
  62. package/cpp/api/JsiSkottieFactory.h +16 -17
  63. package/cpp/api/JsiVideo.h +27 -25
  64. package/cpp/api/recorder/Convertor.h +31 -61
  65. package/cpp/api/recorder/DataTypes.h +8 -16
  66. package/cpp/api/recorder/JsiRecorder.h +83 -55
  67. package/cpp/api/recorder/RNRecorder.h +1 -1
  68. package/cpp/jsi/BoxedNativeObject.h +146 -0
  69. package/cpp/{jsi2 → jsi}/EnumMapper.h +4 -1
  70. package/cpp/{jsi2 → jsi}/NativeObject.h +120 -146
  71. package/cpp/jsi/RuntimeAwareCache.cpp +1 -1
  72. package/cpp/jsi/RuntimeAwareCache.h +26 -8
  73. package/cpp/jsi/ViewProperty.h +5 -11
  74. package/cpp/rnskia/RNSkJsiViewApi.h +20 -11
  75. package/cpp/rnskia/RNSkManager.cpp +23 -25
  76. package/cpp/rnskia/RNSkPictureView.h +1 -1
  77. package/cpp/rnwgpu/ArrayBuffer.h +5 -6
  78. package/cpp/rnwgpu/Canvas.h +4 -2
  79. package/cpp/rnwgpu/api/GPU.cpp +4 -4
  80. package/cpp/rnwgpu/api/GPU.h +1 -1
  81. package/cpp/rnwgpu/api/GPUAdapter.cpp +2 -3
  82. package/cpp/rnwgpu/api/GPUAdapter.h +4 -4
  83. package/cpp/rnwgpu/api/GPUAdapterInfo.h +1 -1
  84. package/cpp/rnwgpu/api/GPUBindGroup.h +1 -1
  85. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +1 -1
  86. package/cpp/rnwgpu/api/GPUBuffer.h +1 -1
  87. package/cpp/rnwgpu/api/GPUCanvasContext.h +1 -1
  88. package/cpp/rnwgpu/api/GPUCommandBuffer.h +1 -1
  89. package/cpp/rnwgpu/api/GPUCommandEncoder.h +1 -1
  90. package/cpp/rnwgpu/api/GPUCompilationInfo.h +1 -1
  91. package/cpp/rnwgpu/api/GPUCompilationMessage.h +1 -1
  92. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +1 -1
  93. package/cpp/rnwgpu/api/GPUComputePipeline.h +1 -1
  94. package/cpp/rnwgpu/api/GPUDevice.cpp +6 -7
  95. package/cpp/rnwgpu/api/GPUDevice.h +3 -3
  96. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +1 -1
  97. package/cpp/rnwgpu/api/GPUError.h +1 -1
  98. package/cpp/rnwgpu/api/GPUExtent3D.h +1 -1
  99. package/cpp/rnwgpu/api/GPUExternalTexture.h +1 -1
  100. package/cpp/rnwgpu/api/GPUInternalError.h +1 -1
  101. package/cpp/rnwgpu/api/GPUOrigin2D.h +1 -1
  102. package/cpp/rnwgpu/api/GPUOrigin3D.h +1 -1
  103. package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +1 -1
  104. package/cpp/rnwgpu/api/GPUPipelineLayout.h +1 -1
  105. package/cpp/rnwgpu/api/GPUQuerySet.h +1 -1
  106. package/cpp/rnwgpu/api/GPUQueue.h +1 -1
  107. package/cpp/rnwgpu/api/GPURenderBundle.h +1 -1
  108. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +1 -1
  109. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +1 -1
  110. package/cpp/rnwgpu/api/GPURenderPipeline.h +1 -1
  111. package/cpp/rnwgpu/api/GPUSampler.h +1 -1
  112. package/cpp/rnwgpu/api/GPUShaderModule.cpp +1 -1
  113. package/cpp/rnwgpu/api/GPUShaderModule.h +1 -1
  114. package/cpp/rnwgpu/api/GPUSharedFence.h +1 -1
  115. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +1 -1
  116. package/cpp/rnwgpu/api/GPUSupportedLimits.h +1 -1
  117. package/cpp/rnwgpu/api/GPUTexture.h +1 -1
  118. package/cpp/rnwgpu/api/GPUTextureView.h +1 -1
  119. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +1 -1
  120. package/cpp/rnwgpu/api/GPUValidationError.h +1 -1
  121. package/cpp/rnwgpu/api/ImageBitmap.h +1 -1
  122. package/cpp/rnwgpu/api/RNWebGPU.h +1 -1
  123. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +1 -1
  124. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +1 -1
  125. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +1 -1
  126. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +1 -1
  127. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +1 -1
  128. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +1 -1
  129. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +1 -1
  130. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +1 -1
  131. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +1 -1
  132. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +1 -1
  133. package/cpp/rnwgpu/api/descriptors/GPUColor.h +1 -1
  134. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +1 -1
  135. package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +1 -1
  136. package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +1 -1
  137. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +1 -1
  138. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +1 -1
  139. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +1 -1
  140. package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +1 -1
  141. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +1 -1
  142. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +1 -1
  143. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +1 -1
  144. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +1 -1
  145. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +1 -1
  146. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +1 -1
  147. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +1 -1
  148. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +1 -1
  149. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +1 -1
  150. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +1 -1
  151. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +1 -1
  152. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +1 -1
  153. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +1 -1
  154. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +1 -1
  155. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +1 -1
  156. package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +1 -1
  157. package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +1 -1
  158. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +1 -1
  159. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +1 -1
  160. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +1 -1
  161. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +1 -1
  162. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +1 -1
  163. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +1 -1
  164. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +1 -1
  165. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +1 -1
  166. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +1 -1
  167. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +1 -1
  168. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +1 -1
  169. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +1 -1
  170. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +1 -1
  171. package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +1 -1
  172. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +1 -1
  173. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +1 -1
  174. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +1 -1
  175. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +1 -1
  176. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +1 -1
  177. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +1 -1
  178. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +1 -1
  179. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +1 -1
  180. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +1 -1
  181. package/cpp/rnwgpu/api/descriptors/Unions.h +1 -1
  182. package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +20 -21
  183. package/lib/commonjs/external/reanimated/renderHelpers.d.ts +15 -0
  184. package/lib/commonjs/external/reanimated/renderHelpers.js +30 -1
  185. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
  186. package/lib/commonjs/skia/NativeSetup.js +4 -0
  187. package/lib/commonjs/skia/NativeSetup.js.map +1 -1
  188. package/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +1 -0
  189. package/lib/commonjs/skia/SkiaWorkletSerialization.js +66 -0
  190. package/lib/commonjs/skia/SkiaWorkletSerialization.js.map +1 -0
  191. package/lib/commonjs/sksg/Container.native.js +20 -1
  192. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  193. package/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
  194. package/lib/module/external/reanimated/renderHelpers.js +29 -0
  195. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  196. package/lib/module/skia/NativeSetup.js +4 -0
  197. package/lib/module/skia/NativeSetup.js.map +1 -1
  198. package/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
  199. package/lib/module/skia/SkiaWorkletSerialization.js +59 -0
  200. package/lib/module/skia/SkiaWorkletSerialization.js.map +1 -0
  201. package/lib/module/sksg/Container.native.js +21 -2
  202. package/lib/module/sksg/Container.native.js.map +1 -1
  203. package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +2 -0
  204. package/lib/typescript/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +2 -0
  205. package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
  206. package/lib/typescript/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
  207. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +15 -0
  208. package/lib/typescript/src/skia/SkiaWorkletSerialization.d.ts +1 -0
  209. package/package.json +6 -2
  210. package/react-native-skia.podspec +1 -2
  211. package/src/external/reanimated/renderHelpers.ts +30 -0
  212. package/src/skia/NativeSetup.ts +5 -0
  213. package/src/skia/SkiaWorkletSerialization.ts +67 -0
  214. package/src/sksg/Container.native.ts +40 -2
  215. package/cpp/api/JsiSkHostObjects.h +0 -257
  216. package/cpp/jsi/JsiHostObject.cpp +0 -137
  217. package/cpp/jsi/JsiHostObject.h +0 -385
  218. /package/cpp/{jsi2 → jsi}/JSIConverter.h +0 -0
  219. /package/cpp/{jsi2 → jsi}/Promise.cpp +0 -0
  220. /package/cpp/{jsi2 → jsi}/Promise.h +0 -0
@@ -5,7 +5,7 @@
5
5
  #include <utility>
6
6
  #include <vector>
7
7
 
8
- #include "JsiSkHostObjects.h"
8
+ #include "JsiSkNativeObjects.h"
9
9
  #include "utils/RNSkLog.h"
10
10
  #include <jsi/jsi.h>
11
11
 
@@ -28,19 +28,18 @@ namespace RNSkia {
28
28
 
29
29
  namespace jsi = facebook::jsi;
30
30
 
31
- class JsiSkiaContext : public JsiSkWrappingSharedPtrHostObject<WindowContext> {
31
+ class JsiSkiaContext
32
+ : public JsiSkWrappingSharedPtrNativeObject<JsiSkiaContext, WindowContext> {
32
33
  public:
33
- EXPORT_JSI_API_TYPENAME(JsiSkiaContext, SkiaContext)
34
+ static constexpr const char *CLASS_NAME = "SkiaContext";
34
35
 
35
36
  JSI_HOST_FUNCTION(getSurface) {
36
37
  auto surface = getObject()->getSurface();
37
38
  if (surface == nullptr) {
38
39
  return jsi::Value::null();
39
40
  }
40
- auto hostObjectInstance =
41
- std::make_shared<JsiSkSurface>(getContext(), std::move(surface));
42
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
43
- runtime, hostObjectInstance, getContext());
41
+ return makeJsiObject(runtime, std::make_shared<JsiSkSurface>(
42
+ getContext(), std::move(surface)));
44
43
  }
45
44
 
46
45
  JSI_HOST_FUNCTION(present) {
@@ -48,16 +47,19 @@ public:
48
47
  return jsi::Value::undefined();
49
48
  }
50
49
 
51
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkiaContext, getSurface),
52
- JSI_EXPORT_FUNC(JsiSkiaContext, present))
50
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
51
+ installCommon(runtime, prototype);
52
+ installHostMethod(runtime, prototype, "getSurface",
53
+ &JsiSkiaContext::getSurface);
54
+ installHostMethod(runtime, prototype, "present", &JsiSkiaContext::present);
55
+ }
53
56
 
54
57
  JsiSkiaContext(std::shared_ptr<RNSkPlatformContext> context,
55
58
  std::shared_ptr<WindowContext> ctx)
56
- : JsiSkWrappingSharedPtrHostObject(std::move(context), std::move(ctx)) {}
57
-
58
- size_t getMemoryPressure() const override { return 10 * 1024 * 1024; }
59
+ : JsiSkWrappingSharedPtrNativeObject<JsiSkiaContext, WindowContext>(
60
+ std::move(context), std::move(ctx)) {}
59
61
 
60
- std::string getObjectType() const override { return "JsiSkiaContext"; }
62
+ size_t getMemoryPressure() override { return 10 * 1024 * 1024; }
61
63
 
62
64
  /**
63
65
  * Creates the function for construction a new instance of the SkFont
@@ -84,10 +86,8 @@ public:
84
86
  "Couldn't create a Skia context from the native surface");
85
87
  }
86
88
  // Return the newly constructed object
87
- auto hostObjectInstance =
88
- std::make_shared<JsiSkiaContext>(context, std::move(result));
89
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
90
- runtime, hostObjectInstance, context);
89
+ return makeJsiObject(runtime, std::make_shared<JsiSkiaContext>(
90
+ context, std::move(result)));
91
91
  };
92
92
  }
93
93
  };
@@ -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
@@ -5,7 +5,7 @@
5
5
  #include <utility>
6
6
  #include <vector>
7
7
 
8
- #include "JsiSkHostObjects.h"
8
+ #include "JsiSkNativeObjects.h"
9
9
  #include "utils/RNSkLog.h"
10
10
  #include <jsi/jsi.h>
11
11
 
@@ -28,9 +28,10 @@ namespace RNSkia {
28
28
 
29
29
  namespace jsi = facebook::jsi;
30
30
 
31
- class JsiVideo : public JsiSkWrappingSharedPtrHostObject<RNSkVideo> {
31
+ class JsiVideo
32
+ : public JsiSkWrappingSharedPtrNativeObject<JsiVideo, RNSkVideo> {
32
33
  public:
33
- EXPORT_JSI_API_TYPENAME(JsiVideo, Video)
34
+ static constexpr const char *CLASS_NAME = "Video";
34
35
 
35
36
  JSI_HOST_FUNCTION(nextImage) {
36
37
  double timestamp = 0;
@@ -39,10 +40,8 @@ public:
39
40
  if (!image) {
40
41
  return jsi::Value::null();
41
42
  }
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());
43
+ return makeJsiObject(
44
+ runtime, std::make_shared<JsiSkImage>(getContext(), std::move(image)));
46
45
  }
47
46
 
48
47
  JSI_HOST_FUNCTION(duration) { return getObject()->duration(); }
@@ -96,24 +95,29 @@ public:
96
95
  return jsi::Value::undefined();
97
96
  }
98
97
 
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))
98
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
99
+ installCommon(runtime, prototype);
100
+ installHostMethod(runtime, prototype, "nextImage", &JsiVideo::nextImage);
101
+ installHostMethod(runtime, prototype, "duration", &JsiVideo::duration);
102
+ installHostMethod(runtime, prototype, "framerate", &JsiVideo::framerate);
103
+ installHostMethod(runtime, prototype, "currentTime",
104
+ &JsiVideo::currentTime);
105
+ installHostMethod(runtime, prototype, "isPlaying", &JsiVideo::isPlaying);
106
+ installHostMethod(runtime, prototype, "seek", &JsiVideo::seek);
107
+ installHostMethod(runtime, prototype, "rotation", &JsiVideo::rotation);
108
+ installHostMethod(runtime, prototype, "size", &JsiVideo::size);
109
+ installHostMethod(runtime, prototype, "play", &JsiVideo::play);
110
+ installHostMethod(runtime, prototype, "pause", &JsiVideo::pause);
111
+ installHostMethod(runtime, prototype, "setVolume", &JsiVideo::setVolume);
112
+ installHostMethod(runtime, prototype, "setLooping", &JsiVideo::setLooping);
113
+ }
108
114
 
109
115
  JsiVideo(std::shared_ptr<RNSkPlatformContext> context,
110
116
  std::shared_ptr<RNSkVideo> video)
111
- : JsiSkWrappingSharedPtrHostObject(std::move(context), std::move(video)) {
112
- }
113
-
114
- size_t getMemoryPressure() const override { return 32768; }
117
+ : JsiSkWrappingSharedPtrNativeObject<JsiVideo, RNSkVideo>(
118
+ std::move(context), std::move(video)) {}
115
119
 
116
- std::string getObjectType() const override { return "JsiVideo"; }
120
+ size_t getMemoryPressure() override { return 32768; }
117
121
 
118
122
  /**
119
123
  * Creates the function for construction a new instance of the SkFont
@@ -128,10 +132,8 @@ public:
128
132
  auto url = arguments[0].asString(runtime).utf8(runtime);
129
133
  auto video = context->createVideo(url);
130
134
  // 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);
135
+ return makeJsiObject(runtime, std::make_shared<JsiVideo>(
136
+ std::move(context), std::move(video)));
135
137
  };
136
138
  }
137
139
  };
@@ -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