@shopify/react-native-skia 2.12.0-next.1 → 2.12.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 (202) hide show
  1. package/Package.swift +117 -0
  2. package/android/CMakeLists.txt +1 -2
  3. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +0 -10
  4. package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +9 -12
  5. package/apple/RNSkApplePlatformContext.h +0 -3
  6. package/apple/RNSkApplePlatformContext.mm +0 -11
  7. package/cpp/api/JsiSkApi.h +0 -6
  8. package/cpp/api/JsiSkFont.h +5 -10
  9. package/cpp/api/JsiSkMatrix.h +4 -2
  10. package/cpp/api/JsiSkSVGFactory.h +4 -0
  11. package/cpp/api/recorder/Convertor.h +5 -2
  12. package/cpp/api/recorder/Drawings.h +13 -3
  13. package/cpp/api/recorder/ImageFilters.h +15 -1
  14. package/cpp/api/recorder/Paint.h +8 -1
  15. package/cpp/jsi/JSICache.cpp +99 -0
  16. package/cpp/jsi/JSICache.h +90 -0
  17. package/cpp/jsi/NativeObject.h +38 -87
  18. package/cpp/jsi/ViewProperty.h +0 -24
  19. package/cpp/rnskia/RNDawnContext.h +2 -1
  20. package/cpp/rnskia/RNDawnWindowContext.h +22 -0
  21. package/cpp/rnskia/RNSkManager.cpp +0 -6
  22. package/cpp/rnskia/RNSkPlatformContext.h +0 -3
  23. package/cpp/skia/include/core/RasterContext.h +25 -0
  24. package/cpp/skia/include/core/SkCanvas.h +0 -1
  25. package/cpp/skia/include/core/SkContext.h +62 -0
  26. package/cpp/skia/include/core/SkContextOptions.h +15 -0
  27. package/cpp/skia/include/core/SkMilestone.h +1 -1
  28. package/cpp/skia/include/core/SkPicture.h +36 -18
  29. package/cpp/skia/include/core/SkRecorder.h +8 -0
  30. package/cpp/skia/include/core/SkSerialProcs.h +2 -6
  31. package/cpp/skia/include/effects/SkImageFilters.h +15 -2
  32. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +73 -47
  33. package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +7 -4
  34. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +12 -0
  35. package/cpp/skia/include/gpu/ganesh/gl/GrGLDirectContext.h +11 -0
  36. package/cpp/skia/include/gpu/ganesh/mtl/GrMtlDirectContext.h +11 -0
  37. package/cpp/skia/include/gpu/ganesh/vk/GrVkDirectContext.h +13 -0
  38. package/cpp/skia/include/gpu/graphite/ContextOptions.h +6 -0
  39. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +5 -4
  40. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +9 -1
  41. package/cpp/skia/include/gpu/graphite/Recorder.h +0 -2
  42. package/cpp/skia/include/gpu/graphite/Recording.h +3 -0
  43. package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +8 -0
  44. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +11 -0
  45. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteContext.h +11 -0
  46. package/cpp/skia/include/private/SkLog.h +1 -19
  47. package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +2 -1
  48. package/cpp/skia/include/utils/SkLogHandler.h +53 -0
  49. package/cpp/skia/include/utils/SkNWayCanvas.h +1 -0
  50. package/cpp/skia/modules/skcms/src/Transform_inl.h +9 -10
  51. package/cpp/skia/modules/skcms/src/skcms_internals.h +8 -3
  52. package/cpp/skia/modules/skottie/include/SkottieProperty.h +2 -0
  53. package/cpp/skia/modules/skottie/include/TextShaper.h +1 -0
  54. package/cpp/skia/modules/skshaper/include/SkShaper.h +23 -1
  55. package/include/ReactNativeSkia.h +6 -0
  56. package/lib/commonjs/dom/nodes/datatypes/Rect.js +5 -1
  57. package/lib/commonjs/dom/nodes/datatypes/Rect.js.map +1 -1
  58. package/lib/commonjs/external/reanimated/useVideo.js +8 -2
  59. package/lib/commonjs/external/reanimated/useVideo.js.map +1 -1
  60. package/lib/commonjs/renderer/components/Mask.js +3 -9
  61. package/lib/commonjs/renderer/components/Mask.js.map +1 -1
  62. package/lib/commonjs/skia/types/JsiInstance.d.ts +1 -0
  63. package/lib/commonjs/skia/types/JsiInstance.js.map +1 -1
  64. package/lib/commonjs/skia/types/Matrix4.js +7 -2
  65. package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
  66. package/lib/commonjs/skia/types/Skia.d.ts +1 -6
  67. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  68. package/lib/commonjs/skia/web/JsiSkCanvas.js +4 -4
  69. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  70. package/lib/commonjs/skia/web/JsiSkImage.js +6 -3
  71. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  72. package/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +1 -1
  73. package/lib/commonjs/skia/web/JsiSkPathBuilder.js +2 -2
  74. package/lib/commonjs/skia/web/JsiSkPathBuilder.js.map +1 -1
  75. package/lib/commonjs/skia/web/JsiSkTextStyle.js +5 -5
  76. package/lib/commonjs/skia/web/JsiSkTextStyle.js.map +1 -1
  77. package/lib/commonjs/skia/web/JsiSkia.js +0 -3
  78. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  79. package/lib/commonjs/skia/web/JsiSkottieAnimation.js +8 -8
  80. package/lib/commonjs/skia/web/JsiSkottieAnimation.js.map +1 -1
  81. package/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +1 -0
  82. package/lib/commonjs/sksg/Recorder/DrawingContext.js +15 -0
  83. package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -1
  84. package/lib/commonjs/sksg/Recorder/Player.js +1 -1
  85. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  86. package/lib/commonjs/sksg/Recorder/Visitor.js +6 -1
  87. package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
  88. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +12 -9
  89. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  90. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js +15 -1
  91. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
  92. package/lib/commonjs/sksg/Recorder/commands/Shaders.js +1 -1
  93. package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
  94. package/lib/commonjs/views/SkiaPictureView.web.js +247 -57
  95. package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
  96. package/lib/module/dom/nodes/datatypes/Rect.js +5 -1
  97. package/lib/module/dom/nodes/datatypes/Rect.js.map +1 -1
  98. package/lib/module/external/reanimated/useVideo.js +8 -2
  99. package/lib/module/external/reanimated/useVideo.js.map +1 -1
  100. package/lib/module/renderer/components/Mask.js +3 -9
  101. package/lib/module/renderer/components/Mask.js.map +1 -1
  102. package/lib/module/skia/types/JsiInstance.d.ts +1 -0
  103. package/lib/module/skia/types/JsiInstance.js.map +1 -1
  104. package/lib/module/skia/types/Matrix4.js +7 -2
  105. package/lib/module/skia/types/Matrix4.js.map +1 -1
  106. package/lib/module/skia/types/Skia.d.ts +1 -6
  107. package/lib/module/skia/types/Skia.js.map +1 -1
  108. package/lib/module/skia/web/JsiSkCanvas.js +4 -4
  109. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  110. package/lib/module/skia/web/JsiSkImage.js +6 -3
  111. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  112. package/lib/module/skia/web/JsiSkPathBuilder.d.ts +1 -1
  113. package/lib/module/skia/web/JsiSkPathBuilder.js +2 -2
  114. package/lib/module/skia/web/JsiSkPathBuilder.js.map +1 -1
  115. package/lib/module/skia/web/JsiSkTextStyle.js +5 -5
  116. package/lib/module/skia/web/JsiSkTextStyle.js.map +1 -1
  117. package/lib/module/skia/web/JsiSkia.js +0 -3
  118. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  119. package/lib/module/skia/web/JsiSkottieAnimation.js +8 -8
  120. package/lib/module/skia/web/JsiSkottieAnimation.js.map +1 -1
  121. package/lib/module/sksg/Recorder/DrawingContext.d.ts +1 -0
  122. package/lib/module/sksg/Recorder/DrawingContext.js +15 -0
  123. package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -1
  124. package/lib/module/sksg/Recorder/Player.js +1 -1
  125. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  126. package/lib/module/sksg/Recorder/Visitor.js +6 -1
  127. package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
  128. package/lib/module/sksg/Recorder/commands/Drawing.js +12 -9
  129. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  130. package/lib/module/sksg/Recorder/commands/ImageFilters.js +15 -1
  131. package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
  132. package/lib/module/sksg/Recorder/commands/Shaders.js +1 -1
  133. package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
  134. package/lib/module/views/SkiaPictureView.web.js +247 -57
  135. package/lib/module/views/SkiaPictureView.web.js.map +1 -1
  136. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +1 -1
  137. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +0 -1
  138. package/lib/typescript/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +1 -0
  139. package/lib/typescript/lib/module/skia/Skia.web.d.ts +0 -1
  140. package/lib/typescript/lib/module/skia/web/JsiSkPathBuilder.d.ts +1 -1
  141. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +0 -1
  142. package/lib/typescript/lib/module/sksg/Recorder/DrawingContext.d.ts +1 -0
  143. package/lib/typescript/react-native.config.d.ts +3 -0
  144. package/lib/typescript/src/skia/types/JsiInstance.d.ts +1 -0
  145. package/lib/typescript/src/skia/types/Skia.d.ts +1 -6
  146. package/lib/typescript/src/skia/web/JsiSkPathBuilder.d.ts +1 -1
  147. package/lib/typescript/src/sksg/Recorder/DrawingContext.d.ts +1 -0
  148. package/package.json +13 -10
  149. package/react-native.config.js +5 -0
  150. package/src/dom/nodes/datatypes/Rect.ts +6 -1
  151. package/src/external/reanimated/useVideo.ts +7 -2
  152. package/src/renderer/components/Mask.tsx +10 -3
  153. package/src/skia/types/JsiInstance.ts +2 -0
  154. package/src/skia/types/Matrix4.ts +6 -2
  155. package/src/skia/types/Skia.ts +1 -7
  156. package/src/skia/web/JsiSkCanvas.ts +11 -6
  157. package/src/skia/web/JsiSkImage.ts +6 -3
  158. package/src/skia/web/JsiSkPathBuilder.ts +2 -2
  159. package/src/skia/web/JsiSkTextStyle.ts +20 -15
  160. package/src/skia/web/JsiSkia.ts +0 -4
  161. package/src/skia/web/JsiSkottieAnimation.ts +8 -8
  162. package/src/sksg/Recorder/DrawingContext.ts +15 -0
  163. package/src/sksg/Recorder/Player.ts +1 -1
  164. package/src/sksg/Recorder/Visitor.ts +9 -6
  165. package/src/sksg/Recorder/commands/Drawing.ts +12 -9
  166. package/src/sksg/Recorder/commands/ImageFilters.ts +20 -1
  167. package/src/sksg/Recorder/commands/Shaders.ts +1 -1
  168. package/src/views/SkiaPictureView.web.tsx +245 -57
  169. package/cpp/api/JsiSkiaContext.h +0 -94
  170. package/cpp/dawn/include/dawn/dawn_proc.h +0 -53
  171. package/cpp/dawn/include/dawn/dawn_proc_table.h +0 -330
  172. package/cpp/dawn/include/dawn/dawn_thread_dispatch_proc.h +0 -47
  173. package/cpp/dawn/include/dawn/dawn_version.h +0 -41
  174. package/cpp/dawn/include/dawn/native/D3D11Backend.h +0 -65
  175. package/cpp/dawn/include/dawn/native/D3D12Backend.h +0 -103
  176. package/cpp/dawn/include/dawn/native/D3DBackend.h +0 -56
  177. package/cpp/dawn/include/dawn/native/DawnNative.h +0 -368
  178. package/cpp/dawn/include/dawn/native/MetalBackend.h +0 -56
  179. package/cpp/dawn/include/dawn/native/NullBackend.h +0 -39
  180. package/cpp/dawn/include/dawn/native/OpenGLBackend.h +0 -89
  181. package/cpp/dawn/include/dawn/native/VulkanBackend.h +0 -183
  182. package/cpp/dawn/include/dawn/native/WebGPUBackend.h +0 -49
  183. package/cpp/dawn/include/dawn/native/dawn_native_export.h +0 -49
  184. package/cpp/dawn/include/dawn/platform/DawnPlatform.h +0 -207
  185. package/cpp/dawn/include/dawn/platform/dawn_platform_export.h +0 -49
  186. package/cpp/dawn/include/dawn/replay/Replay.h +0 -99
  187. package/cpp/dawn/include/dawn/replay/dawn_replay_export.h +0 -49
  188. package/cpp/dawn/include/dawn/webgpu_cpp_print.h +0 -2856
  189. package/cpp/dawn/include/tint/tint.h +0 -91
  190. package/cpp/dawn/include/webgpu/webgpu.h +0 -5029
  191. package/cpp/dawn/include/webgpu/webgpu_cpp.h +0 -10353
  192. package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +0 -57
  193. package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +0 -162
  194. package/cpp/dawn/include/webgpu/webgpu_glfw.h +0 -88
  195. package/cpp/jsi/RuntimeAwareCache.cpp +0 -7
  196. package/cpp/jsi/RuntimeAwareCache.h +0 -117
  197. package/cpp/jsi/RuntimeLifecycleMonitor.cpp +0 -72
  198. package/cpp/jsi/RuntimeLifecycleMonitor.h +0 -32
  199. package/cpp/skia/src/gpu/graphite/ContextOptionsPriv.h +0 -45
  200. package/cpp/skia/src/gpu/graphite/ResourceTypes.h +0 -360
  201. package/cpp/skia/src/gpu/graphite/TextureProxyView.h +0 -105
  202. package/libs/.graphite +0 -1
@@ -320,14 +320,34 @@ public:
320
320
  bool wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores,
321
321
  bool deleteSemaphoresAfterWait = true);
322
322
 
323
+ /*
324
+ * Result of a flush call. A flush can be successful w/ or w/o any semaphores being flushed.
325
+ * In some circumstances an unsuccessful flush can still have flushed the semaphores but
326
+ * the rendering results should be discarded.
327
+ */
328
+ struct FlushResult {
329
+ // This implicit cast is temporary and recreates the success/semaphore-submission
330
+ // conflation of the old API. This can be removed when all clients have been
331
+ // updated to the new return value.
332
+ operator GrSemaphoresSubmitted() const {
333
+ return fSuccess ? GrSemaphoresSubmitted::kYes : GrSemaphoresSubmitted::kNo;
334
+ }
335
+
336
+ bool fSuccess = false; // Did the flush succeed
337
+ // Were any semaphores submitted during the flush process. Will be kNo if no
338
+ // semaphores were specified.
339
+ GrSemaphoresSubmitted fSubmitted = GrSemaphoresSubmitted::kNo;
340
+ };
341
+
323
342
  /**
324
343
  * Call to ensure all drawing to the context has been flushed and submitted to the underlying 3D
325
344
  * API. This is equivalent to calling GrContext::flush with a default GrFlushInfo followed by
326
345
  * GrContext::submit(sync).
327
346
  */
328
- void flushAndSubmit(GrSyncCpu sync = GrSyncCpu::kNo) {
329
- this->flush(GrFlushInfo());
330
- this->submit(sync);
347
+ FlushResult flushAndSubmit(GrSyncCpu sync = GrSyncCpu::kNo) {
348
+ FlushResult result = this->flush(GrFlushInfo());
349
+ result.fSuccess &= this->submit(sync);
350
+ return result;
331
351
  }
332
352
 
333
353
  /**
@@ -341,22 +361,22 @@ public:
341
361
  * buffer or encoder objects. However, these objects are not sent to the gpu until a
342
362
  * submission occurs.
343
363
  *
344
- * If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will be
345
- * submitted to the gpu during the next submit call (it is possible Skia failed to create a
346
- * subset of the semaphores). The client should not wait on these semaphores until after submit
347
- * has been called, and must keep them alive until then. If this call returns
348
- * GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores to be signaled on
349
- * the GPU. Thus the client should not have the GPU wait on any of the semaphores passed in with
350
- * the GrFlushInfo. Regardless of whether semaphores were submitted to the GPU or not, the
351
- * client is still responsible for deleting any initialized semaphores.
364
+ * If FlushResult.fSubmitted is GrSemaphoresSubmitted::kYes, only initialized
365
+ * GrBackendSemaphores will be submitted to the gpu during the next submit call (it is possible
366
+ * Skia failed to create a subset of the semaphores). The client should not wait on these
367
+ * semaphores until after submit has been called, and must keep them alive until then. If
368
+ * fSubmitted is GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores
369
+ * to be signaled on the GPU. Thus the client should not have the GPU wait on any of the
370
+ * semaphores passed in with the GrFlushInfo. Regardless of whether semaphores were submitted
371
+ * to the GPU or not, the client is still responsible for deleting any initialized semaphores.
352
372
  * Regardless of semaphore submission the context will still be flushed. It should be
353
- * emphasized that a return value of GrSemaphoresSubmitted::kNo does not mean the flush did not
354
- * happen. It simply means there were no semaphores submitted to the GPU. A caller should only
355
- * take this as a failure if they passed in semaphores to be submitted.
373
+ * emphasized that a fSubmitted value of GrSemaphoresSubmitted::kNo does not mean the flush
374
+ * did not happen. It simply means there were no semaphores submitted to the GPU. A caller
375
+ * should only take this as a failure if they passed in semaphores to be submitted.
356
376
  */
357
- GrSemaphoresSubmitted flush(const GrFlushInfo& info);
377
+ FlushResult flush(const GrFlushInfo& info);
358
378
 
359
- void flush() { this->flush(GrFlushInfo()); }
379
+ void flush() { (void) this->flush(GrFlushInfo()); }
360
380
 
361
381
  /** Flushes any pending uses of texture-backed images in the GPU backend. If the image is not
362
382
  * texture-backed (including promise texture images) or if the GrDirectContext does not
@@ -367,13 +387,18 @@ public:
367
387
  * @param image the non-null image to flush.
368
388
  * @param info flush options
369
389
  */
370
- GrSemaphoresSubmitted flush(const sk_sp<const SkImage>& image, const GrFlushInfo& info);
371
- void flush(const sk_sp<const SkImage>& image);
390
+ FlushResult flush(const sk_sp<const SkImage>& image, const GrFlushInfo& info);
391
+
392
+ void flush(const sk_sp<const SkImage>& image) { (void) this->flush(image, {}); }
372
393
 
373
394
  /** Version of flush() that uses a default GrFlushInfo. Also submits the flushed work to the
374
- * GPU.
395
+ * GPU.
375
396
  */
376
- void flushAndSubmit(const sk_sp<const SkImage>& image);
397
+ FlushResult flushAndSubmit(const sk_sp<const SkImage>& image) {
398
+ FlushResult result = this->flush(image, {});
399
+ result.fSuccess &= this->submit();
400
+ return result;
401
+ }
377
402
 
378
403
  /** Issues pending SkSurface commands to the GPU-backed API objects and resolves any SkSurface
379
404
  * MSAA. A call to GrDirectContext::submit is always required to ensure work is actually sent
@@ -400,19 +425,20 @@ public:
400
425
  * The GrFlushInfo describes additional options to flush. Please see documentation at
401
426
  * GrFlushInfo for more info.
402
427
  *
403
- * If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will be
404
- * submitted to the gpu during the next submit call (it is possible Skia failed to create a
405
- * subset of the semaphores). The client should not wait on these semaphores until after submit
406
- * has been called, but must keep them alive until then. If a submit flag was passed in with
407
- * the flush these valid semaphores can we waited on immediately. If this call returns
408
- * GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores to be signaled on
409
- * the GPU. Thus the client should not have the GPU wait on any of the semaphores passed in
410
- * with the GrFlushInfo. Regardless of whether semaphores were submitted to the GPU or not, the
411
- * client is still responsible for deleting any initialized semaphores.
412
- * Regardless of semaphore submission the context will still be flushed. It should be
413
- * emphasized that a return value of GrSemaphoresSubmitted::kNo does not mean the flush did not
414
- * happen. It simply means there were no semaphores submitted to the GPU. A caller should only
415
- * take this as a failure if they passed in semaphores to be submitted.
428
+ * If FlushResult.fSubmitted is GrSemaphoresSubmitted::kYes, only initialized
429
+ * GrBackendSemaphores will be submitted to the gpu during the next submit call (it is
430
+ * possible Skia failed to create a subset of the semaphores). The client should not wait on
431
+ * these semaphores until after submit has been called, but must keep them alive until then.
432
+ * If a submit flag was passed in with the flush these valid semaphores can we waited on
433
+ * immediately. If this fSubmitted is GrSemaphoresSubmitted::kNo, the GPU backend will not
434
+ * submit any semaphores to be signaled on the GPU. Thus the client should not have the GPU
435
+ * wait on any of the semaphores passed in with the GrFlushInfo. Regardless of whether
436
+ * semaphores were submitted to the GPU or not, the client is still responsible for deleting
437
+ * any initialized semaphores. Regardless of semaphore submission the context will still be
438
+ * flushed. It should be emphasized that a fSubmitted value of GrSemaphoresSubmitted::kNo
439
+ * does not mean the flush did not happen. It simply means there were no semaphores submitted
440
+ * to the GPU. A caller should only take this as a failure if they passed in semaphores to
441
+ * be submitted.
416
442
  *
417
443
  * Pending surface commands are flushed regardless of the return result.
418
444
  *
@@ -420,9 +446,9 @@ public:
420
446
  * @param access type of access the call will do on the backend object after flush
421
447
  * @param info flush options
422
448
  */
423
- GrSemaphoresSubmitted flush(SkSurface* surface,
424
- SkSurfaces::BackendSurfaceAccess access,
425
- const GrFlushInfo& info);
449
+ FlushResult flush(SkSurface* surface,
450
+ SkSurfaces::BackendSurfaceAccess access,
451
+ const GrFlushInfo& info);
426
452
 
427
453
  /**
428
454
  * Same as above except:
@@ -443,9 +469,16 @@ public:
443
469
  * @param info flush options
444
470
  * @param newState optional state change request after flush
445
471
  */
446
- GrSemaphoresSubmitted flush(SkSurface* surface,
447
- const GrFlushInfo& info,
448
- const skgpu::MutableTextureState* newState = nullptr);
472
+ FlushResult flush(SkSurface* surface,
473
+ const GrFlushInfo& info,
474
+ const skgpu::MutableTextureState* newState = nullptr);
475
+
476
+ /**
477
+ * Flushes the given surface with the default GrFlushInfo.
478
+ *
479
+ * Has no effect on a CPU-backed surface.
480
+ */
481
+ void flush(SkSurface* surface) { (void) this->flush(surface, GrFlushInfo(), nullptr); }
449
482
 
450
483
  /** Call to ensure all reads/writes of the surface have been issued to the underlying 3D API.
451
484
  * Skia will correctly order its own draws and pixel operations. This must to be used to ensure
@@ -455,14 +488,7 @@ public:
455
488
  *
456
489
  * Has no effect on a CPU-backed surface.
457
490
  */
458
- void flushAndSubmit(SkSurface* surface, GrSyncCpu sync = GrSyncCpu::kNo);
459
-
460
- /**
461
- * Flushes the given surface with the default GrFlushInfo.
462
- *
463
- * Has no effect on a CPU-backed surface.
464
- */
465
- void flush(SkSurface* surface);
491
+ FlushResult flushAndSubmit(SkSurface* surface, GrSyncCpu sync = GrSyncCpu::kNo);
466
492
 
467
493
  /**
468
494
  * Submit outstanding work to the gpu from all previously un-submitted flushes. The return
@@ -11,6 +11,7 @@
11
11
  #include "include/core/SkImageInfo.h"
12
12
  #include "include/core/SkRefCnt.h"
13
13
  #include "include/core/SkSurface.h"
14
+ #include "include/gpu/ganesh/GrDirectContext.h"
14
15
  #include "include/gpu/ganesh/GrTypes.h"
15
16
  #include "include/private/SkAPI.h"
16
17
 
@@ -209,10 +210,12 @@ namespace skgpu::ganesh {
209
210
  // Clients should strive to call GrDirectContext::flush directly. However, there exist some
210
211
  // places where the GrDirectContext is hard to find, these helpers allow for the flushing of the
211
212
  // provided surface. This is a no-op if the surface is nullptr or not GPU backed.
212
- SK_API GrSemaphoresSubmitted Flush(sk_sp<SkSurface>);
213
- SK_API GrSemaphoresSubmitted Flush(SkSurface*);
214
- SK_API void FlushAndSubmit(sk_sp<SkSurface>);
215
- SK_API void FlushAndSubmit(SkSurface*);
213
+ SK_API GrDirectContext::FlushResult Flush(sk_sp<SkSurface>);
214
+ SK_API GrDirectContext::FlushResult Flush(SkSurface*);
215
+
216
+ SK_API GrDirectContext::FlushResult FlushAndSubmit(sk_sp<SkSurface>);
217
+ SK_API GrDirectContext::FlushResult FlushAndSubmit(SkSurface*);
218
+
216
219
  } // namespace skgpu::ganesh
217
220
 
218
221
  #endif
@@ -11,9 +11,13 @@
11
11
  #include "include/core/SkRefCnt.h"
12
12
  #include "include/private/SkAPI.h"
13
13
 
14
+ #include <memory>
15
+
14
16
  class GrDirectContext;
17
+ class SkContext;
15
18
  struct GrContextOptions;
16
19
  struct GrD3DBackendContext;
20
+ struct SkContextOptions;
17
21
 
18
22
  namespace GrDirectContexts {
19
23
  /**
@@ -25,4 +29,12 @@ SK_API sk_sp<GrDirectContext> MakeD3D(const GrD3DBackendContext& backendContext,
25
29
  SK_API sk_sp<GrDirectContext> MakeD3D(const GrD3DBackendContext& backendContext);
26
30
  } // namespace GrDirectContexts
27
31
 
32
+ namespace SkContexts {
33
+
34
+ // Creates a context wrapping a Ganesh GPU backend with D3D
35
+ std::unique_ptr<SkContext> MakeGanesh(const GrD3DBackendContext& backendContext,
36
+ const SkContextOptions& options);
37
+
38
+ } // namespace SkContexts
39
+
28
40
  #endif
@@ -11,9 +11,13 @@
11
11
  #include "include/core/SkRefCnt.h"
12
12
  #include "include/private/SkAPI.h"
13
13
 
14
+ #include <memory>
15
+
14
16
  class GrDirectContext;
17
+ class SkContext;
15
18
  struct GrContextOptions;
16
19
  struct GrGLInterface;
20
+ struct SkContextOptions;
17
21
 
18
22
  namespace GrDirectContexts {
19
23
  /**
@@ -27,4 +31,11 @@ SK_API sk_sp<GrDirectContext> MakeGL();
27
31
  #endif
28
32
  }
29
33
 
34
+ namespace SkContexts {
35
+
36
+ // Creates a context wrapping a Ganesh GPU backend with OpenGL
37
+ std::unique_ptr<SkContext> MakeGanesh(sk_sp<const GrGLInterface>, const SkContextOptions& options);
38
+
39
+ } // namespace SkContexts
40
+
30
41
  #endif
@@ -11,9 +11,13 @@
11
11
  #include "include/core/SkRefCnt.h"
12
12
  #include "include/private/SkAPI.h"
13
13
 
14
+ #include <memory>
15
+
14
16
  class GrDirectContext;
17
+ class SkContext;
15
18
  struct GrContextOptions;
16
19
  struct GrMtlBackendContext;
20
+ struct SkContextOptions;
17
21
 
18
22
  namespace GrDirectContexts {
19
23
  /**
@@ -27,4 +31,11 @@ SK_API sk_sp<GrDirectContext> MakeMetal(const GrMtlBackendContext&, const GrCont
27
31
  SK_API sk_sp<GrDirectContext> MakeMetal(const GrMtlBackendContext&);
28
32
  } // namespace GrDirectContexts
29
33
 
34
+ namespace SkContexts {
35
+
36
+ // Creates a context wrapping a Ganesh GPU backend with Metal
37
+ std::unique_ptr<SkContext> MakeGanesh(const GrMtlBackendContext& mtlContext, const SkContextOptions& options);
38
+
39
+ } // namespace SkContexts
40
+
30
41
  #endif
@@ -11,8 +11,12 @@
11
11
  #include "include/core/SkRefCnt.h"
12
12
  #include "include/private/SkAPI.h"
13
13
 
14
+ #include <memory>
15
+
14
16
  class GrDirectContext;
17
+ class SkContext;
15
18
  struct GrContextOptions;
19
+ struct SkContextOptions;
16
20
  namespace skgpu {
17
21
  struct VulkanBackendContext;
18
22
  }
@@ -30,4 +34,13 @@ SK_API sk_sp<GrDirectContext> MakeVulkan(const skgpu::VulkanBackendContext&,
30
34
  SK_API sk_sp<GrDirectContext> MakeVulkan(const skgpu::VulkanBackendContext&);
31
35
  }
32
36
 
37
+ namespace SkContexts {
38
+
39
+ // Creates a context wrapping a Ganesh GPU backend with Vulkan
40
+ std::unique_ptr<SkContext> MakeGanesh(const skgpu::VulkanBackendContext& vkContext,
41
+ const SkContextOptions& options);
42
+
43
+ } // namespace SkContexts
44
+
45
+
33
46
  #endif
@@ -135,6 +135,12 @@ struct SK_API ContextOptions {
135
135
  bool fSetBackendLabels = false;
136
136
  #endif
137
137
 
138
+ /**
139
+ * Enabling switches Graphite from the existing sort-based draw ordering to the new layer-based
140
+ * system.
141
+ */
142
+ bool fUseDrawListLayer = false;
143
+
138
144
  /**
139
145
  * Client-provided context that is passed to the client-provided PipelineCachingCallback
140
146
  * and the (deprecated) PipelineCallback.
@@ -266,8 +266,7 @@ enum DrawTypeFlags : uint16_t {
266
266
 
267
267
  // kDrawVertices should be used to generate Pipelines that use the following RenderSteps:
268
268
  // VerticesRenderStep[*] for:
269
- // [Tris], [TrisTexCoords], [TrisColor], [TrisColorTexCoords],
270
- // [Tristrips], [TristripsTexCoords], [TristripsColor], [TristripsColorTexCoords]
269
+ // [Pos], [PosTexCoords], [PosColor], [PosColorTexCoords],
271
270
  kDrawVertices = 1 << 5,
272
271
 
273
272
  // kCircularArc renders filled circular arcs, with or without the center included, and
@@ -297,7 +296,7 @@ enum DrawTypeFlags : uint16_t {
297
296
  // This draw type covers all the methods Skia uses to draw drop shadows. It can be used to
298
297
  // generate Pipelines which, as part of their labels, have:
299
298
  // the AnalyticBlurRenderStep
300
- // VerticesRenderStep[TrisColor] with a GaussianColorFilter
299
+ // VerticesRenderStep[PosColor] with a GaussianColorFilter
301
300
  // For this draw type the PaintOptions parameter to Precompile() will be ignored.
302
301
  kDropShadows = 1 << 11,
303
302
 
@@ -307,7 +306,9 @@ enum DrawTypeFlags : uint16_t {
307
306
  // AnalyticAndAtlasClip
308
307
  kAnalyticClip = 1 << 12,
309
308
 
310
- kLast = kAnalyticClip,
309
+ kDrawMesh = 1 << 13,
310
+
311
+ kLast = kDrawMesh,
311
312
  };
312
313
 
313
314
  } // namespace skgpu::graphite
@@ -24,6 +24,14 @@ class SharedContext;
24
24
  class PrecompileContextPriv;
25
25
  class ResourceProvider;
26
26
 
27
+ // The PrecompileContext is spawned from a generating Context via Context::makePrecompileContext.
28
+ // It should only be used on a single thread but that can be different from the main thread (i.e.,
29
+ // the one the Context is operating on). Many PrecompileContext's can be operating in parallel
30
+ // but the majority of the benefit will be from the threaded compilation within the
31
+ // PrecompileContext. As for that, the PipelineContext(s) borrow(s) the Executor from the
32
+ // generating Context. To make lifetime management of the Executor reasonable, if the
33
+ // Context is deleted before its PrecompileContexts, the PrecompileContexts will lose access
34
+ // to the Executor and revert to single threaded compilation.
27
35
  class SK_API PrecompileContext {
28
36
  public:
29
37
  ~PrecompileContext();
@@ -99,9 +107,9 @@ private:
99
107
 
100
108
  explicit PrecompileContext(sk_sp<SharedContext>);
101
109
 
110
+ // The PrecompileContext should not be used on multiple threads
102
111
  mutable SingleOwner fSingleOwner;
103
112
  sk_sp<SharedContext> fSharedContext;
104
- std::unique_ptr<ResourceProvider> fResourceProvider;
105
113
  };
106
114
 
107
115
  } // namespace skgpu::graphite
@@ -52,7 +52,6 @@ class BackendTexture;
52
52
  class Context;
53
53
  class Device;
54
54
  class DrawBufferManager;
55
- class StorageBufferManager;
56
55
  class ImageProvider;
57
56
  class PaintParamsKeyBuilder;
58
57
  class PipelineDataGatherer;
@@ -299,7 +298,6 @@ private:
299
298
  std::unique_ptr<UploadBufferManager> fUploadBufferManager;
300
299
  // Depends on fUploadBufferManager (holds a pointer to it). Must be destroyed first.
301
300
  std::unique_ptr<DrawBufferManager> fDrawBufferManager;
302
- sk_sp<StorageBufferManager> fStorageBufferManager;
303
301
  std::unique_ptr<ProxyReadCountMap> fProxyReadCounts;
304
302
 
305
303
  skia_private::STArray<kMaxKeyAndDataBuilders, std::unique_ptr<KeyAndDataBuilder>>
@@ -18,6 +18,7 @@
18
18
  #include <vector>
19
19
 
20
20
  struct SkISize;
21
+ class SkPicture;
21
22
 
22
23
  namespace skgpu {
23
24
  class RefCntedCallback;
@@ -93,6 +94,8 @@ private:
93
94
  std::unique_ptr<LazyProxyData> fTargetProxyData;
94
95
 
95
96
  skia_private::TArray<sk_sp<RefCntedCallback>> fFinishedProcs;
97
+
98
+ skia_private::TArray<sk_sp<SkPicture>> fCapturedPictures;
96
99
  };
97
100
 
98
101
  } // namespace skgpu::graphite
@@ -13,6 +13,9 @@
13
13
 
14
14
  #include <memory>
15
15
 
16
+ class SkContext;
17
+ struct SkContextOptions;
18
+
16
19
  namespace skgpu::graphite {
17
20
 
18
21
  class Context;
@@ -74,4 +77,9 @@ SK_API std::unique_ptr<Context> MakeDawn(const DawnBackendContext&, const Contex
74
77
 
75
78
  } // namespace skgpu::graphite
76
79
 
80
+ namespace SkContexts {
81
+ std::unique_ptr<SkContext> MakeGraphite(const skgpu::graphite::DawnBackendContext& dawnContext,
82
+ const SkContextOptions& options);
83
+ } // namespace SkContexts
84
+
77
85
  #endif // skgpu_graphite_DawnBackendContext_DEFINED
@@ -15,6 +15,9 @@
15
15
  #import <CoreFoundation/CoreFoundation.h>
16
16
  #include <memory>
17
17
 
18
+ class SkContext;
19
+ struct SkContextOptions;
20
+
18
21
  namespace skgpu::graphite {
19
22
 
20
23
  // The MtlBackendContext contains all of the base Metal objects needed by the graphite Metal
@@ -31,4 +34,12 @@ SK_API std::unique_ptr<Context> MakeMetal(const MtlBackendContext&, const Contex
31
34
 
32
35
  } // namespace skgpu::graphite
33
36
 
37
+ namespace SkContexts {
38
+
39
+ // Creates a context wrapping a Graphite GPU backend using Metal
40
+ std::unique_ptr<SkContext> MakeGraphite(const skgpu::graphite::MtlBackendContext& mtlContext,
41
+ const SkContextOptions& options);
42
+
43
+ } // namespace SkContexts
44
+
34
45
  #endif // skgpu_graphite_MtlBackendContext_DEFINED
@@ -12,6 +12,9 @@
12
12
 
13
13
  #include "include/private/SkAPI.h"
14
14
 
15
+ struct SkContextOptions;
16
+ class SkContext;
17
+
15
18
  // NOTE: Because there is already a VulkanBackendContext header shared between Ganesh and Graphite,
16
19
  // this is named VulkanGraphiteContext.h to supply just the factory function (differing from the
17
20
  // public headers exposed by other backends).
@@ -28,4 +31,12 @@ SK_API std::unique_ptr<Context> MakeVulkan(const VulkanBackendContext&, const Co
28
31
 
29
32
  } // namespace skgpu::graphite
30
33
 
34
+ namespace SkContexts {
35
+
36
+ // Creates a context wrapping a Graphite GPU backend with Vulkan
37
+ std::unique_ptr<SkContext> MakeGraphite(const skgpu::VulkanBackendContext& vkContext,
38
+ const SkContextOptions& options);
39
+
40
+ } // namespace SkContexts
41
+
31
42
  #endif // skgpu_graphite_VulkanGraphiteUtils_DEFINED
@@ -16,29 +16,11 @@
16
16
  #include "include/private/SkLogPriority.h"
17
17
 
18
18
  #if !defined(SkLog)
19
- // To be implemented per platform.
19
+ // Implemented per platform.
20
20
  void SkLogVAList(SkLogPriority priority, const char format[], va_list args) SK_PRINTF_LIKE(2, 0);
21
21
  void SK_SPI SkLog(SkLogPriority priority, const char format[], ...) SK_PRINTF_LIKE(2, 3);
22
22
  #endif
23
23
 
24
- /**
25
- * TODO (b/469441457): SKGPU_GRAPHITE_LOWEST_ACTIVE_LOG_PRIORITY Was the config used to set the log
26
- * priority, so we check for that define as well. Eventually, we should move clients using this
27
- * define to the new one.
28
- */
29
- #if defined(SKGPU_GRAPHITE_LOWEST_ACTIVE_LOG_PRIORITY)
30
- static constexpr SkLogPriority MapGraphitePriority(skgpu::graphite::LogPriority priority) {
31
- switch (priority) {
32
- case skgpu::graphite::LogPriority::kError: return SkLogPriority::kError;
33
- case skgpu::graphite::LogPriority::kWarning: return SkLogPriority::kWarning;
34
- case skgpu::graphite::LogPriority::kInfo: return SkLogPriority::kInfo;
35
- case skgpu::graphite::LogPriority::kDebug: return SkLogPriority::kDebug;
36
- default: return SkLogPriority::kDebug;
37
- }
38
- }
39
- #define SKIA_LOWEST_ACTIVE_LOG_PRIORITY MapGraphitePriority(SKGPU_GRAPHITE_LOWEST_ACTIVE_LOG_PRIORITY)
40
- #endif
41
-
42
24
  #if !defined(SKIA_LOWEST_ACTIVE_LOG_PRIORITY)
43
25
  #ifdef SK_DEBUG
44
26
  #define SKIA_LOWEST_ACTIVE_LOG_PRIORITY SkLogPriority::kDebug
@@ -11,6 +11,7 @@
11
11
  #include "include/core/SkRefCnt.h"
12
12
  #include "include/core/SkSurfaceProps.h"
13
13
  #include "include/core/SkTypes.h"
14
+ #include "include/gpu/ganesh/GrDirectContext.h"
14
15
 
15
16
  #include <memory>
16
17
 
@@ -72,7 +73,7 @@ public:
72
73
 
73
74
  // Records all the draws to the imported secondary command buffer and sets any dependent
74
75
  // offscreen draws to the GPU.
75
- void flush();
76
+ GrDirectContext::FlushResult flush();
76
77
 
77
78
  /** Inserts a list of GPU semaphores that Skia will have the driver wait on before executing
78
79
  commands for this secondary CB. The wait semaphores will get added to the VkCommandBuffer
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Copyright 2026 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkLogHandler_DEFINED
9
+ #define SkLogHandler_DEFINED
10
+
11
+ #include "include/core/SkRefCnt.h"
12
+ #include "include/core/SkTypes.h"
13
+ #include "include/private/SkLogPriority.h"
14
+
15
+ #include <cstdarg>
16
+
17
+ /**
18
+ * SkLogHandler defines an interface for receiving Skia log messages.
19
+ * Clients can implement this interface and install it via SetInstance.
20
+ */
21
+ class SK_API SkLogHandler : public SkRefCnt {
22
+ public:
23
+ ~SkLogHandler() override = default;
24
+
25
+ /**
26
+ * Called when a log message is generated (must pass compile-time priority).
27
+ * Must be thread-safe since multiple threads may be logging at the same time.
28
+ * @param priority The priority of the log message.
29
+ * @param format The format string of the log message.
30
+ * @param args The arguments for the format string.
31
+ */
32
+ virtual void onLog(SkLogPriority priority, const char format[], va_list args) = 0;
33
+
34
+ /**
35
+ * Installs a custom log handler. Returns true if successful (i.e., it's the first call).
36
+ * Skia only allows one SkLogHandler to be set and it cannot change after being set.
37
+ */
38
+ static bool SetInstance(sk_sp<SkLogHandler>);
39
+
40
+ /**
41
+ * Returns the current log handler. If none has been set, returns nullptr.
42
+ */
43
+ static sk_sp<SkLogHandler> GetInstance();
44
+
45
+ protected:
46
+ SkLogHandler() = default;
47
+
48
+ private:
49
+ SkLogHandler(const SkLogHandler&) = delete;
50
+ SkLogHandler& operator=(const SkLogHandler&) = delete;
51
+ };
52
+
53
+ #endif // SkLogHandler_DEFINED
@@ -95,6 +95,7 @@ protected:
95
95
  const SkPaint*) override;
96
96
  void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
97
97
  SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override;
98
+ void onDrawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) override;
98
99
 
99
100
  void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
100
101
  void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override;
@@ -1113,11 +1113,9 @@ STAGE(unpremul, NoCtx) {
1113
1113
  }
1114
1114
 
1115
1115
  STAGE(matrix_3x3, const skcms_Matrix3x3* matrix) {
1116
- const float* m = &matrix->vals[0][0];
1117
-
1118
- F R = m[0]*r + m[1]*g + m[2]*b,
1119
- G = m[3]*r + m[4]*g + m[5]*b,
1120
- B = m[6]*r + m[7]*g + m[8]*b;
1116
+ F R = matrix->vals[0][0]*r + matrix->vals[0][1]*g + matrix->vals[0][2]*b,
1117
+ G = matrix->vals[1][0]*r + matrix->vals[1][1]*g + matrix->vals[1][2]*b,
1118
+ B = matrix->vals[2][0]*r + matrix->vals[2][1]*g + matrix->vals[2][2]*b;
1121
1119
 
1122
1120
  r = R;
1123
1121
  g = G;
@@ -1125,11 +1123,12 @@ STAGE(matrix_3x3, const skcms_Matrix3x3* matrix) {
1125
1123
  }
1126
1124
 
1127
1125
  STAGE(matrix_3x4, const skcms_Matrix3x4* matrix) {
1128
- const float* m = &matrix->vals[0][0];
1129
-
1130
- F R = m[0]*r + m[1]*g + m[ 2]*b + m[ 3],
1131
- G = m[4]*r + m[5]*g + m[ 6]*b + m[ 7],
1132
- B = m[8]*r + m[9]*g + m[10]*b + m[11];
1126
+ F R = matrix->vals[0][0]*r + matrix->vals[0][1]*g + matrix->vals[0][2]*b
1127
+ + matrix->vals[0][3],
1128
+ G = matrix->vals[1][0]*r + matrix->vals[1][1]*g + matrix->vals[1][2]*b
1129
+ + matrix->vals[1][3],
1130
+ B = matrix->vals[2][0]*r + matrix->vals[2][1]*g + matrix->vals[2][2]*b
1131
+ + matrix->vals[2][3];
1133
1132
 
1134
1133
  r = R;
1135
1134
  g = G;
@@ -57,9 +57,14 @@ extern "C" {
57
57
  #define SKCMS_HAS_MUSTTAIL 1
58
58
  #endif
59
59
  #elif defined(__GNUC__) && !defined(SKCMS_HAS_MUSTTAIL)
60
- // GCC on riscv64 does not support our tail call functions
61
- // cf. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121784
62
- #if __has_cpp_attribute(clang::musttail) && !defined(__riscv)
60
+ // GCC on RISCV, MIPS, PowerPC, LoongArch, and Windows (MinGW)
61
+ // does not support our tail call functions
62
+ // (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121784).
63
+ #if __has_cpp_attribute(clang::musttail) && !defined(__riscv) \
64
+ && !defined(__mips__) \
65
+ && !defined(__powerpc__) \
66
+ && !defined(__loongarch__) \
67
+ && !defined(_WIN32)
63
68
  #define SKCMS_HAS_MUSTTAIL 1
64
69
  #else
65
70
  #define SKCMS_HAS_MUSTTAIL 0