@shopify/react-native-skia 2.0.0-next.2 → 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 (175) hide show
  1. package/android/build.gradle +14 -10
  2. package/cpp/api/JsiSkCanvas.h +45 -2
  3. package/cpp/api/recorder/Drawings.h +31 -2
  4. package/cpp/api/recorder/Shaders.h +40 -0
  5. package/cpp/skia/include/codec/SkCodec.h +39 -1
  6. package/cpp/skia/include/config/SkUserConfig.h +1 -10
  7. package/cpp/skia/include/core/SkCanvas.h +8 -4
  8. package/cpp/skia/include/core/SkContourMeasure.h +2 -2
  9. package/cpp/skia/include/core/SkMilestone.h +1 -1
  10. package/cpp/skia/include/core/SkPaint.h +8 -5
  11. package/cpp/skia/include/core/SkStream.h +8 -3
  12. package/cpp/skia/include/core/SkTextBlob.h +9 -9
  13. package/cpp/skia/include/core/SkTypeface.h +4 -6
  14. package/cpp/skia/include/core/SkTypes.h +5 -0
  15. package/cpp/skia/include/docs/SkPDFDocument.h +47 -2
  16. package/cpp/skia/include/docs/SkPDFJpegHelpers.h +41 -0
  17. package/cpp/skia/include/effects/SkRuntimeEffect.h +5 -1
  18. package/cpp/skia/include/effects/SkTableMaskFilter.h +4 -0
  19. package/cpp/skia/include/gpu/graphite/BackendTexture.h +0 -2
  20. package/cpp/skia/include/gpu/graphite/ContextOptions.h +17 -0
  21. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +21 -18
  22. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +24 -0
  23. package/cpp/skia/include/gpu/graphite/TextureInfo.h +87 -42
  24. package/cpp/skia/include/gpu/graphite/YUVABackendTextures.h +13 -4
  25. package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +9 -0
  26. package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +166 -0
  27. package/cpp/skia/include/gpu/graphite/dawn/DawnTypes.h +3 -141
  28. package/cpp/skia/include/gpu/graphite/dawn/DawnUtils.h +2 -21
  29. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +4 -0
  30. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +30 -6
  31. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypesUtils.h +4 -42
  32. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes_cpp.h +50 -0
  33. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteUtils.h +2 -20
  34. package/cpp/skia/include/gpu/graphite/precompile/Precompile.h +14 -4
  35. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +14 -6
  36. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteContext.h +31 -0
  37. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +36 -14
  38. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteUtils.h +3 -21
  39. package/cpp/skia/include/ports/SkTypeface_fontations.h +3 -0
  40. package/cpp/skia/include/private/SkJpegMetadataDecoder.h +7 -0
  41. package/cpp/skia/include/private/base/SkAnySubclass.h +6 -0
  42. package/cpp/skia/include/private/chromium/SkPMColor.h +38 -0
  43. package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -2
  44. package/cpp/skia/modules/skunicode/include/SkUnicode.h +10 -6
  45. package/cpp/skia/modules/svg/include/SkSVGDOM.h +1 -3
  46. package/cpp/skia/src/base/SkTInternalLList.h +1 -1
  47. package/cpp/skia/src/core/SkLRUCache.h +6 -3
  48. package/lib/commonjs/external/reanimated/textures.d.ts +2 -4
  49. package/lib/commonjs/external/reanimated/textures.js +8 -15
  50. package/lib/commonjs/external/reanimated/textures.js.map +1 -1
  51. package/lib/commonjs/renderer/Canvas.d.ts +1 -2
  52. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  53. package/lib/commonjs/sksg/HostConfig.js +2 -1
  54. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  55. package/lib/commonjs/sksg/Recorder/Player.d.ts +1 -1
  56. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  57. package/lib/commonjs/sksg/Recorder/commands/Box.js +2 -2
  58. package/lib/commonjs/sksg/Recorder/commands/Box.js.map +1 -1
  59. package/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +1 -3
  60. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +1 -58
  61. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  62. package/lib/module/external/reanimated/textures.d.ts +2 -4
  63. package/lib/module/external/reanimated/textures.js +7 -12
  64. package/lib/module/external/reanimated/textures.js.map +1 -1
  65. package/lib/module/renderer/Canvas.d.ts +1 -2
  66. package/lib/module/renderer/Canvas.js.map +1 -1
  67. package/lib/module/sksg/HostConfig.js +2 -1
  68. package/lib/module/sksg/HostConfig.js.map +1 -1
  69. package/lib/module/sksg/Recorder/Player.d.ts +1 -1
  70. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  71. package/lib/module/sksg/Recorder/commands/Box.js +2 -2
  72. package/lib/module/sksg/Recorder/commands/Box.js.map +1 -1
  73. package/lib/module/sksg/Recorder/commands/Drawing.d.ts +1 -3
  74. package/lib/module/sksg/Recorder/commands/Drawing.js +2 -58
  75. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  76. package/lib/typescript/lib/commonjs/external/reanimated/textures.d.ts +1 -3
  77. package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +1 -1
  78. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +0 -1
  79. package/lib/typescript/lib/module/external/reanimated/textures.d.ts +1 -3
  80. package/lib/typescript/lib/module/sksg/HostConfig.d.ts +1 -1
  81. package/lib/typescript/lib/module/sksg/Recorder/commands/Drawing.d.ts +0 -1
  82. package/lib/typescript/src/external/reanimated/textures.d.ts +2 -4
  83. package/lib/typescript/src/renderer/Canvas.d.ts +1 -2
  84. package/lib/typescript/src/sksg/Recorder/Player.d.ts +1 -1
  85. package/lib/typescript/src/sksg/Recorder/commands/Drawing.d.ts +1 -3
  86. package/libs/android/arm64-v8a/libskia.a +0 -0
  87. package/libs/android/arm64-v8a/libskottie.a +0 -0
  88. package/libs/android/arm64-v8a/libskparagraph.a +0 -0
  89. package/libs/android/arm64-v8a/libsksg.a +0 -0
  90. package/libs/android/arm64-v8a/libskshaper.a +0 -0
  91. package/libs/android/arm64-v8a/libskunicode_icu.a +0 -0
  92. package/libs/android/arm64-v8a/libsvg.a +0 -0
  93. package/libs/android/armeabi-v7a/libskia.a +0 -0
  94. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  95. package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
  96. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  97. package/libs/android/armeabi-v7a/libskshaper.a +0 -0
  98. package/libs/android/armeabi-v7a/libskunicode_icu.a +0 -0
  99. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  100. package/libs/android/x86/libskia.a +0 -0
  101. package/libs/android/x86/libskottie.a +0 -0
  102. package/libs/android/x86/libskparagraph.a +0 -0
  103. package/libs/android/x86/libsksg.a +0 -0
  104. package/libs/android/x86/libskshaper.a +0 -0
  105. package/libs/android/x86/libskunicode_icu.a +0 -0
  106. package/libs/android/x86/libsvg.a +0 -0
  107. package/libs/android/x86_64/libskia.a +0 -0
  108. package/libs/android/x86_64/libskottie.a +0 -0
  109. package/libs/android/x86_64/libskparagraph.a +0 -0
  110. package/libs/android/x86_64/libsksg.a +0 -0
  111. package/libs/android/x86_64/libskshaper.a +0 -0
  112. package/libs/android/x86_64/libskunicode_icu.a +0 -0
  113. package/libs/android/x86_64/libsvg.a +0 -0
  114. package/libs/apple/libskia.xcframework/Info.plist +15 -15
  115. package/libs/apple/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  116. package/libs/apple/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  117. package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
  118. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e/libskia.a +0 -0
  119. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  120. package/libs/apple/libskottie.xcframework/Info.plist +7 -7
  121. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  122. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  123. package/libs/apple/libskottie.xcframework/macos-arm64_x86_64/libskottie.a +0 -0
  124. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e/libskottie.a +0 -0
  125. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  126. package/libs/apple/libskparagraph.xcframework/Info.plist +13 -13
  127. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  128. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  129. package/libs/apple/libskparagraph.xcframework/macos-arm64_x86_64/libskparagraph.a +0 -0
  130. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e/libskparagraph.a +0 -0
  131. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  132. package/libs/apple/libsksg.xcframework/Info.plist +13 -13
  133. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  134. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  135. package/libs/apple/libsksg.xcframework/macos-arm64_x86_64/libsksg.a +0 -0
  136. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e/libsksg.a +0 -0
  137. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  138. package/libs/apple/libskshaper.xcframework/Info.plist +14 -14
  139. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  140. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  141. package/libs/apple/libskshaper.xcframework/macos-arm64_x86_64/libskshaper.a +0 -0
  142. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e/libskshaper.a +0 -0
  143. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  144. package/libs/apple/libskunicode_core.xcframework/Info.plist +12 -12
  145. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e/libskunicode_core.a +0 -0
  146. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  147. package/libs/apple/libskunicode_core.xcframework/macos-arm64_x86_64/libskunicode_core.a +0 -0
  148. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e/libskunicode_core.a +0 -0
  149. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  150. package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +15 -15
  151. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  152. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  153. package/libs/apple/libskunicode_libgrapheme.xcframework/macos-arm64_x86_64/libskunicode_libgrapheme.a +0 -0
  154. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  155. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  156. package/libs/apple/libsvg.xcframework/Info.plist +8 -8
  157. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  158. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  159. package/libs/apple/libsvg.xcframework/macos-arm64_x86_64/libsvg.a +0 -0
  160. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e/libsvg.a +0 -0
  161. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  162. package/package.json +3 -3
  163. package/src/__tests__/snapshots/box/box-shadow-opacity.png +0 -0
  164. package/src/__tests__/snapshots/platform-buffer.png +0 -0
  165. package/src/__tests__/snapshots/screens/snapshot2-android-ci.png +0 -0
  166. package/src/external/reanimated/textures.tsx +12 -20
  167. package/src/renderer/Canvas.tsx +1 -1
  168. package/src/renderer/__tests__/e2e/Box.spec.tsx +22 -0
  169. package/src/renderer/__tests__/e2e/NativeBuffer.spec.tsx +2 -0
  170. package/src/sksg/HostConfig.ts +2 -1
  171. package/src/sksg/Recorder/Player.ts +1 -1
  172. package/src/sksg/Recorder/commands/Box.ts +2 -2
  173. package/src/sksg/Recorder/commands/Drawing.ts +0 -65
  174. package/cpp/skia/include/core/SkColorPriv.h +0 -165
  175. package/cpp/skia/include/private/SkColorData.h +0 -385
@@ -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__
@@ -1,48 +1,10 @@
1
1
  /*
2
- * Copyright 2024 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_MtlGraphiteTypesUtils_DEFINED
9
- #define skgpu_graphite_MtlGraphiteTypesUtils_DEFINED
10
-
11
- #include "include/core/SkTypes.h"
12
-
13
- #include "include/gpu/graphite/BackendTexture.h"
14
- #include "include/gpu/graphite/TextureInfo.h"
15
- #include "include/private/base/SkAPI.h"
16
-
17
- #import <CoreFoundation/CoreFoundation.h>
18
-
19
- namespace skgpu::graphite {
20
-
21
- struct SK_API MtlTextureInfo;
22
-
23
- namespace TextureInfos {
24
- SK_API TextureInfo MakeMetal(const MtlTextureInfo&);
25
- SK_API TextureInfo MakeMetal(CFTypeRef mtlTexture);
26
-
27
- SK_API bool GetMtlTextureInfo(const TextureInfo&, MtlTextureInfo*);
28
- } // namespace TextureInfos
29
-
30
- namespace BackendTextures {
31
- // The BackendTexture will not call retain or release on the passed in CFTypeRef. Thus the
32
- // client must keep the CFTypeRef valid until they are no longer using the BackendTexture.
33
- SK_API BackendTexture MakeMetal(SkISize dimensions, CFTypeRef mtlTexture);
34
-
35
- SK_API CFTypeRef GetMtlTexture(const BackendTexture&);
36
- } // namespace BackendTextures
37
-
38
- namespace BackendSemaphores {
39
- // TODO(b/286088355) Determine creator's responsibility for setting refcnt.
40
- SK_API BackendSemaphore MakeMetal(CFTypeRef mtlEvent, uint64_t value);
41
-
42
- SK_API CFTypeRef GetMtlEvent(const BackendSemaphore&);
43
- SK_API uint64_t GetMtlValue(const BackendSemaphore&);
44
- } // namespace BackendSemaphores
45
-
46
- } // namespace skgpu::graphite
47
-
48
- #endif // skgpu_graphite_MtlGraphiteTypesUtils_DEFINED
8
+ // DEPRECRATED: MtlGraphiteTypesUtils.h will be removed in the future, please include
9
+ // MtlGraphiteTypes_cpp.h
10
+ #include "include/gpu/graphite/mtl/MtlGraphiteTypes_cpp.h"
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright 2024 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_MtlGraphiteTypesUtils_DEFINED
9
+ #define skgpu_graphite_MtlGraphiteTypesUtils_DEFINED
10
+
11
+ #include "include/core/SkTypes.h"
12
+
13
+ #include "include/gpu/graphite/BackendTexture.h"
14
+ #include "include/gpu/graphite/TextureInfo.h"
15
+ #include "include/private/base/SkAPI.h"
16
+
17
+ #import <CoreFoundation/CoreFoundation.h>
18
+
19
+ namespace skgpu::graphite {
20
+
21
+ // MtlTextureInfo requires compiling with Objective-C, so this header is split to allow invoking
22
+ // the various backend wrapping APIs from a C++-only compilation unit.
23
+ class SK_API MtlTextureInfo;
24
+
25
+ namespace TextureInfos {
26
+ SK_API TextureInfo MakeMetal(const MtlTextureInfo&);
27
+ SK_API TextureInfo MakeMetal(CFTypeRef mtlTexture);
28
+
29
+ SK_API bool GetMtlTextureInfo(const TextureInfo&, MtlTextureInfo*);
30
+ } // namespace TextureInfos
31
+
32
+ namespace BackendTextures {
33
+ // The BackendTexture will not call retain or release on the passed in CFTypeRef. Thus the
34
+ // client must keep the CFTypeRef valid until they are no longer using the BackendTexture.
35
+ SK_API BackendTexture MakeMetal(SkISize dimensions, CFTypeRef mtlTexture);
36
+
37
+ SK_API CFTypeRef GetMtlTexture(const BackendTexture&);
38
+ } // namespace BackendTextures
39
+
40
+ namespace BackendSemaphores {
41
+ // TODO(b/286088355) Determine creator's responsibility for setting refcnt.
42
+ SK_API BackendSemaphore MakeMetal(CFTypeRef mtlEvent, uint64_t value);
43
+
44
+ SK_API CFTypeRef GetMtlEvent(const BackendSemaphore&);
45
+ SK_API uint64_t GetMtlValue(const BackendSemaphore&);
46
+ } // namespace BackendSemaphores
47
+
48
+ } // namespace skgpu::graphite
49
+
50
+ #endif // skgpu_graphite_MtlGraphiteTypesUtils_DEFINED
@@ -5,23 +5,5 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
 
8
- #ifndef skgpu_graphite_MtlGraphiteUtils_DEFINED
9
- #define skgpu_graphite_MtlGraphiteUtils_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 MtlBackendContext;
20
-
21
- namespace ContextFactory {
22
- SK_API std::unique_ptr<Context> MakeMetal(const MtlBackendContext&, const ContextOptions&);
23
- } // namespace ContextFactory
24
-
25
- } // namespace skgpu::graphite
26
-
27
- #endif // skgpu_graphite_MtlGraphiteUtils_DEFINED
8
+ // DEPRECRATED: MtlGraphiteUtils.h will be removed in the future, please include MtlBackendContext.h
9
+ #include "include/gpu/graphite/mtl/MtlBackendContext.h"
@@ -8,12 +8,13 @@
8
8
  #ifndef skgpu_graphite_precompile_Precompile_DEFINED
9
9
  #define skgpu_graphite_precompile_Precompile_DEFINED
10
10
 
11
+ #include "include/core/SkColorSpace.h"
12
+ #include "include/core/SkColorType.h"
11
13
  #include "include/core/SkSpan.h"
12
14
  #include "include/gpu/graphite/GraphiteTypes.h"
13
15
 
14
16
  namespace skgpu::graphite {
15
17
 
16
- class Context;
17
18
  class PaintOptions;
18
19
  class PrecompileContext;
19
20
 
@@ -23,9 +24,18 @@ class PrecompileContext;
23
24
  * a pipeline.
24
25
  */
25
26
  struct SK_API RenderPassProperties {
26
- DepthStencilFlags fDSFlags = DepthStencilFlags::kNone;
27
- SkColorType fDstCT = kRGBA_8888_SkColorType;
28
- bool fRequiresMSAA = false;
27
+ bool operator==(const RenderPassProperties& other) const {
28
+ return fDSFlags == other.fDSFlags &&
29
+ fDstCT == other.fDstCT &&
30
+ fRequiresMSAA == other.fRequiresMSAA &&
31
+ SkColorSpace::Equals(fDstCS.get(), other.fDstCS.get());
32
+ }
33
+ bool operator!= (const RenderPassProperties& other) const { return !(*this == other); }
34
+
35
+ DepthStencilFlags fDSFlags = DepthStencilFlags::kNone;
36
+ SkColorType fDstCT = kRGBA_8888_SkColorType;
37
+ sk_sp<SkColorSpace> fDstCS = nullptr;
38
+ bool fRequiresMSAA = false;
29
39
  };
30
40
 
31
41
  /**
@@ -11,6 +11,8 @@
11
11
  #include "include/gpu/graphite/precompile/PrecompileBase.h"
12
12
 
13
13
  #include "include/core/SkBlendMode.h"
14
+ #include "include/core/SkImageInfo.h"
15
+ #include "include/effects/SkGradientShader.h"
14
16
 
15
17
  class SkColorSpace;
16
18
 
@@ -109,11 +111,13 @@ namespace PrecompileShaders {
109
111
  // time this entry point allows the equivalent precompilation program structure to be created.
110
112
  // Note that this factory is for non-YUV SkImages, the YUVImage factory (below) should be used
111
113
  // to represent the shading and sampling required for YUV images.
112
- SK_API sk_sp<PrecompileShader> Image();
114
+ SK_API sk_sp<PrecompileShader> Image(SkSpan<const SkColorInfo> = {},
115
+ SkSpan<const SkTileMode> = {});
113
116
  // As with the above Image call, raw ImageShaders are usually created via an
114
117
  // SkImage::makeRawShader call. The RawImage call allows the equivalent precompilation
115
118
  // program structure to be created without needing the SkImage.
116
- SK_API sk_sp<PrecompileShader> RawImage();
119
+ SK_API sk_sp<PrecompileShader> RawImage(SkSpan<const SkColorInfo> = {},
120
+ SkSpan<const SkTileMode> = {});
117
121
 
118
122
  // In the main Skia API, the specifics of the SkImage used for the SkImage::makeShader call
119
123
  // can determine whether normal or YUV sampling is required. This entry point allows clients
@@ -126,10 +130,14 @@ namespace PrecompileShaders {
126
130
  SK_API sk_sp<PrecompileShader> MakeTurbulence();
127
131
 
128
132
  // --- This block of four matches all the factories in SkGradientShader (SkGradientShader.h)
129
- SK_API sk_sp<PrecompileShader> LinearGradient();
130
- SK_API sk_sp<PrecompileShader> RadialGradient();
131
- SK_API sk_sp<PrecompileShader> TwoPointConicalGradient();
132
- SK_API sk_sp<PrecompileShader> SweepGradient();
133
+ SK_API sk_sp<PrecompileShader> LinearGradient(
134
+ SkGradientShader::Interpolation = SkGradientShader::Interpolation());
135
+ SK_API sk_sp<PrecompileShader> RadialGradient(
136
+ SkGradientShader::Interpolation = SkGradientShader::Interpolation());
137
+ SK_API sk_sp<PrecompileShader> TwoPointConicalGradient(
138
+ SkGradientShader::Interpolation = SkGradientShader::Interpolation());
139
+ SK_API sk_sp<PrecompileShader> SweepGradient(
140
+ SkGradientShader::Interpolation = SkGradientShader::Interpolation());
133
141
 
134
142
  // Normally, SkPicture shaders are only created via SkPicture::makeShader. Since the
135
143
  // SkPicture to be drawn, most likely, won't be available at precompilation time, this
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Copyright 2022 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_VulkanGraphiteUtils_DEFINED
9
+ #define skgpu_graphite_VulkanGraphiteUtils_DEFINED
10
+
11
+ #include <memory>
12
+
13
+ #include "include/private/base/SkAPI.h"
14
+
15
+ // NOTE: Because there is already a VulkanBackendContext header shared between Ganesh and Graphite,
16
+ // this is named VulkanGraphiteContext.h to supply just the factory function (differing from the
17
+ // public headers exposed by other backends).
18
+ namespace skgpu { struct VulkanBackendContext; }
19
+
20
+ namespace skgpu::graphite {
21
+
22
+ class Context;
23
+ struct ContextOptions;
24
+
25
+ namespace ContextFactory {
26
+ SK_API std::unique_ptr<Context> MakeVulkan(const VulkanBackendContext&, const ContextOptions&);
27
+ } // namespace ContextFactory
28
+
29
+ } // namespace skgpu::graphite
30
+
31
+ #endif // skgpu_graphite_VulkanGraphiteUtils_DEFINED
@@ -13,20 +13,21 @@
13
13
  #include "include/gpu/graphite/TextureInfo.h"
14
14
  #include "include/gpu/vk/VulkanTypes.h"
15
15
 
16
- namespace skgpu::graphite {
16
+ class SkStream;
17
+ class SkWStream;
17
18
 
18
- struct VulkanTextureInfo {
19
- uint32_t fSampleCount = 1;
20
- Mipmapped fMipmapped = Mipmapped::kNo;
19
+ namespace skgpu::graphite {
21
20
 
21
+ class SK_API VulkanTextureInfo final : public TextureInfo::Data {
22
+ public:
22
23
  // VkImageCreateInfo properties
23
24
  // Currently the only supported flag is VK_IMAGE_CREATE_PROTECTED_BIT. Any other flag will not
24
25
  // be accepted
25
- VkImageCreateFlags fFlags = 0;
26
- VkFormat fFormat = VK_FORMAT_UNDEFINED;
27
- VkImageTiling fImageTiling = VK_IMAGE_TILING_OPTIMAL;
28
- VkImageUsageFlags fImageUsageFlags = 0;
29
- VkSharingMode fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
26
+ VkImageCreateFlags fFlags = 0;
27
+ VkFormat fFormat = VK_FORMAT_UNDEFINED;
28
+ VkImageTiling fImageTiling = VK_IMAGE_TILING_OPTIMAL;
29
+ VkImageUsageFlags fImageUsageFlags = 0;
30
+ VkSharingMode fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
30
31
 
31
32
  // Properties related to the image view and sampling. These are less inherent properties of the
32
33
  // VkImage but describe how the VkImage should be used within Skia.
@@ -35,8 +36,8 @@ struct VulkanTextureInfo {
35
36
  // However, if the VkImage is a Ycbcr format, the client can pass a specific plan here to have
36
37
  // Skia directly sample a plane. In that case the client should also pass in a VkFormat that is
37
38
  // compatible with the plane as described by the Vulkan spec.
38
- VkImageAspectFlags fAspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
39
- VulkanYcbcrConversionInfo fYcbcrConversionInfo;
39
+ VkImageAspectFlags fAspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
40
+ VulkanYcbcrConversionInfo fYcbcrConversionInfo;
40
41
 
41
42
  VulkanTextureInfo() = default;
42
43
  VulkanTextureInfo(uint32_t sampleCount,
@@ -48,8 +49,7 @@ struct VulkanTextureInfo {
48
49
  VkSharingMode sharingMode,
49
50
  VkImageAspectFlags aspectMask,
50
51
  VulkanYcbcrConversionInfo ycbcrConversionInfo)
51
- : fSampleCount(sampleCount)
52
- , fMipmapped(mipmapped)
52
+ : Data(sampleCount, mipmapped)
53
53
  , fFlags(flags)
54
54
  , fFormat(format)
55
55
  , fImageTiling(imageTiling)
@@ -57,6 +57,29 @@ struct VulkanTextureInfo {
57
57
  , fSharingMode(sharingMode)
58
58
  , fAspectMask(aspectMask)
59
59
  , fYcbcrConversionInfo(ycbcrConversionInfo) {}
60
+
61
+ private:
62
+ friend class TextureInfo;
63
+ friend class TextureInfoPriv;
64
+
65
+ // Non-virtual template API for TextureInfo::Data accessed directly when backend type is known.
66
+ static constexpr skgpu::BackendApi kBackend = skgpu::BackendApi::kVulkan;
67
+
68
+ Protected isProtected() const {
69
+ return fFlags & VK_IMAGE_CREATE_PROTECTED_BIT ? Protected::kYes : Protected::kNo;
70
+ }
71
+ TextureFormat viewFormat() const;
72
+
73
+ bool serialize(SkWStream*) const;
74
+ bool deserialize(SkStream*);
75
+
76
+ // Virtual API when the specific backend type is not available.
77
+ SkString toBackendString() const override;
78
+
79
+ void copyTo(TextureInfo::AnyTextureInfoData& dstData) const override {
80
+ dstData.emplace<VulkanTextureInfo>(*this);
81
+ }
82
+ bool isCompatible(const TextureInfo& that, bool requireExact) const override;
60
83
  };
61
84
 
62
85
  namespace TextureInfos {
@@ -78,7 +101,6 @@ namespace BackendSemaphores {
78
101
  SK_API BackendSemaphore MakeVulkan(VkSemaphore);
79
102
 
80
103
  SK_API VkSemaphore GetVkSemaphore(const BackendSemaphore&);
81
-
82
104
  } // namespace BackendSemaphores
83
105
 
84
106
  } // namespace skgpu::graphite
@@ -5,24 +5,6 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
 
8
- #ifndef skgpu_graphite_VulkanGraphiteUtils_DEFINED
9
- #define skgpu_graphite_VulkanGraphiteUtils_DEFINED
10
-
11
- #include <memory>
12
-
13
- #include "include/private/base/SkAPI.h"
14
-
15
- namespace skgpu { struct VulkanBackendContext; }
16
-
17
- namespace skgpu::graphite {
18
-
19
- class Context;
20
- struct ContextOptions;
21
-
22
- namespace ContextFactory {
23
- SK_API std::unique_ptr<Context> MakeVulkan(const VulkanBackendContext&, const ContextOptions&);
24
- } // namespace ContextFactory
25
-
26
- } // namespace skgpu::graphite
27
-
28
- #endif // skgpu_graphite_VulkanGraphiteUtils_DEFINED
8
+ // DEPRECRATED: VulkanGraphiteUtils.h will be removed in the future, please include
9
+ // VulkanGraphiteContext.h
10
+ #include "include/gpu/graphite/vk/VulkanGraphiteContext.h"
@@ -18,4 +18,7 @@
18
18
  SK_API sk_sp<SkTypeface> SkTypeface_Make_Fontations(std::unique_ptr<SkStreamAsset> fontData,
19
19
  const SkFontArguments& args);
20
20
 
21
+ SK_API sk_sp<SkTypeface> SkTypeface_Make_Fontations(sk_sp<SkData> fontData,
22
+ const SkFontArguments& args);
23
+
21
24
  #endif
@@ -86,6 +86,13 @@ public:
86
86
  virtual bool findGainmapImage(sk_sp<SkData> baseImageData,
87
87
  sk_sp<SkData>& outGainmapImagedata,
88
88
  SkGainmapInfo& outGainmapInfo) = 0;
89
+
90
+ /**
91
+ * Return the first JUMBF superbox, if any, and nullptr otherwise. If |copyData| is false,
92
+ * then the returned SkData may directly reference the data provided when this object was
93
+ * created.
94
+ */
95
+ virtual sk_sp<SkData> getJUMBFMetadata(bool copyData) const = 0;
89
96
  };
90
97
 
91
98
  #endif
@@ -52,6 +52,9 @@ public:
52
52
  fValid = false;
53
53
  }
54
54
 
55
+ bool has_value() const { return fValid; }
56
+ explicit operator bool() const { return this->has_value(); }
57
+
55
58
  const Base* get() const {
56
59
  SkASSERT(fValid);
57
60
  return std::launder(reinterpret_cast<const Base*>(fData));
@@ -65,6 +68,9 @@ public:
65
68
  Base* operator->() { return this->get(); }
66
69
  const Base* operator->() const { return this->get(); }
67
70
 
71
+ Base& operator*() { return *this->get(); }
72
+ const Base& operator*() const { return *this->get(); }
73
+
68
74
  private:
69
75
  alignas(8) std::byte fData[Size];
70
76
  bool fValid = false;