react-native-skia 3.0.0 → 3.0.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 (261) hide show
  1. package/Package.swift +14 -13
  2. package/android/CMakeLists.txt +13 -42
  3. package/android/build.gradle +55 -47
  4. package/android/cpp/jni/JniLoad.cpp +2 -4
  5. package/android/cpp/jni/include/JniSkiaView.h +123 -0
  6. package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.cpp → RNSkAndroidCanvasProvider.cpp} +45 -100
  7. package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.h → RNSkAndroidCanvasProvider.h} +24 -22
  8. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +0 -83
  9. package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +0 -8
  10. package/android/src/main/java/com/reactnative/skia/RNSkiaPackage.java +1 -2
  11. package/android/src/main/java/com/reactnative/skia/SkiaSurfaceView.java +1 -3
  12. package/android/src/main/java/com/reactnative/skia/SkiaTextureView.java +1 -17
  13. package/android/src/main/java/com/reactnative/skia/{SkiaBaseView.java → SkiaView.java} +78 -16
  14. package/android/src/main/java/com/reactnative/skia/SkiaViewManager.java +85 -0
  15. package/apple/MetalLayerColorSpace.mm +0 -4
  16. package/apple/RNSkApplePlatformContext.h +0 -14
  17. package/apple/RNSkApplePlatformContext.mm +2 -112
  18. package/apple/RNSkMetalCanvasProvider.h +14 -19
  19. package/apple/RNSkMetalCanvasProvider.mm +35 -68
  20. package/apple/SkiaView.h +20 -0
  21. package/apple/SkiaView.mm +210 -0
  22. package/cpp/api/JsiSkApi.h +2 -13
  23. package/cpp/api/JsiSkCanvas.h +4 -18
  24. package/cpp/api/JsiSkGraphiteContext.h +1 -5
  25. package/cpp/api/JsiSkGraphiteRecording.h +1 -5
  26. package/cpp/api/JsiSkImage.h +7 -41
  27. package/cpp/api/JsiSkImageFactory.h +0 -14
  28. package/cpp/api/JsiSkSurface.h +2 -16
  29. package/cpp/api/JsiSkSurfaceFactory.h +0 -8
  30. package/cpp/rnskia/RNDawnContext.h +6 -0
  31. package/cpp/rnskia/RNDawnInterop.cpp +0 -4
  32. package/cpp/rnskia/RNDawnUtils.h +0 -1
  33. package/cpp/rnskia/RNDawnWindowContext.cpp +10 -0
  34. package/cpp/rnskia/RNDawnWindowContext.h +4 -0
  35. package/cpp/rnskia/RNSkCanvasProvider.h +221 -0
  36. package/cpp/rnskia/RNSkGraphiteProducer.cpp +36 -14
  37. package/cpp/rnskia/RNSkGraphiteProducer.h +23 -8
  38. package/cpp/rnskia/RNSkGraphiteTarget.h +383 -0
  39. package/cpp/rnskia/RNSkJsiViewApi.h +9 -18
  40. package/cpp/rnskia/RNSkPlatformContext.h +9 -15
  41. package/cpp/rnskia/RNSkView.h +340 -245
  42. package/jestSetup.js +1 -3
  43. package/lib/commonjs/Platform/Platform.web.js +1 -1
  44. package/lib/commonjs/Platform/Platform.web.js.map +1 -1
  45. package/lib/commonjs/index.d.ts +1 -3
  46. package/lib/commonjs/index.js +3 -12
  47. package/lib/commonjs/index.js.map +1 -1
  48. package/lib/commonjs/mock/index.js +0 -1
  49. package/lib/commonjs/mock/index.js.map +1 -1
  50. package/lib/commonjs/renderer/Canvas.d.ts +15 -12
  51. package/lib/commonjs/renderer/Canvas.js +24 -20
  52. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  53. package/lib/commonjs/skia/types/Graphite.d.ts +3 -3
  54. package/lib/commonjs/skia/types/Graphite.js.map +1 -1
  55. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +2 -2
  56. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  57. package/lib/commonjs/skia/types/Skia.d.ts +1 -2
  58. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  59. package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +1 -1
  60. package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
  61. package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +5 -4
  62. package/lib/commonjs/specs/NativeSkiaModule.web.js +5 -9
  63. package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
  64. package/lib/{typescript/src/specs/SkiaPictureViewNativeComponent.d.ts → commonjs/specs/SkiaViewNativeComponent.d.ts} +0 -3
  65. package/lib/commonjs/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
  66. package/lib/commonjs/specs/SkiaViewNativeComponent.js.map +1 -0
  67. package/lib/commonjs/specs/SkiaViewNativeComponent.web.d.ts +10 -0
  68. package/lib/commonjs/specs/SkiaViewNativeComponent.web.js +27 -0
  69. package/lib/commonjs/specs/SkiaViewNativeComponent.web.js.map +1 -0
  70. package/lib/commonjs/views/SkiaGraphiteView.d.ts +3 -4
  71. package/lib/commonjs/views/SkiaGraphiteView.js +23 -12
  72. package/lib/commonjs/views/SkiaGraphiteView.js.map +1 -1
  73. package/lib/commonjs/views/SkiaPictureView.d.ts +4 -1
  74. package/lib/commonjs/views/SkiaPictureView.js +12 -10
  75. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  76. package/lib/commonjs/views/SkiaView.web.d.ts +12 -0
  77. package/lib/commonjs/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +82 -38
  78. package/lib/commonjs/views/SkiaView.web.js.map +1 -0
  79. package/lib/commonjs/views/SkiaWebRenderer.js +1 -1
  80. package/lib/commonjs/views/SkiaWebRenderer.js.map +1 -1
  81. package/lib/commonjs/views/android.d.ts +6 -0
  82. package/lib/commonjs/views/android.js +17 -0
  83. package/lib/commonjs/views/android.js.map +1 -0
  84. package/lib/commonjs/views/types.d.ts +3 -12
  85. package/lib/commonjs/views/types.js.map +1 -1
  86. package/lib/module/Platform/Platform.web.js +1 -1
  87. package/lib/module/Platform/Platform.web.js.map +1 -1
  88. package/lib/module/index.d.ts +1 -3
  89. package/lib/module/index.js +1 -3
  90. package/lib/module/index.js.map +1 -1
  91. package/lib/module/mock/index.js +0 -1
  92. package/lib/module/mock/index.js.map +1 -1
  93. package/lib/module/renderer/Canvas.d.ts +15 -12
  94. package/lib/module/renderer/Canvas.js +24 -19
  95. package/lib/module/renderer/Canvas.js.map +1 -1
  96. package/lib/module/skia/types/Graphite.d.ts +3 -3
  97. package/lib/module/skia/types/Graphite.js.map +1 -1
  98. package/lib/module/skia/types/Image/ImageFactory.d.ts +2 -2
  99. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  100. package/lib/module/skia/types/Skia.d.ts +1 -2
  101. package/lib/module/skia/types/Skia.js.map +1 -1
  102. package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +1 -1
  103. package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
  104. package/lib/module/specs/NativeSkiaModule.web.d.ts +5 -4
  105. package/lib/module/specs/NativeSkiaModule.web.js +5 -9
  106. package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
  107. package/lib/{commonjs/specs/SkiaPictureViewNativeComponent.d.ts → module/specs/SkiaViewNativeComponent.d.ts} +0 -3
  108. package/lib/module/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
  109. package/lib/module/specs/SkiaViewNativeComponent.js.map +1 -0
  110. package/lib/module/specs/SkiaViewNativeComponent.web.d.ts +10 -0
  111. package/lib/module/specs/SkiaViewNativeComponent.web.js +21 -0
  112. package/lib/module/specs/SkiaViewNativeComponent.web.js.map +1 -0
  113. package/lib/module/views/SkiaGraphiteView.d.ts +3 -4
  114. package/lib/module/views/SkiaGraphiteView.js +23 -12
  115. package/lib/module/views/SkiaGraphiteView.js.map +1 -1
  116. package/lib/module/views/SkiaPictureView.d.ts +4 -1
  117. package/lib/module/views/SkiaPictureView.js +12 -10
  118. package/lib/module/views/SkiaPictureView.js.map +1 -1
  119. package/lib/module/views/SkiaView.web.d.ts +12 -0
  120. package/lib/module/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +80 -36
  121. package/lib/module/views/SkiaView.web.js.map +1 -0
  122. package/lib/module/views/SkiaWebRenderer.js +1 -1
  123. package/lib/module/views/SkiaWebRenderer.js.map +1 -1
  124. package/lib/module/views/android.d.ts +6 -0
  125. package/lib/module/views/android.js +10 -0
  126. package/lib/module/views/android.js.map +1 -0
  127. package/lib/module/views/types.d.ts +3 -12
  128. package/lib/module/views/types.js.map +1 -1
  129. package/lib/typescript/src/index.d.ts +1 -3
  130. package/lib/typescript/src/renderer/Canvas.d.ts +15 -12
  131. package/lib/typescript/src/skia/types/Graphite.d.ts +3 -3
  132. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +2 -2
  133. package/lib/typescript/src/skia/types/Skia.d.ts +1 -2
  134. package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +1 -1
  135. package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +5 -4
  136. package/lib/{module/specs/SkiaPictureViewNativeComponent.d.ts → typescript/src/specs/SkiaViewNativeComponent.d.ts} +0 -3
  137. package/lib/typescript/src/specs/SkiaViewNativeComponent.web.d.ts +10 -0
  138. package/lib/typescript/src/views/SkiaGraphiteView.d.ts +3 -4
  139. package/lib/typescript/src/views/SkiaPictureView.d.ts +4 -1
  140. package/lib/typescript/src/views/SkiaView.web.d.ts +12 -0
  141. package/lib/typescript/src/views/android.d.ts +6 -0
  142. package/lib/typescript/src/views/types.d.ts +3 -12
  143. package/package.json +8 -16
  144. package/react-native-skia.podspec +50 -57
  145. package/src/Platform/Platform.web.tsx +1 -1
  146. package/src/index.ts +1 -3
  147. package/src/mock/index.ts +0 -1
  148. package/src/renderer/Canvas.tsx +23 -27
  149. package/src/skia/types/Graphite.ts +3 -3
  150. package/src/skia/types/Image/ImageFactory.ts +2 -2
  151. package/src/skia/types/Skia.ts +1 -2
  152. package/src/skia/types/Surface/SurfaceFactory.ts +1 -1
  153. package/src/specs/NativeSkiaModule.web.ts +9 -21
  154. package/src/specs/{SkiaPictureViewNativeComponent.ts → SkiaViewNativeComponent.ts} +1 -4
  155. package/src/specs/{SkiaPictureViewNativeComponent.web.ts → SkiaViewNativeComponent.web.ts} +8 -10
  156. package/src/views/SkiaGraphiteView.tsx +27 -16
  157. package/src/views/SkiaPictureView.tsx +11 -10
  158. package/src/views/{SkiaGraphiteView.web.tsx → SkiaView.web.tsx} +100 -53
  159. package/src/views/SkiaWebRenderer.ts +1 -1
  160. package/src/views/android.ts +16 -0
  161. package/src/views/types.ts +3 -14
  162. package/android/cpp/jni/include/JniSkiaBaseView.h +0 -92
  163. package/android/cpp/jni/include/JniSkiaGraphiteView.h +0 -176
  164. package/android/cpp/jni/include/JniSkiaPictureView.h +0 -172
  165. package/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp +0 -245
  166. package/android/cpp/rnskia-android/GrAHardwareBufferUtils.h +0 -33
  167. package/android/cpp/rnskia-android/OpenGLContext.h +0 -248
  168. package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +0 -67
  169. package/android/cpp/rnskia-android/OpenGLWindowContext.h +0 -75
  170. package/android/cpp/rnskia-android/RNSkAndroidView.h +0 -67
  171. package/android/cpp/rnskia-android/gl/Context.h +0 -80
  172. package/android/cpp/rnskia-android/gl/Display.h +0 -123
  173. package/android/cpp/rnskia-android/gl/Error.cpp +0 -45
  174. package/android/cpp/rnskia-android/gl/Error.h +0 -8
  175. package/android/cpp/rnskia-android/gl/Surface.h +0 -43
  176. package/android/src/main/java/com/reactnative/skia/SkiaBaseViewManager.java +0 -65
  177. package/android/src/main/java/com/reactnative/skia/SkiaGraphiteView.java +0 -78
  178. package/android/src/main/java/com/reactnative/skia/SkiaGraphiteViewManager.java +0 -32
  179. package/android/src/main/java/com/reactnative/skia/SkiaPictureView.java +0 -105
  180. package/android/src/main/java/com/reactnative/skia/SkiaPictureViewManager.java +0 -44
  181. package/apple/MetalContext.h +0 -116
  182. package/apple/MetalContext.mm +0 -38
  183. package/apple/MetalWindowContext.h +0 -42
  184. package/apple/MetalWindowContext.mm +0 -95
  185. package/apple/RNSkAppleView.h +0 -49
  186. package/apple/RNSkAppleView.mm +0 -35
  187. package/apple/SkiaCVPixelBufferUtils.h +0 -122
  188. package/apple/SkiaCVPixelBufferUtils.mm +0 -535
  189. package/apple/SkiaGraphiteView.h +0 -26
  190. package/apple/SkiaGraphiteView.mm +0 -180
  191. package/apple/SkiaPictureView.h +0 -7
  192. package/apple/SkiaPictureView.mm +0 -70
  193. package/apple/SkiaUIView.h +0 -31
  194. package/apple/SkiaUIView.mm +0 -164
  195. package/cpp/rnskia/RNSkGraphiteView.h +0 -708
  196. package/cpp/rnskia/RNSkPictureView.cpp +0 -69
  197. package/cpp/rnskia/RNSkPictureView.h +0 -211
  198. package/cpp/skia/src/gpu/ganesh/gl/GrGLDefines.h +0 -1162
  199. package/lib/commonjs/renderer/DefaultCanvas.d.ts +0 -8
  200. package/lib/commonjs/renderer/DefaultCanvas.js +0 -42
  201. package/lib/commonjs/renderer/DefaultCanvas.js.map +0 -1
  202. package/lib/commonjs/renderer/GraphiteCanvas.d.ts +0 -22
  203. package/lib/commonjs/renderer/GraphiteCanvas.js +0 -64
  204. package/lib/commonjs/renderer/GraphiteCanvas.js.map +0 -1
  205. package/lib/commonjs/renderer/GraphiteCanvas.web.d.ts +0 -1
  206. package/lib/commonjs/renderer/GraphiteCanvas.web.js +0 -13
  207. package/lib/commonjs/renderer/GraphiteCanvas.web.js.map +0 -1
  208. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
  209. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js +0 -12
  210. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
  211. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
  212. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js +0 -28
  213. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
  214. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +0 -1
  215. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
  216. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js +0 -29
  217. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
  218. package/lib/commonjs/views/SkiaGraphiteView.web.d.ts +0 -14
  219. package/lib/commonjs/views/SkiaGraphiteView.web.js.map +0 -1
  220. package/lib/commonjs/views/SkiaPictureView.web.d.ts +0 -11
  221. package/lib/commonjs/views/SkiaPictureView.web.js +0 -165
  222. package/lib/commonjs/views/SkiaPictureView.web.js.map +0 -1
  223. package/lib/module/renderer/DefaultCanvas.d.ts +0 -8
  224. package/lib/module/renderer/DefaultCanvas.js +0 -34
  225. package/lib/module/renderer/DefaultCanvas.js.map +0 -1
  226. package/lib/module/renderer/GraphiteCanvas.d.ts +0 -22
  227. package/lib/module/renderer/GraphiteCanvas.js +0 -57
  228. package/lib/module/renderer/GraphiteCanvas.js.map +0 -1
  229. package/lib/module/renderer/GraphiteCanvas.web.d.ts +0 -1
  230. package/lib/module/renderer/GraphiteCanvas.web.js +0 -4
  231. package/lib/module/renderer/GraphiteCanvas.web.js.map +0 -1
  232. package/lib/module/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
  233. package/lib/module/specs/SkiaGraphiteViewNativeComponent.js +0 -8
  234. package/lib/module/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
  235. package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
  236. package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js +0 -22
  237. package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
  238. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +0 -1
  239. package/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
  240. package/lib/module/specs/SkiaPictureViewNativeComponent.web.js +0 -23
  241. package/lib/module/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
  242. package/lib/module/views/SkiaGraphiteView.web.d.ts +0 -14
  243. package/lib/module/views/SkiaGraphiteView.web.js.map +0 -1
  244. package/lib/module/views/SkiaPictureView.web.d.ts +0 -11
  245. package/lib/module/views/SkiaPictureView.web.js +0 -156
  246. package/lib/module/views/SkiaPictureView.web.js.map +0 -1
  247. package/lib/typescript/src/renderer/DefaultCanvas.d.ts +0 -8
  248. package/lib/typescript/src/renderer/GraphiteCanvas.d.ts +0 -22
  249. package/lib/typescript/src/renderer/GraphiteCanvas.web.d.ts +0 -1
  250. package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
  251. package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
  252. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
  253. package/lib/typescript/src/views/SkiaGraphiteView.web.d.ts +0 -14
  254. package/lib/typescript/src/views/SkiaPictureView.web.d.ts +0 -11
  255. package/libs/.graphite +0 -1
  256. package/src/renderer/DefaultCanvas.tsx +0 -41
  257. package/src/renderer/GraphiteCanvas.tsx +0 -61
  258. package/src/renderer/GraphiteCanvas.web.tsx +0 -3
  259. package/src/specs/SkiaGraphiteViewNativeComponent.ts +0 -17
  260. package/src/specs/SkiaGraphiteViewNativeComponent.web.ts +0 -31
  261. package/src/views/SkiaPictureView.web.tsx +0 -224
@@ -1,10 +1,6 @@
1
1
  import type { ViewProps } from "react-native";
2
2
  import type { SharedValue } from "react-native-reanimated";
3
3
  import type { SkGraphiteContext, SkImage, SkPicture, SkRect, SkSize } from "../skia/types";
4
- export type NativeSkiaViewProps = ViewProps & {
5
- debug?: boolean;
6
- opaque?: boolean;
7
- };
8
4
  export type AndroidSurfaceType = "SurfaceView" | "TextureView";
9
5
  export interface AndroidCanvasProps {
10
6
  /**
@@ -35,17 +31,13 @@ export interface ISkiaViewApi {
35
31
  makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;
36
32
  size: (nativeId: number) => SkSize;
37
33
  /**
38
- * The recording side of a SkiaGraphiteView: its native id, the layout size
39
- * in points, and the props its surface format follows from. Graphite only.
34
+ * The recording side of a view: its native id, the layout size in points,
35
+ * and the props its surface format follows from.
40
36
  */
41
37
  makeGraphiteContext: (nativeId: number, width: number, height: number, opaque: boolean, highBitDepth: boolean) => SkGraphiteContext;
42
38
  }
39
+ /** The props every Skia view takes, whichever way it is drawn. */
43
40
  export interface SkiaBaseViewProps extends ViewProps {
44
- /**
45
- * When set to true the view will display information about the
46
- * average time it takes to render.
47
- */
48
- debug?: boolean;
49
41
  /**
50
42
  * Declares that the canvas covers every pixel of its bounds. On Android an
51
43
  * opaque canvas is backed by a `SurfaceView` by default, the cheapest path
@@ -64,6 +56,5 @@ export interface SkiaBaseViewProps extends ViewProps {
64
56
  }
65
57
  export interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {
66
58
  picture?: SkPicture;
67
- androidWarmup?: boolean;
68
59
  }
69
60
  export type SkiaGraphiteViewNativeProps = SkiaBaseViewProps;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n SkGraphiteContext,\n SkImage,\n SkPicture,\n SkRect,\n SkSize,\n} from \"../skia/types\";\n\nexport type NativeSkiaViewProps = ViewProps & {\n debug?: boolean;\n opaque?: boolean;\n};\n\nexport type AndroidSurfaceType = \"SurfaceView\" | \"TextureView\";\n\nexport interface AndroidCanvasProps {\n /**\n * Backing view. Defaults to `SurfaceView` when the canvas is `opaque` and to\n * `TextureView` otherwise; both composite correctly in React Native stacking\n * order without further flags.\n */\n surfaceType?: AndroidSurfaceType;\n /**\n * SurfaceView only: composite above every React Native view in the window,\n * ignoring `zIndex`. Ignored for TextureView. Defaults to false.\n */\n zOrderOnTop?: boolean;\n}\n\nexport interface ISkiaViewApi {\n web?: boolean;\n setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;\n requestRedraw: (nativeId: number) => void;\n /**\n * Reads the shared values into the recording held for the view and\n * schedules a redraw. Native only; called from a worklet on every frame.\n * Until the view registers, the recording is queued for it and kept\n * current all the same. Ignored when the recording `recorderId` is neither\n * held by the view nor queued for it.\n */\n applyUpdates: (\n nativeId: number,\n recorderId: number,\n values: SharedValue<unknown>[]\n ) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;\n size: (nativeId: number) => SkSize;\n /**\n * The recording side of a SkiaGraphiteView: its native id, the layout size\n * in points, and the props its surface format follows from. Graphite only.\n */\n makeGraphiteContext: (\n nativeId: number,\n width: number,\n height: number,\n opaque: boolean,\n highBitDepth: boolean\n ) => SkGraphiteContext;\n}\n\nexport interface SkiaBaseViewProps extends ViewProps {\n /**\n * When set to true the view will display information about the\n * average time it takes to render.\n */\n debug?: boolean;\n\n /**\n * Declares that the canvas covers every pixel of its bounds. On Android an\n * opaque canvas is backed by a `SurfaceView` by default, the cheapest path\n * (see `android.surfaceType`). Defaults to false.\n */\n opaque?: boolean;\n\n /**\n * Renders into a surface with more than 8 bits per channel (16-bit float on\n * iOS, 10-bit on Android) to avoid banding in subtle gradients. On Android\n * the extra precision survives composition only when combined with `opaque`.\n */\n highBitDepth?: boolean;\n\n /** Android-only rendering options. Ignored on iOS and web. */\n android?: AndroidCanvasProps;\n\n // On web, only 16 WebGL contextes are allowed. If the drawing is non-animated, set\n // __destroyWebGLContextAfterRender to true to release the context after each draw.\n __destroyWebGLContextAfterRender?: boolean;\n}\n\nexport interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {\n picture?: SkPicture;\n androidWarmup?: boolean;\n}\n\nexport type SkiaGraphiteViewNativeProps = SkiaBaseViewProps;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n SkGraphiteContext,\n SkImage,\n SkPicture,\n SkRect,\n SkSize,\n} from \"../skia/types\";\n\nexport type AndroidSurfaceType = \"SurfaceView\" | \"TextureView\";\n\nexport interface AndroidCanvasProps {\n /**\n * Backing view. Defaults to `SurfaceView` when the canvas is `opaque` and to\n * `TextureView` otherwise; both composite correctly in React Native stacking\n * order without further flags.\n */\n surfaceType?: AndroidSurfaceType;\n /**\n * SurfaceView only: composite above every React Native view in the window,\n * ignoring `zIndex`. Ignored for TextureView. Defaults to false.\n */\n zOrderOnTop?: boolean;\n}\n\nexport interface ISkiaViewApi {\n web?: boolean;\n setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;\n requestRedraw: (nativeId: number) => void;\n /**\n * Reads the shared values into the recording held for the view and\n * schedules a redraw. Native only; called from a worklet on every frame.\n * Until the view registers, the recording is queued for it and kept\n * current all the same. Ignored when the recording `recorderId` is neither\n * held by the view nor queued for it.\n */\n applyUpdates: (\n nativeId: number,\n recorderId: number,\n values: SharedValue<unknown>[]\n ) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;\n size: (nativeId: number) => SkSize;\n /**\n * The recording side of a view: its native id, the layout size in points,\n * and the props its surface format follows from.\n */\n makeGraphiteContext: (\n nativeId: number,\n width: number,\n height: number,\n opaque: boolean,\n highBitDepth: boolean\n ) => SkGraphiteContext;\n}\n\n/** The props every Skia view takes, whichever way it is drawn. */\nexport interface SkiaBaseViewProps extends ViewProps {\n /**\n * Declares that the canvas covers every pixel of its bounds. On Android an\n * opaque canvas is backed by a `SurfaceView` by default, the cheapest path\n * (see `android.surfaceType`). Defaults to false.\n */\n opaque?: boolean;\n\n /**\n * Renders into a surface with more than 8 bits per channel (16-bit float on\n * iOS, 10-bit on Android) to avoid banding in subtle gradients. On Android\n * the extra precision survives composition only when combined with `opaque`.\n */\n highBitDepth?: boolean;\n\n /** Android-only rendering options. Ignored on iOS and web. */\n android?: AndroidCanvasProps;\n\n // On web, only 16 WebGL contextes are allowed. If the drawing is non-animated, set\n // __destroyWebGLContextAfterRender to true to release the context after each draw.\n __destroyWebGLContextAfterRender?: boolean;\n}\n\nexport interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {\n picture?: SkPicture;\n}\n\nexport type SkiaGraphiteViewNativeProps = SkiaBaseViewProps;\n"],"mappings":"","ignoreList":[]}
@@ -1,10 +1,8 @@
1
1
  import "./skia/NativeSetup";
2
2
  export { JsiSkImage } from "./skia/web/JsiSkImage";
3
3
  export * from "./renderer";
4
- export { useCanvasRef, useCanvasSize } from "./renderer/Canvas";
4
+ export { Canvas, useCanvasRef, useCanvasSize } from "./renderer/Canvas";
5
5
  export type { CanvasProps, CanvasRef } from "./renderer/Canvas";
6
- export { GraphiteCanvas } from "./renderer/GraphiteCanvas";
7
- export { Canvas } from "./renderer/DefaultCanvas";
8
6
  export * from "./renderer/Offscreen";
9
7
  export * from "./views";
10
8
  export * from "./skia";
@@ -1,6 +1,6 @@
1
1
  import type { FC, RefObject } from "react";
2
2
  import React from "react";
3
- import type { MeasureInWindowOnSuccessCallback, MeasureOnSuccessCallback, View, ViewProps } from "react-native";
3
+ import type { MeasureInWindowOnSuccessCallback, MeasureOnSuccessCallback, ViewProps } from "react-native";
4
4
  import type { SharedValue } from "react-native-reanimated";
5
5
  import type { AndroidCanvasProps } from "../views/types";
6
6
  import type { SkImage, SkRect, SkSize } from "../skia/types";
@@ -18,7 +18,6 @@ export declare const useCanvasSize: (userRef?: RefObject<CanvasRef | null>) => {
18
18
  size: SkSize;
19
19
  };
20
20
  export interface CanvasProps extends Omit<ViewProps, "onLayout"> {
21
- debug?: boolean;
22
21
  /** @deprecated Not supported on native. Use `onSize` or `useCanvasSize()` instead. */
23
22
  onLayout?: ViewProps["onLayout"];
24
23
  /**
@@ -29,7 +28,6 @@ export interface CanvasProps extends Omit<ViewProps, "onLayout"> {
29
28
  */
30
29
  opaque?: boolean;
31
30
  onSize?: SharedValue<SkSize>;
32
- colorSpace?: "p3" | "srgb";
33
31
  /**
34
32
  * Renders into a surface with more than 8 bits per channel (16-bit float on
35
33
  * iOS, 10-bit on Android) to avoid banding in subtle gradients. Colors are
@@ -42,16 +40,21 @@ export interface CanvasProps extends Omit<ViewProps, "onLayout"> {
42
40
  /** Android-only rendering options. Ignored on iOS and web. */
43
41
  android?: AndroidCanvasProps;
44
42
  ref?: React.Ref<CanvasRef>;
45
- androidWarmup?: boolean;
46
43
  __destroyWebGLContextAfterRender?: boolean;
47
44
  }
48
45
  /**
49
- * What every canvas shares, whichever native view it renders into: the native
50
- * id, the scene graph root rendered into it, the `onSize` measurement and the
51
- * imperative handle of the ref.
46
+ * The declarative canvas. Its children are rendered by Skia's own React
47
+ * renderer; the frames are produced off the JS thread:
48
+ *
49
+ * - the JS thread records the scene graph into a native recorder once per
50
+ * React commit and hands it to the view;
51
+ * - the Reanimated UI runtime only reads the shared values into it (the one
52
+ * step that needs a JS runtime), it never replays anything;
53
+ * - a dedicated native thread pool replays the recorder into a Graphite
54
+ * recording whenever the content changed, at most once per presented frame;
55
+ * - the view presents the recording on the next vsync.
56
+ *
57
+ * On the web the scene is drawn into a picture on the JS thread and painted
58
+ * on a WebGL canvas.
52
59
  */
53
- export declare const useCanvasRoot: ({ children, onSize, ref, onLayout, }: Pick<CanvasProps, "children" | "onSize" | "ref" | "onLayout">) => {
54
- nativeId: number;
55
- viewRef: RefObject<View | null>;
56
- };
57
- export declare const Canvas: ({ debug, opaque, children, onSize, colorSpace, highBitDepth, androidWarmup, android, ref, onLayout, ...viewProps }: CanvasProps) => React.JSX.Element;
60
+ export declare const Canvas: ({ opaque, children, onSize, highBitDepth, android, ref, onLayout, ...viewProps }: CanvasProps) => React.JSX.Element;
@@ -1,12 +1,12 @@
1
1
  import type { SkCanvas } from "./Canvas";
2
2
  import type { SkJSIInstance } from "./JsiInstance";
3
3
  /**
4
- * A frame recorded for a SkiaGraphiteView. Immutable once finished: submit it
5
- * to the view as many times as needed, from any runtime.
4
+ * A frame recorded for a view. Immutable once finished: submit it to the view
5
+ * as many times as needed, from any runtime.
6
6
  */
7
7
  export type SkGraphiteRecording = SkJSIInstance<"GraphiteRecording">;
8
8
  /**
9
- * The recording side of a SkiaGraphiteView, obtained from the view's ref.
9
+ * The recording side of a view, obtained from the ref of a SkiaGraphiteView.
10
10
  *
11
11
  * Frames are recorded on the calling thread and presented by the view on its
12
12
  * display link, so the context can be captured into a worklet and used from
@@ -89,7 +89,7 @@ export interface ImageFactory {
89
89
  * while the image is in use: destroy() releases the underlying GPU
90
90
  * resource regardless of reference counts.
91
91
  *
92
- * Note: This method is only available when the Graphite backend is enabled.
92
+ * Native only.
93
93
  *
94
94
  * @param pointer - The WGPUTexture pointer (texture.nativePointer)
95
95
  * @returns An SkImage wrapping the texture, or throws if the texture is invalid
@@ -101,7 +101,7 @@ export interface ImageFactory {
101
101
  * returned pointer carries one reference and must be adopted exactly once
102
102
  * with react-native-webgpu's adoptTexture(), which owns it from then on.
103
103
  *
104
- * Note: This method is only available when the Graphite backend is enabled.
104
+ * Native only.
105
105
  *
106
106
  * @param image - An SkImage to convert to a texture
107
107
  * @returns A WGPUTexture pointer for adoptTexture(), or throws on failure
@@ -83,8 +83,7 @@ export interface Skia {
83
83
  /**
84
84
  * Raw WGPUDevice pointer of Skia's Graphite device, as a BigInt. Pass it to
85
85
  * react-native-webgpu's importDevice() to get a GPUDevice sharing Skia's
86
- * device (zero-copy interop). Only available on Graphite builds; throws
87
- * otherwise.
86
+ * device (zero-copy interop). Native only.
88
87
  */
89
88
  getNativeDevice(): bigint;
90
89
  }
@@ -33,7 +33,7 @@ export interface SurfaceFactory {
33
33
  * surface exists. Calling destroy() on the GPUTexture still invalidates
34
34
  * the surface.
35
35
  *
36
- * Note: This method is only available when the Graphite backend is enabled.
36
+ * Native only.
37
37
  *
38
38
  * @param pointer - The WGPUTexture pointer (texture.nativePointer)
39
39
  * @returns An SkSurface rendering into the texture, or throws if the texture is invalid
@@ -1,7 +1,11 @@
1
1
  import type { SkGraphiteContext, SkImage, SkPicture, SkRect } from "../skia/types";
2
2
  import type { ISkiaViewApi } from "../views/types";
3
- /** What every web view registers under its native id. */
3
+ /** What the web view registers under its native id. */
4
4
  export interface SkiaWebViewHandle {
5
+ /** Shows a picture: the frame of a <Canvas> or a <SkiaPictureView>. */
6
+ setPicture(picture: SkPicture): void;
7
+ /** The recording side of the view, see SkiaGraphiteView. */
8
+ getContext(): SkGraphiteContext;
5
9
  getSize(): {
6
10
  width: number;
7
11
  height: number;
@@ -11,9 +15,6 @@ export interface SkiaWebViewHandle {
11
15
  measure(callback: (x: number, y: number, width: number, height: number, pageX: number, pageY: number) => void): void;
12
16
  measureInWindow(callback: (x: number, y: number, width: number, height: number) => void): void;
13
17
  }
14
- export interface SkiaGraphiteViewHandle extends SkiaWebViewHandle {
15
- getContext(): SkGraphiteContext;
16
- }
17
18
  export type ISkiaViewApiWeb = ISkiaViewApi & {
18
19
  views: Record<string, SkiaWebViewHandle>;
19
20
  deferedPictures: Record<string, SkPicture>;
@@ -1,11 +1,8 @@
1
1
  import { type ViewProps } from "react-native";
2
2
  import type { WithDefault } from "react-native/Libraries/Types/CodegenTypes";
3
3
  export interface NativeProps extends ViewProps {
4
- debug?: boolean;
5
4
  opaque?: boolean;
6
- colorSpace?: string;
7
5
  highBitDepth?: boolean;
8
- androidWarmup?: boolean;
9
6
  androidSurfaceType?: WithDefault<"auto" | "SurfaceView" | "TextureView", "auto">;
10
7
  androidZOrderOnTop?: WithDefault<boolean, false>;
11
8
  pointerEvents?: WithDefault<"auto" | "none" | "box-none" | "box-only", "auto">;
@@ -0,0 +1,10 @@
1
+ import type { ViewProps } from "react-native";
2
+ export interface NativeProps extends ViewProps {
3
+ opaque?: boolean;
4
+ highBitDepth?: boolean;
5
+ nativeID: string;
6
+ androidSurfaceType?: "auto" | "SurfaceView" | "TextureView";
7
+ androidZOrderOnTop?: boolean;
8
+ }
9
+ declare const SkiaViewNativeComponent: ({ nativeID, onLayout, opaque: _opaque, highBitDepth: _highBitDepth, androidSurfaceType: _androidSurfaceType, androidZOrderOnTop: _androidZOrderOnTop, ...viewProps }: NativeProps) => import("react").FunctionComponentElement<import("../views/SkiaView.web").SkiaViewProps>;
10
+ export default SkiaViewNativeComponent;
@@ -13,8 +13,7 @@ export interface SkiaGraphiteViewProps extends SkiaGraphiteViewNativeProps {
13
13
  ref?: React.Ref<SkiaGraphiteViewRef>;
14
14
  }
15
15
  /**
16
- * A view presenting frames recorded with Skia Graphite. Requires the Graphite
17
- * backend (install-skia-graphite); with the default backend it renders
18
- * nothing. See {@link SkGraphiteContext}.
16
+ * A view whose frames are recorded from JavaScript, on any runtime, through
17
+ * the context of its ref. See {@link SkGraphiteContext}.
19
18
  */
20
- export declare const SkiaGraphiteView: ({ debug, opaque, highBitDepth, ref, ...viewProps }: SkiaGraphiteViewProps) => React.JSX.Element;
19
+ export declare const SkiaGraphiteView: ({ opaque, highBitDepth, android, ref, ...viewProps }: SkiaGraphiteViewProps) => React.JSX.Element;
@@ -3,8 +3,11 @@ import type { SkRect } from "../skia/types";
3
3
  import type { SkiaPictureViewNativeProps } from "./types";
4
4
  interface SkiaPictureViewProps extends SkiaPictureViewNativeProps {
5
5
  mode?: "default" | "continuous";
6
- androidWarmup?: boolean;
7
6
  }
7
+ /**
8
+ * A view showing a picture. The picture is handed to the native view, which
9
+ * records it once (and again on every redraw) for its surface.
10
+ */
8
11
  export declare class SkiaPictureView extends React.Component<SkiaPictureViewProps> {
9
12
  private requestId;
10
13
  constructor(props: SkiaPictureViewProps);
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import type { ViewProps } from "react-native";
3
+ import type { SkiaWebViewHandle } from "../specs/NativeSkiaModule.web";
4
+ export interface SkiaViewHandle extends SkiaWebViewHandle {
5
+ /** The canvas element, for Reanimated's measure(). */
6
+ readonly canvasRef: () => HTMLCanvasElement | null;
7
+ }
8
+ export interface SkiaViewProps extends ViewProps {
9
+ ref?: React.Ref<SkiaViewHandle>;
10
+ __destroyWebGLContextAfterRender?: boolean;
11
+ }
12
+ export declare const SkiaView: (props: SkiaViewProps) => React.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import type { AndroidCanvasProps, AndroidSurfaceType } from "./types";
2
+ /** The native props the `android` prop of a view resolves to. */
3
+ export declare const androidNativeProps: (android?: AndroidCanvasProps) => {
4
+ androidSurfaceType: AndroidSurfaceType | "auto";
5
+ androidZOrderOnTop: boolean;
6
+ };
@@ -1,10 +1,6 @@
1
1
  import type { ViewProps } from "react-native";
2
2
  import type { SharedValue } from "react-native-reanimated";
3
3
  import type { SkGraphiteContext, SkImage, SkPicture, SkRect, SkSize } from "../skia/types";
4
- export type NativeSkiaViewProps = ViewProps & {
5
- debug?: boolean;
6
- opaque?: boolean;
7
- };
8
4
  export type AndroidSurfaceType = "SurfaceView" | "TextureView";
9
5
  export interface AndroidCanvasProps {
10
6
  /**
@@ -35,17 +31,13 @@ export interface ISkiaViewApi {
35
31
  makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;
36
32
  size: (nativeId: number) => SkSize;
37
33
  /**
38
- * The recording side of a SkiaGraphiteView: its native id, the layout size
39
- * in points, and the props its surface format follows from. Graphite only.
34
+ * The recording side of a view: its native id, the layout size in points,
35
+ * and the props its surface format follows from.
40
36
  */
41
37
  makeGraphiteContext: (nativeId: number, width: number, height: number, opaque: boolean, highBitDepth: boolean) => SkGraphiteContext;
42
38
  }
39
+ /** The props every Skia view takes, whichever way it is drawn. */
43
40
  export interface SkiaBaseViewProps extends ViewProps {
44
- /**
45
- * When set to true the view will display information about the
46
- * average time it takes to render.
47
- */
48
- debug?: boolean;
49
41
  /**
50
42
  * Declares that the canvas covers every pixel of its bounds. On Android an
51
43
  * opaque canvas is backed by a `SurfaceView` by default, the cheapest path
@@ -64,6 +56,5 @@ export interface SkiaBaseViewProps extends ViewProps {
64
56
  }
65
57
  export interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {
66
58
  picture?: SkPicture;
67
- androidWarmup?: boolean;
68
59
  }
69
60
  export type SkiaGraphiteViewNativeProps = SkiaBaseViewProps;
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "setup-skia-web": "scripts/setup-canvaskit.js"
9
9
  },
10
10
  "title": "React Native Skia",
11
- "version": "3.0.0",
11
+ "version": "3.0.2",
12
12
  "description": "High-performance React Native Graphics using Skia",
13
13
  "main": "lib/module/index.js",
14
14
  "react-native": "src/index.ts",
@@ -35,8 +35,7 @@
35
35
  "Package.swift",
36
36
  "include/**",
37
37
  "react-native.config.js",
38
- "dist/**",
39
- "libs/.graphite"
38
+ "dist/**"
40
39
  ],
41
40
  "scripts": {
42
41
  "lint": "eslint . --ext .ts,.tsx --max-warnings 0 --cache --fix",
@@ -48,8 +47,6 @@
48
47
  "clean-skia": "yarn rimraf ./libs && yarn rimraf ../../externals/skia/out",
49
48
  "build-skia": "tsx ./scripts/build-skia.ts",
50
49
  "copy-skia-headers": "tsx ./scripts/copy-skia-headers.ts",
51
- "install-skia": "tsx ./scripts/install-skia.ts",
52
- "install-skia-graphite": "tsx ./scripts/install-skia-graphite.ts",
53
50
  "clang-format": "yarn clang-format-ios && yarn clang-format-android && yarn clang-format-common",
54
51
  "clang-format-ios": "find apple/ -iname '*.h' -o -iname '*.mm' -o -iname '*.cpp' | xargs clang-format -i",
55
52
  "clang-format-android": "find android/cpp/ -iname '*.h' -o -iname '*.m' -o -iname '*.cpp' | xargs clang-format -i",
@@ -130,6 +127,7 @@
130
127
  "react-native": "0.83.1",
131
128
  "react-native-builder-bob": "0.18.2",
132
129
  "react-native-reanimated": "4.3.1",
130
+ "react-native-skia-graphite-headers": "154.0.1",
133
131
  "react-native-worklets": "0.8.3",
134
132
  "rimraf": "3.0.2",
135
133
  "semantic-release": "^24.1.0",
@@ -142,16 +140,11 @@
142
140
  },
143
141
  "dependencies": {
144
142
  "canvaskit-wasm": "0.41.0",
145
- "react-native-skia-graphite-android": "154.0.0",
146
- "react-native-skia-graphite-apple-ios": "154.0.0",
147
- "react-native-skia-graphite-apple-macos": "154.0.0",
143
+ "react-native-skia-graphite-android": "154.0.1",
144
+ "react-native-skia-graphite-apple-ios": "154.0.1",
145
+ "react-native-skia-graphite-apple-macos": "154.0.1",
148
146
  "react-reconciler": "0.31.0"
149
147
  },
150
- "graphiteDependencies": {
151
- "react-native-skia-graphite-android": "154.0.0",
152
- "react-native-skia-graphite-apple-ios": "154.0.0",
153
- "react-native-skia-graphite-apple-macos": "154.0.0"
154
- },
155
148
  "eslintIgnore": [
156
149
  "node_modules/",
157
150
  "lib/"
@@ -165,8 +158,7 @@
165
158
  },
166
159
  "ios": {
167
160
  "componentProvider": {
168
- "SkiaPictureView": "SkiaPictureView",
169
- "SkiaGraphiteView": "SkiaGraphiteView"
161
+ "SkiaView": "SkiaView"
170
162
  }
171
163
  }
172
164
  },
@@ -189,4 +181,4 @@
189
181
  ]
190
182
  ]
191
183
  }
192
- }
184
+ }
@@ -1,14 +1,10 @@
1
- # @shopify/react-native-skia.podspec
1
+ # react-native-skia.podspec
2
2
 
3
3
  require "json"
4
4
  require "fileutils"
5
5
 
6
6
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
7
7
 
8
- # Check if Graphite is enabled via marker file (created by install-skia-graphite)
9
- use_graphite = File.exist?(File.join(__dir__, 'libs', '.graphite'))
10
- puts "-- SK_GRAPHITE: #{use_graphite ? 'ON' : 'OFF'} (detected via libs/.graphite marker file)"
11
-
12
8
  # Resolve a node package directory using Node's own module resolution
13
9
  # (mirrors `require.resolve(pkg/package.json)`). Returns nil if it can't be found.
14
10
  # Defined as a lambda (not a `def`) because CocoaPods evaluates the podspec inside
@@ -37,10 +33,25 @@ install_apple_skia_libs = lambda do |base_dir, packages|
37
33
  src = File.join(pkg_dir, 'libs')
38
34
  next unless Dir.exist?(src) && !Dir.glob(File.join(src, '*.xcframework')).empty?
39
35
 
36
+ # Graphite packages carry the Dawn release tag they ship (libs/.dawn-version),
37
+ # used below for the react-native-webgpu version check.
38
+ dawn_version = File.join(src, '.dawn-version')
39
+ if File.exist?(dawn_version)
40
+ FileUtils.mkdir_p(File.join(base_dir, 'libs'))
41
+ FileUtils.cp(dawn_version, File.join(base_dir, 'libs', '.dawn-version'))
42
+ end
43
+
40
44
  version = JSON.parse(File.read(File.join(pkg_dir, 'package.json')))['version'].to_s
41
45
  dest = File.join(base_dir, 'libs', platform)
42
46
  marker = File.join(dest, '.version')
43
47
 
48
+ # Frameworks without a .version stamp were built locally (`yarn build-skia`):
49
+ # keep them instead of overwriting them with the npm package.
50
+ if !File.exist?(marker) && !Dir.glob(File.join(dest, '*.xcframework')).empty?
51
+ Pod::UI.puts "react-native-skia: using locally built #{platform} Skia frameworks"
52
+ next
53
+ end
54
+
44
55
  # Already up to date: leave the files untouched so CocoaPods keeps its cache.
45
56
  next if File.exist?(marker) && File.read(marker).strip == version
46
57
 
@@ -52,23 +63,15 @@ install_apple_skia_libs = lambda do |base_dir, packages|
52
63
  end
53
64
  end
54
65
 
55
- # The default (Ganesh) build ships its binaries in the react-native-skia-apple-*
56
- # npm packages, the Graphite build in react-native-skia-graphite-apple-* (no tvOS).
57
- # During in-repo development install-skia-graphite downloads the binaries directly
58
- # into libs/ and the graphite packages are absent from node_modules, in which case
59
- # the copy below is a no-op and the downloaded binaries are used as-is.
60
- apple_skia_packages = use_graphite ?
61
- { 'ios' => 'react-native-skia-graphite-apple-ios',
62
- 'macos' => 'react-native-skia-graphite-apple-macos' } :
63
- { 'ios' => 'react-native-skia-apple-ios',
64
- 'macos' => 'react-native-skia-apple-macos',
65
- 'tvos' => 'react-native-skia-apple-tvos' }
66
+ # The Graphite binaries ship in the react-native-skia-graphite-apple-* npm
67
+ # packages (no tvOS), together with the shared Dawn (libwebgpu_dawn.xcframework).
68
+ apple_skia_packages = {
69
+ 'ios' => 'react-native-skia-graphite-apple-ios',
70
+ 'macos' => 'react-native-skia-graphite-apple-macos'
71
+ }
66
72
  install_apple_skia_libs.call(__dir__, apple_skia_packages)
67
73
 
68
- # Set preprocessor definitions based on GRAPHITE flag
69
- preprocessor_defs = use_graphite ?
70
- '$(inherited) SK_GRAPHITE=1 SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API=1 SK_DISABLE_LEGACY_SHAPER_FACTORY=1' :
71
- '$(inherited) SK_METAL=1 SK_GANESH=1 SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API=1 SK_DISABLE_LEGACY_SHAPER_FACTORY=1'
74
+ preprocessor_defs = '$(inherited) SK_GRAPHITE=1 SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API=1 SK_DISABLE_LEGACY_SHAPER_FACTORY=1'
72
75
 
73
76
  # Define framework names
74
77
  framework_names = ['libskia', 'libsvg', 'libskshaper', 'libskparagraph',
@@ -81,14 +84,18 @@ framework_names = ['libskia', 'libsvg', 'libskshaper', 'libskparagraph',
81
84
  # vendoring the framework here as well would fail CocoaPods'
82
85
  # duplicate-framework-name check, so Skia only vendors it when alone. The
83
86
  # skia pod's dawn::native references resolve from webgpu's copy at app link.
87
+ # An app that installs react-native-webgpu but keeps it out of a platform's
88
+ # Pods (e.g. a macOS target that filters it out of autolinking) sets
89
+ # RNSKIA_VENDOR_DAWN=1 before `pod install` so Skia vendors Dawn itself there.
84
90
  webgpu_pkg_dir = resolve_node_package.call('react-native-webgpu', __dir__)
85
- has_webgpu_pkg = !webgpu_pkg_dir.nil?
86
- if use_graphite && has_webgpu_pkg
91
+ has_webgpu_pkg = !webgpu_pkg_dir.nil? && ENV['RNSKIA_VENDOR_DAWN'] != '1'
92
+ if has_webgpu_pkg
87
93
  Pod::UI.puts 'react-native-skia: react-native-webgpu detected, Dawn is provided by its libwebgpu_dawn'
88
94
 
89
95
  # Both packages must link the exact same Dawn artifact. Compare the release
90
- # tag this Graphite build was installed with (libs/.dawn-version) against
91
- # the tag react-native-webgpu declares in its package.json `dawn` field.
96
+ # tag the Skia binaries were packaged with (libs/.dawn-version, copied in from
97
+ # the binary package above) against the tag react-native-webgpu declares in
98
+ # its package.json `dawn` field.
92
99
  dawn_marker = File.join(__dir__, 'libs', '.dawn-version')
93
100
  if File.exist?(dawn_marker)
94
101
  skia_dawn = File.read(dawn_marker).strip
@@ -110,10 +117,22 @@ if use_graphite && has_webgpu_pkg
110
117
  Pod::UI.puts "react-native-skia: Dawn versions match (#{skia_dawn})"
111
118
  end
112
119
  end
113
- framework_names += ['libwebgpu_dawn'] if use_graphite && !has_webgpu_pkg
120
+ unless has_webgpu_pkg
121
+ # CocoaPods silently skips missing vendored frameworks, which would surface
122
+ # later as undefined dawn::native symbols at link time. Fail early instead.
123
+ %w[ios macos].each do |platform|
124
+ platform_dir = File.join(__dir__, 'libs', platform)
125
+ # A missing libs/<platform> is reported by the prebuilt binaries check below.
126
+ next if !Dir.exist?(platform_dir) || Dir.exist?(File.join(platform_dir, 'libwebgpu_dawn.xcframework'))
127
+ raise "react-native-skia: libwebgpu_dawn.xcframework not found in libs/#{platform}. " \
128
+ "The installed #{apple_skia_packages[platform]} package does not ship the shared " \
129
+ "Dawn library this Graphite build links against. Upgrade it, then run `pod install` again."
130
+ end
131
+ framework_names += ['libwebgpu_dawn']
132
+ end
114
133
 
115
134
  # Verify that the prebuilt binaries are available (copied in above from the npm
116
- # packages, or downloaded by install-skia-graphite for in-repo Graphite builds).
135
+ # packages, or built locally with `yarn build-skia`).
117
136
  unless Dir.exist?(File.join(__dir__, 'libs', 'ios')) && Dir.exist?(File.join(__dir__, 'libs', 'macos'))
118
137
  expected_packages = apple_skia_packages.values.join(', ')
119
138
  Pod::UI.warn "#{'-' * 72}"
@@ -126,33 +145,26 @@ unless Dir.exist?(File.join(__dir__, 'libs', 'ios')) && Dir.exist?(File.join(__d
126
145
  end
127
146
 
128
147
  # Build platform-specific framework paths (relative to pod's libs directory)
129
- # xcframeworks are copied into libs/ by install_apple_skia_libs above (default build)
130
- # or downloaded by install-skia-graphite (Graphite build).
148
+ # xcframeworks are copied into libs/ by install_apple_skia_libs above.
131
149
  ios_frameworks = framework_names.map { |f| "libs/ios/#{f}.xcframework" }
132
150
  osx_frameworks = framework_names.map { |f| "libs/macos/#{f}.xcframework" }
133
- # tvOS frameworks - check if libs/tvos/ exists (only populated for the default build)
134
- tvos_frameworks = if use_graphite || !Dir.exist?(File.join(__dir__, 'libs', 'tvos'))
135
- []
136
- else
137
- framework_names.map { |f| "libs/tvos/#{f}.xcframework" }
138
- end
139
151
 
140
152
  Pod::Spec.new do |s|
141
153
  s.name = "react-native-skia"
142
154
  s.version = package["version"]
143
155
  s.summary = package["description"]
144
156
  s.description = <<-DESC
145
- @shopify/react-native-skia
157
+ react-native-skia
146
158
  DESC
147
- s.homepage = "https://github.com/shopify/react-native-skia"
159
+ s.homepage = "https://github.com/wcandillon/react-native-skia"
148
160
  s.license = "MIT"
149
161
  s.license = { :type => "MIT", :file => "LICENSE.md" }
150
162
  s.authors = {
151
163
  "Christian Falch" => "christian.falch@gmail.com",
152
164
  "William Candillon" => "wcandillon@gmail.com"
153
165
  }
154
- s.platforms = { :ios => "14.0", :tvos => "13.0", :osx => "11" }
155
- s.source = { :git => "https://github.com/shopify/react-native-skia/react-native-skia.git", :tag => "#{s.version}" }
166
+ s.platforms = { :ios => "14.0", :osx => "11" }
167
+ s.source = { :git => "https://github.com/wcandillon/react-native-skia.git", :tag => "#{s.version}" }
156
168
 
157
169
  s.requires_arc = true
158
170
  s.pod_target_xcconfig = {
@@ -168,11 +180,6 @@ Pod::Spec.new do |s|
168
180
  s.ios.vendored_frameworks = ios_frameworks
169
181
  s.osx.vendored_frameworks = osx_frameworks
170
182
 
171
- # tvOS frameworks only available for non-Graphite builds
172
- unless use_graphite
173
- s.tvos.vendored_frameworks = tvos_frameworks
174
- end
175
-
176
183
  # Preserve the copied libs directory
177
184
  s.preserve_paths = ["libs/**/*"]
178
185
 
@@ -182,20 +189,6 @@ Pod::Spec.new do |s|
182
189
  "cpp/**/*.{h,cpp}"
183
190
  ]
184
191
 
185
- graphite_exclusions = [
186
- 'cpp/rnskia/RNDawnContext.h',
187
- 'cpp/rnskia/RNDawnUtils.h',
188
- 'cpp/rnskia/RNMetalLayerColorSpace.h',
189
- 'cpp/rnskia/RNDawnWindowContext.h',
190
- 'cpp/rnskia/RNDawnWindowContext.cpp',
191
- 'cpp/rnskia/RNDawnInterop.cpp',
192
- 'cpp/rnskia/RNImageProvider.h',
193
- 'cpp/rnskia/RNSkGraphiteView.h',
194
- 'cpp/api/JsiSkGraphiteContext.h',
195
- 'cpp/api/JsiSkGraphiteRecording.h'
196
- ]
197
- s.exclude_files = graphite_exclusions unless use_graphite
198
-
199
192
  install_modules_dependencies(s)
200
193
  s.dependency "React"
201
194
  s.dependency "React-callinvoker"
@@ -7,7 +7,7 @@ import { isRNModule, unwrapModule } from "../skia/types";
7
7
 
8
8
  import type { IPlatform } from "./IPlatform";
9
9
 
10
- // Layout is observed by the views themselves (see SkiaPictureView.web.tsx):
10
+ // Layout is observed by the views themselves (see SkiaView.web.tsx):
11
11
  // this shim only reproduces react-native-web's default View styling.
12
12
  const View = (({ children, style: rawStyle }: ViewProps) => {
13
13
  const style = useMemo(() => (rawStyle ?? {}) as CSSProperties, [rawStyle]);
package/src/index.ts CHANGED
@@ -1,10 +1,8 @@
1
1
  import "./skia/NativeSetup";
2
2
  export { JsiSkImage } from "./skia/web/JsiSkImage";
3
3
  export * from "./renderer";
4
- export { useCanvasRef, useCanvasSize } from "./renderer/Canvas";
4
+ export { Canvas, useCanvasRef, useCanvasSize } from "./renderer/Canvas";
5
5
  export type { CanvasProps, CanvasRef } from "./renderer/Canvas";
6
- export { GraphiteCanvas } from "./renderer/GraphiteCanvas";
7
- export { Canvas } from "./renderer/DefaultCanvas";
8
6
  export * from "./renderer/Offscreen";
9
7
  export * from "./views";
10
8
  export * from "./skia";
package/src/mock/index.ts CHANGED
@@ -23,7 +23,6 @@ export const Mock = (CanvasKit: CanvasKit) => {
23
23
  ...require("../dom/types"),
24
24
  ...require("../dom/nodes"),
25
25
  Canvas: require("react-native").View,
26
- GraphiteCanvas: require("react-native").View,
27
26
  getPreferredHighBitDepthCanvasFormat: () => "rgba16float",
28
27
  SkiaPictureView: require("react-native").View,
29
28
  SkiaGraphiteView: require("react-native").View,