@shopify/react-native-skia 2.10.0 → 2.10.2

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 (332) hide show
  1. package/android/CMakeLists.txt +7 -41
  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 +14 -20
  5. package/cpp/api/JsiSkAnimatedImage.h +13 -16
  6. package/cpp/api/JsiSkAnimatedImageFactory.h +9 -7
  7. package/cpp/api/JsiSkApi.h +94 -90
  8. package/cpp/api/JsiSkCanvas.h +108 -251
  9. package/cpp/api/JsiSkColorFilterFactory.h +45 -63
  10. package/cpp/api/JsiSkContourMeasure.h +19 -29
  11. package/cpp/api/JsiSkContourMeasureIter.h +6 -6
  12. package/cpp/api/JsiSkConverters.h +410 -0
  13. package/cpp/api/JsiSkDataFactory.h +9 -15
  14. package/cpp/api/JsiSkFont.h +99 -180
  15. package/cpp/api/JsiSkFontMgr.h +19 -21
  16. package/cpp/api/JsiSkFontMgrFactory.h +4 -5
  17. package/cpp/api/JsiSkImage.h +66 -66
  18. package/cpp/api/JsiSkImageFactory.h +66 -63
  19. package/cpp/api/JsiSkImageFilterFactory.h +354 -608
  20. package/cpp/api/JsiSkImageInfo.h +10 -13
  21. package/cpp/api/JsiSkMaskFilterFactory.h +8 -11
  22. package/cpp/api/JsiSkMatrix.h +36 -73
  23. package/cpp/api/JsiSkNativeObjects.h +64 -96
  24. package/cpp/api/JsiSkPaint.h +73 -131
  25. package/cpp/api/JsiSkParagraph.h +36 -53
  26. package/cpp/api/JsiSkParagraphBuilder.h +36 -64
  27. package/cpp/api/JsiSkParagraphBuilderFactory.h +11 -16
  28. package/cpp/api/JsiSkPath.h +216 -349
  29. package/cpp/api/JsiSkPathBuilder.h +133 -269
  30. package/cpp/api/JsiSkPathBuilderFactory.h +11 -11
  31. package/cpp/api/JsiSkPathEffectFactory.h +52 -72
  32. package/cpp/api/JsiSkPathFactory.h +129 -195
  33. package/cpp/api/JsiSkPicture.h +12 -18
  34. package/cpp/api/JsiSkPictureRecorder.h +14 -15
  35. package/cpp/api/JsiSkPoint.h +4 -4
  36. package/cpp/api/JsiSkRRect.h +7 -8
  37. package/cpp/api/JsiSkRSXform.h +10 -23
  38. package/cpp/api/JsiSkRect.h +23 -31
  39. package/cpp/api/JsiSkRuntimeEffect.h +67 -83
  40. package/cpp/api/JsiSkRuntimeEffectFactory.h +6 -10
  41. package/cpp/api/JsiSkRuntimeShaderBuilder.h +5 -14
  42. package/cpp/api/JsiSkSVG.h +4 -4
  43. package/cpp/api/JsiSkShaderFactory.h +153 -225
  44. package/cpp/api/JsiSkSkottie.h +104 -126
  45. package/cpp/api/JsiSkSurface.h +11 -14
  46. package/cpp/api/JsiSkSurfaceFactory.h +6 -7
  47. package/cpp/api/JsiSkTextBlobFactory.h +31 -54
  48. package/cpp/api/JsiSkTypeface.h +8 -12
  49. package/cpp/api/JsiSkTypefaceFactory.h +9 -7
  50. package/cpp/api/JsiSkTypefaceFontProvider.h +22 -23
  51. package/cpp/api/JsiSkTypefaceFontProviderFactory.h +5 -6
  52. package/cpp/api/JsiSkVertices.h +6 -8
  53. package/cpp/api/JsiSkiaContext.h +10 -11
  54. package/cpp/api/JsiVideo.h +31 -71
  55. package/cpp/jsi/EnumMapper.h +2 -2
  56. package/cpp/jsi/JSIConverter.h +2 -33
  57. package/cpp/jsi/NativeObject.h +24 -19
  58. package/cpp/jsi/Promise.cpp +2 -2
  59. package/cpp/jsi/Promise.h +2 -2
  60. package/cpp/rnskia/RNDawnContext.h +18 -2
  61. package/cpp/rnskia/RNDawnInterop.cpp +19 -0
  62. package/cpp/rnskia/RNDawnUtils.h +18 -1
  63. package/cpp/rnskia/RNSkManager.cpp +5 -162
  64. package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkaroundsAutogen.h +2 -0
  65. package/lib/commonjs/mock/index.js +0 -1
  66. package/lib/commonjs/mock/index.js.map +1 -1
  67. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +15 -6
  68. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  69. package/lib/commonjs/skia/types/Skia.d.ts +5 -15
  70. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  71. package/lib/commonjs/skia/types/index.d.ts +0 -1
  72. package/lib/commonjs/skia/types/index.js +0 -11
  73. package/lib/commonjs/skia/types/index.js.map +1 -1
  74. package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
  75. package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
  76. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  77. package/lib/commonjs/skia/web/JsiSkia.js +1 -4
  78. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  79. package/lib/commonjs/views/index.d.ts +0 -1
  80. package/lib/commonjs/views/index.js +0 -11
  81. package/lib/commonjs/views/index.js.map +1 -1
  82. package/lib/module/mock/index.js +0 -1
  83. package/lib/module/mock/index.js.map +1 -1
  84. package/lib/module/skia/types/Image/ImageFactory.d.ts +15 -6
  85. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  86. package/lib/module/skia/types/Skia.d.ts +5 -15
  87. package/lib/module/skia/types/Skia.js.map +1 -1
  88. package/lib/module/skia/types/index.d.ts +0 -1
  89. package/lib/module/skia/types/index.js +0 -1
  90. package/lib/module/skia/types/index.js.map +1 -1
  91. package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
  92. package/lib/module/skia/web/JsiSkImageFactory.js +2 -2
  93. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  94. package/lib/module/skia/web/JsiSkia.js +1 -4
  95. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  96. package/lib/module/views/index.d.ts +0 -1
  97. package/lib/module/views/index.js +0 -1
  98. package/lib/module/views/index.js.map +1 -1
  99. package/lib/typescript/lib/commonjs/mock/index.d.ts +0 -1
  100. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
  101. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +1 -2
  102. package/lib/typescript/lib/module/mock/index.d.ts +0 -2
  103. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -2
  104. package/lib/typescript/lib/module/skia/types/index.d.ts +0 -1
  105. package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
  106. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +1 -2
  107. package/lib/typescript/lib/module/views/index.d.ts +0 -1
  108. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +15 -6
  109. package/lib/typescript/src/skia/types/Skia.d.ts +5 -15
  110. package/lib/typescript/src/skia/types/index.d.ts +0 -1
  111. package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -2
  112. package/lib/typescript/src/views/index.d.ts +0 -1
  113. package/package.json +3 -4
  114. package/react-native-skia.podspec +38 -4
  115. package/src/mock/index.ts +0 -1
  116. package/src/skia/types/Image/ImageFactory.ts +15 -6
  117. package/src/skia/types/Skia.ts +5 -15
  118. package/src/skia/types/index.ts +0 -1
  119. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  120. package/src/skia/web/JsiSkia.ts +2 -5
  121. package/src/views/index.ts +0 -1
  122. package/android/cpp/jni/JniWebGPUView.cpp +0 -112
  123. package/android/cpp/rnskia-android/SkiaPlatformContext.h +0 -26
  124. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUSurfaceView.java +0 -43
  125. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUTextureView.java +0 -50
  126. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUView.java +0 -98
  127. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewAPI.java +0 -19
  128. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewManager.java +0 -58
  129. package/apple/RNWebGPUAppleNativeBuffer.mm +0 -33
  130. package/apple/SkiaPlatformContext.h +0 -20
  131. package/apple/SkiaPlatformContext.mm +0 -21
  132. package/apple/SkiaWebGPUView.mm +0 -81
  133. package/apple/WebGPUMetalView.mm +0 -136
  134. package/cpp/rnwgpu/ArrayBuffer.h +0 -116
  135. package/cpp/rnwgpu/Canvas.h +0 -52
  136. package/cpp/rnwgpu/PlatformContext.h +0 -18
  137. package/cpp/rnwgpu/SurfaceRegistry.h +0 -605
  138. package/cpp/rnwgpu/api/AppleNativeBuffer.h +0 -22
  139. package/cpp/rnwgpu/api/Convertors.h +0 -783
  140. package/cpp/rnwgpu/api/External.h +0 -12
  141. package/cpp/rnwgpu/api/GPU.cpp +0 -162
  142. package/cpp/rnwgpu/api/GPU.h +0 -60
  143. package/cpp/rnwgpu/api/GPUAdapter.cpp +0 -239
  144. package/cpp/rnwgpu/api/GPUAdapter.h +0 -60
  145. package/cpp/rnwgpu/api/GPUAdapterInfo.h +0 -57
  146. package/cpp/rnwgpu/api/GPUBindGroup.cpp +0 -3
  147. package/cpp/rnwgpu/api/GPUBindGroup.h +0 -51
  148. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +0 -52
  149. package/cpp/rnwgpu/api/GPUBuffer.cpp +0 -107
  150. package/cpp/rnwgpu/api/GPUBuffer.h +0 -88
  151. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +0 -75
  152. package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -70
  153. package/cpp/rnwgpu/api/GPUCommandBuffer.h +0 -45
  154. package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +0 -179
  155. package/cpp/rnwgpu/api/GPUCommandEncoder.h +0 -111
  156. package/cpp/rnwgpu/api/GPUCompilationInfo.h +0 -79
  157. package/cpp/rnwgpu/api/GPUCompilationMessage.h +0 -36
  158. package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +0 -60
  159. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +0 -85
  160. package/cpp/rnwgpu/api/GPUComputePipeline.cpp +0 -12
  161. package/cpp/rnwgpu/api/GPUComputePipeline.h +0 -60
  162. package/cpp/rnwgpu/api/GPUDevice.cpp +0 -613
  163. package/cpp/rnwgpu/api/GPUDevice.h +0 -258
  164. package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +0 -7
  165. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +0 -40
  166. package/cpp/rnwgpu/api/GPUError.h +0 -35
  167. package/cpp/rnwgpu/api/GPUExtent3D.h +0 -66
  168. package/cpp/rnwgpu/api/GPUExternalTexture.cpp +0 -139
  169. package/cpp/rnwgpu/api/GPUExternalTexture.h +0 -95
  170. package/cpp/rnwgpu/api/GPUFeatures.h +0 -203
  171. package/cpp/rnwgpu/api/GPUInternalError.h +0 -31
  172. package/cpp/rnwgpu/api/GPUOrigin2D.h +0 -55
  173. package/cpp/rnwgpu/api/GPUOrigin3D.h +0 -62
  174. package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +0 -33
  175. package/cpp/rnwgpu/api/GPUPipelineLayout.h +0 -45
  176. package/cpp/rnwgpu/api/GPUQuerySet.cpp +0 -11
  177. package/cpp/rnwgpu/api/GPUQuerySet.h +0 -73
  178. package/cpp/rnwgpu/api/GPUQueue.cpp +0 -179
  179. package/cpp/rnwgpu/api/GPUQueue.h +0 -84
  180. package/cpp/rnwgpu/api/GPURenderBundle.h +0 -44
  181. package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +0 -131
  182. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +0 -110
  183. package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +0 -165
  184. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +0 -130
  185. package/cpp/rnwgpu/api/GPURenderPipeline.cpp +0 -13
  186. package/cpp/rnwgpu/api/GPURenderPipeline.h +0 -61
  187. package/cpp/rnwgpu/api/GPUSampler.h +0 -44
  188. package/cpp/rnwgpu/api/GPUShaderModule.cpp +0 -56
  189. package/cpp/rnwgpu/api/GPUShaderModule.h +0 -66
  190. package/cpp/rnwgpu/api/GPUSharedFence.cpp +0 -80
  191. package/cpp/rnwgpu/api/GPUSharedFence.h +0 -53
  192. package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +0 -135
  193. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +0 -75
  194. package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +0 -129
  195. package/cpp/rnwgpu/api/GPUSupportedLimits.h +0 -131
  196. package/cpp/rnwgpu/api/GPUTexture.cpp +0 -47
  197. package/cpp/rnwgpu/api/GPUTexture.h +0 -162
  198. package/cpp/rnwgpu/api/GPUTextureView.h +0 -44
  199. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +0 -60
  200. package/cpp/rnwgpu/api/GPUValidationError.h +0 -32
  201. package/cpp/rnwgpu/api/ImageBitmap.h +0 -62
  202. package/cpp/rnwgpu/api/NativeBufferUtils.h +0 -87
  203. package/cpp/rnwgpu/api/RNWebGPU.h +0 -82
  204. package/cpp/rnwgpu/api/WebGPUConstants.h +0 -36
  205. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +0 -64
  206. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +0 -78
  207. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +0 -56
  208. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +0 -97
  209. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +0 -57
  210. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +0 -52
  211. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +0 -56
  212. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +0 -56
  213. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +0 -59
  214. package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +0 -39
  215. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +0 -76
  216. package/cpp/rnwgpu/api/descriptors/GPUColor.h +0 -66
  217. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +0 -58
  218. package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +0 -29
  219. package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +0 -45
  220. package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +0 -45
  221. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +0 -56
  222. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +0 -58
  223. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +0 -67
  224. package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +0 -56
  225. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +0 -103
  226. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +0 -109
  227. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +0 -38
  228. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +0 -90
  229. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +0 -73
  230. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +0 -62
  231. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +0 -63
  232. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +0 -65
  233. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +0 -81
  234. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +0 -54
  235. package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +0 -22
  236. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +0 -54
  237. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +0 -57
  238. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +0 -69
  239. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +0 -61
  240. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +0 -55
  241. package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +0 -43
  242. package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +0 -45
  243. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +0 -80
  244. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +0 -81
  245. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +0 -101
  246. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +0 -92
  247. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +0 -58
  248. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +0 -103
  249. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +0 -51
  250. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +0 -45
  251. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +0 -110
  252. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +0 -60
  253. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +0 -62
  254. package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +0 -25
  255. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +0 -58
  256. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +0 -51
  257. package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +0 -73
  258. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +0 -64
  259. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +0 -59
  260. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +0 -59
  261. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +0 -91
  262. package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +0 -29
  263. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +0 -91
  264. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +0 -64
  265. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +0 -53
  266. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +0 -62
  267. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +0 -73
  268. package/cpp/rnwgpu/api/descriptors/Unions.h +0 -1969
  269. package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +0 -213
  270. package/cpp/rnwgpu/async/AsyncTaskHandle.h +0 -58
  271. package/cpp/rnwgpu/async/RuntimeContext.cpp +0 -199
  272. package/cpp/rnwgpu/async/RuntimeContext.h +0 -134
  273. package/lib/commonjs/skia/types/WebGPU.d.ts +0 -184
  274. package/lib/commonjs/skia/types/WebGPU.js +0 -105
  275. package/lib/commonjs/skia/types/WebGPU.js.map +0 -1
  276. package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -8
  277. package/lib/commonjs/specs/WebGPUViewNativeComponent.js +0 -10
  278. package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +0 -1
  279. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  280. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +0 -103
  281. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +0 -1
  282. package/lib/commonjs/specs/utils.d.ts +0 -1
  283. package/lib/commonjs/specs/utils.js +0 -11
  284. package/lib/commonjs/specs/utils.js.map +0 -1
  285. package/lib/commonjs/views/WebGPUCanvas.d.ts +0 -33
  286. package/lib/commonjs/views/WebGPUCanvas.js +0 -79
  287. package/lib/commonjs/views/WebGPUCanvas.js.map +0 -1
  288. package/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -23
  289. package/lib/commonjs/views/WebGPUCanvas.web.js +0 -20
  290. package/lib/commonjs/views/WebGPUCanvas.web.js.map +0 -1
  291. package/lib/module/skia/types/WebGPU.d.ts +0 -184
  292. package/lib/module/skia/types/WebGPU.js +0 -99
  293. package/lib/module/skia/types/WebGPU.js.map +0 -1
  294. package/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -8
  295. package/lib/module/specs/WebGPUViewNativeComponent.js +0 -4
  296. package/lib/module/specs/WebGPUViewNativeComponent.js.map +0 -1
  297. package/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  298. package/lib/module/specs/WebGPUViewNativeComponent.web.js +0 -96
  299. package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +0 -1
  300. package/lib/module/specs/utils.d.ts +0 -1
  301. package/lib/module/specs/utils.js +0 -5
  302. package/lib/module/specs/utils.js.map +0 -1
  303. package/lib/module/views/WebGPUCanvas.d.ts +0 -33
  304. package/lib/module/views/WebGPUCanvas.js +0 -70
  305. package/lib/module/views/WebGPUCanvas.js.map +0 -1
  306. package/lib/module/views/WebGPUCanvas.web.d.ts +0 -23
  307. package/lib/module/views/WebGPUCanvas.web.js +0 -12
  308. package/lib/module/views/WebGPUCanvas.web.js.map +0 -1
  309. package/lib/typescript/lib/commonjs/skia/types/WebGPU.d.ts +0 -2
  310. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -4
  311. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -3
  312. package/lib/typescript/lib/commonjs/specs/utils.d.ts +0 -2
  313. package/lib/typescript/lib/commonjs/views/WebGPUCanvas.d.ts +0 -6
  314. package/lib/typescript/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -6
  315. package/lib/typescript/lib/module/skia/types/WebGPU.d.ts +0 -31
  316. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -2
  317. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -2
  318. package/lib/typescript/lib/module/specs/utils.d.ts +0 -1
  319. package/lib/typescript/lib/module/views/WebGPUCanvas.d.ts +0 -7
  320. package/lib/typescript/lib/module/views/WebGPUCanvas.web.d.ts +0 -8
  321. package/lib/typescript/src/skia/types/WebGPU.d.ts +0 -184
  322. package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +0 -8
  323. package/lib/typescript/src/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  324. package/lib/typescript/src/specs/utils.d.ts +0 -1
  325. package/lib/typescript/src/views/WebGPUCanvas.d.ts +0 -33
  326. package/lib/typescript/src/views/WebGPUCanvas.web.d.ts +0 -23
  327. package/src/skia/types/WebGPU.ts +0 -226
  328. package/src/specs/WebGPUViewNativeComponent.ts +0 -11
  329. package/src/specs/WebGPUViewNativeComponent.web.ts +0 -110
  330. package/src/specs/utils.ts +0 -4
  331. package/src/views/WebGPUCanvas.tsx +0 -125
  332. package/src/views/WebGPUCanvas.web.tsx +0 -36
@@ -1,7 +1,9 @@
1
1
  #pragma once
2
2
 
3
3
  #include <memory>
4
+ #include <optional>
4
5
 
6
+ #include "JsiSkConverters.h"
5
7
  #include "JsiSkData.h"
6
8
  #include "JsiSkDispatcher.h"
7
9
  #include "JsiSkMatrix.h"
@@ -56,22 +58,15 @@ public:
56
58
  }
57
59
  }
58
60
 
59
- JSI_HOST_FUNCTION(makeShader) {
60
- auto tmx = (SkTileMode)arguments[0].asNumber();
61
- auto tmy = (SkTileMode)arguments[1].asNumber();
62
- auto fm = (SkFilterMode)arguments[2].asNumber();
63
- auto m = count > 3 && !arguments[3].isUndefined()
64
- ? JsiSkMatrix::fromValue(runtime, arguments[3]).get()
65
- : nullptr;
66
-
67
- auto tr = count > 4 && !arguments[4].isUndefined()
68
- ? JsiSkRect::fromValue(runtime, arguments[4]).get()
69
- : nullptr;
70
-
71
- // Create shader
72
- auto shader = getObject()->makeShader(tmx, tmy, fm, m, tr);
73
- return makeJsiObject(runtime,
74
- std::make_shared<JsiSkShader>(getContext(), shader));
61
+ std::shared_ptr<JsiSkShader>
62
+ makeShader(double tmx, double tmy, double fm,
63
+ std::optional<std::shared_ptr<SkMatrix>> m,
64
+ std::optional<std::shared_ptr<SkRect>> tr) {
65
+ auto shader = getObject()->makeShader(
66
+ static_cast<SkTileMode>(tmx), static_cast<SkTileMode>(tmy),
67
+ static_cast<SkFilterMode>(fm), m.has_value() ? m->get() : nullptr,
68
+ tr.has_value() ? tr->get() : nullptr);
69
+ return std::make_shared<JsiSkShader>(getContext(), shader);
75
70
  }
76
71
 
77
72
  JSI_HOST_FUNCTION(serialize) {
@@ -103,8 +98,7 @@ public:
103
98
 
104
99
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
105
100
  installCommon(runtime, prototype);
106
- installHostMethod(runtime, prototype, "makeShader",
107
- &JsiSkPicture::makeShader);
101
+ installMethod(runtime, prototype, "makeShader", &JsiSkPicture::makeShader);
108
102
  installHostMethod(runtime, prototype, "serialize",
109
103
  &JsiSkPicture::serialize);
110
104
  }
@@ -3,6 +3,7 @@
3
3
  #include <memory>
4
4
 
5
5
  #include "JsiSkCanvas.h"
6
+ #include "JsiSkConverters.h"
6
7
  #include "JsiSkNativeObjects.h"
7
8
  #include "JsiSkPicture.h"
8
9
  #include "JsiSkRect.h"
@@ -30,33 +31,31 @@ public:
30
31
  SkPictureRecorder>(
31
32
  context, std::make_shared<SkPictureRecorder>()) {}
32
33
 
33
- JSI_HOST_FUNCTION(beginRecording) {
34
+ std::shared_ptr<JsiSkCanvas>
35
+ beginRecording(JsiOptional<std::shared_ptr<SkRect>> rect) {
34
36
  SkCanvas *canvas;
35
- if (count > 0 && !arguments[0].isUndefined()) {
36
- auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
37
+ if (rect.has_value()) {
37
38
  SkRTreeFactory factory;
38
- canvas = getObject()->beginRecording(*rect, &factory);
39
+ canvas = getObject()->beginRecording(**rect, &factory);
39
40
  } else {
40
41
  SkISize size = SkISize::Make(2'000'000, 2'000'000);
41
- SkRect rect = SkRect::Make(size);
42
- canvas = getObject()->beginRecording(rect, nullptr);
42
+ SkRect bounds = SkRect::Make(size);
43
+ canvas = getObject()->beginRecording(bounds, nullptr);
43
44
  }
44
- return makeJsiObject(runtime,
45
- std::make_shared<JsiSkCanvas>(getContext(), canvas));
45
+ return std::make_shared<JsiSkCanvas>(getContext(), canvas);
46
46
  }
47
47
 
48
- JSI_HOST_FUNCTION(finishRecordingAsPicture) {
48
+ std::shared_ptr<JsiSkPicture> finishRecordingAsPicture() {
49
49
  auto picture = getObject()->finishRecordingAsPicture();
50
- return makeJsiObject(runtime, std::make_shared<JsiSkPicture>(
51
- getContext(), std::move(picture)));
50
+ return std::make_shared<JsiSkPicture>(getContext(), std::move(picture));
52
51
  }
53
52
 
54
53
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
55
54
  installCommon(runtime, prototype);
56
- installHostMethod(runtime, prototype, "beginRecording",
57
- &JsiSkPictureRecorder::beginRecording);
58
- installHostMethod(runtime, prototype, "finishRecordingAsPicture",
59
- &JsiSkPictureRecorder::finishRecordingAsPicture);
55
+ installMethod(runtime, prototype, "beginRecording",
56
+ &JsiSkPictureRecorder::beginRecording);
57
+ installMethod(runtime, prototype, "finishRecordingAsPicture",
58
+ &JsiSkPictureRecorder::finishRecordingAsPicture);
60
59
  }
61
60
 
62
61
  size_t getMemoryPressure() override { return 1024 * 1024; }
@@ -23,14 +23,14 @@ class JsiSkPoint
23
23
  public:
24
24
  static constexpr const char *CLASS_NAME = "Point";
25
25
 
26
- JSI_PROPERTY_GET(x) { return static_cast<double>(getObject()->x()); }
26
+ double getX() { return static_cast<double>(getObject()->x()); }
27
27
 
28
- JSI_PROPERTY_GET(y) { return static_cast<double>(getObject()->y()); }
28
+ double getY() { return static_cast<double>(getObject()->y()); }
29
29
 
30
30
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
31
31
  installCommon(runtime, prototype);
32
- installHostGetter(runtime, prototype, "x", &JsiSkPoint::get_x);
33
- installHostGetter(runtime, prototype, "y", &JsiSkPoint::get_y);
32
+ installGetter(runtime, prototype, "x", &JsiSkPoint::getX);
33
+ installGetter(runtime, prototype, "y", &JsiSkPoint::getY);
34
34
  }
35
35
 
36
36
  JsiSkPoint(std::shared_ptr<RNSkPlatformContext> context, const SkPoint &point)
@@ -26,22 +26,21 @@ class JsiSkRRect
26
26
  public:
27
27
  static constexpr const char *CLASS_NAME = "RRect";
28
28
 
29
- JSI_PROPERTY_GET(rx) {
29
+ double getRx() {
30
30
  return static_cast<double>(getObject()->getSimpleRadii().x());
31
31
  }
32
- JSI_PROPERTY_GET(ry) {
32
+ double getRy() {
33
33
  return static_cast<double>(getObject()->getSimpleRadii().y());
34
34
  }
35
- JSI_PROPERTY_GET(rect) {
36
- return makeJsiObject(runtime, std::make_shared<JsiSkRect>(
37
- getContext(), getObject()->getBounds()));
35
+ std::shared_ptr<JsiSkRect> getRect() {
36
+ return std::make_shared<JsiSkRect>(getContext(), getObject()->getBounds());
38
37
  }
39
38
 
40
39
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
41
40
  installCommon(runtime, prototype);
42
- installHostGetter(runtime, prototype, "rx", &JsiSkRRect::get_rx);
43
- installHostGetter(runtime, prototype, "ry", &JsiSkRRect::get_ry);
44
- installHostGetter(runtime, prototype, "rect", &JsiSkRRect::get_rect);
41
+ installGetter(runtime, prototype, "rx", &JsiSkRRect::getRx);
42
+ installGetter(runtime, prototype, "ry", &JsiSkRRect::getRy);
43
+ installGetter(runtime, prototype, "rect", &JsiSkRRect::getRect);
45
44
  }
46
45
 
47
46
  JsiSkRRect(std::shared_ptr<RNSkPlatformContext> context, const SkRRect &rect)
@@ -28,38 +28,25 @@ public:
28
28
  : JsiSkWrappingSharedPtrNativeObject<JsiSkRSXform, SkRSXform>(
29
29
  std::move(context), std::make_shared<SkRSXform>(rsxform)) {}
30
30
 
31
- JSI_PROPERTY_GET(scos) {
32
- return jsi::Value(SkScalarToDouble(getObject()->fSCos));
33
- }
34
- JSI_PROPERTY_GET(ssin) {
35
- return jsi::Value(SkScalarToDouble(getObject()->fSSin));
36
- }
37
- JSI_PROPERTY_GET(tx) {
38
- return jsi::Value(SkScalarToDouble(getObject()->fTx));
39
- }
40
- JSI_PROPERTY_GET(ty) {
41
- return jsi::Value(SkScalarToDouble(getObject()->fTy));
42
- }
31
+ double getScos() { return SkScalarToDouble(getObject()->fSCos); }
32
+ double getSsin() { return SkScalarToDouble(getObject()->fSSin); }
33
+ double getTx() { return SkScalarToDouble(getObject()->fTx); }
34
+ double getTy() { return SkScalarToDouble(getObject()->fTy); }
43
35
 
44
36
  #pragma clang diagnostic push
45
37
  #pragma clang diagnostic ignored "-Woverloaded-virtual"
46
- JSI_HOST_FUNCTION(set) {
47
- auto scos = arguments[0].asNumber();
48
- auto ssin = arguments[1].asNumber();
49
- auto tx = arguments[2].asNumber();
50
- auto ty = arguments[3].asNumber();
38
+ void set(double scos, double ssin, double tx, double ty) {
51
39
  getObject()->set(scos, ssin, tx, ty);
52
- return jsi::Value::undefined();
53
40
  }
54
41
  #pragma clang diagnostic pop
55
42
 
56
43
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
57
44
  installCommon(runtime, prototype);
58
- installHostGetter(runtime, prototype, "scos", &JsiSkRSXform::get_scos);
59
- installHostGetter(runtime, prototype, "ssin", &JsiSkRSXform::get_ssin);
60
- installHostGetter(runtime, prototype, "tx", &JsiSkRSXform::get_tx);
61
- installHostGetter(runtime, prototype, "ty", &JsiSkRSXform::get_ty);
62
- installHostMethod(runtime, prototype, "set", &JsiSkRSXform::set);
45
+ installGetter(runtime, prototype, "scos", &JsiSkRSXform::getScos);
46
+ installGetter(runtime, prototype, "ssin", &JsiSkRSXform::getSsin);
47
+ installGetter(runtime, prototype, "tx", &JsiSkRSXform::getTx);
48
+ installGetter(runtime, prototype, "ty", &JsiSkRSXform::getTy);
49
+ installMethod(runtime, prototype, "set", &JsiSkRSXform::set);
63
50
  }
64
51
 
65
52
  /**
@@ -22,43 +22,35 @@ class JsiSkRect : public JsiSkWrappingSharedPtrNativeObject<JsiSkRect, SkRect> {
22
22
  public:
23
23
  static constexpr const char *CLASS_NAME = "Rect";
24
24
 
25
- JSI_PROPERTY_GET(x) { return static_cast<double>(getObject()->x()); }
26
- JSI_PROPERTY_GET(y) { return static_cast<double>(getObject()->y()); }
27
- JSI_PROPERTY_GET(width) { return static_cast<double>(getObject()->width()); }
28
- JSI_PROPERTY_GET(height) {
29
- return static_cast<double>(getObject()->height());
30
- }
31
- JSI_PROPERTY_GET(left) { return static_cast<double>(getObject()->left()); }
32
- JSI_PROPERTY_GET(top) { return static_cast<double>(getObject()->top()); }
33
- JSI_PROPERTY_GET(right) { return static_cast<double>(getObject()->right()); }
34
- JSI_PROPERTY_GET(bottom) {
35
- return static_cast<double>(getObject()->bottom());
36
- }
37
-
38
- JSI_HOST_FUNCTION(setXYWH) {
39
- getObject()->setXYWH(arguments[0].asNumber(), arguments[1].asNumber(),
40
- arguments[2].asNumber(), arguments[3].asNumber());
41
- return jsi::Value::undefined();
25
+ double getX() { return static_cast<double>(getObject()->x()); }
26
+ double getY() { return static_cast<double>(getObject()->y()); }
27
+ double getWidth() { return static_cast<double>(getObject()->width()); }
28
+ double getHeight() { return static_cast<double>(getObject()->height()); }
29
+ double getLeft() { return static_cast<double>(getObject()->left()); }
30
+ double getTop() { return static_cast<double>(getObject()->top()); }
31
+ double getRight() { return static_cast<double>(getObject()->right()); }
32
+ double getBottom() { return static_cast<double>(getObject()->bottom()); }
33
+
34
+ void setXYWH(double x, double y, double width, double height) {
35
+ getObject()->setXYWH(x, y, width, height);
42
36
  }
43
37
 
44
- JSI_HOST_FUNCTION(setLTRB) {
45
- getObject()->setLTRB(arguments[0].asNumber(), arguments[1].asNumber(),
46
- arguments[2].asNumber(), arguments[3].asNumber());
47
- return jsi::Value::undefined();
38
+ void setLTRB(double left, double top, double right, double bottom) {
39
+ getObject()->setLTRB(left, top, right, bottom);
48
40
  }
49
41
 
50
42
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
51
43
  installCommon(runtime, prototype);
52
- installHostGetter(runtime, prototype, "x", &JsiSkRect::get_x);
53
- installHostGetter(runtime, prototype, "y", &JsiSkRect::get_y);
54
- installHostGetter(runtime, prototype, "width", &JsiSkRect::get_width);
55
- installHostGetter(runtime, prototype, "height", &JsiSkRect::get_height);
56
- installHostGetter(runtime, prototype, "left", &JsiSkRect::get_left);
57
- installHostGetter(runtime, prototype, "top", &JsiSkRect::get_top);
58
- installHostGetter(runtime, prototype, "right", &JsiSkRect::get_right);
59
- installHostGetter(runtime, prototype, "bottom", &JsiSkRect::get_bottom);
60
- installHostMethod(runtime, prototype, "setXYWH", &JsiSkRect::setXYWH);
61
- installHostMethod(runtime, prototype, "setLTRB", &JsiSkRect::setLTRB);
44
+ installGetter(runtime, prototype, "x", &JsiSkRect::getX);
45
+ installGetter(runtime, prototype, "y", &JsiSkRect::getY);
46
+ installGetter(runtime, prototype, "width", &JsiSkRect::getWidth);
47
+ installGetter(runtime, prototype, "height", &JsiSkRect::getHeight);
48
+ installGetter(runtime, prototype, "left", &JsiSkRect::getLeft);
49
+ installGetter(runtime, prototype, "top", &JsiSkRect::getTop);
50
+ installGetter(runtime, prototype, "right", &JsiSkRect::getRight);
51
+ installGetter(runtime, prototype, "bottom", &JsiSkRect::getBottom);
52
+ installMethod(runtime, prototype, "setXYWH", &JsiSkRect::setXYWH);
53
+ installMethod(runtime, prototype, "setLTRB", &JsiSkRect::setLTRB);
62
54
  }
63
55
 
64
56
  /**
@@ -5,6 +5,7 @@
5
5
  #include <utility>
6
6
  #include <vector>
7
7
 
8
+ #include "JsiSkConverters.h"
8
9
  #include "JsiSkMatrix.h"
9
10
  #include "JsiSkNativeObjects.h"
10
11
  #include "JsiSkShader.h"
@@ -36,108 +37,95 @@ struct RuntimeEffectUniform {
36
37
  bool isInteger;
37
38
  };
38
39
 
40
+ } // namespace RNSkia
41
+
42
+ namespace RNJsi {
43
+
44
+ // RuntimeEffectUniform -> {columns, rows, slot, isInteger}
45
+ template <> struct JSIConverter<RNSkia::RuntimeEffectUniform> {
46
+ static jsi::Value toJSI(jsi::Runtime &runtime,
47
+ const RNSkia::RuntimeEffectUniform &u) {
48
+ jsi::Object result(runtime);
49
+ result.setProperty(runtime, "columns", u.columns);
50
+ result.setProperty(runtime, "rows", u.rows);
51
+ result.setProperty(runtime, "slot", u.slot);
52
+ result.setProperty(runtime, "isInteger", u.isInteger);
53
+ return result;
54
+ }
55
+ };
56
+
57
+ } // namespace RNJsi
58
+
59
+ namespace RNSkia {
60
+
39
61
  class JsiSkRuntimeEffect
40
62
  : public JsiSkWrappingSkPtrNativeObject<JsiSkRuntimeEffect,
41
63
  SkRuntimeEffect> {
42
64
  public:
43
65
  static constexpr const char *CLASS_NAME = "RuntimeEffect";
44
66
 
45
- JSI_HOST_FUNCTION(makeShader) {
46
- auto uniforms = castUniforms(runtime, arguments[0]);
47
-
48
- auto matrix =
49
- count >= 2 && !arguments[1].isUndefined() && !arguments[1].isNull()
50
- ? JsiSkMatrix::fromValue(runtime, arguments[1]).get()
51
- : nullptr;
52
-
53
- // Create and return shader as host object
54
- auto shader =
55
- getObject()->makeShader(std::move(uniforms), nullptr, 0, matrix);
56
-
57
- return makeJsiObject(runtime, std::make_shared<JsiSkShader>(
58
- getContext(), std::move(shader)));
67
+ std::shared_ptr<JsiSkShader>
68
+ makeShader(std::vector<double> uniformValues,
69
+ JsiOptional<std::shared_ptr<SkMatrix>> matrix) {
70
+ auto uniforms = castUniforms(uniformValues);
71
+ auto shader = getObject()->makeShader(
72
+ std::move(uniforms), nullptr, 0,
73
+ matrix.has_value() ? matrix->get() : nullptr);
74
+ return std::make_shared<JsiSkShader>(getContext(), std::move(shader));
59
75
  }
60
76
 
61
- JSI_HOST_FUNCTION(makeShaderWithChildren) {
62
- auto uniforms = castUniforms(runtime, arguments[0]);
63
-
64
- // Children
65
- std::vector<sk_sp<SkShader>> children;
66
- auto jsiChildren = arguments[1].asObject(runtime).asArray(runtime);
67
- auto jsiChildCount = jsiChildren.size(runtime);
68
- children.reserve(jsiChildCount);
69
- for (int i = 0; i < jsiChildCount; i++) {
70
- auto shader = getJsiObject<JsiSkShader>(
71
- runtime, jsiChildren.getValueAtIndex(runtime, i))
72
- ->getObject();
73
- children.push_back(shader);
74
- }
75
-
76
- auto matrix =
77
- count >= 3 && !arguments[2].isUndefined() && !arguments[2].isNull()
78
- ? JsiSkMatrix::fromValue(runtime, arguments[2]).get()
79
- : nullptr;
80
-
81
- // Create and return shader as host object
82
- auto shader = getObject()->makeShader(std::move(uniforms), children.data(),
83
- children.size(), matrix);
84
-
85
- return makeJsiObject(runtime, std::make_shared<JsiSkShader>(
86
- getContext(), std::move(shader)));
77
+ std::shared_ptr<JsiSkShader>
78
+ makeShaderWithChildren(std::vector<double> uniformValues,
79
+ std::vector<sk_sp<SkShader>> children,
80
+ JsiOptional<std::shared_ptr<SkMatrix>> matrix) {
81
+ auto uniforms = castUniforms(uniformValues);
82
+ auto shader = getObject()->makeShader(
83
+ std::move(uniforms), children.data(), children.size(),
84
+ matrix.has_value() ? matrix->get() : nullptr);
85
+ return std::make_shared<JsiSkShader>(getContext(), std::move(shader));
87
86
  }
88
87
 
89
- JSI_HOST_FUNCTION(getUniformCount) {
88
+ int getUniformCount() {
90
89
  return static_cast<int>(getObject()->uniforms().size());
91
90
  }
92
91
 
93
- JSI_HOST_FUNCTION(getUniformFloatCount) {
92
+ int getUniformFloatCount() {
94
93
  return static_cast<int>(getObject()->uniformSize() / sizeof(float));
95
94
  }
96
95
 
97
- JSI_HOST_FUNCTION(getUniformName) {
98
- auto i = static_cast<int>(arguments[0].asNumber());
96
+ std::string getUniformName(int i) {
99
97
  if (i < 0 || i >= getObject()->uniforms().size()) {
100
- throw jsi::JSError(runtime, "invalid uniform index");
98
+ throw std::runtime_error("invalid uniform index");
101
99
  }
102
100
  auto it = getObject()->uniforms().begin() + i;
103
- return jsi::String::createFromAscii(runtime, std::string(it->name));
101
+ return std::string(it->name);
104
102
  }
105
103
 
106
- JSI_HOST_FUNCTION(getUniform) {
107
- auto i = static_cast<int>(arguments[0].asNumber());
104
+ RuntimeEffectUniform getUniform(int i) {
108
105
  if (i < 0 || i >= getObject()->uniforms().size()) {
109
- throw jsi::JSError(runtime, "invalid uniform index");
106
+ throw std::runtime_error("invalid uniform index");
110
107
  }
111
108
  auto it = getObject()->uniforms().begin() + i;
112
- auto result = jsi::Object(runtime);
113
- RuntimeEffectUniform su = fromUniform(*it);
114
- result.setProperty(runtime, "columns", su.columns);
115
- result.setProperty(runtime, "rows", su.rows);
116
- result.setProperty(runtime, "slot", su.slot);
117
- result.setProperty(runtime, "isInteger", su.isInteger);
118
- return result;
109
+ return fromUniform(*it);
119
110
  }
120
111
 
121
- JSI_HOST_FUNCTION(source) {
122
- return jsi::String::createFromAscii(runtime, getObject()->source());
123
- }
112
+ std::string source() { return std::string(getObject()->source()); }
124
113
 
125
114
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
126
115
  installCommon(runtime, prototype);
127
- installHostMethod(runtime, prototype, "makeShader",
128
- &JsiSkRuntimeEffect::makeShader);
129
- installHostMethod(runtime, prototype, "makeShaderWithChildren",
130
- &JsiSkRuntimeEffect::makeShaderWithChildren);
131
- installHostMethod(runtime, prototype, "getUniformCount",
132
- &JsiSkRuntimeEffect::getUniformCount);
133
- installHostMethod(runtime, prototype, "getUniformFloatCount",
134
- &JsiSkRuntimeEffect::getUniformFloatCount);
135
- installHostMethod(runtime, prototype, "getUniformName",
136
- &JsiSkRuntimeEffect::getUniformName);
137
- installHostMethod(runtime, prototype, "getUniform",
138
- &JsiSkRuntimeEffect::getUniform);
139
- installHostMethod(runtime, prototype, "source",
140
- &JsiSkRuntimeEffect::source);
116
+ installMethod(runtime, prototype, "makeShader",
117
+ &JsiSkRuntimeEffect::makeShader);
118
+ installMethod(runtime, prototype, "makeShaderWithChildren",
119
+ &JsiSkRuntimeEffect::makeShaderWithChildren);
120
+ installMethod(runtime, prototype, "getUniformCount",
121
+ &JsiSkRuntimeEffect::getUniformCount);
122
+ installMethod(runtime, prototype, "getUniformFloatCount",
123
+ &JsiSkRuntimeEffect::getUniformFloatCount);
124
+ installMethod(runtime, prototype, "getUniformName",
125
+ &JsiSkRuntimeEffect::getUniformName);
126
+ installMethod(runtime, prototype, "getUniform",
127
+ &JsiSkRuntimeEffect::getUniform);
128
+ installMethod(runtime, prototype, "source", &JsiSkRuntimeEffect::source);
141
129
  }
142
130
 
143
131
  JsiSkRuntimeEffect(std::shared_ptr<RNSkPlatformContext> context,
@@ -206,17 +194,13 @@ public:
206
194
  }
207
195
 
208
196
  private:
209
- sk_sp<SkData> castUniforms(jsi::Runtime &runtime, const jsi::Value &value) {
210
- auto jsiUniforms = value.asObject(runtime).asArray(runtime);
211
- auto jsiUniformsSize = jsiUniforms.size(runtime);
212
-
197
+ sk_sp<SkData> castUniforms(const std::vector<double> &values) {
213
198
  // verify size of input uniforms
214
- if (jsiUniformsSize * sizeof(float) != getObject()->uniformSize()) {
215
- std::string msg =
199
+ if (values.size() * sizeof(float) != getObject()->uniformSize()) {
200
+ throw std::runtime_error(
216
201
  "Uniforms size differs from effect's uniform size. Received " +
217
- std::to_string(jsiUniformsSize) + " expected " +
218
- std::to_string(getObject()->uniformSize() / sizeof(float));
219
- throw jsi::JSError(runtime, msg.c_str());
202
+ std::to_string(values.size()) + " expected " +
203
+ std::to_string(getObject()->uniformSize() / sizeof(float)));
220
204
  }
221
205
 
222
206
  auto uniforms = SkData::MakeUninitialized(getObject()->uniformSize());
@@ -228,7 +212,7 @@ private:
228
212
  RuntimeEffectUniform reu = fromUniform(*it);
229
213
  for (std::size_t j = 0; j < reu.columns * reu.rows; ++j) {
230
214
  const std::size_t offset = reu.slot + j;
231
- float fValue = jsiUniforms.getValueAtIndex(runtime, offset).asNumber();
215
+ float fValue = static_cast<float>(values[offset]);
232
216
  int iValue = static_cast<int>(fValue);
233
217
  auto value = reu.isInteger ? SkBits2Float(iValue) : fValue;
234
218
  memcpy(SkTAddOffset<void>(uniforms->writable_data(),
@@ -18,26 +18,22 @@ class JsiSkRuntimeEffectFactory
18
18
  public:
19
19
  static constexpr const char *CLASS_NAME = "RuntimeEffectFactory";
20
20
 
21
- JSI_HOST_FUNCTION(Make) {
22
- auto sksl = arguments[0].asString(runtime).utf8(runtime);
21
+ std::shared_ptr<JsiSkRuntimeEffect> Make(std::string sksl) {
23
22
  auto result = SkRuntimeEffect::MakeForShader(SkString(sksl));
24
23
  auto effect = result.effect;
25
24
  auto errorText = result.errorText;
26
25
  if (!effect) {
27
- throw jsi::JSError(runtime, std::string("Error in sksl:\n" +
28
- std::string(errorText.c_str()))
29
- .c_str());
30
- return jsi::Value::null();
26
+ throw std::runtime_error("Error in sksl:\n" +
27
+ std::string(errorText.c_str()));
31
28
  }
32
- return makeJsiObject(runtime, std::make_shared<JsiSkRuntimeEffect>(
33
- getContext(), std::move(effect)));
29
+ return std::make_shared<JsiSkRuntimeEffect>(getContext(),
30
+ std::move(effect));
34
31
  }
35
32
 
36
33
  size_t getMemoryPressure() override { return 1024; }
37
34
 
38
35
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
39
- installHostMethod(runtime, prototype, "Make",
40
- &JsiSkRuntimeEffectFactory::Make);
36
+ installMethod(runtime, prototype, "Make", &JsiSkRuntimeEffectFactory::Make);
41
37
  }
42
38
 
43
39
  explicit JsiSkRuntimeEffectFactory(
@@ -1,6 +1,7 @@
1
1
  #pragma once
2
2
 
3
3
  #include <memory>
4
+ #include <string>
4
5
  #include <utility>
5
6
  #include <vector>
6
7
 
@@ -35,26 +36,16 @@ public:
35
36
  SkRuntimeShaderBuilder>(
36
37
  std::move(context), std::make_shared<SkRuntimeShaderBuilder>(rt)) {}
37
38
 
38
- JSI_HOST_FUNCTION(setUniform) {
39
- auto name = arguments[0].asString(runtime).utf8(runtime);
40
- auto jsiValue = arguments[1].asObject(runtime).asArray(runtime);
41
- auto size = jsiValue.size(runtime);
42
- std::vector<SkScalar> value;
43
- value.reserve(size);
44
- for (int i = 0; i < size; i++) {
45
- auto e = jsiValue.getValueAtIndex(runtime, i).asNumber();
46
- value.push_back(e);
47
- }
39
+ void setUniform(std::string name, std::vector<float> value) {
48
40
  getObject()
49
41
  ->uniform(name.c_str())
50
- .set(value.data(), static_cast<int>(size));
51
- return jsi::Value::undefined();
42
+ .set(value.data(), static_cast<int>(value.size()));
52
43
  }
53
44
 
54
45
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
55
46
  installCommon(runtime, prototype);
56
- installHostMethod(runtime, prototype, "setUniform",
57
- &JsiSkRuntimeShaderBuilder::setUniform);
47
+ installMethod(runtime, prototype, "setUniform",
48
+ &JsiSkRuntimeShaderBuilder::setUniform);
58
49
  }
59
50
 
60
51
  /**
@@ -29,18 +29,18 @@ public:
29
29
 
30
30
  ~JsiSkSVG() = default;
31
31
 
32
- JSI_HOST_FUNCTION(width) {
32
+ double width() {
33
33
  return static_cast<double>(getObject()->containerSize().width());
34
34
  }
35
35
 
36
- JSI_HOST_FUNCTION(height) {
36
+ double height() {
37
37
  return static_cast<double>(getObject()->containerSize().height());
38
38
  }
39
39
 
40
40
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
41
41
  installCommon(runtime, prototype);
42
- installHostMethod(runtime, prototype, "width", &JsiSkSVG::width);
43
- installHostMethod(runtime, prototype, "height", &JsiSkSVG::height);
42
+ installMethod(runtime, prototype, "width", &JsiSkSVG::width);
43
+ installMethod(runtime, prototype, "height", &JsiSkSVG::height);
44
44
  }
45
45
 
46
46
  /**