react-native-skia 3.0.1 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/Package.swift +14 -13
  2. package/README.md +19 -2
  3. package/android/CMakeLists.txt +13 -42
  4. package/android/build.gradle +54 -63
  5. package/android/cpp/jni/JniLoad.cpp +2 -4
  6. package/android/cpp/jni/include/JniSkiaView.h +123 -0
  7. package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.cpp → RNSkAndroidCanvasProvider.cpp} +45 -100
  8. package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.h → RNSkAndroidCanvasProvider.h} +24 -22
  9. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +0 -83
  10. package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +0 -8
  11. package/android/src/main/java/com/reactnative/skia/RNSkiaPackage.java +1 -2
  12. package/android/src/main/java/com/reactnative/skia/SkiaSurfaceView.java +1 -3
  13. package/android/src/main/java/com/reactnative/skia/SkiaTextureView.java +1 -17
  14. package/android/src/main/java/com/reactnative/skia/{SkiaBaseView.java → SkiaView.java} +78 -16
  15. package/android/src/main/java/com/reactnative/skia/SkiaViewManager.java +85 -0
  16. package/apple/MetalLayerColorSpace.mm +10 -12
  17. package/apple/RNSkApplePlatformContext.h +12 -14
  18. package/apple/RNSkApplePlatformContext.mm +19 -112
  19. package/apple/RNSkMetalCanvasProvider.h +14 -19
  20. package/apple/RNSkMetalCanvasProvider.mm +39 -70
  21. package/apple/RNSkiaModule.mm +10 -0
  22. package/apple/SkiaView.h +20 -0
  23. package/apple/SkiaView.mm +210 -0
  24. package/cpp/api/JsiSkApi.h +2 -13
  25. package/cpp/api/JsiSkCanvas.h +4 -18
  26. package/cpp/api/JsiSkGraphiteContext.h +1 -5
  27. package/cpp/api/JsiSkGraphiteRecording.h +1 -5
  28. package/cpp/api/JsiSkImage.h +7 -41
  29. package/cpp/api/JsiSkImageFactory.h +0 -14
  30. package/cpp/api/JsiSkSurface.h +2 -16
  31. package/cpp/api/JsiSkSurfaceFactory.h +0 -8
  32. package/cpp/rnskia/RNDawnContext.h +3 -2
  33. package/cpp/rnskia/RNDawnInterop.cpp +0 -4
  34. package/cpp/rnskia/RNDawnUtils.h +12 -1
  35. package/cpp/rnskia/RNDawnWindowContext.cpp +12 -1
  36. package/cpp/rnskia/RNDawnWindowContext.h +19 -7
  37. package/cpp/rnskia/RNMetalLayerColorSpace.h +4 -2
  38. package/cpp/rnskia/RNSkCanvasProvider.h +231 -0
  39. package/cpp/rnskia/RNSkGraphiteProducer.cpp +36 -14
  40. package/cpp/rnskia/RNSkGraphiteProducer.h +23 -8
  41. package/cpp/rnskia/RNSkGraphiteTarget.h +396 -0
  42. package/cpp/rnskia/RNSkJsiViewApi.h +9 -18
  43. package/cpp/rnskia/RNSkPlatformContext.h +17 -15
  44. package/cpp/rnskia/RNSkView.h +362 -246
  45. package/jestSetup.js +1 -3
  46. package/lib/commonjs/Platform/Platform.web.js +1 -1
  47. package/lib/commonjs/Platform/Platform.web.js.map +1 -1
  48. package/lib/commonjs/external/reanimated/interpolators.js +1 -1
  49. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  50. package/lib/commonjs/index.d.ts +1 -3
  51. package/lib/commonjs/index.js +3 -12
  52. package/lib/commonjs/index.js.map +1 -1
  53. package/lib/commonjs/mock/index.js +0 -1
  54. package/lib/commonjs/mock/index.js.map +1 -1
  55. package/lib/commonjs/renderer/Canvas.d.ts +15 -12
  56. package/lib/commonjs/renderer/Canvas.js +25 -21
  57. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  58. package/lib/commonjs/skia/types/Graphite.d.ts +3 -3
  59. package/lib/commonjs/skia/types/Graphite.js.map +1 -1
  60. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +2 -2
  61. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  62. package/lib/commonjs/skia/types/Skia.d.ts +1 -2
  63. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  64. package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +1 -1
  65. package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
  66. package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +5 -4
  67. package/lib/commonjs/specs/NativeSkiaModule.web.js +5 -9
  68. package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
  69. package/lib/{typescript/src/specs/SkiaPictureViewNativeComponent.d.ts → commonjs/specs/SkiaViewNativeComponent.d.ts} +0 -3
  70. package/lib/commonjs/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
  71. package/lib/commonjs/specs/SkiaViewNativeComponent.js.map +1 -0
  72. package/lib/commonjs/specs/SkiaViewNativeComponent.web.d.ts +10 -0
  73. package/lib/commonjs/specs/SkiaViewNativeComponent.web.js +27 -0
  74. package/lib/commonjs/specs/SkiaViewNativeComponent.web.js.map +1 -0
  75. package/lib/commonjs/views/SkiaGraphiteView.d.ts +3 -4
  76. package/lib/commonjs/views/SkiaGraphiteView.js +23 -12
  77. package/lib/commonjs/views/SkiaGraphiteView.js.map +1 -1
  78. package/lib/commonjs/views/SkiaPictureView.d.ts +4 -1
  79. package/lib/commonjs/views/SkiaPictureView.js +12 -10
  80. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  81. package/lib/commonjs/views/SkiaView.web.d.ts +12 -0
  82. package/lib/commonjs/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +82 -38
  83. package/lib/commonjs/views/SkiaView.web.js.map +1 -0
  84. package/lib/commonjs/views/SkiaWebRenderer.js +1 -1
  85. package/lib/commonjs/views/SkiaWebRenderer.js.map +1 -1
  86. package/lib/commonjs/views/android.d.ts +6 -0
  87. package/lib/commonjs/views/android.js +17 -0
  88. package/lib/commonjs/views/android.js.map +1 -0
  89. package/lib/commonjs/views/types.d.ts +3 -12
  90. package/lib/commonjs/views/types.js.map +1 -1
  91. package/lib/module/Platform/Platform.web.js +1 -1
  92. package/lib/module/Platform/Platform.web.js.map +1 -1
  93. package/lib/module/external/reanimated/interpolators.js +1 -1
  94. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  95. package/lib/module/index.d.ts +1 -3
  96. package/lib/module/index.js +1 -3
  97. package/lib/module/index.js.map +1 -1
  98. package/lib/module/mock/index.js +0 -1
  99. package/lib/module/mock/index.js.map +1 -1
  100. package/lib/module/renderer/Canvas.d.ts +15 -12
  101. package/lib/module/renderer/Canvas.js +25 -20
  102. package/lib/module/renderer/Canvas.js.map +1 -1
  103. package/lib/module/skia/types/Graphite.d.ts +3 -3
  104. package/lib/module/skia/types/Graphite.js.map +1 -1
  105. package/lib/module/skia/types/Image/ImageFactory.d.ts +2 -2
  106. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  107. package/lib/module/skia/types/Skia.d.ts +1 -2
  108. package/lib/module/skia/types/Skia.js.map +1 -1
  109. package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +1 -1
  110. package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
  111. package/lib/module/specs/NativeSkiaModule.web.d.ts +5 -4
  112. package/lib/module/specs/NativeSkiaModule.web.js +5 -9
  113. package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
  114. package/lib/{commonjs/specs/SkiaPictureViewNativeComponent.d.ts → module/specs/SkiaViewNativeComponent.d.ts} +0 -3
  115. package/lib/module/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
  116. package/lib/module/specs/SkiaViewNativeComponent.js.map +1 -0
  117. package/lib/module/specs/SkiaViewNativeComponent.web.d.ts +10 -0
  118. package/lib/module/specs/SkiaViewNativeComponent.web.js +21 -0
  119. package/lib/module/specs/SkiaViewNativeComponent.web.js.map +1 -0
  120. package/lib/module/views/SkiaGraphiteView.d.ts +3 -4
  121. package/lib/module/views/SkiaGraphiteView.js +23 -12
  122. package/lib/module/views/SkiaGraphiteView.js.map +1 -1
  123. package/lib/module/views/SkiaPictureView.d.ts +4 -1
  124. package/lib/module/views/SkiaPictureView.js +12 -10
  125. package/lib/module/views/SkiaPictureView.js.map +1 -1
  126. package/lib/module/views/SkiaView.web.d.ts +12 -0
  127. package/lib/module/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +80 -36
  128. package/lib/module/views/SkiaView.web.js.map +1 -0
  129. package/lib/module/views/SkiaWebRenderer.js +1 -1
  130. package/lib/module/views/SkiaWebRenderer.js.map +1 -1
  131. package/lib/module/views/android.d.ts +6 -0
  132. package/lib/module/views/android.js +10 -0
  133. package/lib/module/views/android.js.map +1 -0
  134. package/lib/module/views/types.d.ts +3 -12
  135. package/lib/module/views/types.js.map +1 -1
  136. package/lib/typescript/src/index.d.ts +1 -3
  137. package/lib/typescript/src/renderer/Canvas.d.ts +15 -12
  138. package/lib/typescript/src/skia/types/Graphite.d.ts +3 -3
  139. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +2 -2
  140. package/lib/typescript/src/skia/types/Skia.d.ts +1 -2
  141. package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +1 -1
  142. package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +5 -4
  143. package/lib/{module/specs/SkiaPictureViewNativeComponent.d.ts → typescript/src/specs/SkiaViewNativeComponent.d.ts} +0 -3
  144. package/lib/typescript/src/specs/SkiaViewNativeComponent.web.d.ts +10 -0
  145. package/lib/typescript/src/views/SkiaGraphiteView.d.ts +3 -4
  146. package/lib/typescript/src/views/SkiaPictureView.d.ts +4 -1
  147. package/lib/typescript/src/views/SkiaView.web.d.ts +12 -0
  148. package/lib/typescript/src/views/android.d.ts +6 -0
  149. package/lib/typescript/src/views/types.d.ts +3 -12
  150. package/package.json +5 -13
  151. package/react-native-skia.podspec +34 -58
  152. package/src/Platform/Platform.web.tsx +1 -1
  153. package/src/external/reanimated/interpolators.ts +1 -1
  154. package/src/index.ts +1 -3
  155. package/src/mock/index.ts +0 -1
  156. package/src/renderer/Canvas.tsx +24 -28
  157. package/src/skia/types/Graphite.ts +3 -3
  158. package/src/skia/types/Image/ImageFactory.ts +2 -2
  159. package/src/skia/types/Skia.ts +1 -2
  160. package/src/skia/types/Surface/SurfaceFactory.ts +1 -1
  161. package/src/specs/NativeSkiaModule.web.ts +9 -21
  162. package/src/specs/{SkiaPictureViewNativeComponent.ts → SkiaViewNativeComponent.ts} +1 -4
  163. package/src/specs/{SkiaPictureViewNativeComponent.web.ts → SkiaViewNativeComponent.web.ts} +8 -10
  164. package/src/views/SkiaGraphiteView.tsx +27 -16
  165. package/src/views/SkiaPictureView.tsx +11 -10
  166. package/src/views/{SkiaGraphiteView.web.tsx → SkiaView.web.tsx} +100 -53
  167. package/src/views/SkiaWebRenderer.ts +1 -1
  168. package/src/views/android.ts +16 -0
  169. package/src/views/types.ts +3 -14
  170. package/android/cpp/jni/include/JniSkiaBaseView.h +0 -92
  171. package/android/cpp/jni/include/JniSkiaGraphiteView.h +0 -176
  172. package/android/cpp/jni/include/JniSkiaPictureView.h +0 -172
  173. package/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp +0 -245
  174. package/android/cpp/rnskia-android/GrAHardwareBufferUtils.h +0 -33
  175. package/android/cpp/rnskia-android/OpenGLContext.h +0 -248
  176. package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +0 -67
  177. package/android/cpp/rnskia-android/OpenGLWindowContext.h +0 -75
  178. package/android/cpp/rnskia-android/RNSkAndroidView.h +0 -67
  179. package/android/cpp/rnskia-android/gl/Context.h +0 -80
  180. package/android/cpp/rnskia-android/gl/Display.h +0 -123
  181. package/android/cpp/rnskia-android/gl/Error.cpp +0 -45
  182. package/android/cpp/rnskia-android/gl/Error.h +0 -8
  183. package/android/cpp/rnskia-android/gl/Surface.h +0 -43
  184. package/android/src/main/java/com/reactnative/skia/SkiaBaseViewManager.java +0 -65
  185. package/android/src/main/java/com/reactnative/skia/SkiaGraphiteView.java +0 -78
  186. package/android/src/main/java/com/reactnative/skia/SkiaGraphiteViewManager.java +0 -32
  187. package/android/src/main/java/com/reactnative/skia/SkiaPictureView.java +0 -105
  188. package/android/src/main/java/com/reactnative/skia/SkiaPictureViewManager.java +0 -44
  189. package/apple/MetalContext.h +0 -116
  190. package/apple/MetalContext.mm +0 -38
  191. package/apple/MetalWindowContext.h +0 -42
  192. package/apple/MetalWindowContext.mm +0 -95
  193. package/apple/RNSkAppleView.h +0 -49
  194. package/apple/RNSkAppleView.mm +0 -35
  195. package/apple/SkiaCVPixelBufferUtils.h +0 -122
  196. package/apple/SkiaCVPixelBufferUtils.mm +0 -535
  197. package/apple/SkiaGraphiteView.h +0 -26
  198. package/apple/SkiaGraphiteView.mm +0 -180
  199. package/apple/SkiaPictureView.h +0 -7
  200. package/apple/SkiaPictureView.mm +0 -70
  201. package/apple/SkiaUIView.h +0 -31
  202. package/apple/SkiaUIView.mm +0 -164
  203. package/cpp/rnskia/RNSkGraphiteView.h +0 -708
  204. package/cpp/rnskia/RNSkPictureView.cpp +0 -69
  205. package/cpp/rnskia/RNSkPictureView.h +0 -211
  206. package/cpp/skia/src/gpu/ganesh/gl/GrGLDefines.h +0 -1162
  207. package/lib/commonjs/renderer/DefaultCanvas.d.ts +0 -8
  208. package/lib/commonjs/renderer/DefaultCanvas.js +0 -42
  209. package/lib/commonjs/renderer/DefaultCanvas.js.map +0 -1
  210. package/lib/commonjs/renderer/GraphiteCanvas.d.ts +0 -22
  211. package/lib/commonjs/renderer/GraphiteCanvas.js +0 -64
  212. package/lib/commonjs/renderer/GraphiteCanvas.js.map +0 -1
  213. package/lib/commonjs/renderer/GraphiteCanvas.web.d.ts +0 -1
  214. package/lib/commonjs/renderer/GraphiteCanvas.web.js +0 -13
  215. package/lib/commonjs/renderer/GraphiteCanvas.web.js.map +0 -1
  216. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
  217. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js +0 -12
  218. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
  219. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
  220. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js +0 -28
  221. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
  222. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +0 -1
  223. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
  224. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js +0 -29
  225. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
  226. package/lib/commonjs/views/SkiaGraphiteView.web.d.ts +0 -14
  227. package/lib/commonjs/views/SkiaGraphiteView.web.js.map +0 -1
  228. package/lib/commonjs/views/SkiaPictureView.web.d.ts +0 -11
  229. package/lib/commonjs/views/SkiaPictureView.web.js +0 -165
  230. package/lib/commonjs/views/SkiaPictureView.web.js.map +0 -1
  231. package/lib/module/renderer/DefaultCanvas.d.ts +0 -8
  232. package/lib/module/renderer/DefaultCanvas.js +0 -34
  233. package/lib/module/renderer/DefaultCanvas.js.map +0 -1
  234. package/lib/module/renderer/GraphiteCanvas.d.ts +0 -22
  235. package/lib/module/renderer/GraphiteCanvas.js +0 -57
  236. package/lib/module/renderer/GraphiteCanvas.js.map +0 -1
  237. package/lib/module/renderer/GraphiteCanvas.web.d.ts +0 -1
  238. package/lib/module/renderer/GraphiteCanvas.web.js +0 -4
  239. package/lib/module/renderer/GraphiteCanvas.web.js.map +0 -1
  240. package/lib/module/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
  241. package/lib/module/specs/SkiaGraphiteViewNativeComponent.js +0 -8
  242. package/lib/module/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
  243. package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
  244. package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js +0 -22
  245. package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
  246. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +0 -1
  247. package/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
  248. package/lib/module/specs/SkiaPictureViewNativeComponent.web.js +0 -23
  249. package/lib/module/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
  250. package/lib/module/views/SkiaGraphiteView.web.d.ts +0 -14
  251. package/lib/module/views/SkiaGraphiteView.web.js.map +0 -1
  252. package/lib/module/views/SkiaPictureView.web.d.ts +0 -11
  253. package/lib/module/views/SkiaPictureView.web.js +0 -156
  254. package/lib/module/views/SkiaPictureView.web.js.map +0 -1
  255. package/lib/typescript/src/renderer/DefaultCanvas.d.ts +0 -8
  256. package/lib/typescript/src/renderer/GraphiteCanvas.d.ts +0 -22
  257. package/lib/typescript/src/renderer/GraphiteCanvas.web.d.ts +0 -1
  258. package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
  259. package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
  260. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
  261. package/lib/typescript/src/views/SkiaGraphiteView.web.d.ts +0 -14
  262. package/lib/typescript/src/views/SkiaPictureView.web.d.ts +0 -11
  263. package/libs/.graphite +0 -1
  264. package/src/renderer/DefaultCanvas.tsx +0 -41
  265. package/src/renderer/GraphiteCanvas.tsx +0 -61
  266. package/src/renderer/GraphiteCanvas.web.tsx +0 -3
  267. package/src/specs/SkiaGraphiteViewNativeComponent.ts +0 -17
  268. package/src/specs/SkiaGraphiteViewNativeComponent.web.ts +0 -31
  269. package/src/views/SkiaPictureView.web.tsx +0 -224
@@ -13,9 +13,7 @@
13
13
  #include "JsiSkNativeObjects.h"
14
14
  #include "jsi/JsiPromises.h"
15
15
 
16
- #ifdef SK_GRAPHITE
17
16
  #include "rnskia/RNDawnContext.h"
18
- #endif
19
17
 
20
18
  namespace RNSkia {
21
19
 
@@ -109,7 +107,6 @@ public:
109
107
  // device: both packages link one Dawn and share one wgpu::Instance.
110
108
 
111
109
  JSI_HOST_FUNCTION(MakeImageFromNativeTexture) {
112
- #ifdef SK_GRAPHITE
113
110
  if (count < 1 || !arguments[0].isBigInt()) {
114
111
  throw std::runtime_error("MakeImageFromNativeTexture requires a "
115
112
  "WGPUTexture pointer (BigInt), e.g. "
@@ -137,15 +134,9 @@ public:
137
134
  }
138
135
  return makeJsiObject(
139
136
  runtime, std::make_shared<JsiSkImage>(getContext(), std::move(image)));
140
- #else
141
- throw std::runtime_error(
142
- "MakeImageFromNativeTexture is only available with the Graphite "
143
- "backend. Rebuild with SK_GRAPHITE enabled.");
144
- #endif
145
137
  }
146
138
 
147
139
  JSI_HOST_FUNCTION(MakeNativeTextureFromImage) {
148
- #ifdef SK_GRAPHITE
149
140
  if (count < 1) {
150
141
  throw std::runtime_error(
151
142
  "MakeNativeTextureFromImage requires an SkImage argument");
@@ -165,11 +156,6 @@ public:
165
156
  // releases it when the JS GPUTexture is destroyed.
166
157
  return jsi::BigInt::fromUint64(
167
158
  runtime, reinterpret_cast<uint64_t>(texture.MoveToCHandle()));
168
- #else
169
- throw std::runtime_error(
170
- "MakeNativeTextureFromImage is only available with the Graphite "
171
- "backend. Rebuild with SK_GRAPHITE enabled.");
172
- #endif
173
159
  }
174
160
 
175
161
  size_t getMemoryPressure() override { return 1024; }
@@ -15,15 +15,12 @@
15
15
  #include "JsiSkCanvas.h"
16
16
  #include "JsiSkImage.h"
17
17
 
18
- #if defined(SK_GRAPHITE)
19
18
  #include "rnskia/RNDawnContext.h"
20
- #endif
21
19
 
22
20
  #pragma clang diagnostic push
23
21
  #pragma clang diagnostic ignored "-Wdocumentation"
24
22
 
25
23
  #include "include/core/SkSurface.h"
26
- #include "include/gpu/ganesh/GrDirectContext.h"
27
24
 
28
25
  #pragma clang diagnostic pop
29
26
 
@@ -87,7 +84,6 @@ public:
87
84
  // submitted work. Required before a native consumer on a different command
88
85
  // queue reads this surface's texture via getNativeTextureUnstable(). #3916
89
86
  bool sync = syncParam.has_value() && *syncParam;
90
- #if defined(SK_GRAPHITE)
91
87
  // A raster surface (e.g. Skia.Surface.Make) has no Graphite recorder;
92
88
  // only Graphite-backed surfaces need to snap and submit a recording.
93
89
  if (auto *recorder = surface->recorder()) {
@@ -96,11 +92,6 @@ public:
96
92
  recording.get(), sync ? skgpu::graphite::SyncToCpu::kYes
97
93
  : skgpu::graphite::SyncToCpu::kNo);
98
94
  }
99
- #else
100
- if (auto dContext = GrAsDirectContext(surface->recordingContext())) {
101
- dContext->flushAndSubmit(sync ? GrSyncCpu::kYes : GrSyncCpu::kNo);
102
- }
103
- #endif
104
95
  }
105
96
 
106
97
  JSI_HOST_FUNCTION(makeImageSnapshot) {
@@ -113,14 +104,12 @@ public:
113
104
  } else {
114
105
  image = surface->makeImageSnapshot();
115
106
  }
116
- #if defined(SK_GRAPHITE)
117
107
  // A raster surface (e.g. Skia.Surface.Make) has no Graphite recorder; its
118
108
  // snapshot is already a valid CPU image, so skip the recording submit.
119
109
  if (auto *recorder = surface->recorder()) {
120
110
  auto recording = recorder->snap();
121
111
  DawnContext::getInstance().submitRecording(recording.get());
122
112
  }
123
- #endif
124
113
  if (count > 1 && arguments[1].isObject()) {
125
114
  auto jsiImage = getJsiObject<JsiSkImage>(runtime, arguments[1]);
126
115
  jsiImage->setObject(image);
@@ -173,11 +162,8 @@ public:
173
162
  size_t estimated = pixelBytes;
174
163
 
175
164
  auto canvas = surface->getCanvas();
176
- const bool isGpuBacked =
177
- surface->recordingContext() != nullptr ||
178
- surface->recorder() != nullptr ||
179
- (canvas && (canvas->recordingContext() != nullptr ||
180
- canvas->recorder() != nullptr));
165
+ const bool isGpuBacked = surface->recorder() != nullptr ||
166
+ (canvas && canvas->recorder() != nullptr);
181
167
 
182
168
  if (isGpuBacked) {
183
169
  // Account for a resolved texture and depth/stencil attachments.
@@ -10,9 +10,7 @@
10
10
 
11
11
  #include "JsiSkSurface.h"
12
12
 
13
- #ifdef SK_GRAPHITE
14
13
  #include "rnskia/RNDawnContext.h"
15
- #endif
16
14
 
17
15
  #pragma clang diagnostic push
18
16
  #pragma clang diagnostic ignored "-Wdocumentation"
@@ -68,7 +66,6 @@ public:
68
66
  // directly into a texture created on the shared device, so WebGPU can
69
67
  // sample what Skia drew without any copy.
70
68
  JSI_HOST_FUNCTION(MakeFromNativeTexture) {
71
- #ifdef SK_GRAPHITE
72
69
  if (count < 1 || !arguments[0].isBigInt()) {
73
70
  throw std::runtime_error("MakeFromNativeTexture requires a WGPUTexture "
74
71
  "pointer (BigInt), e.g. texture.nativePointer");
@@ -91,11 +88,6 @@ public:
91
88
  }
92
89
  return makeJsiObject(runtime, std::make_shared<JsiSkSurface>(
93
90
  getContext(), std::move(surface)));
94
- #else
95
- throw std::runtime_error(
96
- "MakeFromNativeTexture is only available with the Graphite backend. "
97
- "Rebuild with SK_GRAPHITE enabled.");
98
- #endif
99
91
  }
100
92
 
101
93
  size_t getMemoryPressure() override { return 2048; }
@@ -406,7 +406,8 @@ public:
406
406
 
407
407
  // Create onscreen surface with window
408
408
  std::unique_ptr<WindowContext> MakeWindow(void *window, int width, int height,
409
- bool highBitDepth = false) {
409
+ bool highBitDepth = false,
410
+ bool useP3ColorSpace = false) {
410
411
  // 1. Create Surface
411
412
  wgpu::SurfaceDescriptor surfaceDescriptor;
412
413
  #ifdef __APPLE__
@@ -422,7 +423,7 @@ public:
422
423
  wgpu::Instance(instance->Get()).CreateSurface(&surfaceDescriptor);
423
424
  return std::make_unique<DawnWindowContext>(
424
425
  getRecorder(), backendContext.fDevice, surface, window, width, height,
425
- highBitDepth);
426
+ highBitDepth, useP3ColorSpace);
426
427
  }
427
428
 
428
429
  skgpu::graphite::Recorder *getRecorder() {
@@ -1,5 +1,3 @@
1
- #ifdef SK_GRAPHITE
2
-
3
1
  #include "RNDawnContext.h"
4
2
 
5
3
  // Runtime discovery surface for react-native-webgpu.
@@ -15,5 +13,3 @@ extern "C" __attribute__((visibility("default"))) WGPUInstance
15
13
  rnskia_getWGPUInstance() {
16
14
  return RNSkia::DawnContext::getInstance().getWGPUInstance().Get();
17
15
  }
18
-
19
- #endif
@@ -8,6 +8,7 @@
8
8
 
9
9
  #include "dawn/native/DawnNative.h"
10
10
 
11
+ #include "include/core/SkColorSpace.h"
11
12
  #include "include/core/SkColorType.h"
12
13
  #include "include/gpu/graphite/dawn/DawnBackendContext.h"
13
14
  #include "utils/RNSkLog.h"
@@ -42,6 +43,17 @@ static const wgpu::TextureFormat HighBitDepthTextureFormat =
42
43
  wgpu::TextureFormat::RGB10A2Unorm;
43
44
  #endif
44
45
 
46
+ // The color space a view renders in: Display P3 (with the sRGB transfer
47
+ // function) where the platform prefers it (a wide gamut display on Apple
48
+ // platforms, see RNSkPlatformContext::prefersP3ColorSpace), sRGB otherwise.
49
+ // Colors are managed either way: content looks the same in both, Display P3
50
+ // only adds the colors sRGB cannot represent.
51
+ inline sk_sp<SkColorSpace> viewColorSpace(bool useP3ColorSpace) {
52
+ return useP3ColorSpace ? SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB,
53
+ SkNamedGamut::kDisplayP3)
54
+ : SkColorSpace::MakeSRGB();
55
+ }
56
+
45
57
  // Usage requested for a window texture when the surface supports it (see
46
58
  // DawnWindowContext::supportedSurfaceUsage), and assumed for a Graphite
47
59
  // recording made before its window exists: TextureBinding lets a render pass
@@ -137,7 +149,6 @@ requestDevice(dawn::native::Adapter &nativeAdapter,
137
149
  #endif
138
150
  "disable_lazy_clear_for_mapped_at_creation_buffer",
139
151
  "allow_unsafe_apis",
140
- "use_user_defined_labels_in_backend",
141
152
  "disable_robustness",
142
153
  };
143
154
  wgpu::DawnTogglesDescriptor togglesDesc;
@@ -29,7 +29,8 @@ bool DawnWindowContext::presentRecordings(
29
29
  auto backendTex = skgpu::graphite::BackendTextures::MakeDawn(texture.Get());
30
30
  SkSurfaceProps surfaceProps;
31
31
  auto surface = SkSurfaces::WrapBackendTexture(
32
- _recorder, backendTex, SkColorSpace::MakeSRGB(), &surfaceProps);
32
+ _recorder, backendTex, DawnUtils::viewColorSpace(_useP3ColorSpace),
33
+ &surfaceProps);
33
34
  if (!surface) {
34
35
  return false;
35
36
  }
@@ -42,4 +43,14 @@ bool DawnWindowContext::presentRecordings(
42
43
  return success;
43
44
  }
44
45
 
46
+ bool DawnWindowContext::presentImage(const sk_sp<SkImage> &image) {
47
+ auto surface = getSurface();
48
+ if (!surface) {
49
+ return false;
50
+ }
51
+ surface->getCanvas()->drawImage(image, 0, 0);
52
+ present();
53
+ return true;
54
+ }
55
+
45
56
  } // namespace RNSkia
@@ -30,9 +30,11 @@ class DawnWindowContext : public WindowContext {
30
30
  public:
31
31
  DawnWindowContext(skgpu::graphite::Recorder *recorder, wgpu::Device device,
32
32
  wgpu::Surface surface, void *nativeSurface, int width,
33
- int height, bool highBitDepth = false)
33
+ int height, bool highBitDepth = false,
34
+ bool useP3ColorSpace = false)
34
35
  : _recorder(recorder), _device(device), _surface(surface),
35
- _nativeSurface(nativeSurface), _width(width), _height(height) {
36
+ _nativeSurface(nativeSurface), _useP3ColorSpace(useP3ColorSpace),
37
+ _width(width), _height(height) {
36
38
  _format = DawnUtils::PreferredTextureFormat;
37
39
  _colorType = DawnUtils::PreferedColorType;
38
40
  if (highBitDepth) {
@@ -59,10 +61,10 @@ public:
59
61
  skgpu::graphite::SampleCount::k1, skgpu::Mipmapped::kNo, _format,
60
62
  texture.GetUsage(), wgpu::TextureAspect::All);
61
63
  auto backendTex = skgpu::graphite::BackendTextures::MakeDawn(texture.Get());
62
- sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeSRGB();
63
64
  SkSurfaceProps surfaceProps;
64
65
  auto surface = SkSurfaces::WrapBackendTexture(
65
- _recorder, backendTex, _colorType, colorSpace, &surfaceProps);
66
+ _recorder, backendTex, _colorType,
67
+ DawnUtils::viewColorSpace(_useP3ColorSpace), &surfaceProps);
66
68
  return surface;
67
69
  }
68
70
 
@@ -74,8 +76,16 @@ public:
74
76
  bool presentRecordings(
75
77
  const std::vector<skgpu::graphite::Recording *> &recordings);
76
78
 
79
+ // Draws an image at the origin of the current swapchain texture (on the
80
+ // window's own recorder) and presents it.
81
+ bool presentImage(const sk_sp<SkImage> &image);
82
+
77
83
  SkColorType getColorType() const { return _colorType; }
78
84
 
85
+ // Whether the window is in Display P3 rather than sRGB: a deferred canvas
86
+ // must be recorded in the color space of the window it is replayed onto.
87
+ bool usesP3ColorSpace() const { return _useP3ColorSpace; }
88
+
79
89
  // The texture description a deferred canvas must be recorded with to be
80
90
  // replayed onto this window.
81
91
  skgpu::graphite::TextureInfo getTextureInfo() const {
@@ -110,9 +120,10 @@ private:
110
120
  #endif
111
121
  _surface.Configure(&config);
112
122
  #ifdef __APPLE__
113
- // Float formats need the layer tagged as (gamma-encoded) extended sRGB so
114
- // the sRGB-encoded values display identically to the 8-bit path.
115
- applyCAMetalLayerColorSpace(_nativeSurface, _format);
123
+ // The layer is tagged with the gamut the window renders in; float formats
124
+ // need the (gamma-encoded) extended variant so the values display
125
+ // identically to the 8-bit path.
126
+ applyCAMetalLayerColorSpace(_nativeSurface, _format, _useP3ColorSpace);
116
127
  #endif
117
128
  }
118
129
 
@@ -157,6 +168,7 @@ private:
157
168
  wgpu::Device _device;
158
169
  wgpu::Surface _surface;
159
170
  [[maybe_unused]] void *_nativeSurface;
171
+ bool _useP3ColorSpace;
160
172
  wgpu::TextureFormat _format;
161
173
  wgpu::TextureUsage _usage = wgpu::TextureUsage::RenderAttachment;
162
174
  SkColorType _colorType;
@@ -7,9 +7,11 @@
7
7
  namespace RNSkia {
8
8
 
9
9
  // Tags the CAMetalLayer with the colorspace matching the configured texture
10
- // format. Implemented in apple/MetalLayerColorSpace.mm.
10
+ // format and the gamut the view renders in. Implemented in
11
+ // apple/MetalLayerColorSpace.mm.
11
12
  void applyCAMetalLayerColorSpace(void *nativeSurface,
12
- wgpu::TextureFormat format);
13
+ wgpu::TextureFormat format,
14
+ bool useP3ColorSpace);
13
15
 
14
16
  } // namespace RNSkia
15
17
 
@@ -0,0 +1,231 @@
1
+ #pragma once
2
+
3
+ #include <functional>
4
+ #include <memory>
5
+ #include <utility>
6
+ #include <vector>
7
+
8
+ #include "RNDawnContext.h"
9
+ #include "RNDawnUtils.h"
10
+ #include "RNSkPlatformContext.h"
11
+
12
+ #pragma clang diagnostic push
13
+ #pragma clang diagnostic ignored "-Wdocumentation"
14
+
15
+ #include "include/core/SkCanvas.h"
16
+ #include "include/core/SkImage.h"
17
+ #include "include/core/SkSurface.h"
18
+ #include "include/gpu/graphite/Recording.h"
19
+ #include "include/gpu/graphite/TextureInfo.h"
20
+ #include "include/gpu/graphite/dawn/DawnGraphiteTypes.h"
21
+
22
+ #pragma clang diagnostic pop
23
+
24
+ namespace RNSkia {
25
+
26
+ /**
27
+ * Describes the texture a recording is replayed onto: the pixel size, the
28
+ * format and the color space of a window (or offscreen) surface. A deferred
29
+ * canvas is recorded against this description, so it can be created before
30
+ * the surface itself exists.
31
+ */
32
+ struct RNSkGraphiteTargetInfo {
33
+ int width = 0;
34
+ int height = 0;
35
+ SkColorType colorType = kUnknown_SkColorType;
36
+ // Display P3 rather than sRGB (see DawnUtils::viewColorSpace). The colors
37
+ // of a recording are converted to the color space of its target when it is
38
+ // recorded, not when it is replayed.
39
+ bool useP3ColorSpace = false;
40
+ skgpu::graphite::TextureInfo textureInfo;
41
+ };
42
+
43
+ /**
44
+ * The surface a view presents into: a platform window (a CAMetalLayer, an
45
+ * ANativeWindow) or an offscreen surface. It describes its target texture to
46
+ * whoever records for the view and replays their recordings onto it.
47
+ */
48
+ class RNSkCanvasProvider {
49
+ public:
50
+ virtual ~RNSkCanvasProvider() = default;
51
+
52
+ /** Width of the surface, in pixels. */
53
+ virtual int getWidth() = 0;
54
+
55
+ /** Height of the surface, in pixels. */
56
+ virtual int getHeight() = 0;
57
+
58
+ /**
59
+ Describes the current target texture. Safe to call from any thread;
60
+ returns false while there is no surface to describe.
61
+ */
62
+ virtual bool getTargetInfo(RNSkGraphiteTargetInfo *info) = 0;
63
+
64
+ /**
65
+ The size in pixels the surface will have, known from the platform layout
66
+ before the surface itself exists (on Android the surface only appears a
67
+ frame after the view is laid out). Safe to call from any thread; returns
68
+ false until the view is laid out. A frame recorded against this size is
69
+ presented as is once the surface appears, where one recorded against a
70
+ size derived from the layout in points could be off by a pixel and would
71
+ not cover the surface.
72
+ */
73
+ virtual bool getLayoutSize(int *width, int *height) { return false; }
74
+
75
+ /**
76
+ Replays the recordings, in order, onto the target texture and presents
77
+ it. Called on the thread that owns the surface. Returns false when the
78
+ surface cannot present right now (there is none, or the app is in the
79
+ background): nothing was consumed.
80
+ */
81
+ virtual bool presentRecordings(
82
+ const std::vector<skgpu::graphite::Recording *> &recordings) = 0;
83
+
84
+ /**
85
+ Draws an image at the origin of the target texture and presents it. Same
86
+ thread and return value as presentRecordings(). Used for a recording whose
87
+ size or color space differs from the target's: it is replayed into a
88
+ texture of its own first (see RNSkView::present).
89
+ */
90
+ virtual bool presentImage(const sk_sp<SkImage> &image) = 0;
91
+
92
+ /**
93
+ Installed by the view owning the provider: asks it for a frame when the
94
+ surface appears or changes size.
95
+ */
96
+ void setRequestRedraw(std::function<void()> requestRedraw) {
97
+ _requestRedraw = std::move(requestRedraw);
98
+ }
99
+
100
+ protected:
101
+ void requestRedraw() {
102
+ if (_requestRedraw) {
103
+ _requestRedraw();
104
+ }
105
+ }
106
+
107
+ private:
108
+ std::function<void()> _requestRedraw;
109
+ };
110
+
111
+ /**
112
+ * An offscreen surface the content of a view is replayed into for a snapshot.
113
+ * A recording is replayed as is, so the surface takes the color space of the
114
+ * recordings it is meant for.
115
+ */
116
+ class RNSkOffscreenCanvasProvider : public RNSkCanvasProvider {
117
+ public:
118
+ RNSkOffscreenCanvasProvider(
119
+ const std::shared_ptr<RNSkPlatformContext> &context, int width,
120
+ int height, bool useP3ColorSpace = false)
121
+ : _width(width), _height(height), _pd(context->getPixelDensity()),
122
+ _useP3ColorSpace(useP3ColorSpace),
123
+ _surface(
124
+ context->makeOffscreenSurface(width, height, useP3ColorSpace)) {}
125
+
126
+ virtual ~RNSkOffscreenCanvasProvider() = default;
127
+
128
+ /** The canvas of the surface, in pixels; nullptr without a surface. */
129
+ SkCanvas *getCanvas() { return _surface ? _surface->getCanvas() : nullptr; }
130
+
131
+ /**
132
+ A GPU image of the surface, usable by any recorder of the context once
133
+ this returns; nullptr without a surface.
134
+ */
135
+ sk_sp<SkImage> makeImage() {
136
+ if (_surface == nullptr) {
137
+ return nullptr;
138
+ }
139
+ auto image = _surface->makeImageSnapshot();
140
+ // The snapshot is a copy task on the surface's recorder: submitted here,
141
+ // so that the image is complete for whoever draws it next.
142
+ if (auto *recorder = _surface->recorder()) {
143
+ DawnContext::getInstance().submitRecording(recorder->snap().get());
144
+ }
145
+ return image;
146
+ }
147
+
148
+ /**
149
+ Returns a snapshot of the current surface/canvas
150
+ */
151
+ sk_sp<SkImage> makeSnapshot(SkRect *bounds) {
152
+ if (_surface == nullptr) {
153
+ return nullptr;
154
+ }
155
+ sk_sp<SkImage> image;
156
+ if (bounds != nullptr) {
157
+ SkIRect b =
158
+ SkIRect::MakeXYWH(bounds->x() * _pd, bounds->y() * _pd,
159
+ bounds->width() * _pd, bounds->height() * _pd);
160
+ image = _surface->makeImageSnapshot(b);
161
+ } else {
162
+ image = _surface->makeImageSnapshot();
163
+ }
164
+ // Only Graphite-backed surfaces have a recorder to snap/submit; a raster
165
+ // surface's snapshot is already a valid CPU image.
166
+ if (auto *recorder = _surface->recorder()) {
167
+ DawnContext::getInstance().submitRecording(recorder->snap().get());
168
+ }
169
+ return DawnContext::getInstance().MakeRasterImage(image);
170
+ }
171
+
172
+ int getWidth() override { return _width; }
173
+
174
+ int getHeight() override { return _height; }
175
+
176
+ bool getTargetInfo(RNSkGraphiteTargetInfo *info) override {
177
+ if (_surface == nullptr || _surface->recorder() == nullptr) {
178
+ return false;
179
+ }
180
+ // Graphite gives its render targets the sampled+renderable usage, a
181
+ // superset of what a deferred canvas asks for.
182
+ auto colorType = _surface->imageInfo().colorType();
183
+ info->width = _width;
184
+ info->height = _height;
185
+ info->colorType = colorType;
186
+ info->useP3ColorSpace = _useP3ColorSpace;
187
+ info->textureInfo = skgpu::graphite::TextureInfos::MakeDawn(
188
+ skgpu::graphite::DawnTextureInfo(
189
+ skgpu::graphite::SampleCount::k1, skgpu::Mipmapped::kNo,
190
+ DawnUtils::textureFormatForColorType(colorType),
191
+ DawnUtils::DefaultTargetUsage, wgpu::TextureAspect::All));
192
+ return true;
193
+ }
194
+
195
+ bool presentRecordings(
196
+ const std::vector<skgpu::graphite::Recording *> &recordings) override {
197
+ auto *recorder = _surface ? _surface->recorder() : nullptr;
198
+ if (recorder == nullptr) {
199
+ return false;
200
+ }
201
+ // A new surface clears itself in its first pass, which its own recorder
202
+ // only records when it next snaps. The recordings go straight to the
203
+ // context, so that clear would run after them and wipe them: record and
204
+ // submit it first (the explicit clear makes sure the pass is emitted).
205
+ if (!_cleared) {
206
+ _surface->getCanvas()->clear(SK_ColorTRANSPARENT);
207
+ DawnContext::getInstance().submitRecording(recorder->snap().get());
208
+ _cleared = true;
209
+ }
210
+ return DawnContext::getInstance().insertRecordings(recordings,
211
+ _surface.get());
212
+ }
213
+
214
+ bool presentImage(const sk_sp<SkImage> &image) override {
215
+ if (_surface == nullptr) {
216
+ return false;
217
+ }
218
+ _surface->getCanvas()->drawImage(image, 0, 0);
219
+ return true;
220
+ }
221
+
222
+ private:
223
+ int _width;
224
+ int _height;
225
+ float _pd;
226
+ bool _useP3ColorSpace;
227
+ sk_sp<SkSurface> _surface;
228
+ bool _cleared = false;
229
+ };
230
+
231
+ } // namespace RNSkia
@@ -1,15 +1,13 @@
1
1
  // Everything that needs a complete Recorder lives here rather than in
2
2
  // RNSkGraphiteProducer.h (which the view headers include on their own).
3
- #if defined(SK_GRAPHITE)
4
-
5
3
  #include "RNSkGraphiteProducer.h"
6
4
 
7
5
  #include <memory>
8
6
  #include <utility>
9
7
 
10
- #include "RNSkGraphiteView.h"
11
- #include "RNSkPictureView.h"
8
+ #include "RNSkGraphiteTarget.h"
12
9
  #include "RNSkThreadPool.h"
10
+ #include "api/recorder/DrawingCtx.h"
13
11
  #include "api/recorder/RNRecorder.h"
14
12
  #include "utils/RNSkLog.h"
15
13
 
@@ -20,6 +18,21 @@ namespace RNSkia {
20
18
 
21
19
  RNSkGraphiteProducer::~RNSkGraphiteProducer() = default;
22
20
 
21
+ void RNSkGraphiteProducer::drawContent(SkCanvas *canvas, Recorder *recorder,
22
+ const sk_sp<SkPicture> &picture,
23
+ float pixelDensity) {
24
+ canvas->clear(SK_ColorTRANSPARENT);
25
+ canvas->save();
26
+ canvas->scale(pixelDensity, pixelDensity);
27
+ if (recorder != nullptr) {
28
+ DrawingCtx ctx(canvas);
29
+ recorder->play(&ctx);
30
+ } else if (picture != nullptr) {
31
+ canvas->drawPicture(picture);
32
+ }
33
+ canvas->restore();
34
+ }
35
+
23
36
  void RNSkGraphiteProducer::setTarget(
24
37
  std::shared_ptr<RNSkGraphiteTarget> target) {
25
38
  std::lock_guard<std::mutex> lock(_mutex);
@@ -67,6 +80,18 @@ bool RNSkGraphiteProducer::hasContent() {
67
80
  return _recorder != nullptr || _picture != nullptr;
68
81
  }
69
82
 
83
+ bool RNSkGraphiteProducer::applyUpdatesTo(
84
+ const std::shared_ptr<Recorder> &recorder, jsi::Runtime &runtime,
85
+ double recorderId, const jsi::Array &values) {
86
+ if (recorder == nullptr || recorder->id != recorderId) {
87
+ return false;
88
+ }
89
+ // The values are written into the commands by the next replay, which the
90
+ // caller schedules: the mapper never waits for a draw.
91
+ recorder->readUpdates(runtime, values);
92
+ return true;
93
+ }
94
+
70
95
  bool RNSkGraphiteProducer::applyUpdates(jsi::Runtime &runtime,
71
96
  double recorderId,
72
97
  const jsi::Array &values) {
@@ -75,13 +100,12 @@ bool RNSkGraphiteProducer::applyUpdates(jsi::Runtime &runtime,
75
100
  std::lock_guard<std::mutex> lock(_mutex);
76
101
  recorder = _recorder;
77
102
  }
78
- if (recorder == nullptr || recorder->id != recorderId) {
79
- return false;
80
- }
81
103
  // Outside the lock: a commit replacing the recorder must not wait for the
82
104
  // read. Should it land while this runs, the values go into the retired
83
105
  // recorder and the commit's own frame draws the new one.
84
- recorder->readUpdates(runtime, values);
106
+ if (!applyUpdatesTo(recorder, runtime, recorderId, values)) {
107
+ return false;
108
+ }
85
109
  std::lock_guard<std::mutex> lock(_mutex);
86
110
  _dirty = true;
87
111
  kickLocked();
@@ -142,14 +166,14 @@ void RNSkGraphiteProducer::produce() {
142
166
  // The deferred canvas already draws in points.
143
167
  drawContent(canvas, recorder.get(), picture, /* pixelDensity= */ 1.0f);
144
168
  } catch (const std::exception &e) {
145
- RNSkLogger::logToConsole(
146
- "GraphiteCanvas: replaying the scene failed: %s", e.what());
169
+ RNSkLogger::logToConsole("Canvas: replaying the scene failed: %s",
170
+ e.what());
147
171
  }
148
172
  try {
149
173
  recording = target->finishRecording();
150
174
  } catch (const std::exception &e) {
151
- RNSkLogger::logToConsole(
152
- "GraphiteCanvas: recording the frame failed: %s", e.what());
175
+ RNSkLogger::logToConsole("Canvas: recording the frame failed: %s",
176
+ e.what());
153
177
  }
154
178
  }
155
179
  }
@@ -185,5 +209,3 @@ void RNSkGraphiteProducer::renderInto(SkCanvas *canvas, float pixelDensity) {
185
209
  }
186
210
 
187
211
  } // namespace RNSkia
188
-
189
- #endif // SK_GRAPHITE