@shopify/react-native-skia 2.0.5 → 2.0.6

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 (180) hide show
  1. package/android/CMakeLists.txt +10 -0
  2. package/android/build.gradle +2 -1
  3. package/apple/SkiaCVPixelBufferUtils.mm +8 -4
  4. package/cpp/api/JsiSkCanvas.h +10 -8
  5. package/cpp/api/JsiSkFont.h +14 -18
  6. package/cpp/api/JsiSkPath.h +4 -2
  7. package/cpp/api/JsiSkPathEffectFactory.h +2 -2
  8. package/cpp/api/JsiSkTextBlobFactory.h +5 -3
  9. package/cpp/api/JsiSkTypeface.h +5 -4
  10. package/cpp/api/recorder/Drawings.h +26 -20
  11. package/cpp/api/recorder/PathEffects.h +3 -2
  12. package/cpp/skia/include/android/SkAndroidFrameworkUtils.h +1 -1
  13. package/cpp/skia/include/android/SkImageAndroid.h +1 -8
  14. package/cpp/skia/include/config/SkUserConfig.h +9 -0
  15. package/cpp/skia/include/core/SkCPUContext.h +31 -0
  16. package/cpp/skia/include/core/SkCPURecorder.h +69 -0
  17. package/cpp/skia/include/core/SkCanvas.h +57 -13
  18. package/cpp/skia/include/core/SkContourMeasure.h +1 -1
  19. package/cpp/skia/include/core/SkData.h +63 -37
  20. package/cpp/skia/include/core/SkFont.h +94 -65
  21. package/cpp/skia/include/core/SkImage.h +10 -9
  22. package/cpp/skia/include/core/SkImageGenerator.h +3 -0
  23. package/cpp/skia/include/core/SkMatrix.h +102 -116
  24. package/cpp/skia/include/core/SkMilestone.h +1 -1
  25. package/cpp/skia/include/core/SkPath.h +163 -60
  26. package/cpp/skia/include/core/SkPathBuilder.h +713 -30
  27. package/cpp/skia/include/core/SkPathTypes.h +5 -1
  28. package/cpp/skia/include/core/SkPictureRecorder.h +6 -6
  29. package/cpp/skia/include/core/SkRecorder.h +35 -0
  30. package/cpp/skia/include/core/SkRect.h +57 -27
  31. package/cpp/skia/include/core/SkRegion.h +1 -1
  32. package/cpp/skia/include/core/SkSurface.h +8 -1
  33. package/cpp/skia/include/core/SkTextBlob.h +50 -6
  34. package/cpp/skia/include/core/SkTraceMemoryDump.h +7 -0
  35. package/cpp/skia/include/core/SkTypeface.h +53 -26
  36. package/cpp/skia/include/core/SkTypes.h +6 -0
  37. package/cpp/skia/include/effects/SkDashPathEffect.h +9 -3
  38. package/cpp/skia/include/effects/SkRuntimeEffect.h +1 -1
  39. package/cpp/skia/include/encode/SkEncoder.h +1 -1
  40. package/cpp/skia/include/encode/SkICC.h +1 -1
  41. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +23 -0
  42. package/cpp/skia/include/gpu/ganesh/GrRecordingContext.h +12 -0
  43. package/cpp/skia/include/gpu/graphite/Context.h +32 -8
  44. package/cpp/skia/include/gpu/graphite/ContextOptions.h +22 -4
  45. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +21 -4
  46. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +16 -2
  47. package/cpp/skia/include/gpu/graphite/Recorder.h +30 -10
  48. package/cpp/skia/include/gpu/graphite/Recording.h +7 -3
  49. package/cpp/skia/include/gpu/graphite/TextureInfo.h +3 -3
  50. package/cpp/skia/include/gpu/graphite/precompile/PaintOptions.h +15 -0
  51. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +89 -13
  52. package/cpp/skia/include/gpu/graphite/vk/precompile/VulkanPrecompileShader.h +39 -0
  53. package/cpp/skia/include/gpu/vk/VulkanBackendContext.h +1 -1
  54. package/cpp/skia/include/gpu/vk/VulkanPreferredFeatures.h +214 -0
  55. package/cpp/skia/include/pathops/SkPathOps.h +7 -111
  56. package/cpp/skia/include/ports/SkFontMgr_fontconfig.h +3 -0
  57. package/cpp/skia/include/private/SkGainmapShader.h +10 -4
  58. package/cpp/skia/include/private/SkPathRef.h +6 -2
  59. package/cpp/skia/include/private/base/SkAlign.h +11 -0
  60. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +1 -1
  61. package/cpp/skia/include/third_party/vulkan/vulkan/vk_icd.h +255 -0
  62. package/cpp/skia/include/third_party/vulkan/vulkan/vk_layer.h +203 -0
  63. package/cpp/skia/include/third_party/vulkan/vulkan/vk_platform.h +1 -2
  64. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std.h +390 -0
  65. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_decode.h +106 -0
  66. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_encode.h +140 -0
  67. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std.h +1 -1
  68. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_decode.h +1 -1
  69. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_encode.h +144 -0
  70. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std.h +1 -1
  71. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_decode.h +1 -1
  72. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_encode.h +158 -0
  73. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codecs_common.h +1 -1
  74. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +1 -1
  75. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +1 -1
  76. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_beta.h +242 -0
  77. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +10094 -5707
  78. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_directfb.h +55 -0
  79. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_fuchsia.h +288 -0
  80. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ggp.h +59 -0
  81. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ios.h +1 -1
  82. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_macos.h +1 -1
  83. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_metal.h +238 -0
  84. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_screen.h +110 -0
  85. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_vi.h +47 -0
  86. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_wayland.h +55 -0
  87. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_win32.h +1 -1
  88. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xcb.h +1 -1
  89. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xlib.h +60 -0
  90. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xlib_xrandr.h +46 -0
  91. package/cpp/skia/modules/pathops/include/SkPathOps.h +121 -0
  92. package/cpp/skia/modules/skcms/src/skcms_internals.h +10 -2
  93. package/cpp/skia/modules/skcms/src/skcms_public.h +39 -10
  94. package/libs/android/arm64-v8a/libpathops.a +0 -0
  95. package/libs/android/arm64-v8a/libskia.a +0 -0
  96. package/libs/android/arm64-v8a/libskottie.a +0 -0
  97. package/libs/android/arm64-v8a/libskparagraph.a +0 -0
  98. package/libs/android/arm64-v8a/libsksg.a +0 -0
  99. package/libs/android/arm64-v8a/libskshaper.a +0 -0
  100. package/libs/android/arm64-v8a/libskunicode_icu.a +0 -0
  101. package/libs/android/arm64-v8a/libsvg.a +0 -0
  102. package/libs/android/armeabi-v7a/libpathops.a +0 -0
  103. package/libs/android/armeabi-v7a/libskia.a +0 -0
  104. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  105. package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
  106. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  107. package/libs/android/armeabi-v7a/libskshaper.a +0 -0
  108. package/libs/android/armeabi-v7a/libskunicode_icu.a +0 -0
  109. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  110. package/libs/android/x86/libpathops.a +0 -0
  111. package/libs/android/x86/libskia.a +0 -0
  112. package/libs/android/x86/libskottie.a +0 -0
  113. package/libs/android/x86/libskparagraph.a +0 -0
  114. package/libs/android/x86/libsksg.a +0 -0
  115. package/libs/android/x86/libskshaper.a +0 -0
  116. package/libs/android/x86/libskunicode_icu.a +0 -0
  117. package/libs/android/x86/libsvg.a +0 -0
  118. package/libs/android/x86_64/libpathops.a +0 -0
  119. package/libs/android/x86_64/libskia.a +0 -0
  120. package/libs/android/x86_64/libskottie.a +0 -0
  121. package/libs/android/x86_64/libskparagraph.a +0 -0
  122. package/libs/android/x86_64/libsksg.a +0 -0
  123. package/libs/android/x86_64/libskshaper.a +0 -0
  124. package/libs/android/x86_64/libskunicode_icu.a +0 -0
  125. package/libs/android/x86_64/libsvg.a +0 -0
  126. package/libs/apple/libpathops.xcframework/Info.plist +94 -0
  127. package/libs/apple/libpathops.xcframework/ios-arm64_arm64e/libpathops.a +0 -0
  128. package/libs/apple/libpathops.xcframework/ios-arm64_arm64e_x86_64-simulator/libpathops.a +0 -0
  129. package/libs/apple/libpathops.xcframework/macos-arm64_x86_64/libpathops.a +0 -0
  130. package/libs/apple/libpathops.xcframework/tvos-arm64_arm64e/libpathops.a +0 -0
  131. package/libs/apple/libpathops.xcframework/tvos-arm64_arm64e_x86_64-simulator/libpathops.a +0 -0
  132. package/libs/apple/libskia.xcframework/Info.plist +7 -7
  133. package/libs/apple/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  134. package/libs/apple/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  135. package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
  136. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e/libskia.a +0 -0
  137. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  138. package/libs/apple/libskottie.xcframework/Info.plist +10 -10
  139. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  140. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  141. package/libs/apple/libskottie.xcframework/macos-arm64_x86_64/libskottie.a +0 -0
  142. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e/libskottie.a +0 -0
  143. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  144. package/libs/apple/libskparagraph.xcframework/Info.plist +13 -13
  145. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  146. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  147. package/libs/apple/libskparagraph.xcframework/macos-arm64_x86_64/libskparagraph.a +0 -0
  148. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e/libskparagraph.a +0 -0
  149. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  150. package/libs/apple/libsksg.xcframework/Info.plist +11 -11
  151. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  152. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  153. package/libs/apple/libsksg.xcframework/macos-arm64_x86_64/libsksg.a +0 -0
  154. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e/libsksg.a +0 -0
  155. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  156. package/libs/apple/libskshaper.xcframework/Info.plist +12 -12
  157. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  158. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  159. package/libs/apple/libskshaper.xcframework/macos-arm64_x86_64/libskshaper.a +0 -0
  160. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e/libskshaper.a +0 -0
  161. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  162. package/libs/apple/libskunicode_core.xcframework/Info.plist +14 -14
  163. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  164. package/libs/apple/libskunicode_core.xcframework/macos-arm64_x86_64/libskunicode_core.a +0 -0
  165. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  166. package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +13 -13
  167. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  168. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  169. package/libs/apple/libskunicode_libgrapheme.xcframework/macos-arm64_x86_64/libskunicode_libgrapheme.a +0 -0
  170. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  171. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  172. package/libs/apple/libsvg.xcframework/Info.plist +17 -17
  173. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  174. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  175. package/libs/apple/libsvg.xcframework/macos-arm64_x86_64/libsvg.a +0 -0
  176. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e/libsvg.a +0 -0
  177. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  178. package/package.json +1 -1
  179. package/react-native-skia.podspec +2 -1
  180. package/src/renderer/__tests__/e2e/BackdropFilters.spec.tsx +23 -0
@@ -10,36 +10,52 @@
10
10
 
11
11
  #include "include/core/SkImage.h"
12
12
  #include "include/core/SkRefCnt.h"
13
- #include "include/core/SkShader.h"
14
- #include "include/gpu/graphite/ContextOptions.h"
13
+ #include "include/core/SkSize.h"
14
+ #include "include/core/SkSpan.h"
15
+ #include "include/core/SkTypes.h"
15
16
  #include "include/gpu/graphite/GraphiteTypes.h"
16
- #include "include/gpu/graphite/Recorder.h"
17
+ #include "include/gpu/graphite/Recorder.h" // IWYU pragma: keep
17
18
  #include "include/private/base/SingleOwner.h"
19
+ #include "include/private/base/SkThreadAnnotations.h"
18
20
 
19
21
  #if defined(GPU_TEST_UTILS)
20
22
  #include "include/private/base/SkMutex.h"
21
23
  #endif
22
24
 
23
25
  #include <chrono>
26
+ #include <cstddef>
27
+ #include <cstdint>
24
28
  #include <functional>
25
29
  #include <memory>
30
+ #include <vector>
26
31
 
32
+ class SkColorInfo;
33
+ class SkSurface;
34
+ enum SkYUVColorSpace : int;
27
35
  class SkColorSpace;
28
- class SkRuntimeEffect;
29
36
  class SkTraceMemoryDump;
37
+ struct SkIRect;
38
+ struct SkImageInfo;
39
+
40
+ namespace skcpu {
41
+ class ContextImpl;
42
+ class Recorder;
43
+ } // namespace skcpu
44
+
45
+ namespace skgpu {
46
+ enum class BackendApi : unsigned int;
47
+ enum class GpuStatsFlags : uint32_t;
48
+ }
30
49
 
31
50
  namespace skgpu::graphite {
32
51
 
33
52
  class BackendTexture;
34
53
  class Buffer;
35
54
  class ClientMappedBufferManager;
36
- class Context;
37
55
  class ContextPriv;
38
- class GlobalCache;
39
- class PaintOptions;
56
+ struct ContextOptions;
40
57
  class PrecompileContext;
41
58
  class QueueManager;
42
- class Recording;
43
59
  class ResourceProvider;
44
60
  class SharedContext;
45
61
  class TextureProxy;
@@ -56,6 +72,7 @@ public:
56
72
  BackendApi backend() const;
57
73
 
58
74
  std::unique_ptr<Recorder> makeRecorder(const RecorderOptions& = {});
75
+ std::unique_ptr<skcpu::Recorder> makeCPURecorder();
59
76
 
60
77
  /** Creates a helper object that can be moved to a different thread and used
61
78
  * for precompilation.
@@ -291,6 +308,12 @@ private:
291
308
  friend class ContextCtorAccessor;
292
309
 
293
310
  struct PixelTransferResult {
311
+ PixelTransferResult();
312
+ PixelTransferResult(const PixelTransferResult&);
313
+ PixelTransferResult(PixelTransferResult&&);
314
+ PixelTransferResult& operator=(const PixelTransferResult&);
315
+ ~PixelTransferResult();
316
+
294
317
  using ConversionFn = void(void* dst, const void* mappedBuffer);
295
318
  // If null then the transfer could not be performed. Otherwise this buffer will contain
296
319
  // the pixel data when the transfer is complete.
@@ -357,6 +380,7 @@ private:
357
380
  std::unique_ptr<ResourceProvider> fResourceProvider;
358
381
  std::unique_ptr<QueueManager> fQueueManager;
359
382
  std::unique_ptr<ClientMappedBufferManager> fMappedBufferManager;
383
+ std::unique_ptr<const skcpu::ContextImpl> fCPUContext;
360
384
 
361
385
  // In debug builds we guard against improper thread handling. This guard is passed to the
362
386
  // ResourceCache for the Context.
@@ -9,6 +9,7 @@
9
9
  #define skgpu_graphite_ContextOptions_DEFINED
10
10
 
11
11
  #include "include/core/SkRefCnt.h"
12
+ #include "include/core/SkSize.h"
12
13
  #include "include/core/SkSpan.h"
13
14
  #include "include/private/base/SkAPI.h"
14
15
  #include "include/private/base/SkMath.h"
@@ -45,7 +46,16 @@ struct SK_API ContextOptions {
45
46
  *
46
47
  * If <= 1, Graphite will disable internal code paths that use multisampling.
47
48
  */
48
- int fInternalMultisampleCount = 4;
49
+ uint8_t fInternalMultisampleCount = 4;
50
+
51
+ /**
52
+ * If set, this specifies the max width/height of MSAA textures that Graphite should use for
53
+ * internal draws. Graphite might have to break the drawing region into multiple tiles to
54
+ * satisfy the size constraint.
55
+ * Note: this option will be ignored if the backend doesn't support it, or if a more optimal HW
56
+ * feature is available.
57
+ */
58
+ std::optional<SkISize> fInternalMSAATileSize = std::nullopt;
49
59
 
50
60
  /**
51
61
  * Will the client make sure to only ever be executing one thread that uses the Context and all
@@ -89,10 +99,18 @@ struct SK_API ContextOptions {
89
99
  bool fSupportBilerpFromGlyphAtlas = false;
90
100
 
91
101
  /**
92
- * For the moment, if Recordings are replayed in the order they are recorded, then
93
- * Graphite can make certain assumptions that allow for better performance. Otherwise
94
- * we have to flush some caches at the start of each Recording to ensure that they can
102
+ * For the moment, if Recordings from the same Recorder are replayed in the order they are
103
+ * recorded, then Graphite can make certain assumptions that allow for better performance.
104
+ * Otherwise we have to flush some caches at the start of each Recording to ensure that they can
95
105
  * be played back properly.
106
+ *
107
+ * This is the default ordering requirement for a Recorder. It can be overridden by
108
+ * setting the same field on the RecorderOptions passed to makeRecorder.
109
+ *
110
+ * Regardless of this value or a per-Recorder's setting, Recordings from separate Recorders can
111
+ * always be inserted in any order but it is the application's responsible to ensure that any
112
+ * implicit dependencies between the Recorders are respected (e.g. rendering to an SkSurface
113
+ * in one Recorder and sampling from that SkSurface's SkImage view on another Recorder).
96
114
  */
97
115
  bool fRequireOrderedRecordings = false;
98
116
 
@@ -168,7 +168,11 @@ enum DrawTypeFlags : uint16_t {
168
168
  // AnalyticRRectRenderStep
169
169
  // PerEdgeAAQuadRenderStep
170
170
  // CoverBoundsRenderStep[NonAAFill]
171
- kSimpleShape = 1 << 7,
171
+ kAnalyticRRect = 1 << 7,
172
+ kPerEdgeAAQuad = 1 << 8,
173
+ kNonAAFillRect = 1 << 9,
174
+
175
+ kSimpleShape = kAnalyticRRect | kPerEdgeAAQuad | kNonAAFillRect,
172
176
 
173
177
  // kNonSimpleShape should be used to generate Pipelines that use the following RenderSteps:
174
178
  // CoverageMaskRenderStep
@@ -177,9 +181,22 @@ enum DrawTypeFlags : uint16_t {
177
181
  // TessellateWedgesRenderStep[*] for [Convex], [EvenOdd], [Winding]
178
182
  // TessellateCurvesRenderStep[*] for [EvenOdd], [Winding]
179
183
  // MiddleOutFanRenderStep[*] for [EvenOdd], [Winding]
180
- kNonSimpleShape = 1 << 8,
181
-
182
- kLast = kNonSimpleShape,
184
+ kNonSimpleShape = 1 << 10,
185
+
186
+ // This draw type covers all the methods Skia uses to draw drop shadows. It can be used to
187
+ // generate Pipelines which, as part of their labels, have:
188
+ // the AnalyticBlurRenderStep
189
+ // VerticesRenderStep[TrisColor] with a GaussianColorFilter
190
+ // For this draw type the PaintOptions parameter to Precompile() will be ignored.
191
+ kDropShadows = 1 << 11,
192
+
193
+ // kAnalyticClip should be combined with the primary drawType for Pipelines that contain
194
+ // either of the following sub-strings:
195
+ // AnalyticClip
196
+ // AnalyticAndAtlasClip
197
+ kAnalyticClip = 1 << 12,
198
+
199
+ kLast = kAnalyticClip,
183
200
  };
184
201
 
185
202
  } // namespace skgpu::graphite
@@ -10,9 +10,11 @@
10
10
 
11
11
  #include "include/core/SkRefCnt.h"
12
12
  #include "include/private/base/SingleOwner.h"
13
+ #include "include/private/base/SkAPI.h"
13
14
 
14
15
  #include <chrono>
15
16
  #include <memory>
17
+ #include <string>
16
18
 
17
19
  class SkData;
18
20
 
@@ -34,10 +36,22 @@ public:
34
36
  */
35
37
  void purgePipelinesNotUsedInMs(std::chrono::milliseconds msNotUsed);
36
38
 
39
+ enum class StatOptions {
40
+ // Emit histograms (using the SK_HISTOGRAM* macros) for Skia's Precompiled Pipeline
41
+ // usage:
42
+ // Skia.Graphite.Precompile.NormalPreemptedByPrecompile
43
+ // Skia.Graphite.Precompile.UnpreemptedPrecompilePipelines
44
+ // Skia.Graphite.Precompile.UnusedPrecompiledPipelines
45
+ kPrecompile,
46
+ // Emit histograms (using the SK_HISTOGRAM* macros) for Skia's Pipeline cache usage:
47
+ // Skia.Graphite.PipelineCache.PipelineUsesInEpoch
48
+ kPipelineCache,
49
+ };
50
+
37
51
  /**
38
- * Emit histograms (using the SK_HISTOGRAM* macros) for Skia's Pipeline usage.
52
+ * Emit histograms histograms related to Skia's Pipelines (c.f. the StatOptions enum).
39
53
  */
40
- void reportPipelineStats();
54
+ void reportPipelineStats(StatOptions option = StatOptions::kPrecompile);
41
55
 
42
56
  /**
43
57
  * Precompile one specific Pipeline that has been previously serialized. Serialized pipeline
@@ -8,22 +8,33 @@
8
8
  #ifndef skgpu_graphite_Recorder_DEFINED
9
9
  #define skgpu_graphite_Recorder_DEFINED
10
10
 
11
+ #include "include/core/SkCPURecorder.h"
12
+ #include "include/core/SkRecorder.h"
11
13
  #include "include/core/SkRefCnt.h"
12
- #include "include/core/SkSize.h"
13
14
  #include "include/gpu/graphite/GraphiteTypes.h"
14
15
  #include "include/gpu/graphite/Recording.h"
15
16
  #include "include/private/base/SingleOwner.h"
17
+ #include "include/private/base/SkAPI.h"
16
18
  #include "include/private/base/SkTArray.h"
17
19
 
18
20
  #include <chrono>
21
+ #include <cstddef>
22
+ #include <cstdint>
23
+ #include <memory>
24
+ #include <optional>
19
25
 
20
- struct AHardwareBuffer;
21
26
  class SkCanvas;
22
- struct SkImageInfo;
23
27
  class SkPixmap;
24
28
  class SkTraceMemoryDump;
29
+ struct SkISize;
30
+ struct SkImageInfo;
31
+
32
+ #if defined(SK_BUILD_FOR_ANDROID)
33
+ struct AHardwareBuffer;
34
+ #endif
25
35
 
26
36
  namespace skgpu {
37
+ enum class BackendApi : unsigned int;
27
38
  class RefCntedCallback;
28
39
  class TokenTracker;
29
40
  }
@@ -37,26 +48,23 @@ namespace skgpu::graphite {
37
48
 
38
49
  class AtlasProvider;
39
50
  class BackendTexture;
40
- class Caps;
41
51
  class Context;
42
52
  class Device;
43
53
  class DrawBufferManager;
44
- class GlobalCache;
45
54
  class ImageProvider;
46
- class ProxyCache;
47
55
  class ProxyReadCountMap;
48
56
  class RecorderPriv;
49
57
  class ResourceProvider;
50
58
  class RuntimeEffectDictionary;
51
59
  class SharedContext;
52
- class Task;
53
60
  class TaskList;
54
61
  class TextureDataBlock;
55
62
  class TextureInfo;
56
- class UniformDataBlock;
57
63
  class UploadBufferManager;
58
64
  class UploadList;
59
65
 
66
+ struct RecorderOptionsPriv;
67
+
60
68
  template<typename T> class PipelineDataCache;
61
69
  using TextureDataCache = PipelineDataCache<TextureDataBlock>;
62
70
 
@@ -70,19 +78,29 @@ struct SK_API RecorderOptions final {
70
78
  static constexpr size_t kDefaultRecorderBudget = 256 * (1 << 20);
71
79
  // What is the budget for GPU resources allocated and held by this Recorder.
72
80
  size_t fGpuBudgetInBytes = kDefaultRecorderBudget;
81
+ // If Recordings are known to be played back in the order they are recorded, then Graphite
82
+ // may be able to make certain assumptions that improve performance. This is often the case
83
+ // if the content being drawn triggers the use of internal atlasing in Graphite (e.g. text).
84
+ std::optional<bool> fRequireOrderedRecordings;
85
+
86
+ // Private options that are only meant for testing within Skia's tools.
87
+ RecorderOptionsPriv* fRecorderOptionsPriv = nullptr;
73
88
  };
74
89
 
75
- class SK_API Recorder final {
90
+ class SK_API Recorder final : public SkRecorder {
76
91
  public:
77
92
  Recorder(const Recorder&) = delete;
78
93
  Recorder(Recorder&&) = delete;
79
94
  Recorder& operator=(const Recorder&) = delete;
80
95
  Recorder& operator=(Recorder&&) = delete;
81
96
 
82
- ~Recorder();
97
+ ~Recorder() override;
83
98
 
84
99
  BackendApi backend() const;
85
100
 
101
+ Type type() const override { return SkRecorder::Type::kGraphite; }
102
+ skcpu::Recorder* cpuRecorder() override;
103
+
86
104
  std::unique_ptr<Recording> snap();
87
105
 
88
106
  ImageProvider* clientImageProvider() { return fClientImageProvider.get(); }
@@ -281,6 +299,8 @@ private:
281
299
 
282
300
  uint32_t fUniqueID; // Needed for MessageBox handling for text
283
301
  uint32_t fNextRecordingID = 1;
302
+ const bool fRequireOrderedRecordings;
303
+
284
304
  std::unique_ptr<AtlasProvider> fAtlasProvider;
285
305
  std::unique_ptr<TokenTracker> fTokenTracker;
286
306
  std::unique_ptr<sktext::gpu::StrikeCache> fStrikeCache;
@@ -9,13 +9,16 @@
9
9
  #define skgpu_graphite_Recording_DEFINED
10
10
 
11
11
  #include "include/core/SkRefCnt.h"
12
- #include "include/core/SkSize.h"
12
+ #include "include/private/base/SkAPI.h"
13
13
  #include "include/private/base/SkTArray.h"
14
-
14
+ #include <cstddef>
15
+ #include <cstdint>
15
16
  #include <memory>
16
17
  #include <unordered_set>
17
18
  #include <vector>
18
19
 
20
+ struct SkISize;
21
+
19
22
  namespace skgpu {
20
23
  class RefCntedCallback;
21
24
  }
@@ -47,6 +50,7 @@ private:
47
50
  class LazyProxyData {
48
51
  public:
49
52
  LazyProxyData(const Caps*, SkISize dimensions, const TextureInfo&);
53
+ ~LazyProxyData();
50
54
 
51
55
  TextureProxy* lazyProxy();
52
56
  sk_sp<TextureProxy> refLazyProxy();
@@ -72,7 +76,7 @@ private:
72
76
  bool addCommands(CommandBuffer*, ResourceProvider*);
73
77
  void addResourceRef(sk_sp<Resource>);
74
78
 
75
- // Used to verify ordering
79
+ // Used to verify ordering if recorder ID is not SK_InvalidGenID
76
80
  uint32_t fUniqueID;
77
81
  uint32_t fRecorderID;
78
82
 
@@ -49,7 +49,7 @@ private:
49
49
  public:
50
50
  virtual ~Data() = default;
51
51
 
52
- Data(uint32_t sampleCount, skgpu::Mipmapped mipmapped)
52
+ Data(uint8_t sampleCount, skgpu::Mipmapped mipmapped)
53
53
  : fSampleCount(sampleCount)
54
54
  , fMipmapped(mipmapped) {}
55
55
 
@@ -59,7 +59,7 @@ private:
59
59
  Data& operator=(const Data&) = default;
60
60
 
61
61
  // NOTE: These fields are accessible via the backend-specific subclasses.
62
- uint32_t fSampleCount = 1;
62
+ uint8_t fSampleCount = 1;
63
63
  Mipmapped fMipmapped = Mipmapped::kNo;
64
64
 
65
65
  private:
@@ -92,7 +92,7 @@ public:
92
92
  return fBackend;
93
93
  }
94
94
 
95
- uint32_t numSamples() const { return fData.has_value() ? fData->fSampleCount : 1; }
95
+ uint8_t numSamples() const { return fData.has_value() ? fData->fSampleCount : 1; }
96
96
  Mipmapped mipmapped() const { return fData.has_value() ? fData->fMipmapped : Mipmapped::kNo; }
97
97
  Protected isProtected() const { return fProtected; }
98
98
 
@@ -27,6 +27,7 @@ class PrecompileShader;
27
27
  enum class Coverage;
28
28
  enum DrawTypeFlags : uint16_t;
29
29
  enum class PrecompileImageFilterFlags : uint32_t;
30
+ enum class TextureFormat : uint8_t;
30
31
 
31
32
  class KeyContext;
32
33
  class PaintOptionsPriv;
@@ -139,6 +140,11 @@ public:
139
140
  void setDither(bool dither) { fDither = dither; }
140
141
  bool isDither() const { return fDither; }
141
142
 
143
+ void setPaintColorIsOpaque(bool paintColorIsOpaque) {
144
+ fPaintColorIsOpaque = paintColorIsOpaque;
145
+ }
146
+ bool isPaintColorOpaque() const { return fPaintColorIsOpaque; }
147
+
142
148
  // Provides access to functions that aren't part of the public API.
143
149
  PaintOptionsPriv priv();
144
150
  const PaintOptionsPriv priv() const; // NOLINT(readability-const-return-type)
@@ -155,6 +161,10 @@ private:
155
161
 
156
162
  void setClipShaders(SkSpan<const sk_sp<PrecompileShader>> clipShaders);
157
163
 
164
+ // In the main API this is specified via the SkBlender parameter to drawVertices
165
+ void setPrimitiveBlendMode(SkBlendMode bm) { fPrimitiveBlendMode = bm; }
166
+ void setSkipColorXform(bool skipColorXform) { fSkipColorXform = skipColorXform; }
167
+
158
168
  int numShaderCombinations() const;
159
169
  int numColorFilterCombinations() const;
160
170
  int numBlendCombinations() const;
@@ -163,10 +173,12 @@ private:
163
173
  int numCombinations() const;
164
174
  // 'desiredCombination' must be less than the result of the numCombinations call
165
175
  void createKey(const KeyContext&,
176
+ TextureFormat,
166
177
  PaintParamsKeyBuilder*,
167
178
  PipelineDataGatherer*,
168
179
  int desiredCombination,
169
180
  bool addPrimitiveBlender,
181
+ bool addAnalyticClip,
170
182
  Coverage coverage) const;
171
183
 
172
184
  typedef std::function<void(UniquePaintParamsID id,
@@ -192,7 +204,10 @@ private:
192
204
  skia_private::TArray<sk_sp<PrecompileImageFilter>> fImageFilterOptions;
193
205
  skia_private::TArray<sk_sp<PrecompileMaskFilter>> fMaskFilterOptions;
194
206
 
207
+ SkBlendMode fPrimitiveBlendMode = SkBlendMode::kSrcOver;
208
+ bool fSkipColorXform = false;
195
209
  bool fDither = false;
210
+ bool fPaintColorIsOpaque = true;
196
211
  };
197
212
 
198
213
  } // namespace skgpu::graphite
@@ -106,37 +106,113 @@ namespace PrecompileShaders {
106
106
  SkSpan<const sk_sp<PrecompileShader>> srcs);
107
107
  SK_API sk_sp<PrecompileShader> CoordClamp(SkSpan<const sk_sp<PrecompileShader>>);
108
108
 
109
- // In the main Skia API ImageShaders are usually created via a SkImage::makeShader call.
110
- // Since the SkImage used to create the ImageShader is unlikely to be present at precompilation
111
- // time this entry point allows the equivalent precompilation program structure to be created.
112
- // Note that this factory is for non-YUV SkImages, the YUVImage factory (below) should be used
113
- // to represent the shading and sampling required for YUV images.
114
- SK_API sk_sp<PrecompileShader> Image(SkSpan<const SkColorInfo> = {},
115
- SkSpan<const SkTileMode> = {});
109
+ enum class ImageShaderFlags : uint16_t {
110
+ kNone = 0,
111
+
112
+ kCubicSampling = 1 << 1,
113
+ kIncludeAlphaOnly = 1 << 2,
114
+
115
+ kAll = kCubicSampling | kIncludeAlphaOnly,
116
+ kExcludeCubic = kIncludeAlphaOnly,
117
+ kNoAlphaNoCubic = kNone,
118
+ };
119
+
120
+ static constexpr SkTileMode kAllTileModes[] = {
121
+ SkTileMode::kClamp,
122
+ SkTileMode::kRepeat,
123
+ SkTileMode::kMirror,
124
+ SkTileMode::kDecal,
125
+ };
126
+
127
+ /**
128
+ In the main Skia API ImageShaders are usually created via a SkImage::makeShader call.
129
+ Since the SkImage used to create the ImageShader is unlikely to be present at precompilation
130
+ time this entry point allows the equivalent precompilation program structure to be created.
131
+ Note that this factory is for non-YUV SkImages, the YUVImage factory (below) should be used
132
+ to represent the shading and sampling required for YUV images.
133
+
134
+ @param shaderFlags Specify the sampling variations that will be precompiled.
135
+ @param colorInfos a span of SkColorInfos to narrow down the combinations.
136
+ In general, the color info affects the swizzle and colorSpace
137
+ transformation of the final Pipeline.
138
+ @param tileModes a span of SkTileModes to narrow down the combinations.
139
+ The default will generate all possible combinations. Passing an
140
+ empty SkSpan will eliminate the Shader-based sampling combinations.
141
+ @return A precompile shader capturing the specified combinations
142
+ */
143
+ SK_API sk_sp<PrecompileShader> Image(ImageShaderFlags = ImageShaderFlags::kAll,
144
+ SkSpan<const SkColorInfo> = {},
145
+ SkSpan<const SkTileMode> = { kAllTileModes });
146
+
147
+ /** DEPRECATED
148
+ * Use above version.
149
+ */
150
+ SK_API sk_sp<PrecompileShader> Image(SkSpan<const SkColorInfo> colorInfos,
151
+ SkSpan<const SkTileMode> = { kAllTileModes });
152
+
116
153
  // As with the above Image call, raw ImageShaders are usually created via an
117
154
  // SkImage::makeRawShader call. The RawImage call allows the equivalent precompilation
118
155
  // program structure to be created without needing the SkImage.
119
- SK_API sk_sp<PrecompileShader> RawImage(SkSpan<const SkColorInfo> = {},
120
- SkSpan<const SkTileMode> = {});
156
+ SK_API sk_sp<PrecompileShader> RawImage(ImageShaderFlags = ImageShaderFlags::kExcludeCubic,
157
+ SkSpan<const SkColorInfo> = {},
158
+ SkSpan<const SkTileMode> = { kAllTileModes });
121
159
 
122
- // In the main Skia API, the specifics of the SkImage used for the SkImage::makeShader call
123
- // can determine whether normal or YUV sampling is required. This entry point allows clients
124
- // to specify that the future image will be a YUV image.
125
- SK_API sk_sp<PrecompileShader> YUVImage();
160
+ enum class YUVImageShaderFlags : uint16_t {
161
+ kNone = 0,
162
+
163
+ kHardwareSamplingNoSwizzle = 1 << 1,
164
+ kHardwareSampling = 1 << 2,
165
+ kShaderBasedSampling = 1 << 3,
166
+ kCubicSampling = 1 << 4,
167
+
168
+ kExcludeCubic = kHardwareSamplingNoSwizzle | kHardwareSampling | kShaderBasedSampling,
169
+ kNoCubicNoNonSwizzledHW = kHardwareSamplingNoSwizzle | kShaderBasedSampling,
170
+ };
171
+
172
+ /**
173
+ In the main Skia API, the specifics of the SkImage used for the SkImage::makeShader call
174
+ can determine whether normal or YUV sampling is required. This entry point allows clients
175
+ to specify that the future image will be a YUV image.
176
+
177
+ @param shaderFlags Specify the sampling variations that will be precompiled.
178
+ In practice, YUV images are rarely cubic-sampling.
179
+ @param colorInfos a span of SkColorInfos to narrow down the combinations.
180
+ In general, the color info affects the swizzle and colorSpace
181
+ transformation of the final Pipeline.
182
+ @return A precompile shader capturing the specified combinations
183
+ */
184
+ SK_API sk_sp<PrecompileShader> YUVImage(
185
+ YUVImageShaderFlags = YUVImageShaderFlags::kExcludeCubic,
186
+ SkSpan<const SkColorInfo> = {});
126
187
 
127
188
  // --- This block of two matches the SkShaders factories in SkPerlinNoiseShader.h
128
189
  // Again, most of the details have been elided.
129
190
  SK_API sk_sp<PrecompileShader> MakeFractalNoise();
130
191
  SK_API sk_sp<PrecompileShader> MakeTurbulence();
131
192
 
193
+ enum class GradientShaderFlags : uint16_t {
194
+ kNone = 0,
195
+
196
+ kSmall = 1 << 1,
197
+ kMedium = 1 << 2,
198
+ kLarge = 1 << 3,
199
+
200
+ kAll = kSmall | kMedium | kLarge,
201
+ kNoLarge = kSmall | kMedium,
202
+ };
203
+
132
204
  // --- This block of four matches all the factories in SkGradientShader (SkGradientShader.h)
133
205
  SK_API sk_sp<PrecompileShader> LinearGradient(
206
+ GradientShaderFlags = GradientShaderFlags::kAll,
134
207
  SkGradientShader::Interpolation = SkGradientShader::Interpolation());
135
208
  SK_API sk_sp<PrecompileShader> RadialGradient(
209
+ GradientShaderFlags = GradientShaderFlags::kAll,
136
210
  SkGradientShader::Interpolation = SkGradientShader::Interpolation());
137
211
  SK_API sk_sp<PrecompileShader> TwoPointConicalGradient(
212
+ GradientShaderFlags = GradientShaderFlags::kAll,
138
213
  SkGradientShader::Interpolation = SkGradientShader::Interpolation());
139
214
  SK_API sk_sp<PrecompileShader> SweepGradient(
215
+ GradientShaderFlags = GradientShaderFlags::kAll,
140
216
  SkGradientShader::Interpolation = SkGradientShader::Interpolation());
141
217
 
142
218
  // Normally, SkPicture shaders are only created via SkPicture::makeShader. Since the
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright 2025 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 skgpu_graphite_vk_precompile_PrecompileShader_DEFINED
9
+ #define skgpu_graphite_vk_precompile_PrecompileShader_DEFINED
10
+
11
+ #include "include/gpu/graphite/precompile/PrecompileShader.h"
12
+
13
+ namespace skgpu {
14
+ struct VulkanYcbcrConversionInfo;
15
+ }
16
+
17
+ namespace skgpu::graphite {
18
+
19
+ namespace PrecompileShaders {
20
+
21
+ /**
22
+ In the main Skia API YCbCr Images are usually created by wrapping a BackendTexture.
23
+ Such backend textures are, in turn, created by a backend-specific entry point like:
24
+ BackendTextures::MakeVulkan(SkISize, const VulkanTextureInfo&, ...)
25
+ where the VulkanTextureInfo contains additional YCbCr information. This API cuts right to
26
+ providing the backend-specific YCbCr information (i.e., the VulkanYcbcrConversionInfo).
27
+
28
+ @return A precompile shader for a specific type of YCbCr image
29
+ */
30
+ SK_API sk_sp<PrecompileShader> VulkanYCbCrImage(skgpu::VulkanYcbcrConversionInfo& YCbCrInfo,
31
+ ImageShaderFlags = ImageShaderFlags::kAll,
32
+ SkSpan<const SkColorInfo> = {},
33
+ SkSpan<const SkTileMode> = { kAllTileModes });
34
+
35
+ } // namespace PrecompileShaders
36
+
37
+ } // namespace skgpu::graphite
38
+
39
+ #endif // skgpu_graphite_vk_precompile_PrecompileShader_DEFINED
@@ -29,7 +29,7 @@ struct SK_API VulkanBackendContext {
29
29
  VkQueue fQueue = VK_NULL_HANDLE;
30
30
  uint32_t fGraphicsQueueIndex = 0;
31
31
  // The max api version set here should match the value set in VkApplicationInfo::apiVersion when
32
- // then VkInstance was created.
32
+ // then VkInstance was created. Skia requires Vulkan 1.1 as the minimum version.
33
33
  uint32_t fMaxAPIVersion = 0;
34
34
  const skgpu::VulkanExtensions* fVkExtensions = nullptr;
35
35
  // The client can create their VkDevice with either a VkPhysicalDeviceFeatures or