@shopify/react-native-skia 2.6.0 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/android/CMakeLists.txt +0 -1
  2. package/android/cpp/jni/JniWebGPUView.cpp +3 -3
  3. package/android/cpp/rnskia-android/OpenGLContext.h +4 -5
  4. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +1 -1
  5. package/apple/MetalContext.h +5 -6
  6. package/apple/MetalWindowContext.mm +3 -4
  7. package/apple/RNSkApplePlatformContext.h +1 -1
  8. package/apple/RNSkApplePlatformContext.mm +4 -3
  9. package/apple/SkiaCVPixelBufferUtils.h +1 -1
  10. package/apple/SkiaCVPixelBufferUtils.mm +31 -30
  11. package/apple/SkiaPlatformContext.mm +2 -2
  12. package/apple/SkiaUIView.mm +1 -1
  13. package/apple/SkiaWebGPUView.mm +8 -4
  14. package/apple/WebGPUMetalView.h +1 -1
  15. package/apple/WebGPUMetalView.mm +1 -1
  16. package/cpp/api/JsiSkColor.h +8 -4
  17. package/cpp/api/JsiSkContourMeasure.h +4 -3
  18. package/cpp/api/JsiSkImage.h +17 -9
  19. package/cpp/api/JsiSkParagraphBuilder.h +14 -1
  20. package/cpp/api/JsiSkPath.h +71 -81
  21. package/cpp/api/JsiSkPathEffectFactory.h +2 -1
  22. package/cpp/api/JsiSkPathFactory.h +48 -52
  23. package/cpp/api/JsiSkShader.h +1 -1
  24. package/cpp/api/JsiSkShaderFactory.h +50 -26
  25. package/cpp/api/JsiSkSurfaceFactory.h +2 -1
  26. package/cpp/api/recorder/Drawings.h +5 -7
  27. package/cpp/api/recorder/Shaders.h +77 -22
  28. package/cpp/jsi2/JSIConverter.h +1 -1
  29. package/cpp/rnskia/RNDawnContext.h +14 -15
  30. package/cpp/rnskia/RNDawnUtils.h +14 -17
  31. package/cpp/rnskia/RNDawnWindowContext.h +1 -1
  32. package/cpp/rnskia/RNSkManager.cpp +5 -4
  33. package/cpp/rnskia/RNSkPlatformContext.h +2 -2
  34. package/cpp/rnwgpu/api/GPU.cpp +21 -0
  35. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +1 -1
  36. package/cpp/rnwgpu/api/GPUCanvasContext.h +2 -2
  37. package/cpp/rnwgpu/api/GPUFeatures.h +0 -9
  38. package/cpp/rnwgpu/api/GPUTexture.h +14 -2
  39. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +3 -4
  40. package/cpp/rnwgpu/api/RNWebGPU.h +1 -1
  41. package/cpp/rnwgpu/api/descriptors/Unions.h +0 -15
  42. package/cpp/skia/include/android/SkImageAndroid.h +7 -2
  43. package/cpp/skia/include/android/vk/AndroidVulkanMemoryAllocator.h +31 -0
  44. package/cpp/skia/include/codec/SkCodec.h +42 -15
  45. package/cpp/skia/include/config/SkUserConfig.h +8 -0
  46. package/cpp/skia/include/core/SkBitmap.h +0 -5
  47. package/cpp/skia/include/core/SkCanvas.h +2 -39
  48. package/cpp/skia/include/core/SkColor.h +12 -0
  49. package/cpp/skia/include/core/SkColorSpace.h +9 -0
  50. package/cpp/skia/include/core/SkContourMeasure.h +1 -5
  51. package/cpp/skia/include/core/SkData.h +8 -0
  52. package/cpp/skia/include/core/SkFont.h +1 -55
  53. package/cpp/skia/include/core/SkFontArguments.h +15 -0
  54. package/cpp/skia/include/core/SkGraphics.h +0 -5
  55. package/cpp/skia/include/core/SkImage.h +0 -4
  56. package/cpp/skia/include/core/SkImageGenerator.h +1 -4
  57. package/cpp/skia/include/core/SkMatrix.h +0 -37
  58. package/cpp/skia/include/core/SkMilestone.h +1 -1
  59. package/cpp/skia/include/core/SkPath.h +11 -911
  60. package/cpp/skia/include/core/SkPathBuilder.h +42 -32
  61. package/cpp/skia/include/core/SkPathEffect.h +0 -9
  62. package/cpp/skia/include/core/SkPathMeasure.h +1 -4
  63. package/cpp/skia/include/core/SkPathUtils.h +0 -10
  64. package/cpp/skia/include/core/SkRect.h +0 -12
  65. package/cpp/skia/include/core/SkRegion.h +1 -6
  66. package/cpp/skia/include/core/SkSerialProcs.h +4 -5
  67. package/cpp/skia/include/core/SkSurfaceProps.h +6 -0
  68. package/cpp/skia/include/core/SkTextBlob.h +0 -22
  69. package/cpp/skia/include/core/SkTypeface.h +14 -32
  70. package/cpp/skia/include/core/SkTypes.h +0 -8
  71. package/cpp/skia/include/docs/SkPDFDocument.h +19 -17
  72. package/cpp/skia/include/effects/SkDashPathEffect.h +0 -6
  73. package/cpp/skia/include/effects/SkGradient.h +206 -0
  74. package/cpp/skia/include/effects/SkHighContrastFilter.h +2 -2
  75. package/cpp/skia/include/gpu/GpuTypes.h +2 -0
  76. package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +5 -35
  77. package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +7 -106
  78. package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +0 -11
  79. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +0 -9
  80. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSemaphore.h +20 -0
  81. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSurface.h +59 -0
  82. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +28 -0
  83. package/cpp/skia/include/gpu/ganesh/gl/GrGLFunctions.h +4 -1
  84. package/cpp/skia/include/gpu/graphite/ContextOptions.h +4 -20
  85. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +32 -46
  86. package/cpp/skia/include/gpu/graphite/Recorder.h +1 -1
  87. package/cpp/skia/include/gpu/graphite/Surface.h +31 -0
  88. package/cpp/skia/include/gpu/graphite/TextureInfo.h +3 -10
  89. package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +3 -3
  90. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -1
  91. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +6 -6
  92. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +5 -3
  93. package/cpp/skia/include/gpu/graphite/vk/precompile/VulkanPrecompileShader.h +1 -1
  94. package/cpp/skia/include/gpu/vk/VulkanBackendContext.h +1 -1
  95. package/cpp/skia/include/gpu/vk/VulkanPreferredFeatures.h +8 -0
  96. package/cpp/skia/include/private/SkEncodedInfo.h +43 -105
  97. package/cpp/skia/include/private/SkHdrMetadata.h +165 -2
  98. package/cpp/skia/include/private/SkPathRef.h +0 -457
  99. package/cpp/skia/include/private/base/SkFeatures.h +4 -0
  100. package/cpp/skia/include/private/base/SkFloatingPoint.h +1 -2
  101. package/cpp/skia/include/private/base/SkLoadUserConfig.h +2 -1
  102. package/cpp/skia/include/private/base/SkLog.h +68 -0
  103. package/cpp/skia/include/private/base/SkLogPriority.h +35 -0
  104. package/cpp/skia/include/private/base/SkMacros.h +9 -0
  105. package/cpp/skia/include/private/base/SkTArray.h +1 -1
  106. package/cpp/skia/include/private/gpu/ganesh/GrD3DTypesMinimal.h +10 -24
  107. package/cpp/skia/include/utils/SkEventTracer.h +5 -7
  108. package/cpp/skia/modules/skottie/include/TextShaper.h +0 -7
  109. package/cpp/skia/modules/skparagraph/include/FontCollection.h +6 -20
  110. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +0 -6
  111. package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +4 -19
  112. package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +2 -3
  113. package/cpp/skia/modules/skunicode/include/SkUnicode_icu.h +18 -0
  114. package/cpp/skia/modules/skunicode/include/SkUnicode_libgrapheme.h +19 -0
  115. package/cpp/skia/src/base/SkMathPriv.h +27 -132
  116. package/package.json +5 -5
  117. package/cpp/skia/include/effects/SkGradientShader.h +0 -359
  118. package/cpp/skia/include/gpu/graphite/LogPriority.h +0 -36
@@ -11,6 +11,7 @@
11
11
  #include "include/core/SkRefCnt.h"
12
12
  #include "include/core/SkSize.h"
13
13
  #include "include/core/SkSpan.h"
14
+ #include "include/gpu/graphite/GraphiteTypes.h"
14
15
  #include "include/private/base/SkAPI.h"
15
16
  #include "include/private/base/SkMath.h"
16
17
 
@@ -45,11 +46,12 @@ struct SK_API ContextOptions {
45
46
 
46
47
  /**
47
48
  * Specifies the number of samples Graphite should use when performing internal draws with MSAA
48
- * (hardware capabilities permitting).
49
+ * (hardware capabilities permitting). This represents the maximum that will be used; if a
50
+ * a specific format supports only lower values, those may be used instead.
49
51
  *
50
52
  * If <= 1, Graphite will disable internal code paths that use multisampling.
51
53
  */
52
- uint8_t fInternalMultisampleCount = 4;
54
+ SampleCount fInternalMultisampleCount = SampleCount::k4;
53
55
 
54
56
  /**
55
57
  * If set, this specifies the max width/height of MSAA textures that Graphite should use for
@@ -68,13 +70,6 @@ struct SK_API ContextOptions {
68
70
  */
69
71
  float fMinimumPathSizeForMSAA = 0;
70
72
 
71
- /**
72
- * Will the client make sure to only ever be executing one thread that uses the Context and all
73
- * derived classes (e.g. Recorders, Recordings, etc.) at a time. If so we can possibly make some
74
- * objects (e.g. VulkanMemoryAllocator) not thread safe to improve single thread performance.
75
- */
76
- bool fClientWillExternallySynchronizeAllThreads = false;
77
-
78
73
  /**
79
74
  * The maximum size of cache textures used for Skia's Glyph cache.
80
75
  */
@@ -140,17 +135,6 @@ struct SK_API ContextOptions {
140
135
  bool fSetBackendLabels = false;
141
136
  #endif
142
137
 
143
- /**
144
- * If Skia is creating a default VMA allocator for the Vulkan backend this value will be used
145
- * for the preferredLargeHeapBlockSize. If the value is not set, then Skia will use an
146
- * internally defined default size.
147
- *
148
- * However, it is highly discouraged to have Skia make a default allocator (and support for
149
- * doing so will be removed soon, b/321962001). Instead clients should create their own
150
- * allocator to pass into Skia where they can fine tune this value themeselves.
151
- */
152
- std::optional<uint64_t> fVulkanVMALargeHeapBlockSize;
153
-
154
138
  /**
155
139
  * Client-provided context that is passed to the client-provided PipelineCachingCallback
156
140
  * and the (deprecated) PipelineCallback.
@@ -14,6 +14,7 @@
14
14
  #include "include/gpu/GpuTypes.h"
15
15
 
16
16
  #include <memory>
17
+ #include <string>
17
18
 
18
19
  class SkSurface;
19
20
 
@@ -52,16 +53,24 @@ public:
52
53
  kAddCommandsFailed,
53
54
  // Internal failure, shader pipeline compilation failed (driver issue, or disk corruption),
54
55
  // state unrecoverable.
55
- kAsyncShaderCompilesFailed
56
+ kAsyncShaderCompilesFailed,
57
+ // The inserted Recording is out of order from what the Context expects (when
58
+ // `[Context|Recorder]Options::fRequireOrderedRecordings` is true), which can either
59
+ // represent a client synchronization error or an internal failure when a prior dependent
60
+ // Recording failed for some reason, no CB changes but state likely unrecoverable.
61
+ kOutOfOrderRecording,
56
62
  };
57
63
 
58
- constexpr InsertStatus() : fValue(kSuccess) {}
59
- /*implicit*/ constexpr InsertStatus(V v) : fValue(v) {}
64
+ InsertStatus() : fValue(kSuccess) {}
65
+ /*implicit*/ InsertStatus(V v) : fValue(v) {}
66
+ InsertStatus(V v, std::string message) : fValue(v), fMessage(std::move(message)) {}
60
67
 
61
68
  operator InsertStatus::V() const {
62
69
  return fValue;
63
70
  }
64
71
 
72
+ const std::string& message() const { return fMessage; }
73
+
65
74
  // Assist migration from old bool return value of insertRecording; kSuccess is true,
66
75
  // all other error statuses are false.
67
76
  // NOTE: This is intentionally not explicit so that InsertStatus can be assigned correctly to
@@ -73,6 +82,7 @@ public:
73
82
 
74
83
  private:
75
84
  V fValue;
85
+ std::string fMessage;
76
86
  };
77
87
 
78
88
  /**
@@ -148,7 +158,7 @@ struct InsertRecordingInfo {
148
158
  * and the caller can use the callback to know it is safe to free any resources associated with
149
159
  * the Recording that they may be holding onto. If the Recording is successfully submitted to the
150
160
  * GPU the callback will be called with CallbackResult::kSuccess once the GPU has finished. All
151
- * other cases where some failure occured it will be called with CallbackResult::kFailed.
161
+ * other cases where some failure occurred it will be called with CallbackResult::kFailed.
152
162
  */
153
163
  struct InsertFinishInfo {
154
164
  InsertFinishInfo() = default;
@@ -209,50 +219,26 @@ enum class DepthStencilFlags : int {
209
219
  kDepthStencil = kDepth | kStencil,
210
220
  };
211
221
 
212
- // NOTE: This can be converted to just an `enum class SampleCount {}` once clients are migrated
213
- // off of writing integer values into backend TextureInfo fields or ContextOptions.
214
- class SampleCount {
215
- public:
216
- // Do not refer to V directly; use these constants as if SampleCount were a class enum, e.g.
217
- // SampleCount::k4.
218
- enum V : uint8_t {
219
- k1 = 1,
220
- k2 = 2,
221
- k4 = 4,
222
- k8 = 8,
223
- k16 = 16
224
- };
225
-
226
- constexpr SampleCount() : fValue(k1) {}
227
- /*implicit*/ constexpr SampleCount(V v) : fValue(v) {}
228
-
229
- // Behave like an enum
230
- constexpr bool operator ==(const SampleCount& o) const { return fValue == o.fValue; }
231
- constexpr bool operator <(const SampleCount& o) const { return fValue < o.fValue; }
232
- constexpr bool operator <=(const SampleCount& o) const { return fValue <= o.fValue; }
233
- constexpr bool operator >(const SampleCount& o) const { return fValue > o.fValue; }
234
- constexpr bool operator >=(const SampleCount& o) const { return fValue >= o.fValue; }
235
-
236
- // This needs to be explicit so that ternaries that return constants mixed with variables aren't
237
- // ambiguous; internal code can cast for switch statements.
238
- explicit constexpr operator SampleCount::V() const { return fValue; }
239
- explicit constexpr operator uint8_t() const { return (uint8_t) fValue; }
240
- explicit constexpr operator unsigned int() const { return (unsigned int) fValue; }
241
-
242
- // Assist migration from old code that would assign integers to sample count fields that used
243
- // to be uint8_t and are now more strictly typed to SampleCount. Asserts if the value doesn't
244
- // match a SampleCount value.
245
- /*implicit*/ constexpr SampleCount(uint8_t v) : fValue((V) v) {
246
- SkASSERT(v == 1 || v == 2 || v == 4 || v == 8 || v == 16);
247
- }
248
- constexpr SampleCount& operator=(uint8_t sampleCount) {
249
- return (*this = SampleCount(sampleCount));
250
- }
251
-
252
- private:
253
- V fValue;
222
+ enum class SampleCount : uint8_t {
223
+ k1 = 1,
224
+ k2 = 2,
225
+ k4 = 4,
226
+ k8 = 8,
227
+ k16 = 16
254
228
  };
255
229
 
230
+ /**
231
+ * Convert an integer value to a strictly typed SampleCount value, rounding down to the lowest
232
+ * valid sample count if needed if `sampleCount` is not already equivalent.
233
+ */
234
+ constexpr SampleCount ToSampleCount(uint32_t sampleCount) {
235
+ return sampleCount >= 16 ? SampleCount::k16 :
236
+ sampleCount >= 8 ? SampleCount::k8 :
237
+ sampleCount >= 4 ? SampleCount::k4 :
238
+ sampleCount >= 2 ? SampleCount::k2 :
239
+ SampleCount::k1;
240
+ }
241
+
256
242
  /*
257
243
  * This enum allows mapping from a set of observed RenderSteps (e.g., from a GraphicsPipeline
258
244
  * printout) to the correct 'drawTypes' parameter needed by the Precompilation API.
@@ -291,7 +291,7 @@ private:
291
291
 
292
292
  // NOTE: These are stored by pointer to allow them to be forward declared.
293
293
  std::unique_ptr<TaskList> fRootTaskList;
294
- // Aggregated one-time uploads that preceed all tasks in the root task list.
294
+ // Aggregated one-time uploads that precede all tasks in the root task list.
295
295
  std::unique_ptr<UploadList> fRootUploads;
296
296
 
297
297
  std::unique_ptr<DrawBufferManager> fDrawBufferManager;
@@ -76,6 +76,8 @@ SK_API sk_sp<SkSurface> RenderTarget(skgpu::graphite::Recorder*,
76
76
  * configuration, then the recorder must support sRGB, and colorSpace must be present. Further,
77
77
  * backendTexture's width and height must not exceed the recorder's capabilities, and the
78
78
  * recorder must be able to support the back-end texture.
79
+ *
80
+ * DEPRECATED: Use WrapBackendTexture that does not take a `colorType`.
79
81
  */
80
82
  SK_API sk_sp<SkSurface> WrapBackendTexture(skgpu::graphite::Recorder*,
81
83
  const skgpu::graphite::BackendTexture&,
@@ -85,6 +87,35 @@ SK_API sk_sp<SkSurface> WrapBackendTexture(skgpu::graphite::Recorder*,
85
87
  TextureReleaseProc = nullptr,
86
88
  ReleaseContext = nullptr,
87
89
  std::string_view label = {});
90
+ /**
91
+ * Wraps a GPU-backed texture in an SkSurface. Depending on the backend gpu API, the caller may
92
+ * be required to ensure the texture is valid for the lifetime of the returned SkSurface. The
93
+ * required lifetimes for the specific apis are:
94
+ * Metal: Skia will call retain on the underlying MTLTexture so the caller can drop it once
95
+ * this call returns.
96
+ *
97
+ * SkSurface is returned if all the parameters are valid. The backendTexture is valid if its
98
+ * format and dimensions are supported by the context that created the recorder. The color type
99
+ * reported by the SkSurface's image info is inferred from backend texture's format, matching as
100
+ * closely as possible when a texture format is not representable exactly as an SkColorType. This
101
+ * is fine as the SkColorType represents the data layout were the texture to be read to CPU memory.
102
+ *
103
+ * For single-channel texture formats, the alpha-only SkColorType is selected as that is more
104
+ * consistently defined for data types. The implication of this is that the alpha channel output
105
+ * from fragment shading will be what's stored in the texture, regardless of whether its format was
106
+ * A or R.
107
+ *
108
+ * For other formats and color types, the ambiguities between BGR and RGB channel order are
109
+ * irrelevant for rendering and sampling on the GPU. Those swizzles can reliably be handled by the
110
+ * hardware and there's no semantic change for the related SkColorTypes.
111
+ */
112
+ SK_API sk_sp<SkSurface> WrapBackendTexture(skgpu::graphite::Recorder*,
113
+ const skgpu::graphite::BackendTexture&,
114
+ sk_sp<SkColorSpace> colorSpace,
115
+ const SkSurfaceProps* props,
116
+ TextureReleaseProc = nullptr,
117
+ ReleaseContext = nullptr,
118
+ std::string_view label = {});
88
119
  } // namespace SkSurfaces
89
120
 
90
121
  #endif // skgpu_graphite_Surface_DEFINED
@@ -46,7 +46,7 @@ private:
46
46
  public:
47
47
  virtual ~Data() = default;
48
48
 
49
- Data(uint8_t sampleCount, skgpu::Mipmapped mipmapped)
49
+ Data(SampleCount sampleCount, skgpu::Mipmapped mipmapped)
50
50
  : fSampleCount(sampleCount)
51
51
  , fMipmapped(mipmapped) {}
52
52
 
@@ -56,11 +56,7 @@ private:
56
56
  Data& operator=(const Data&) = default;
57
57
 
58
58
  // NOTE: These fields are accessible via the backend-specific subclasses.
59
-
60
- // Must be a valid SampleCount value, or TextureInfo creation will fail to wrap the backend
61
- // specific data. This is not strongly typed so that it can be assigned directly from the
62
- // backend GPU API's representation, which is often just an integer.
63
- uint8_t fSampleCount = 1;
59
+ SampleCount fSampleCount = SampleCount::k1;
64
60
  Mipmapped fMipmapped = Mipmapped::kNo;
65
61
 
66
62
  private:
@@ -95,7 +91,7 @@ public:
95
91
 
96
92
  Protected isProtected() const { return fProtected; }
97
93
  SampleCount sampleCount() const {
98
- return fData.has_value() ? static_cast<SampleCount>(fData->fSampleCount) : SampleCount::k1;
94
+ return fData.has_value() ? fData->fSampleCount : SampleCount::k1;
99
95
  }
100
96
  Mipmapped mipmapped() const {
101
97
  return fData.has_value() ? fData->fMipmapped : Mipmapped::kNo;
@@ -119,9 +115,6 @@ private:
119
115
  : fBackend(BackendTextureData::kBackend)
120
116
  , fViewFormat(data.viewFormat())
121
117
  , fProtected(data.isProtected()) {
122
- // TextureInfoPriv should not construct a TextureInfo if `data` would fail this assert.
123
- SkASSERT(data.fSampleCount == 1 || data.fSampleCount == 2 || data.fSampleCount == 4 ||
124
- data.fSampleCount == 8 || data.fSampleCount == 16);
125
118
  fData.emplace<BackendTextureData>(data);
126
119
  }
127
120
 
@@ -48,7 +48,7 @@ public:
48
48
 
49
49
  explicit DawnTextureInfo(WGPUTexture texture);
50
50
 
51
- DawnTextureInfo(uint32_t sampleCount,
51
+ DawnTextureInfo(SampleCount sampleCount,
52
52
  Mipmapped mipmapped,
53
53
  wgpu::TextureFormat format,
54
54
  wgpu::TextureUsage usage,
@@ -61,7 +61,7 @@ public:
61
61
  aspect,
62
62
  /*slice=*/0) {}
63
63
 
64
- DawnTextureInfo(uint32_t sampleCount,
64
+ DawnTextureInfo(SampleCount sampleCount,
65
65
  Mipmapped mipmapped,
66
66
  wgpu::TextureFormat format,
67
67
  wgpu::TextureFormat viewFormat,
@@ -76,7 +76,7 @@ public:
76
76
  , fSlice(slice) {}
77
77
 
78
78
  #if !defined(__EMSCRIPTEN__)
79
- DawnTextureInfo(uint32_t sampleCount,
79
+ DawnTextureInfo(SampleCount sampleCount,
80
80
  Mipmapped mipmapped,
81
81
  wgpu::TextureFormat format,
82
82
  wgpu::TextureFormat viewFormat,
@@ -35,7 +35,7 @@ public:
35
35
 
36
36
  MtlTextureInfo() = default;
37
37
  explicit MtlTextureInfo(CFTypeRef mtlTexture);
38
- MtlTextureInfo(uint32_t sampleCount,
38
+ MtlTextureInfo(SampleCount sampleCount,
39
39
  skgpu::Mipmapped mipmapped,
40
40
  MTLPixelFormat format,
41
41
  MTLTextureUsage usage,
@@ -12,7 +12,7 @@
12
12
 
13
13
  #include "include/core/SkBlendMode.h"
14
14
  #include "include/core/SkImageInfo.h"
15
- #include "include/effects/SkGradientShader.h"
15
+ #include "include/effects/SkGradient.h"
16
16
 
17
17
  class SkColorSpace;
18
18
 
@@ -202,19 +202,19 @@ namespace PrecompileShaders {
202
202
  kNoLarge = kSmall | kMedium,
203
203
  };
204
204
 
205
- // --- This block of four matches all the factories in SkGradientShader (SkGradientShader.h)
205
+ // --- This block of four matches all the factories in SkGradientShader (SkGradient.h)
206
206
  SK_API sk_sp<PrecompileShader> LinearGradient(
207
207
  GradientShaderFlags = GradientShaderFlags::kAll,
208
- SkGradientShader::Interpolation = SkGradientShader::Interpolation());
208
+ SkGradient::Interpolation = SkGradient::Interpolation());
209
209
  SK_API sk_sp<PrecompileShader> RadialGradient(
210
210
  GradientShaderFlags = GradientShaderFlags::kAll,
211
- SkGradientShader::Interpolation = SkGradientShader::Interpolation());
211
+ SkGradient::Interpolation = SkGradient::Interpolation());
212
212
  SK_API sk_sp<PrecompileShader> TwoPointConicalGradient(
213
213
  GradientShaderFlags = GradientShaderFlags::kAll,
214
- SkGradientShader::Interpolation = SkGradientShader::Interpolation());
214
+ SkGradient::Interpolation = SkGradient::Interpolation());
215
215
  SK_API sk_sp<PrecompileShader> SweepGradient(
216
216
  GradientShaderFlags = GradientShaderFlags::kAll,
217
- SkGradientShader::Interpolation = SkGradientShader::Interpolation());
217
+ SkGradient::Interpolation = SkGradient::Interpolation());
218
218
 
219
219
  // Normally, SkPicture shaders are only created via SkPicture::makeShader. Since the
220
220
  // SkPicture to be drawn, most likely, won't be available at precompilation time, this
@@ -18,8 +18,9 @@ namespace skgpu::graphite {
18
18
  class SK_API VulkanTextureInfo final : public TextureInfo::Data {
19
19
  public:
20
20
  // VkImageCreateInfo properties
21
- // Currently the only supported flag is VK_IMAGE_CREATE_PROTECTED_BIT. Any other flag will not
22
- // be accepted
21
+ // Currently the only supported flags are VK_IMAGE_CREATE_PROTECTED_BIT and, when
22
+ // VK_EXT_multisampled_render_to_single_sampled is present and enabled,
23
+ // VK_IMAGE_CREATE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_BIT_EXT. Other flags are not accepted.
23
24
  VkImageCreateFlags fFlags = 0;
24
25
  VkFormat fFormat = VK_FORMAT_UNDEFINED;
25
26
  VkImageTiling fImageTiling = VK_IMAGE_TILING_OPTIMAL;
@@ -46,7 +47,8 @@ public:
46
47
  VkSharingMode sharingMode,
47
48
  VkImageAspectFlags aspectMask,
48
49
  VulkanYcbcrConversionInfo ycbcrConversionInfo)
49
- : Data(static_cast<uint8_t>(sampleCount), mipmapped)
50
+ // VkSampleCountFlagBits is value equivalent to SampleCount
51
+ : Data(static_cast<SampleCount>(sampleCount), mipmapped)
50
52
  , fFlags(flags)
51
53
  , fFormat(format)
52
54
  , fImageTiling(imageTiling)
@@ -27,7 +27,7 @@ namespace PrecompileShaders {
27
27
 
28
28
  @return A precompile shader for a specific type of YCbCr image
29
29
  */
30
- SK_API sk_sp<PrecompileShader> VulkanYCbCrImage(skgpu::VulkanYcbcrConversionInfo& YCbCrInfo,
30
+ SK_API sk_sp<PrecompileShader> VulkanYCbCrImage(const skgpu::VulkanYcbcrConversionInfo& YCbCrInfo,
31
31
  ImageShaderFlags = ImageShaderFlags::kAll,
32
32
  SkSpan<const SkColorInfo> = {},
33
33
  SkSpan<const SkTileMode> = { kAllTileModes });
@@ -39,7 +39,7 @@ struct SK_API VulkanBackendContext {
39
39
  // fDeviceFeatures and fDeviceFeatures2 are null we will assume no features are enabled.
40
40
  const VkPhysicalDeviceFeatures* fDeviceFeatures = nullptr;
41
41
  const VkPhysicalDeviceFeatures2* fDeviceFeatures2 = nullptr;
42
- // Optional. The client may provide an inplementation of a VulkanMemoryAllocator for Skia to use
42
+ // The client must provide an inplementation of a VulkanMemoryAllocator for Skia to use
43
43
  // for allocating Vulkan resources that use VkDeviceMemory.
44
44
  sk_sp<VulkanMemoryAllocator> fMemoryAllocator;
45
45
  skgpu::VulkanGetProc fGetProc;
@@ -201,6 +201,10 @@ private:
201
201
  const char* fLoadStoreOpNoneExtension = nullptr;
202
202
  // VK_EXT_conservative_rasterization
203
203
  const char* fConservativeRasterizationExtension = nullptr;
204
+ #if defined(SK_BUILD_FOR_ANDROID)
205
+ // VK_ANDROID_external_memory_android_hardware_buffer
206
+ const char* fExternalMemoryAHardwareBufferExtension = nullptr;
207
+ #endif
204
208
 
205
209
  // Extensions that the other extensions above depend on:
206
210
  // Dependency of VK_EXT_graphics_pipeline_library: VK_KHR_pipeline_library
@@ -210,6 +214,10 @@ private:
210
214
  const char* fFormatFeatureFlags2Extension = nullptr;
211
215
  // Dependency of VK_EXT_multisampled_render_to_single_sampled: VK_KHR_depth_stencil_resolve
212
216
  const char* fDepthStencilResolveExtension = nullptr;
217
+ #if defined(SK_BUILD_FOR_ANDROID)
218
+ // Dependency of VK_ANDROID_external_memory_android_hardware_buffer: VK_EXT_queue_family_foreign
219
+ const char* fQueueFamilyForeignExtension = nullptr;
220
+ #endif
213
221
  };
214
222
 
215
223
  } // namespace skgpu
@@ -16,6 +16,7 @@
16
16
  #include "include/core/SkRefCnt.h"
17
17
  #include "include/core/SkTypes.h"
18
18
  #include "include/private/SkHdrMetadata.h"
19
+ #include "include/private/base/SkAPI.h"
19
20
  #include "include/private/base/SkTo.h"
20
21
  #include "modules/skcms/skcms.h"
21
22
 
@@ -24,22 +25,12 @@
24
25
  #include <tuple>
25
26
  #include <utility>
26
27
 
27
- struct SkEncodedInfo {
28
- public:
29
- class ICCProfile {
30
- public:
31
- static std::unique_ptr<ICCProfile> Make(sk_sp<const SkData>);
32
- static std::unique_ptr<ICCProfile> Make(const skcms_ICCProfile&);
33
-
34
- const skcms_ICCProfile* profile() const { return &fProfile; }
35
- sk_sp<const SkData> data() const { return fData; }
36
- private:
37
- ICCProfile(const skcms_ICCProfile&, sk_sp<const SkData> = nullptr);
38
-
39
- skcms_ICCProfile fProfile;
40
- sk_sp<const SkData> fData;
41
- };
28
+ namespace SkCodecs {
29
+ class ColorProfile;
30
+ }
42
31
 
32
+ struct SK_API SkEncodedInfo {
33
+ public:
43
34
  enum Alpha {
44
35
  kOpaque_Alpha,
45
36
  kUnpremul_Alpha,
@@ -106,75 +97,41 @@ public:
106
97
  kYCCK_Color,
107
98
  };
108
99
 
109
- static SkEncodedInfo Make(int width, int height, Color color, Alpha alpha,
110
- int bitsPerComponent) {
111
- return Make(width, height, color, alpha, bitsPerComponent, nullptr);
112
- }
100
+ static SkEncodedInfo Make(
101
+ int width, int height, Color color, Alpha alpha, int bitsPerComponent);
113
102
 
114
- static SkEncodedInfo Make(int width, int height, Color color,
115
- Alpha alpha, int bitsPerComponent, std::unique_ptr<ICCProfile> profile) {
116
- return Make(width, height, color, alpha, /*bitsPerComponent*/ bitsPerComponent,
117
- std::move(profile), /*colorDepth*/ bitsPerComponent);
118
- }
103
+ static SkEncodedInfo Make(
104
+ int width, int height, Color color, Alpha alpha, int bitsPerComponent,
105
+ std::unique_ptr<SkCodecs::ColorProfile> profile);
119
106
 
120
- static SkEncodedInfo Make(int width, int height, Color color,
121
- Alpha alpha, int bitsPerComponent, std::unique_ptr<ICCProfile> profile,
122
- int colorDepth) {
123
- return Make(width, height, color, alpha, bitsPerComponent, colorDepth, std::move(profile),
124
- skhdr::Metadata::MakeEmpty());
125
- }
107
+ static SkEncodedInfo Make(
108
+ int width, int height, Color color, Alpha alpha, int bitsPerComponent,
109
+ std::unique_ptr<SkCodecs::ColorProfile> profile, int colorDepth);
126
110
 
127
- static SkEncodedInfo Make(int width, int height, Color color,
128
- Alpha alpha, int bitsPerComponent, int colorDepth, std::unique_ptr<ICCProfile> profile,
129
- const skhdr::Metadata& hdrMetadata) {
130
- SkASSERT(1 == bitsPerComponent ||
131
- 2 == bitsPerComponent ||
132
- 4 == bitsPerComponent ||
133
- 8 == bitsPerComponent ||
134
- 16 == bitsPerComponent);
135
- VerifyColor(color, alpha, bitsPerComponent);
136
- return SkEncodedInfo(width,
137
- height,
138
- color,
139
- alpha,
140
- SkToU8(bitsPerComponent),
141
- SkToU8(colorDepth),
142
- std::move(profile),
143
- hdrMetadata);
144
- }
111
+ static SkEncodedInfo Make(
112
+ int width, int height, Color color, Alpha alpha, int bitsPerComponent,
113
+ int colorDepth,
114
+ std::unique_ptr<SkCodecs::ColorProfile> profile, const skhdr::Metadata& hdrMetadata);
145
115
 
146
116
  /*
147
117
  * Returns a recommended SkImageInfo.
148
118
  *
149
119
  * TODO: Leave this up to the client.
150
120
  */
151
- SkImageInfo makeImageInfo() const {
152
- auto ct = kGray_Color == fColor ? kGray_8_SkColorType :
153
- kXAlpha_Color == fColor ? kAlpha_8_SkColorType :
154
- k565_Color == fColor ? kRGB_565_SkColorType :
155
- kN32_SkColorType ;
156
- auto alpha = kOpaque_Alpha == fAlpha ? kOpaque_SkAlphaType
157
- : kUnpremul_SkAlphaType;
158
- sk_sp<SkColorSpace> cs = fProfile ? SkColorSpace::Make(*fProfile->profile())
159
- : nullptr;
160
- if (!cs) {
161
- cs = SkColorSpace::MakeSRGB();
162
- }
163
- return SkImageInfo::Make(fWidth, fHeight, ct, alpha, std::move(cs));
164
- }
121
+ SkImageInfo makeImageInfo() const;
165
122
 
166
123
  int width() const { return fWidth; }
167
124
  int height() const { return fHeight; }
168
125
  Color color() const { return fColor; }
169
126
  Alpha alpha() const { return fAlpha; }
170
127
  bool opaque() const { return fAlpha == kOpaque_Alpha; }
171
- const skcms_ICCProfile* profile() const {
172
- if (!fProfile) return nullptr;
173
- return fProfile->profile();
174
- }
175
- sk_sp<const SkData> profileData() const {
176
- if (!fProfile) return nullptr;
177
- return fProfile->data();
128
+
129
+ // TODO(https://issues.skia.org/issues/464217864): Remove direct access to the
130
+ // skcms_ICCProfile and change profileData() to serialize a new profile.
131
+ const skcms_ICCProfile* profile() const;
132
+ sk_sp<const SkData> profileData() const;
133
+ const SkCodecs::ColorProfile* colorProfile() const {
134
+ return fColorProfile.get();
178
135
  }
179
136
 
180
137
  uint8_t bitsPerComponent() const { return fBitsPerComponent; }
@@ -208,20 +165,11 @@ public:
208
165
  SkEncodedInfo(const SkEncodedInfo& orig) = delete;
209
166
  SkEncodedInfo& operator=(const SkEncodedInfo&) = delete;
210
167
 
211
- SkEncodedInfo(SkEncodedInfo&& orig) = default;
212
- SkEncodedInfo& operator=(SkEncodedInfo&&) = default;
168
+ SkEncodedInfo(SkEncodedInfo&& orig);
169
+ SkEncodedInfo& operator=(SkEncodedInfo&&);
213
170
 
214
171
  // Explicit copy method, to avoid accidental copying.
215
- SkEncodedInfo copy() const {
216
- return SkEncodedInfo(fWidth,
217
- fHeight,
218
- fColor,
219
- fAlpha,
220
- fBitsPerComponent,
221
- fColorDepth,
222
- fProfile ? std::make_unique<const ICCProfile>(*fProfile) : nullptr,
223
- fHdrMetadata);
224
- }
172
+ SkEncodedInfo copy() const;
225
173
 
226
174
  // Return number of bits of R/G/B channel
227
175
  uint8_t getColorDepth() const {
@@ -234,23 +182,13 @@ public:
234
182
  return fHdrMetadata;
235
183
  }
236
184
 
185
+ ~SkEncodedInfo();
186
+
237
187
  private:
238
- SkEncodedInfo(int width,
239
- int height,
240
- Color color,
241
- Alpha alpha,
242
- uint8_t bitsPerComponent,
243
- uint8_t colorDepth,
244
- std::unique_ptr<const ICCProfile> profile,
245
- const skhdr::Metadata& hdrMetadata)
246
- : fWidth(width)
247
- , fHeight(height)
248
- , fColor(color)
249
- , fAlpha(alpha)
250
- , fBitsPerComponent(bitsPerComponent)
251
- , fColorDepth(colorDepth)
252
- , fProfile(std::move(profile))
253
- , fHdrMetadata(hdrMetadata) {}
188
+ SkEncodedInfo(
189
+ int width, int height, Color color, Alpha alpha, uint8_t bitsPerComponent,
190
+ uint8_t colorDepth,
191
+ std::unique_ptr<SkCodecs::ColorProfile> profile, const skhdr::Metadata& hdrMetadata);
254
192
 
255
193
  static void VerifyColor(Color color, Alpha alpha, int bitsPerComponent) {
256
194
  // Avoid `-Wunused-parameter` warnings on non-debug builds.
@@ -298,14 +236,14 @@ private:
298
236
  SkASSERT(false); // Unrecognized `color` enum value.
299
237
  }
300
238
 
301
- int fWidth;
302
- int fHeight;
303
- Color fColor;
304
- Alpha fAlpha;
305
- uint8_t fBitsPerComponent;
306
- uint8_t fColorDepth;
307
- std::unique_ptr<const ICCProfile> fProfile;
308
- skhdr::Metadata fHdrMetadata;
239
+ int fWidth;
240
+ int fHeight;
241
+ Color fColor;
242
+ Alpha fAlpha;
243
+ uint8_t fBitsPerComponent;
244
+ uint8_t fColorDepth;
245
+ std::unique_ptr<const SkCodecs::ColorProfile> fColorProfile;
246
+ skhdr::Metadata fHdrMetadata;
309
247
  };
310
248
 
311
249
  #endif