@shopify/react-native-skia 2.6.0 → 2.6.2
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/android/CMakeLists.txt +0 -1
- package/android/cpp/jni/JniWebGPUView.cpp +3 -3
- package/android/cpp/rnskia-android/OpenGLContext.h +4 -5
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +1 -1
- package/apple/MetalContext.h +5 -6
- package/apple/MetalWindowContext.mm +3 -4
- package/apple/RNSkApplePlatformContext.h +1 -1
- package/apple/RNSkApplePlatformContext.mm +4 -3
- package/apple/SkiaCVPixelBufferUtils.h +1 -1
- package/apple/SkiaCVPixelBufferUtils.mm +31 -30
- package/apple/SkiaPlatformContext.mm +2 -2
- package/apple/SkiaUIView.mm +1 -1
- package/apple/SkiaWebGPUView.mm +8 -4
- package/apple/WebGPUMetalView.h +1 -1
- package/apple/WebGPUMetalView.mm +1 -1
- package/cpp/api/JsiSkColor.h +8 -4
- package/cpp/api/JsiSkContourMeasure.h +4 -3
- package/cpp/api/JsiSkImage.h +17 -9
- package/cpp/api/JsiSkParagraphBuilder.h +14 -1
- package/cpp/api/JsiSkPath.h +71 -81
- package/cpp/api/JsiSkPathEffectFactory.h +2 -1
- package/cpp/api/JsiSkPathFactory.h +48 -52
- package/cpp/api/JsiSkShader.h +1 -1
- package/cpp/api/JsiSkShaderFactory.h +50 -26
- package/cpp/api/JsiSkSurfaceFactory.h +2 -1
- package/cpp/api/recorder/Drawings.h +5 -7
- package/cpp/api/recorder/Shaders.h +77 -22
- package/cpp/jsi2/JSIConverter.h +1 -1
- package/cpp/rnskia/RNDawnContext.h +14 -15
- package/cpp/rnskia/RNDawnUtils.h +14 -17
- package/cpp/rnskia/RNDawnWindowContext.h +1 -1
- package/cpp/rnskia/RNSkManager.cpp +5 -4
- package/cpp/rnskia/RNSkPlatformContext.h +2 -2
- package/cpp/rnwgpu/api/GPU.cpp +21 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +1 -1
- package/cpp/rnwgpu/api/GPUCanvasContext.h +2 -2
- package/cpp/rnwgpu/api/GPUFeatures.h +0 -9
- package/cpp/rnwgpu/api/GPUTexture.h +14 -2
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +3 -4
- package/cpp/rnwgpu/api/RNWebGPU.h +1 -1
- package/cpp/rnwgpu/api/descriptors/Unions.h +0 -15
- package/cpp/skia/include/android/SkImageAndroid.h +7 -2
- package/cpp/skia/include/android/vk/AndroidVulkanMemoryAllocator.h +31 -0
- package/cpp/skia/include/codec/SkCodec.h +42 -15
- package/cpp/skia/include/config/SkUserConfig.h +8 -0
- package/cpp/skia/include/core/SkBitmap.h +0 -5
- package/cpp/skia/include/core/SkCanvas.h +2 -39
- package/cpp/skia/include/core/SkColor.h +12 -0
- package/cpp/skia/include/core/SkColorSpace.h +9 -0
- package/cpp/skia/include/core/SkContourMeasure.h +1 -5
- package/cpp/skia/include/core/SkData.h +8 -0
- package/cpp/skia/include/core/SkFont.h +1 -55
- package/cpp/skia/include/core/SkFontArguments.h +15 -0
- package/cpp/skia/include/core/SkGraphics.h +0 -5
- package/cpp/skia/include/core/SkImage.h +0 -4
- package/cpp/skia/include/core/SkImageGenerator.h +1 -4
- package/cpp/skia/include/core/SkMatrix.h +0 -37
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkPath.h +11 -911
- package/cpp/skia/include/core/SkPathBuilder.h +42 -32
- package/cpp/skia/include/core/SkPathEffect.h +0 -9
- package/cpp/skia/include/core/SkPathMeasure.h +1 -4
- package/cpp/skia/include/core/SkPathUtils.h +0 -10
- package/cpp/skia/include/core/SkRect.h +0 -12
- package/cpp/skia/include/core/SkRegion.h +1 -6
- package/cpp/skia/include/core/SkSerialProcs.h +4 -5
- package/cpp/skia/include/core/SkSurfaceProps.h +6 -0
- package/cpp/skia/include/core/SkTextBlob.h +0 -22
- package/cpp/skia/include/core/SkTypeface.h +14 -32
- package/cpp/skia/include/core/SkTypes.h +0 -8
- package/cpp/skia/include/docs/SkPDFDocument.h +19 -17
- package/cpp/skia/include/effects/SkDashPathEffect.h +0 -6
- package/cpp/skia/include/effects/SkGradient.h +206 -0
- package/cpp/skia/include/effects/SkHighContrastFilter.h +2 -2
- package/cpp/skia/include/gpu/GpuTypes.h +2 -0
- package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +5 -35
- package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +7 -106
- package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +0 -11
- package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +0 -9
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSemaphore.h +20 -0
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSurface.h +59 -0
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +28 -0
- package/cpp/skia/include/gpu/ganesh/gl/GrGLFunctions.h +4 -1
- package/cpp/skia/include/gpu/graphite/ContextOptions.h +4 -20
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +32 -46
- package/cpp/skia/include/gpu/graphite/Recorder.h +1 -1
- package/cpp/skia/include/gpu/graphite/Surface.h +31 -0
- package/cpp/skia/include/gpu/graphite/TextureInfo.h +3 -10
- package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +3 -3
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -1
- package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +6 -6
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +5 -3
- package/cpp/skia/include/gpu/graphite/vk/precompile/VulkanPrecompileShader.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanBackendContext.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanPreferredFeatures.h +8 -0
- package/cpp/skia/include/private/SkEncodedInfo.h +43 -105
- package/cpp/skia/include/private/SkHdrMetadata.h +165 -2
- package/cpp/skia/include/private/SkPathRef.h +0 -457
- package/cpp/skia/include/private/base/SkFeatures.h +4 -0
- package/cpp/skia/include/private/base/SkFloatingPoint.h +1 -2
- package/cpp/skia/include/private/base/SkLoadUserConfig.h +2 -1
- package/cpp/skia/include/private/base/SkLog.h +68 -0
- package/cpp/skia/include/private/base/SkLogPriority.h +35 -0
- package/cpp/skia/include/private/base/SkMacros.h +9 -0
- package/cpp/skia/include/private/base/SkTArray.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrD3DTypesMinimal.h +10 -24
- package/cpp/skia/include/utils/SkEventTracer.h +5 -7
- package/cpp/skia/modules/skottie/include/TextShaper.h +0 -7
- package/cpp/skia/modules/skparagraph/include/FontCollection.h +6 -20
- package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +0 -6
- package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +4 -19
- package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +2 -3
- package/cpp/skia/modules/skunicode/include/SkUnicode_icu.h +18 -0
- package/cpp/skia/modules/skunicode/include/SkUnicode_libgrapheme.h +19 -0
- package/cpp/skia/src/base/SkMathPriv.h +27 -132
- package/package.json +5 -5
- package/cpp/skia/include/effects/SkGradientShader.h +0 -359
- package/cpp/skia/include/gpu/graphite/LogPriority.h +0 -36
package/cpp/api/JsiSkPath.h
CHANGED
|
@@ -54,7 +54,8 @@ inline void warnDeprecatedPathMethod(jsi::Runtime &runtime,
|
|
|
54
54
|
warnings.insert(methodName);
|
|
55
55
|
std::string message =
|
|
56
56
|
std::string("[react-native-skia] SkPath.") + methodName +
|
|
57
|
-
"() is deprecated and will be removed in a future release. " +
|
|
57
|
+
"() is deprecated and will be removed in a future release. " +
|
|
58
|
+
suggestion +
|
|
58
59
|
" See migration guide: "
|
|
59
60
|
"https://shopify.github.io/react-native-skia/docs/shapes/path-migration";
|
|
60
61
|
RNSkLogger::warnToJavascriptConsole(runtime, message);
|
|
@@ -213,8 +214,8 @@ public:
|
|
|
213
214
|
? JsiSkMatrix::fromValue(runtime, arguments[1])
|
|
214
215
|
: nullptr;
|
|
215
216
|
auto extend = count > 2 && arguments[2].getBool();
|
|
216
|
-
auto mode =
|
|
217
|
-
|
|
217
|
+
auto mode =
|
|
218
|
+
extend ? SkPath::kExtend_AddPathMode : SkPath::kAppend_AddPathMode;
|
|
218
219
|
if (matrix) {
|
|
219
220
|
getObject()->addPath(srcPath, *matrix, mode);
|
|
220
221
|
} else {
|
|
@@ -234,45 +235,43 @@ public:
|
|
|
234
235
|
}
|
|
235
236
|
|
|
236
237
|
JSI_HOST_FUNCTION(addOval) {
|
|
237
|
-
warnDeprecatedPathMethod(
|
|
238
|
-
"addOval",
|
|
238
|
+
warnDeprecatedPathMethod(
|
|
239
|
+
runtime, "addOval",
|
|
239
240
|
"Use Skia.Path.Oval() or Skia.PathBuilder.Make().addOval() instead.");
|
|
240
241
|
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
241
242
|
auto isCCW = count > 1 && arguments[1].getBool();
|
|
242
|
-
auto startIndex =
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
auto startIndex =
|
|
244
|
+
count > 2 ? static_cast<unsigned>(arguments[2].asNumber()) : 1;
|
|
245
|
+
auto direction = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
245
246
|
getObject()->addOval(*rect, direction, startIndex);
|
|
246
247
|
return thisValue.getObject(runtime);
|
|
247
248
|
}
|
|
248
249
|
|
|
249
250
|
JSI_HOST_FUNCTION(addRect) {
|
|
250
|
-
warnDeprecatedPathMethod(
|
|
251
|
-
"addRect",
|
|
251
|
+
warnDeprecatedPathMethod(
|
|
252
|
+
runtime, "addRect",
|
|
252
253
|
"Use Skia.Path.Rect() or Skia.PathBuilder.Make().addRect() instead.");
|
|
253
254
|
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
254
255
|
auto isCCW = count > 1 && arguments[1].getBool();
|
|
255
|
-
auto direction =
|
|
256
|
-
isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
256
|
+
auto direction = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
257
257
|
getObject()->addRect(*rect, direction);
|
|
258
258
|
return thisValue.getObject(runtime);
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
JSI_HOST_FUNCTION(addRRect) {
|
|
262
|
-
warnDeprecatedPathMethod(
|
|
263
|
-
"addRRect",
|
|
262
|
+
warnDeprecatedPathMethod(
|
|
263
|
+
runtime, "addRRect",
|
|
264
264
|
"Use Skia.Path.RRect() or Skia.PathBuilder.Make().addRRect() instead.");
|
|
265
265
|
auto rrect = JsiSkRRect::fromValue(runtime, arguments[0]);
|
|
266
266
|
auto isCCW = count > 1 && arguments[1].getBool();
|
|
267
|
-
auto direction =
|
|
268
|
-
isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
267
|
+
auto direction = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
269
268
|
getObject()->addRRect(*rrect, direction);
|
|
270
269
|
return thisValue.getObject(runtime);
|
|
271
270
|
}
|
|
272
271
|
|
|
273
272
|
JSI_HOST_FUNCTION(addCircle) {
|
|
274
|
-
warnDeprecatedPathMethod(
|
|
275
|
-
"addCircle",
|
|
273
|
+
warnDeprecatedPathMethod(
|
|
274
|
+
runtime, "addCircle",
|
|
276
275
|
"Use Skia.Path.Circle() or Skia.PathBuilder.Make().addCircle() "
|
|
277
276
|
"instead.");
|
|
278
277
|
SkScalar x = arguments[0].asNumber();
|
|
@@ -283,8 +282,8 @@ public:
|
|
|
283
282
|
}
|
|
284
283
|
|
|
285
284
|
JSI_HOST_FUNCTION(addPoly) {
|
|
286
|
-
warnDeprecatedPathMethod(
|
|
287
|
-
"addPoly",
|
|
285
|
+
warnDeprecatedPathMethod(
|
|
286
|
+
runtime, "addPoly",
|
|
288
287
|
"Use Skia.Path.Polygon() or Skia.PathBuilder.Make().addPoly() "
|
|
289
288
|
"instead.");
|
|
290
289
|
auto jsiPoints = arguments[0].asObject(runtime).asArray(runtime);
|
|
@@ -293,8 +292,8 @@ public:
|
|
|
293
292
|
std::vector<SkPoint> points;
|
|
294
293
|
points.reserve(pointsSize);
|
|
295
294
|
for (int i = 0; i < pointsSize; i++) {
|
|
296
|
-
auto pt =
|
|
297
|
-
runtime, jsiPoints.getValueAtIndex(runtime, i));
|
|
295
|
+
auto pt =
|
|
296
|
+
JsiSkPoint::fromValue(runtime, jsiPoints.getValueAtIndex(runtime, i));
|
|
298
297
|
points.push_back(*pt);
|
|
299
298
|
}
|
|
300
299
|
getObject()->addPolygon(SkSpan<const SkPoint>(points.data(), points.size()),
|
|
@@ -303,8 +302,9 @@ public:
|
|
|
303
302
|
}
|
|
304
303
|
|
|
305
304
|
JSI_HOST_FUNCTION(arcToOval) {
|
|
306
|
-
warnDeprecatedPathMethod(
|
|
307
|
-
|
|
305
|
+
warnDeprecatedPathMethod(
|
|
306
|
+
runtime, "arcToOval",
|
|
307
|
+
"Use Skia.PathBuilder.Make().arcToOval() instead.");
|
|
308
308
|
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
309
309
|
auto start = arguments[1].asNumber();
|
|
310
310
|
auto sweep = arguments[2].asNumber();
|
|
@@ -314,8 +314,9 @@ public:
|
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
JSI_HOST_FUNCTION(arcToRotated) {
|
|
317
|
-
warnDeprecatedPathMethod(
|
|
318
|
-
|
|
317
|
+
warnDeprecatedPathMethod(
|
|
318
|
+
runtime, "arcToRotated",
|
|
319
|
+
"Use Skia.PathBuilder.Make().arcToRotated() instead.");
|
|
319
320
|
SkScalar rx = arguments[0].asNumber();
|
|
320
321
|
SkScalar ry = arguments[1].asNumber();
|
|
321
322
|
SkScalar xAxisRotate = arguments[2].asNumber();
|
|
@@ -325,8 +326,7 @@ public:
|
|
|
325
326
|
SkScalar y = arguments[6].asNumber();
|
|
326
327
|
auto arcSize = useSmallArc ? SkPathBuilder::kSmall_ArcSize
|
|
327
328
|
: SkPathBuilder::kLarge_ArcSize;
|
|
328
|
-
auto sweep =
|
|
329
|
-
isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
329
|
+
auto sweep = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
330
330
|
getObject()->arcTo(SkPoint::Make(rx, ry), xAxisRotate, arcSize, sweep,
|
|
331
331
|
SkPoint::Make(x, y));
|
|
332
332
|
return thisValue.getObject(runtime);
|
|
@@ -344,8 +344,7 @@ public:
|
|
|
344
344
|
SkScalar dy = arguments[6].asNumber();
|
|
345
345
|
auto arcSize = useSmallArc ? SkPathBuilder::kSmall_ArcSize
|
|
346
346
|
: SkPathBuilder::kLarge_ArcSize;
|
|
347
|
-
auto sweep =
|
|
348
|
-
isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
347
|
+
auto sweep = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
349
348
|
SkVector dxdy(dx, dy);
|
|
350
349
|
SkPoint r(rx, ry);
|
|
351
350
|
getObject()->rArcTo(r, xAxisRotate, arcSize, sweep, dxdy);
|
|
@@ -353,8 +352,9 @@ public:
|
|
|
353
352
|
}
|
|
354
353
|
|
|
355
354
|
JSI_HOST_FUNCTION(arcToTangent) {
|
|
356
|
-
warnDeprecatedPathMethod(
|
|
357
|
-
|
|
355
|
+
warnDeprecatedPathMethod(
|
|
356
|
+
runtime, "arcToTangent",
|
|
357
|
+
"Use Skia.PathBuilder.Make().arcToTangent() instead.");
|
|
358
358
|
SkScalar x1 = arguments[0].asNumber();
|
|
359
359
|
SkScalar y1 = arguments[1].asNumber();
|
|
360
360
|
SkScalar x2 = arguments[2].asNumber();
|
|
@@ -365,16 +365,18 @@ public:
|
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
JSI_HOST_FUNCTION(setFillType) {
|
|
368
|
-
warnDeprecatedPathMethod(
|
|
369
|
-
|
|
368
|
+
warnDeprecatedPathMethod(
|
|
369
|
+
runtime, "setFillType",
|
|
370
|
+
"Use Skia.PathBuilder.Make().setFillType() instead.");
|
|
370
371
|
auto ft = arguments[0].asNumber();
|
|
371
372
|
getObject()->setFillType(static_cast<SkPathFillType>(static_cast<int>(ft)));
|
|
372
373
|
return thisValue.getObject(runtime);
|
|
373
374
|
}
|
|
374
375
|
|
|
375
376
|
JSI_HOST_FUNCTION(setIsVolatile) {
|
|
376
|
-
warnDeprecatedPathMethod(
|
|
377
|
-
|
|
377
|
+
warnDeprecatedPathMethod(
|
|
378
|
+
runtime, "setIsVolatile",
|
|
379
|
+
"Use Skia.PathBuilder.Make().setIsVolatile() instead.");
|
|
378
380
|
auto v = arguments[0].getBool();
|
|
379
381
|
getObject()->setIsVolatile(v);
|
|
380
382
|
return thisValue.getObject(runtime);
|
|
@@ -383,8 +385,9 @@ public:
|
|
|
383
385
|
// Mutable transform methods (deprecated)
|
|
384
386
|
|
|
385
387
|
JSI_HOST_FUNCTION(transform) {
|
|
386
|
-
warnDeprecatedPathMethod(
|
|
387
|
-
|
|
388
|
+
warnDeprecatedPathMethod(
|
|
389
|
+
runtime, "transform",
|
|
390
|
+
"Use Skia.PathBuilder.Make().transform() instead.");
|
|
388
391
|
auto m3 = *JsiSkMatrix::fromValue(runtime, arguments[0]);
|
|
389
392
|
getObject()->transform(m3);
|
|
390
393
|
return thisValue.getObject(runtime);
|
|
@@ -413,9 +416,11 @@ public:
|
|
|
413
416
|
}
|
|
414
417
|
|
|
415
418
|
JSI_HOST_FUNCTION(op) {
|
|
416
|
-
warnDeprecatedPathMethod(runtime, "op",
|
|
419
|
+
warnDeprecatedPathMethod(runtime, "op",
|
|
420
|
+
"Use Skia.Path.MakeFromOp() instead.");
|
|
417
421
|
auto path2 = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
418
|
-
auto pathOp =
|
|
422
|
+
auto pathOp =
|
|
423
|
+
static_cast<SkPathOp>(static_cast<int>(arguments[1].asNumber()));
|
|
419
424
|
auto p1 = asPath();
|
|
420
425
|
auto p2 = path2->snapshot();
|
|
421
426
|
auto result = ::Op(p1, p2, pathOp);
|
|
@@ -437,8 +442,8 @@ public:
|
|
|
437
442
|
}
|
|
438
443
|
|
|
439
444
|
JSI_HOST_FUNCTION(dash) {
|
|
440
|
-
warnDeprecatedPathMethod(
|
|
441
|
-
|
|
445
|
+
warnDeprecatedPathMethod(
|
|
446
|
+
runtime, "dash", "Use Skia.Path.Dash(path, on, off, phase) instead.");
|
|
442
447
|
auto path = asPath();
|
|
443
448
|
SkScalar on = arguments[0].asNumber();
|
|
444
449
|
SkScalar off = arguments[1].asNumber();
|
|
@@ -467,12 +472,14 @@ public:
|
|
|
467
472
|
|
|
468
473
|
auto jsiCap = opts.getProperty(runtime, "cap");
|
|
469
474
|
if (!jsiCap.isUndefined()) {
|
|
470
|
-
p.setStrokeCap(
|
|
475
|
+
p.setStrokeCap(
|
|
476
|
+
static_cast<SkPaint::Cap>(static_cast<int>(jsiCap.asNumber())));
|
|
471
477
|
}
|
|
472
478
|
|
|
473
479
|
auto jsiJoin = opts.getProperty(runtime, "join");
|
|
474
480
|
if (!jsiJoin.isUndefined()) {
|
|
475
|
-
p.setStrokeJoin(
|
|
481
|
+
p.setStrokeJoin(
|
|
482
|
+
static_cast<SkPaint::Join>(static_cast<int>(jsiJoin.asNumber())));
|
|
476
483
|
}
|
|
477
484
|
|
|
478
485
|
auto jsiWidth = opts.getProperty(runtime, "width");
|
|
@@ -495,8 +502,9 @@ public:
|
|
|
495
502
|
}
|
|
496
503
|
|
|
497
504
|
JSI_HOST_FUNCTION(trim) {
|
|
498
|
-
warnDeprecatedPathMethod(
|
|
499
|
-
"trim",
|
|
505
|
+
warnDeprecatedPathMethod(
|
|
506
|
+
runtime, "trim",
|
|
507
|
+
"Use Skia.Path.Trim(path, start, end, isComplement) instead.");
|
|
500
508
|
auto path = asPath();
|
|
501
509
|
float start =
|
|
502
510
|
std::clamp(static_cast<float>(arguments[0].asNumber()), 0.0f, 1.0f);
|
|
@@ -544,9 +552,7 @@ public:
|
|
|
544
552
|
return jsi::Value(static_cast<int>(fillType));
|
|
545
553
|
}
|
|
546
554
|
|
|
547
|
-
JSI_HOST_FUNCTION(isVolatile) {
|
|
548
|
-
return jsi::Value(asPath().isVolatile());
|
|
549
|
-
}
|
|
555
|
+
JSI_HOST_FUNCTION(isVolatile) { return jsi::Value(asPath().isVolatile()); }
|
|
550
556
|
|
|
551
557
|
JSI_HOST_FUNCTION(getPoint) {
|
|
552
558
|
auto index = arguments[0].asNumber();
|
|
@@ -590,8 +596,7 @@ public:
|
|
|
590
596
|
|
|
591
597
|
JSI_HOST_FUNCTION(copy) {
|
|
592
598
|
auto path = asPath();
|
|
593
|
-
auto hostObjectInstance =
|
|
594
|
-
std::make_shared<JsiSkPath>(getContext(), path);
|
|
599
|
+
auto hostObjectInstance = std::make_shared<JsiSkPath>(getContext(), path);
|
|
595
600
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
596
601
|
runtime, hostObjectInstance, getContext());
|
|
597
602
|
}
|
|
@@ -702,24 +707,15 @@ public:
|
|
|
702
707
|
|
|
703
708
|
JSI_EXPORT_FUNCTIONS(
|
|
704
709
|
// Mutable building methods
|
|
705
|
-
JSI_EXPORT_FUNC(JsiSkPath, moveTo),
|
|
706
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
|
707
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
|
708
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
|
709
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
|
710
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
|
711
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
|
712
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
|
713
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
|
714
|
-
JSI_EXPORT_FUNC(JsiSkPath, rCubicTo),
|
|
715
|
-
JSI_EXPORT_FUNC(JsiSkPath, close),
|
|
716
|
-
JSI_EXPORT_FUNC(JsiSkPath, reset),
|
|
717
|
-
JSI_EXPORT_FUNC(JsiSkPath, rewind),
|
|
718
|
-
JSI_EXPORT_FUNC(JsiSkPath, addPath),
|
|
719
|
-
JSI_EXPORT_FUNC(JsiSkPath, addArc),
|
|
720
|
-
JSI_EXPORT_FUNC(JsiSkPath, addOval),
|
|
721
|
-
JSI_EXPORT_FUNC(JsiSkPath, addRect),
|
|
722
|
-
JSI_EXPORT_FUNC(JsiSkPath, addRRect),
|
|
710
|
+
JSI_EXPORT_FUNC(JsiSkPath, moveTo), JSI_EXPORT_FUNC(JsiSkPath, rMoveTo),
|
|
711
|
+
JSI_EXPORT_FUNC(JsiSkPath, lineTo), JSI_EXPORT_FUNC(JsiSkPath, rLineTo),
|
|
712
|
+
JSI_EXPORT_FUNC(JsiSkPath, quadTo), JSI_EXPORT_FUNC(JsiSkPath, rQuadTo),
|
|
713
|
+
JSI_EXPORT_FUNC(JsiSkPath, conicTo), JSI_EXPORT_FUNC(JsiSkPath, rConicTo),
|
|
714
|
+
JSI_EXPORT_FUNC(JsiSkPath, cubicTo), JSI_EXPORT_FUNC(JsiSkPath, rCubicTo),
|
|
715
|
+
JSI_EXPORT_FUNC(JsiSkPath, close), JSI_EXPORT_FUNC(JsiSkPath, reset),
|
|
716
|
+
JSI_EXPORT_FUNC(JsiSkPath, rewind), JSI_EXPORT_FUNC(JsiSkPath, addPath),
|
|
717
|
+
JSI_EXPORT_FUNC(JsiSkPath, addArc), JSI_EXPORT_FUNC(JsiSkPath, addOval),
|
|
718
|
+
JSI_EXPORT_FUNC(JsiSkPath, addRect), JSI_EXPORT_FUNC(JsiSkPath, addRRect),
|
|
723
719
|
JSI_EXPORT_FUNC(JsiSkPath, addCircle),
|
|
724
720
|
JSI_EXPORT_FUNC(JsiSkPath, addPoly),
|
|
725
721
|
JSI_EXPORT_FUNC(JsiSkPath, arcToOval),
|
|
@@ -729,14 +725,11 @@ public:
|
|
|
729
725
|
JSI_EXPORT_FUNC(JsiSkPath, setFillType),
|
|
730
726
|
JSI_EXPORT_FUNC(JsiSkPath, setIsVolatile),
|
|
731
727
|
// Mutable transform methods
|
|
732
|
-
JSI_EXPORT_FUNC(JsiSkPath, transform),
|
|
733
|
-
JSI_EXPORT_FUNC(JsiSkPath, offset),
|
|
728
|
+
JSI_EXPORT_FUNC(JsiSkPath, transform), JSI_EXPORT_FUNC(JsiSkPath, offset),
|
|
734
729
|
// Mutable path operations
|
|
735
|
-
JSI_EXPORT_FUNC(JsiSkPath, simplify),
|
|
736
|
-
JSI_EXPORT_FUNC(JsiSkPath, op),
|
|
730
|
+
JSI_EXPORT_FUNC(JsiSkPath, simplify), JSI_EXPORT_FUNC(JsiSkPath, op),
|
|
737
731
|
JSI_EXPORT_FUNC(JsiSkPath, makeAsWinding),
|
|
738
|
-
JSI_EXPORT_FUNC(JsiSkPath, dash),
|
|
739
|
-
JSI_EXPORT_FUNC(JsiSkPath, stroke),
|
|
732
|
+
JSI_EXPORT_FUNC(JsiSkPath, dash), JSI_EXPORT_FUNC(JsiSkPath, stroke),
|
|
740
733
|
JSI_EXPORT_FUNC(JsiSkPath, trim),
|
|
741
734
|
// Query methods
|
|
742
735
|
JSI_EXPORT_FUNC(JsiSkPath, computeTightBounds),
|
|
@@ -744,17 +737,14 @@ public:
|
|
|
744
737
|
JSI_EXPORT_FUNC(JsiSkPath, contains),
|
|
745
738
|
JSI_EXPORT_FUNC(JsiSkPath, getFillType),
|
|
746
739
|
JSI_EXPORT_FUNC(JsiSkPath, isVolatile),
|
|
747
|
-
JSI_EXPORT_FUNC(JsiSkPath, getPoint),
|
|
748
|
-
JSI_EXPORT_FUNC(JsiSkPath, isEmpty),
|
|
740
|
+
JSI_EXPORT_FUNC(JsiSkPath, getPoint), JSI_EXPORT_FUNC(JsiSkPath, isEmpty),
|
|
749
741
|
JSI_EXPORT_FUNC(JsiSkPath, countPoints),
|
|
750
742
|
JSI_EXPORT_FUNC(JsiSkPath, getLastPt),
|
|
751
743
|
JSI_EXPORT_FUNC(JsiSkPath, toSVGString),
|
|
752
|
-
JSI_EXPORT_FUNC(JsiSkPath, equals),
|
|
753
|
-
JSI_EXPORT_FUNC(JsiSkPath, copy),
|
|
744
|
+
JSI_EXPORT_FUNC(JsiSkPath, equals), JSI_EXPORT_FUNC(JsiSkPath, copy),
|
|
754
745
|
JSI_EXPORT_FUNC(JsiSkPath, isInterpolatable),
|
|
755
746
|
JSI_EXPORT_FUNC(JsiSkPath, interpolate),
|
|
756
|
-
JSI_EXPORT_FUNC(JsiSkPath, toCmds),
|
|
757
|
-
JSI_EXPORT_FUNC(JsiSkPath, dispose))
|
|
747
|
+
JSI_EXPORT_FUNC(JsiSkPath, toCmds), JSI_EXPORT_FUNC(JsiSkPath, dispose))
|
|
758
748
|
|
|
759
749
|
JsiSkPath(std::shared_ptr<RNSkPlatformContext> context, SkPathBuilder builder)
|
|
760
750
|
: JsiSkWrappingSharedPtrHostObject<SkPathBuilder>(
|
|
@@ -92,7 +92,8 @@ public:
|
|
|
92
92
|
auto style =
|
|
93
93
|
static_cast<SkPath1DPathEffect::Style>(arguments[3].asNumber());
|
|
94
94
|
auto pathEffect = std::make_shared<JsiSkPathEffect>(
|
|
95
|
-
getContext(),
|
|
95
|
+
getContext(),
|
|
96
|
+
SkPath1DPathEffect::Make(path->snapshot(), advance, phase, style));
|
|
96
97
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, pathEffect,
|
|
97
98
|
getContext());
|
|
98
99
|
}
|
|
@@ -52,36 +52,33 @@ public:
|
|
|
52
52
|
|
|
53
53
|
JSI_HOST_FUNCTION(MakeFromSVGString) {
|
|
54
54
|
auto svgString = arguments[0].asString(runtime).utf8(runtime);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!SkParsePath::FromSVGString(svgString.c_str(), &result)) {
|
|
55
|
+
auto result = SkParsePath::FromSVGString(svgString.c_str());
|
|
56
|
+
if (!result.has_value()) {
|
|
58
57
|
throw jsi::JSError(runtime, "Could not parse Svg path");
|
|
59
58
|
return jsi::Value(nullptr);
|
|
60
59
|
}
|
|
61
|
-
|
|
62
60
|
auto hostObjectInstance =
|
|
63
|
-
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
61
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result.value()));
|
|
64
62
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
65
63
|
runtime, hostObjectInstance, getContext());
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
JSI_HOST_FUNCTION(MakeFromOp) {
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
auto one = JsiSkPath::fromValue(runtime, arguments[0])->snapshot();
|
|
68
|
+
auto two = JsiSkPath::fromValue(runtime, arguments[1])->snapshot();
|
|
71
69
|
SkPathOp op = (SkPathOp)arguments[2].asNumber();
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!success) {
|
|
70
|
+
auto result = Op(one, two, op);
|
|
71
|
+
if (!result.has_value()) {
|
|
75
72
|
return jsi::Value(nullptr);
|
|
76
73
|
}
|
|
77
74
|
auto hostObjectInstance =
|
|
78
|
-
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
75
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result.value()));
|
|
79
76
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
80
77
|
runtime, hostObjectInstance, getContext());
|
|
81
78
|
}
|
|
82
79
|
|
|
83
80
|
JSI_HOST_FUNCTION(MakeFromCmds) {
|
|
84
|
-
|
|
81
|
+
SkPathBuilder builder;
|
|
85
82
|
auto cmds = arguments[0].asObject(runtime).asArray(runtime);
|
|
86
83
|
auto cmdCount = cmds.size(runtime);
|
|
87
84
|
for (int i = 0; i < cmdCount; i++) {
|
|
@@ -100,7 +97,7 @@ public:
|
|
|
100
97
|
}
|
|
101
98
|
auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
|
|
102
99
|
auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
103
|
-
|
|
100
|
+
builder.moveTo(x, y);
|
|
104
101
|
break;
|
|
105
102
|
}
|
|
106
103
|
case LINE: {
|
|
@@ -110,7 +107,7 @@ public:
|
|
|
110
107
|
}
|
|
111
108
|
auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
|
|
112
109
|
auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
113
|
-
|
|
110
|
+
builder.lineTo(x, y);
|
|
114
111
|
break;
|
|
115
112
|
}
|
|
116
113
|
case QUAD: {
|
|
@@ -122,7 +119,7 @@ public:
|
|
|
122
119
|
auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
123
120
|
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
|
|
124
121
|
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
|
125
|
-
|
|
122
|
+
builder.quadTo(x1, y1, x2, y2);
|
|
126
123
|
break;
|
|
127
124
|
}
|
|
128
125
|
case CONIC: {
|
|
@@ -135,7 +132,7 @@ public:
|
|
|
135
132
|
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
|
|
136
133
|
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
|
137
134
|
auto w = cmd.getValueAtIndex(runtime, 5).asNumber();
|
|
138
|
-
|
|
135
|
+
builder.conicTo(x1, y1, x2, y2, w);
|
|
139
136
|
break;
|
|
140
137
|
}
|
|
141
138
|
case CUBIC: {
|
|
@@ -149,11 +146,11 @@ public:
|
|
|
149
146
|
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
|
150
147
|
auto x3 = cmd.getValueAtIndex(runtime, 5).asNumber();
|
|
151
148
|
auto y3 = cmd.getValueAtIndex(runtime, 6).asNumber();
|
|
152
|
-
|
|
149
|
+
builder.cubicTo(x1, y1, x2, y2, x3, y3);
|
|
153
150
|
break;
|
|
154
151
|
}
|
|
155
152
|
case CLOSE: {
|
|
156
|
-
|
|
153
|
+
builder.close();
|
|
157
154
|
break;
|
|
158
155
|
}
|
|
159
156
|
default: {
|
|
@@ -163,7 +160,7 @@ public:
|
|
|
163
160
|
}
|
|
164
161
|
}
|
|
165
162
|
auto hostObjectInstance =
|
|
166
|
-
std::make_shared<JsiSkPath>(getContext(),
|
|
163
|
+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
167
164
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
168
165
|
runtime, hostObjectInstance, getContext());
|
|
169
166
|
}
|
|
@@ -189,10 +186,10 @@ public:
|
|
|
189
186
|
if (count >= 2 && arguments[1].getBool()) {
|
|
190
187
|
direction = SkPathDirection::kCCW;
|
|
191
188
|
}
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
SkPathBuilder builder;
|
|
190
|
+
builder.addRect(*rect, direction);
|
|
194
191
|
auto hostObjectInstance =
|
|
195
|
-
std::make_shared<JsiSkPath>(getContext(),
|
|
192
|
+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
196
193
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
197
194
|
runtime, hostObjectInstance, getContext());
|
|
198
195
|
}
|
|
@@ -204,10 +201,10 @@ public:
|
|
|
204
201
|
direction = SkPathDirection::kCCW;
|
|
205
202
|
}
|
|
206
203
|
unsigned startIndex = count < 3 ? 0 : arguments[2].asNumber();
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
SkPathBuilder builder;
|
|
205
|
+
builder.addOval(*rect, direction, startIndex);
|
|
209
206
|
auto hostObjectInstance =
|
|
210
|
-
std::make_shared<JsiSkPath>(getContext(),
|
|
207
|
+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
211
208
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
212
209
|
runtime, hostObjectInstance, getContext());
|
|
213
210
|
}
|
|
@@ -216,10 +213,10 @@ public:
|
|
|
216
213
|
auto x = arguments[0].asNumber();
|
|
217
214
|
auto y = arguments[1].asNumber();
|
|
218
215
|
auto r = arguments[2].asNumber();
|
|
219
|
-
|
|
220
|
-
|
|
216
|
+
SkPathBuilder builder;
|
|
217
|
+
builder.addCircle(x, y, r);
|
|
221
218
|
auto hostObjectInstance =
|
|
222
|
-
std::make_shared<JsiSkPath>(getContext(),
|
|
219
|
+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
223
220
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
224
221
|
runtime, hostObjectInstance, getContext());
|
|
225
222
|
}
|
|
@@ -230,24 +227,22 @@ public:
|
|
|
230
227
|
if (count >= 2 && arguments[1].getBool()) {
|
|
231
228
|
direction = SkPathDirection::kCCW;
|
|
232
229
|
}
|
|
233
|
-
|
|
234
|
-
|
|
230
|
+
SkPathBuilder builder;
|
|
231
|
+
builder.addRRect(*rrect, direction);
|
|
235
232
|
auto hostObjectInstance =
|
|
236
|
-
std::make_shared<JsiSkPath>(getContext(),
|
|
233
|
+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
237
234
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
238
235
|
runtime, hostObjectInstance, getContext());
|
|
239
236
|
}
|
|
240
237
|
|
|
241
238
|
JSI_HOST_FUNCTION(Line) {
|
|
242
|
-
auto p1 = JsiSkPoint::fromValue(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
path.moveTo(*p1);
|
|
248
|
-
path.lineTo(*p2);
|
|
239
|
+
auto p1 = JsiSkPoint::fromValue(runtime, arguments[0].asObject(runtime));
|
|
240
|
+
auto p2 = JsiSkPoint::fromValue(runtime, arguments[1].asObject(runtime));
|
|
241
|
+
SkPathBuilder builder;
|
|
242
|
+
builder.moveTo(*p1);
|
|
243
|
+
builder.lineTo(*p2);
|
|
249
244
|
auto hostObjectInstance =
|
|
250
|
-
std::make_shared<JsiSkPath>(getContext(),
|
|
245
|
+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
251
246
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
252
247
|
runtime, hostObjectInstance, getContext());
|
|
253
248
|
}
|
|
@@ -263,11 +258,10 @@ public:
|
|
|
263
258
|
runtime, jsiPoints.getValueAtIndex(runtime, i).asObject(runtime));
|
|
264
259
|
points.push_back(*point.get());
|
|
265
260
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
path.addPoly(p, close);
|
|
261
|
+
SkPathBuilder builder;
|
|
262
|
+
builder.addPolygon(SkSpan(points), close);
|
|
269
263
|
auto hostObjectInstance =
|
|
270
|
-
std::make_shared<JsiSkPath>(getContext(),
|
|
264
|
+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
271
265
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
272
266
|
runtime, hostObjectInstance, getContext());
|
|
273
267
|
}
|
|
@@ -308,22 +302,22 @@ public:
|
|
|
308
302
|
|
|
309
303
|
auto jsiPrecision = opts.getProperty(runtime, "precision");
|
|
310
304
|
auto precision = jsiPrecision.isUndefined() ? 1 : jsiPrecision.asNumber();
|
|
311
|
-
|
|
305
|
+
SkPathBuilder resultBuilder;
|
|
306
|
+
auto ctm = SkMatrix::Scale(precision, precision);
|
|
312
307
|
auto success =
|
|
313
|
-
skpathutils::FillPathWithPaint(path, p, &
|
|
308
|
+
skpathutils::FillPathWithPaint(path, p, &resultBuilder, nullptr, ctm);
|
|
314
309
|
if (success) {
|
|
315
310
|
auto hostObjectInstance =
|
|
316
|
-
std::make_shared<JsiSkPath>(getContext(),
|
|
311
|
+
std::make_shared<JsiSkPath>(getContext(), resultBuilder.snapshot());
|
|
317
312
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
318
313
|
runtime, hostObjectInstance, getContext());
|
|
319
314
|
}
|
|
320
315
|
} else {
|
|
321
|
-
|
|
322
|
-
auto success =
|
|
323
|
-
skpathutils::FillPathWithPaint(path, p, &result, nullptr, 1);
|
|
316
|
+
SkPathBuilder resultBuilder;
|
|
317
|
+
auto success = skpathutils::FillPathWithPaint(path, p, &resultBuilder);
|
|
324
318
|
if (success) {
|
|
325
319
|
auto hostObjectInstance =
|
|
326
|
-
std::make_shared<JsiSkPath>(getContext(),
|
|
320
|
+
std::make_shared<JsiSkPath>(getContext(), resultBuilder.snapshot());
|
|
327
321
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
328
322
|
runtime, hostObjectInstance, getContext());
|
|
329
323
|
}
|
|
@@ -333,8 +327,10 @@ public:
|
|
|
333
327
|
|
|
334
328
|
JSI_HOST_FUNCTION(Trim) {
|
|
335
329
|
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
336
|
-
float start =
|
|
337
|
-
|
|
330
|
+
float start =
|
|
331
|
+
std::clamp(static_cast<float>(arguments[1].asNumber()), 0.0f, 1.0f);
|
|
332
|
+
float end =
|
|
333
|
+
std::clamp(static_cast<float>(arguments[2].asNumber()), 0.0f, 1.0f);
|
|
338
334
|
auto isComplement = arguments[3].getBool();
|
|
339
335
|
// If requesting the full path in normal mode, just return a copy
|
|
340
336
|
if (start <= 0 && end >= 1 && !isComplement) {
|
package/cpp/api/JsiSkShader.h
CHANGED