@shopify/react-native-skia 2.6.9 → 2.8.0

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 (247) hide show
  1. package/android/cpp/jni/include/JniSkiaBaseView.h +6 -4
  2. package/android/cpp/jni/include/JniSkiaPictureView.h +8 -6
  3. package/android/cpp/rnskia-android/OpenGLContext.h +10 -1
  4. package/android/cpp/rnskia-android/RNSkAndroidView.h +8 -8
  5. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +9 -5
  6. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +4 -2
  7. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +48 -12
  8. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +5 -0
  9. package/android/src/main/java/com/shopify/reactnative/skia/SkiaPictureView.java +2 -2
  10. package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +11 -7
  11. package/apple/MetalContext.h +7 -6
  12. package/apple/MetalLayerColorSpace.mm +39 -0
  13. package/apple/MetalLayerColorSpaceUtils.h +34 -0
  14. package/apple/MetalWindowContext.h +3 -1
  15. package/apple/MetalWindowContext.mm +9 -8
  16. package/apple/RNSkAppleView.h +6 -0
  17. package/apple/RNSkMetalCanvasProvider.h +2 -0
  18. package/apple/RNSkMetalCanvasProvider.mm +15 -2
  19. package/apple/SkiaPictureView.mm +1 -0
  20. package/apple/SkiaPictureViewManager.mm +5 -0
  21. package/apple/SkiaUIView.h +1 -0
  22. package/apple/SkiaUIView.mm +9 -0
  23. package/cpp/api/JsiSkParagraph.h +114 -0
  24. package/cpp/api/JsiSkSurface.h +8 -2
  25. package/cpp/rnskia/RNDawnContext.h +4 -3
  26. package/cpp/rnskia/RNDawnUtils.h +25 -6
  27. package/cpp/rnskia/RNDawnWindowContext.h +44 -10
  28. package/cpp/rnskia/RNMetalLayerColorSpace.h +16 -0
  29. package/cpp/rnskia/RNSkJsiViewApi.h +46 -24
  30. package/cpp/rnwgpu/SurfaceRegistry.h +10 -4
  31. package/lib/commonjs/Platform/Platform.web.js +2 -90
  32. package/lib/commonjs/Platform/Platform.web.js.map +1 -1
  33. package/lib/commonjs/external/reanimated/useVideoLoading.js +11 -2
  34. package/lib/commonjs/external/reanimated/useVideoLoading.js.map +1 -1
  35. package/lib/commonjs/mock/index.js +1 -0
  36. package/lib/commonjs/mock/index.js.map +1 -1
  37. package/lib/commonjs/renderer/Canvas.d.ts +10 -1
  38. package/lib/commonjs/renderer/Canvas.js +2 -0
  39. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  40. package/lib/commonjs/skia/core/SVG.web.js +4 -5
  41. package/lib/commonjs/skia/core/SVG.web.js.map +1 -1
  42. package/lib/commonjs/skia/types/Paragraph/Paragraph.d.ts +62 -0
  43. package/lib/commonjs/skia/types/Paragraph/Paragraph.js.map +1 -1
  44. package/lib/commonjs/skia/types/Surface/Surface.d.ts +5 -1
  45. package/lib/commonjs/skia/types/Surface/Surface.js.map +1 -1
  46. package/lib/commonjs/skia/web/Host.js +7 -0
  47. package/lib/commonjs/skia/web/Host.js.map +1 -1
  48. package/lib/commonjs/skia/web/JsiSkPaint.js +5 -0
  49. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  50. package/lib/commonjs/skia/web/JsiSkParagraph.d.ts +3 -1
  51. package/lib/commonjs/skia/web/JsiSkParagraph.js +6 -0
  52. package/lib/commonjs/skia/web/JsiSkParagraph.js.map +1 -1
  53. package/lib/commonjs/skia/web/JsiSkParagraphStyle.js +14 -3
  54. package/lib/commonjs/skia/web/JsiSkParagraphStyle.js.map +1 -1
  55. package/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -1
  56. package/lib/commonjs/skia/web/JsiSkSurface.js +2 -1
  57. package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
  58. package/lib/commonjs/sksg/Container.native.d.ts +1 -0
  59. package/lib/commonjs/sksg/Container.native.js +11 -0
  60. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  61. package/lib/commonjs/sksg/Container.web.d.ts +1 -0
  62. package/lib/commonjs/sksg/Container.web.js +45 -3
  63. package/lib/commonjs/sksg/Container.web.js.map +1 -1
  64. package/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +2 -0
  65. package/lib/commonjs/sksg/Recorder/DrawingContext.js +22 -6
  66. package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -1
  67. package/lib/commonjs/sksg/Recorder/FrameScope.d.ts +18 -0
  68. package/lib/commonjs/sksg/Recorder/FrameScope.js +66 -0
  69. package/lib/commonjs/sksg/Recorder/FrameScope.js.map +1 -0
  70. package/lib/commonjs/sksg/Recorder/FrameScope.native.d.ts +10 -0
  71. package/lib/commonjs/sksg/Recorder/FrameScope.native.js +26 -0
  72. package/lib/commonjs/sksg/Recorder/FrameScope.native.js.map +1 -0
  73. package/lib/commonjs/sksg/Recorder/Player.js +1 -2
  74. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  75. package/lib/commonjs/sksg/Recorder/Recorder.d.ts +3 -1
  76. package/lib/commonjs/sksg/Recorder/Recorder.js +12 -1
  77. package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
  78. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +3 -3
  79. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  80. package/lib/commonjs/sksg/Recorder/commands/Shaders.js +3 -3
  81. package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
  82. package/lib/commonjs/sksg/StaticContainer.d.ts +1 -0
  83. package/lib/commonjs/sksg/StaticContainer.js +27 -1
  84. package/lib/commonjs/sksg/StaticContainer.js.map +1 -1
  85. package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +2 -0
  86. package/lib/commonjs/specs/NativeSkiaModule.web.js +32 -7
  87. package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
  88. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
  89. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  90. package/lib/commonjs/views/SkiaPictureView.js +2 -0
  91. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  92. package/lib/commonjs/views/SkiaPictureView.web.js +279 -94
  93. package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
  94. package/lib/commonjs/views/formats.d.ts +1 -0
  95. package/lib/commonjs/views/formats.js +28 -0
  96. package/lib/commonjs/views/formats.js.map +1 -0
  97. package/lib/commonjs/views/index.d.ts +1 -0
  98. package/lib/commonjs/views/index.js +11 -0
  99. package/lib/commonjs/views/index.js.map +1 -1
  100. package/lib/commonjs/views/types.d.ts +6 -0
  101. package/lib/commonjs/views/types.js.map +1 -1
  102. package/lib/module/Platform/Platform.web.js +3 -91
  103. package/lib/module/Platform/Platform.web.js.map +1 -1
  104. package/lib/module/external/reanimated/useVideoLoading.js +12 -2
  105. package/lib/module/external/reanimated/useVideoLoading.js.map +1 -1
  106. package/lib/module/mock/index.js +1 -0
  107. package/lib/module/mock/index.js.map +1 -1
  108. package/lib/module/renderer/Canvas.d.ts +10 -1
  109. package/lib/module/renderer/Canvas.js +2 -0
  110. package/lib/module/renderer/Canvas.js.map +1 -1
  111. package/lib/module/skia/core/SVG.web.js +4 -5
  112. package/lib/module/skia/core/SVG.web.js.map +1 -1
  113. package/lib/module/skia/types/Paragraph/Paragraph.d.ts +62 -0
  114. package/lib/module/skia/types/Paragraph/Paragraph.js.map +1 -1
  115. package/lib/module/skia/types/Surface/Surface.d.ts +5 -1
  116. package/lib/module/skia/types/Surface/Surface.js.map +1 -1
  117. package/lib/module/skia/web/Host.js +7 -0
  118. package/lib/module/skia/web/Host.js.map +1 -1
  119. package/lib/module/skia/web/JsiSkPaint.js +5 -0
  120. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  121. package/lib/module/skia/web/JsiSkParagraph.d.ts +3 -1
  122. package/lib/module/skia/web/JsiSkParagraph.js +7 -1
  123. package/lib/module/skia/web/JsiSkParagraph.js.map +1 -1
  124. package/lib/module/skia/web/JsiSkParagraphStyle.js +14 -3
  125. package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -1
  126. package/lib/module/skia/web/JsiSkSurface.d.ts +1 -1
  127. package/lib/module/skia/web/JsiSkSurface.js +2 -1
  128. package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
  129. package/lib/module/sksg/Container.native.d.ts +1 -0
  130. package/lib/module/sksg/Container.native.js +11 -0
  131. package/lib/module/sksg/Container.native.js.map +1 -1
  132. package/lib/module/sksg/Container.web.d.ts +1 -0
  133. package/lib/module/sksg/Container.web.js +46 -4
  134. package/lib/module/sksg/Container.web.js.map +1 -1
  135. package/lib/module/sksg/Recorder/DrawingContext.d.ts +2 -0
  136. package/lib/module/sksg/Recorder/DrawingContext.js +22 -6
  137. package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -1
  138. package/lib/module/sksg/Recorder/FrameScope.d.ts +18 -0
  139. package/lib/module/sksg/Recorder/FrameScope.js +59 -0
  140. package/lib/module/sksg/Recorder/FrameScope.js.map +1 -0
  141. package/lib/module/sksg/Recorder/FrameScope.native.d.ts +10 -0
  142. package/lib/module/sksg/Recorder/FrameScope.native.js +19 -0
  143. package/lib/module/sksg/Recorder/FrameScope.native.js.map +1 -0
  144. package/lib/module/sksg/Recorder/Player.js +1 -2
  145. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  146. package/lib/module/sksg/Recorder/Recorder.d.ts +3 -1
  147. package/lib/module/sksg/Recorder/Recorder.js +10 -0
  148. package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
  149. package/lib/module/sksg/Recorder/commands/Drawing.js +3 -3
  150. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  151. package/lib/module/sksg/Recorder/commands/Shaders.js +3 -3
  152. package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
  153. package/lib/module/sksg/StaticContainer.d.ts +1 -0
  154. package/lib/module/sksg/StaticContainer.js +28 -2
  155. package/lib/module/sksg/StaticContainer.js.map +1 -1
  156. package/lib/module/specs/NativeSkiaModule.web.d.ts +2 -0
  157. package/lib/module/specs/NativeSkiaModule.web.js +32 -7
  158. package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
  159. package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
  160. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  161. package/lib/module/views/SkiaPictureView.js +2 -0
  162. package/lib/module/views/SkiaPictureView.js.map +1 -1
  163. package/lib/module/views/SkiaPictureView.web.js +280 -95
  164. package/lib/module/views/SkiaPictureView.web.js.map +1 -1
  165. package/lib/module/views/formats.d.ts +1 -0
  166. package/lib/module/views/formats.js +22 -0
  167. package/lib/module/views/formats.js.map +1 -0
  168. package/lib/module/views/index.d.ts +1 -0
  169. package/lib/module/views/index.js +1 -0
  170. package/lib/module/views/index.js.map +1 -1
  171. package/lib/module/views/types.d.ts +6 -0
  172. package/lib/module/views/types.js.map +1 -1
  173. package/lib/typescript/lib/commonjs/Platform/Platform.web.d.ts +1 -2
  174. package/lib/typescript/lib/commonjs/mock/index.d.ts +1 -0
  175. package/lib/typescript/lib/commonjs/renderer/Canvas.d.ts +2 -1
  176. package/lib/typescript/lib/commonjs/skia/web/JsiSkParagraph.d.ts +2 -0
  177. package/lib/typescript/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -1
  178. package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +1 -1
  179. package/lib/typescript/lib/commonjs/sksg/Container.web.d.ts +3 -3
  180. package/lib/typescript/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +2 -0
  181. package/lib/typescript/lib/commonjs/sksg/Recorder/FrameScope.d.ts +17 -0
  182. package/lib/typescript/lib/commonjs/sksg/Recorder/FrameScope.native.d.ts +13 -0
  183. package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -0
  184. package/lib/typescript/lib/commonjs/sksg/StaticContainer.d.ts +2 -2
  185. package/lib/typescript/lib/commonjs/views/formats.d.ts +2 -0
  186. package/lib/typescript/lib/module/Platform/Platform.web.d.ts +1 -3
  187. package/lib/typescript/lib/module/mock/index.d.ts +2 -2
  188. package/lib/typescript/lib/module/renderer/Canvas.d.ts +2 -1
  189. package/lib/typescript/lib/module/skia/web/JsiSkParagraph.d.ts +2 -0
  190. package/lib/typescript/lib/module/skia/web/JsiSkSurface.d.ts +1 -1
  191. package/lib/typescript/lib/module/sksg/Container.native.d.ts +1 -1
  192. package/lib/typescript/lib/module/sksg/Container.web.d.ts +3 -3
  193. package/lib/typescript/lib/module/sksg/Recorder/DrawingContext.d.ts +2 -0
  194. package/lib/typescript/lib/module/sksg/Recorder/FrameScope.d.ts +5 -0
  195. package/lib/typescript/lib/module/sksg/Recorder/FrameScope.native.d.ts +5 -0
  196. package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -0
  197. package/lib/typescript/lib/module/sksg/StaticContainer.d.ts +2 -2
  198. package/lib/typescript/lib/module/views/formats.d.ts +1 -0
  199. package/lib/typescript/lib/module/views/index.d.ts +1 -0
  200. package/lib/typescript/src/renderer/Canvas.d.ts +10 -1
  201. package/lib/typescript/src/skia/types/Paragraph/Paragraph.d.ts +62 -0
  202. package/lib/typescript/src/skia/types/Surface/Surface.d.ts +5 -1
  203. package/lib/typescript/src/skia/web/JsiSkParagraph.d.ts +3 -1
  204. package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +1 -1
  205. package/lib/typescript/src/sksg/Container.native.d.ts +1 -0
  206. package/lib/typescript/src/sksg/Container.web.d.ts +1 -0
  207. package/lib/typescript/src/sksg/Recorder/DrawingContext.d.ts +2 -0
  208. package/lib/typescript/src/sksg/Recorder/FrameScope.d.ts +18 -0
  209. package/lib/typescript/src/sksg/Recorder/FrameScope.native.d.ts +10 -0
  210. package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +3 -1
  211. package/lib/typescript/src/sksg/StaticContainer.d.ts +1 -0
  212. package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +2 -0
  213. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
  214. package/lib/typescript/src/views/formats.d.ts +1 -0
  215. package/lib/typescript/src/views/index.d.ts +1 -0
  216. package/lib/typescript/src/views/types.d.ts +6 -0
  217. package/package.json +4 -1
  218. package/react-native-skia.podspec +1 -0
  219. package/src/Platform/Platform.web.tsx +7 -99
  220. package/src/external/reanimated/useVideoLoading.ts +12 -2
  221. package/src/mock/index.ts +1 -0
  222. package/src/renderer/Canvas.tsx +11 -0
  223. package/src/skia/core/SVG.web.ts +5 -14
  224. package/src/skia/types/Paragraph/Paragraph.ts +67 -0
  225. package/src/skia/types/Surface/Surface.ts +5 -1
  226. package/src/skia/web/Host.ts +7 -0
  227. package/src/skia/web/JsiSkPaint.ts +5 -0
  228. package/src/skia/web/JsiSkParagraph.ts +9 -1
  229. package/src/skia/web/JsiSkParagraphStyle.ts +16 -2
  230. package/src/skia/web/JsiSkSurface.ts +2 -1
  231. package/src/sksg/Container.native.ts +12 -0
  232. package/src/sksg/Container.web.ts +43 -4
  233. package/src/sksg/Recorder/DrawingContext.ts +19 -6
  234. package/src/sksg/Recorder/FrameScope.native.ts +21 -0
  235. package/src/sksg/Recorder/FrameScope.ts +69 -0
  236. package/src/sksg/Recorder/Player.ts +1 -2
  237. package/src/sksg/Recorder/Recorder.ts +15 -1
  238. package/src/sksg/Recorder/commands/Drawing.ts +3 -3
  239. package/src/sksg/Recorder/commands/Shaders.ts +22 -16
  240. package/src/sksg/StaticContainer.ts +29 -2
  241. package/src/specs/NativeSkiaModule.web.ts +39 -7
  242. package/src/specs/SkiaPictureViewNativeComponent.ts +1 -0
  243. package/src/views/SkiaPictureView.tsx +2 -0
  244. package/src/views/SkiaPictureView.web.tsx +318 -106
  245. package/src/views/formats.ts +21 -0
  246. package/src/views/index.ts +1 -0
  247. package/src/views/types.ts +7 -0
@@ -8,6 +8,7 @@
8
8
  #include <jsi/jsi.h>
9
9
 
10
10
  #include "JsiSkCanvas.h"
11
+ #include "JsiSkFont.h"
11
12
  #include "JsiSkHostObjects.h"
12
13
  #include "JsiSkPath.h"
13
14
  #include "JsiSkRect.h"
@@ -141,6 +142,117 @@ public:
141
142
  return returnValue;
142
143
  }
143
144
 
145
+ JSI_HOST_FUNCTION(getPath) {
146
+ auto lineNumber =
147
+ static_cast<int>(getArgumentAsNumber(runtime, arguments, count, 0));
148
+ auto paragraph = getObject();
149
+ // Paragraph::getPath does not bounds-check the line number.
150
+ if (lineNumber < 0 ||
151
+ static_cast<size_t>(lineNumber) >= paragraph->lineNumber()) {
152
+ return jsi::Value::null();
153
+ }
154
+ // Paragraph::getPath resets its path builder after every visual run, so
155
+ // for lines shaped as multiple runs (e.g. through font fallback) it only
156
+ // returns the glyphs of the last run. Build the path from the per-glyph
157
+ // data exposed by extendedVisit instead.
158
+ SkPathBuilder builder;
159
+ paragraph->extendedVisit(
160
+ [lineNumber, &builder](
161
+ int visitedLine, const para::Paragraph::ExtendedVisitorInfo *info) {
162
+ if (visitedLine != lineNumber || info == nullptr) {
163
+ return;
164
+ }
165
+ struct Rec {
166
+ SkPathBuilder *builder;
167
+ SkPoint origin;
168
+ const SkPoint *pos;
169
+ } rec = {&builder, info->origin, info->positions};
170
+ info->font.getPaths(
171
+ {info->glyphs, static_cast<size_t>(info->count)},
172
+ [](const SkPath *src, const SkMatrix &mx, void *ctx) {
173
+ auto *rec = static_cast<Rec *>(ctx);
174
+ if (src != nullptr) {
175
+ SkMatrix total = mx;
176
+ total.postTranslate(rec->origin.fX + rec->pos->fX,
177
+ rec->origin.fY + rec->pos->fY);
178
+ rec->builder->addPath(*src, total);
179
+ }
180
+ rec->pos += 1;
181
+ },
182
+ &rec);
183
+ });
184
+ SkPath path = builder.detach();
185
+ auto hostObjectInstance =
186
+ std::make_shared<JsiSkPath>(getContext(), std::move(path));
187
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
188
+ runtime, hostObjectInstance, getContext());
189
+ }
190
+
191
+ JSI_HOST_FUNCTION(extendedVisit) {
192
+ auto visitorObject = getArgumentAsFunction(runtime, arguments, count, 0);
193
+ auto visitor = visitorObject.asFunction(runtime);
194
+ auto context = getContext();
195
+ getObject()->extendedVisit(
196
+ [&runtime, &visitor, &context](
197
+ int lineNumber, const para::Paragraph::ExtendedVisitorInfo *info) {
198
+ if (info == nullptr) {
199
+ // Signals the end of the line
200
+ visitor.call(runtime, static_cast<double>(lineNumber),
201
+ jsi::Value::null());
202
+ return;
203
+ }
204
+ auto value = jsi::Object(runtime);
205
+
206
+ auto fontInstance = std::make_shared<JsiSkFont>(context, info->font);
207
+ value.setProperty(runtime, "font",
208
+ JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
209
+ runtime, fontInstance, context));
210
+
211
+ auto origin = jsi::Object(runtime);
212
+ origin.setProperty(runtime, "x",
213
+ static_cast<double>(info->origin.x()));
214
+ origin.setProperty(runtime, "y",
215
+ static_cast<double>(info->origin.y()));
216
+ value.setProperty(runtime, "origin", origin);
217
+
218
+ auto advance = jsi::Object(runtime);
219
+ advance.setProperty(runtime, "width",
220
+ static_cast<double>(info->advance.width()));
221
+ advance.setProperty(runtime, "height",
222
+ static_cast<double>(info->advance.height()));
223
+ value.setProperty(runtime, "advance", advance);
224
+
225
+ auto size = info->count;
226
+ auto glyphs = jsi::Array(runtime, size);
227
+ auto positions = jsi::Array(runtime, size);
228
+ auto bounds = jsi::Array(runtime, size);
229
+ auto utf8Starts = jsi::Array(runtime, size);
230
+ for (int i = 0; i < size; ++i) {
231
+ glyphs.setValueAtIndex(runtime, i,
232
+ static_cast<double>(info->glyphs[i]));
233
+ auto position = jsi::Object(runtime);
234
+ position.setProperty(runtime, "x",
235
+ static_cast<double>(info->positions[i].x()));
236
+ position.setProperty(runtime, "y",
237
+ static_cast<double>(info->positions[i].y()));
238
+ positions.setValueAtIndex(runtime, i, position);
239
+ bounds.setValueAtIndex(
240
+ runtime, i,
241
+ JsiSkRect::toValue(runtime, context, info->bounds[i]));
242
+ utf8Starts.setValueAtIndex(
243
+ runtime, i, static_cast<double>(info->utf8Starts[i]));
244
+ }
245
+ value.setProperty(runtime, "glyphs", glyphs);
246
+ value.setProperty(runtime, "positions", positions);
247
+ value.setProperty(runtime, "bounds", bounds);
248
+ value.setProperty(runtime, "utf8Starts", utf8Starts);
249
+ value.setProperty(runtime, "flags", static_cast<double>(info->flags));
250
+
251
+ visitor.call(runtime, static_cast<double>(lineNumber), value);
252
+ });
253
+ return jsi::Value::undefined();
254
+ }
255
+
144
256
  JSI_HOST_FUNCTION(getRectsForPlaceholders) {
145
257
  std::vector<para::TextBox> placeholderInfos =
146
258
  getObject()->getRectsForPlaceholders();
@@ -169,6 +281,8 @@ public:
169
281
  getGlyphPositionAtCoordinate),
170
282
  JSI_EXPORT_FUNC(JsiSkParagraph, getRectsForRange),
171
283
  JSI_EXPORT_FUNC(JsiSkParagraph, getLineMetrics),
284
+ JSI_EXPORT_FUNC(JsiSkParagraph, getPath),
285
+ JSI_EXPORT_FUNC(JsiSkParagraph, extendedVisit),
172
286
  JSI_EXPORT_FUNC(JsiSkParagraph, dispose))
173
287
 
174
288
  size_t getMemoryPressure() const override { return 1024 * 1024; }
@@ -84,16 +84,22 @@ public:
84
84
 
85
85
  JSI_HOST_FUNCTION(flush) {
86
86
  auto surface = getObject();
87
+ // When `sync` is true, block until the GPU has finished executing the
88
+ // submitted work. Required before a native consumer on a different command
89
+ // queue reads this surface's texture via getNativeTextureUnstable(). #3916
90
+ bool sync = count > 0 && arguments[0].isBool() && arguments[0].getBool();
87
91
  #if defined(SK_GRAPHITE)
88
92
  // A raster surface (e.g. Skia.Surface.Make) has no Graphite recorder;
89
93
  // only Graphite-backed surfaces need to snap and submit a recording.
90
94
  if (auto *recorder = surface->recorder()) {
91
95
  auto recording = recorder->snap();
92
- DawnContext::getInstance().submitRecording(recording.get());
96
+ DawnContext::getInstance().submitRecording(
97
+ recording.get(), sync ? skgpu::graphite::SyncToCpu::kYes
98
+ : skgpu::graphite::SyncToCpu::kNo);
93
99
  }
94
100
  #else
95
101
  if (auto dContext = GrAsDirectContext(surface->recordingContext())) {
96
- dContext->flushAndSubmit();
102
+ dContext->flushAndSubmit(sync ? GrSyncCpu::kYes : GrSyncCpu::kNo);
97
103
  }
98
104
  #endif
99
105
  return jsi::Value::undefined();
@@ -325,8 +325,8 @@ public:
325
325
  }
326
326
 
327
327
  // Create onscreen surface with window
328
- std::unique_ptr<WindowContext> MakeWindow(void *window, int width,
329
- int height) {
328
+ std::unique_ptr<WindowContext> MakeWindow(void *window, int width, int height,
329
+ bool highBitDepth = false) {
330
330
  // 1. Create Surface
331
331
  wgpu::SurfaceDescriptor surfaceDescriptor;
332
332
  #ifdef __APPLE__
@@ -341,7 +341,8 @@ public:
341
341
  auto surface =
342
342
  wgpu::Instance(instance->Get()).CreateSurface(&surfaceDescriptor);
343
343
  return std::make_unique<DawnWindowContext>(
344
- getRecorder(), backendContext.fDevice, surface, width, height);
344
+ getRecorder(), backendContext.fDevice, surface, window, width, height,
345
+ highBitDepth);
345
346
  }
346
347
 
347
348
  skgpu::graphite::Recorder *getRecorder() {
@@ -5,9 +5,9 @@
5
5
  #include "dawn/dawn_proc.h"
6
6
  #include "dawn/native/DawnNative.h"
7
7
 
8
- #include "utils/RNSkLog.h"
9
8
  #include "include/core/SkColorType.h"
10
9
  #include "include/gpu/graphite/dawn/DawnBackendContext.h"
10
+ #include "utils/RNSkLog.h"
11
11
 
12
12
  namespace DawnUtils {
13
13
 
@@ -21,6 +21,24 @@ static const wgpu::TextureFormat PreferredTextureFormat =
21
21
  wgpu::TextureFormat::RGBA8Unorm;
22
22
  #endif
23
23
 
24
+ // On-screen format used when the view requests high bit depth. The values
25
+ // stay sRGB-encoded (SDR), only with more precision than 8 bits per channel;
26
+ // this is about banding, not HDR.
27
+ // - Apple: 16-bit float, displayed through the extended sRGB layer colorspace
28
+ // so colors match the 8-bit path exactly.
29
+ // - Android: 10-bit unorm. SurfaceFlinger quantizes SDR float16 layers during
30
+ // composition, but RGBA_1010102 buffers keep their precision through
31
+ // composition, including direct scanout on 10-bit panels.
32
+ #ifdef __APPLE__
33
+ static const SkColorType HighBitDepthColorType = kRGBA_F16_SkColorType;
34
+ static const wgpu::TextureFormat HighBitDepthTextureFormat =
35
+ wgpu::TextureFormat::RGBA16Float;
36
+ #else
37
+ static const SkColorType HighBitDepthColorType = kRGBA_1010102_SkColorType;
38
+ static const wgpu::TextureFormat HighBitDepthTextureFormat =
39
+ wgpu::TextureFormat::RGB10A2Unorm;
40
+ #endif
41
+
24
42
  // Find the best matching GPU adapter for the current platform.
25
43
  // Sorts by adapter type (DiscreteGPU > IntegratedGPU > CPU) and selects the
26
44
  // first adapter matching the platform backend (Metal on Apple, Vulkan on
@@ -207,11 +225,12 @@ createDawnBackendContext(dawn::native::Instance *instance) {
207
225
  #ifdef __APPLE__
208
226
  wgpu::FeatureName::SharedTextureMemoryIOSurface,
209
227
  // Required to call SharedTextureMemory::EndAccess on Metal (it exports a
210
- // MTLSharedEvent fence). importExternalTexture / importSharedTextureMemory
211
- // end the access window after submit; without this EndAccess errors with
212
- // "Required feature (SharedFenceMTLSharedEvent) is missing". Safe here
213
- // because we always queue.submit() before EndAccess (the secondary device
214
- // omits it on purpose its camera path doesn't commit first).
228
+ // MTLSharedEvent fence). importExternalTexture /
229
+ // importSharedTextureMemory end the access window after submit; without
230
+ // this EndAccess errors with "Required feature
231
+ // (SharedFenceMTLSharedEvent) is missing". Safe here because we always
232
+ // queue.submit() before EndAccess (the secondary device omits it on
233
+ // purpose; its camera path doesn't commit first).
215
234
  wgpu::FeatureName::SharedFenceMTLSharedEvent,
216
235
  wgpu::FeatureName::DawnMultiPlanarFormats,
217
236
  wgpu::FeatureName::MultiPlanarFormatP010,
@@ -1,6 +1,7 @@
1
1
  #pragma once
2
2
 
3
3
  #include "RNDawnUtils.h"
4
+ #include "RNMetalLayerColorSpace.h"
4
5
  #include "RNWindowContext.h"
5
6
 
6
7
  #include "dawn/native/MetalBackend.h"
@@ -24,9 +25,22 @@ namespace RNSkia {
24
25
  class DawnWindowContext : public WindowContext {
25
26
  public:
26
27
  DawnWindowContext(skgpu::graphite::Recorder *recorder, wgpu::Device device,
27
- wgpu::Surface surface, int width, int height)
28
- : _recorder(recorder), _device(device), _surface(surface), _width(width),
29
- _height(height) {
28
+ wgpu::Surface surface, void *nativeSurface, int width,
29
+ int height, bool highBitDepth = false)
30
+ : _recorder(recorder), _device(device), _surface(surface),
31
+ _nativeSurface(nativeSurface), _width(width), _height(height) {
32
+ _format = DawnUtils::PreferredTextureFormat;
33
+ _colorType = DawnUtils::PreferedColorType;
34
+ if (highBitDepth) {
35
+ if (surfaceSupportsFormat(DawnUtils::HighBitDepthTextureFormat)) {
36
+ _format = DawnUtils::HighBitDepthTextureFormat;
37
+ _colorType = DawnUtils::HighBitDepthColorType;
38
+ } else {
39
+ RNSkLogger::logToConsole(
40
+ "High bit depth was requested but the surface does not support "
41
+ "it, falling back to the 8-bit format");
42
+ }
43
+ }
30
44
  configureSurface();
31
45
  }
32
46
 
@@ -38,15 +52,13 @@ public:
38
52
  return nullptr;
39
53
  }
40
54
  skgpu::graphite::DawnTextureInfo info(
41
- skgpu::graphite::SampleCount::k1, skgpu::Mipmapped::kNo,
42
- DawnUtils::PreferredTextureFormat, texture.GetUsage(),
43
- wgpu::TextureAspect::All);
55
+ skgpu::graphite::SampleCount::k1, skgpu::Mipmapped::kNo, _format,
56
+ texture.GetUsage(), wgpu::TextureAspect::All);
44
57
  auto backendTex = skgpu::graphite::BackendTextures::MakeDawn(texture.Get());
45
58
  sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeSRGB();
46
59
  SkSurfaceProps surfaceProps;
47
- auto surface = SkSurfaces::WrapBackendTexture(_recorder, backendTex,
48
- DawnUtils::PreferedColorType,
49
- colorSpace, &surfaceProps);
60
+ auto surface = SkSurfaces::WrapBackendTexture(
61
+ _recorder, backendTex, _colorType, colorSpace, &surfaceProps);
50
62
  return surface;
51
63
  }
52
64
 
@@ -66,7 +78,7 @@ private:
66
78
  void configureSurface() {
67
79
  wgpu::SurfaceConfiguration config;
68
80
  config.device = _device;
69
- config.format = DawnUtils::PreferredTextureFormat;
81
+ config.format = _format;
70
82
  config.width = _width;
71
83
  config.height = _height;
72
84
  config.presentMode = wgpu::PresentMode::Fifo;
@@ -74,12 +86,34 @@ private:
74
86
  config.alphaMode = wgpu::CompositeAlphaMode::Premultiplied;
75
87
  #endif
76
88
  _surface.Configure(&config);
89
+ #ifdef __APPLE__
90
+ // Float formats need the layer tagged as (gamma-encoded) extended sRGB so
91
+ // the sRGB-encoded values display identically to the 8-bit path.
92
+ applyCAMetalLayerColorSpace(_nativeSurface, _format);
93
+ #endif
94
+ }
95
+
96
+ bool surfaceSupportsFormat(wgpu::TextureFormat format) {
97
+ wgpu::SurfaceCapabilities capabilities;
98
+ if (_surface.GetCapabilities(_device.GetAdapter(), &capabilities) !=
99
+ wgpu::Status::Success) {
100
+ return false;
101
+ }
102
+ for (size_t i = 0; i < capabilities.formatCount; i++) {
103
+ if (capabilities.formats[i] == format) {
104
+ return true;
105
+ }
106
+ }
107
+ return false;
77
108
  }
78
109
 
79
110
  skgpu::graphite::Recorder *_recorder;
80
111
  // TODO: keep device in DawnContext? Do we need it for resizing?
81
112
  wgpu::Device _device;
82
113
  wgpu::Surface _surface;
114
+ [[maybe_unused]] void *_nativeSurface;
115
+ wgpu::TextureFormat _format;
116
+ SkColorType _colorType;
83
117
  int _width;
84
118
  int _height;
85
119
  };
@@ -0,0 +1,16 @@
1
+ #pragma once
2
+
3
+ #ifdef __APPLE__
4
+
5
+ #include "webgpu/webgpu_cpp.h"
6
+
7
+ namespace RNSkia {
8
+
9
+ // Tags the CAMetalLayer with the colorspace matching the configured texture
10
+ // format. Implemented in apple/MetalLayerColorSpace.mm.
11
+ void applyCAMetalLayerColorSpace(void *nativeSurface,
12
+ wgpu::TextureFormat format);
13
+
14
+ } // namespace RNSkia
15
+
16
+ #endif // __APPLE__
@@ -6,13 +6,14 @@
6
6
  #include <shared_mutex>
7
7
  #include <string>
8
8
  #include <unordered_map>
9
+ #include <unordered_set>
9
10
  #include <utility>
10
11
  #include <vector>
11
12
 
12
- #include "jsi/JsiHostObject.h"
13
13
  #include "RNSkPictureView.h"
14
14
  #include "RNSkPlatformContext.h"
15
15
  #include "RNSkView.h"
16
+ #include "jsi/JsiHostObject.h"
16
17
  #include "jsi/ViewProperty.h"
17
18
  #include <jsi/jsi.h>
18
19
 
@@ -39,33 +40,56 @@ public:
39
40
  void removeViewInfo(size_t id) {
40
41
  std::unique_lock<std::shared_mutex> lock(_mutex);
41
42
  _registry.erase(id);
43
+ // Remember that this id was explicitly unregistered. Property updates
44
+ // can arrive after unregistration (e.g. a Reanimated worklet setting the
45
+ // picture racing with unmount); without a tombstone they would recreate
46
+ // the entry and its props (an SkPicture retaining every image it draws)
47
+ // would stay in this global registry forever.
48
+ _unregistered.insert(id);
42
49
  }
43
50
 
44
- // Execute a function while holding the registry lock
51
+ // Execute a function while holding the registry lock.
52
+ // When `revive` is true (registration paths), a previously unregistered id
53
+ // becomes valid again; otherwise calls for unregistered ids receive a
54
+ // transient info object that is not stored in the registry.
45
55
  template <typename F>
46
- auto withViewInfo(size_t id, F &&func)
56
+ auto withViewInfo(size_t id, F &&func, bool revive = false)
47
57
  -> decltype(func(std::shared_ptr<RNSkViewInfo>())) {
48
58
  std::unique_lock<std::shared_mutex> lock(_mutex);
59
+ if (revive) {
60
+ _unregistered.erase(id);
61
+ }
49
62
  auto it = _registry.find(id);
50
63
  std::shared_ptr<RNSkViewInfo> info;
51
64
  if (it != _registry.end()) {
52
65
  info = it->second;
53
66
  } else {
54
67
  info = std::make_shared<RNSkViewInfo>();
55
- _registry[id] = info;
68
+ if (_unregistered.find(id) == _unregistered.end()) {
69
+ _registry[id] = info;
70
+ }
56
71
  }
57
72
  return func(info);
58
73
  }
59
74
 
75
+ // Read-only lookup: never creates a registry entry.
76
+ std::shared_ptr<RNSkView> getView(size_t id) {
77
+ std::shared_lock<std::shared_mutex> lock(_mutex);
78
+ auto it = _registry.find(id);
79
+ return it != _registry.end() ? it->second->view : nullptr;
80
+ }
81
+
60
82
  void clear() {
61
83
  std::unique_lock<std::shared_mutex> lock(_mutex);
62
84
  _registry.clear();
85
+ _unregistered.clear();
63
86
  }
64
87
 
65
88
  private:
66
89
  ViewRegistry() = default;
67
90
  mutable std::shared_mutex _mutex;
68
91
  std::unordered_map<size_t, std::shared_ptr<RNSkViewInfo>> _registry;
92
+ std::unordered_set<size_t> _unregistered;
69
93
  };
70
94
 
71
95
  class RNSkJsiViewApi : public RNJsi::JsiHostObject,
@@ -137,13 +161,10 @@ public:
137
161
 
138
162
  // find Skia View
139
163
  int nativeId = arguments[0].asNumber();
140
- ViewRegistry::getInstance().withViewInfo(
141
- nativeId, [](std::shared_ptr<RNSkViewInfo> info) {
142
- if (info->view != nullptr) {
143
- info->view->requestRedraw();
144
- }
145
- return nullptr;
146
- });
164
+ auto view = ViewRegistry::getInstance().getView(nativeId);
165
+ if (view != nullptr) {
166
+ view->requestRedraw();
167
+ }
147
168
  return jsi::Value::undefined();
148
169
  }
149
170
 
@@ -164,9 +185,8 @@ public:
164
185
  // find Skia view
165
186
  int nativeId = arguments[0].asNumber();
166
187
  sk_sp<SkImage> image;
167
- std::shared_ptr<RNSkView> view = ViewRegistry::getInstance().withViewInfo(
168
- nativeId,
169
- [](std::shared_ptr<RNSkViewInfo> info) { return info->view; });
188
+ std::shared_ptr<RNSkView> view =
189
+ ViewRegistry::getInstance().getView(nativeId);
170
190
  if (view != nullptr) {
171
191
  if (count > 1 && !arguments[1].isUndefined() && !arguments[1].isNull()) {
172
192
  auto rect = JsiSkRect::fromValue(runtime, arguments[1]);
@@ -202,9 +222,8 @@ public:
202
222
 
203
223
  // find Skia view
204
224
  int nativeId = arguments[0].asNumber();
205
- std::shared_ptr<RNSkView> view = ViewRegistry::getInstance().withViewInfo(
206
- nativeId,
207
- [](std::shared_ptr<RNSkViewInfo> info) { return info->view; });
225
+ std::shared_ptr<RNSkView> view =
226
+ ViewRegistry::getInstance().getView(nativeId);
208
227
  auto context = _platformContext;
209
228
  auto bounds =
210
229
  count > 1 && !arguments[1].isUndefined() && !arguments[1].isNull()
@@ -248,9 +267,8 @@ public:
248
267
 
249
268
  // find Skia View
250
269
  int nativeId = arguments[0].asNumber();
251
- std::shared_ptr<RNSkView> view = ViewRegistry::getInstance().withViewInfo(
252
- nativeId,
253
- [](std::shared_ptr<RNSkViewInfo> info) { return info->view; });
270
+ std::shared_ptr<RNSkView> view =
271
+ ViewRegistry::getInstance().getView(nativeId);
254
272
  if (view != nullptr) {
255
273
  auto pixelDensity = _platformContext->getPixelDensity();
256
274
  auto sizeObj = jsi::Object(runtime);
@@ -293,7 +311,8 @@ public:
293
311
  */
294
312
  void registerSkiaView(size_t nativeId, std::shared_ptr<RNSkView> view) {
295
313
  ViewRegistry::getInstance().withViewInfo(
296
- nativeId, [&](std::shared_ptr<RNSkViewInfo> info) {
314
+ nativeId,
315
+ [&](std::shared_ptr<RNSkViewInfo> info) {
297
316
  info->view = view;
298
317
  info->view->setNativeId(nativeId);
299
318
 
@@ -301,7 +320,8 @@ public:
301
320
  info->props.clear();
302
321
 
303
322
  return nullptr;
304
- });
323
+ },
324
+ /* revive= */ true);
305
325
  }
306
326
 
307
327
  /**
@@ -320,7 +340,8 @@ public:
320
340
  */
321
341
  void setSkiaView(size_t nativeId, std::shared_ptr<RNSkView> view) {
322
342
  ViewRegistry::getInstance().withViewInfo(
323
- nativeId, [&](std::shared_ptr<RNSkViewInfo> info) {
343
+ nativeId,
344
+ [&](std::shared_ptr<RNSkViewInfo> info) {
324
345
  if (view != nullptr) {
325
346
  info->view = view;
326
347
  info->view->setNativeId(nativeId);
@@ -330,7 +351,8 @@ public:
330
351
  info->view = view; // Set to nullptr
331
352
  }
332
353
  return nullptr;
333
- });
354
+ },
355
+ /* revive= */ view != nullptr);
334
356
  }
335
357
 
336
358
  private:
@@ -8,6 +8,8 @@
8
8
  #include "webgpu/webgpu_cpp.h"
9
9
 
10
10
  #ifdef __APPLE__
11
+ #include "rnskia/RNMetalLayerColorSpace.h"
12
+
11
13
  namespace dawn::native::metal {
12
14
  void WaitForCommandsToBeScheduled(WGPUDevice device);
13
15
  } // namespace dawn::native::metal
@@ -126,10 +128,11 @@ public:
126
128
  #ifdef __APPLE__
127
129
  // Ensure command buffers are scheduled before presenting. Read the device
128
130
  // under a shared lock, then wait without holding it (the wait can block).
129
- // The device may be reconfigured between the two locks; that is safe because
130
- // present() is called on the rendering thread right after submit(), the wait
131
- // just flushes that thread's already-submitted work, and the Present() below
132
- // re-checks `surface` under the unique lock before touching it.
131
+ // The device may be reconfigured between the two locks; that is safe
132
+ // because present() is called on the rendering thread right after submit(),
133
+ // the wait just flushes that thread's already-submitted work, and the
134
+ // Present() below re-checks `surface` under the unique lock before touching
135
+ // it.
133
136
  wgpu::Device device;
134
137
  {
135
138
  std::shared_lock<std::shared_mutex> lock(_mutex);
@@ -186,6 +189,9 @@ private:
186
189
  void _configure() {
187
190
  if (surface) {
188
191
  surface.Configure(&config);
192
+ #ifdef __APPLE__
193
+ RNSkia::applyCAMetalLayerColorSpace(nativeSurface, config.format);
194
+ #endif
189
195
  } else {
190
196
  wgpu::TextureDescriptor textureDesc;
191
197
  textureDesc.format = config.format;
@@ -7,100 +7,13 @@ exports.Platform = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _types = require("../skia/types");
9
9
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
10
- // https://github.com/necolas/react-native-web/blob/master/packages/react-native-web/src/modules/useElementLayout/index.js
11
- const DOM_LAYOUT_HANDLER_NAME = "__reactLayoutHandler";
12
- let resizeObserver = null;
13
- const getObserver = () => {
14
- if (resizeObserver == null) {
15
- resizeObserver = new window.ResizeObserver(function (entries) {
16
- entries.forEach(entry => {
17
- const node = entry.target;
18
- const {
19
- left,
20
- top,
21
- width,
22
- height
23
- } = entry.contentRect;
24
- const onLayout = node[DOM_LAYOUT_HANDLER_NAME];
25
- if (typeof onLayout === "function") {
26
- // setTimeout 0 is taken from react-native-web (UIManager)
27
- setTimeout(() => onLayout({
28
- timeStamp: Date.now(),
29
- nativeEvent: {
30
- layout: {
31
- x: left,
32
- y: top,
33
- width,
34
- height
35
- }
36
- },
37
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
38
- // @ts-expect-error
39
- currentTarget: 0,
40
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
41
- // @ts-expect-error
42
- target: 0,
43
- bubbles: false,
44
- cancelable: false,
45
- defaultPrevented: false,
46
- eventPhase: 0,
47
- isDefaultPrevented() {
48
- throw new Error("Method not supported on web.");
49
- },
50
- isPropagationStopped() {
51
- throw new Error("Method not supported on web.");
52
- },
53
- persist() {
54
- throw new Error("Method not supported on web.");
55
- },
56
- preventDefault() {
57
- throw new Error("Method not supported on web.");
58
- },
59
- stopPropagation() {
60
- throw new Error("Method not supported on web.");
61
- },
62
- isTrusted: true,
63
- type: ""
64
- }), 0);
65
- }
66
- });
67
- });
68
- }
69
- return resizeObserver;
70
- };
71
- const useElementLayout = (ref, onLayout) => {
72
- const observer = getObserver();
73
- (0, _react.useLayoutEffect)(() => {
74
- const node = ref.current;
75
- if (node !== null) {
76
- node[DOM_LAYOUT_HANDLER_NAME] = onLayout;
77
- }
78
- }, [ref, onLayout]);
79
- (0, _react.useLayoutEffect)(() => {
80
- const node = ref.current;
81
- if (node != null && observer != null) {
82
- if (typeof node[DOM_LAYOUT_HANDLER_NAME] === "function") {
83
- observer.observe(node);
84
- } else {
85
- observer.unobserve(node);
86
- }
87
- }
88
- return () => {
89
- if (node != null && observer != null) {
90
- observer.unobserve(node);
91
- }
92
- };
93
- }, [observer, ref]);
94
- };
10
+ // Layout is observed by the views themselves (see SkiaPictureView.web.tsx):
11
+ // this shim only reproduces react-native-web's default View styling.
95
12
  const View = ({
96
13
  children,
97
- onLayout,
98
14
  style: rawStyle
99
15
  }) => {
100
16
  const style = (0, _react.useMemo)(() => rawStyle !== null && rawStyle !== void 0 ? rawStyle : {}, [rawStyle]);
101
- const ref = (0, _react.useRef)(null);
102
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
103
- useElementLayout(ref, onLayout);
104
17
  const cssStyles = (0, _react.useMemo)(() => {
105
18
  return {
106
19
  alignItems: "stretch",
@@ -123,7 +36,6 @@ const View = ({
123
36
  };
124
37
  }, [style]);
125
38
  return /*#__PURE__*/_react.default.createElement("div", {
126
- ref: ref,
127
39
  style: cssStyles
128
40
  }, children);
129
41
  };