@shopify/react-native-skia 2.0.0-next.3 → 2.0.0-next.5
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.
- package/apple/RNSkApplePlatformContext.h +2 -1
- package/apple/RNSkApplePlatformContext.mm +6 -4
- package/apple/RNSkAppleView.h +1 -1
- package/apple/RNSkAppleView.mm +1 -1
- package/apple/SkiaManager.mm +2 -1
- package/apple/SkiaUIView.h +1 -1
- package/cpp/api/JsiSkCanvas.h +29 -25
- package/cpp/api/recorder/Drawings.h +13 -17
- package/cpp/api/recorder/Shaders.h +21 -32
- package/cpp/skia/include/codec/SkCodec.h +39 -1
- package/cpp/skia/include/config/SkUserConfig.h +1 -10
- package/cpp/skia/include/core/SkCanvas.h +8 -4
- package/cpp/skia/include/core/SkContourMeasure.h +2 -2
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkPaint.h +8 -5
- package/cpp/skia/include/core/SkStream.h +8 -3
- package/cpp/skia/include/core/SkTextBlob.h +9 -9
- package/cpp/skia/include/core/SkTypeface.h +4 -6
- package/cpp/skia/include/core/SkTypes.h +5 -0
- package/cpp/skia/include/docs/SkPDFDocument.h +47 -2
- package/cpp/skia/include/docs/SkPDFJpegHelpers.h +41 -0
- package/cpp/skia/include/effects/SkRuntimeEffect.h +5 -1
- package/cpp/skia/include/effects/SkTableMaskFilter.h +4 -0
- package/cpp/skia/include/gpu/graphite/BackendTexture.h +0 -2
- package/cpp/skia/include/gpu/graphite/ContextOptions.h +17 -0
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +21 -18
- package/cpp/skia/include/gpu/graphite/PrecompileContext.h +24 -0
- package/cpp/skia/include/gpu/graphite/TextureInfo.h +87 -42
- package/cpp/skia/include/gpu/graphite/YUVABackendTextures.h +13 -4
- package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +9 -0
- package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +166 -0
- package/cpp/skia/include/gpu/graphite/dawn/DawnTypes.h +3 -141
- package/cpp/skia/include/gpu/graphite/dawn/DawnUtils.h +2 -21
- package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +4 -0
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +30 -6
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypesUtils.h +4 -42
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes_cpp.h +50 -0
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteUtils.h +2 -20
- package/cpp/skia/include/gpu/graphite/precompile/Precompile.h +14 -4
- package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +14 -6
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteContext.h +31 -0
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +36 -14
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteUtils.h +3 -21
- package/cpp/skia/include/ports/SkTypeface_fontations.h +3 -0
- package/cpp/skia/include/private/SkJpegMetadataDecoder.h +7 -0
- package/cpp/skia/include/private/base/SkAnySubclass.h +6 -0
- package/cpp/skia/include/private/chromium/SkPMColor.h +38 -0
- package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -2
- package/cpp/skia/modules/skunicode/include/SkUnicode.h +10 -6
- package/cpp/skia/modules/svg/include/SkSVGDOM.h +1 -3
- package/cpp/skia/src/base/SkTInternalLList.h +1 -1
- package/cpp/skia/src/core/SkLRUCache.h +6 -3
- package/lib/commonjs/external/reanimated/textures.d.ts +2 -4
- package/lib/commonjs/external/reanimated/textures.js +8 -15
- package/lib/commonjs/external/reanimated/textures.js.map +1 -1
- package/lib/commonjs/sksg/HostConfig.js +2 -1
- package/lib/commonjs/sksg/HostConfig.js.map +1 -1
- package/lib/module/external/reanimated/textures.d.ts +2 -4
- package/lib/module/external/reanimated/textures.js +7 -12
- package/lib/module/external/reanimated/textures.js.map +1 -1
- package/lib/module/sksg/HostConfig.js +2 -1
- package/lib/module/sksg/HostConfig.js.map +1 -1
- package/lib/typescript/lib/commonjs/external/reanimated/textures.d.ts +1 -3
- package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +1 -1
- package/lib/typescript/lib/module/external/reanimated/textures.d.ts +1 -3
- package/lib/typescript/lib/module/sksg/HostConfig.d.ts +1 -1
- package/lib/typescript/src/external/reanimated/textures.d.ts +2 -4
- package/libs/android/arm64-v8a/libskia.a +0 -0
- package/libs/android/arm64-v8a/libskottie.a +0 -0
- package/libs/android/arm64-v8a/libskparagraph.a +0 -0
- package/libs/android/arm64-v8a/libsksg.a +0 -0
- package/libs/android/arm64-v8a/libskshaper.a +0 -0
- package/libs/android/arm64-v8a/libskunicode_icu.a +0 -0
- package/libs/android/arm64-v8a/libsvg.a +0 -0
- package/libs/android/armeabi-v7a/libskia.a +0 -0
- package/libs/android/armeabi-v7a/libskottie.a +0 -0
- package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
- package/libs/android/armeabi-v7a/libsksg.a +0 -0
- package/libs/android/armeabi-v7a/libskshaper.a +0 -0
- package/libs/android/armeabi-v7a/libskunicode_icu.a +0 -0
- package/libs/android/armeabi-v7a/libsvg.a +0 -0
- package/libs/android/x86/libskia.a +0 -0
- package/libs/android/x86/libskottie.a +0 -0
- package/libs/android/x86/libskparagraph.a +0 -0
- package/libs/android/x86/libsksg.a +0 -0
- package/libs/android/x86/libskshaper.a +0 -0
- package/libs/android/x86/libskunicode_icu.a +0 -0
- package/libs/android/x86/libsvg.a +0 -0
- package/libs/android/x86_64/libskia.a +0 -0
- package/libs/android/x86_64/libskottie.a +0 -0
- package/libs/android/x86_64/libskparagraph.a +0 -0
- package/libs/android/x86_64/libsksg.a +0 -0
- package/libs/android/x86_64/libskshaper.a +0 -0
- package/libs/android/x86_64/libskunicode_icu.a +0 -0
- package/libs/android/x86_64/libsvg.a +0 -0
- package/libs/apple/libskia.xcframework/Info.plist +15 -15
- package/libs/apple/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/tvos-arm64_arm64e/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/apple/libskottie.xcframework/Info.plist +7 -7
- package/libs/apple/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/macos-arm64_x86_64/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/apple/libskparagraph.xcframework/Info.plist +13 -13
- package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/macos-arm64_x86_64/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
- package/libs/apple/libsksg.xcframework/Info.plist +13 -13
- package/libs/apple/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/macos-arm64_x86_64/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/apple/libskshaper.xcframework/Info.plist +14 -14
- package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/macos-arm64_x86_64/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/Info.plist +12 -12
- package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/macos-arm64_x86_64/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +15 -15
- package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/macos-arm64_x86_64/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libsvg.xcframework/Info.plist +8 -8
- package/libs/apple/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/macos-arm64_x86_64/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +1 -1
- package/src/external/reanimated/textures.tsx +12 -20
- package/src/sksg/HostConfig.ts +2 -1
- package/cpp/skia/include/core/SkColorPriv.h +0 -165
- package/cpp/skia/include/private/SkColorData.h +0 -385
@@ -16,9 +16,12 @@
|
|
16
16
|
#include <vector>
|
17
17
|
|
18
18
|
class SkCanvas;
|
19
|
+
class SkCodec;
|
20
|
+
class SkData;
|
19
21
|
class SkExecutor;
|
20
22
|
class SkPDFArray;
|
21
23
|
class SkPDFStructTree;
|
24
|
+
class SkPixmap;
|
22
25
|
class SkWStream;
|
23
26
|
|
24
27
|
#define SKPDF_STRING(X) SKPDF_STRING_IMPL(X)
|
@@ -80,6 +83,9 @@ struct DateTime {
|
|
80
83
|
void toISO8601(SkString* dst) const;
|
81
84
|
};
|
82
85
|
|
86
|
+
using DecodeJpegCallback = std::unique_ptr<SkCodec> (*)(sk_sp<SkData>);
|
87
|
+
using EncodeJpegCallback = bool (*)(SkWStream* dst, const SkPixmap& src, int quality);
|
88
|
+
|
83
89
|
/** Optional metadata to be passed into the PDF factory function.
|
84
90
|
*/
|
85
91
|
struct Metadata {
|
@@ -157,6 +163,7 @@ struct Metadata {
|
|
157
163
|
enum class Outline : int {
|
158
164
|
None = 0,
|
159
165
|
StructureElementHeaders = 1,
|
166
|
+
StructureElements = 2,
|
160
167
|
} fOutline = Outline::None;
|
161
168
|
|
162
169
|
/** Executor to handle threaded work within PDF Backend. If this is nullptr,
|
@@ -186,14 +193,50 @@ struct Metadata {
|
|
186
193
|
enum Subsetter {
|
187
194
|
kHarfbuzz_Subsetter,
|
188
195
|
} fSubsetter = kHarfbuzz_Subsetter;
|
196
|
+
|
197
|
+
/** Clients can provide a way to decode jpeg. To use Skia's JPEG decoder, pass in
|
198
|
+
SkJpegDecoder::Decode. If not supplied, all images will need to be re-encoded
|
199
|
+
as jpegs or deflated images before embedding. If supplied, Skia may be able to
|
200
|
+
skip the re-encoding step.
|
201
|
+
Skia's JPEG decoder can be used here.
|
202
|
+
*/
|
203
|
+
SkPDF::DecodeJpegCallback jpegDecoder = nullptr;
|
204
|
+
|
205
|
+
/** Clients can provide a way to encode jpeg. If not supplied, images will be embedded
|
206
|
+
as a deflated image, potentially making them much larger. If clients provide
|
207
|
+
their own implementation, JPEGs should be encoded to RGB (not YUV) otherwise they
|
208
|
+
will have the wrong surrounding metadata provided by Skia.
|
209
|
+
Skia's JPEG encoder can be used here.
|
210
|
+
*/
|
211
|
+
SkPDF::EncodeJpegCallback jpegEncoder = nullptr;
|
212
|
+
|
213
|
+
// Skia's PDF support depends on having both a jpeg encoder and decoder for writing
|
214
|
+
// compact PDFs. It will technically work, but produce larger than optimal PDFs
|
215
|
+
// if either the decoder or encoder are left as nullptr. If clients will be creating
|
216
|
+
// PDFs that don't use images or otherwise want to incur this cost (with the upside
|
217
|
+
// of not having a jpeg library), they should set this to true to avoid an internal
|
218
|
+
// assert from firing.
|
219
|
+
bool allowNoJpegs = false;
|
189
220
|
};
|
190
221
|
|
222
|
+
namespace NodeID {
|
223
|
+
static const constexpr int Nothing = 0;
|
224
|
+
static const constexpr int OtherArtifact = -1;
|
225
|
+
static const constexpr int PaginationArtifact = -2;
|
226
|
+
static const constexpr int PaginationHeaderArtifact = -3;
|
227
|
+
static const constexpr int PaginationFooterArtifact = -4;
|
228
|
+
static const constexpr int PaginationWatermarkArtifact = -5;
|
229
|
+
static const constexpr int LayoutArtifact = -6;
|
230
|
+
static const constexpr int PageArtifact = -7;
|
231
|
+
static const constexpr int BackgroundArtifact = -8;
|
232
|
+
} // namespace NodeID
|
233
|
+
|
191
234
|
/** Associate a node ID with subsequent drawing commands in an
|
192
235
|
SkCanvas. The same node ID can appear in a StructureElementNode
|
193
236
|
in order to associate a document's structure element tree with
|
194
237
|
its content.
|
195
238
|
|
196
|
-
A node ID of zero indicates no node ID.
|
239
|
+
A node ID of zero indicates no node ID. Negative node IDs are reserved.
|
197
240
|
|
198
241
|
@param canvas The canvas used to draw to the PDF.
|
199
242
|
@param nodeId The node ID for subsequent drawing commands.
|
@@ -207,15 +250,17 @@ SK_API void SetNodeId(SkCanvas* dst, int nodeID);
|
|
207
250
|
@param stream A PDF document will be written to this stream. The document may write
|
208
251
|
to the stream at anytime during its lifetime, until either close() is
|
209
252
|
called or the document is deleted.
|
210
|
-
@param metadata a PDFmetadata object.
|
253
|
+
@param metadata a PDFmetadata object. Some fields may be left empty.
|
211
254
|
|
212
255
|
@returns NULL if there is an error, otherwise a newly created PDF-backed SkDocument.
|
213
256
|
*/
|
214
257
|
SK_API sk_sp<SkDocument> MakeDocument(SkWStream* stream, const Metadata& metadata);
|
215
258
|
|
259
|
+
#if !defined(SK_DISABLE_LEGACY_PDF_JPEG)
|
216
260
|
static inline sk_sp<SkDocument> MakeDocument(SkWStream* stream) {
|
217
261
|
return MakeDocument(stream, Metadata());
|
218
262
|
}
|
263
|
+
#endif
|
219
264
|
|
220
265
|
} // namespace SkPDF
|
221
266
|
|
@@ -0,0 +1,41 @@
|
|
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
|
+
#ifndef SkPDFJPEGHelpers_DEFINED
|
8
|
+
#define SkPDFJPEGHelpers_DEFINED
|
9
|
+
|
10
|
+
#include "include/codec/SkJpegDecoder.h"
|
11
|
+
#include "include/core/SkData.h"
|
12
|
+
#include "include/core/SkRefCnt.h"
|
13
|
+
#include "include/docs/SkPDFDocument.h"
|
14
|
+
#include "include/encode/SkJpegEncoder.h"
|
15
|
+
|
16
|
+
class SkPixmap;
|
17
|
+
class SkWStream;
|
18
|
+
|
19
|
+
#include <memory>
|
20
|
+
|
21
|
+
namespace SkPDF::JPEG {
|
22
|
+
inline std::unique_ptr<SkCodec> Decode(sk_sp<SkData> data) {
|
23
|
+
return SkJpegDecoder::Decode(data, nullptr, nullptr);
|
24
|
+
}
|
25
|
+
|
26
|
+
inline bool Encode(SkWStream* dst, const SkPixmap& src, int quality) {
|
27
|
+
SkJpegEncoder::Options jOpts;
|
28
|
+
jOpts.fQuality = quality;
|
29
|
+
return SkJpegEncoder::Encode(dst, src, jOpts);
|
30
|
+
}
|
31
|
+
|
32
|
+
inline SkPDF::Metadata MetadataWithCallbacks() {
|
33
|
+
SkPDF::Metadata m;
|
34
|
+
m.jpegDecoder = SkPDF::JPEG::Decode;
|
35
|
+
m.jpegEncoder = SkPDF::JPEG::Encode;
|
36
|
+
return m;
|
37
|
+
}
|
38
|
+
|
39
|
+
} // namespace SkPDF::JPEG
|
40
|
+
|
41
|
+
#endif
|
@@ -126,6 +126,8 @@ public:
|
|
126
126
|
// don't run the inliner directly, but they still get an inlining pass once they are
|
127
127
|
// painted.)
|
128
128
|
bool forceUnoptimized = false;
|
129
|
+
// When possible this name will be used to identify the created runtime effect.
|
130
|
+
std::string_view fName;
|
129
131
|
|
130
132
|
private:
|
131
133
|
friend class SkRuntimeEffect;
|
@@ -317,7 +319,9 @@ private:
|
|
317
319
|
friend class SkRuntimeEffectPriv;
|
318
320
|
|
319
321
|
uint32_t fHash;
|
320
|
-
|
322
|
+
// When not 0, this field holds a StableKey value or a user-defined stable key
|
323
|
+
uint32_t fStableKey = 0;
|
324
|
+
SkString fName;
|
321
325
|
|
322
326
|
std::unique_ptr<SkSL::Program> fBaseProgram;
|
323
327
|
std::unique_ptr<SkSL::RP::Program> fRPProgram;
|
@@ -17,7 +17,6 @@
|
|
17
17
|
namespace skgpu::graphite {
|
18
18
|
|
19
19
|
class BackendTextureData;
|
20
|
-
struct VulkanTextureInfo;
|
21
20
|
|
22
21
|
class SK_API BackendTexture {
|
23
22
|
public:
|
@@ -61,4 +60,3 @@ private:
|
|
61
60
|
} // namespace skgpu::graphite
|
62
61
|
|
63
62
|
#endif // skgpu_graphite_BackendTexture_DEFINED
|
64
|
-
|
@@ -9,12 +9,14 @@
|
|
9
9
|
#define skgpu_graphite_ContextOptions_DEFINED
|
10
10
|
|
11
11
|
#include "include/core/SkRefCnt.h"
|
12
|
+
#include "include/core/SkSpan.h"
|
12
13
|
#include "include/private/base/SkAPI.h"
|
13
14
|
#include "include/private/base/SkMath.h"
|
14
15
|
|
15
16
|
#include <optional>
|
16
17
|
|
17
18
|
class SkData;
|
19
|
+
class SkRuntimeEffect;
|
18
20
|
namespace skgpu { class ShaderErrorHandler; }
|
19
21
|
|
20
22
|
namespace skgpu::graphite {
|
@@ -136,6 +138,21 @@ struct SK_API ContextOptions {
|
|
136
138
|
PipelineCallbackContext fPipelineCallbackContext = nullptr;
|
137
139
|
PipelineCallback fPipelineCallback = nullptr;
|
138
140
|
|
141
|
+
/**
|
142
|
+
* The runtime effects provided here will be registered as user-defined *known* runtime
|
143
|
+
* effects and will be given a stable key. Such runtime effects can then be used in
|
144
|
+
* serialized pipeline keys (c.f. PrecompileContext::precompile).
|
145
|
+
*
|
146
|
+
* Graphite will take a ref on the provided runtime effects and they will persist for as long
|
147
|
+
* as the Context exists. Rather than recreating new SkRuntimeEffects using the same SkSL,
|
148
|
+
* clients should use the existing SkRuntimeEffects provided here.
|
149
|
+
*
|
150
|
+
* Warning: Registering runtime effects here does obligate users to clear out their caches
|
151
|
+
* of serialized pipeline keys if the provided runtime effects ever change in a meaningful way.
|
152
|
+
* This includes adding, removing or reordering the effects provided here.
|
153
|
+
*/
|
154
|
+
SkSpan<sk_sp<SkRuntimeEffect>> fUserDefinedKnownRuntimeEffects;
|
155
|
+
|
139
156
|
/**
|
140
157
|
* Private options that are only meant for testing within Skia's tools.
|
141
158
|
*/
|
@@ -140,44 +140,47 @@ enum class DepthStencilFlags : int {
|
|
140
140
|
*/
|
141
141
|
enum DrawTypeFlags : uint16_t {
|
142
142
|
|
143
|
-
kNone =
|
143
|
+
kNone = 0,
|
144
144
|
|
145
145
|
// kBitmapText_Mask should be used for the BitmapTextRenderStep[mask] RenderStep
|
146
|
-
kBitmapText_Mask =
|
146
|
+
kBitmapText_Mask = 1 << 0,
|
147
147
|
// kBitmapText_LCD should be used for the BitmapTextRenderStep[LCD] RenderStep
|
148
|
-
kBitmapText_LCD =
|
148
|
+
kBitmapText_LCD = 1 << 1,
|
149
149
|
// kBitmapText_Color should be used for the BitmapTextRenderStep[color] RenderStep
|
150
|
-
kBitmapText_Color =
|
150
|
+
kBitmapText_Color = 1 << 2,
|
151
151
|
// kSDFText should be used for the SDFTextRenderStep RenderStep
|
152
|
-
kSDFText =
|
152
|
+
kSDFText = 1 << 3,
|
153
153
|
// kSDFText_LCD should be used for the SDFTextLCDRenderStep RenderStep
|
154
|
-
kSDFText_LCD =
|
154
|
+
kSDFText_LCD = 1 << 4,
|
155
155
|
|
156
156
|
// kDrawVertices should be used to generate Pipelines that use the following RenderSteps:
|
157
157
|
// VerticesRenderStep[*] for:
|
158
|
-
// [
|
159
|
-
// [
|
160
|
-
kDrawVertices =
|
158
|
+
// [Tris], [TrisTexCoords], [TrisColor], [TrisColorTexCoords],
|
159
|
+
// [Tristrips], [TristripsTexCoords], [TristripsColor], [TristripsColorTexCoords]
|
160
|
+
kDrawVertices = 1 << 5,
|
161
|
+
|
162
|
+
// kCircularArc renders filled circular arcs, with or without the center included, and
|
163
|
+
// stroked circular arcs with butt or round caps that don't include the center point.
|
164
|
+
// It corresponds to the CircularArcRenderStep.
|
165
|
+
kCircularArc = 1 << 6,
|
161
166
|
|
162
167
|
// kSimpleShape should be used to generate Pipelines that use the following RenderSteps:
|
163
|
-
// AnalyticBlurRenderStep
|
164
168
|
// AnalyticRRectRenderStep
|
165
169
|
// PerEdgeAAQuadRenderStep
|
166
|
-
// CoverBoundsRenderStep[
|
167
|
-
kSimpleShape =
|
170
|
+
// CoverBoundsRenderStep[NonAAFill]
|
171
|
+
kSimpleShape = 1 << 7,
|
168
172
|
|
169
173
|
// kNonSimpleShape should be used to generate Pipelines that use the following RenderSteps:
|
170
174
|
// CoverageMaskRenderStep
|
171
|
-
// CoverBoundsRenderStep[*] for [
|
175
|
+
// CoverBoundsRenderStep[*] for [InverseCover], [RegularCover]
|
172
176
|
// TessellateStrokeRenderStep
|
173
|
-
// TessellateWedgesRenderStep[*] for [
|
174
|
-
// TessellateCurvesRenderStep[*] for [
|
175
|
-
// MiddleOutFanRenderStep[*] for [
|
176
|
-
kNonSimpleShape =
|
177
|
+
// TessellateWedgesRenderStep[*] for [Convex], [EvenOdd], [Winding]
|
178
|
+
// TessellateCurvesRenderStep[*] for [EvenOdd], [Winding]
|
179
|
+
// MiddleOutFanRenderStep[*] for [EvenOdd], [Winding]
|
180
|
+
kNonSimpleShape = 1 << 8,
|
177
181
|
|
178
182
|
kLast = kNonSimpleShape,
|
179
183
|
};
|
180
|
-
static constexpr int kDrawTypeFlagsCnt = static_cast<int>(DrawTypeFlags::kLast) + 1;
|
181
184
|
|
182
185
|
} // namespace skgpu::graphite
|
183
186
|
|
@@ -14,6 +14,8 @@
|
|
14
14
|
#include <chrono>
|
15
15
|
#include <memory>
|
16
16
|
|
17
|
+
class SkData;
|
18
|
+
|
17
19
|
namespace skgpu::graphite {
|
18
20
|
|
19
21
|
class SharedContext;
|
@@ -32,6 +34,28 @@ public:
|
|
32
34
|
*/
|
33
35
|
void purgePipelinesNotUsedInMs(std::chrono::milliseconds msNotUsed);
|
34
36
|
|
37
|
+
/**
|
38
|
+
* Emit histograms (using the SK_HISTOGRAM* macros) for Skia's Pipeline usage.
|
39
|
+
*/
|
40
|
+
void reportPipelineStats();
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Precompile one specific Pipeline that has been previously serialized. Serialized pipeline
|
44
|
+
* keys can be acquired via the ContextOptions::PipelineCallback.
|
45
|
+
*
|
46
|
+
* @param serializedPipelineKey serialized Pipeline key.
|
47
|
+
* @return true if a Pipeline was created from the key; false otherwise
|
48
|
+
*/
|
49
|
+
bool precompile(sk_sp<SkData> serializedPipelineKey);
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Get a human-readable version of a serialized pipeline key.
|
53
|
+
*
|
54
|
+
* @param serializedPipelineKey serialized Pipeline key.
|
55
|
+
* @return A human-readable version of the provided key; "" on failure.
|
56
|
+
*/
|
57
|
+
std::string getPipelineLabel(sk_sp<SkData> serializedPipelineKey);
|
58
|
+
|
35
59
|
// Provides access to functions that aren't part of the public API.
|
36
60
|
PrecompileContextPriv priv();
|
37
61
|
const PrecompileContextPriv priv() const; // NOLINT(readability-const-return-type)
|
@@ -18,70 +18,115 @@ struct SkISize;
|
|
18
18
|
|
19
19
|
namespace skgpu::graphite {
|
20
20
|
|
21
|
-
class
|
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
|
34
|
-
BackendApi backend() const {
|
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
|
-
|
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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
72
|
-
|
73
|
-
size_t bytesPerPixel() const;
|
120
|
+
bool isCompatible(const TextureInfo& that, bool requireExact) const;
|
74
121
|
|
75
|
-
BackendApi
|
76
|
-
|
122
|
+
skgpu::BackendApi fBackend = BackendApi::kUnsupported;
|
123
|
+
AnyTextureInfoData fData;
|
77
124
|
|
78
|
-
|
79
|
-
|
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
|
-
}
|
130
|
+
} // namespace skgpu::graphite
|
86
131
|
|
87
|
-
#endif
|
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
|
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
|
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
|