@shopify/react-native-skia 2.5.5 → 2.6.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/cpp/api/CustomBlendModes.h +1 -0
- package/cpp/api/JsiSkApi.h +4 -0
- package/cpp/api/JsiSkCanvas.h +2 -2
- package/cpp/api/JsiSkContourMeasureIter.h +1 -1
- package/cpp/api/JsiSkPath.h +483 -355
- package/cpp/api/JsiSkPathBuilder.h +415 -0
- package/cpp/api/JsiSkPathBuilderFactory.h +53 -0
- package/cpp/api/JsiSkPathEffectFactory.h +2 -2
- package/cpp/api/JsiSkPathFactory.h +274 -3
- package/cpp/api/recorder/DataTypes.h +1 -1
- package/cpp/api/recorder/Drawings.h +6 -2
- package/cpp/rnskia/RNDawnContext.h +21 -0
- package/cpp/rnskia/RNDawnUtils.h +115 -113
- package/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/commonjs/animation/functions/interpolatePaths.js +5 -4
- package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.d.ts +11 -2
- package/lib/commonjs/external/reanimated/interpolators.js +21 -4
- package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
- package/lib/commonjs/skia/types/Path/PathBuilder.d.ts +201 -0
- package/lib/commonjs/skia/types/Path/PathBuilder.js +6 -0
- package/lib/commonjs/skia/types/Path/PathBuilder.js.map +1 -0
- package/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +13 -0
- package/lib/commonjs/skia/types/Path/PathBuilderFactory.js +6 -0
- package/lib/commonjs/skia/types/Path/PathBuilderFactory.js.map +1 -0
- package/lib/commonjs/skia/types/Path/PathFactory.d.ts +87 -1
- package/lib/commonjs/skia/types/Path/PathFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Path/index.d.ts +2 -0
- package/lib/commonjs/skia/types/Path/index.js +22 -0
- package/lib/commonjs/skia/types/Path/index.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +2 -1
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/web/Host.js +1 -3
- package/lib/commonjs/skia/web/Host.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +6 -2
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkContourMeasure.js +4 -1
- package/lib/commonjs/skia/web/JsiSkContourMeasure.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.d.ts +42 -30
- package/lib/commonjs/skia/web/JsiSkPath.js +302 -111
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +45 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilder.js +192 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilder.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js +26 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +6 -2
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +13 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.js +140 -5
- package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +8 -1
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js +18 -6
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js +2 -3
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -2
- package/lib/commonjs/specs/WebGPUViewNativeComponent.js +2 -3
- package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +2 -0
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +1 -1
- package/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/module/animation/functions/interpolatePaths.js +5 -4
- package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.d.ts +11 -2
- package/lib/module/external/reanimated/interpolators.js +21 -4
- package/lib/module/external/reanimated/interpolators.js.map +1 -1
- package/lib/module/skia/types/Path/PathBuilder.d.ts +201 -0
- package/lib/module/skia/types/Path/PathBuilder.js +2 -0
- package/lib/module/skia/types/Path/PathBuilder.js.map +1 -0
- package/lib/module/skia/types/Path/PathBuilderFactory.d.ts +13 -0
- package/lib/module/skia/types/Path/PathBuilderFactory.js +2 -0
- package/lib/module/skia/types/Path/PathBuilderFactory.js.map +1 -0
- package/lib/module/skia/types/Path/PathFactory.d.ts +87 -1
- package/lib/module/skia/types/Path/PathFactory.js.map +1 -1
- package/lib/module/skia/types/Path/index.d.ts +2 -0
- package/lib/module/skia/types/Path/index.js +2 -0
- package/lib/module/skia/types/Path/index.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +2 -1
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/web/Host.js +1 -3
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +6 -2
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkContourMeasure.js +4 -1
- package/lib/module/skia/web/JsiSkContourMeasure.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.d.ts +42 -30
- package/lib/module/skia/web/JsiSkPath.js +300 -110
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
- package/lib/module/skia/web/JsiSkPathBuilder.js +186 -0
- package/lib/module/skia/web/JsiSkPathBuilder.js.map +1 -0
- package/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
- package/lib/module/skia/web/JsiSkPathBuilderFactory.js +19 -0
- package/lib/module/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
- package/lib/module/skia/web/JsiSkPathEffectFactory.js +6 -2
- package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathFactory.d.ts +13 -1
- package/lib/module/skia/web/JsiSkPathFactory.js +141 -6
- package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +8 -1
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Drawing.js +18 -6
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
- package/lib/module/specs/SkiaPictureViewNativeComponent.js +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/module/specs/WebGPUViewNativeComponent.d.ts +2 -2
- package/lib/module/specs/WebGPUViewNativeComponent.js +1 -1
- package/lib/module/specs/WebGPUViewNativeComponent.js.map +1 -1
- package/lib/module/specs/WebGPUViewNativeComponent.web.js +2 -0
- package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +1 -1
- package/lib/typescript/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/typescript/lib/commonjs/external/reanimated/interpolators.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilder.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +33 -25
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +46 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +7 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +12 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -1
- package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -1
- package/lib/typescript/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/typescript/lib/module/external/reanimated/interpolators.d.ts +1 -1
- package/lib/typescript/lib/module/mock/index.d.ts +1 -1
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Path/PathBuilder.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Path/PathBuilderFactory.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Path/index.d.ts +2 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +38 -25
- package/lib/typescript/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +6 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPathFactory.d.ts +12 -0
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +1 -1
- package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/typescript/src/external/reanimated/interpolators.d.ts +11 -2
- package/lib/typescript/src/skia/types/Path/PathBuilder.d.ts +201 -0
- package/lib/typescript/src/skia/types/Path/PathBuilderFactory.d.ts +13 -0
- package/lib/typescript/src/skia/types/Path/PathFactory.d.ts +87 -1
- package/lib/typescript/src/skia/types/Path/index.d.ts +2 -0
- package/lib/typescript/src/skia/types/Skia.d.ts +2 -1
- package/lib/typescript/src/skia/web/JsiSkPath.d.ts +42 -30
- package/lib/typescript/src/skia/web/JsiSkPathBuilder.d.ts +45 -0
- package/lib/typescript/src/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
- package/lib/typescript/src/skia/web/JsiSkPathFactory.d.ts +13 -1
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
- package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +2 -2
- package/package.json +3 -2
- package/scripts/install-libs.js +16 -6
- package/src/animation/functions/interpolatePaths.ts +5 -6
- package/src/external/reanimated/interpolators.ts +25 -5
- package/src/skia/types/Path/PathBuilder.ts +303 -0
- package/src/skia/types/Path/PathBuilderFactory.ts +15 -0
- package/src/skia/types/Path/PathFactory.ts +108 -1
- package/src/skia/types/Path/index.ts +2 -0
- package/src/skia/types/Skia.ts +2 -1
- package/src/skia/web/Host.ts +7 -1
- package/src/skia/web/JsiSkCanvas.ts +6 -6
- package/src/skia/web/JsiSkContourMeasure.ts +4 -4
- package/src/skia/web/JsiSkPath.ts +451 -168
- package/src/skia/web/JsiSkPathBuilder.ts +293 -0
- package/src/skia/web/JsiSkPathBuilderFactory.ts +32 -0
- package/src/skia/web/JsiSkPathEffectFactory.ts +6 -2
- package/src/skia/web/JsiSkPathFactory.ts +231 -8
- package/src/skia/web/JsiSkia.ts +11 -8
- package/src/sksg/Recorder/commands/Drawing.ts +20 -7
- package/src/specs/SkiaPictureViewNativeComponent.ts +1 -2
- package/src/specs/WebGPUViewNativeComponent.ts +2 -2
- package/src/specs/WebGPUViewNativeComponent.web.ts +2 -0
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <algorithm>
|
|
3
4
|
#include <memory>
|
|
4
5
|
#include <utility>
|
|
6
|
+
#include <vector>
|
|
5
7
|
|
|
6
8
|
#include <jsi/jsi.h>
|
|
7
9
|
|
|
8
10
|
#include "JsiSkHostObjects.h"
|
|
11
|
+
#include "JsiSkMatrix.h"
|
|
9
12
|
#include "JsiSkPathEffect.h"
|
|
13
|
+
#include "JsiSkPoint.h"
|
|
14
|
+
#include "JsiSkRRect.h"
|
|
15
|
+
#include "JsiSkRect.h"
|
|
10
16
|
|
|
11
17
|
#pragma clang diagnostic push
|
|
12
18
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
13
19
|
|
|
14
20
|
#include "RNSkLog.h"
|
|
15
21
|
#include "include/core/SkPath.h"
|
|
22
|
+
#include "include/core/SkPathBuilder.h"
|
|
23
|
+
#include "include/core/SkPathUtils.h"
|
|
24
|
+
#include "include/core/SkStrokeRec.h"
|
|
25
|
+
#include "include/effects/SkDashPathEffect.h"
|
|
26
|
+
#include "include/effects/SkTrimPathEffect.h"
|
|
16
27
|
#include "include/pathops/SkPathOps.h"
|
|
28
|
+
#include "include/utils/SkTextUtils.h"
|
|
17
29
|
|
|
18
30
|
#pragma clang diagnostic pop
|
|
19
31
|
|
|
@@ -54,8 +66,8 @@ public:
|
|
|
54
66
|
}
|
|
55
67
|
|
|
56
68
|
JSI_HOST_FUNCTION(MakeFromOp) {
|
|
57
|
-
SkPath one =
|
|
58
|
-
SkPath two =
|
|
69
|
+
SkPath one = JsiSkPath::fromValue(runtime, arguments[0])->snapshot();
|
|
70
|
+
SkPath two = JsiSkPath::fromValue(runtime, arguments[1])->snapshot();
|
|
59
71
|
SkPathOp op = (SkPathOp)arguments[2].asNumber();
|
|
60
72
|
SkPath result;
|
|
61
73
|
bool success = Op(one, two, op, &result);
|
|
@@ -170,6 +182,251 @@ public:
|
|
|
170
182
|
runtime, hostObjectInstance, getContext());
|
|
171
183
|
}
|
|
172
184
|
|
|
185
|
+
// Static shape factories
|
|
186
|
+
JSI_HOST_FUNCTION(Rect) {
|
|
187
|
+
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
188
|
+
auto direction = SkPathDirection::kCW;
|
|
189
|
+
if (count >= 2 && arguments[1].getBool()) {
|
|
190
|
+
direction = SkPathDirection::kCCW;
|
|
191
|
+
}
|
|
192
|
+
SkPath path;
|
|
193
|
+
path.addRect(*rect, direction);
|
|
194
|
+
auto hostObjectInstance =
|
|
195
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(path));
|
|
196
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
197
|
+
runtime, hostObjectInstance, getContext());
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
JSI_HOST_FUNCTION(Oval) {
|
|
201
|
+
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
202
|
+
auto direction = SkPathDirection::kCW;
|
|
203
|
+
if (count >= 2 && arguments[1].getBool()) {
|
|
204
|
+
direction = SkPathDirection::kCCW;
|
|
205
|
+
}
|
|
206
|
+
unsigned startIndex = count < 3 ? 0 : arguments[2].asNumber();
|
|
207
|
+
SkPath path;
|
|
208
|
+
path.addOval(*rect, direction, startIndex);
|
|
209
|
+
auto hostObjectInstance =
|
|
210
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(path));
|
|
211
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
212
|
+
runtime, hostObjectInstance, getContext());
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
JSI_HOST_FUNCTION(Circle) {
|
|
216
|
+
auto x = arguments[0].asNumber();
|
|
217
|
+
auto y = arguments[1].asNumber();
|
|
218
|
+
auto r = arguments[2].asNumber();
|
|
219
|
+
SkPath path;
|
|
220
|
+
path.addCircle(x, y, r);
|
|
221
|
+
auto hostObjectInstance =
|
|
222
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(path));
|
|
223
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
224
|
+
runtime, hostObjectInstance, getContext());
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
JSI_HOST_FUNCTION(RRect) {
|
|
228
|
+
auto rrect = JsiSkRRect::fromValue(runtime, arguments[0]);
|
|
229
|
+
auto direction = SkPathDirection::kCW;
|
|
230
|
+
if (count >= 2 && arguments[1].getBool()) {
|
|
231
|
+
direction = SkPathDirection::kCCW;
|
|
232
|
+
}
|
|
233
|
+
SkPath path;
|
|
234
|
+
path.addRRect(*rrect, direction);
|
|
235
|
+
auto hostObjectInstance =
|
|
236
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(path));
|
|
237
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
238
|
+
runtime, hostObjectInstance, getContext());
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
JSI_HOST_FUNCTION(Line) {
|
|
242
|
+
auto p1 = JsiSkPoint::fromValue(
|
|
243
|
+
runtime, arguments[0].asObject(runtime));
|
|
244
|
+
auto p2 = JsiSkPoint::fromValue(
|
|
245
|
+
runtime, arguments[1].asObject(runtime));
|
|
246
|
+
SkPath path;
|
|
247
|
+
path.moveTo(*p1);
|
|
248
|
+
path.lineTo(*p2);
|
|
249
|
+
auto hostObjectInstance =
|
|
250
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(path));
|
|
251
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
252
|
+
runtime, hostObjectInstance, getContext());
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
JSI_HOST_FUNCTION(Polygon) {
|
|
256
|
+
std::vector<SkPoint> points;
|
|
257
|
+
auto jsiPoints = arguments[0].asObject(runtime).asArray(runtime);
|
|
258
|
+
auto close = arguments[1].getBool();
|
|
259
|
+
auto pointsSize = jsiPoints.size(runtime);
|
|
260
|
+
points.reserve(pointsSize);
|
|
261
|
+
for (int i = 0; i < pointsSize; i++) {
|
|
262
|
+
std::shared_ptr<SkPoint> point = JsiSkPoint::fromValue(
|
|
263
|
+
runtime, jsiPoints.getValueAtIndex(runtime, i).asObject(runtime));
|
|
264
|
+
points.push_back(*point.get());
|
|
265
|
+
}
|
|
266
|
+
SkPath path;
|
|
267
|
+
auto p = SkSpan(points.data(), points.size());
|
|
268
|
+
path.addPoly(p, close);
|
|
269
|
+
auto hostObjectInstance =
|
|
270
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(path));
|
|
271
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
272
|
+
runtime, hostObjectInstance, getContext());
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Static path operations
|
|
276
|
+
JSI_HOST_FUNCTION(Stroke) {
|
|
277
|
+
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
278
|
+
SkPath path = srcPath->snapshot();
|
|
279
|
+
SkPaint p;
|
|
280
|
+
p.setStyle(SkPaint::kStroke_Style);
|
|
281
|
+
|
|
282
|
+
if (count > 1 && !arguments[1].isUndefined()) {
|
|
283
|
+
auto opts = arguments[1].asObject(runtime);
|
|
284
|
+
|
|
285
|
+
auto jsiCap = opts.getProperty(runtime, "cap");
|
|
286
|
+
if (!jsiCap.isUndefined()) {
|
|
287
|
+
auto cap = (SkPaint::Cap)jsiCap.asNumber();
|
|
288
|
+
p.setStrokeCap(cap);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
auto jsiJoin = opts.getProperty(runtime, "join");
|
|
292
|
+
if (!jsiJoin.isUndefined()) {
|
|
293
|
+
auto join = (SkPaint::Join)jsiJoin.asNumber();
|
|
294
|
+
p.setStrokeJoin(join);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
auto jsiWidth = opts.getProperty(runtime, "width");
|
|
298
|
+
if (!jsiWidth.isUndefined()) {
|
|
299
|
+
auto width = jsiWidth.asNumber();
|
|
300
|
+
p.setStrokeWidth(width);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
auto jsiMiterLimit = opts.getProperty(runtime, "miter_limit");
|
|
304
|
+
if (!jsiMiterLimit.isUndefined()) {
|
|
305
|
+
auto miter_limit = jsiMiterLimit.asNumber();
|
|
306
|
+
p.setStrokeMiter(miter_limit);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
auto jsiPrecision = opts.getProperty(runtime, "precision");
|
|
310
|
+
auto precision = jsiPrecision.isUndefined() ? 1 : jsiPrecision.asNumber();
|
|
311
|
+
SkPath result;
|
|
312
|
+
auto success =
|
|
313
|
+
skpathutils::FillPathWithPaint(path, p, &result, nullptr, precision);
|
|
314
|
+
if (success) {
|
|
315
|
+
auto hostObjectInstance =
|
|
316
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
317
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
318
|
+
runtime, hostObjectInstance, getContext());
|
|
319
|
+
}
|
|
320
|
+
} else {
|
|
321
|
+
SkPath result;
|
|
322
|
+
auto success =
|
|
323
|
+
skpathutils::FillPathWithPaint(path, p, &result, nullptr, 1);
|
|
324
|
+
if (success) {
|
|
325
|
+
auto hostObjectInstance =
|
|
326
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
327
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
328
|
+
runtime, hostObjectInstance, getContext());
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return jsi::Value::null();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
JSI_HOST_FUNCTION(Trim) {
|
|
335
|
+
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
336
|
+
float start = std::clamp(static_cast<float>(arguments[1].asNumber()), 0.0f, 1.0f);
|
|
337
|
+
float end = std::clamp(static_cast<float>(arguments[2].asNumber()), 0.0f, 1.0f);
|
|
338
|
+
auto isComplement = arguments[3].getBool();
|
|
339
|
+
// If requesting the full path in normal mode, just return a copy
|
|
340
|
+
if (start <= 0 && end >= 1 && !isComplement) {
|
|
341
|
+
SkPath result = srcPath->snapshot();
|
|
342
|
+
auto hostObjectInstance =
|
|
343
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
344
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
345
|
+
runtime, hostObjectInstance, getContext());
|
|
346
|
+
}
|
|
347
|
+
SkPath path = srcPath->snapshot();
|
|
348
|
+
auto mode = isComplement ? SkTrimPathEffect::Mode::kInverted
|
|
349
|
+
: SkTrimPathEffect::Mode::kNormal;
|
|
350
|
+
auto pe = SkTrimPathEffect::Make(start, end, mode);
|
|
351
|
+
if (!pe) {
|
|
352
|
+
return jsi::Value::null();
|
|
353
|
+
}
|
|
354
|
+
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
|
355
|
+
SkPathBuilder resultBuilder;
|
|
356
|
+
if (pe->filterPath(&resultBuilder, path, &rec)) {
|
|
357
|
+
auto result = resultBuilder.detach();
|
|
358
|
+
auto hostObjectInstance =
|
|
359
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
360
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
361
|
+
runtime, hostObjectInstance, getContext());
|
|
362
|
+
}
|
|
363
|
+
return jsi::Value::null();
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
JSI_HOST_FUNCTION(Simplify) {
|
|
367
|
+
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
368
|
+
auto result = ::Simplify(srcPath->snapshot());
|
|
369
|
+
if (result.has_value()) {
|
|
370
|
+
auto hostObjectInstance =
|
|
371
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result.value()));
|
|
372
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
373
|
+
runtime, hostObjectInstance, getContext());
|
|
374
|
+
}
|
|
375
|
+
return jsi::Value::null();
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
JSI_HOST_FUNCTION(Dash) {
|
|
379
|
+
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
380
|
+
SkScalar on = arguments[1].asNumber();
|
|
381
|
+
SkScalar off = arguments[2].asNumber();
|
|
382
|
+
auto phase = arguments[3].asNumber();
|
|
383
|
+
SkScalar intervals[] = {on, off};
|
|
384
|
+
auto i = SkSpan(intervals, 2);
|
|
385
|
+
auto pe = SkDashPathEffect::Make(i, phase);
|
|
386
|
+
if (!pe) {
|
|
387
|
+
return jsi::Value::null();
|
|
388
|
+
}
|
|
389
|
+
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
|
390
|
+
SkPathBuilder resultBuilder;
|
|
391
|
+
if (pe->filterPath(&resultBuilder, srcPath->snapshot(), &rec)) {
|
|
392
|
+
auto result = resultBuilder.detach();
|
|
393
|
+
auto hostObjectInstance =
|
|
394
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
395
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
396
|
+
runtime, hostObjectInstance, getContext());
|
|
397
|
+
}
|
|
398
|
+
return jsi::Value::null();
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
JSI_HOST_FUNCTION(AsWinding) {
|
|
402
|
+
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
403
|
+
auto result = ::AsWinding(srcPath->snapshot());
|
|
404
|
+
if (result.has_value()) {
|
|
405
|
+
auto hostObjectInstance =
|
|
406
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result.value()));
|
|
407
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
408
|
+
runtime, hostObjectInstance, getContext());
|
|
409
|
+
}
|
|
410
|
+
return jsi::Value::null();
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
JSI_HOST_FUNCTION(Interpolate) {
|
|
414
|
+
auto path1 = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
415
|
+
auto path2 = JsiSkPath::fromValue(runtime, arguments[1]);
|
|
416
|
+
auto weight = arguments[2].asNumber();
|
|
417
|
+
auto p1 = path1->snapshot();
|
|
418
|
+
auto p2 = path2->snapshot();
|
|
419
|
+
SkPath result;
|
|
420
|
+
auto succeed = p1.interpolate(p2, weight, &result);
|
|
421
|
+
if (!succeed) {
|
|
422
|
+
return jsi::Value::null();
|
|
423
|
+
}
|
|
424
|
+
auto hostObjectInstance =
|
|
425
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
426
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
427
|
+
runtime, hostObjectInstance, getContext());
|
|
428
|
+
}
|
|
429
|
+
|
|
173
430
|
size_t getMemoryPressure() const override { return 1024; }
|
|
174
431
|
|
|
175
432
|
std::string getObjectType() const override { return "JsiSkPathFactory"; }
|
|
@@ -178,7 +435,21 @@ public:
|
|
|
178
435
|
JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromSVGString),
|
|
179
436
|
JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromOp),
|
|
180
437
|
JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromCmds),
|
|
181
|
-
JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromText)
|
|
438
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromText),
|
|
439
|
+
// Static shape factories
|
|
440
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Rect),
|
|
441
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Oval),
|
|
442
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Circle),
|
|
443
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, RRect),
|
|
444
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Line),
|
|
445
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Polygon),
|
|
446
|
+
// Static path operations
|
|
447
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Stroke),
|
|
448
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Trim),
|
|
449
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Simplify),
|
|
450
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Dash),
|
|
451
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, AsWinding),
|
|
452
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Interpolate))
|
|
182
453
|
|
|
183
454
|
explicit JsiSkPathFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
184
455
|
: JsiSkHostObject(std::move(context)) {}
|
|
@@ -141,7 +141,7 @@ std::shared_ptr<SkPath> processPath(jsi::Runtime &runtime,
|
|
|
141
141
|
auto ptr = std::dynamic_pointer_cast<JsiSkPath>(
|
|
142
142
|
value.asObject(runtime).asHostObject(runtime));
|
|
143
143
|
if (ptr != nullptr) {
|
|
144
|
-
return ptr->getObject();
|
|
144
|
+
return std::make_shared<SkPath>(ptr->getObject()->snapshot());
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
return nullptr;
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
#include "ImageFit.h"
|
|
9
9
|
#include "RNSkPlatformContext.h"
|
|
10
10
|
|
|
11
|
+
#include "include/core/SkPathBuilder.h"
|
|
12
|
+
#include "include/core/SkStrokeRec.h"
|
|
13
|
+
|
|
11
14
|
namespace RNSkia {
|
|
12
15
|
|
|
13
16
|
struct CircleCmdProps {
|
|
@@ -123,12 +126,13 @@ public:
|
|
|
123
126
|
SkTrimPathEffect::Make(start, end, SkTrimPathEffect::Mode::kNormal);
|
|
124
127
|
if (pe != nullptr) {
|
|
125
128
|
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
|
126
|
-
|
|
129
|
+
SkPathBuilder filteredBuilder;
|
|
130
|
+
if (!pe->filterPath(&filteredBuilder, filteredPath, &rec)) {
|
|
127
131
|
throw std::runtime_error(
|
|
128
132
|
"Failed trimming path with parameters start: " +
|
|
129
133
|
std::to_string(start) + ", end: " + std::to_string(end));
|
|
130
134
|
}
|
|
131
|
-
filteredPath.
|
|
135
|
+
filteredPath = filteredBuilder.detach();
|
|
132
136
|
} else {
|
|
133
137
|
throw std::runtime_error(
|
|
134
138
|
"Failed trimming path with parameters start: " +
|
|
@@ -188,6 +188,27 @@ public:
|
|
|
188
188
|
// Get the wgpu::Device for WebGPU bindings
|
|
189
189
|
wgpu::Device getWGPUDevice() { return backendContext.fDevice; }
|
|
190
190
|
|
|
191
|
+
// Create a secondary Dawn device from the same adapter.
|
|
192
|
+
// Has its own command queue and does NOT enable ImplicitDeviceSynchronization,
|
|
193
|
+
// so it won't contend with the primary rendering device's mutex.
|
|
194
|
+
// Safe for concurrent GPU work (e.g. ML inference) alongside Skia rendering.
|
|
195
|
+
wgpu::Device createSecondaryDevice() {
|
|
196
|
+
auto adapter = DawnUtils::getMatchedAdapter(instance.get());
|
|
197
|
+
|
|
198
|
+
std::vector<wgpu::FeatureName> features = {
|
|
199
|
+
wgpu::FeatureName::BufferMapExtendedUsages,
|
|
200
|
+
#ifdef __APPLE__
|
|
201
|
+
wgpu::FeatureName::SharedTextureMemoryIOSurface,
|
|
202
|
+
wgpu::FeatureName::DawnMultiPlanarFormats,
|
|
203
|
+
// Note: SharedFenceMTLSharedEvent intentionally NOT enabled — it causes
|
|
204
|
+
// EndAccess to encode fence signals that crash with "uncommitted encoder".
|
|
205
|
+
// IOSurface data is already written by the camera before we read it.
|
|
206
|
+
#endif
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
return DawnUtils::requestDevice(adapter, features, false);
|
|
210
|
+
}
|
|
211
|
+
|
|
191
212
|
// Create an SkImage from a WebGPU texture
|
|
192
213
|
// The texture must have TextureBinding usage
|
|
193
214
|
sk_sp<SkImage> MakeImageFromTexture(wgpu::Texture texture, int width,
|
package/cpp/rnskia/RNDawnUtils.h
CHANGED
|
@@ -21,35 +21,21 @@ static const wgpu::TextureFormat PreferredTextureFormat =
|
|
|
21
21
|
wgpu::TextureFormat::RGBA8Unorm;
|
|
22
22
|
#endif
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"skip_validation",
|
|
31
|
-
#endif
|
|
32
|
-
"disable_lazy_clear_for_mapped_at_creation_buffer",
|
|
33
|
-
"allow_unsafe_apis",
|
|
34
|
-
"use_user_defined_labels_in_backend",
|
|
35
|
-
"disable_robustness",
|
|
36
|
-
"use_tint_ir",
|
|
37
|
-
};
|
|
38
|
-
wgpu::DawnTogglesDescriptor togglesDesc;
|
|
39
|
-
togglesDesc.enabledToggleCount = std::size(kToggles) - (useTintIR ? 0 : 1);
|
|
40
|
-
togglesDesc.enabledToggles = kToggles;
|
|
41
|
-
|
|
42
|
-
dawn::native::Adapter matchedAdaptor;
|
|
43
|
-
|
|
44
|
-
wgpu::RequestAdapterOptions options;
|
|
24
|
+
// Find the best matching GPU adapter for the current platform.
|
|
25
|
+
// Sorts by adapter type (DiscreteGPU > IntegratedGPU > CPU) and selects the
|
|
26
|
+
// first adapter matching the platform backend (Metal on Apple, Vulkan on
|
|
27
|
+
// Android).
|
|
28
|
+
inline dawn::native::Adapter
|
|
29
|
+
getMatchedAdapter(dawn::native::Instance *instance) {
|
|
45
30
|
#ifdef __APPLE__
|
|
46
31
|
constexpr auto kDefaultBackendType = wgpu::BackendType::Metal;
|
|
47
32
|
#elif __ANDROID__
|
|
48
33
|
constexpr auto kDefaultBackendType = wgpu::BackendType::Vulkan;
|
|
49
34
|
#endif
|
|
35
|
+
|
|
36
|
+
wgpu::RequestAdapterOptions options;
|
|
50
37
|
options.backendType = kDefaultBackendType;
|
|
51
38
|
options.featureLevel = wgpu::FeatureLevel::Core;
|
|
52
|
-
options.nextInChain = &togglesDesc;
|
|
53
39
|
|
|
54
40
|
std::vector<dawn::native::Adapter> adapters =
|
|
55
41
|
instance->EnumerateAdapters(&options);
|
|
@@ -57,8 +43,6 @@ createDawnBackendContext(dawn::native::Instance *instance) {
|
|
|
57
43
|
throw std::runtime_error("No matching adapter found");
|
|
58
44
|
}
|
|
59
45
|
|
|
60
|
-
// Sort adapters by adapterType(DiscreteGPU, IntegratedGPU, CPU) and
|
|
61
|
-
// backendType(Metal, Vulkan, OpenGL, OpenGLES, WebGPU).
|
|
62
46
|
std::sort(adapters.begin(), adapters.end(),
|
|
63
47
|
[](dawn::native::Adapter a, dawn::native::Adapter b) {
|
|
64
48
|
wgpu::Adapter wgpuA = a.Get();
|
|
@@ -76,16 +60,93 @@ createDawnBackendContext(dawn::native::Instance *instance) {
|
|
|
76
60
|
wgpu::AdapterInfo props;
|
|
77
61
|
wgpuAdapter.GetInfo(&props);
|
|
78
62
|
if (kDefaultBackendType == props.backendType) {
|
|
79
|
-
|
|
80
|
-
break;
|
|
63
|
+
return adapter;
|
|
81
64
|
}
|
|
82
65
|
}
|
|
83
66
|
|
|
84
|
-
|
|
85
|
-
|
|
67
|
+
throw std::runtime_error("No matching adapter found");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Create a Dawn device from the given adapter with the requested features.
|
|
71
|
+
// Features not supported by the adapter are silently skipped.
|
|
72
|
+
// Set fatalOnDeviceLost=true for primary rendering devices (SK_ABORT on loss),
|
|
73
|
+
// false for secondary/compute devices (log only).
|
|
74
|
+
inline wgpu::Device
|
|
75
|
+
requestDevice(dawn::native::Adapter &nativeAdapter,
|
|
76
|
+
const std::vector<wgpu::FeatureName> &requestedFeatures,
|
|
77
|
+
bool fatalOnDeviceLost = true) {
|
|
78
|
+
wgpu::Adapter adapter = nativeAdapter.Get();
|
|
79
|
+
|
|
80
|
+
// Filter to only features the adapter supports
|
|
81
|
+
std::vector<wgpu::FeatureName> features;
|
|
82
|
+
for (auto feature : requestedFeatures) {
|
|
83
|
+
if (adapter.HasFeature(feature)) {
|
|
84
|
+
features.push_back(feature);
|
|
85
|
+
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
static constexpr const char *kToggles[] = {
|
|
89
|
+
#if !defined(SK_DEBUG)
|
|
90
|
+
"skip_validation",
|
|
91
|
+
#endif
|
|
92
|
+
"disable_lazy_clear_for_mapped_at_creation_buffer",
|
|
93
|
+
"allow_unsafe_apis",
|
|
94
|
+
"use_user_defined_labels_in_backend",
|
|
95
|
+
"disable_robustness",
|
|
96
|
+
};
|
|
97
|
+
wgpu::DawnTogglesDescriptor togglesDesc;
|
|
98
|
+
togglesDesc.enabledToggleCount = std::size(kToggles);
|
|
99
|
+
togglesDesc.enabledToggles = kToggles;
|
|
100
|
+
|
|
101
|
+
wgpu::DeviceDescriptor desc;
|
|
102
|
+
desc.requiredFeatureCount = features.size();
|
|
103
|
+
desc.requiredFeatures = features.data();
|
|
104
|
+
desc.nextInChain = &togglesDesc;
|
|
105
|
+
|
|
106
|
+
if (fatalOnDeviceLost) {
|
|
107
|
+
desc.SetDeviceLostCallback(
|
|
108
|
+
wgpu::CallbackMode::AllowSpontaneous,
|
|
109
|
+
[](const wgpu::Device &, wgpu::DeviceLostReason reason,
|
|
110
|
+
wgpu::StringView message) {
|
|
111
|
+
if (reason != wgpu::DeviceLostReason::Destroyed) {
|
|
112
|
+
SK_ABORT("Device lost: %.*s\n",
|
|
113
|
+
static_cast<int>(message.length), message.data);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
desc.SetUncapturedErrorCallback(
|
|
117
|
+
[](const wgpu::Device &, wgpu::ErrorType,
|
|
118
|
+
wgpu::StringView message) {
|
|
119
|
+
SkDebugf("Device error: %.*s\n",
|
|
120
|
+
static_cast<int>(message.length), message.data);
|
|
121
|
+
});
|
|
122
|
+
} else {
|
|
123
|
+
desc.SetDeviceLostCallback(
|
|
124
|
+
wgpu::CallbackMode::AllowSpontaneous,
|
|
125
|
+
[](const wgpu::Device &, wgpu::DeviceLostReason reason,
|
|
126
|
+
wgpu::StringView message) {
|
|
127
|
+
if (reason != wgpu::DeviceLostReason::Destroyed) {
|
|
128
|
+
RNSkia::RNSkLogger::logToConsole(
|
|
129
|
+
"Device lost: %.*s",
|
|
130
|
+
static_cast<int>(message.length), message.data);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
desc.SetUncapturedErrorCallback(
|
|
134
|
+
[](const wgpu::Device &, wgpu::ErrorType,
|
|
135
|
+
wgpu::StringView message) {
|
|
136
|
+
RNSkia::RNSkLogger::logToConsole(
|
|
137
|
+
"Device error: %.*s",
|
|
138
|
+
static_cast<int>(message.length), message.data);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return wgpu::Device::Acquire(nativeAdapter.CreateDevice(&desc));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
inline skgpu::graphite::DawnBackendContext
|
|
146
|
+
createDawnBackendContext(dawn::native::Instance *instance) {
|
|
147
|
+
|
|
148
|
+
auto matchedAdapter = getMatchedAdapter(instance);
|
|
149
|
+
wgpu::Adapter adapter = matchedAdapter.Get();
|
|
89
150
|
|
|
90
151
|
// Log selected adapter info
|
|
91
152
|
wgpu::AdapterInfo adapterInfo;
|
|
@@ -130,93 +191,34 @@ createDawnBackendContext(dawn::native::Instance *instance) {
|
|
|
130
191
|
"Selected Dawn adapter - Backend: %s, Device: %s, Description: %s",
|
|
131
192
|
backendName.c_str(), deviceName.c_str(), description.c_str());
|
|
132
193
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (adapter.HasFeature(wgpu::FeatureName::BufferMapExtendedUsages)) {
|
|
150
|
-
features.push_back(wgpu::FeatureName::BufferMapExtendedUsages);
|
|
151
|
-
}
|
|
152
|
-
if (adapter.HasFeature(wgpu::FeatureName::TextureCompressionETC2)) {
|
|
153
|
-
features.push_back(wgpu::FeatureName::TextureCompressionETC2);
|
|
154
|
-
}
|
|
155
|
-
if (adapter.HasFeature(wgpu::FeatureName::TextureCompressionBC)) {
|
|
156
|
-
features.push_back(wgpu::FeatureName::TextureCompressionBC);
|
|
157
|
-
}
|
|
158
|
-
if (adapter.HasFeature(wgpu::FeatureName::R8UnormStorage)) {
|
|
159
|
-
features.push_back(wgpu::FeatureName::R8UnormStorage);
|
|
160
|
-
}
|
|
161
|
-
if (adapter.HasFeature(wgpu::FeatureName::DawnLoadResolveTexture)) {
|
|
162
|
-
features.push_back(wgpu::FeatureName::DawnLoadResolveTexture);
|
|
163
|
-
}
|
|
164
|
-
if (adapter.HasFeature(wgpu::FeatureName::DawnPartialLoadResolveTexture)) {
|
|
165
|
-
features.push_back(wgpu::FeatureName::DawnPartialLoadResolveTexture);
|
|
166
|
-
}
|
|
167
|
-
if (adapter.HasFeature(wgpu::FeatureName::TimestampQuery)) {
|
|
168
|
-
features.push_back(wgpu::FeatureName::TimestampQuery);
|
|
169
|
-
}
|
|
170
|
-
if (adapter.HasFeature(wgpu::FeatureName::DawnTexelCopyBufferRowAlignment)) {
|
|
171
|
-
features.push_back(wgpu::FeatureName::DawnTexelCopyBufferRowAlignment);
|
|
172
|
-
}
|
|
173
|
-
if (adapter.HasFeature(wgpu::FeatureName::ImplicitDeviceSynchronization)) {
|
|
174
|
-
features.push_back(wgpu::FeatureName::ImplicitDeviceSynchronization);
|
|
175
|
-
}
|
|
194
|
+
// Primary device features — request everything Skia/Graphite can use
|
|
195
|
+
std::vector<wgpu::FeatureName> features = {
|
|
196
|
+
wgpu::FeatureName::MSAARenderToSingleSampled,
|
|
197
|
+
wgpu::FeatureName::TransientAttachments,
|
|
198
|
+
wgpu::FeatureName::Unorm16TextureFormats,
|
|
199
|
+
wgpu::FeatureName::DualSourceBlending,
|
|
200
|
+
wgpu::FeatureName::FramebufferFetch,
|
|
201
|
+
wgpu::FeatureName::BufferMapExtendedUsages,
|
|
202
|
+
wgpu::FeatureName::TextureCompressionETC2,
|
|
203
|
+
wgpu::FeatureName::TextureCompressionBC,
|
|
204
|
+
wgpu::FeatureName::R8UnormStorage,
|
|
205
|
+
wgpu::FeatureName::DawnLoadResolveTexture,
|
|
206
|
+
wgpu::FeatureName::DawnPartialLoadResolveTexture,
|
|
207
|
+
wgpu::FeatureName::TimestampQuery,
|
|
208
|
+
wgpu::FeatureName::DawnTexelCopyBufferRowAlignment,
|
|
209
|
+
wgpu::FeatureName::ImplicitDeviceSynchronization,
|
|
176
210
|
#ifdef __APPLE__
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
if (adapter.HasFeature(wgpu::FeatureName::MultiPlanarFormatP010)) {
|
|
184
|
-
features.push_back(wgpu::FeatureName::MultiPlanarFormatP010);
|
|
185
|
-
}
|
|
186
|
-
if (adapter.HasFeature(wgpu::FeatureName::MultiPlanarFormatP210)) {
|
|
187
|
-
features.push_back(wgpu::FeatureName::MultiPlanarFormatP210);
|
|
188
|
-
}
|
|
189
|
-
if (adapter.HasFeature(wgpu::FeatureName::MultiPlanarFormatExtendedUsages)) {
|
|
190
|
-
features.push_back(wgpu::FeatureName::MultiPlanarFormatExtendedUsages);
|
|
191
|
-
}
|
|
211
|
+
wgpu::FeatureName::SharedTextureMemoryIOSurface,
|
|
212
|
+
wgpu::FeatureName::DawnMultiPlanarFormats,
|
|
213
|
+
wgpu::FeatureName::MultiPlanarFormatP010,
|
|
214
|
+
wgpu::FeatureName::MultiPlanarFormatP210,
|
|
215
|
+
wgpu::FeatureName::MultiPlanarFormatExtendedUsages,
|
|
192
216
|
#else
|
|
193
|
-
|
|
194
|
-
wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer)) {
|
|
195
|
-
features.push_back(wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer);
|
|
196
|
-
}
|
|
217
|
+
wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer,
|
|
197
218
|
#endif
|
|
219
|
+
};
|
|
198
220
|
|
|
199
|
-
wgpu::
|
|
200
|
-
desc.requiredFeatureCount = features.size();
|
|
201
|
-
desc.requiredFeatures = features.data();
|
|
202
|
-
desc.nextInChain = &togglesDesc;
|
|
203
|
-
desc.SetDeviceLostCallback(
|
|
204
|
-
wgpu::CallbackMode::AllowSpontaneous,
|
|
205
|
-
[](const wgpu::Device &, wgpu::DeviceLostReason reason,
|
|
206
|
-
wgpu::StringView message) {
|
|
207
|
-
if (reason != wgpu::DeviceLostReason::Destroyed) {
|
|
208
|
-
SK_ABORT("Device lost: %.*s\n", static_cast<int>(message.length),
|
|
209
|
-
message.data);
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
desc.SetUncapturedErrorCallback(
|
|
213
|
-
[](const wgpu::Device &, wgpu::ErrorType, wgpu::StringView message) {
|
|
214
|
-
SkDebugf("Device error: %.*s\n", static_cast<int>(message.length),
|
|
215
|
-
message.data);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
wgpu::Device device =
|
|
219
|
-
wgpu::Device::Acquire(matchedAdaptor.CreateDevice(&desc));
|
|
221
|
+
wgpu::Device device = requestDevice(matchedAdapter, features, true);
|
|
220
222
|
SkASSERT(device);
|
|
221
223
|
|
|
222
224
|
skgpu::graphite::DawnBackendContext backendContext;
|
|
@@ -227,4 +229,4 @@ createDawnBackendContext(dawn::native::Instance *instance) {
|
|
|
227
229
|
return backendContext;
|
|
228
230
|
}
|
|
229
231
|
|
|
230
|
-
} // namespace DawnUtils
|
|
232
|
+
} // namespace DawnUtils
|
|
@@ -16,4 +16,4 @@ import type { ExtrapolationType } from "./interpolate";
|
|
|
16
16
|
* path2.lineTo(0, 100);
|
|
17
17
|
* const path = interpolatePath(0.5, [0, 1], [path1, path2]);
|
|
18
18
|
*/
|
|
19
|
-
export declare const interpolatePaths: (value: number, input: number[], outputRange: SkPath[], options?: ExtrapolationType,
|
|
19
|
+
export declare const interpolatePaths: (value: number, input: number[], outputRange: SkPath[], options?: ExtrapolationType, _output?: SkPath) => SkPath;
|