react-native-skia 3.0.1 → 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 (260) hide show
  1. package/Package.swift +14 -13
  2. package/android/CMakeLists.txt +13 -42
  3. package/android/build.gradle +54 -63
  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/RNDawnInterop.cpp +0 -4
  31. package/cpp/rnskia/RNDawnUtils.h +0 -1
  32. package/cpp/rnskia/RNDawnWindowContext.cpp +10 -0
  33. package/cpp/rnskia/RNDawnWindowContext.h +4 -0
  34. package/cpp/rnskia/RNSkCanvasProvider.h +221 -0
  35. package/cpp/rnskia/RNSkGraphiteProducer.cpp +36 -14
  36. package/cpp/rnskia/RNSkGraphiteProducer.h +23 -8
  37. package/cpp/rnskia/RNSkGraphiteTarget.h +383 -0
  38. package/cpp/rnskia/RNSkJsiViewApi.h +9 -18
  39. package/cpp/rnskia/RNSkPlatformContext.h +9 -15
  40. package/cpp/rnskia/RNSkView.h +340 -245
  41. package/jestSetup.js +1 -3
  42. package/lib/commonjs/Platform/Platform.web.js +1 -1
  43. package/lib/commonjs/Platform/Platform.web.js.map +1 -1
  44. package/lib/commonjs/index.d.ts +1 -3
  45. package/lib/commonjs/index.js +3 -12
  46. package/lib/commonjs/index.js.map +1 -1
  47. package/lib/commonjs/mock/index.js +0 -1
  48. package/lib/commonjs/mock/index.js.map +1 -1
  49. package/lib/commonjs/renderer/Canvas.d.ts +15 -12
  50. package/lib/commonjs/renderer/Canvas.js +24 -20
  51. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  52. package/lib/commonjs/skia/types/Graphite.d.ts +3 -3
  53. package/lib/commonjs/skia/types/Graphite.js.map +1 -1
  54. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +2 -2
  55. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  56. package/lib/commonjs/skia/types/Skia.d.ts +1 -2
  57. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  58. package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +1 -1
  59. package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
  60. package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +5 -4
  61. package/lib/commonjs/specs/NativeSkiaModule.web.js +5 -9
  62. package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
  63. package/lib/{typescript/src/specs/SkiaPictureViewNativeComponent.d.ts → commonjs/specs/SkiaViewNativeComponent.d.ts} +0 -3
  64. package/lib/commonjs/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
  65. package/lib/commonjs/specs/SkiaViewNativeComponent.js.map +1 -0
  66. package/lib/commonjs/specs/SkiaViewNativeComponent.web.d.ts +10 -0
  67. package/lib/commonjs/specs/SkiaViewNativeComponent.web.js +27 -0
  68. package/lib/commonjs/specs/SkiaViewNativeComponent.web.js.map +1 -0
  69. package/lib/commonjs/views/SkiaGraphiteView.d.ts +3 -4
  70. package/lib/commonjs/views/SkiaGraphiteView.js +23 -12
  71. package/lib/commonjs/views/SkiaGraphiteView.js.map +1 -1
  72. package/lib/commonjs/views/SkiaPictureView.d.ts +4 -1
  73. package/lib/commonjs/views/SkiaPictureView.js +12 -10
  74. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  75. package/lib/commonjs/views/SkiaView.web.d.ts +12 -0
  76. package/lib/commonjs/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +82 -38
  77. package/lib/commonjs/views/SkiaView.web.js.map +1 -0
  78. package/lib/commonjs/views/SkiaWebRenderer.js +1 -1
  79. package/lib/commonjs/views/SkiaWebRenderer.js.map +1 -1
  80. package/lib/commonjs/views/android.d.ts +6 -0
  81. package/lib/commonjs/views/android.js +17 -0
  82. package/lib/commonjs/views/android.js.map +1 -0
  83. package/lib/commonjs/views/types.d.ts +3 -12
  84. package/lib/commonjs/views/types.js.map +1 -1
  85. package/lib/module/Platform/Platform.web.js +1 -1
  86. package/lib/module/Platform/Platform.web.js.map +1 -1
  87. package/lib/module/index.d.ts +1 -3
  88. package/lib/module/index.js +1 -3
  89. package/lib/module/index.js.map +1 -1
  90. package/lib/module/mock/index.js +0 -1
  91. package/lib/module/mock/index.js.map +1 -1
  92. package/lib/module/renderer/Canvas.d.ts +15 -12
  93. package/lib/module/renderer/Canvas.js +24 -19
  94. package/lib/module/renderer/Canvas.js.map +1 -1
  95. package/lib/module/skia/types/Graphite.d.ts +3 -3
  96. package/lib/module/skia/types/Graphite.js.map +1 -1
  97. package/lib/module/skia/types/Image/ImageFactory.d.ts +2 -2
  98. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  99. package/lib/module/skia/types/Skia.d.ts +1 -2
  100. package/lib/module/skia/types/Skia.js.map +1 -1
  101. package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +1 -1
  102. package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
  103. package/lib/module/specs/NativeSkiaModule.web.d.ts +5 -4
  104. package/lib/module/specs/NativeSkiaModule.web.js +5 -9
  105. package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
  106. package/lib/{commonjs/specs/SkiaPictureViewNativeComponent.d.ts → module/specs/SkiaViewNativeComponent.d.ts} +0 -3
  107. package/lib/module/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
  108. package/lib/module/specs/SkiaViewNativeComponent.js.map +1 -0
  109. package/lib/module/specs/SkiaViewNativeComponent.web.d.ts +10 -0
  110. package/lib/module/specs/SkiaViewNativeComponent.web.js +21 -0
  111. package/lib/module/specs/SkiaViewNativeComponent.web.js.map +1 -0
  112. package/lib/module/views/SkiaGraphiteView.d.ts +3 -4
  113. package/lib/module/views/SkiaGraphiteView.js +23 -12
  114. package/lib/module/views/SkiaGraphiteView.js.map +1 -1
  115. package/lib/module/views/SkiaPictureView.d.ts +4 -1
  116. package/lib/module/views/SkiaPictureView.js +12 -10
  117. package/lib/module/views/SkiaPictureView.js.map +1 -1
  118. package/lib/module/views/SkiaView.web.d.ts +12 -0
  119. package/lib/module/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +80 -36
  120. package/lib/module/views/SkiaView.web.js.map +1 -0
  121. package/lib/module/views/SkiaWebRenderer.js +1 -1
  122. package/lib/module/views/SkiaWebRenderer.js.map +1 -1
  123. package/lib/module/views/android.d.ts +6 -0
  124. package/lib/module/views/android.js +10 -0
  125. package/lib/module/views/android.js.map +1 -0
  126. package/lib/module/views/types.d.ts +3 -12
  127. package/lib/module/views/types.js.map +1 -1
  128. package/lib/typescript/src/index.d.ts +1 -3
  129. package/lib/typescript/src/renderer/Canvas.d.ts +15 -12
  130. package/lib/typescript/src/skia/types/Graphite.d.ts +3 -3
  131. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +2 -2
  132. package/lib/typescript/src/skia/types/Skia.d.ts +1 -2
  133. package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +1 -1
  134. package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +5 -4
  135. package/lib/{module/specs/SkiaPictureViewNativeComponent.d.ts → typescript/src/specs/SkiaViewNativeComponent.d.ts} +0 -3
  136. package/lib/typescript/src/specs/SkiaViewNativeComponent.web.d.ts +10 -0
  137. package/lib/typescript/src/views/SkiaGraphiteView.d.ts +3 -4
  138. package/lib/typescript/src/views/SkiaPictureView.d.ts +4 -1
  139. package/lib/typescript/src/views/SkiaView.web.d.ts +12 -0
  140. package/lib/typescript/src/views/android.d.ts +6 -0
  141. package/lib/typescript/src/views/types.d.ts +3 -12
  142. package/package.json +5 -13
  143. package/react-native-skia.podspec +34 -58
  144. package/src/Platform/Platform.web.tsx +1 -1
  145. package/src/index.ts +1 -3
  146. package/src/mock/index.ts +0 -1
  147. package/src/renderer/Canvas.tsx +23 -27
  148. package/src/skia/types/Graphite.ts +3 -3
  149. package/src/skia/types/Image/ImageFactory.ts +2 -2
  150. package/src/skia/types/Skia.ts +1 -2
  151. package/src/skia/types/Surface/SurfaceFactory.ts +1 -1
  152. package/src/specs/NativeSkiaModule.web.ts +9 -21
  153. package/src/specs/{SkiaPictureViewNativeComponent.ts → SkiaViewNativeComponent.ts} +1 -4
  154. package/src/specs/{SkiaPictureViewNativeComponent.web.ts → SkiaViewNativeComponent.web.ts} +8 -10
  155. package/src/views/SkiaGraphiteView.tsx +27 -16
  156. package/src/views/SkiaPictureView.tsx +11 -10
  157. package/src/views/{SkiaGraphiteView.web.tsx → SkiaView.web.tsx} +100 -53
  158. package/src/views/SkiaWebRenderer.ts +1 -1
  159. package/src/views/android.ts +16 -0
  160. package/src/views/types.ts +3 -14
  161. package/android/cpp/jni/include/JniSkiaBaseView.h +0 -92
  162. package/android/cpp/jni/include/JniSkiaGraphiteView.h +0 -176
  163. package/android/cpp/jni/include/JniSkiaPictureView.h +0 -172
  164. package/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp +0 -245
  165. package/android/cpp/rnskia-android/GrAHardwareBufferUtils.h +0 -33
  166. package/android/cpp/rnskia-android/OpenGLContext.h +0 -248
  167. package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +0 -67
  168. package/android/cpp/rnskia-android/OpenGLWindowContext.h +0 -75
  169. package/android/cpp/rnskia-android/RNSkAndroidView.h +0 -67
  170. package/android/cpp/rnskia-android/gl/Context.h +0 -80
  171. package/android/cpp/rnskia-android/gl/Display.h +0 -123
  172. package/android/cpp/rnskia-android/gl/Error.cpp +0 -45
  173. package/android/cpp/rnskia-android/gl/Error.h +0 -8
  174. package/android/cpp/rnskia-android/gl/Surface.h +0 -43
  175. package/android/src/main/java/com/reactnative/skia/SkiaBaseViewManager.java +0 -65
  176. package/android/src/main/java/com/reactnative/skia/SkiaGraphiteView.java +0 -78
  177. package/android/src/main/java/com/reactnative/skia/SkiaGraphiteViewManager.java +0 -32
  178. package/android/src/main/java/com/reactnative/skia/SkiaPictureView.java +0 -105
  179. package/android/src/main/java/com/reactnative/skia/SkiaPictureViewManager.java +0 -44
  180. package/apple/MetalContext.h +0 -116
  181. package/apple/MetalContext.mm +0 -38
  182. package/apple/MetalWindowContext.h +0 -42
  183. package/apple/MetalWindowContext.mm +0 -95
  184. package/apple/RNSkAppleView.h +0 -49
  185. package/apple/RNSkAppleView.mm +0 -35
  186. package/apple/SkiaCVPixelBufferUtils.h +0 -122
  187. package/apple/SkiaCVPixelBufferUtils.mm +0 -535
  188. package/apple/SkiaGraphiteView.h +0 -26
  189. package/apple/SkiaGraphiteView.mm +0 -180
  190. package/apple/SkiaPictureView.h +0 -7
  191. package/apple/SkiaPictureView.mm +0 -70
  192. package/apple/SkiaUIView.h +0 -31
  193. package/apple/SkiaUIView.mm +0 -164
  194. package/cpp/rnskia/RNSkGraphiteView.h +0 -708
  195. package/cpp/rnskia/RNSkPictureView.cpp +0 -69
  196. package/cpp/rnskia/RNSkPictureView.h +0 -211
  197. package/cpp/skia/src/gpu/ganesh/gl/GrGLDefines.h +0 -1162
  198. package/lib/commonjs/renderer/DefaultCanvas.d.ts +0 -8
  199. package/lib/commonjs/renderer/DefaultCanvas.js +0 -42
  200. package/lib/commonjs/renderer/DefaultCanvas.js.map +0 -1
  201. package/lib/commonjs/renderer/GraphiteCanvas.d.ts +0 -22
  202. package/lib/commonjs/renderer/GraphiteCanvas.js +0 -64
  203. package/lib/commonjs/renderer/GraphiteCanvas.js.map +0 -1
  204. package/lib/commonjs/renderer/GraphiteCanvas.web.d.ts +0 -1
  205. package/lib/commonjs/renderer/GraphiteCanvas.web.js +0 -13
  206. package/lib/commonjs/renderer/GraphiteCanvas.web.js.map +0 -1
  207. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
  208. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js +0 -12
  209. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
  210. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
  211. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js +0 -28
  212. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
  213. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +0 -1
  214. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
  215. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js +0 -29
  216. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
  217. package/lib/commonjs/views/SkiaGraphiteView.web.d.ts +0 -14
  218. package/lib/commonjs/views/SkiaGraphiteView.web.js.map +0 -1
  219. package/lib/commonjs/views/SkiaPictureView.web.d.ts +0 -11
  220. package/lib/commonjs/views/SkiaPictureView.web.js +0 -165
  221. package/lib/commonjs/views/SkiaPictureView.web.js.map +0 -1
  222. package/lib/module/renderer/DefaultCanvas.d.ts +0 -8
  223. package/lib/module/renderer/DefaultCanvas.js +0 -34
  224. package/lib/module/renderer/DefaultCanvas.js.map +0 -1
  225. package/lib/module/renderer/GraphiteCanvas.d.ts +0 -22
  226. package/lib/module/renderer/GraphiteCanvas.js +0 -57
  227. package/lib/module/renderer/GraphiteCanvas.js.map +0 -1
  228. package/lib/module/renderer/GraphiteCanvas.web.d.ts +0 -1
  229. package/lib/module/renderer/GraphiteCanvas.web.js +0 -4
  230. package/lib/module/renderer/GraphiteCanvas.web.js.map +0 -1
  231. package/lib/module/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
  232. package/lib/module/specs/SkiaGraphiteViewNativeComponent.js +0 -8
  233. package/lib/module/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
  234. package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
  235. package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js +0 -22
  236. package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
  237. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +0 -1
  238. package/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
  239. package/lib/module/specs/SkiaPictureViewNativeComponent.web.js +0 -23
  240. package/lib/module/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
  241. package/lib/module/views/SkiaGraphiteView.web.d.ts +0 -14
  242. package/lib/module/views/SkiaGraphiteView.web.js.map +0 -1
  243. package/lib/module/views/SkiaPictureView.web.d.ts +0 -11
  244. package/lib/module/views/SkiaPictureView.web.js +0 -156
  245. package/lib/module/views/SkiaPictureView.web.js.map +0 -1
  246. package/lib/typescript/src/renderer/DefaultCanvas.d.ts +0 -8
  247. package/lib/typescript/src/renderer/GraphiteCanvas.d.ts +0 -22
  248. package/lib/typescript/src/renderer/GraphiteCanvas.web.d.ts +0 -1
  249. package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
  250. package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
  251. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
  252. package/lib/typescript/src/views/SkiaGraphiteView.web.d.ts +0 -14
  253. package/lib/typescript/src/views/SkiaPictureView.web.d.ts +0 -11
  254. package/libs/.graphite +0 -1
  255. package/src/renderer/DefaultCanvas.tsx +0 -41
  256. package/src/renderer/GraphiteCanvas.tsx +0 -61
  257. package/src/renderer/GraphiteCanvas.web.tsx +0 -3
  258. package/src/specs/SkiaGraphiteViewNativeComponent.ts +0 -17
  259. package/src/specs/SkiaGraphiteViewNativeComponent.web.ts +0 -31
  260. 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.1",
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",
@@ -147,11 +145,6 @@
147
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.1",
152
- "react-native-skia-graphite-apple-ios": "154.0.1",
153
- "react-native-skia-graphite-apple-macos": "154.0.1"
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
@@ -40,12 +36,22 @@ install_apple_skia_libs = lambda do |base_dir, packages|
40
36
  # Graphite packages carry the Dawn release tag they ship (libs/.dawn-version),
41
37
  # used below for the react-native-webgpu version check.
42
38
  dawn_version = File.join(src, '.dawn-version')
43
- FileUtils.cp(dawn_version, File.join(base_dir, 'libs', '.dawn-version')) if File.exist?(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
44
43
 
45
44
  version = JSON.parse(File.read(File.join(pkg_dir, 'package.json')))['version'].to_s
46
45
  dest = File.join(base_dir, 'libs', platform)
47
46
  marker = File.join(dest, '.version')
48
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
+
49
55
  # Already up to date: leave the files untouched so CocoaPods keeps its cache.
50
56
  next if File.exist?(marker) && File.read(marker).strip == version
51
57
 
@@ -57,23 +63,15 @@ install_apple_skia_libs = lambda do |base_dir, packages|
57
63
  end
58
64
  end
59
65
 
60
- # The default (Ganesh) build ships its binaries in the react-native-skia-apple-*
61
- # npm packages, the Graphite build in react-native-skia-graphite-apple-* (no tvOS).
62
- # During in-repo development install-skia-graphite downloads the binaries directly
63
- # into libs/ and the graphite packages are absent from node_modules, in which case
64
- # the copy below is a no-op and the downloaded binaries are used as-is.
65
- apple_skia_packages = use_graphite ?
66
- { 'ios' => 'react-native-skia-graphite-apple-ios',
67
- 'macos' => 'react-native-skia-graphite-apple-macos' } :
68
- { 'ios' => 'react-native-skia-apple-ios',
69
- 'macos' => 'react-native-skia-apple-macos',
70
- '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
+ }
71
72
  install_apple_skia_libs.call(__dir__, apple_skia_packages)
72
73
 
73
- # Set preprocessor definitions based on GRAPHITE flag
74
- preprocessor_defs = use_graphite ?
75
- '$(inherited) SK_GRAPHITE=1 SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API=1 SK_DISABLE_LEGACY_SHAPER_FACTORY=1' :
76
- '$(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'
77
75
 
78
76
  # Define framework names
79
77
  framework_names = ['libskia', 'libsvg', 'libskshaper', 'libskparagraph',
@@ -86,14 +84,18 @@ framework_names = ['libskia', 'libsvg', 'libskshaper', 'libskparagraph',
86
84
  # vendoring the framework here as well would fail CocoaPods'
87
85
  # duplicate-framework-name check, so Skia only vendors it when alone. The
88
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.
89
90
  webgpu_pkg_dir = resolve_node_package.call('react-native-webgpu', __dir__)
90
- has_webgpu_pkg = !webgpu_pkg_dir.nil?
91
- if use_graphite && has_webgpu_pkg
91
+ has_webgpu_pkg = !webgpu_pkg_dir.nil? && ENV['RNSKIA_VENDOR_DAWN'] != '1'
92
+ if has_webgpu_pkg
92
93
  Pod::UI.puts 'react-native-skia: react-native-webgpu detected, Dawn is provided by its libwebgpu_dawn'
93
94
 
94
95
  # Both packages must link the exact same Dawn artifact. Compare the release
95
- # tag this Graphite build was installed with (libs/.dawn-version) against
96
- # 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.
97
99
  dawn_marker = File.join(__dir__, 'libs', '.dawn-version')
98
100
  if File.exist?(dawn_marker)
99
101
  skia_dawn = File.read(dawn_marker).strip
@@ -115,7 +117,7 @@ if use_graphite && has_webgpu_pkg
115
117
  Pod::UI.puts "react-native-skia: Dawn versions match (#{skia_dawn})"
116
118
  end
117
119
  end
118
- if use_graphite && !has_webgpu_pkg
120
+ unless has_webgpu_pkg
119
121
  # CocoaPods silently skips missing vendored frameworks, which would surface
120
122
  # later as undefined dawn::native symbols at link time. Fail early instead.
121
123
  %w[ios macos].each do |platform|
@@ -130,7 +132,7 @@ if use_graphite && !has_webgpu_pkg
130
132
  end
131
133
 
132
134
  # Verify that the prebuilt binaries are available (copied in above from the npm
133
- # packages, or downloaded by install-skia-graphite for in-repo Graphite builds).
135
+ # packages, or built locally with `yarn build-skia`).
134
136
  unless Dir.exist?(File.join(__dir__, 'libs', 'ios')) && Dir.exist?(File.join(__dir__, 'libs', 'macos'))
135
137
  expected_packages = apple_skia_packages.values.join(', ')
136
138
  Pod::UI.warn "#{'-' * 72}"
@@ -143,33 +145,26 @@ unless Dir.exist?(File.join(__dir__, 'libs', 'ios')) && Dir.exist?(File.join(__d
143
145
  end
144
146
 
145
147
  # Build platform-specific framework paths (relative to pod's libs directory)
146
- # xcframeworks are copied into libs/ by install_apple_skia_libs above (default build)
147
- # or downloaded by install-skia-graphite (Graphite build).
148
+ # xcframeworks are copied into libs/ by install_apple_skia_libs above.
148
149
  ios_frameworks = framework_names.map { |f| "libs/ios/#{f}.xcframework" }
149
150
  osx_frameworks = framework_names.map { |f| "libs/macos/#{f}.xcframework" }
150
- # tvOS frameworks - check if libs/tvos/ exists (only populated for the default build)
151
- tvos_frameworks = if use_graphite || !Dir.exist?(File.join(__dir__, 'libs', 'tvos'))
152
- []
153
- else
154
- framework_names.map { |f| "libs/tvos/#{f}.xcframework" }
155
- end
156
151
 
157
152
  Pod::Spec.new do |s|
158
153
  s.name = "react-native-skia"
159
154
  s.version = package["version"]
160
155
  s.summary = package["description"]
161
156
  s.description = <<-DESC
162
- @shopify/react-native-skia
157
+ react-native-skia
163
158
  DESC
164
- s.homepage = "https://github.com/shopify/react-native-skia"
159
+ s.homepage = "https://github.com/wcandillon/react-native-skia"
165
160
  s.license = "MIT"
166
161
  s.license = { :type => "MIT", :file => "LICENSE.md" }
167
162
  s.authors = {
168
163
  "Christian Falch" => "christian.falch@gmail.com",
169
164
  "William Candillon" => "wcandillon@gmail.com"
170
165
  }
171
- s.platforms = { :ios => "14.0", :tvos => "13.0", :osx => "11" }
172
- 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}" }
173
168
 
174
169
  s.requires_arc = true
175
170
  s.pod_target_xcconfig = {
@@ -185,11 +180,6 @@ Pod::Spec.new do |s|
185
180
  s.ios.vendored_frameworks = ios_frameworks
186
181
  s.osx.vendored_frameworks = osx_frameworks
187
182
 
188
- # tvOS frameworks only available for non-Graphite builds
189
- unless use_graphite
190
- s.tvos.vendored_frameworks = tvos_frameworks
191
- end
192
-
193
183
  # Preserve the copied libs directory
194
184
  s.preserve_paths = ["libs/**/*"]
195
185
 
@@ -199,20 +189,6 @@ Pod::Spec.new do |s|
199
189
  "cpp/**/*.{h,cpp}"
200
190
  ]
201
191
 
202
- graphite_exclusions = [
203
- 'cpp/rnskia/RNDawnContext.h',
204
- 'cpp/rnskia/RNDawnUtils.h',
205
- 'cpp/rnskia/RNMetalLayerColorSpace.h',
206
- 'cpp/rnskia/RNDawnWindowContext.h',
207
- 'cpp/rnskia/RNDawnWindowContext.cpp',
208
- 'cpp/rnskia/RNDawnInterop.cpp',
209
- 'cpp/rnskia/RNImageProvider.h',
210
- 'cpp/rnskia/RNSkGraphiteView.h',
211
- 'cpp/api/JsiSkGraphiteContext.h',
212
- 'cpp/api/JsiSkGraphiteRecording.h'
213
- ]
214
- s.exclude_files = graphite_exclusions unless use_graphite
215
-
216
192
  install_modules_dependencies(s)
217
193
  s.dependency "React"
218
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,