@shopify/react-native-skia 2.11.2 → 2.12.0
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/Package.swift +117 -0
- package/android/CMakeLists.txt +1 -2
- package/cpp/api/JsiSkSVGFactory.h +4 -0
- package/cpp/jsi/JSICache.cpp +99 -0
- package/cpp/jsi/JSICache.h +90 -0
- package/cpp/jsi/NativeObject.h +30 -97
- package/cpp/jsi/ViewProperty.h +0 -24
- package/cpp/rnskia/RNDawnContext.h +2 -1
- package/cpp/rnskia/RNDawnWindowContext.h +22 -0
- package/cpp/rnskia/RNSkManager.cpp +0 -11
- package/cpp/skia/include/core/RasterContext.h +25 -0
- package/cpp/skia/include/core/SkCanvas.h +0 -1
- package/cpp/skia/include/core/SkContext.h +62 -0
- package/cpp/skia/include/core/SkContextOptions.h +15 -0
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkPicture.h +36 -18
- package/cpp/skia/include/core/SkRecorder.h +8 -0
- package/cpp/skia/include/core/SkSerialProcs.h +2 -6
- package/cpp/skia/include/effects/SkImageFilters.h +15 -2
- package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +73 -47
- package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +7 -4
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +12 -0
- package/cpp/skia/include/gpu/ganesh/gl/GrGLDirectContext.h +11 -0
- package/cpp/skia/include/gpu/ganesh/mtl/GrMtlDirectContext.h +11 -0
- package/cpp/skia/include/gpu/ganesh/vk/GrVkDirectContext.h +13 -0
- package/cpp/skia/include/gpu/graphite/ContextOptions.h +6 -0
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +5 -4
- package/cpp/skia/include/gpu/graphite/PrecompileContext.h +9 -1
- package/cpp/skia/include/gpu/graphite/Recorder.h +0 -2
- package/cpp/skia/include/gpu/graphite/Recording.h +3 -0
- package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +8 -0
- package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +11 -0
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteContext.h +11 -0
- package/cpp/skia/include/private/SkLog.h +1 -19
- package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +2 -1
- package/cpp/skia/include/utils/SkLogHandler.h +53 -0
- package/cpp/skia/include/utils/SkNWayCanvas.h +1 -0
- package/cpp/skia/modules/skcms/src/Transform_inl.h +9 -10
- package/cpp/skia/modules/skcms/src/skcms_internals.h +8 -3
- package/cpp/skia/modules/skottie/include/SkottieProperty.h +2 -0
- package/cpp/skia/modules/skottie/include/TextShaper.h +1 -0
- package/cpp/skia/modules/skshaper/include/SkShaper.h +23 -1
- package/include/ReactNativeSkia.h +6 -0
- package/lib/commonjs/skia/web/JsiSkCanvas.js +4 -4
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.js +6 -3
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkPathBuilder.js +2 -2
- package/lib/commonjs/skia/web/JsiSkPathBuilder.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTextStyle.js +5 -5
- package/lib/commonjs/skia/web/JsiSkTextStyle.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkottieAnimation.js +8 -8
- package/lib/commonjs/skia/web/JsiSkottieAnimation.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js +2 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.js +228 -43
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +4 -4
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.js +6 -3
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/lib/module/skia/web/JsiSkPathBuilder.js +2 -2
- package/lib/module/skia/web/JsiSkPathBuilder.js.map +1 -1
- package/lib/module/skia/web/JsiSkTextStyle.js +5 -5
- package/lib/module/skia/web/JsiSkTextStyle.js.map +1 -1
- package/lib/module/skia/web/JsiSkottieAnimation.js +8 -8
- package/lib/module/skia/web/JsiSkottieAnimation.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Drawing.js +2 -1
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.js +228 -43
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/lib/typescript/react-native.config.d.ts +3 -0
- package/lib/typescript/src/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/package.json +12 -9
- package/react-native.config.js +5 -0
- package/src/skia/web/JsiSkCanvas.ts +11 -6
- package/src/skia/web/JsiSkImage.ts +6 -3
- package/src/skia/web/JsiSkPathBuilder.ts +2 -2
- package/src/skia/web/JsiSkTextStyle.ts +20 -15
- package/src/skia/web/JsiSkottieAnimation.ts +8 -8
- package/src/sksg/Recorder/commands/Drawing.ts +2 -1
- package/src/views/SkiaPictureView.web.tsx +228 -43
- package/cpp/jsi/RuntimeAwareCache.cpp +0 -8
- package/cpp/jsi/RuntimeAwareCache.h +0 -146
- package/cpp/jsi/RuntimeLifecycleMonitor.cpp +0 -72
- package/cpp/jsi/RuntimeLifecycleMonitor.h +0 -32
|
@@ -2529,7 +2529,6 @@ private:
|
|
|
2529
2529
|
std::unique_ptr<SkRasterHandleAllocator> fAllocator;
|
|
2530
2530
|
|
|
2531
2531
|
SkSurface_Base* fSurfaceBase;
|
|
2532
|
-
virtual SkSurface_Base* getSurfaceBase() const { return fSurfaceBase; }
|
|
2533
2532
|
void setSurfaceBase(SkSurface_Base* sb) {
|
|
2534
2533
|
fSurfaceBase = sb;
|
|
2535
2534
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 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 SkContext_DEFINED
|
|
9
|
+
#define SkContext_DEFINED
|
|
10
|
+
|
|
11
|
+
#include "include/core/SkRefCnt.h"
|
|
12
|
+
#include "include/private/SkAPI.h"
|
|
13
|
+
|
|
14
|
+
class SkContextPriv;
|
|
15
|
+
class SkResourceCache;
|
|
16
|
+
class SkSharedContext;
|
|
17
|
+
class SkStrikeCache;
|
|
18
|
+
class SkTraceMemoryDump;
|
|
19
|
+
class SkTypefaceCache;
|
|
20
|
+
struct SkContextOptions;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @brief SkContext is a central context object that serves as the mandatory first point of
|
|
24
|
+
* initialization for all Skia clients. SkContext consolidates global state, management of shared
|
|
25
|
+
* resources, and internal caches.
|
|
26
|
+
*/
|
|
27
|
+
class SK_API SkContext final {
|
|
28
|
+
public:
|
|
29
|
+
SkContext(const SkContext&) = delete;
|
|
30
|
+
SkContext(SkContext&&) = delete;
|
|
31
|
+
SkContext& operator=(const SkContext&) = delete;
|
|
32
|
+
SkContext& operator=(SkContext&&) = delete;
|
|
33
|
+
|
|
34
|
+
~SkContext();
|
|
35
|
+
|
|
36
|
+
SkContextPriv priv();
|
|
37
|
+
const SkContextPriv priv() const;
|
|
38
|
+
|
|
39
|
+
private:
|
|
40
|
+
SkContext(sk_sp<SkSharedContext>);
|
|
41
|
+
|
|
42
|
+
SkResourceCache* resourceCache() const;
|
|
43
|
+
SkStrikeCache* fontCache() const;
|
|
44
|
+
SkTypefaceCache* typefaceCache() const;
|
|
45
|
+
|
|
46
|
+
size_t fontCacheLimit() const;
|
|
47
|
+
size_t setFontCacheLimit(size_t bytes);
|
|
48
|
+
size_t fontCacheUsed() const;
|
|
49
|
+
|
|
50
|
+
int fontCacheCountLimit() const;
|
|
51
|
+
int setFontCacheCountLimit(int count);
|
|
52
|
+
int fontCacheCountUsed() const;
|
|
53
|
+
|
|
54
|
+
void purgeFontCache();
|
|
55
|
+
void purgePinnedFontCache();
|
|
56
|
+
|
|
57
|
+
void dumpMemoryStatistics(SkTraceMemoryDump* dump);
|
|
58
|
+
|
|
59
|
+
sk_sp<SkSharedContext> fSharedContext;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
#endif // SkContext_DEFINED
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 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 SkContextOptions_DEFINED
|
|
9
|
+
#define SkContextOptions_DEFINED
|
|
10
|
+
|
|
11
|
+
#include "include/private/SkAPI.h"
|
|
12
|
+
|
|
13
|
+
struct SK_API SkContextOptions {};
|
|
14
|
+
|
|
15
|
+
#endif // SkContextOptions_DEFINED
|
|
@@ -16,12 +16,16 @@
|
|
|
16
16
|
#include <atomic>
|
|
17
17
|
#include <cstddef>
|
|
18
18
|
#include <cstdint>
|
|
19
|
+
#include <memory>
|
|
19
20
|
|
|
21
|
+
class SkBBoxHierarchy;
|
|
20
22
|
class SkCanvas;
|
|
21
23
|
class SkData;
|
|
22
24
|
class SkMatrix;
|
|
25
|
+
class SkRecord;
|
|
23
26
|
class SkStream;
|
|
24
27
|
class SkWStream;
|
|
28
|
+
class SkSnapshotArray;
|
|
25
29
|
enum class SkFilterMode;
|
|
26
30
|
struct SkDeserialProcs;
|
|
27
31
|
struct SkSerialProcs;
|
|
@@ -33,8 +37,8 @@ struct SkSerialProcs;
|
|
|
33
37
|
SkPicture records drawing commands made to SkCanvas. The command stream may be
|
|
34
38
|
played in whole or in part at a later time.
|
|
35
39
|
|
|
36
|
-
SkPicture
|
|
37
|
-
|
|
40
|
+
SkPicture may be generated by SkPictureRecorder or SkDrawable, or from a
|
|
41
|
+
SkPicture previously saved to SkData or SkStream.
|
|
38
42
|
|
|
39
43
|
SkPicture may contain any SkCanvas drawing command, as well as one or more
|
|
40
44
|
SkCanvas matrix or SkCanvas clip. SkPicture has a cull SkRect, which is used as
|
|
@@ -84,7 +88,8 @@ public:
|
|
|
84
88
|
@param procs custom serial data decoders; may be nullptr
|
|
85
89
|
@return SkPicture constructed from data
|
|
86
90
|
*/
|
|
87
|
-
static sk_sp<SkPicture> MakeFromData(const void* data,
|
|
91
|
+
static sk_sp<SkPicture> MakeFromData(const void* data,
|
|
92
|
+
size_t size,
|
|
88
93
|
const SkDeserialProcs* procs = nullptr);
|
|
89
94
|
|
|
90
95
|
/** \class SkPicture::AbortCallback
|
|
@@ -133,7 +138,7 @@ public:
|
|
|
133
138
|
|
|
134
139
|
example: https://fiddle.skia.org/c/@Picture_playback
|
|
135
140
|
*/
|
|
136
|
-
|
|
141
|
+
void playback(SkCanvas* canvas, AbortCallback* callback = nullptr) const;
|
|
137
142
|
|
|
138
143
|
/** Returns cull SkRect for this picture, passed in when SkPicture was created.
|
|
139
144
|
Returned SkRect does not specify clipping SkRect for SkPicture; cull is hint
|
|
@@ -146,7 +151,7 @@ public:
|
|
|
146
151
|
|
|
147
152
|
example: https://fiddle.skia.org/c/@Picture_cullRect
|
|
148
153
|
*/
|
|
149
|
-
|
|
154
|
+
SkRect cullRect() const { return fCullRect; }
|
|
150
155
|
|
|
151
156
|
/** Returns a non-zero value unique among SkPicture in Skia process.
|
|
152
157
|
|
|
@@ -212,11 +217,12 @@ public:
|
|
|
212
217
|
|
|
213
218
|
@param nested if true, include the op-counts of nested pictures as well, else
|
|
214
219
|
just return count the ops in the top-level picture.
|
|
215
|
-
@return approximate operation count
|
|
220
|
+
@return approximate operation count. If 0 is returned, we say the SkPicture is "empty"
|
|
221
|
+
meaning its cullRect is the result of an SkRect::MakeEmpty().
|
|
216
222
|
|
|
217
223
|
example: https://fiddle.skia.org/c/@Picture_approximateOpCount
|
|
218
224
|
*/
|
|
219
|
-
|
|
225
|
+
int approximateOpCount(bool nested = false) const;
|
|
220
226
|
|
|
221
227
|
/** Returns the approximate byte size of SkPicture. Does not include large objects
|
|
222
228
|
referenced by SkPicture.
|
|
@@ -225,7 +231,7 @@ public:
|
|
|
225
231
|
|
|
226
232
|
example: https://fiddle.skia.org/c/@Picture_approximateBytesUsed
|
|
227
233
|
*/
|
|
228
|
-
|
|
234
|
+
size_t approximateBytesUsed() const;
|
|
229
235
|
|
|
230
236
|
/** Return a new shader that will draw with this picture.
|
|
231
237
|
*
|
|
@@ -240,18 +246,23 @@ public:
|
|
|
240
246
|
* bounds.
|
|
241
247
|
* @return Returns a new shader object. Note: this function never returns null.
|
|
242
248
|
*/
|
|
243
|
-
sk_sp<SkShader> makeShader(SkTileMode tmx,
|
|
244
|
-
|
|
249
|
+
sk_sp<SkShader> makeShader(SkTileMode tmx,
|
|
250
|
+
SkTileMode tmy,
|
|
251
|
+
SkFilterMode mode,
|
|
252
|
+
const SkMatrix* localMatrix,
|
|
253
|
+
const SkRect* tileRect) const;
|
|
245
254
|
|
|
246
255
|
sk_sp<SkShader> makeShader(SkTileMode tmx, SkTileMode tmy, SkFilterMode mode) const {
|
|
247
256
|
return this->makeShader(tmx, tmy, mode, nullptr, nullptr);
|
|
248
257
|
}
|
|
249
258
|
|
|
250
259
|
private:
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
260
|
+
SkPicture(const SkRect& cull,
|
|
261
|
+
sk_sp<const SkRecord> record,
|
|
262
|
+
std::unique_ptr<const SkSnapshotArray> drawablePicts,
|
|
263
|
+
sk_sp<const SkBBoxHierarchy> bbh,
|
|
264
|
+
size_t approxBytesUsedBySubPictures);
|
|
265
|
+
|
|
255
266
|
friend class SkPicturePriv;
|
|
256
267
|
|
|
257
268
|
void serialize(SkWStream*, const SkSerialProcs*, class SkRefCntSet* typefaces,
|
|
@@ -273,9 +284,6 @@ private:
|
|
|
273
284
|
static bool BufferIsSKP(class SkReadBuffer*, struct SkPictInfo*);
|
|
274
285
|
friend bool SkPicture_StreamIsSKP(SkStream*, struct SkPictInfo*);
|
|
275
286
|
|
|
276
|
-
// Returns NULL if this is not an SkBigPicture.
|
|
277
|
-
virtual const class SkBigPicture* asSkBigPicture() const { return nullptr; }
|
|
278
|
-
|
|
279
287
|
static bool IsValidPictInfo(const struct SkPictInfo& info);
|
|
280
288
|
static sk_sp<SkPicture> Forwardport(const struct SkPictInfo&,
|
|
281
289
|
const class SkPictureData*,
|
|
@@ -284,7 +292,17 @@ private:
|
|
|
284
292
|
struct SkPictInfo createHeader() const;
|
|
285
293
|
class SkPictureData* backport() const;
|
|
286
294
|
|
|
287
|
-
|
|
295
|
+
// When fRecord is nullptr, then we treat the SkPicture as a "placeholder"
|
|
296
|
+
// placeholders provide the bare minimum to operate on an SkPicture
|
|
297
|
+
bool isPlaceholder() const { return !fRecord; }
|
|
298
|
+
|
|
299
|
+
const uint32_t fUniqueID;
|
|
300
|
+
const SkRect fCullRect;
|
|
301
|
+
const size_t fApproxBytesUsedBySubPictures;
|
|
302
|
+
const sk_sp<const SkRecord> fRecord;
|
|
303
|
+
const std::unique_ptr<const SkSnapshotArray> fDrawablePicts;
|
|
304
|
+
const sk_sp<const SkBBoxHierarchy> fBBH;
|
|
305
|
+
|
|
288
306
|
mutable std::atomic<bool> fAddedToCache{false};
|
|
289
307
|
};
|
|
290
308
|
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
#ifndef SkRecorder_DEFINED
|
|
8
8
|
#define SkRecorder_DEFINED
|
|
9
9
|
|
|
10
|
+
#include "include/core/SkPicture.h"
|
|
10
11
|
#include "include/private/SkAPI.h"
|
|
12
|
+
#include "include/private/SkTArray.h"
|
|
11
13
|
|
|
12
14
|
class SkCanvas;
|
|
13
15
|
class SkSurface;
|
|
@@ -34,11 +36,17 @@ public:
|
|
|
34
36
|
|
|
35
37
|
virtual skcpu::Recorder* cpuRecorder() = 0;
|
|
36
38
|
|
|
39
|
+
protected:
|
|
40
|
+
skia_private::TArray<sk_sp<SkPicture>> fCapturedPictures;
|
|
41
|
+
|
|
37
42
|
private:
|
|
38
43
|
|
|
39
44
|
/**
|
|
40
45
|
* Attempts to create and return an SkCaptureCanvas that wraps the provided base canvas.
|
|
41
46
|
* Returns nullptr if capture is not enabled.
|
|
47
|
+
*
|
|
48
|
+
* TODO: When implementing in all Recorder subclasses, see if the implementations can be shared
|
|
49
|
+
* and moved here.
|
|
42
50
|
*/
|
|
43
51
|
virtual SkCanvas* makeCaptureCanvas(SkCanvas*) = 0;
|
|
44
52
|
virtual void createCaptureBreakpoint(SkSurface*) = 0;
|
|
@@ -47,8 +47,7 @@ using SkSerialTypefaceProc = SkSerialReturnType (*)(SkTypeface*, void* ctx);
|
|
|
47
47
|
using SkDeserialPictureProc = sk_sp<SkPicture> (*)(const void* data, size_t length, void* ctx);
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* Called with the encoded form of an image.
|
|
51
|
-
* returns nullptr, then Skia will take its default action to try to create an image from the data.
|
|
50
|
+
* Called with the encoded form of an image. If this is not set, no image decoding will be done.
|
|
52
51
|
*
|
|
53
52
|
* This will also be used to decode the internal mipmap layers that are saved on some images.
|
|
54
53
|
*
|
|
@@ -60,14 +59,11 @@ using SkDeserialPictureProc = sk_sp<SkPicture> (*)(const void* data, size_t leng
|
|
|
60
59
|
* must make a copy of any data they needed after the proc finishes, since the data will go away
|
|
61
60
|
* after serialization ends.
|
|
62
61
|
*/
|
|
63
|
-
#if !defined(SK_LEGACY_DESERIAL_IMAGE_PROC)
|
|
64
|
-
using SkDeserialImageProc = sk_sp<SkImage> (*)(const void* data, size_t length, void* ctx);
|
|
65
|
-
#else
|
|
66
62
|
using SkDeserialImageProc = sk_sp<SkImage> (*)(const void* data,
|
|
67
63
|
size_t length,
|
|
68
64
|
std::optional<SkAlphaType>,
|
|
69
65
|
void* ctx);
|
|
70
|
-
|
|
66
|
+
|
|
71
67
|
using SkDeserialImageFromDataProc = sk_sp<SkImage> (*)(sk_sp<SkData>,
|
|
72
68
|
std::optional<SkAlphaType>,
|
|
73
69
|
void* ctx);
|
|
@@ -414,12 +414,21 @@ public:
|
|
|
414
414
|
* This allows Skia to provide sampleable values for the image filter without worrying about
|
|
415
415
|
* boundary conditions.
|
|
416
416
|
*
|
|
417
|
+
* By default the output of a runtime shader is unbounded, since Skia cannot know what colors
|
|
418
|
+
* the SkSL will produce for pixels outside of its inputs' bounds. If
|
|
419
|
+
* 'restrictOutputToInputBounds' is true, the caller promises that the SkSL evaluates to
|
|
420
|
+
* transparent black wherever its child shaders are transparent black, so the filter's output
|
|
421
|
+
* bounds can be restricted to the union of its inputs' output bounds (the source image's
|
|
422
|
+
* bounds when 'input' is null). This lets downstream filters (e.g. a blur with a non-decal
|
|
423
|
+
* tile mode) see the original content bounds instead of an unbounded result.
|
|
424
|
+
*
|
|
417
425
|
* This requires a GPU backend or SkSL to be compiled in.
|
|
418
426
|
*/
|
|
419
427
|
static sk_sp<SkImageFilter> RuntimeShader(const SkRuntimeEffectBuilder& builder,
|
|
420
428
|
SkScalar sampleRadius,
|
|
421
429
|
std::string_view childShaderName,
|
|
422
|
-
sk_sp<SkImageFilter> input
|
|
430
|
+
sk_sp<SkImageFilter> input,
|
|
431
|
+
bool restrictOutputToInputBounds = false);
|
|
423
432
|
|
|
424
433
|
/**
|
|
425
434
|
* Create a filter that fills the output with the per-pixel evaluation of the SkShader produced
|
|
@@ -453,13 +462,17 @@ public:
|
|
|
453
462
|
* childShaderNames) will be evaluated with coordinates at most 'maxSampleRadius' away from the
|
|
454
463
|
* coordinate provided to the runtime shader itself.
|
|
455
464
|
*
|
|
465
|
+
* If 'restrictOutputToInputBounds' is true, the filter's output bounds are restricted to the
|
|
466
|
+
* union of its inputs' output bounds; see the single-child variant for details.
|
|
467
|
+
*
|
|
456
468
|
* This requires a GPU backend or SkSL to be compiled in.
|
|
457
469
|
*/
|
|
458
470
|
static sk_sp<SkImageFilter> RuntimeShader(const SkRuntimeEffectBuilder& builder,
|
|
459
471
|
SkScalar maxSampleRadius,
|
|
460
472
|
std::string_view childShaderNames[],
|
|
461
473
|
const sk_sp<SkImageFilter> inputs[],
|
|
462
|
-
int inputCount
|
|
474
|
+
int inputCount,
|
|
475
|
+
bool restrictOutputToInputBounds = false);
|
|
463
476
|
|
|
464
477
|
enum class Dither : bool {
|
|
465
478
|
kNo = false,
|
|
@@ -320,14 +320,34 @@ public:
|
|
|
320
320
|
bool wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores,
|
|
321
321
|
bool deleteSemaphoresAfterWait = true);
|
|
322
322
|
|
|
323
|
+
/*
|
|
324
|
+
* Result of a flush call. A flush can be successful w/ or w/o any semaphores being flushed.
|
|
325
|
+
* In some circumstances an unsuccessful flush can still have flushed the semaphores but
|
|
326
|
+
* the rendering results should be discarded.
|
|
327
|
+
*/
|
|
328
|
+
struct FlushResult {
|
|
329
|
+
// This implicit cast is temporary and recreates the success/semaphore-submission
|
|
330
|
+
// conflation of the old API. This can be removed when all clients have been
|
|
331
|
+
// updated to the new return value.
|
|
332
|
+
operator GrSemaphoresSubmitted() const {
|
|
333
|
+
return fSuccess ? GrSemaphoresSubmitted::kYes : GrSemaphoresSubmitted::kNo;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
bool fSuccess = false; // Did the flush succeed
|
|
337
|
+
// Were any semaphores submitted during the flush process. Will be kNo if no
|
|
338
|
+
// semaphores were specified.
|
|
339
|
+
GrSemaphoresSubmitted fSubmitted = GrSemaphoresSubmitted::kNo;
|
|
340
|
+
};
|
|
341
|
+
|
|
323
342
|
/**
|
|
324
343
|
* Call to ensure all drawing to the context has been flushed and submitted to the underlying 3D
|
|
325
344
|
* API. This is equivalent to calling GrContext::flush with a default GrFlushInfo followed by
|
|
326
345
|
* GrContext::submit(sync).
|
|
327
346
|
*/
|
|
328
|
-
|
|
329
|
-
this->flush(GrFlushInfo());
|
|
330
|
-
this->submit(sync);
|
|
347
|
+
FlushResult flushAndSubmit(GrSyncCpu sync = GrSyncCpu::kNo) {
|
|
348
|
+
FlushResult result = this->flush(GrFlushInfo());
|
|
349
|
+
result.fSuccess &= this->submit(sync);
|
|
350
|
+
return result;
|
|
331
351
|
}
|
|
332
352
|
|
|
333
353
|
/**
|
|
@@ -341,22 +361,22 @@ public:
|
|
|
341
361
|
* buffer or encoder objects. However, these objects are not sent to the gpu until a
|
|
342
362
|
* submission occurs.
|
|
343
363
|
*
|
|
344
|
-
* If
|
|
345
|
-
* submitted to the gpu during the next submit call (it is possible
|
|
346
|
-
* subset of the semaphores). The client should not wait on these
|
|
347
|
-
* has been called, and must keep them alive until then. If
|
|
348
|
-
* GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores
|
|
349
|
-
* the GPU. Thus the client should not have the GPU wait on any of the
|
|
350
|
-
* the GrFlushInfo. Regardless of whether semaphores were submitted
|
|
351
|
-
* client is still responsible for deleting any initialized semaphores.
|
|
364
|
+
* If FlushResult.fSubmitted is GrSemaphoresSubmitted::kYes, only initialized
|
|
365
|
+
* GrBackendSemaphores will be submitted to the gpu during the next submit call (it is possible
|
|
366
|
+
* Skia failed to create a subset of the semaphores). The client should not wait on these
|
|
367
|
+
* semaphores until after submit has been called, and must keep them alive until then. If
|
|
368
|
+
* fSubmitted is GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores
|
|
369
|
+
* to be signaled on the GPU. Thus the client should not have the GPU wait on any of the
|
|
370
|
+
* semaphores passed in with the GrFlushInfo. Regardless of whether semaphores were submitted
|
|
371
|
+
* to the GPU or not, the client is still responsible for deleting any initialized semaphores.
|
|
352
372
|
* Regardless of semaphore submission the context will still be flushed. It should be
|
|
353
|
-
* emphasized that a
|
|
354
|
-
* happen. It simply means there were no semaphores submitted to the GPU. A caller
|
|
355
|
-
* take this as a failure if they passed in semaphores to be submitted.
|
|
373
|
+
* emphasized that a fSubmitted value of GrSemaphoresSubmitted::kNo does not mean the flush
|
|
374
|
+
* did not happen. It simply means there were no semaphores submitted to the GPU. A caller
|
|
375
|
+
* should only take this as a failure if they passed in semaphores to be submitted.
|
|
356
376
|
*/
|
|
357
|
-
|
|
377
|
+
FlushResult flush(const GrFlushInfo& info);
|
|
358
378
|
|
|
359
|
-
void flush() { this->flush(GrFlushInfo()); }
|
|
379
|
+
void flush() { (void) this->flush(GrFlushInfo()); }
|
|
360
380
|
|
|
361
381
|
/** Flushes any pending uses of texture-backed images in the GPU backend. If the image is not
|
|
362
382
|
* texture-backed (including promise texture images) or if the GrDirectContext does not
|
|
@@ -367,13 +387,18 @@ public:
|
|
|
367
387
|
* @param image the non-null image to flush.
|
|
368
388
|
* @param info flush options
|
|
369
389
|
*/
|
|
370
|
-
|
|
371
|
-
|
|
390
|
+
FlushResult flush(const sk_sp<const SkImage>& image, const GrFlushInfo& info);
|
|
391
|
+
|
|
392
|
+
void flush(const sk_sp<const SkImage>& image) { (void) this->flush(image, {}); }
|
|
372
393
|
|
|
373
394
|
/** Version of flush() that uses a default GrFlushInfo. Also submits the flushed work to the
|
|
374
|
-
*
|
|
395
|
+
* GPU.
|
|
375
396
|
*/
|
|
376
|
-
|
|
397
|
+
FlushResult flushAndSubmit(const sk_sp<const SkImage>& image) {
|
|
398
|
+
FlushResult result = this->flush(image, {});
|
|
399
|
+
result.fSuccess &= this->submit();
|
|
400
|
+
return result;
|
|
401
|
+
}
|
|
377
402
|
|
|
378
403
|
/** Issues pending SkSurface commands to the GPU-backed API objects and resolves any SkSurface
|
|
379
404
|
* MSAA. A call to GrDirectContext::submit is always required to ensure work is actually sent
|
|
@@ -400,19 +425,20 @@ public:
|
|
|
400
425
|
* The GrFlushInfo describes additional options to flush. Please see documentation at
|
|
401
426
|
* GrFlushInfo for more info.
|
|
402
427
|
*
|
|
403
|
-
* If
|
|
404
|
-
* submitted to the gpu during the next submit call (it is
|
|
405
|
-
* subset of the semaphores). The client should not wait on
|
|
406
|
-
* has been called, but must keep them alive until then.
|
|
407
|
-
* the flush these valid semaphores can we waited on
|
|
408
|
-
* GrSemaphoresSubmitted::kNo, the GPU backend will not
|
|
409
|
-
* the GPU. Thus the client should not have the GPU
|
|
410
|
-
*
|
|
411
|
-
* client is still responsible for deleting
|
|
412
|
-
* Regardless of semaphore submission the context will still be
|
|
413
|
-
* emphasized that a
|
|
414
|
-
* happen. It simply means there were no semaphores submitted
|
|
415
|
-
* take this as a failure if they passed in semaphores to
|
|
428
|
+
* If FlushResult.fSubmitted is GrSemaphoresSubmitted::kYes, only initialized
|
|
429
|
+
* GrBackendSemaphores will be submitted to the gpu during the next submit call (it is
|
|
430
|
+
* possible Skia failed to create a subset of the semaphores). The client should not wait on
|
|
431
|
+
* these semaphores until after submit has been called, but must keep them alive until then.
|
|
432
|
+
* If a submit flag was passed in with the flush these valid semaphores can we waited on
|
|
433
|
+
* immediately. If this fSubmitted is GrSemaphoresSubmitted::kNo, the GPU backend will not
|
|
434
|
+
* submit any semaphores to be signaled on the GPU. Thus the client should not have the GPU
|
|
435
|
+
* wait on any of the semaphores passed in with the GrFlushInfo. Regardless of whether
|
|
436
|
+
* semaphores were submitted to the GPU or not, the client is still responsible for deleting
|
|
437
|
+
* any initialized semaphores. Regardless of semaphore submission the context will still be
|
|
438
|
+
* flushed. It should be emphasized that a fSubmitted value of GrSemaphoresSubmitted::kNo
|
|
439
|
+
* does not mean the flush did not happen. It simply means there were no semaphores submitted
|
|
440
|
+
* to the GPU. A caller should only take this as a failure if they passed in semaphores to
|
|
441
|
+
* be submitted.
|
|
416
442
|
*
|
|
417
443
|
* Pending surface commands are flushed regardless of the return result.
|
|
418
444
|
*
|
|
@@ -420,9 +446,9 @@ public:
|
|
|
420
446
|
* @param access type of access the call will do on the backend object after flush
|
|
421
447
|
* @param info flush options
|
|
422
448
|
*/
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
449
|
+
FlushResult flush(SkSurface* surface,
|
|
450
|
+
SkSurfaces::BackendSurfaceAccess access,
|
|
451
|
+
const GrFlushInfo& info);
|
|
426
452
|
|
|
427
453
|
/**
|
|
428
454
|
* Same as above except:
|
|
@@ -443,9 +469,16 @@ public:
|
|
|
443
469
|
* @param info flush options
|
|
444
470
|
* @param newState optional state change request after flush
|
|
445
471
|
*/
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
472
|
+
FlushResult flush(SkSurface* surface,
|
|
473
|
+
const GrFlushInfo& info,
|
|
474
|
+
const skgpu::MutableTextureState* newState = nullptr);
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Flushes the given surface with the default GrFlushInfo.
|
|
478
|
+
*
|
|
479
|
+
* Has no effect on a CPU-backed surface.
|
|
480
|
+
*/
|
|
481
|
+
void flush(SkSurface* surface) { (void) this->flush(surface, GrFlushInfo(), nullptr); }
|
|
449
482
|
|
|
450
483
|
/** Call to ensure all reads/writes of the surface have been issued to the underlying 3D API.
|
|
451
484
|
* Skia will correctly order its own draws and pixel operations. This must to be used to ensure
|
|
@@ -455,14 +488,7 @@ public:
|
|
|
455
488
|
*
|
|
456
489
|
* Has no effect on a CPU-backed surface.
|
|
457
490
|
*/
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* Flushes the given surface with the default GrFlushInfo.
|
|
462
|
-
*
|
|
463
|
-
* Has no effect on a CPU-backed surface.
|
|
464
|
-
*/
|
|
465
|
-
void flush(SkSurface* surface);
|
|
491
|
+
FlushResult flushAndSubmit(SkSurface* surface, GrSyncCpu sync = GrSyncCpu::kNo);
|
|
466
492
|
|
|
467
493
|
/**
|
|
468
494
|
* Submit outstanding work to the gpu from all previously un-submitted flushes. The return
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
#include "include/core/SkImageInfo.h"
|
|
12
12
|
#include "include/core/SkRefCnt.h"
|
|
13
13
|
#include "include/core/SkSurface.h"
|
|
14
|
+
#include "include/gpu/ganesh/GrDirectContext.h"
|
|
14
15
|
#include "include/gpu/ganesh/GrTypes.h"
|
|
15
16
|
#include "include/private/SkAPI.h"
|
|
16
17
|
|
|
@@ -209,10 +210,12 @@ namespace skgpu::ganesh {
|
|
|
209
210
|
// Clients should strive to call GrDirectContext::flush directly. However, there exist some
|
|
210
211
|
// places where the GrDirectContext is hard to find, these helpers allow for the flushing of the
|
|
211
212
|
// provided surface. This is a no-op if the surface is nullptr or not GPU backed.
|
|
212
|
-
SK_API
|
|
213
|
-
SK_API
|
|
214
|
-
|
|
215
|
-
SK_API
|
|
213
|
+
SK_API GrDirectContext::FlushResult Flush(sk_sp<SkSurface>);
|
|
214
|
+
SK_API GrDirectContext::FlushResult Flush(SkSurface*);
|
|
215
|
+
|
|
216
|
+
SK_API GrDirectContext::FlushResult FlushAndSubmit(sk_sp<SkSurface>);
|
|
217
|
+
SK_API GrDirectContext::FlushResult FlushAndSubmit(SkSurface*);
|
|
218
|
+
|
|
216
219
|
} // namespace skgpu::ganesh
|
|
217
220
|
|
|
218
221
|
#endif
|
|
@@ -11,9 +11,13 @@
|
|
|
11
11
|
#include "include/core/SkRefCnt.h"
|
|
12
12
|
#include "include/private/SkAPI.h"
|
|
13
13
|
|
|
14
|
+
#include <memory>
|
|
15
|
+
|
|
14
16
|
class GrDirectContext;
|
|
17
|
+
class SkContext;
|
|
15
18
|
struct GrContextOptions;
|
|
16
19
|
struct GrD3DBackendContext;
|
|
20
|
+
struct SkContextOptions;
|
|
17
21
|
|
|
18
22
|
namespace GrDirectContexts {
|
|
19
23
|
/**
|
|
@@ -25,4 +29,12 @@ SK_API sk_sp<GrDirectContext> MakeD3D(const GrD3DBackendContext& backendContext,
|
|
|
25
29
|
SK_API sk_sp<GrDirectContext> MakeD3D(const GrD3DBackendContext& backendContext);
|
|
26
30
|
} // namespace GrDirectContexts
|
|
27
31
|
|
|
32
|
+
namespace SkContexts {
|
|
33
|
+
|
|
34
|
+
// Creates a context wrapping a Ganesh GPU backend with D3D
|
|
35
|
+
std::unique_ptr<SkContext> MakeGanesh(const GrD3DBackendContext& backendContext,
|
|
36
|
+
const SkContextOptions& options);
|
|
37
|
+
|
|
38
|
+
} // namespace SkContexts
|
|
39
|
+
|
|
28
40
|
#endif
|
|
@@ -11,9 +11,13 @@
|
|
|
11
11
|
#include "include/core/SkRefCnt.h"
|
|
12
12
|
#include "include/private/SkAPI.h"
|
|
13
13
|
|
|
14
|
+
#include <memory>
|
|
15
|
+
|
|
14
16
|
class GrDirectContext;
|
|
17
|
+
class SkContext;
|
|
15
18
|
struct GrContextOptions;
|
|
16
19
|
struct GrGLInterface;
|
|
20
|
+
struct SkContextOptions;
|
|
17
21
|
|
|
18
22
|
namespace GrDirectContexts {
|
|
19
23
|
/**
|
|
@@ -27,4 +31,11 @@ SK_API sk_sp<GrDirectContext> MakeGL();
|
|
|
27
31
|
#endif
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
namespace SkContexts {
|
|
35
|
+
|
|
36
|
+
// Creates a context wrapping a Ganesh GPU backend with OpenGL
|
|
37
|
+
std::unique_ptr<SkContext> MakeGanesh(sk_sp<const GrGLInterface>, const SkContextOptions& options);
|
|
38
|
+
|
|
39
|
+
} // namespace SkContexts
|
|
40
|
+
|
|
30
41
|
#endif
|
|
@@ -11,9 +11,13 @@
|
|
|
11
11
|
#include "include/core/SkRefCnt.h"
|
|
12
12
|
#include "include/private/SkAPI.h"
|
|
13
13
|
|
|
14
|
+
#include <memory>
|
|
15
|
+
|
|
14
16
|
class GrDirectContext;
|
|
17
|
+
class SkContext;
|
|
15
18
|
struct GrContextOptions;
|
|
16
19
|
struct GrMtlBackendContext;
|
|
20
|
+
struct SkContextOptions;
|
|
17
21
|
|
|
18
22
|
namespace GrDirectContexts {
|
|
19
23
|
/**
|
|
@@ -27,4 +31,11 @@ SK_API sk_sp<GrDirectContext> MakeMetal(const GrMtlBackendContext&, const GrCont
|
|
|
27
31
|
SK_API sk_sp<GrDirectContext> MakeMetal(const GrMtlBackendContext&);
|
|
28
32
|
} // namespace GrDirectContexts
|
|
29
33
|
|
|
34
|
+
namespace SkContexts {
|
|
35
|
+
|
|
36
|
+
// Creates a context wrapping a Ganesh GPU backend with Metal
|
|
37
|
+
std::unique_ptr<SkContext> MakeGanesh(const GrMtlBackendContext& mtlContext, const SkContextOptions& options);
|
|
38
|
+
|
|
39
|
+
} // namespace SkContexts
|
|
40
|
+
|
|
30
41
|
#endif
|
|
@@ -11,8 +11,12 @@
|
|
|
11
11
|
#include "include/core/SkRefCnt.h"
|
|
12
12
|
#include "include/private/SkAPI.h"
|
|
13
13
|
|
|
14
|
+
#include <memory>
|
|
15
|
+
|
|
14
16
|
class GrDirectContext;
|
|
17
|
+
class SkContext;
|
|
15
18
|
struct GrContextOptions;
|
|
19
|
+
struct SkContextOptions;
|
|
16
20
|
namespace skgpu {
|
|
17
21
|
struct VulkanBackendContext;
|
|
18
22
|
}
|
|
@@ -30,4 +34,13 @@ SK_API sk_sp<GrDirectContext> MakeVulkan(const skgpu::VulkanBackendContext&,
|
|
|
30
34
|
SK_API sk_sp<GrDirectContext> MakeVulkan(const skgpu::VulkanBackendContext&);
|
|
31
35
|
}
|
|
32
36
|
|
|
37
|
+
namespace SkContexts {
|
|
38
|
+
|
|
39
|
+
// Creates a context wrapping a Ganesh GPU backend with Vulkan
|
|
40
|
+
std::unique_ptr<SkContext> MakeGanesh(const skgpu::VulkanBackendContext& vkContext,
|
|
41
|
+
const SkContextOptions& options);
|
|
42
|
+
|
|
43
|
+
} // namespace SkContexts
|
|
44
|
+
|
|
45
|
+
|
|
33
46
|
#endif
|
|
@@ -135,6 +135,12 @@ struct SK_API ContextOptions {
|
|
|
135
135
|
bool fSetBackendLabels = false;
|
|
136
136
|
#endif
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Enabling switches Graphite from the existing sort-based draw ordering to the new layer-based
|
|
140
|
+
* system.
|
|
141
|
+
*/
|
|
142
|
+
bool fUseDrawListLayer = false;
|
|
143
|
+
|
|
138
144
|
/**
|
|
139
145
|
* Client-provided context that is passed to the client-provided PipelineCachingCallback
|
|
140
146
|
* and the (deprecated) PipelineCallback.
|