@shopify/react-native-skia 2.0.0-next.1 → 2.0.0-next.3

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 (329) hide show
  1. package/android/build.gradle +25 -11
  2. package/android/cpp/jni/JniPlatformContext.cpp +1 -0
  3. package/{ios/RNSkia-iOS → apple}/MetalContext.h +0 -5
  4. package/{ios/RNSkia-iOS → apple}/MetalWindowContext.mm +4 -0
  5. package/{ios/RNSkia-iOS/RNSkiOSPlatformContext.h → apple/RNSkApplePlatformContext.h} +7 -3
  6. package/{ios/RNSkia-iOS/RNSkiOSPlatformContext.mm → apple/RNSkApplePlatformContext.mm} +19 -19
  7. package/{ios/RNSkia-iOS/RNSkiOSVideo.h → apple/RNSkAppleVideo.h} +3 -3
  8. package/{ios/RNSkia-iOS/RNSkiOSVideo.mm → apple/RNSkAppleVideo.mm} +14 -14
  9. package/{ios/RNSkia-iOS/RNSkiOSView.h → apple/RNSkAppleView.h} +4 -4
  10. package/{ios/RNSkia-iOS/RNSkiOSView.mm → apple/RNSkAppleView.mm} +4 -4
  11. package/{ios/RNSkia-iOS → apple}/RNSkMetalCanvasProvider.mm +6 -1
  12. package/{ios/RNSkia-iOS → apple}/SkiaManager.mm +2 -2
  13. package/{ios/RNSkia-iOS → apple}/SkiaPictureView.mm +2 -2
  14. package/{ios/RNSkia-iOS → apple}/SkiaPictureViewManager.mm +6 -2
  15. package/{ios/RNSkia-iOS → apple}/SkiaUIView.h +12 -4
  16. package/{ios/RNSkia-iOS → apple}/SkiaUIView.mm +11 -7
  17. package/{ios/RNSkia-iOS → apple}/ViewScreenshotService.h +4 -0
  18. package/{ios/RNSkia-iOS → apple}/ViewScreenshotService.mm +4 -0
  19. package/cpp/api/JsiSkCanvas.h +45 -2
  20. package/cpp/api/JsiSkContourMeasure.h +1 -1
  21. package/cpp/api/JsiSkHostObjects.h +21 -10
  22. package/cpp/api/JsiSkParagraph.h +17 -27
  23. package/cpp/api/JsiSkPathEffect.h +1 -1
  24. package/cpp/api/JsiSkPictureFactory.h +1 -1
  25. package/cpp/api/JsiSkShaderFactory.h +43 -8
  26. package/cpp/api/JsiSkVertices.h +14 -3
  27. package/cpp/api/recorder/Drawings.h +35 -5
  28. package/cpp/api/recorder/Shaders.h +40 -0
  29. package/cpp/rnskia/DawnContext.h +1 -1
  30. package/cpp/skia/include/codec/SkCodec.h +7 -2
  31. package/cpp/skia/include/config/SkUserConfig.h +11 -0
  32. package/cpp/skia/include/core/SkCanvas.h +11 -7
  33. package/cpp/skia/include/core/SkColor.h +10 -0
  34. package/cpp/skia/include/core/SkColorSpace.h +184 -2
  35. package/cpp/skia/include/core/SkColorType.h +114 -32
  36. package/cpp/skia/include/core/SkFontScanner.h +5 -8
  37. package/cpp/skia/include/core/SkFontStyle.h +1 -1
  38. package/cpp/skia/include/core/SkMaskFilter.h +0 -8
  39. package/cpp/skia/include/core/SkMilestone.h +1 -1
  40. package/cpp/skia/include/core/SkPath.h +1 -1
  41. package/cpp/skia/include/core/SkRRect.h +3 -1
  42. package/cpp/skia/include/core/SkShader.h +3 -3
  43. package/cpp/skia/include/core/SkString.h +8 -8
  44. package/cpp/skia/include/core/SkSurface.h +14 -0
  45. package/cpp/skia/include/core/SkTypeface.h +24 -7
  46. package/cpp/skia/include/effects/SkGradientShader.h +6 -1
  47. package/cpp/skia/include/effects/SkRuntimeEffect.h +1 -0
  48. package/cpp/skia/include/encode/SkPngEncoder.h +14 -0
  49. package/cpp/skia/include/gpu/GpuTypes.h +9 -0
  50. package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +135 -133
  51. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +5 -0
  52. package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkarounds.h +3 -3
  53. package/cpp/skia/include/gpu/ganesh/GrTypes.h +14 -9
  54. package/cpp/skia/include/gpu/graphite/Context.h +25 -2
  55. package/cpp/skia/include/gpu/graphite/ContextOptions.h +23 -5
  56. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +20 -1
  57. package/cpp/skia/include/gpu/graphite/Image.h +1 -0
  58. package/cpp/skia/include/gpu/graphite/LogPriority.h +36 -0
  59. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +52 -0
  60. package/cpp/skia/include/gpu/graphite/Recorder.h +6 -0
  61. package/cpp/skia/include/gpu/graphite/Recording.h +3 -1
  62. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +4 -36
  63. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypesUtils.h +48 -0
  64. package/cpp/skia/include/gpu/graphite/precompile/Precompile.h +3 -2
  65. package/cpp/skia/include/pathops/SkPathOps.h +9 -1
  66. package/cpp/skia/include/ports/SkFontMgr_FontConfigInterface.h +3 -0
  67. package/cpp/skia/include/private/SkPathRef.h +15 -21
  68. package/cpp/skia/include/private/base/SkAttributes.h +16 -10
  69. package/cpp/skia/include/private/base/SkMutex.h +8 -0
  70. package/cpp/skia/include/private/base/SkTArray.h +1 -1
  71. package/cpp/skia/include/private/base/SkTDArray.h +1 -1
  72. package/cpp/skia/include/private/base/SkTemplates.h +24 -11
  73. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +1 -1
  74. package/cpp/skia/include/sksl/SkSLDebugTrace.h +0 -3
  75. package/cpp/skia/modules/skcms/src/Transform_inl.h +20 -20
  76. package/cpp/skia/modules/skcms/src/skcms_Transform.h +4 -3
  77. package/cpp/skia/modules/skcms/src/skcms_public.h +19 -15
  78. package/cpp/skia/modules/skresources/include/SkResources.h +3 -1
  79. package/cpp/skia/modules/svg/include/SkSVGCircle.h +1 -1
  80. package/cpp/skia/modules/svg/include/SkSVGContainer.h +1 -1
  81. package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
  82. package/cpp/skia/modules/svg/include/SkSVGImage.h +2 -2
  83. package/cpp/skia/modules/svg/include/SkSVGPath.h +1 -1
  84. package/cpp/skia/modules/svg/include/SkSVGPoly.h +1 -1
  85. package/cpp/skia/modules/svg/include/SkSVGRect.h +1 -1
  86. package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +2 -0
  87. package/cpp/skia/modules/svg/include/SkSVGShape.h +1 -0
  88. package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
  89. package/cpp/skia/modules/svg/include/SkSVGTransformableNode.h +4 -0
  90. package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
  91. package/cpp/skia/src/core/SkLRUCache.h +19 -13
  92. package/cpp/skia/src/core/SkTHash.h +50 -4
  93. package/cpp/skia/src/gpu/ganesh/gl/GrGLDefines.h +1 -0
  94. package/lib/commonjs/__tests__/setup.d.ts +18 -0
  95. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +4 -3
  96. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -1
  97. package/lib/commonjs/headless/index.d.ts +1 -0
  98. package/lib/commonjs/headless/index.js +12 -0
  99. package/lib/commonjs/headless/index.js.map +1 -1
  100. package/lib/commonjs/mock/index.js +1 -2
  101. package/lib/commonjs/mock/index.js.map +1 -1
  102. package/lib/commonjs/renderer/Canvas.d.ts +1 -2
  103. package/lib/commonjs/renderer/Canvas.js +3 -1
  104. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  105. package/lib/commonjs/skia/web/Host.d.ts +4 -6
  106. package/lib/commonjs/skia/web/Host.js +23 -10
  107. package/lib/commonjs/skia/web/Host.js.map +1 -1
  108. package/lib/commonjs/skia/web/JsiSkCanvas.js +15 -15
  109. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  110. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +1 -1
  111. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  112. package/lib/commonjs/skia/web/JsiSkFont.js +3 -3
  113. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  114. package/lib/commonjs/skia/web/JsiSkFontMgr.js +1 -1
  115. package/lib/commonjs/skia/web/JsiSkFontMgr.js.map +1 -1
  116. package/lib/commonjs/skia/web/JsiSkImage.js +6 -6
  117. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  118. package/lib/commonjs/skia/web/JsiSkImageFactory.js +3 -3
  119. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  120. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +9 -9
  121. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  122. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js +1 -1
  123. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  124. package/lib/commonjs/skia/web/JsiSkPaint.js +3 -3
  125. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  126. package/lib/commonjs/skia/web/JsiSkPath.js +4 -4
  127. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  128. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +3 -3
  129. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  130. package/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +1 -1
  131. package/lib/commonjs/skia/web/JsiSkPathFactory.js +2 -2
  132. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  133. package/lib/commonjs/skia/web/JsiSkPicture.js +1 -1
  134. package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
  135. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +5 -5
  136. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  137. package/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.js +1 -1
  138. package/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.js.map +1 -1
  139. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +1 -1
  140. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
  141. package/lib/commonjs/skia/web/JsiSkia.js +4 -3
  142. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  143. package/lib/commonjs/skia/web/JsiVideo.js +2 -1
  144. package/lib/commonjs/skia/web/JsiVideo.js.map +1 -1
  145. package/lib/commonjs/sksg/HostConfig.js +3 -1
  146. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  147. package/lib/commonjs/sksg/Recorder/Core.d.ts +1 -5
  148. package/lib/commonjs/sksg/Recorder/Core.js +12 -4
  149. package/lib/commonjs/sksg/Recorder/Core.js.map +1 -1
  150. package/lib/commonjs/sksg/Recorder/Player.d.ts +1 -1
  151. package/lib/commonjs/sksg/Recorder/Player.js +4 -5
  152. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  153. package/lib/commonjs/sksg/Recorder/commands/Box.js +4 -6
  154. package/lib/commonjs/sksg/Recorder/commands/Box.js.map +1 -1
  155. package/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +1 -3
  156. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +1 -58
  157. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  158. package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +2 -0
  159. package/lib/commonjs/specs/NativeSkiaModule.web.js +10 -1
  160. package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
  161. package/lib/module/__tests__/setup.d.ts +18 -0
  162. package/lib/module/external/reanimated/useAnimatedImageValue.js +4 -3
  163. package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -1
  164. package/lib/module/headless/index.d.ts +1 -0
  165. package/lib/module/headless/index.js +1 -0
  166. package/lib/module/headless/index.js.map +1 -1
  167. package/lib/module/mock/index.js +1 -2
  168. package/lib/module/mock/index.js.map +1 -1
  169. package/lib/module/renderer/Canvas.d.ts +1 -2
  170. package/lib/module/renderer/Canvas.js +3 -1
  171. package/lib/module/renderer/Canvas.js.map +1 -1
  172. package/lib/module/skia/web/Host.d.ts +4 -6
  173. package/lib/module/skia/web/Host.js +21 -8
  174. package/lib/module/skia/web/Host.js.map +1 -1
  175. package/lib/module/skia/web/JsiSkCanvas.js +15 -15
  176. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  177. package/lib/module/skia/web/JsiSkColorFilterFactory.js +1 -1
  178. package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  179. package/lib/module/skia/web/JsiSkFont.js +4 -4
  180. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  181. package/lib/module/skia/web/JsiSkFontMgr.js +2 -2
  182. package/lib/module/skia/web/JsiSkFontMgr.js.map +1 -1
  183. package/lib/module/skia/web/JsiSkImage.js +6 -6
  184. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  185. package/lib/module/skia/web/JsiSkImageFactory.js +4 -4
  186. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  187. package/lib/module/skia/web/JsiSkImageFilterFactory.js +10 -10
  188. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  189. package/lib/module/skia/web/JsiSkMaskFilterFactory.js +1 -1
  190. package/lib/module/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  191. package/lib/module/skia/web/JsiSkPaint.js +3 -3
  192. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  193. package/lib/module/skia/web/JsiSkPath.js +4 -4
  194. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  195. package/lib/module/skia/web/JsiSkPathEffectFactory.js +4 -4
  196. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  197. package/lib/module/skia/web/JsiSkPathFactory.d.ts +1 -1
  198. package/lib/module/skia/web/JsiSkPathFactory.js +3 -3
  199. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  200. package/lib/module/skia/web/JsiSkPicture.js +1 -1
  201. package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
  202. package/lib/module/skia/web/JsiSkShaderFactory.js +5 -5
  203. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  204. package/lib/module/skia/web/JsiSkTypefaceFontProvider.js +2 -2
  205. package/lib/module/skia/web/JsiSkTypefaceFontProvider.js.map +1 -1
  206. package/lib/module/skia/web/JsiSkVerticesFactory.js +1 -1
  207. package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
  208. package/lib/module/skia/web/JsiSkia.js +4 -3
  209. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  210. package/lib/module/skia/web/JsiVideo.js +2 -1
  211. package/lib/module/skia/web/JsiVideo.js.map +1 -1
  212. package/lib/module/sksg/HostConfig.js +3 -1
  213. package/lib/module/sksg/HostConfig.js.map +1 -1
  214. package/lib/module/sksg/Recorder/Core.d.ts +1 -5
  215. package/lib/module/sksg/Recorder/Core.js +10 -2
  216. package/lib/module/sksg/Recorder/Core.js.map +1 -1
  217. package/lib/module/sksg/Recorder/Player.d.ts +1 -1
  218. package/lib/module/sksg/Recorder/Player.js +5 -6
  219. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  220. package/lib/module/sksg/Recorder/commands/Box.js +5 -7
  221. package/lib/module/sksg/Recorder/commands/Box.js.map +1 -1
  222. package/lib/module/sksg/Recorder/commands/Drawing.d.ts +1 -3
  223. package/lib/module/sksg/Recorder/commands/Drawing.js +2 -58
  224. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  225. package/lib/module/specs/NativeSkiaModule.web.d.ts +2 -0
  226. package/lib/module/specs/NativeSkiaModule.web.js +10 -1
  227. package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
  228. package/lib/typescript/lib/commonjs/mock/index.d.ts +2 -2
  229. package/lib/typescript/lib/commonjs/skia/index.d.ts +1 -1
  230. package/lib/typescript/lib/commonjs/skia/web/Host.d.ts +3 -5
  231. package/lib/typescript/lib/commonjs/skia/web/JsiSkFont.d.ts +1 -1
  232. package/lib/typescript/lib/commonjs/skia/web/JsiSkFontMgr.d.ts +1 -1
  233. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +1 -1
  234. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFilterFactory.d.ts +1 -1
  235. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathEffectFactory.d.ts +2 -2
  236. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +1 -1
  237. package/lib/typescript/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.d.ts +1 -1
  238. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +3 -3
  239. package/lib/typescript/lib/commonjs/skia/web/JsiVideo.d.ts +1 -1
  240. package/lib/typescript/lib/commonjs/sksg/Recorder/Core.d.ts +1 -1
  241. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +0 -1
  242. package/lib/typescript/lib/module/headless/index.d.ts +1 -0
  243. package/lib/typescript/lib/module/mock/index.d.ts +5 -5
  244. package/lib/typescript/lib/module/skia/Skia.d.ts +1 -1
  245. package/lib/typescript/lib/module/skia/Skia.web.d.ts +3 -3
  246. package/lib/typescript/lib/module/skia/web/Host.d.ts +3 -5
  247. package/lib/typescript/lib/module/skia/web/JsiSkFont.d.ts +1 -1
  248. package/lib/typescript/lib/module/skia/web/JsiSkFontMgr.d.ts +1 -1
  249. package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +1 -1
  250. package/lib/typescript/lib/module/skia/web/JsiSkImageFilterFactory.d.ts +1 -1
  251. package/lib/typescript/lib/module/skia/web/JsiSkPathEffectFactory.d.ts +2 -2
  252. package/lib/typescript/lib/module/skia/web/JsiSkPathFactory.d.ts +1 -1
  253. package/lib/typescript/lib/module/skia/web/JsiSkTypefaceFontProvider.d.ts +1 -1
  254. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +3 -3
  255. package/lib/typescript/lib/module/skia/web/JsiVideo.d.ts +1 -1
  256. package/lib/typescript/lib/module/sksg/Recorder/Core.d.ts +1 -1
  257. package/lib/typescript/lib/module/sksg/Recorder/commands/Drawing.d.ts +0 -1
  258. package/lib/typescript/src/__tests__/setup.d.ts +18 -0
  259. package/lib/typescript/src/headless/index.d.ts +1 -0
  260. package/lib/typescript/src/renderer/Canvas.d.ts +1 -2
  261. package/lib/typescript/src/skia/web/Host.d.ts +4 -6
  262. package/lib/typescript/src/skia/web/JsiSkPathFactory.d.ts +1 -1
  263. package/lib/typescript/src/sksg/Recorder/Core.d.ts +1 -5
  264. package/lib/typescript/src/sksg/Recorder/Player.d.ts +1 -1
  265. package/lib/typescript/src/sksg/Recorder/commands/Drawing.d.ts +1 -3
  266. package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +2 -0
  267. package/package.json +8 -7
  268. package/react-native-skia.podspec +3 -3
  269. package/src/__tests__/setup.ts +67 -1
  270. package/src/__tests__/snapshots/box/box-shadow-opacity.png +0 -0
  271. package/src/__tests__/snapshots/platform-buffer.png +0 -0
  272. package/src/__tests__/snapshots/screens/snapshot2-android-ci.png +0 -0
  273. package/src/external/reanimated/useAnimatedImageValue.ts +4 -3
  274. package/src/headless/index.ts +2 -1
  275. package/src/mock/index.ts +1 -2
  276. package/src/renderer/Canvas.tsx +3 -2
  277. package/src/renderer/__tests__/e2e/Box.spec.tsx +22 -0
  278. package/src/renderer/__tests__/e2e/Matrix4.spec.tsx +1 -2
  279. package/src/renderer/__tests__/e2e/NativeBuffer.spec.tsx +2 -0
  280. package/src/renderer/__tests__/e2e/Paths.spec.tsx +13 -11
  281. package/src/skia/__tests__/Enums.spec.ts +24 -2
  282. package/src/skia/__tests__/Path.spec.ts +2 -2
  283. package/src/skia/web/Host.ts +29 -11
  284. package/src/skia/web/JsiSkCanvas.ts +17 -17
  285. package/src/skia/web/JsiSkColorFilterFactory.ts +1 -1
  286. package/src/skia/web/JsiSkFont.ts +5 -5
  287. package/src/skia/web/JsiSkFontMgr.ts +3 -3
  288. package/src/skia/web/JsiSkImage.ts +14 -10
  289. package/src/skia/web/JsiSkImageFactory.ts +5 -5
  290. package/src/skia/web/JsiSkImageFilterFactory.ts +12 -22
  291. package/src/skia/web/JsiSkMaskFilterFactory.ts +1 -1
  292. package/src/skia/web/JsiSkPaint.ts +3 -3
  293. package/src/skia/web/JsiSkPath.ts +4 -4
  294. package/src/skia/web/JsiSkPathEffectFactory.ts +6 -6
  295. package/src/skia/web/JsiSkPathFactory.ts +4 -9
  296. package/src/skia/web/JsiSkPicture.ts +3 -3
  297. package/src/skia/web/JsiSkShaderFactory.ts +5 -5
  298. package/src/skia/web/JsiSkTypefaceFontProvider.ts +3 -3
  299. package/src/skia/web/JsiSkVerticesFactory.ts +1 -1
  300. package/src/skia/web/JsiSkia.ts +7 -4
  301. package/src/skia/web/JsiVideo.ts +2 -1
  302. package/src/sksg/HostConfig.ts +1 -1
  303. package/src/sksg/Recorder/Core.ts +5 -7
  304. package/src/sksg/Recorder/Player.ts +6 -7
  305. package/src/sksg/Recorder/commands/Box.ts +5 -7
  306. package/src/sksg/Recorder/commands/Drawing.ts +0 -65
  307. package/src/specs/NativeSkiaModule.web.ts +12 -2
  308. package/ios/Rnskia.xcodeproj/project.pbxproj +0 -281
  309. package/ios/Rnskia.xcworkspace/contents.xcworkspacedata +0 -7
  310. package/lib/commonjs/skia/types/Image/ColorType.web.d.ts +0 -19
  311. package/lib/commonjs/skia/types/Image/ColorType.web.js +0 -43
  312. package/lib/commonjs/skia/types/Image/ColorType.web.js.map +0 -1
  313. package/lib/module/skia/types/Image/ColorType.web.d.ts +0 -19
  314. package/lib/module/skia/types/Image/ColorType.web.js +0 -37
  315. package/lib/module/skia/types/Image/ColorType.web.js.map +0 -1
  316. package/lib/typescript/lib/commonjs/skia/types/Image/ColorType.web.d.ts +0 -2
  317. package/lib/typescript/lib/module/skia/types/Image/ColorType.web.d.ts +0 -1
  318. package/lib/typescript/src/skia/types/Image/ColorType.web.d.ts +0 -19
  319. package/src/skia/types/Image/ColorType.web.ts +0 -19
  320. /package/{ios/RNSkia-iOS → apple}/MetalContext.mm +0 -0
  321. /package/{ios/RNSkia-iOS → apple}/MetalWindowContext.h +0 -0
  322. /package/{ios/RNSkia-iOS → apple}/RNSkMetalCanvasProvider.h +0 -0
  323. /package/{ios → apple}/RNSkiaModule.h +0 -0
  324. /package/{ios → apple}/RNSkiaModule.mm +0 -0
  325. /package/{ios/RNSkia-iOS → apple}/SkiaCVPixelBufferUtils.h +0 -0
  326. /package/{ios/RNSkia-iOS → apple}/SkiaCVPixelBufferUtils.mm +0 -0
  327. /package/{ios/RNSkia-iOS → apple}/SkiaManager.h +0 -0
  328. /package/{ios/RNSkia-iOS → apple}/SkiaPictureView.h +0 -0
  329. /package/{ios/RNSkia-iOS → apple}/SkiaPictureViewManager.h +0 -0
@@ -243,6 +243,12 @@ public:
243
243
 
244
244
  auto jsiPoints = arguments[1].asObject(runtime).asArray(runtime);
245
245
  auto pointsSize = jsiPoints.size(runtime);
246
+
247
+ // Check if we have at least one point
248
+ if (pointsSize == 0) {
249
+ throw std::invalid_argument("Points array must not be empty");
250
+ }
251
+
246
252
  points.reserve(pointsSize);
247
253
 
248
254
  for (int i = 0; i < pointsSize; i++) {
@@ -274,6 +280,12 @@ public:
274
280
 
275
281
  auto jsiCubics = arguments[0].asObject(runtime).asArray(runtime);
276
282
  auto cubicsSize = jsiCubics.size(runtime);
283
+
284
+ // Validate cubic points - must be exactly 12 points
285
+ if (cubicsSize != 12) {
286
+ throw std::invalid_argument("Cubic points array must contain exactly 12 points");
287
+ }
288
+
277
289
  cubics.reserve(cubicsSize);
278
290
  for (int i = 0; i < cubicsSize; i++) {
279
291
  std::shared_ptr<SkPoint> point = JsiSkPoint::fromValue(
@@ -284,6 +296,12 @@ public:
284
296
  if (count >= 2 && !arguments[1].isNull() && !arguments[1].isUndefined()) {
285
297
  auto jsiColors = arguments[1].asObject(runtime).asArray(runtime);
286
298
  auto colorsSize = jsiColors.size(runtime);
299
+
300
+ // Validate colors array - must be exactly 4 colors
301
+ if (colorsSize != 4) {
302
+ throw std::invalid_argument("Colors array must contain exactly 4 colors");
303
+ }
304
+
287
305
  colors.reserve(colorsSize);
288
306
  for (int i = 0; i < colorsSize; i++) {
289
307
  SkColor color = JsiSkColor::fromValue(
@@ -295,6 +313,12 @@ public:
295
313
  if (count >= 3 && !arguments[2].isNull() && !arguments[2].isUndefined()) {
296
314
  auto jsiTexs = arguments[2].asObject(runtime).asArray(runtime);
297
315
  auto texsSize = jsiTexs.size(runtime);
316
+
317
+ // Validate textures array - must be exactly 4 points
318
+ if (texsSize != 4) {
319
+ throw std::invalid_argument("Texture coordinates array must contain exactly 4 points");
320
+ }
321
+
298
322
  texs.reserve(texsSize);
299
323
  for (int i = 0; i < texsSize; i++) {
300
324
  auto point = JsiSkPoint::fromValue(
@@ -306,7 +330,8 @@ public:
306
330
  auto paint =
307
331
  count >= 4 ? JsiSkPaint::fromValue(runtime, arguments[4]) : nullptr;
308
332
  auto blendMode = static_cast<SkBlendMode>(arguments[3].asNumber());
309
- _canvas->drawPatch(cubics.data(), colors.data(), texs.data(), blendMode,
333
+ _canvas->drawPatch(cubics.data(), colors.empty() ? nullptr : colors.data(),
334
+ texs.empty() ? nullptr : texs.data(), blendMode,
310
335
  *paint);
311
336
  return jsi::Value::undefined();
312
337
  }
@@ -364,6 +389,12 @@ public:
364
389
 
365
390
  std::vector<SkGlyphID> glyphs;
366
391
  int glyphsSize = static_cast<int>(jsiGlyphs.size(runtime));
392
+
393
+ // Validate that glyphs and positions arrays have the same size
394
+ if (glyphsSize != pointsSize) {
395
+ throw std::invalid_argument("Glyphs and positions arrays must have the same length");
396
+ }
397
+
367
398
  glyphs.reserve(glyphsSize);
368
399
  for (int i = 0; i < glyphsSize; i++) {
369
400
  glyphs.push_back(jsiGlyphs.getValueAtIndex(runtime, i).asNumber());
@@ -522,11 +553,22 @@ public:
522
553
  runtime, rects.getValueAtIndex(runtime, i).asObject(runtime));
523
554
  skRects.push_back(*rect.get());
524
555
  }
556
+
557
+ // Validate transforms and rects have the same size
558
+ if (xformsSize != rectsSize) {
559
+ throw std::invalid_argument("Transforms and rects arrays must have the same length");
560
+ }
525
561
 
526
562
  std::vector<SkColor> colors;
527
563
  if (count > 5 && !arguments[5].isUndefined()) {
528
564
  auto colorsArray = arguments[5].asObject(runtime).asArray(runtime);
529
565
  int colorsSize = static_cast<int>(colorsArray.size(runtime));
566
+
567
+ // Validate colors array matches the size of sprites and transforms
568
+ if (colorsSize != rectsSize) {
569
+ throw std::invalid_argument("Colors array must have the same length as rects/transforms");
570
+ }
571
+
530
572
  colors.reserve(colorsSize);
531
573
  for (int i = 0; i < colorsSize; i++) {
532
574
  // Convert from [r,g,b,a] in [0,1] to SkColor
@@ -551,7 +593,8 @@ public:
551
593
  sampling = SamplingOptionsFromValue(runtime, arguments[6]);
552
594
  }
553
595
  _canvas->drawAtlas(atlas.get(), xforms.data(), skRects.data(),
554
- colors.data(), skRects.size(), blendMode, sampling,
596
+ colors.empty() ? nullptr : colors.data(),
597
+ skRects.size(), blendMode, sampling,
555
598
  nullptr, paint.get());
556
599
 
557
600
  return jsi::Value::undefined();
@@ -34,7 +34,7 @@ public:
34
34
  SkPoint tangent;
35
35
  auto result = getObject()->getPosTan(dist, &position, &tangent);
36
36
  if (!result) {
37
- throw jsi::JSError(runtime, "getSegment() failed");
37
+ throw jsi::JSError(runtime, "getPosTan() failed");
38
38
  }
39
39
  auto posTan = jsi::Array(runtime, 2);
40
40
  auto pos = jsi::Object::createFromHostObject(
@@ -54,20 +54,21 @@ public:
54
54
 
55
55
  /**
56
56
  * Returns the underlying object exposed by this host object. This object
57
- * should be wrapped in a shared pointer of some kind
57
+ * should be wrapped in a shared pointer of some kind.
58
+ * Throws if the object has been disposed.
58
59
  * @return Underlying object
59
60
  */
60
- T getObject() { return _object; }
61
- const T getObject() const { return _object; }
61
+ T getObject() { return validateObject(); }
62
+ const T getObject() const { return validateObject(); }
62
63
 
63
64
  /**
64
- Updates the inner object with a new version of the object.
65
+ * Updates the inner object with a new version of the object.
65
66
  */
66
67
  void setObject(T object) { _object = object; }
67
68
 
68
69
  /**
69
- Dispose function that can be exposed to JS by using the JSI_API_TYPENAME
70
- macro
70
+ * Dispose function that can be exposed to JS by using the JSI_API_TYPENAME
71
+ * macro.
71
72
  */
72
73
  JSI_HOST_FUNCTION(dispose) {
73
74
  safeDispose();
@@ -76,12 +77,22 @@ public:
76
77
 
77
78
  protected:
78
79
  /**
79
- Override to implement disposale of allocated resources like smart pointers
80
- etc. This method will only be called once for each instance of this class.
80
+ * Override to implement disposal of allocated resources like smart pointers.
81
+ * This method will only be called once for each instance of this class.
81
82
  */
82
83
  virtual void releaseResources() = 0;
83
84
 
84
85
  private:
86
+ /**
87
+ * Validates that _object was not disposed and returns it.
88
+ */
89
+ T validateObject() const {
90
+ if (_isDisposed) {
91
+ throw std::runtime_error("Attempted to access a disposed object.");
92
+ }
93
+ return _object;
94
+ }
95
+
85
96
  void safeDispose() {
86
97
  if (!_isDisposed) {
87
98
  _isDisposed = true;
@@ -90,12 +101,12 @@ private:
90
101
  }
91
102
 
92
103
  /**
93
- * Wrapped object
104
+ * Wrapped object.
94
105
  */
95
106
  T _object;
96
107
 
97
108
  /**
98
- Resource disposed flag
109
+ * Resource disposed flag.
99
110
  */
100
111
  std::atomic<bool> _isDisposed = {false};
101
112
  };
@@ -24,19 +24,19 @@
24
24
  namespace RNSkia {
25
25
 
26
26
  namespace jsi = facebook::jsi;
27
-
28
27
  namespace para = skia::textlayout;
29
28
 
30
29
  /**
31
- Implementation of the Paragraph object in JSI
30
+ * Implementation of the Paragraph object in JSI
32
31
  */
33
- class JsiSkParagraph : public JsiSkHostObject {
32
+ class JsiSkParagraph
33
+ : public JsiSkWrappingSharedPtrHostObject<para::Paragraph> {
34
34
  public:
35
35
  EXPORT_JSI_API_TYPENAME(JsiSkParagraph, Paragraph)
36
36
 
37
37
  JSI_HOST_FUNCTION(layout) {
38
38
  auto width = getArgumentAsNumber(runtime, arguments, count, 0);
39
- _paragraph->layout(width);
39
+ getObject()->layout(width);
40
40
  return jsi::Value::undefined();
41
41
  }
42
42
 
@@ -45,34 +45,34 @@ public:
45
45
  getArgumentAsHostObject<JsiSkCanvas>(runtime, arguments, count, 0);
46
46
  auto x = getArgumentAsNumber(runtime, arguments, count, 1);
47
47
  auto y = getArgumentAsNumber(runtime, arguments, count, 2);
48
- _paragraph->paint(jsiCanvas->getCanvas(), x, y);
48
+ getObject()->paint(jsiCanvas->getCanvas(), x, y);
49
49
  return jsi::Value::undefined();
50
50
  }
51
51
 
52
52
  JSI_HOST_FUNCTION(getHeight) {
53
- return static_cast<double>(_paragraph->getHeight());
53
+ return static_cast<double>(getObject()->getHeight());
54
54
  }
55
55
 
56
56
  JSI_HOST_FUNCTION(getMaxWidth) {
57
- return static_cast<double>(_paragraph->getMaxWidth());
57
+ return static_cast<double>(getObject()->getMaxWidth());
58
58
  }
59
59
 
60
60
  JSI_HOST_FUNCTION(getMaxIntrinsicWidth) {
61
- return static_cast<double>(_paragraph->getMaxIntrinsicWidth());
61
+ return static_cast<double>(getObject()->getMaxIntrinsicWidth());
62
62
  }
63
63
 
64
64
  JSI_HOST_FUNCTION(getMinIntrinsicWidth) {
65
- return static_cast<double>(_paragraph->getMinIntrinsicWidth());
65
+ return static_cast<double>(getObject()->getMinIntrinsicWidth());
66
66
  }
67
67
 
68
68
  JSI_HOST_FUNCTION(getLongestLine) {
69
- return static_cast<double>(_paragraph->getLongestLine());
69
+ return static_cast<double>(getObject()->getLongestLine());
70
70
  }
71
71
 
72
72
  JSI_HOST_FUNCTION(getGlyphPositionAtCoordinate) {
73
73
  auto dx = getArgumentAsNumber(runtime, arguments, count, 0);
74
74
  auto dy = getArgumentAsNumber(runtime, arguments, count, 1);
75
- auto result = _paragraph->getGlyphPositionAtCoordinate(dx, dy);
75
+ auto result = getObject()->getGlyphPositionAtCoordinate(dx, dy);
76
76
  return result.position;
77
77
  }
78
78
 
@@ -80,8 +80,8 @@ public:
80
80
  auto start = getArgumentAsNumber(runtime, arguments, count, 0);
81
81
  auto end = getArgumentAsNumber(runtime, arguments, count, 1);
82
82
  auto result =
83
- _paragraph->getRectsForRange(start, end, para::RectHeightStyle::kTight,
84
- para::RectWidthStyle::kTight);
83
+ getObject()->getRectsForRange(start, end, para::RectHeightStyle::kTight,
84
+ para::RectWidthStyle::kTight);
85
85
  auto returnValue = jsi::Array(runtime, result.size());
86
86
  for (size_t i = 0; i < result.size(); ++i) {
87
87
  returnValue.setValueAtIndex(
@@ -93,7 +93,7 @@ public:
93
93
 
94
94
  JSI_HOST_FUNCTION(getLineMetrics) {
95
95
  std::vector<para::LineMetrics> metrics;
96
- _paragraph->getLineMetrics(metrics);
96
+ getObject()->getLineMetrics(metrics);
97
97
  auto returnValue = jsi::Array(runtime, metrics.size());
98
98
  auto height = 0;
99
99
  for (size_t i = 0; i < metrics.size(); ++i) {
@@ -110,7 +110,7 @@ public:
110
110
 
111
111
  JSI_HOST_FUNCTION(getRectsForPlaceholders) {
112
112
  std::vector<para::TextBox> placeholderInfos =
113
- _paragraph->getRectsForPlaceholders();
113
+ getObject()->getRectsForPlaceholders();
114
114
  auto returnValue = jsi::Array(runtime, placeholderInfos.size());
115
115
  for (size_t i = 0; i < placeholderInfos.size(); ++i) {
116
116
  auto obj = jsi::Object(runtime);
@@ -124,12 +124,6 @@ public:
124
124
  return returnValue;
125
125
  }
126
126
 
127
- JSI_HOST_FUNCTION(dispose) {
128
- _paragraph = nullptr;
129
-
130
- return jsi::Value::undefined();
131
- }
132
-
133
127
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkParagraph, layout),
134
128
  JSI_EXPORT_FUNC(JsiSkParagraph, paint),
135
129
  JSI_EXPORT_FUNC(JsiSkParagraph, getMaxWidth),
@@ -146,12 +140,8 @@ public:
146
140
 
147
141
  explicit JsiSkParagraph(std::shared_ptr<RNSkPlatformContext> context,
148
142
  para::ParagraphBuilder *paragraphBuilder)
149
- : JsiSkHostObject(std::move(context)) {
150
- _paragraph = paragraphBuilder->Build();
151
- }
152
-
153
- public:
154
- std::unique_ptr<para::Paragraph> _paragraph;
143
+ : JsiSkWrappingSharedPtrHostObject<para::Paragraph>(
144
+ std::move(context), std::move(paragraphBuilder->Build())) {}
155
145
  };
156
146
 
157
147
  } // namespace RNSkia
@@ -26,7 +26,7 @@ public:
26
26
  std::move(pathEffect)) {}
27
27
 
28
28
  EXPORT_JSI_API_TYPENAME(JsiSkPathEffect, PathEffect)
29
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkColorFilter, dispose))
29
+ JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPathEffect, dispose))
30
30
  };
31
31
 
32
32
  } // namespace RNSkia
@@ -45,7 +45,7 @@ public:
45
45
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPictureFactory, MakePicture))
46
46
 
47
47
  explicit JsiSkPictureFactory(std::shared_ptr<RNSkPlatformContext> context)
48
- : JsiSkHostObject(context) {}
48
+ : JsiSkHostObject(std::move(context)) {}
49
49
  };
50
50
 
51
51
  } // namespace RNSkia
@@ -84,14 +84,22 @@ public:
84
84
  SkPoint pts[] = {p1, p2};
85
85
 
86
86
  std::vector<SkColor> colors = getColors(runtime, arguments[2]);
87
+ auto colorsSize = colors.size();
88
+ if (colorsSize < 2) {
89
+ throw std::invalid_argument("colors must have at least 2 colors");
90
+ }
87
91
  std::vector<SkScalar> positions = getPositions(runtime, arguments[3]);
92
+ if (!positions.empty() && positions.size() != colorsSize) {
93
+ throw std::invalid_argument(
94
+ "positions must be empty or have the same size as colors");
95
+ }
88
96
  auto tileMode = getTileMode(arguments, 4, count);
89
97
  auto flag = getFlag(arguments, 6, count);
90
98
  auto localMatrix = getLocalMatrix(runtime, arguments, 5, count);
91
99
 
92
100
  sk_sp<SkShader> gradient = SkGradientShader::MakeLinear(
93
- pts, colors.data(), positions.data(), static_cast<int>(colors.size()),
94
- tileMode, flag, localMatrix);
101
+ pts, colors.data(), !positions.empty() ? positions.data() : nullptr,
102
+ static_cast<int>(colorsSize), tileMode, flag, localMatrix);
95
103
  return jsi::Object::createFromHostObject(
96
104
  runtime,
97
105
  std::make_shared<JsiSkShader>(getContext(), std::move(gradient)));
@@ -103,14 +111,23 @@ public:
103
111
  auto r = arguments[1].asNumber();
104
112
 
105
113
  std::vector<SkColor> colors = getColors(runtime, arguments[2]);
114
+ auto colorsSize = colors.size();
115
+ if (colorsSize < 2) {
116
+ throw std::invalid_argument("colors must have at least 2 colors");
117
+ }
106
118
  std::vector<SkScalar> positions = getPositions(runtime, arguments[3]);
119
+ if (!positions.empty() && positions.size() != colorsSize) {
120
+ throw std::invalid_argument(
121
+ "positions must be empty or the same size as colors");
122
+ }
107
123
  auto tileMode = getTileMode(arguments, 4, count);
108
124
  auto flag = getFlag(arguments, 6, count);
109
125
  auto localMatrix = getLocalMatrix(runtime, arguments, 5, count);
110
126
 
111
127
  sk_sp<SkShader> gradient = SkGradientShader::MakeRadial(
112
- center, r, colors.data(), positions.data(),
113
- static_cast<int>(colors.size()), tileMode, flag, localMatrix);
128
+ center, r, colors.data(),
129
+ !positions.empty() ? positions.data() : nullptr,
130
+ static_cast<int>(colorsSize), tileMode, flag, localMatrix);
114
131
  return jsi::Object::createFromHostObject(
115
132
  runtime,
116
133
  std::make_shared<JsiSkShader>(getContext(), std::move(gradient)));
@@ -120,7 +137,15 @@ public:
120
137
  auto x = arguments[0].asNumber();
121
138
  auto y = arguments[1].asNumber();
122
139
  std::vector<SkColor> colors = getColors(runtime, arguments[2]);
140
+ auto colorsSize = colors.size();
141
+ if (colorsSize < 2) {
142
+ throw std::invalid_argument("colors must have at least 2 colors");
143
+ }
123
144
  std::vector<SkScalar> positions = getPositions(runtime, arguments[3]);
145
+ if (!positions.empty() && positions.size() != colorsSize) {
146
+ throw std::invalid_argument(
147
+ "positions must be empty or the same size as colors");
148
+ }
124
149
  auto tileMode = getTileMode(arguments, 4, count);
125
150
  auto localMatrix = getLocalMatrix(runtime, arguments, 5, count);
126
151
  auto flag = getFlag(arguments, 6, count);
@@ -130,8 +155,9 @@ public:
130
155
  ? 360
131
156
  : arguments[8].asNumber();
132
157
  sk_sp<SkShader> gradient = SkGradientShader::MakeSweep(
133
- x, y, colors.data(), positions.data(), static_cast<int>(colors.size()),
134
- tileMode, startAngle, endAngle, flag, localMatrix);
158
+ x, y, colors.data(), !positions.empty() ? positions.data() : nullptr,
159
+ static_cast<int>(colorsSize), tileMode, startAngle, endAngle, flag,
160
+ localMatrix);
135
161
  return jsi::Object::createFromHostObject(
136
162
  runtime,
137
163
  std::make_shared<JsiSkShader>(getContext(), std::move(gradient)));
@@ -147,14 +173,23 @@ public:
147
173
  auto endRadius = arguments[3].asNumber();
148
174
 
149
175
  std::vector<SkColor> colors = getColors(runtime, arguments[4]);
176
+ auto colorsSize = colors.size();
177
+ if (colorsSize < 2) {
178
+ throw std::invalid_argument("colors must have at least 2 colors");
179
+ }
150
180
  std::vector<SkScalar> positions = getPositions(runtime, arguments[5]);
181
+ if (!positions.empty() && positions.size() != colorsSize) {
182
+ throw std::invalid_argument(
183
+ "positions must be empty or the same size as colors");
184
+ }
151
185
  auto tileMode = getTileMode(arguments, 6, count);
152
186
  auto localMatrix = getLocalMatrix(runtime, arguments, 7, count);
153
187
  auto flag = getFlag(arguments, 8, count);
154
188
 
155
189
  sk_sp<SkShader> gradient = SkGradientShader::MakeTwoPointConical(
156
- start, startRadius, end, endRadius, colors.data(), positions.data(),
157
- static_cast<int>(colors.size()), tileMode, flag, localMatrix);
190
+ start, startRadius, end, endRadius, colors.data(),
191
+ !positions.empty() ? positions.data() : nullptr,
192
+ static_cast<int>(colorsSize), tileMode, flag, localMatrix);
158
193
 
159
194
  return jsi::Object::createFromHostObject(
160
195
  runtime,
@@ -70,6 +70,10 @@ public:
70
70
  if (count >= 3 && !arguments[2].isNull() && !arguments[2].isUndefined()) {
71
71
  auto jsiTexs = arguments[2].asObject(runtime).asArray(runtime);
72
72
  auto texsSize = jsiTexs.size(runtime);
73
+ if (texsSize != positionsSize) {
74
+ throw jsi::JSError(runtime, "The number of texture coordinates must "
75
+ "match the number of positions");
76
+ }
73
77
  texs.reserve(texsSize);
74
78
  for (int i = 0; i < texsSize; i++) {
75
79
  auto point = JsiSkPoint::fromValue(
@@ -81,6 +85,11 @@ public:
81
85
  if (count >= 4 && !arguments[3].isNull() && !arguments[3].isUndefined()) {
82
86
  auto jsiColors = arguments[3].asObject(runtime).asArray(runtime);
83
87
  auto colorsSize = jsiColors.size(runtime);
88
+ if (colorsSize != positionsSize) {
89
+ throw jsi::JSError(
90
+ runtime,
91
+ "The number of colors must match the number of positions");
92
+ }
84
93
  colors.reserve(colorsSize);
85
94
  for (int i = 0; i < colorsSize; i++) {
86
95
  SkColor color = JsiSkColor::fromValue(
@@ -132,9 +141,11 @@ public:
132
141
  // builder.indices());
133
142
  // }
134
143
  // auto vertices = builder.detach();
135
- auto vertices = SkVertices::MakeCopy(
136
- mode, positionsSize, positions.data(), texs.data(), colors.data(),
137
- indicesSize, indices.data());
144
+ auto vertices =
145
+ SkVertices::MakeCopy(mode, positionsSize, positions.data(),
146
+ texs.size() > 0 ? texs.data() : nullptr,
147
+ colors.size() > 0 ? colors.data() : nullptr,
148
+ indicesSize, indices.data());
138
149
  return jsi::Object::createFromHostObject(
139
150
  runtime,
140
151
  std::make_shared<JsiSkVertices>(context, std::move(vertices)));
@@ -418,7 +418,7 @@ public:
418
418
  SkPaint shadowPaint;
419
419
  shadowPaint.setAntiAlias(true);
420
420
  shadowPaint.setColor(shadow.color.value_or(SK_ColorBLACK));
421
- shadowPaint.setAlphaf(opacity);
421
+ shadowPaint.setAlphaf(opacity * shadowPaint.getAlphaf());
422
422
  shadowPaint.setMaskFilter(SkMaskFilter::MakeBlur(
423
423
  SkBlurStyle::kNormal_SkBlurStyle, shadow.blur, true));
424
424
 
@@ -442,7 +442,7 @@ public:
442
442
  SkPaint shadowPaint;
443
443
  shadowPaint.setAntiAlias(true);
444
444
  shadowPaint.setColor(shadow.color.value_or(SK_ColorBLACK));
445
- shadowPaint.setAlphaf(opacity);
445
+ shadowPaint.setAlphaf(opacity * shadowPaint.getAlphaf());
446
446
  shadowPaint.setMaskFilter(SkMaskFilter::MakeBlur(
447
447
  SkBlurStyle::kNormal_SkBlurStyle, shadow.blur, true));
448
448
 
@@ -637,6 +637,16 @@ public:
637
637
  }
638
638
 
639
639
  void draw(DrawingCtx *ctx) {
640
+ // Validate colors array has exactly 4 colors if provided
641
+ if (props.colors.has_value() && props.colors.value().size() != 4) {
642
+ throw std::invalid_argument("Colors array for patch must have exactly 4 colors");
643
+ }
644
+
645
+ // Validate texture array has exactly 4 points if provided
646
+ if (props.texture.has_value() && props.texture.value().size() != 4) {
647
+ throw std::invalid_argument("Texture coordinates array for patch must have exactly 4 points");
648
+ }
649
+
640
650
  // Determine default blend mode based on presence of colors
641
651
  SkBlendMode defaultBlendMode = props.colors.has_value()
642
652
  ? SkBlendMode::kDstOver
@@ -676,6 +686,15 @@ public:
676
686
  }
677
687
 
678
688
  void draw(DrawingCtx *ctx) {
689
+ // Validate array sizes
690
+ if (props.colors.has_value() && props.colors.value().size() != props.vertices.size()) {
691
+ throw std::invalid_argument("Colors array must have the same size as vertices array");
692
+ }
693
+
694
+ if (props.textures.has_value() && props.textures.value().size() != props.vertices.size()) {
695
+ throw std::invalid_argument("Textures array must have the same size as vertices array");
696
+ }
697
+
679
698
  // Create vertices using MakeCopy
680
699
  auto vertices = SkVertices::MakeCopy(
681
700
  props.mode, static_cast<int>(props.vertices.size()),
@@ -874,9 +893,10 @@ public:
874
893
  }
875
894
 
876
895
  void draw(DrawingCtx *ctx) {
877
- if (props.paragraph && props.paragraph->_paragraph) {
878
- props.paragraph->_paragraph->layout(props.width);
879
- props.paragraph->_paragraph->paint(ctx->canvas, props.x, props.y);
896
+ if (props.paragraph) {
897
+ auto paragraph = props.paragraph->getObject();
898
+ paragraph->layout(props.width);
899
+ paragraph->paint(ctx->canvas, props.x, props.y);
880
900
  }
881
901
  }
882
902
  };
@@ -908,6 +928,16 @@ public:
908
928
 
909
929
  void draw(DrawingCtx *ctx) {
910
930
  if (props.image) {
931
+ // Validate transforms and sprites have the same size
932
+ if (props.transforms.size() != props.sprites.size()) {
933
+ throw std::invalid_argument("transforms and sprites arrays must have the same length");
934
+ }
935
+
936
+ // Validate colors array matches if provided
937
+ if (props.colors.has_value() && props.colors.value().size() != props.transforms.size()) {
938
+ throw std::invalid_argument("colors array must have the same length as transforms/sprites");
939
+ }
940
+
911
941
  auto colors =
912
942
  props.colors.has_value() ? props.colors.value().data() : nullptr;
913
943
  auto blendMode = props.blendMode.value_or(SkBlendMode::kDstOver);
@@ -239,6 +239,16 @@ public:
239
239
  }
240
240
 
241
241
  void pushShader(DrawingCtx *ctx) {
242
+ // Validate colors array has at least 2 colors
243
+ if (props.colors.size() < 2) {
244
+ throw std::invalid_argument("Colors array must have at least 2 colors");
245
+ }
246
+
247
+ // Validate positions array matches colors array in size
248
+ if (props.positions.has_value() && props.positions.value().size() != props.colors.size()) {
249
+ throw std::invalid_argument("Positions array must have the same size as colors array");
250
+ }
251
+
242
252
  SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
243
253
  const SkPoint pts[2] = {props.start, props.end};
244
254
  auto shader = SkGradientShader::MakeLinear(
@@ -276,6 +286,16 @@ public:
276
286
  }
277
287
 
278
288
  void pushShader(DrawingCtx *ctx) {
289
+ // Validate colors array has at least 2 colors
290
+ if (props.colors.size() < 2) {
291
+ throw std::invalid_argument("Colors array must have at least 2 colors");
292
+ }
293
+
294
+ // Validate positions array matches colors array in size
295
+ if (props.positions.has_value() && props.positions.value().size() != props.colors.size()) {
296
+ throw std::invalid_argument("Positions array must have the same size as colors array");
297
+ }
298
+
279
299
  SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
280
300
  auto shader = SkGradientShader::MakeRadial(
281
301
  props.center, props.radius, props.colors.data(),
@@ -314,6 +334,16 @@ public:
314
334
  }
315
335
 
316
336
  void pushShader(DrawingCtx *ctx) {
337
+ // Validate colors array has at least 2 colors
338
+ if (props.colors.size() < 2) {
339
+ throw std::invalid_argument("Colors array must have at least 2 colors");
340
+ }
341
+
342
+ // Validate positions array matches colors array in size
343
+ if (props.positions.has_value() && props.positions.value().size() != props.colors.size()) {
344
+ throw std::invalid_argument("Positions array must have the same size as colors array");
345
+ }
346
+
317
347
  SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
318
348
  auto shader = SkGradientShader::MakeSweep(
319
349
  props.center.x(), props.center.y(), props.colors.data(),
@@ -355,6 +385,16 @@ public:
355
385
  }
356
386
 
357
387
  void pushShader(DrawingCtx *ctx) {
388
+ // Validate colors array has at least 2 colors
389
+ if (props.colors.size() < 2) {
390
+ throw std::invalid_argument("Colors array must have at least 2 colors");
391
+ }
392
+
393
+ // Validate positions array matches colors array in size
394
+ if (props.positions.has_value() && props.positions.value().size() != props.colors.size()) {
395
+ throw std::invalid_argument("Positions array must have the same size as colors array");
396
+ }
397
+
358
398
  SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
359
399
  auto shader = SkGradientShader::MakeTwoPointConical(
360
400
  props.start, props.startRadius, props.end, props.endRadius,
@@ -51,7 +51,7 @@ async_callback(void *c,
51
51
  class DawnContext {
52
52
  public:
53
53
  // TODO: remove
54
- friend class RNSkiOSPlatformContext;
54
+ friend class RNSkApplePlatformContext;
55
55
 
56
56
  DawnContext(const DawnContext &) = delete;
57
57
  DawnContext &operator=(const DawnContext &) = delete;
@@ -412,6 +412,9 @@ public:
412
412
  * If a scanline decode is in progress, scanline mode will end, requiring the client to call
413
413
  * startScanlineDecode() in order to return to decoding scanlines.
414
414
  *
415
+ * For certain codecs, reading into a smaller bitmap than the original dimensions may not
416
+ * produce correct results (e.g. animated webp).
417
+ *
415
418
  * @return Result kSuccess, or another value explaining the type of failure.
416
419
  */
417
420
  Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options*);
@@ -812,6 +815,7 @@ protected:
812
815
  }
813
816
 
814
817
  virtual bool onGetGainmapCodec(SkGainmapInfo*, std::unique_ptr<SkCodec>*) { return false; }
818
+ virtual bool onGetGainmapInfo(SkGainmapInfo*) { return false; }
815
819
 
816
820
  // TODO(issues.skia.org/363544350): This API only works for JPEG images. Remove this API once
817
821
  // it is no longer used.
@@ -1053,8 +1057,9 @@ private:
1053
1057
  friend class PNGCodecGM; // for fillIncompleteImage
1054
1058
  friend class SkSampledCodec;
1055
1059
  friend class SkIcoCodec;
1056
- friend class SkAndroidCodec; // for fEncodedInfo
1057
- friend class SkPDFBitmap; // for fEncodedInfo
1060
+ friend class SkPngCodec; // for onGetGainmapCodec
1061
+ friend class SkAndroidCodec; // for handleFrameIndex
1062
+ friend class SkCodecPriv; // for fEncodedInfo
1058
1063
  };
1059
1064
 
1060
1065
  namespace SkCodecs {