@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,9 +1,16 @@
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"
13
+ #include "JsiSkConverters.h"
7
14
  #include "JsiSkNativeObjects.h"
8
15
  #include "JsiSkPoint.h"
9
16
  #include "JsiSkRect.h"
@@ -153,84 +160,64 @@ public:
153
160
  static constexpr const char *CLASS_NAME = "Skottie";
154
161
 
155
162
  // #region Properties
156
- JSI_HOST_FUNCTION(duration) {
163
+ double duration() {
157
164
  return static_cast<double>(getObject()->_animation->duration());
158
165
  }
159
- JSI_HOST_FUNCTION(fps) {
160
- return static_cast<double>(getObject()->_animation->fps());
161
- }
166
+ double fps() { return static_cast<double>(getObject()->_animation->fps()); }
162
167
  // #endregion
163
168
 
164
169
  // #region Methods
165
- JSI_HOST_FUNCTION(seekFrame) {
170
+ void seekFrame(double frame,
171
+ std::optional<std::shared_ptr<SkRect>> rectParam) {
166
172
  sksg::InvalidationController ic;
167
- getObject()->_animation->seekFrame(arguments[0].asNumber(), &ic);
173
+ getObject()->_animation->seekFrame(frame, &ic);
168
174
  auto bounds = ic.bounds();
169
- if (count >= 2) {
170
- auto rect = JsiSkRect::fromValue(runtime, arguments[1]);
171
- if (rect != nullptr) {
172
- rect->setXYWH(bounds.x(), bounds.y(), bounds.width(), bounds.height());
173
- }
175
+ if (rectParam.has_value() && *rectParam != nullptr) {
176
+ auto rect = *rectParam;
177
+ rect->setXYWH(bounds.x(), bounds.y(), bounds.width(), bounds.height());
174
178
  }
175
- return jsi::Value::undefined();
176
179
  }
177
180
 
178
- JSI_HOST_FUNCTION(size) {
179
- auto size = getObject()->_animation->size();
180
- jsi::Object jsiSize(runtime);
181
- jsiSize.setProperty(runtime, "width", size.width());
182
- jsiSize.setProperty(runtime, "height", size.height());
183
- return jsiSize;
184
- }
181
+ SkSize size() { return getObject()->_animation->size(); }
185
182
 
186
- JSI_HOST_FUNCTION(render) {
187
- auto canvas = getJsiObject<JsiSkCanvas>(runtime, arguments[0])->getCanvas();
188
- if (count > 1) {
189
- auto rect = JsiSkRect::fromValue(runtime, arguments[1]);
190
- 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());
191
188
  } else {
192
189
  getObject()->_animation->render(canvas);
193
190
  }
194
-
195
- return jsi::Value::undefined();
196
191
  }
197
192
 
198
- JSI_HOST_FUNCTION(version) {
199
- return jsi::String::createFromUtf8(
200
- runtime, getObject()->_animation->version().c_str());
193
+ std::string version() {
194
+ return std::string(getObject()->_animation->version().c_str());
201
195
  }
202
196
 
203
- JSI_HOST_FUNCTION(setColor) {
204
- if (count < 2) {
205
- 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;
206
200
  }
207
- auto key = arguments[0].asString(runtime).utf8(runtime);
208
- auto color = JsiSkColor::fromValue(runtime, arguments[1]);
209
- return getObject()->_propManager->setColor(key, color);
201
+ return getObject()->_propManager->setColor(*key, *color);
210
202
  }
211
203
 
212
- JSI_HOST_FUNCTION(setOpacity) {
213
- if (count < 2) {
214
- 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;
215
207
  }
216
-
217
- auto key = arguments[0].asString(runtime).utf8(runtime);
218
- auto opacity = arguments[1].asNumber();
219
- return getObject()->_propManager->setOpacity(key, opacity);
208
+ return getObject()->_propManager->setOpacity(*key, *opacity);
220
209
  }
221
210
 
222
- JSI_HOST_FUNCTION(setText) {
223
- if (count < 3) {
224
- 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;
225
215
  }
226
- auto key = arguments[0].asString(runtime).utf8(runtime);
227
- auto text = arguments[1].asString(runtime).utf8(runtime);
228
- auto size = arguments[2].asNumber();
229
216
  // preserve all other text fields
230
- auto t = getObject()->_propManager->getText(key);
231
- t.fText = SkString(text);
232
- t.fTextSize = size;
233
- 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);
234
221
  }
235
222
 
236
223
  JSI_HOST_FUNCTION(getTextProps) {
@@ -251,27 +238,24 @@ public:
251
238
  return props;
252
239
  }
253
240
 
254
- JSI_HOST_FUNCTION(setTransform) {
255
- if (count < 7) {
256
- 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;
257
249
  }
258
250
 
259
- auto key = arguments[0].asString(runtime).utf8(runtime);
260
- auto anchor = JsiSkPoint::fromValue(runtime, arguments[1]);
261
- auto position = JsiSkPoint::fromValue(runtime, arguments[2]);
262
- auto scale = JsiSkPoint::fromValue(runtime, arguments[3]);
263
- auto rotation = arguments[4].asNumber();
264
- auto skew = arguments[5].asNumber();
265
- auto skewAxis = arguments[6].asNumber();
266
-
267
251
  skottie::TransformPropertyValue transform;
268
252
  transform.fAnchorPoint = {anchor->x(), anchor->y()};
269
253
  transform.fPosition = {position->x(), position->y()};
270
254
  transform.fScale = {scale->x(), scale->y()};
271
- transform.fRotation = rotation;
272
- transform.fSkew = skew;
273
- transform.fSkewAxis = skewAxis;
274
- 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);
275
259
  }
276
260
 
277
261
  JSI_HOST_FUNCTION(getSlotInfo) {
@@ -325,52 +309,47 @@ public:
325
309
  return slotInfoJS;
326
310
  }
327
311
 
328
- JSI_HOST_FUNCTION(setColorSlot) {
329
- if (count < 2) {
330
- 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;
331
316
  }
332
- auto slotID = arguments[0].asString(runtime).utf8(runtime);
333
- auto color = JsiSkColor::fromValue(runtime, arguments[1]);
334
- return getObject()->_slotManager->setColorSlot(SkString(slotID), color);
317
+ return getObject()->_slotManager->setColorSlot(SkString(*slotID), *color);
335
318
  }
336
319
 
337
- JSI_HOST_FUNCTION(setScalarSlot) {
338
- if (count < 2) {
339
- 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;
340
324
  }
341
- auto slotID = arguments[0].asString(runtime).utf8(runtime);
342
- auto scalar = arguments[1].asNumber();
343
- return getObject()->_slotManager->setScalarSlot(SkString(slotID), scalar);
325
+ return getObject()->_slotManager->setScalarSlot(SkString(*slotID),
326
+ *scalar);
344
327
  }
345
328
 
346
- JSI_HOST_FUNCTION(setVec2Slot) {
347
- if (count < 2) {
348
- 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;
349
333
  }
350
- auto slotID = arguments[0].asString(runtime).utf8(runtime);
351
- auto point = JsiSkPoint::fromValue(runtime, arguments[1]);
352
334
  SkV2 vec2{point->x(), point->y()};
353
- return getObject()->_slotManager->setVec2Slot(SkString(slotID), vec2);
335
+ return getObject()->_slotManager->setVec2Slot(SkString(*slotID), vec2);
354
336
  }
355
337
 
356
- JSI_HOST_FUNCTION(setTextSlot) {
357
- if (count < 2) {
358
- return jsi::Value(false);
359
- }
360
- 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) {
361
341
  // TODO: Implement proper text slot setting
362
- return jsi::Value(false);
342
+ return false;
363
343
  }
364
344
 
365
- JSI_HOST_FUNCTION(setImageSlot) {
366
- if (count < 2) {
367
- 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;
368
349
  }
369
- auto slotID = arguments[0].asString(runtime).utf8(runtime);
370
- auto assetName = arguments[1].asString(runtime).utf8(runtime);
371
350
  return getObject()->_slotManager->setImageSlot(
372
- SkString(slotID), getObject()->_resourceProvider->loadImageAsset(
373
- nullptr, assetName.data(), nullptr));
351
+ SkString(*slotID), getObject()->_resourceProvider->loadImageAsset(
352
+ nullptr, assetName->data(), nullptr));
374
353
  }
375
354
 
376
355
  JSI_HOST_FUNCTION(getColorSlot) {
@@ -384,15 +363,15 @@ public:
384
363
  return jsi::Value::null();
385
364
  }
386
365
 
387
- JSI_HOST_FUNCTION(getScalarSlot) {
388
- if (count < 1) {
389
- 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;
390
370
  }
391
- auto slotID = arguments[0].asString(runtime).utf8(runtime);
392
- if (auto v = getObject()->_slotManager->getScalarSlot(SkString(slotID))) {
393
- return jsi::Value(v.value());
371
+ if (auto v = getObject()->_slotManager->getScalarSlot(SkString(*slotID))) {
372
+ return static_cast<double>(v.value());
394
373
  }
395
- return jsi::Value::null();
374
+ return nullptr;
396
375
  }
397
376
 
398
377
  JSI_HOST_FUNCTION(getVec2Slot) {
@@ -551,29 +530,28 @@ public:
551
530
 
552
531
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
553
532
  installCommon(runtime, prototype);
554
- installHostMethod(runtime, prototype, "duration", &JsiSkSkottie::duration);
555
- installHostMethod(runtime, prototype, "fps", &JsiSkSkottie::fps);
556
- installHostMethod(runtime, prototype, "seekFrame",
557
- &JsiSkSkottie::seekFrame);
558
- installHostMethod(runtime, prototype, "render", &JsiSkSkottie::render);
559
- installHostMethod(runtime, prototype, "size", &JsiSkSkottie::size);
560
- installHostMethod(runtime, prototype, "version", &JsiSkSkottie::version);
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);
561
539
  installHostMethod(runtime, prototype, "getSlotInfo",
562
540
  &JsiSkSkottie::getSlotInfo);
563
- installHostMethod(runtime, prototype, "setColorSlot",
564
- &JsiSkSkottie::setColorSlot);
565
- installHostMethod(runtime, prototype, "setScalarSlot",
566
- &JsiSkSkottie::setScalarSlot);
567
- installHostMethod(runtime, prototype, "setVec2Slot",
568
- &JsiSkSkottie::setVec2Slot);
569
- installHostMethod(runtime, prototype, "setTextSlot",
570
- &JsiSkSkottie::setTextSlot);
571
- installHostMethod(runtime, prototype, "setImageSlot",
572
- &JsiSkSkottie::setImageSlot);
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);
573
551
  installHostMethod(runtime, prototype, "getColorSlot",
574
552
  &JsiSkSkottie::getColorSlot);
575
- installHostMethod(runtime, prototype, "getScalarSlot",
576
- &JsiSkSkottie::getScalarSlot);
553
+ installMethod(runtime, prototype, "getScalarSlot",
554
+ &JsiSkSkottie::getScalarSlot);
577
555
  installHostMethod(runtime, prototype, "getVec2Slot",
578
556
  &JsiSkSkottie::getVec2Slot);
579
557
  installHostMethod(runtime, prototype, "getTextSlot",
@@ -586,8 +564,8 @@ public:
586
564
  &JsiSkSkottie::getTransformProps);
587
565
  installHostMethod(runtime, prototype, "getTextProps",
588
566
  &JsiSkSkottie::getTextProps);
589
- installHostMethod(runtime, prototype, "setColor", &JsiSkSkottie::setColor);
590
- installHostMethod(runtime, prototype, "setText", &JsiSkSkottie::setText);
567
+ installMethod(runtime, prototype, "setColor", &JsiSkSkottie::setColor);
568
+ installMethod(runtime, prototype, "setText", &JsiSkSkottie::setText);
591
569
  }
592
570
  // #endregion
593
571
 
@@ -7,6 +7,7 @@
7
7
 
8
8
  #include <jsi/jsi.h>
9
9
 
10
+ #include "JsiSkConverters.h"
10
11
  #include "JsiSkDispatcher.h"
11
12
  #include "JsiSkNativeObjects.h"
12
13
  #include "JsiTextureInfo.h"
@@ -67,27 +68,25 @@ public:
67
68
  }
68
69
 
69
70
  // TODO-API: Properties?
70
- JSI_HOST_FUNCTION(width) { return static_cast<double>(getObject()->width()); }
71
- JSI_HOST_FUNCTION(height) {
72
- return static_cast<double>(getObject()->height());
73
- }
71
+ double width() { return static_cast<double>(getObject()->width()); }
72
+ double height() { return static_cast<double>(getObject()->height()); }
74
73
 
75
- JSI_HOST_FUNCTION(getCanvas) {
74
+ std::shared_ptr<JsiSkCanvas> getCanvas() {
76
75
  auto surface = getObject();
77
76
  auto canvas =
78
77
  std::make_shared<JsiSkCanvas>(getContext(), surface->getCanvas());
79
78
  // Keep a reference to the owning surface so the canvas can read pixels back
80
79
  // through a snapshot on Graphite (which lacks synchronous canvas readback).
81
80
  canvas->setSurface(surface);
82
- return makeJsiObject(runtime, std::move(canvas));
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) {
@@ -195,13 +193,12 @@ public:
195
193
 
196
194
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
197
195
  installCommon(runtime, prototype);
198
- installHostMethod(runtime, prototype, "width", &JsiSkSurface::width);
199
- installHostMethod(runtime, prototype, "height", &JsiSkSurface::height);
200
- installHostMethod(runtime, prototype, "getCanvas",
201
- &JsiSkSurface::getCanvas);
196
+ installMethod(runtime, prototype, "width", &JsiSkSurface::width);
197
+ installMethod(runtime, prototype, "height", &JsiSkSurface::height);
198
+ installMethod(runtime, prototype, "getCanvas", &JsiSkSurface::getCanvas);
202
199
  installHostMethod(runtime, prototype, "makeImageSnapshot",
203
200
  &JsiSkSurface::makeImageSnapshot);
204
- installHostMethod(runtime, prototype, "flush", &JsiSkSurface::flush);
201
+ installMethod(runtime, prototype, "flush", &JsiSkSurface::flush);
205
202
  installHostMethod(runtime, prototype, "getNativeTextureUnstable",
206
203
  &JsiSkSurface::getNativeTextureUnstable);
207
204
  }
@@ -2,6 +2,7 @@
2
2
 
3
3
  #include <memory>
4
4
  #include <utility>
5
+ #include <variant>
5
6
 
6
7
  #include <jsi/jsi.h>
7
8
 
@@ -24,16 +25,14 @@ class JsiSkSurfaceFactory : public JsiSkNativeObject<JsiSkSurfaceFactory> {
24
25
  public:
25
26
  static constexpr const char *CLASS_NAME = "SurfaceFactory";
26
27
 
27
- JSI_HOST_FUNCTION(Make) {
28
- auto width = static_cast<int>(arguments[0].asNumber());
29
- auto height = static_cast<int>(arguments[1].asNumber());
28
+ std::variant<std::nullptr_t, std::shared_ptr<JsiSkSurface>> Make(int width,
29
+ int height) {
30
30
  auto imageInfo = SkImageInfo::MakeN32Premul(width, height);
31
31
  auto surface = SkSurfaces::Raster(imageInfo);
32
32
  if (surface == nullptr) {
33
- return jsi::Value::null();
33
+ return nullptr;
34
34
  }
35
- return makeJsiObject(runtime, std::make_shared<JsiSkSurface>(
36
- getContext(), std::move(surface)));
35
+ return std::make_shared<JsiSkSurface>(getContext(), std::move(surface));
37
36
  }
38
37
 
39
38
  JSI_HOST_FUNCTION(MakeOffscreen) {
@@ -63,7 +62,7 @@ public:
63
62
  size_t getMemoryPressure() override { return 2048; }
64
63
 
65
64
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
66
- installHostMethod(runtime, prototype, "Make", &JsiSkSurfaceFactory::Make);
65
+ installMethod(runtime, prototype, "Make", &JsiSkSurfaceFactory::Make);
67
66
  installHostMethod(runtime, prototype, "MakeOffscreen",
68
67
  &JsiSkSurfaceFactory::MakeOffscreen);
69
68
  }
@@ -1,11 +1,13 @@
1
1
  #pragma once
2
2
 
3
3
  #include <memory>
4
+ #include <string>
4
5
  #include <utility>
5
6
  #include <vector>
6
7
 
7
8
  #include <jsi/jsi.h>
8
9
 
10
+ #include "JsiSkConverters.h"
9
11
  #include "JsiSkFont.h"
10
12
  #include "JsiSkNativeObjects.h"
11
13
  #include "JsiSkRSXform.h"
@@ -26,88 +28,63 @@ class JsiSkTextBlobFactory : public JsiSkNativeObject<JsiSkTextBlobFactory> {
26
28
  public:
27
29
  static constexpr const char *CLASS_NAME = "TextBlobFactory";
28
30
 
29
- JSI_HOST_FUNCTION(MakeFromText) {
30
- auto str = arguments[0].asString(runtime).utf8(runtime);
31
- auto font = JsiSkFont::fromValue(runtime, arguments[1]);
31
+ std::shared_ptr<JsiSkTextBlob> MakeFromText(std::string str,
32
+ std::shared_ptr<SkFont> font) {
32
33
  auto textBlob = SkTextBlob::MakeFromString(str.c_str(), *font);
33
- return makeJsiObject(runtime, std::make_shared<JsiSkTextBlob>(
34
- getContext(), std::move(textBlob)));
34
+ return std::make_shared<JsiSkTextBlob>(getContext(), std::move(textBlob));
35
35
  }
36
36
 
37
- JSI_HOST_FUNCTION(MakeFromGlyphs) {
38
- auto jsiGlyphs = arguments[0].asObject(runtime).asArray(runtime);
39
- auto font = JsiSkFont::fromValue(runtime, arguments[1]);
37
+ std::shared_ptr<JsiSkTextBlob> MakeFromGlyphs(std::vector<int> glyphIds,
38
+ std::shared_ptr<SkFont> font) {
40
39
  int bytesPerGlyph = 2;
41
40
  std::vector<SkGlyphID> glyphs;
42
- int glyphsSize = static_cast<int>(jsiGlyphs.size(runtime));
43
- glyphs.reserve(glyphsSize);
44
- for (int i = 0; i < glyphsSize; i++) {
45
- glyphs.push_back(jsiGlyphs.getValueAtIndex(runtime, i).asNumber());
41
+ glyphs.reserve(glyphIds.size());
42
+ for (auto glyph : glyphIds) {
43
+ glyphs.push_back(static_cast<SkGlyphID>(glyph));
46
44
  }
47
45
  auto textBlob =
48
46
  SkTextBlob::MakeFromText(glyphs.data(), glyphs.size() * bytesPerGlyph,
49
47
  *font, SkTextEncoding::kGlyphID);
50
- return makeJsiObject(runtime, std::make_shared<JsiSkTextBlob>(
51
- getContext(), std::move(textBlob)));
48
+ return std::make_shared<JsiSkTextBlob>(getContext(), std::move(textBlob));
52
49
  }
53
50
 
54
- JSI_HOST_FUNCTION(MakeFromRSXform) {
55
- auto str = arguments[0].asString(runtime).utf8(runtime);
56
- auto jsiRsxforms = arguments[1].asObject(runtime).asArray(runtime);
57
- auto font = JsiSkFont::fromValue(runtime, arguments[2]);
58
- std::vector<SkRSXform> rsxforms;
59
- int rsxformsSize = static_cast<int>(jsiRsxforms.size(runtime));
60
- rsxforms.reserve(rsxformsSize);
61
- for (int i = 0; i < rsxformsSize; i++) {
62
- auto rsxform = JsiSkRSXform::fromValue(
63
- runtime, jsiRsxforms.getValueAtIndex(runtime, i));
64
- rsxforms.push_back(*rsxform);
65
- }
51
+ std::shared_ptr<JsiSkTextBlob>
52
+ MakeFromRSXform(std::string str, std::vector<SkRSXform> rsxforms,
53
+ std::shared_ptr<SkFont> font) {
66
54
  auto x = SkSpan(rsxforms.data(), rsxforms.size());
67
55
  auto textBlob =
68
56
  SkTextBlob::MakeFromRSXform(str.c_str(), str.length(), x, *font);
69
- return makeJsiObject(runtime, std::make_shared<JsiSkTextBlob>(
70
- getContext(), std::move(textBlob)));
57
+ return std::make_shared<JsiSkTextBlob>(getContext(), std::move(textBlob));
71
58
  }
72
59
 
73
- JSI_HOST_FUNCTION(MakeFromRSXformGlyphs) {
74
- auto jsiGlyphs = arguments[0].asObject(runtime).asArray(runtime);
75
- auto jsiRsxforms = arguments[1].asObject(runtime).asArray(runtime);
76
- auto font = JsiSkFont::fromValue(runtime, arguments[2]);
60
+ std::shared_ptr<JsiSkTextBlob>
61
+ MakeFromRSXformGlyphs(std::vector<int> glyphIds,
62
+ std::vector<SkRSXform> rsxforms,
63
+ std::shared_ptr<SkFont> font) {
77
64
  int bytesPerGlyph = 2;
78
65
  std::vector<SkGlyphID> glyphs;
79
- int glyphsSize = static_cast<int>(jsiGlyphs.size(runtime));
80
- glyphs.reserve(glyphsSize);
81
- for (int i = 0; i < glyphsSize; i++) {
82
- glyphs.push_back(jsiGlyphs.getValueAtIndex(runtime, i).asNumber());
83
- }
84
- std::vector<SkRSXform> rsxforms;
85
- int rsxformsSize = static_cast<int>(jsiRsxforms.size(runtime));
86
- rsxforms.reserve(rsxformsSize);
87
- for (int i = 0; i < rsxformsSize; i++) {
88
- auto rsxform = JsiSkRSXform::fromValue(
89
- runtime, jsiRsxforms.getValueAtIndex(runtime, i));
90
- rsxforms.push_back(*rsxform);
66
+ glyphs.reserve(glyphIds.size());
67
+ for (auto glyph : glyphIds) {
68
+ glyphs.push_back(static_cast<SkGlyphID>(glyph));
91
69
  }
92
70
  auto x = SkSpan(rsxforms.data(), rsxforms.size());
93
71
  auto textBlob = SkTextBlob::MakeFromRSXform(
94
72
  glyphs.data(), glyphs.size() * bytesPerGlyph, x, *font,
95
73
  SkTextEncoding::kGlyphID);
96
- return makeJsiObject(runtime, std::make_shared<JsiSkTextBlob>(
97
- getContext(), std::move(textBlob)));
74
+ return std::make_shared<JsiSkTextBlob>(getContext(), std::move(textBlob));
98
75
  }
99
76
 
100
77
  size_t getMemoryPressure() override { return 2048; }
101
78
 
102
79
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
103
- installHostMethod(runtime, prototype, "MakeFromText",
104
- &JsiSkTextBlobFactory::MakeFromText);
105
- installHostMethod(runtime, prototype, "MakeFromGlyphs",
106
- &JsiSkTextBlobFactory::MakeFromGlyphs);
107
- installHostMethod(runtime, prototype, "MakeFromRSXform",
108
- &JsiSkTextBlobFactory::MakeFromRSXform);
109
- installHostMethod(runtime, prototype, "MakeFromRSXformGlyphs",
110
- &JsiSkTextBlobFactory::MakeFromRSXformGlyphs);
80
+ installMethod(runtime, prototype, "MakeFromText",
81
+ &JsiSkTextBlobFactory::MakeFromText);
82
+ installMethod(runtime, prototype, "MakeFromGlyphs",
83
+ &JsiSkTextBlobFactory::MakeFromGlyphs);
84
+ installMethod(runtime, prototype, "MakeFromRSXform",
85
+ &JsiSkTextBlobFactory::MakeFromRSXform);
86
+ installMethod(runtime, prototype, "MakeFromRSXformGlyphs",
87
+ &JsiSkTextBlobFactory::MakeFromRSXformGlyphs);
111
88
  }
112
89
 
113
90
  explicit JsiSkTextBlobFactory(std::shared_ptr<RNSkPlatformContext> context)
@@ -1,11 +1,13 @@
1
1
  #pragma once
2
2
 
3
3
  #include <memory>
4
+ #include <string>
4
5
  #include <utility>
5
6
  #include <vector>
6
7
 
7
8
  #include <jsi/jsi.h>
8
9
 
10
+ #include "JsiSkConverters.h"
9
11
  #include "JsiSkNativeObjects.h"
10
12
  #include "utils/RNSkLog.h"
11
13
 
@@ -32,11 +34,10 @@ public:
32
34
  : JsiSkWrappingSkPtrNativeObject<JsiSkTypeface, SkTypeface>(
33
35
  std::move(context), std::move(typeface)) {}
34
36
 
35
- JSI_HOST_FUNCTION(getGlyphIDs) {
36
- auto str = arguments[0].asString(runtime).utf8(runtime);
37
+ std::vector<int> getGlyphIDs(std::string str, JsiOptional<int> numGlyphs) {
37
38
  int numGlyphIDs =
38
- count > 1 && !arguments[1].isNull() && !arguments[1].isUndefined()
39
- ? static_cast<int>(arguments[1].asNumber())
39
+ numGlyphs.has_value()
40
+ ? *numGlyphs
40
41
  : getObject()->textToGlyphs(str.c_str(), str.length(),
41
42
  SkTextEncoding::kUTF8,
42
43
  SkSpan<SkGlyphID>(nullptr, 0));
@@ -45,12 +46,7 @@ public:
45
46
  getObject()->textToGlyphs(
46
47
  str.c_str(), str.length(), SkTextEncoding::kUTF8,
47
48
  SkSpan(static_cast<SkGlyphID *>(glyphIDs.data()), numGlyphIDs));
48
- auto jsiGlyphIDs = jsi::Array(runtime, numGlyphIDs);
49
- for (int i = 0; i < numGlyphIDs; i++) {
50
- jsiGlyphIDs.setValueAtIndex(runtime, i,
51
- jsi::Value(static_cast<int>(glyphIDs[i])));
52
- }
53
- return jsiGlyphIDs;
49
+ return std::vector<int>(glyphIDs.begin(), glyphIDs.end());
54
50
  }
55
51
 
56
52
  size_t getMemoryPressure() override {
@@ -85,8 +81,8 @@ public:
85
81
 
86
82
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
87
83
  installCommon(runtime, prototype);
88
- installHostMethod(runtime, prototype, "getGlyphIDs",
89
- &JsiSkTypeface::getGlyphIDs);
84
+ installMethod(runtime, prototype, "getGlyphIDs",
85
+ &JsiSkTypeface::getGlyphIDs);
90
86
  }
91
87
  };
92
88