@shopify/react-native-skia 2.0.0-next.3 → 2.0.0-next.4

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 (139) hide show
  1. package/cpp/skia/include/codec/SkCodec.h +39 -1
  2. package/cpp/skia/include/config/SkUserConfig.h +1 -10
  3. package/cpp/skia/include/core/SkCanvas.h +8 -4
  4. package/cpp/skia/include/core/SkContourMeasure.h +2 -2
  5. package/cpp/skia/include/core/SkMilestone.h +1 -1
  6. package/cpp/skia/include/core/SkPaint.h +8 -5
  7. package/cpp/skia/include/core/SkStream.h +8 -3
  8. package/cpp/skia/include/core/SkTextBlob.h +9 -9
  9. package/cpp/skia/include/core/SkTypeface.h +4 -6
  10. package/cpp/skia/include/core/SkTypes.h +5 -0
  11. package/cpp/skia/include/docs/SkPDFDocument.h +47 -2
  12. package/cpp/skia/include/docs/SkPDFJpegHelpers.h +41 -0
  13. package/cpp/skia/include/effects/SkRuntimeEffect.h +5 -1
  14. package/cpp/skia/include/effects/SkTableMaskFilter.h +4 -0
  15. package/cpp/skia/include/gpu/graphite/BackendTexture.h +0 -2
  16. package/cpp/skia/include/gpu/graphite/ContextOptions.h +17 -0
  17. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +21 -18
  18. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +24 -0
  19. package/cpp/skia/include/gpu/graphite/TextureInfo.h +87 -42
  20. package/cpp/skia/include/gpu/graphite/YUVABackendTextures.h +13 -4
  21. package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +9 -0
  22. package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +166 -0
  23. package/cpp/skia/include/gpu/graphite/dawn/DawnTypes.h +3 -141
  24. package/cpp/skia/include/gpu/graphite/dawn/DawnUtils.h +2 -21
  25. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +4 -0
  26. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +30 -6
  27. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypesUtils.h +4 -42
  28. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes_cpp.h +50 -0
  29. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteUtils.h +2 -20
  30. package/cpp/skia/include/gpu/graphite/precompile/Precompile.h +14 -4
  31. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +14 -6
  32. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteContext.h +31 -0
  33. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +36 -14
  34. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteUtils.h +3 -21
  35. package/cpp/skia/include/ports/SkTypeface_fontations.h +3 -0
  36. package/cpp/skia/include/private/SkJpegMetadataDecoder.h +7 -0
  37. package/cpp/skia/include/private/base/SkAnySubclass.h +6 -0
  38. package/cpp/skia/include/private/chromium/SkPMColor.h +38 -0
  39. package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -2
  40. package/cpp/skia/modules/skunicode/include/SkUnicode.h +10 -6
  41. package/cpp/skia/modules/svg/include/SkSVGDOM.h +1 -3
  42. package/cpp/skia/src/base/SkTInternalLList.h +1 -1
  43. package/cpp/skia/src/core/SkLRUCache.h +6 -3
  44. package/lib/commonjs/external/reanimated/textures.d.ts +2 -4
  45. package/lib/commonjs/external/reanimated/textures.js +8 -15
  46. package/lib/commonjs/external/reanimated/textures.js.map +1 -1
  47. package/lib/commonjs/sksg/HostConfig.js +2 -1
  48. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  49. package/lib/module/external/reanimated/textures.d.ts +2 -4
  50. package/lib/module/external/reanimated/textures.js +7 -12
  51. package/lib/module/external/reanimated/textures.js.map +1 -1
  52. package/lib/module/sksg/HostConfig.js +2 -1
  53. package/lib/module/sksg/HostConfig.js.map +1 -1
  54. package/lib/typescript/lib/commonjs/external/reanimated/textures.d.ts +1 -3
  55. package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +1 -1
  56. package/lib/typescript/lib/module/external/reanimated/textures.d.ts +1 -3
  57. package/lib/typescript/lib/module/sksg/HostConfig.d.ts +1 -1
  58. package/lib/typescript/src/external/reanimated/textures.d.ts +2 -4
  59. package/libs/android/arm64-v8a/libskia.a +0 -0
  60. package/libs/android/arm64-v8a/libskottie.a +0 -0
  61. package/libs/android/arm64-v8a/libskparagraph.a +0 -0
  62. package/libs/android/arm64-v8a/libsksg.a +0 -0
  63. package/libs/android/arm64-v8a/libskshaper.a +0 -0
  64. package/libs/android/arm64-v8a/libskunicode_icu.a +0 -0
  65. package/libs/android/arm64-v8a/libsvg.a +0 -0
  66. package/libs/android/armeabi-v7a/libskia.a +0 -0
  67. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  68. package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
  69. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  70. package/libs/android/armeabi-v7a/libskshaper.a +0 -0
  71. package/libs/android/armeabi-v7a/libskunicode_icu.a +0 -0
  72. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  73. package/libs/android/x86/libskia.a +0 -0
  74. package/libs/android/x86/libskottie.a +0 -0
  75. package/libs/android/x86/libskparagraph.a +0 -0
  76. package/libs/android/x86/libsksg.a +0 -0
  77. package/libs/android/x86/libskshaper.a +0 -0
  78. package/libs/android/x86/libskunicode_icu.a +0 -0
  79. package/libs/android/x86/libsvg.a +0 -0
  80. package/libs/android/x86_64/libskia.a +0 -0
  81. package/libs/android/x86_64/libskottie.a +0 -0
  82. package/libs/android/x86_64/libskparagraph.a +0 -0
  83. package/libs/android/x86_64/libsksg.a +0 -0
  84. package/libs/android/x86_64/libskshaper.a +0 -0
  85. package/libs/android/x86_64/libskunicode_icu.a +0 -0
  86. package/libs/android/x86_64/libsvg.a +0 -0
  87. package/libs/apple/libskia.xcframework/Info.plist +15 -15
  88. package/libs/apple/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  89. package/libs/apple/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  90. package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
  91. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e/libskia.a +0 -0
  92. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  93. package/libs/apple/libskottie.xcframework/Info.plist +7 -7
  94. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  95. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  96. package/libs/apple/libskottie.xcframework/macos-arm64_x86_64/libskottie.a +0 -0
  97. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e/libskottie.a +0 -0
  98. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  99. package/libs/apple/libskparagraph.xcframework/Info.plist +13 -13
  100. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  101. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  102. package/libs/apple/libskparagraph.xcframework/macos-arm64_x86_64/libskparagraph.a +0 -0
  103. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e/libskparagraph.a +0 -0
  104. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  105. package/libs/apple/libsksg.xcframework/Info.plist +13 -13
  106. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  107. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  108. package/libs/apple/libsksg.xcframework/macos-arm64_x86_64/libsksg.a +0 -0
  109. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e/libsksg.a +0 -0
  110. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  111. package/libs/apple/libskshaper.xcframework/Info.plist +14 -14
  112. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  113. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  114. package/libs/apple/libskshaper.xcframework/macos-arm64_x86_64/libskshaper.a +0 -0
  115. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e/libskshaper.a +0 -0
  116. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  117. package/libs/apple/libskunicode_core.xcframework/Info.plist +12 -12
  118. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e/libskunicode_core.a +0 -0
  119. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  120. package/libs/apple/libskunicode_core.xcframework/macos-arm64_x86_64/libskunicode_core.a +0 -0
  121. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e/libskunicode_core.a +0 -0
  122. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  123. package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +15 -15
  124. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  125. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  126. package/libs/apple/libskunicode_libgrapheme.xcframework/macos-arm64_x86_64/libskunicode_libgrapheme.a +0 -0
  127. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  128. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  129. package/libs/apple/libsvg.xcframework/Info.plist +8 -8
  130. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  131. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  132. package/libs/apple/libsvg.xcframework/macos-arm64_x86_64/libsvg.a +0 -0
  133. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e/libsvg.a +0 -0
  134. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  135. package/package.json +1 -1
  136. package/src/external/reanimated/textures.tsx +12 -20
  137. package/src/sksg/HostConfig.ts +2 -1
  138. package/cpp/skia/include/core/SkColorPriv.h +0 -165
  139. package/cpp/skia/include/private/SkColorData.h +0 -385
@@ -18,70 +18,115 @@ struct SkISize;
18
18
 
19
19
  namespace skgpu::graphite {
20
20
 
21
- class TextureInfoData;
21
+ enum class TextureFormat : uint8_t;
22
22
 
23
+ /**
24
+ * TextureInfo is a backend-agnostic wrapper around the properties of a texture, sans dimensions.
25
+ * It is designed this way to be compilable w/o bringing in a specific backend's build files, and
26
+ * without requiring heap allocations of virtual types.
27
+ */
23
28
  class SK_API TextureInfo {
29
+ private:
30
+ class Data;
31
+ friend class MtlTextureInfo;
32
+ friend class DawnTextureInfo;
33
+ friend class VulkanTextureInfo;
34
+
35
+ // Size is the largest of the Data subclasses assuming a 64-bit compiler.
36
+ inline constexpr static size_t kMaxSubclassSize = 112;
37
+ using AnyTextureInfoData = SkAnySubclass<Data, kMaxSubclassSize>;
38
+
39
+ // Base properties for all backend-specific properties. Clients managing textures directly
40
+ // should use the public subclasses of Data directly, e.g. MtlTextureInfo/DawnTextureInfo.
41
+ //
42
+ // Each backend subclass must expose to TextureInfo[Priv]:
43
+ // static constexpr BackendApi kBackend;
44
+ // Protected isProtected() const;
45
+ // TextureFormat viewFormat() const;
46
+ // bool serialize(SkWStream*) const;
47
+ // bool deserialize(SkStream*);
48
+ class Data {
49
+ public:
50
+ virtual ~Data() = default;
51
+
52
+ Data(uint32_t sampleCount, skgpu::Mipmapped mipmapped)
53
+ : fSampleCount(sampleCount)
54
+ , fMipmapped(mipmapped) {}
55
+
56
+ Data() = default;
57
+ Data(const Data&) = default;
58
+
59
+ Data& operator=(const Data&) = default;
60
+
61
+ // NOTE: These fields are accessible via the backend-specific subclasses.
62
+ uint32_t fSampleCount = 1;
63
+ Mipmapped fMipmapped = Mipmapped::kNo;
64
+
65
+ private:
66
+ friend class TextureInfo;
67
+ friend class TextureInfoPriv;
68
+
69
+ virtual SkString toBackendString() const = 0;
70
+
71
+ virtual void copyTo(AnyTextureInfoData&) const = 0;
72
+ // Passed in TextureInfo will have data of the same backend type and subclass, and
73
+ // base properties of Data have already been checked for equality/compatibility.
74
+ virtual bool isCompatible(const TextureInfo& that, bool requireExact) const = 0;
75
+ };
76
+
24
77
  public:
25
- TextureInfo();
26
- ~TextureInfo();
78
+ TextureInfo() = default;
79
+ ~TextureInfo() = default;
80
+
27
81
  TextureInfo(const TextureInfo&);
28
82
  TextureInfo& operator=(const TextureInfo&);
29
83
 
30
- bool operator==(const TextureInfo&) const;
84
+ bool operator==(const TextureInfo& that) const {
85
+ return this->isCompatible(that, /*requireExact=*/true);
86
+ }
31
87
  bool operator!=(const TextureInfo& that) const { return !(*this == that); }
32
88
 
33
- bool isValid() const { return fValid; }
34
- BackendApi backend() const { return fBackend; }
89
+ bool isValid() const { return fData.has_value(); }
90
+ BackendApi backend() const {
91
+ SkASSERT(fData.has_value() || fBackend == BackendApi::kUnsupported);
92
+ return fBackend;
93
+ }
35
94
 
36
- uint32_t numSamples() const { return fSampleCount; }
37
- Mipmapped mipmapped() const { return fMipmapped; }
95
+ uint32_t numSamples() const { return fData.has_value() ? fData->fSampleCount : 1; }
96
+ Mipmapped mipmapped() const { return fData.has_value() ? fData->fMipmapped : Mipmapped::kNo; }
38
97
  Protected isProtected() const { return fProtected; }
39
- SkTextureCompressionType compressionType() const;
40
- bool isMemoryless() const;
41
98
 
42
- bool isCompatible(const TextureInfo& that) const;
99
+ // Return true if `that` describes a texture that is compatible with this info and can validly
100
+ // be used to fulfill a promise image that was created with this TextureInfo.
101
+ bool canBeFulfilledBy(const TextureInfo& that) const {
102
+ return this->isCompatible(that, /*requireExact=*/false);
103
+ }
104
+
43
105
  // Return a string containing the full description of this TextureInfo.
44
106
  SkString toString() const;
45
- // Return a string containing only the info relevant for its use as a RenderPass attachment.
46
- SkString toRPAttachmentString() const;
47
107
 
48
108
  private:
49
- friend class TextureInfoData;
50
109
  friend class TextureInfoPriv;
51
110
 
52
- // Size determined by looking at the TextureInfoData subclasses, then guessing-and-checking.
53
- // Compiler will complain if this is too small - in that case, just increase the number.
54
- inline constexpr static size_t kMaxSubclassSize = 112;
55
- using AnyTextureInfoData = SkAnySubclass<TextureInfoData, kMaxSubclassSize>;
56
-
57
- template <typename SomeTextureInfoData>
58
- TextureInfo(BackendApi backend,
59
- uint32_t sampleCount,
60
- skgpu::Mipmapped mipped,
61
- skgpu::Protected isProtected,
62
- const SomeTextureInfoData& textureInfoData)
63
- : fBackend(backend)
64
- , fValid(true)
65
- , fSampleCount(sampleCount)
66
- , fMipmapped(mipped)
67
- , fProtected(isProtected) {
68
- fTextureInfoData.emplace<SomeTextureInfoData>(textureInfoData);
111
+ template <typename BackendTextureData,
112
+ std::enable_if_t<std::is_base_of_v<Data, BackendTextureData>, bool> = true>
113
+ explicit TextureInfo(const BackendTextureData& data)
114
+ : fBackend(BackendTextureData::kBackend)
115
+ , fViewFormat(data.viewFormat())
116
+ , fProtected(data.isProtected()) {
117
+ fData.emplace<BackendTextureData>(data);
69
118
  }
70
119
 
71
- friend size_t ComputeSize(SkISize dimensions, const TextureInfo&); // for bytesPerPixel
72
-
73
- size_t bytesPerPixel() const;
120
+ bool isCompatible(const TextureInfo& that, bool requireExact) const;
74
121
 
75
- BackendApi fBackend = BackendApi::kMock;
76
- bool fValid = false;
122
+ skgpu::BackendApi fBackend = BackendApi::kUnsupported;
123
+ AnyTextureInfoData fData;
77
124
 
78
- uint32_t fSampleCount = 1;
79
- Mipmapped fMipmapped = Mipmapped::kNo;
125
+ // Derived properties from the backend data, cached to avoid a virtual function call
126
+ TextureFormat fViewFormat;
80
127
  Protected fProtected = Protected::kNo;
81
-
82
- AnyTextureInfoData fTextureInfoData;
83
128
  };
84
129
 
85
- } // namespace skgpu::graphite
130
+ } // namespace skgpu::graphite
86
131
 
87
- #endif //skgpu_graphite_TextureInfo_DEFINED
132
+ #endif // skgpu_graphite_TextureInfo_DEFINED
@@ -37,10 +37,15 @@ public:
37
37
  * by Mipmapped. This will produce an invalid result (return false from isValid()) if the
38
38
  * passed formats' channels don't agree with SkYUVAInfo.
39
39
  */
40
- YUVABackendTextureInfo(const Recorder*,
41
- const SkYUVAInfo&,
40
+ YUVABackendTextureInfo(const SkYUVAInfo&,
42
41
  SkSpan<const TextureInfo>,
43
42
  Mipmapped);
43
+ // DEPRECATED: No more need for a Recorder to construct YUVABackendTextureInfo
44
+ YUVABackendTextureInfo(Recorder*,
45
+ const SkYUVAInfo& yuvaInfo,
46
+ SkSpan<const TextureInfo> textures,
47
+ Mipmapped mipmapped)
48
+ : YUVABackendTextureInfo(yuvaInfo, textures, mipmapped) {}
44
49
 
45
50
  bool operator==(const YUVABackendTextureInfo&) const;
46
51
  bool operator!=(const YUVABackendTextureInfo& that) const { return !(*this == that); }
@@ -95,9 +100,13 @@ public:
95
100
  * indicated by the SkYUVAInfo. This will produce an invalid result (return false from
96
101
  * isValid()) if the passed texture formats' channels don't agree with SkYUVAInfo.
97
102
  */
98
- YUVABackendTextures(const Recorder*,
99
- const SkYUVAInfo&,
103
+ YUVABackendTextures(const SkYUVAInfo&,
100
104
  SkSpan<const BackendTexture>);
105
+ // DEPRECATED: No more need for a Recorder to construct YUVABackendTextureInfo
106
+ YUVABackendTextures(Recorder*,
107
+ const SkYUVAInfo& yuvaInfo,
108
+ SkSpan<const BackendTexture> textures)
109
+ : YUVABackendTextures(yuvaInfo, textures) {}
101
110
 
102
111
  SkSpan<const BackendTexture> planeTextures() const {
103
112
  return SkSpan<const BackendTexture>(fPlaneTextures);
@@ -11,8 +11,13 @@
11
11
  #include "include/core/SkTypes.h"
12
12
  #include "webgpu/webgpu_cpp.h" // NO_G3_REWRITE
13
13
 
14
+ #include <memory>
15
+
14
16
  namespace skgpu::graphite {
15
17
 
18
+ class Context;
19
+ struct ContextOptions;
20
+
16
21
  /**
17
22
  * WebGPU needs to allow the main thread loop to run to detect GPU progress. Dawn native has a
18
23
  * function wgpu::Instance::ProcessEvents, not (currently) present in WebGPU, that can be used to
@@ -63,6 +68,10 @@ struct SK_API DawnBackendContext {
63
68
  #endif
64
69
  };
65
70
 
71
+ namespace ContextFactory {
72
+ SK_API std::unique_ptr<Context> MakeDawn(const DawnBackendContext&, const ContextOptions&);
73
+ } // namespace ContextFactory
74
+
66
75
  } // namespace skgpu::graphite
67
76
 
68
77
  #endif // skgpu_graphite_DawnBackendContext_DEFINED
@@ -0,0 +1,166 @@
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_DawnTypes_DEFINED
9
+ #define skgpu_graphite_DawnTypes_DEFINED
10
+
11
+ #include "include/core/SkSize.h"
12
+ #include "include/gpu/graphite/GraphiteTypes.h"
13
+ #include "include/gpu/graphite/TextureInfo.h"
14
+ #include "include/private/base/SkAPI.h"
15
+
16
+ #include "webgpu/webgpu_cpp.h" // NO_G3_REWRITE
17
+
18
+ class SkStream;
19
+ class SkWStream;
20
+
21
+ namespace skgpu::graphite {
22
+ class BackendTexture;
23
+
24
+ class SK_API DawnTextureInfo final : public TextureInfo::Data {
25
+ public:
26
+ // wgpu::TextureDescriptor properties
27
+ wgpu::TextureFormat fFormat = wgpu::TextureFormat::Undefined;
28
+ // `fViewFormat` for multiplanar formats corresponds to the plane TextureView's format.
29
+ wgpu::TextureFormat fViewFormat = wgpu::TextureFormat::Undefined;
30
+ wgpu::TextureUsage fUsage = wgpu::TextureUsage::None;
31
+ // TODO(b/308944094): Migrate aspect information to BackendTextureViews.
32
+ wgpu::TextureAspect fAspect = wgpu::TextureAspect::All;
33
+ uint32_t fSlice = 0;
34
+
35
+ #if !defined(__EMSCRIPTEN__)
36
+ // The descriptor of the YCbCr info (if any) for this texture. Dawn's YCbCr
37
+ // sampling will be used for this texture if this info is set. Setting the
38
+ // info is supported only on Android and only if using Vulkan as the
39
+ // underlying GPU driver.
40
+ wgpu::YCbCrVkDescriptor fYcbcrVkDescriptor = {};
41
+ #endif
42
+
43
+ wgpu::TextureFormat getViewFormat() const {
44
+ return fViewFormat != wgpu::TextureFormat::Undefined ? fViewFormat : fFormat;
45
+ }
46
+
47
+ DawnTextureInfo() = default;
48
+
49
+ DawnTextureInfo(WGPUTexture texture);
50
+
51
+ DawnTextureInfo(uint32_t sampleCount,
52
+ Mipmapped mipmapped,
53
+ wgpu::TextureFormat format,
54
+ wgpu::TextureUsage usage,
55
+ wgpu::TextureAspect aspect)
56
+ : DawnTextureInfo(sampleCount,
57
+ mipmapped,
58
+ /*format=*/format,
59
+ /*viewFormat=*/format,
60
+ usage,
61
+ aspect,
62
+ /*slice=*/0) {}
63
+
64
+ DawnTextureInfo(uint32_t sampleCount,
65
+ Mipmapped mipmapped,
66
+ wgpu::TextureFormat format,
67
+ wgpu::TextureFormat viewFormat,
68
+ wgpu::TextureUsage usage,
69
+ wgpu::TextureAspect aspect,
70
+ uint32_t slice)
71
+ : Data(sampleCount, mipmapped)
72
+ , fFormat(format)
73
+ , fViewFormat(viewFormat)
74
+ , fUsage(usage)
75
+ , fAspect(aspect)
76
+ , fSlice(slice) {}
77
+
78
+ #if !defined(__EMSCRIPTEN__)
79
+ DawnTextureInfo(uint32_t sampleCount,
80
+ Mipmapped mipmapped,
81
+ wgpu::TextureFormat format,
82
+ wgpu::TextureFormat viewFormat,
83
+ wgpu::TextureUsage usage,
84
+ wgpu::TextureAspect aspect,
85
+ uint32_t slice,
86
+ wgpu::YCbCrVkDescriptor ycbcrVkDescriptor)
87
+ : Data(sampleCount, mipmapped)
88
+ , fFormat(format)
89
+ , fViewFormat(viewFormat)
90
+ , fUsage(usage)
91
+ , fAspect(aspect)
92
+ , fSlice(slice)
93
+ , fYcbcrVkDescriptor(ycbcrVkDescriptor) {}
94
+ #endif
95
+
96
+ private:
97
+ friend class TextureInfo;
98
+ friend class TextureInfoPriv;
99
+
100
+ // Non-virtual template API for TextureInfo::Data accessed directly when backend type is known.
101
+ static constexpr skgpu::BackendApi kBackend = skgpu::BackendApi::kDawn;
102
+
103
+ Protected isProtected() const { return Protected::kNo; }
104
+ TextureFormat viewFormat() const;
105
+
106
+ bool serialize(SkWStream*) const;
107
+ bool deserialize(SkStream*);
108
+
109
+ // Virtual API when the specific backend type is not available.
110
+ SkString toBackendString() const override;
111
+
112
+ void copyTo(TextureInfo::AnyTextureInfoData& dstData) const override {
113
+ dstData.emplace<DawnTextureInfo>(*this);
114
+ }
115
+ bool isCompatible(const TextureInfo& that, bool requireExact) const override;
116
+ };
117
+
118
+ namespace TextureInfos {
119
+ SK_API TextureInfo MakeDawn(const DawnTextureInfo& dawnInfo);
120
+
121
+ SK_API bool GetDawnTextureInfo(const TextureInfo&, DawnTextureInfo*);
122
+ } // namespace TextureInfos
123
+
124
+ namespace BackendTextures {
125
+ // Create a BackendTexture from a WGPUTexture. Texture info will be queried from the texture.
126
+ //
127
+ // This is the recommended way of specifying a BackendTexture for Dawn. See the note below on
128
+ // the constructor that takes a WGPUTextureView for a fuller explanation.
129
+ //
130
+ // The BackendTexture will not call retain or release on the passed in WGPUTexture. Thus, the
131
+ // client must keep the WGPUTexture valid until they are no longer using the BackendTexture.
132
+ // However, any SkImage or SkSurface that wraps the BackendTexture *will* retain and release
133
+ // the WGPUTexture.
134
+ SK_API BackendTexture MakeDawn(WGPUTexture);
135
+
136
+ // Create a BackendTexture from a WGPUTexture. Texture planeDimensions, plane aspect and
137
+ // info have to be provided. This is intended to be used only when accessing a plane
138
+ // of a WGPUTexture.
139
+ //
140
+ // The BackendTexture will not call retain or release on the passed in WGPUTexture. Thus, the
141
+ // client must keep the WGPUTexture valid until they are no longer using the BackendTexture.
142
+ // However, any SkImage or SkSurface that wraps the BackendTexture *will* retain and release
143
+ // the WGPUTexture.
144
+ SK_API BackendTexture MakeDawn(SkISize planeDimensions, const DawnTextureInfo&, WGPUTexture);
145
+
146
+ // Create a BackendTexture from a WGPUTextureView. Texture dimensions and
147
+ // info have to be provided.
148
+ //
149
+ // Using a WGPUTextureView rather than a WGPUTexture is less effecient for operations that
150
+ // require buffer transfers to or from the texture (e.g. methods on graphite::Context that read
151
+ // pixels or SkSurface::writePixels). In such cases an intermediate copy to or from a
152
+ // WGPUTexture is required. Thus, it is recommended to use this functionality only for cases
153
+ // where a WGPUTexture is unavailable, in particular when using wgpu::SwapChain.
154
+ //
155
+ // The BackendTexture will not call retain or release on the passed in WGPUTextureView. Thus,
156
+ // the client must keep the WGPUTextureView valid until they are no longer using the
157
+ // BackendTexture. However, any SkImage or SkSurface that wraps the BackendTexture *will* retain
158
+ // and release the WGPUTextureView.
159
+ SK_API BackendTexture MakeDawn(SkISize dimensions,
160
+ const DawnTextureInfo& info,
161
+ WGPUTextureView textureView);
162
+ } // namespace BackendTextures
163
+
164
+ } // namespace skgpu::graphite
165
+
166
+ #endif // skgpu_graphite_DawnTypes_DEFINED
@@ -1,147 +1,9 @@
1
1
  /*
2
- * Copyright 2022 Google LLC.
2
+ * Copyright 2022 Google LLC
3
3
  *
4
4
  * Use of this source code is governed by a BSD-style license that can be
5
5
  * found in the LICENSE file.
6
6
  */
7
7
 
8
- #ifndef skgpu_graphite_DawnTypes_DEFINED
9
- #define skgpu_graphite_DawnTypes_DEFINED
10
-
11
- #include "include/core/SkSize.h"
12
- #include "include/gpu/graphite/GraphiteTypes.h"
13
- #include "include/private/base/SkAPI.h"
14
-
15
- #include "webgpu/webgpu_cpp.h" // NO_G3_REWRITE
16
-
17
- namespace skgpu::graphite {
18
- class BackendTexture;
19
- class TextureInfo;
20
-
21
- struct DawnTextureInfo {
22
- uint32_t fSampleCount = 1;
23
- Mipmapped fMipmapped = Mipmapped::kNo;
24
-
25
- // wgpu::TextureDescriptor properties
26
- wgpu::TextureFormat fFormat = wgpu::TextureFormat::Undefined;
27
- // `fViewFormat` for multiplanar formats corresponds to the plane TextureView's format.
28
- wgpu::TextureFormat fViewFormat = wgpu::TextureFormat::Undefined;
29
- wgpu::TextureUsage fUsage = wgpu::TextureUsage::None;
30
- // TODO(b/308944094): Migrate aspect information to BackendTextureViews.
31
- wgpu::TextureAspect fAspect = wgpu::TextureAspect::All;
32
- uint32_t fSlice = 0;
33
-
34
- #if !defined(__EMSCRIPTEN__)
35
- // The descriptor of the YCbCr info (if any) for this texture. Dawn's YCbCr
36
- // sampling will be used for this texture if this info is set. Setting the
37
- // info is supported only on Android and only if using Vulkan as the
38
- // underlying GPU driver.
39
- wgpu::YCbCrVkDescriptor fYcbcrVkDescriptor = {};
40
- #endif
41
-
42
- wgpu::TextureFormat getViewFormat() const {
43
- return fViewFormat != wgpu::TextureFormat::Undefined ? fViewFormat : fFormat;
44
- }
45
-
46
- DawnTextureInfo() = default;
47
-
48
- DawnTextureInfo(uint32_t sampleCount,
49
- Mipmapped mipmapped,
50
- wgpu::TextureFormat format,
51
- wgpu::TextureUsage usage,
52
- wgpu::TextureAspect aspect)
53
- : DawnTextureInfo(sampleCount,
54
- mipmapped,
55
- /*format=*/format,
56
- /*viewFormat=*/format,
57
- usage,
58
- aspect,
59
- /*slice=*/0) {}
60
-
61
- DawnTextureInfo(uint32_t sampleCount,
62
- Mipmapped mipmapped,
63
- wgpu::TextureFormat format,
64
- wgpu::TextureFormat viewFormat,
65
- wgpu::TextureUsage usage,
66
- wgpu::TextureAspect aspect,
67
- uint32_t slice)
68
- : fSampleCount(sampleCount)
69
- , fMipmapped(mipmapped)
70
- , fFormat(format)
71
- , fViewFormat(viewFormat)
72
- , fUsage(usage)
73
- , fAspect(aspect)
74
- , fSlice(slice) {}
75
-
76
- #if !defined(__EMSCRIPTEN__)
77
- DawnTextureInfo(uint32_t sampleCount,
78
- Mipmapped mipmapped,
79
- wgpu::TextureFormat format,
80
- wgpu::TextureFormat viewFormat,
81
- wgpu::TextureUsage usage,
82
- wgpu::TextureAspect aspect,
83
- uint32_t slice,
84
- wgpu::YCbCrVkDescriptor ycbcrVkDescriptor)
85
- : fSampleCount(sampleCount)
86
- , fMipmapped(mipmapped)
87
- , fFormat(format)
88
- , fViewFormat(viewFormat)
89
- , fUsage(usage)
90
- , fAspect(aspect)
91
- , fSlice(slice)
92
- , fYcbcrVkDescriptor(ycbcrVkDescriptor) {}
93
- #endif
94
- };
95
-
96
- namespace TextureInfos {
97
- SK_API TextureInfo MakeDawn(const DawnTextureInfo& dawnInfo);
98
-
99
- SK_API bool GetDawnTextureInfo(const TextureInfo&, DawnTextureInfo*);
100
- } // namespace TextureInfos
101
-
102
- namespace BackendTextures {
103
- // Create a BackendTexture from a WGPUTexture. Texture info will be queried from the texture.
104
- //
105
- // This is the recommended way of specifying a BackendTexture for Dawn. See the note below on
106
- // the constructor that takes a WGPUTextureView for a fuller explanation.
107
- //
108
- // The BackendTexture will not call retain or release on the passed in WGPUTexture. Thus, the
109
- // client must keep the WGPUTexture valid until they are no longer using the BackendTexture.
110
- // However, any SkImage or SkSurface that wraps the BackendTexture *will* retain and release
111
- // the WGPUTexture.
112
- SK_API BackendTexture MakeDawn(WGPUTexture);
113
-
114
- // Create a BackendTexture from a WGPUTexture. Texture planeDimensions, plane aspect and
115
- // info have to be provided. This is intended to be used only when accessing a plane
116
- // of a WGPUTexture.
117
- //
118
- // The BackendTexture will not call retain or release on the passed in WGPUTexture. Thus, the
119
- // client must keep the WGPUTexture valid until they are no longer using the BackendTexture.
120
- // However, any SkImage or SkSurface that wraps the BackendTexture *will* retain and release
121
- // the WGPUTexture.
122
- SK_API BackendTexture MakeDawn(SkISize planeDimensions, const DawnTextureInfo&, WGPUTexture);
123
-
124
- // Create a BackendTexture from a WGPUTextureView. Texture dimensions and
125
- // info have to be provided.
126
- //
127
- // Using a WGPUTextureView rather than a WGPUTexture is less effecient for operations that
128
- // require buffer transfers to or from the texture (e.g. methods on graphite::Context that read
129
- // pixels or SkSurface::writePixels). In such cases an intermediate copy to or from a
130
- // WGPUTexture is required. Thus, it is recommended to use this functionality only for cases
131
- // where a WGPUTexture is unavailable, in particular when using wgpu::SwapChain.
132
- //
133
- // The BackendTexture will not call retain or release on the passed in WGPUTextureView. Thus,
134
- // the client must keep the WGPUTextureView valid until they are no longer using the
135
- // BackendTexture. However, any SkImage or SkSurface that wraps the BackendTexture *will* retain
136
- // and release the WGPUTextureView.
137
- SK_API BackendTexture MakeDawn(SkISize dimensions,
138
- const DawnTextureInfo& info,
139
- WGPUTextureView textureView);
140
-
141
- } // namespace BackendTextures
142
-
143
- } // namespace skgpu::graphite
144
-
145
- #endif // skgpu_graphite_DawnTypes_DEFINED
146
-
147
-
8
+ // DEPRECRATED: DawnTypes.h will be removed in the future, please include DawnGraphiteTypes.h
9
+ #include "include/gpu/graphite/dawn/DawnGraphiteTypes.h"
@@ -5,24 +5,5 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
 
8
- #ifndef skgpu_graphite_DawnUtils_DEFINED
9
- #define skgpu_graphite_DawnUtils_DEFINED
10
-
11
- #include <memory>
12
-
13
- #include "include/private/base/SkAPI.h"
14
-
15
- namespace skgpu::graphite {
16
-
17
- class Context;
18
- struct ContextOptions;
19
- struct DawnBackendContext;
20
-
21
- namespace ContextFactory {
22
- SK_API std::unique_ptr<Context> MakeDawn(const DawnBackendContext&, const ContextOptions&);
23
- } // namespace ContextFactory
24
-
25
- } // namespace skgpu::graphite
26
-
27
-
28
- #endif // skgpu_graphite_DawnUtils_DEFINED
8
+ // DEPRECRATED: DawnUtils.h will be removed in the future, please include DawnBackendContext.h
9
+ #include "include/gpu/graphite/dawn/DawnBackendContext.h"
@@ -23,6 +23,10 @@ struct SK_API MtlBackendContext {
23
23
  sk_cfp<CFTypeRef> fQueue;
24
24
  };
25
25
 
26
+ namespace ContextFactory {
27
+ SK_API std::unique_ptr<Context> MakeMetal(const MtlBackendContext&, const ContextOptions&);
28
+ } // namespace ContextFactory
29
+
26
30
  } // namespace skgpu::graphite
27
31
 
28
32
  #endif // skgpu_graphite_MtlBackendContext_DEFINED
@@ -13,18 +13,21 @@
13
13
  #include "include/core/SkTypes.h"
14
14
 
15
15
  #include "include/gpu/graphite/GraphiteTypes.h"
16
- #include "include/gpu/graphite/mtl/MtlGraphiteTypesUtils.h"
16
+ #include "include/gpu/graphite/TextureInfo.h"
17
+ #include "include/gpu/graphite/mtl/MtlGraphiteTypes_cpp.h"
17
18
  #include "include/private/base/SkAPI.h"
18
19
 
19
20
  #import <CoreFoundation/CoreFoundation.h>
20
21
  #import <Metal/Metal.h>
21
22
  #import <TargetConditionals.h>
22
23
 
24
+ class SkStream;
25
+ class SkWStream;
26
+
23
27
  namespace skgpu::graphite {
24
- struct SK_API MtlTextureInfo {
25
- uint32_t fSampleCount = 1;
26
- skgpu::Mipmapped fMipmapped = skgpu::Mipmapped::kNo;
27
28
 
29
+ class SK_API MtlTextureInfo final : public TextureInfo::Data {
30
+ public:
28
31
  MTLPixelFormat fFormat = MTLPixelFormatInvalid;
29
32
  MTLTextureUsage fUsage = MTLTextureUsageUnknown;
30
33
  MTLStorageMode fStorageMode = MTLStorageModeShared;
@@ -38,13 +41,34 @@ struct SK_API MtlTextureInfo {
38
41
  MTLTextureUsage usage,
39
42
  MTLStorageMode storageMode,
40
43
  bool framebufferOnly)
41
- : fSampleCount(sampleCount)
42
- , fMipmapped(mipmapped)
44
+ : Data(sampleCount, mipmapped)
43
45
  , fFormat(format)
44
46
  , fUsage(usage)
45
47
  , fStorageMode(storageMode)
46
48
  , fFramebufferOnly(framebufferOnly) {}
49
+
50
+ private:
51
+ friend class TextureInfo;
52
+ friend class TextureInfoPriv;
53
+
54
+ // Non-virtual template API for TextureInfo::Data accessed directly when backend type is known.
55
+ static constexpr skgpu::BackendApi kBackend = skgpu::BackendApi::kMetal;
56
+
57
+ Protected isProtected() const { return Protected::kNo; }
58
+ TextureFormat viewFormat() const;
59
+
60
+ bool serialize(SkWStream*) const;
61
+ bool deserialize(SkStream*);
62
+
63
+ // Virtual API when the specific backend type is not available.
64
+ SkString toBackendString() const override;
65
+
66
+ void copyTo(TextureInfo::AnyTextureInfoData& dstData) const override {
67
+ dstData.emplace<MtlTextureInfo>(*this);
68
+ }
69
+ bool isCompatible(const TextureInfo& that, bool requireExact) const override;
47
70
  };
71
+
48
72
  } // namespace skgpu::graphite
49
73
 
50
74
  #endif // __OBJC__