@shopify/react-native-skia 2.9.1 → 2.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (387) hide show
  1. package/android/CMakeLists.txt +8 -46
  2. package/android/build.gradle +33 -0
  3. package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaPackage.java +1 -2
  4. package/cpp/api/JsiNativeBuffer.h +23 -24
  5. package/cpp/api/JsiSkAnimatedImage.h +24 -25
  6. package/cpp/api/JsiSkAnimatedImageFactory.h +18 -17
  7. package/cpp/api/JsiSkApi.h +254 -96
  8. package/cpp/api/JsiSkCanvas.h +141 -266
  9. package/cpp/api/JsiSkColor.h +7 -5
  10. package/cpp/api/JsiSkColorFilter.h +15 -8
  11. package/cpp/api/JsiSkColorFilterFactory.h +49 -67
  12. package/cpp/api/JsiSkContourMeasure.h +31 -38
  13. package/cpp/api/JsiSkContourMeasureIter.h +20 -23
  14. package/cpp/api/JsiSkConverters.h +410 -0
  15. package/cpp/api/JsiSkData.h +13 -7
  16. package/cpp/api/JsiSkDataFactory.h +27 -32
  17. package/cpp/api/JsiSkFont.h +123 -192
  18. package/cpp/api/JsiSkFontMgr.h +33 -26
  19. package/cpp/api/JsiSkFontMgrFactory.h +12 -11
  20. package/cpp/api/JsiSkFontStyle.h +14 -12
  21. package/cpp/api/JsiSkImage.h +90 -79
  22. package/cpp/api/JsiSkImageFactory.h +93 -95
  23. package/cpp/api/JsiSkImageFilter.h +21 -11
  24. package/cpp/api/JsiSkImageFilterFactory.h +375 -629
  25. package/cpp/api/JsiSkImageInfo.h +25 -25
  26. package/cpp/api/JsiSkMaskFilter.h +21 -11
  27. package/cpp/api/JsiSkMaskFilterFactory.h +17 -17
  28. package/cpp/api/JsiSkMatrix.h +51 -88
  29. package/cpp/api/JsiSkNativeObjects.h +387 -0
  30. package/cpp/api/JsiSkPaint.h +104 -142
  31. package/cpp/api/JsiSkParagraph.h +54 -64
  32. package/cpp/api/JsiSkParagraphBuilder.h +43 -68
  33. package/cpp/api/JsiSkParagraphBuilderFactory.h +20 -24
  34. package/cpp/api/JsiSkPath.h +242 -350
  35. package/cpp/api/JsiSkPathBuilder.h +153 -273
  36. package/cpp/api/JsiSkPathBuilderFactory.h +19 -20
  37. package/cpp/api/JsiSkPathEffect.h +21 -11
  38. package/cpp/api/JsiSkPathEffectFactory.h +61 -80
  39. package/cpp/api/JsiSkPathFactory.h +148 -238
  40. package/cpp/api/JsiSkPicture.h +32 -27
  41. package/cpp/api/JsiSkPictureFactory.h +21 -26
  42. package/cpp/api/JsiSkPictureRecorder.h +27 -29
  43. package/cpp/api/JsiSkPoint.h +20 -23
  44. package/cpp/api/JsiSkRRect.h +24 -32
  45. package/cpp/api/JsiSkRSXform.h +31 -48
  46. package/cpp/api/JsiSkRect.h +40 -50
  47. package/cpp/api/JsiSkRuntimeEffect.h +85 -92
  48. package/cpp/api/JsiSkRuntimeEffectFactory.h +14 -18
  49. package/cpp/api/JsiSkRuntimeShaderBuilder.h +28 -30
  50. package/cpp/api/JsiSkSVG.h +15 -15
  51. package/cpp/api/JsiSkSVGFactory.h +17 -20
  52. package/cpp/api/JsiSkShader.h +15 -8
  53. package/cpp/api/JsiSkShaderFactory.h +159 -238
  54. package/cpp/api/JsiSkSkottie.h +131 -143
  55. package/cpp/api/JsiSkSurface.h +29 -32
  56. package/cpp/api/JsiSkSurfaceFactory.h +18 -20
  57. package/cpp/api/JsiSkTextBlob.h +15 -8
  58. package/cpp/api/JsiSkTextBlobFactory.h +40 -66
  59. package/cpp/api/JsiSkTypeface.h +25 -22
  60. package/cpp/api/JsiSkTypefaceFactory.h +17 -15
  61. package/cpp/api/JsiSkTypefaceFontProvider.h +43 -39
  62. package/cpp/api/JsiSkTypefaceFontProviderFactory.h +13 -12
  63. package/cpp/api/JsiSkVertices.h +23 -22
  64. package/cpp/api/JsiSkiaContext.h +22 -23
  65. package/cpp/api/JsiSkottieFactory.h +16 -17
  66. package/cpp/api/JsiVideo.h +43 -81
  67. package/cpp/api/recorder/Convertor.h +31 -61
  68. package/cpp/api/recorder/DataTypes.h +8 -16
  69. package/cpp/api/recorder/JsiRecorder.h +83 -55
  70. package/cpp/api/recorder/RNRecorder.h +1 -1
  71. package/cpp/jsi/BoxedNativeObject.h +146 -0
  72. package/cpp/{jsi2 → jsi}/EnumMapper.h +4 -1
  73. package/cpp/{jsi2 → jsi}/JSIConverter.h +0 -31
  74. package/cpp/{jsi2 → jsi}/NativeObject.h +131 -152
  75. package/cpp/jsi/RuntimeAwareCache.cpp +1 -1
  76. package/cpp/jsi/RuntimeAwareCache.h +26 -8
  77. package/cpp/jsi/ViewProperty.h +5 -11
  78. package/cpp/rnskia/RNDawnContext.h +18 -2
  79. package/cpp/rnskia/RNDawnInterop.cpp +19 -0
  80. package/cpp/rnskia/RNDawnUtils.h +18 -1
  81. package/cpp/rnskia/RNSkJsiViewApi.h +20 -11
  82. package/cpp/rnskia/RNSkManager.cpp +9 -168
  83. package/cpp/rnskia/RNSkPictureView.h +1 -1
  84. package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkaroundsAutogen.h +2 -0
  85. package/lib/commonjs/external/reanimated/renderHelpers.d.ts +15 -0
  86. package/lib/commonjs/external/reanimated/renderHelpers.js +30 -1
  87. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
  88. package/lib/commonjs/mock/index.js +0 -1
  89. package/lib/commonjs/mock/index.js.map +1 -1
  90. package/lib/commonjs/skia/NativeSetup.js +4 -0
  91. package/lib/commonjs/skia/NativeSetup.js.map +1 -1
  92. package/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +1 -0
  93. package/lib/commonjs/skia/SkiaWorkletSerialization.js +66 -0
  94. package/lib/commonjs/skia/SkiaWorkletSerialization.js.map +1 -0
  95. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +15 -6
  96. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  97. package/lib/commonjs/skia/types/Skia.d.ts +5 -15
  98. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  99. package/lib/commonjs/skia/types/index.d.ts +0 -1
  100. package/lib/commonjs/skia/types/index.js +0 -11
  101. package/lib/commonjs/skia/types/index.js.map +1 -1
  102. package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
  103. package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
  104. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  105. package/lib/commonjs/skia/web/JsiSkia.js +1 -4
  106. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  107. package/lib/commonjs/sksg/Container.native.js +20 -1
  108. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  109. package/lib/commonjs/views/index.d.ts +0 -1
  110. package/lib/commonjs/views/index.js +0 -11
  111. package/lib/commonjs/views/index.js.map +1 -1
  112. package/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
  113. package/lib/module/external/reanimated/renderHelpers.js +29 -0
  114. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  115. package/lib/module/mock/index.js +0 -1
  116. package/lib/module/mock/index.js.map +1 -1
  117. package/lib/module/skia/NativeSetup.js +4 -0
  118. package/lib/module/skia/NativeSetup.js.map +1 -1
  119. package/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
  120. package/lib/module/skia/SkiaWorkletSerialization.js +59 -0
  121. package/lib/module/skia/SkiaWorkletSerialization.js.map +1 -0
  122. package/lib/module/skia/types/Image/ImageFactory.d.ts +15 -6
  123. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  124. package/lib/module/skia/types/Skia.d.ts +5 -15
  125. package/lib/module/skia/types/Skia.js.map +1 -1
  126. package/lib/module/skia/types/index.d.ts +0 -1
  127. package/lib/module/skia/types/index.js +0 -1
  128. package/lib/module/skia/types/index.js.map +1 -1
  129. package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
  130. package/lib/module/skia/web/JsiSkImageFactory.js +2 -2
  131. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  132. package/lib/module/skia/web/JsiSkia.js +1 -4
  133. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  134. package/lib/module/sksg/Container.native.js +21 -2
  135. package/lib/module/sksg/Container.native.js.map +1 -1
  136. package/lib/module/views/index.d.ts +0 -1
  137. package/lib/module/views/index.js +0 -1
  138. package/lib/module/views/index.js.map +1 -1
  139. package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +2 -0
  140. package/lib/typescript/lib/commonjs/mock/index.d.ts +0 -1
  141. package/lib/typescript/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +2 -0
  142. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
  143. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +1 -2
  144. package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
  145. package/lib/typescript/lib/module/mock/index.d.ts +0 -2
  146. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -2
  147. package/lib/typescript/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
  148. package/lib/typescript/lib/module/skia/types/index.d.ts +0 -1
  149. package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
  150. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +1 -2
  151. package/lib/typescript/lib/module/views/index.d.ts +0 -1
  152. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +15 -0
  153. package/lib/typescript/src/skia/SkiaWorkletSerialization.d.ts +1 -0
  154. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +15 -6
  155. package/lib/typescript/src/skia/types/Skia.d.ts +5 -15
  156. package/lib/typescript/src/skia/types/index.d.ts +0 -1
  157. package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -2
  158. package/lib/typescript/src/views/index.d.ts +0 -1
  159. package/package.json +8 -5
  160. package/react-native-skia.podspec +38 -5
  161. package/src/external/reanimated/renderHelpers.ts +30 -0
  162. package/src/mock/index.ts +0 -1
  163. package/src/skia/NativeSetup.ts +5 -0
  164. package/src/skia/SkiaWorkletSerialization.ts +67 -0
  165. package/src/skia/types/Image/ImageFactory.ts +15 -6
  166. package/src/skia/types/Skia.ts +5 -15
  167. package/src/skia/types/index.ts +0 -1
  168. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  169. package/src/skia/web/JsiSkia.ts +2 -5
  170. package/src/sksg/Container.native.ts +40 -2
  171. package/src/views/index.ts +0 -1
  172. package/android/cpp/jni/JniWebGPUView.cpp +0 -112
  173. package/android/cpp/rnskia-android/SkiaPlatformContext.h +0 -26
  174. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUSurfaceView.java +0 -43
  175. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUTextureView.java +0 -50
  176. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUView.java +0 -98
  177. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewAPI.java +0 -19
  178. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewManager.java +0 -58
  179. package/apple/RNWebGPUAppleNativeBuffer.mm +0 -33
  180. package/apple/SkiaPlatformContext.h +0 -20
  181. package/apple/SkiaPlatformContext.mm +0 -21
  182. package/apple/SkiaWebGPUView.mm +0 -81
  183. package/apple/WebGPUMetalView.mm +0 -136
  184. package/cpp/api/JsiSkHostObjects.h +0 -257
  185. package/cpp/jsi/JsiHostObject.cpp +0 -137
  186. package/cpp/jsi/JsiHostObject.h +0 -385
  187. package/cpp/rnwgpu/ArrayBuffer.h +0 -117
  188. package/cpp/rnwgpu/Canvas.h +0 -50
  189. package/cpp/rnwgpu/PlatformContext.h +0 -18
  190. package/cpp/rnwgpu/SurfaceRegistry.h +0 -605
  191. package/cpp/rnwgpu/api/AppleNativeBuffer.h +0 -22
  192. package/cpp/rnwgpu/api/Convertors.h +0 -783
  193. package/cpp/rnwgpu/api/External.h +0 -12
  194. package/cpp/rnwgpu/api/GPU.cpp +0 -162
  195. package/cpp/rnwgpu/api/GPU.h +0 -60
  196. package/cpp/rnwgpu/api/GPUAdapter.cpp +0 -240
  197. package/cpp/rnwgpu/api/GPUAdapter.h +0 -60
  198. package/cpp/rnwgpu/api/GPUAdapterInfo.h +0 -57
  199. package/cpp/rnwgpu/api/GPUBindGroup.cpp +0 -3
  200. package/cpp/rnwgpu/api/GPUBindGroup.h +0 -51
  201. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +0 -52
  202. package/cpp/rnwgpu/api/GPUBuffer.cpp +0 -107
  203. package/cpp/rnwgpu/api/GPUBuffer.h +0 -88
  204. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +0 -75
  205. package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -70
  206. package/cpp/rnwgpu/api/GPUCommandBuffer.h +0 -45
  207. package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +0 -179
  208. package/cpp/rnwgpu/api/GPUCommandEncoder.h +0 -111
  209. package/cpp/rnwgpu/api/GPUCompilationInfo.h +0 -79
  210. package/cpp/rnwgpu/api/GPUCompilationMessage.h +0 -36
  211. package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +0 -60
  212. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +0 -85
  213. package/cpp/rnwgpu/api/GPUComputePipeline.cpp +0 -12
  214. package/cpp/rnwgpu/api/GPUComputePipeline.h +0 -60
  215. package/cpp/rnwgpu/api/GPUDevice.cpp +0 -614
  216. package/cpp/rnwgpu/api/GPUDevice.h +0 -258
  217. package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +0 -7
  218. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +0 -40
  219. package/cpp/rnwgpu/api/GPUError.h +0 -35
  220. package/cpp/rnwgpu/api/GPUExtent3D.h +0 -66
  221. package/cpp/rnwgpu/api/GPUExternalTexture.cpp +0 -139
  222. package/cpp/rnwgpu/api/GPUExternalTexture.h +0 -95
  223. package/cpp/rnwgpu/api/GPUFeatures.h +0 -203
  224. package/cpp/rnwgpu/api/GPUInternalError.h +0 -31
  225. package/cpp/rnwgpu/api/GPUOrigin2D.h +0 -55
  226. package/cpp/rnwgpu/api/GPUOrigin3D.h +0 -62
  227. package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +0 -33
  228. package/cpp/rnwgpu/api/GPUPipelineLayout.h +0 -45
  229. package/cpp/rnwgpu/api/GPUQuerySet.cpp +0 -11
  230. package/cpp/rnwgpu/api/GPUQuerySet.h +0 -73
  231. package/cpp/rnwgpu/api/GPUQueue.cpp +0 -179
  232. package/cpp/rnwgpu/api/GPUQueue.h +0 -84
  233. package/cpp/rnwgpu/api/GPURenderBundle.h +0 -44
  234. package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +0 -131
  235. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +0 -110
  236. package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +0 -165
  237. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +0 -130
  238. package/cpp/rnwgpu/api/GPURenderPipeline.cpp +0 -13
  239. package/cpp/rnwgpu/api/GPURenderPipeline.h +0 -61
  240. package/cpp/rnwgpu/api/GPUSampler.h +0 -44
  241. package/cpp/rnwgpu/api/GPUShaderModule.cpp +0 -56
  242. package/cpp/rnwgpu/api/GPUShaderModule.h +0 -66
  243. package/cpp/rnwgpu/api/GPUSharedFence.cpp +0 -80
  244. package/cpp/rnwgpu/api/GPUSharedFence.h +0 -53
  245. package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +0 -135
  246. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +0 -75
  247. package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +0 -129
  248. package/cpp/rnwgpu/api/GPUSupportedLimits.h +0 -131
  249. package/cpp/rnwgpu/api/GPUTexture.cpp +0 -47
  250. package/cpp/rnwgpu/api/GPUTexture.h +0 -162
  251. package/cpp/rnwgpu/api/GPUTextureView.h +0 -44
  252. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +0 -60
  253. package/cpp/rnwgpu/api/GPUValidationError.h +0 -32
  254. package/cpp/rnwgpu/api/ImageBitmap.h +0 -62
  255. package/cpp/rnwgpu/api/NativeBufferUtils.h +0 -87
  256. package/cpp/rnwgpu/api/RNWebGPU.h +0 -82
  257. package/cpp/rnwgpu/api/WebGPUConstants.h +0 -36
  258. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +0 -64
  259. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +0 -78
  260. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +0 -56
  261. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +0 -97
  262. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +0 -57
  263. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +0 -52
  264. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +0 -56
  265. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +0 -56
  266. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +0 -59
  267. package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +0 -39
  268. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +0 -76
  269. package/cpp/rnwgpu/api/descriptors/GPUColor.h +0 -66
  270. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +0 -58
  271. package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +0 -29
  272. package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +0 -45
  273. package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +0 -45
  274. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +0 -56
  275. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +0 -58
  276. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +0 -67
  277. package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +0 -56
  278. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +0 -103
  279. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +0 -109
  280. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +0 -38
  281. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +0 -90
  282. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +0 -73
  283. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +0 -62
  284. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +0 -63
  285. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +0 -65
  286. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +0 -81
  287. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +0 -54
  288. package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +0 -22
  289. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +0 -54
  290. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +0 -57
  291. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +0 -69
  292. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +0 -61
  293. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +0 -55
  294. package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +0 -43
  295. package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +0 -45
  296. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +0 -80
  297. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +0 -81
  298. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +0 -101
  299. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +0 -92
  300. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +0 -58
  301. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +0 -103
  302. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +0 -51
  303. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +0 -45
  304. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +0 -110
  305. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +0 -60
  306. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +0 -62
  307. package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +0 -25
  308. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +0 -58
  309. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +0 -51
  310. package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +0 -73
  311. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +0 -64
  312. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +0 -59
  313. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +0 -59
  314. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +0 -91
  315. package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +0 -29
  316. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +0 -91
  317. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +0 -64
  318. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +0 -53
  319. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +0 -62
  320. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +0 -73
  321. package/cpp/rnwgpu/api/descriptors/Unions.h +0 -1969
  322. package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +0 -214
  323. package/cpp/rnwgpu/async/AsyncTaskHandle.h +0 -58
  324. package/cpp/rnwgpu/async/RuntimeContext.cpp +0 -199
  325. package/cpp/rnwgpu/async/RuntimeContext.h +0 -134
  326. package/lib/commonjs/skia/types/WebGPU.d.ts +0 -184
  327. package/lib/commonjs/skia/types/WebGPU.js +0 -105
  328. package/lib/commonjs/skia/types/WebGPU.js.map +0 -1
  329. package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -8
  330. package/lib/commonjs/specs/WebGPUViewNativeComponent.js +0 -10
  331. package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +0 -1
  332. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  333. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +0 -103
  334. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +0 -1
  335. package/lib/commonjs/specs/utils.d.ts +0 -1
  336. package/lib/commonjs/specs/utils.js +0 -11
  337. package/lib/commonjs/specs/utils.js.map +0 -1
  338. package/lib/commonjs/views/WebGPUCanvas.d.ts +0 -33
  339. package/lib/commonjs/views/WebGPUCanvas.js +0 -79
  340. package/lib/commonjs/views/WebGPUCanvas.js.map +0 -1
  341. package/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -23
  342. package/lib/commonjs/views/WebGPUCanvas.web.js +0 -20
  343. package/lib/commonjs/views/WebGPUCanvas.web.js.map +0 -1
  344. package/lib/module/skia/types/WebGPU.d.ts +0 -184
  345. package/lib/module/skia/types/WebGPU.js +0 -99
  346. package/lib/module/skia/types/WebGPU.js.map +0 -1
  347. package/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -8
  348. package/lib/module/specs/WebGPUViewNativeComponent.js +0 -4
  349. package/lib/module/specs/WebGPUViewNativeComponent.js.map +0 -1
  350. package/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  351. package/lib/module/specs/WebGPUViewNativeComponent.web.js +0 -96
  352. package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +0 -1
  353. package/lib/module/specs/utils.d.ts +0 -1
  354. package/lib/module/specs/utils.js +0 -5
  355. package/lib/module/specs/utils.js.map +0 -1
  356. package/lib/module/views/WebGPUCanvas.d.ts +0 -33
  357. package/lib/module/views/WebGPUCanvas.js +0 -70
  358. package/lib/module/views/WebGPUCanvas.js.map +0 -1
  359. package/lib/module/views/WebGPUCanvas.web.d.ts +0 -23
  360. package/lib/module/views/WebGPUCanvas.web.js +0 -12
  361. package/lib/module/views/WebGPUCanvas.web.js.map +0 -1
  362. package/lib/typescript/lib/commonjs/skia/types/WebGPU.d.ts +0 -2
  363. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -4
  364. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -3
  365. package/lib/typescript/lib/commonjs/specs/utils.d.ts +0 -2
  366. package/lib/typescript/lib/commonjs/views/WebGPUCanvas.d.ts +0 -6
  367. package/lib/typescript/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -6
  368. package/lib/typescript/lib/module/skia/types/WebGPU.d.ts +0 -31
  369. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -2
  370. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -2
  371. package/lib/typescript/lib/module/specs/utils.d.ts +0 -1
  372. package/lib/typescript/lib/module/views/WebGPUCanvas.d.ts +0 -7
  373. package/lib/typescript/lib/module/views/WebGPUCanvas.web.d.ts +0 -8
  374. package/lib/typescript/src/skia/types/WebGPU.d.ts +0 -184
  375. package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +0 -8
  376. package/lib/typescript/src/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  377. package/lib/typescript/src/specs/utils.d.ts +0 -1
  378. package/lib/typescript/src/views/WebGPUCanvas.d.ts +0 -33
  379. package/lib/typescript/src/views/WebGPUCanvas.web.d.ts +0 -23
  380. package/src/skia/types/WebGPU.ts +0 -226
  381. package/src/specs/WebGPUViewNativeComponent.ts +0 -11
  382. package/src/specs/WebGPUViewNativeComponent.web.ts +0 -110
  383. package/src/specs/utils.ts +0 -4
  384. package/src/views/WebGPUCanvas.tsx +0 -125
  385. package/src/views/WebGPUCanvas.web.tsx +0 -36
  386. /package/cpp/{jsi2 → jsi}/Promise.cpp +0 -0
  387. /package/cpp/{jsi2 → jsi}/Promise.h +0 -0
@@ -1,10 +1,17 @@
1
1
  #pragma once
2
2
 
3
+ #include <memory>
4
+ #include <optional>
5
+ #include <string>
6
+ #include <utility>
7
+ #include <variant>
8
+
3
9
  #include <jsi/jsi.h>
4
10
 
5
11
  #include "JsiSkCanvas.h"
6
12
  #include "JsiSkColor.h"
7
- #include "JsiSkHostObjects.h"
13
+ #include "JsiSkConverters.h"
14
+ #include "JsiSkNativeObjects.h"
8
15
  #include "JsiSkPoint.h"
9
16
  #include "JsiSkRect.h"
10
17
  #include "api/third_party/SkottieUtils.h"
@@ -146,96 +153,71 @@ public:
146
153
  std::unique_ptr<CustomPropertyManager> _propManager = nullptr;
147
154
  };
148
155
 
149
- class JsiSkSkottie : public JsiSkWrappingSharedPtrHostObject<ManagedAnimation> {
156
+ class JsiSkSkottie
157
+ : public JsiSkWrappingSharedPtrNativeObject<JsiSkSkottie,
158
+ ManagedAnimation> {
150
159
  public:
160
+ static constexpr const char *CLASS_NAME = "Skottie";
161
+
151
162
  // #region Properties
152
- JSI_HOST_FUNCTION(duration) {
163
+ double duration() {
153
164
  return static_cast<double>(getObject()->_animation->duration());
154
165
  }
155
- JSI_HOST_FUNCTION(fps) {
156
- return static_cast<double>(getObject()->_animation->fps());
157
- }
158
-
159
- JSI_PROPERTY_GET(__typename__) {
160
- return jsi::String::createFromUtf8(runtime, "Skottie");
161
- }
162
-
163
- JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkSkottie, __typename__))
166
+ double fps() { return static_cast<double>(getObject()->_animation->fps()); }
164
167
  // #endregion
165
168
 
166
169
  // #region Methods
167
- JSI_HOST_FUNCTION(seekFrame) {
170
+ void seekFrame(double frame,
171
+ std::optional<std::shared_ptr<SkRect>> rectParam) {
168
172
  sksg::InvalidationController ic;
169
- getObject()->_animation->seekFrame(arguments[0].asNumber(), &ic);
173
+ getObject()->_animation->seekFrame(frame, &ic);
170
174
  auto bounds = ic.bounds();
171
- if (count >= 2) {
172
- auto rect = JsiSkRect::fromValue(runtime, arguments[1]);
173
- if (rect != nullptr) {
174
- rect->setXYWH(bounds.x(), bounds.y(), bounds.width(), bounds.height());
175
- }
175
+ if (rectParam.has_value() && *rectParam != nullptr) {
176
+ auto rect = *rectParam;
177
+ rect->setXYWH(bounds.x(), bounds.y(), bounds.width(), bounds.height());
176
178
  }
177
- return jsi::Value::undefined();
178
179
  }
179
180
 
180
- JSI_HOST_FUNCTION(size) {
181
- auto size = getObject()->_animation->size();
182
- jsi::Object jsiSize(runtime);
183
- jsiSize.setProperty(runtime, "width", size.width());
184
- jsiSize.setProperty(runtime, "height", size.height());
185
- return jsiSize;
186
- }
181
+ SkSize size() { return getObject()->_animation->size(); }
187
182
 
188
- JSI_HOST_FUNCTION(render) {
189
- auto canvas = arguments[0]
190
- .asObject(runtime)
191
- .asHostObject<JsiSkCanvas>(runtime)
192
- ->getCanvas();
193
- if (count > 1) {
194
- auto rect = JsiSkRect::fromValue(runtime, arguments[1]);
195
- getObject()->_animation->render(canvas, rect.get());
183
+ void render(std::shared_ptr<JsiSkCanvas> jsiCanvas,
184
+ std::optional<std::shared_ptr<SkRect>> rect) {
185
+ auto canvas = jsiCanvas->getCanvas();
186
+ if (rect.has_value()) {
187
+ getObject()->_animation->render(canvas, rect->get());
196
188
  } else {
197
189
  getObject()->_animation->render(canvas);
198
190
  }
199
-
200
- return jsi::Value::undefined();
201
191
  }
202
192
 
203
- JSI_HOST_FUNCTION(version) {
204
- return jsi::String::createFromUtf8(
205
- runtime, getObject()->_animation->version().c_str());
193
+ std::string version() {
194
+ return std::string(getObject()->_animation->version().c_str());
206
195
  }
207
196
 
208
- JSI_HOST_FUNCTION(setColor) {
209
- if (count < 2) {
210
- return jsi::Value(false);
197
+ bool setColor(JsiOptional<std::string> key, JsiOptional<JsiColor> color) {
198
+ if (!key.has_value() || !color.has_value()) {
199
+ return false;
211
200
  }
212
- auto key = arguments[0].asString(runtime).utf8(runtime);
213
- auto color = JsiSkColor::fromValue(runtime, arguments[1]);
214
- return getObject()->_propManager->setColor(key, color);
201
+ return getObject()->_propManager->setColor(*key, *color);
215
202
  }
216
203
 
217
- JSI_HOST_FUNCTION(setOpacity) {
218
- if (count < 2) {
219
- return jsi::Value(false);
204
+ bool setOpacity(JsiOptional<std::string> key, JsiOptional<double> opacity) {
205
+ if (!key.has_value() || !opacity.has_value()) {
206
+ return false;
220
207
  }
221
-
222
- auto key = arguments[0].asString(runtime).utf8(runtime);
223
- auto opacity = arguments[1].asNumber();
224
- return getObject()->_propManager->setOpacity(key, opacity);
208
+ return getObject()->_propManager->setOpacity(*key, *opacity);
225
209
  }
226
210
 
227
- JSI_HOST_FUNCTION(setText) {
228
- if (count < 3) {
229
- return jsi::Value(false);
211
+ bool setText(JsiOptional<std::string> key, JsiOptional<std::string> text,
212
+ JsiOptional<double> size) {
213
+ if (!key.has_value() || !text.has_value() || !size.has_value()) {
214
+ return false;
230
215
  }
231
- auto key = arguments[0].asString(runtime).utf8(runtime);
232
- auto text = arguments[1].asString(runtime).utf8(runtime);
233
- auto size = arguments[2].asNumber();
234
216
  // preserve all other text fields
235
- auto t = getObject()->_propManager->getText(key);
236
- t.fText = SkString(text);
237
- t.fTextSize = size;
238
- return getObject()->_propManager->setText(key, t);
217
+ auto t = getObject()->_propManager->getText(*key);
218
+ t.fText = SkString(*text);
219
+ t.fTextSize = *size;
220
+ return getObject()->_propManager->setText(*key, t);
239
221
  }
240
222
 
241
223
  JSI_HOST_FUNCTION(getTextProps) {
@@ -256,27 +238,24 @@ public:
256
238
  return props;
257
239
  }
258
240
 
259
- JSI_HOST_FUNCTION(setTransform) {
260
- if (count < 7) {
261
- return jsi::Value(false);
241
+ bool setTransform(JsiOptional<std::string> key, JsiOptional<SkPoint> anchor,
242
+ JsiOptional<SkPoint> position, JsiOptional<SkPoint> scale,
243
+ JsiOptional<double> rotation, JsiOptional<double> skew,
244
+ JsiOptional<double> skewAxis) {
245
+ if (!key.has_value() || !anchor.has_value() || !position.has_value() ||
246
+ !scale.has_value() || !rotation.has_value() || !skew.has_value() ||
247
+ !skewAxis.has_value()) {
248
+ return false;
262
249
  }
263
250
 
264
- auto key = arguments[0].asString(runtime).utf8(runtime);
265
- auto anchor = JsiSkPoint::fromValue(runtime, arguments[1]);
266
- auto position = JsiSkPoint::fromValue(runtime, arguments[2]);
267
- auto scale = JsiSkPoint::fromValue(runtime, arguments[3]);
268
- auto rotation = arguments[4].asNumber();
269
- auto skew = arguments[5].asNumber();
270
- auto skewAxis = arguments[6].asNumber();
271
-
272
251
  skottie::TransformPropertyValue transform;
273
252
  transform.fAnchorPoint = {anchor->x(), anchor->y()};
274
253
  transform.fPosition = {position->x(), position->y()};
275
254
  transform.fScale = {scale->x(), scale->y()};
276
- transform.fRotation = rotation;
277
- transform.fSkew = skew;
278
- transform.fSkewAxis = skewAxis;
279
- return getObject()->_propManager->setTransform(key, transform);
255
+ transform.fRotation = *rotation;
256
+ transform.fSkew = *skew;
257
+ transform.fSkewAxis = *skewAxis;
258
+ return getObject()->_propManager->setTransform(*key, transform);
280
259
  }
281
260
 
282
261
  JSI_HOST_FUNCTION(getSlotInfo) {
@@ -330,52 +309,47 @@ public:
330
309
  return slotInfoJS;
331
310
  }
332
311
 
333
- JSI_HOST_FUNCTION(setColorSlot) {
334
- if (count < 2) {
335
- return jsi::Value(false);
312
+ bool setColorSlot(JsiOptional<std::string> slotID,
313
+ JsiOptional<JsiColor> color) {
314
+ if (!slotID.has_value() || !color.has_value()) {
315
+ return false;
336
316
  }
337
- auto slotID = arguments[0].asString(runtime).utf8(runtime);
338
- auto color = JsiSkColor::fromValue(runtime, arguments[1]);
339
- return getObject()->_slotManager->setColorSlot(SkString(slotID), color);
317
+ return getObject()->_slotManager->setColorSlot(SkString(*slotID), *color);
340
318
  }
341
319
 
342
- JSI_HOST_FUNCTION(setScalarSlot) {
343
- if (count < 2) {
344
- return jsi::Value(false);
320
+ bool setScalarSlot(JsiOptional<std::string> slotID,
321
+ JsiOptional<double> scalar) {
322
+ if (!slotID.has_value() || !scalar.has_value()) {
323
+ return false;
345
324
  }
346
- auto slotID = arguments[0].asString(runtime).utf8(runtime);
347
- auto scalar = arguments[1].asNumber();
348
- return getObject()->_slotManager->setScalarSlot(SkString(slotID), scalar);
325
+ return getObject()->_slotManager->setScalarSlot(SkString(*slotID),
326
+ *scalar);
349
327
  }
350
328
 
351
- JSI_HOST_FUNCTION(setVec2Slot) {
352
- if (count < 2) {
353
- return jsi::Value(false);
329
+ bool setVec2Slot(JsiOptional<std::string> slotID,
330
+ JsiOptional<SkPoint> point) {
331
+ if (!slotID.has_value() || !point.has_value()) {
332
+ return false;
354
333
  }
355
- auto slotID = arguments[0].asString(runtime).utf8(runtime);
356
- auto point = JsiSkPoint::fromValue(runtime, arguments[1]);
357
334
  SkV2 vec2{point->x(), point->y()};
358
- return getObject()->_slotManager->setVec2Slot(SkString(slotID), vec2);
335
+ return getObject()->_slotManager->setVec2Slot(SkString(*slotID), vec2);
359
336
  }
360
337
 
361
- JSI_HOST_FUNCTION(setTextSlot) {
362
- if (count < 2) {
363
- return jsi::Value(false);
364
- }
365
- auto key = arguments[0].asString(runtime).utf8(runtime);
338
+ // The text value argument is intentionally not declared: the raw binding
339
+ // never read it (the method is not implemented yet).
340
+ bool setTextSlot(JsiOptional<std::string> key) {
366
341
  // TODO: Implement proper text slot setting
367
- return jsi::Value(false);
342
+ return false;
368
343
  }
369
344
 
370
- JSI_HOST_FUNCTION(setImageSlot) {
371
- if (count < 2) {
372
- return jsi::Value(false);
345
+ bool setImageSlot(JsiOptional<std::string> slotID,
346
+ JsiOptional<std::string> assetName) {
347
+ if (!slotID.has_value() || !assetName.has_value()) {
348
+ return false;
373
349
  }
374
- auto slotID = arguments[0].asString(runtime).utf8(runtime);
375
- auto assetName = arguments[1].asString(runtime).utf8(runtime);
376
350
  return getObject()->_slotManager->setImageSlot(
377
- SkString(slotID), getObject()->_resourceProvider->loadImageAsset(
378
- nullptr, assetName.data(), nullptr));
351
+ SkString(*slotID), getObject()->_resourceProvider->loadImageAsset(
352
+ nullptr, assetName->data(), nullptr));
379
353
  }
380
354
 
381
355
  JSI_HOST_FUNCTION(getColorSlot) {
@@ -389,15 +363,15 @@ public:
389
363
  return jsi::Value::null();
390
364
  }
391
365
 
392
- JSI_HOST_FUNCTION(getScalarSlot) {
393
- if (count < 1) {
394
- return jsi::Value::null();
366
+ std::variant<double, std::nullptr_t>
367
+ getScalarSlot(JsiOptional<std::string> slotID) {
368
+ if (!slotID.has_value()) {
369
+ return nullptr;
395
370
  }
396
- auto slotID = arguments[0].asString(runtime).utf8(runtime);
397
- if (auto v = getObject()->_slotManager->getScalarSlot(SkString(slotID))) {
398
- return jsi::Value(v.value());
371
+ if (auto v = getObject()->_slotManager->getScalarSlot(SkString(*slotID))) {
372
+ return static_cast<double>(v.value());
399
373
  }
400
- return jsi::Value::null();
374
+ return nullptr;
401
375
  }
402
376
 
403
377
  JSI_HOST_FUNCTION(getVec2Slot) {
@@ -554,29 +528,45 @@ public:
554
528
  return transformProps;
555
529
  }
556
530
 
557
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkSkottie, duration),
558
- JSI_EXPORT_FUNC(JsiSkSkottie, fps),
559
- JSI_EXPORT_FUNC(JsiSkSkottie, seekFrame),
560
- JSI_EXPORT_FUNC(JsiSkSkottie, render),
561
- JSI_EXPORT_FUNC(JsiSkSkottie, size),
562
- JSI_EXPORT_FUNC(JsiSkSkottie, version),
563
- JSI_EXPORT_FUNC(JsiSkSkottie, getSlotInfo),
564
- JSI_EXPORT_FUNC(JsiSkSkottie, setColorSlot),
565
- JSI_EXPORT_FUNC(JsiSkSkottie, setScalarSlot),
566
- JSI_EXPORT_FUNC(JsiSkSkottie, setVec2Slot),
567
- JSI_EXPORT_FUNC(JsiSkSkottie, setTextSlot),
568
- JSI_EXPORT_FUNC(JsiSkSkottie, setImageSlot),
569
- JSI_EXPORT_FUNC(JsiSkSkottie, getColorSlot),
570
- JSI_EXPORT_FUNC(JsiSkSkottie, getScalarSlot),
571
- JSI_EXPORT_FUNC(JsiSkSkottie, getVec2Slot),
572
- JSI_EXPORT_FUNC(JsiSkSkottie, getTextSlot),
573
- JSI_EXPORT_FUNC(JsiSkSkottie, getColorProps),
574
- JSI_EXPORT_FUNC(JsiSkSkottie, getOpacityProps),
575
- JSI_EXPORT_FUNC(JsiSkSkottie, getTransformProps),
576
- JSI_EXPORT_FUNC(JsiSkSkottie, getTextProps),
577
- JSI_EXPORT_FUNC(JsiSkSkottie, setColor),
578
- JSI_EXPORT_FUNC(JsiSkSkottie, setText),
579
- JSI_EXPORT_FUNC(JsiSkSkottie, dispose))
531
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
532
+ installCommon(runtime, prototype);
533
+ installMethod(runtime, prototype, "duration", &JsiSkSkottie::duration);
534
+ installMethod(runtime, prototype, "fps", &JsiSkSkottie::fps);
535
+ installMethod(runtime, prototype, "seekFrame", &JsiSkSkottie::seekFrame);
536
+ installMethod(runtime, prototype, "render", &JsiSkSkottie::render);
537
+ installMethod(runtime, prototype, "size", &JsiSkSkottie::size);
538
+ installMethod(runtime, prototype, "version", &JsiSkSkottie::version);
539
+ installHostMethod(runtime, prototype, "getSlotInfo",
540
+ &JsiSkSkottie::getSlotInfo);
541
+ installMethod(runtime, prototype, "setColorSlot",
542
+ &JsiSkSkottie::setColorSlot);
543
+ installMethod(runtime, prototype, "setScalarSlot",
544
+ &JsiSkSkottie::setScalarSlot);
545
+ installMethod(runtime, prototype, "setVec2Slot",
546
+ &JsiSkSkottie::setVec2Slot);
547
+ installMethod(runtime, prototype, "setTextSlot",
548
+ &JsiSkSkottie::setTextSlot);
549
+ installMethod(runtime, prototype, "setImageSlot",
550
+ &JsiSkSkottie::setImageSlot);
551
+ installHostMethod(runtime, prototype, "getColorSlot",
552
+ &JsiSkSkottie::getColorSlot);
553
+ installMethod(runtime, prototype, "getScalarSlot",
554
+ &JsiSkSkottie::getScalarSlot);
555
+ installHostMethod(runtime, prototype, "getVec2Slot",
556
+ &JsiSkSkottie::getVec2Slot);
557
+ installHostMethod(runtime, prototype, "getTextSlot",
558
+ &JsiSkSkottie::getTextSlot);
559
+ installHostMethod(runtime, prototype, "getColorProps",
560
+ &JsiSkSkottie::getColorProps);
561
+ installHostMethod(runtime, prototype, "getOpacityProps",
562
+ &JsiSkSkottie::getOpacityProps);
563
+ installHostMethod(runtime, prototype, "getTransformProps",
564
+ &JsiSkSkottie::getTransformProps);
565
+ installHostMethod(runtime, prototype, "getTextProps",
566
+ &JsiSkSkottie::getTextProps);
567
+ installMethod(runtime, prototype, "setColor", &JsiSkSkottie::setColor);
568
+ installMethod(runtime, prototype, "setText", &JsiSkSkottie::setText);
569
+ }
580
570
  // #endregion
581
571
 
582
572
  /**
@@ -584,10 +574,10 @@ public:
584
574
  */
585
575
  JsiSkSkottie(std::shared_ptr<RNSkPlatformContext> context,
586
576
  std::shared_ptr<ManagedAnimation> animation)
587
- : JsiSkWrappingSharedPtrHostObject<ManagedAnimation>(
577
+ : JsiSkWrappingSharedPtrNativeObject<JsiSkSkottie, ManagedAnimation>(
588
578
  std::move(context), std::move(animation)) {}
589
579
 
590
- size_t getMemoryPressure() const override {
580
+ size_t getMemoryPressure() override {
591
581
  auto animation = getObject();
592
582
  if (!animation || !animation->_animation) {
593
583
  return 1024; // Base size if no animation
@@ -615,7 +605,5 @@ public:
615
605
 
616
606
  return animationMemory + baseOverhead;
617
607
  }
618
-
619
- std::string getObjectType() const override { return "JsiSkSkottie"; }
620
608
  };
621
609
  } // namespace RNSkia
@@ -7,8 +7,9 @@
7
7
 
8
8
  #include <jsi/jsi.h>
9
9
 
10
+ #include "JsiSkConverters.h"
10
11
  #include "JsiSkDispatcher.h"
11
- #include "JsiSkHostObjects.h"
12
+ #include "JsiSkNativeObjects.h"
12
13
  #include "JsiTextureInfo.h"
13
14
 
14
15
  #include "JsiSkCanvas.h"
@@ -30,15 +31,18 @@ namespace RNSkia {
30
31
 
31
32
  namespace jsi = facebook::jsi;
32
33
 
33
- class JsiSkSurface : public JsiSkWrappingSkPtrHostObject<SkSurface> {
34
+ class JsiSkSurface
35
+ : public JsiSkWrappingSkPtrNativeObject<JsiSkSurface, SkSurface> {
34
36
  private:
35
37
  std::shared_ptr<Dispatcher> _dispatcher;
36
38
 
37
39
  public:
40
+ static constexpr const char *CLASS_NAME = "Surface";
41
+
38
42
  JsiSkSurface(std::shared_ptr<RNSkPlatformContext> context,
39
43
  sk_sp<SkSurface> surface)
40
- : JsiSkWrappingSkPtrHostObject<SkSurface>(std::move(context),
41
- std::move(surface)) {
44
+ : JsiSkWrappingSkPtrNativeObject<JsiSkSurface, SkSurface>(
45
+ std::move(context), std::move(surface)) {
42
46
  // Get the dispatcher for the current thread
43
47
  _dispatcher = Dispatcher::getDispatcher();
44
48
  // Process any pending operations
@@ -63,31 +67,26 @@ public:
63
67
  }
64
68
  }
65
69
 
66
- EXPORT_JSI_API_TYPENAME(JsiSkSurface, Surface)
67
-
68
70
  // TODO-API: Properties?
69
- JSI_HOST_FUNCTION(width) { return static_cast<double>(getObject()->width()); }
70
- JSI_HOST_FUNCTION(height) {
71
- return static_cast<double>(getObject()->height());
72
- }
71
+ double width() { return static_cast<double>(getObject()->width()); }
72
+ double height() { return static_cast<double>(getObject()->height()); }
73
73
 
74
- JSI_HOST_FUNCTION(getCanvas) {
74
+ std::shared_ptr<JsiSkCanvas> getCanvas() {
75
75
  auto surface = getObject();
76
76
  auto canvas =
77
77
  std::make_shared<JsiSkCanvas>(getContext(), surface->getCanvas());
78
78
  // Keep a reference to the owning surface so the canvas can read pixels back
79
79
  // through a snapshot on Graphite (which lacks synchronous canvas readback).
80
80
  canvas->setSurface(surface);
81
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, canvas,
82
- getContext());
81
+ return canvas;
83
82
  }
84
83
 
85
- JSI_HOST_FUNCTION(flush) {
84
+ void flush(JsiOptional<bool> syncParam) {
86
85
  auto surface = getObject();
87
86
  // When `sync` is true, block until the GPU has finished executing the
88
87
  // submitted work. Required before a native consumer on a different command
89
88
  // queue reads this surface's texture via getNativeTextureUnstable(). #3916
90
- bool sync = count > 0 && arguments[0].isBool() && arguments[0].getBool();
89
+ bool sync = syncParam.has_value() && *syncParam;
91
90
  #if defined(SK_GRAPHITE)
92
91
  // A raster surface (e.g. Skia.Surface.Make) has no Graphite recorder;
93
92
  // only Graphite-backed surfaces need to snap and submit a recording.
@@ -102,7 +101,6 @@ public:
102
101
  dContext->flushAndSubmit(sync ? GrSyncCpu::kYes : GrSyncCpu::kNo);
103
102
  }
104
103
  #endif
105
- return jsi::Value::undefined();
106
104
  }
107
105
 
108
106
  JSI_HOST_FUNCTION(makeImageSnapshot) {
@@ -124,15 +122,12 @@ public:
124
122
  }
125
123
  #endif
126
124
  if (count > 1 && arguments[1].isObject()) {
127
- auto jsiImage =
128
- arguments[1].asObject(runtime).asHostObject<JsiSkImage>(runtime);
125
+ auto jsiImage = getJsiObject<JsiSkImage>(runtime, arguments[1]);
129
126
  jsiImage->setObject(image);
130
127
  return jsi::Value(runtime, arguments[1]);
131
128
  }
132
- auto hostObjectInstance =
133
- std::make_shared<JsiSkImage>(getContext(), std::move(image));
134
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
135
- runtime, hostObjectInstance, getContext());
129
+ return makeJsiObject(
130
+ runtime, std::make_shared<JsiSkImage>(getContext(), std::move(image)));
136
131
  }
137
132
 
138
133
  JSI_HOST_FUNCTION(getNativeTextureUnstable) {
@@ -140,7 +135,7 @@ public:
140
135
  return JsiTextureInfo::toValue(runtime, texInfo);
141
136
  }
142
137
 
143
- size_t getMemoryPressure() const override {
138
+ size_t getMemoryPressure() override {
144
139
  if (isDisposed()) {
145
140
  return 0;
146
141
  }
@@ -196,15 +191,17 @@ public:
196
191
  return estimated;
197
192
  }
198
193
 
199
- std::string getObjectType() const override { return "JsiSkSurface"; }
200
-
201
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkSurface, width),
202
- JSI_EXPORT_FUNC(JsiSkSurface, height),
203
- JSI_EXPORT_FUNC(JsiSkSurface, getCanvas),
204
- JSI_EXPORT_FUNC(JsiSkSurface, makeImageSnapshot),
205
- JSI_EXPORT_FUNC(JsiSkSurface, flush),
206
- JSI_EXPORT_FUNC(JsiSkSurface, getNativeTextureUnstable),
207
- JSI_EXPORT_FUNC(JsiSkSurface, dispose))
194
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
195
+ installCommon(runtime, prototype);
196
+ installMethod(runtime, prototype, "width", &JsiSkSurface::width);
197
+ installMethod(runtime, prototype, "height", &JsiSkSurface::height);
198
+ installMethod(runtime, prototype, "getCanvas", &JsiSkSurface::getCanvas);
199
+ installHostMethod(runtime, prototype, "makeImageSnapshot",
200
+ &JsiSkSurface::makeImageSnapshot);
201
+ installMethod(runtime, prototype, "flush", &JsiSkSurface::flush);
202
+ installHostMethod(runtime, prototype, "getNativeTextureUnstable",
203
+ &JsiSkSurface::getNativeTextureUnstable);
204
+ }
208
205
  };
209
206
 
210
207
  } // namespace RNSkia
@@ -2,10 +2,11 @@
2
2
 
3
3
  #include <memory>
4
4
  #include <utility>
5
+ #include <variant>
5
6
 
6
7
  #include <jsi/jsi.h>
7
8
 
8
- #include "JsiSkHostObjects.h"
9
+ #include "JsiSkNativeObjects.h"
9
10
 
10
11
  #include "JsiSkSurface.h"
11
12
 
@@ -20,20 +21,18 @@ namespace RNSkia {
20
21
 
21
22
  namespace jsi = facebook::jsi;
22
23
 
23
- class JsiSkSurfaceFactory : public JsiSkHostObject {
24
+ class JsiSkSurfaceFactory : public JsiSkNativeObject<JsiSkSurfaceFactory> {
24
25
  public:
25
- JSI_HOST_FUNCTION(Make) {
26
- auto width = static_cast<int>(arguments[0].asNumber());
27
- auto height = static_cast<int>(arguments[1].asNumber());
26
+ static constexpr const char *CLASS_NAME = "SurfaceFactory";
27
+
28
+ std::variant<std::nullptr_t, std::shared_ptr<JsiSkSurface>> Make(int width,
29
+ int height) {
28
30
  auto imageInfo = SkImageInfo::MakeN32Premul(width, height);
29
31
  auto surface = SkSurfaces::Raster(imageInfo);
30
32
  if (surface == nullptr) {
31
- return jsi::Value::null();
33
+ return nullptr;
32
34
  }
33
- auto hostObjectInstance =
34
- std::make_shared<JsiSkSurface>(getContext(), std::move(surface));
35
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
36
- runtime, hostObjectInstance, getContext());
35
+ return std::make_shared<JsiSkSurface>(getContext(), std::move(surface));
37
36
  }
38
37
 
39
38
  JSI_HOST_FUNCTION(MakeOffscreen) {
@@ -56,21 +55,20 @@ public:
56
55
  if (surface == nullptr) {
57
56
  return jsi::Value::null();
58
57
  }
59
- auto hostObjectInstance =
60
- std::make_shared<JsiSkSurface>(getContext(), std::move(surface));
61
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
62
- runtime, hostObjectInstance, getContext());
58
+ return makeJsiObject(runtime, std::make_shared<JsiSkSurface>(
59
+ getContext(), std::move(surface)));
63
60
  }
64
61
 
65
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkSurfaceFactory, Make),
66
- JSI_EXPORT_FUNC(JsiSkSurfaceFactory, MakeOffscreen))
67
-
68
- size_t getMemoryPressure() const override { return 2048; }
62
+ size_t getMemoryPressure() override { return 2048; }
69
63
 
70
- std::string getObjectType() const override { return "JsiSkSurfaceFactory"; }
64
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
65
+ installMethod(runtime, prototype, "Make", &JsiSkSurfaceFactory::Make);
66
+ installHostMethod(runtime, prototype, "MakeOffscreen",
67
+ &JsiSkSurfaceFactory::MakeOffscreen);
68
+ }
71
69
 
72
70
  explicit JsiSkSurfaceFactory(std::shared_ptr<RNSkPlatformContext> context)
73
- : JsiSkHostObject(std::move(context)) {}
71
+ : JsiSkNativeObject<JsiSkSurfaceFactory>(std::move(context)) {}
74
72
  };
75
73
 
76
74
  } // namespace RNSkia
@@ -5,7 +5,7 @@
5
5
 
6
6
  #include <jsi/jsi.h>
7
7
 
8
- #include "JsiSkHostObjects.h"
8
+ #include "JsiSkNativeObjects.h"
9
9
 
10
10
  #pragma clang diagnostic push
11
11
  #pragma clang diagnostic ignored "-Wdocumentation"
@@ -18,14 +18,17 @@ namespace RNSkia {
18
18
 
19
19
  namespace jsi = facebook::jsi;
20
20
 
21
- class JsiSkTextBlob : public JsiSkWrappingSkPtrHostObject<SkTextBlob> {
21
+ class JsiSkTextBlob
22
+ : public JsiSkWrappingSkPtrNativeObject<JsiSkTextBlob, SkTextBlob> {
22
23
  public:
24
+ static constexpr const char *CLASS_NAME = "TextBlob";
25
+
23
26
  JsiSkTextBlob(std::shared_ptr<RNSkPlatformContext> context,
24
27
  sk_sp<SkTextBlob> shader)
25
- : JsiSkWrappingSkPtrHostObject<SkTextBlob>(std::move(context),
26
- std::move(shader)) {}
28
+ : JsiSkWrappingSkPtrNativeObject<JsiSkTextBlob, SkTextBlob>(
29
+ std::move(context), std::move(shader)) {}
27
30
 
28
- size_t getMemoryPressure() const override {
31
+ size_t getMemoryPressure() override {
29
32
  auto textBlob = getObject();
30
33
  if (!textBlob)
31
34
  return 0;
@@ -37,9 +40,13 @@ public:
37
40
  1024; // Area estimation + base overhead
38
41
  }
39
42
 
40
- std::string getObjectType() const override { return "JsiSkTextBlob"; }
43
+ static sk_sp<SkTextBlob> fromValue(jsi::Runtime &runtime,
44
+ const jsi::Value &obj) {
45
+ return objectFromValue(runtime, obj);
46
+ }
41
47
 
42
- EXPORT_JSI_API_TYPENAME(JsiSkTextBlob, TextBlob)
43
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkTextBlob, dispose))
48
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
49
+ installCommon(runtime, prototype);
50
+ }
44
51
  };
45
52
  } // namespace RNSkia