@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.
Files changed (118) hide show
  1. package/android/CMakeLists.txt +0 -1
  2. package/android/cpp/jni/JniWebGPUView.cpp +3 -3
  3. package/android/cpp/rnskia-android/OpenGLContext.h +4 -5
  4. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +1 -1
  5. package/apple/MetalContext.h +5 -6
  6. package/apple/MetalWindowContext.mm +3 -4
  7. package/apple/RNSkApplePlatformContext.h +1 -1
  8. package/apple/RNSkApplePlatformContext.mm +4 -3
  9. package/apple/SkiaCVPixelBufferUtils.h +1 -1
  10. package/apple/SkiaCVPixelBufferUtils.mm +31 -30
  11. package/apple/SkiaPlatformContext.mm +2 -2
  12. package/apple/SkiaUIView.mm +1 -1
  13. package/apple/SkiaWebGPUView.mm +8 -4
  14. package/apple/WebGPUMetalView.h +1 -1
  15. package/apple/WebGPUMetalView.mm +1 -1
  16. package/cpp/api/JsiSkColor.h +8 -4
  17. package/cpp/api/JsiSkContourMeasure.h +4 -3
  18. package/cpp/api/JsiSkImage.h +17 -9
  19. package/cpp/api/JsiSkParagraphBuilder.h +14 -1
  20. package/cpp/api/JsiSkPath.h +71 -81
  21. package/cpp/api/JsiSkPathEffectFactory.h +2 -1
  22. package/cpp/api/JsiSkPathFactory.h +48 -52
  23. package/cpp/api/JsiSkShader.h +1 -1
  24. package/cpp/api/JsiSkShaderFactory.h +50 -26
  25. package/cpp/api/JsiSkSurfaceFactory.h +2 -1
  26. package/cpp/api/recorder/Drawings.h +5 -7
  27. package/cpp/api/recorder/Shaders.h +77 -22
  28. package/cpp/jsi2/JSIConverter.h +1 -1
  29. package/cpp/rnskia/RNDawnContext.h +14 -15
  30. package/cpp/rnskia/RNDawnUtils.h +14 -17
  31. package/cpp/rnskia/RNDawnWindowContext.h +1 -1
  32. package/cpp/rnskia/RNSkManager.cpp +5 -4
  33. package/cpp/rnskia/RNSkPlatformContext.h +2 -2
  34. package/cpp/rnwgpu/api/GPU.cpp +21 -0
  35. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +1 -1
  36. package/cpp/rnwgpu/api/GPUCanvasContext.h +2 -2
  37. package/cpp/rnwgpu/api/GPUFeatures.h +0 -9
  38. package/cpp/rnwgpu/api/GPUTexture.h +14 -2
  39. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +3 -4
  40. package/cpp/rnwgpu/api/RNWebGPU.h +1 -1
  41. package/cpp/rnwgpu/api/descriptors/Unions.h +0 -15
  42. package/cpp/skia/include/android/SkImageAndroid.h +7 -2
  43. package/cpp/skia/include/android/vk/AndroidVulkanMemoryAllocator.h +31 -0
  44. package/cpp/skia/include/codec/SkCodec.h +42 -15
  45. package/cpp/skia/include/config/SkUserConfig.h +8 -0
  46. package/cpp/skia/include/core/SkBitmap.h +0 -5
  47. package/cpp/skia/include/core/SkCanvas.h +2 -39
  48. package/cpp/skia/include/core/SkColor.h +12 -0
  49. package/cpp/skia/include/core/SkColorSpace.h +9 -0
  50. package/cpp/skia/include/core/SkContourMeasure.h +1 -5
  51. package/cpp/skia/include/core/SkData.h +8 -0
  52. package/cpp/skia/include/core/SkFont.h +1 -55
  53. package/cpp/skia/include/core/SkFontArguments.h +15 -0
  54. package/cpp/skia/include/core/SkGraphics.h +0 -5
  55. package/cpp/skia/include/core/SkImage.h +0 -4
  56. package/cpp/skia/include/core/SkImageGenerator.h +1 -4
  57. package/cpp/skia/include/core/SkMatrix.h +0 -37
  58. package/cpp/skia/include/core/SkMilestone.h +1 -1
  59. package/cpp/skia/include/core/SkPath.h +11 -911
  60. package/cpp/skia/include/core/SkPathBuilder.h +42 -32
  61. package/cpp/skia/include/core/SkPathEffect.h +0 -9
  62. package/cpp/skia/include/core/SkPathMeasure.h +1 -4
  63. package/cpp/skia/include/core/SkPathUtils.h +0 -10
  64. package/cpp/skia/include/core/SkRect.h +0 -12
  65. package/cpp/skia/include/core/SkRegion.h +1 -6
  66. package/cpp/skia/include/core/SkSerialProcs.h +4 -5
  67. package/cpp/skia/include/core/SkSurfaceProps.h +6 -0
  68. package/cpp/skia/include/core/SkTextBlob.h +0 -22
  69. package/cpp/skia/include/core/SkTypeface.h +14 -32
  70. package/cpp/skia/include/core/SkTypes.h +0 -8
  71. package/cpp/skia/include/docs/SkPDFDocument.h +19 -17
  72. package/cpp/skia/include/effects/SkDashPathEffect.h +0 -6
  73. package/cpp/skia/include/effects/SkGradient.h +206 -0
  74. package/cpp/skia/include/effects/SkHighContrastFilter.h +2 -2
  75. package/cpp/skia/include/gpu/GpuTypes.h +2 -0
  76. package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +5 -35
  77. package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +7 -106
  78. package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +0 -11
  79. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +0 -9
  80. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSemaphore.h +20 -0
  81. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSurface.h +59 -0
  82. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +28 -0
  83. package/cpp/skia/include/gpu/ganesh/gl/GrGLFunctions.h +4 -1
  84. package/cpp/skia/include/gpu/graphite/ContextOptions.h +4 -20
  85. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +32 -46
  86. package/cpp/skia/include/gpu/graphite/Recorder.h +1 -1
  87. package/cpp/skia/include/gpu/graphite/Surface.h +31 -0
  88. package/cpp/skia/include/gpu/graphite/TextureInfo.h +3 -10
  89. package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +3 -3
  90. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -1
  91. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +6 -6
  92. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +5 -3
  93. package/cpp/skia/include/gpu/graphite/vk/precompile/VulkanPrecompileShader.h +1 -1
  94. package/cpp/skia/include/gpu/vk/VulkanBackendContext.h +1 -1
  95. package/cpp/skia/include/gpu/vk/VulkanPreferredFeatures.h +8 -0
  96. package/cpp/skia/include/private/SkEncodedInfo.h +43 -105
  97. package/cpp/skia/include/private/SkHdrMetadata.h +165 -2
  98. package/cpp/skia/include/private/SkPathRef.h +0 -457
  99. package/cpp/skia/include/private/base/SkFeatures.h +4 -0
  100. package/cpp/skia/include/private/base/SkFloatingPoint.h +1 -2
  101. package/cpp/skia/include/private/base/SkLoadUserConfig.h +2 -1
  102. package/cpp/skia/include/private/base/SkLog.h +68 -0
  103. package/cpp/skia/include/private/base/SkLogPriority.h +35 -0
  104. package/cpp/skia/include/private/base/SkMacros.h +9 -0
  105. package/cpp/skia/include/private/base/SkTArray.h +1 -1
  106. package/cpp/skia/include/private/gpu/ganesh/GrD3DTypesMinimal.h +10 -24
  107. package/cpp/skia/include/utils/SkEventTracer.h +5 -7
  108. package/cpp/skia/modules/skottie/include/TextShaper.h +0 -7
  109. package/cpp/skia/modules/skparagraph/include/FontCollection.h +6 -20
  110. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +0 -6
  111. package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +4 -19
  112. package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +2 -3
  113. package/cpp/skia/modules/skunicode/include/SkUnicode_icu.h +18 -0
  114. package/cpp/skia/modules/skunicode/include/SkUnicode_libgrapheme.h +19 -0
  115. package/cpp/skia/src/base/SkMathPriv.h +27 -132
  116. package/package.json +5 -5
  117. package/cpp/skia/include/effects/SkGradientShader.h +0 -359
  118. package/cpp/skia/include/gpu/graphite/LogPriority.h +0 -36
@@ -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. " + suggestion +
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 = extend ? SkPath::kExtend_AddPathMode
217
- : SkPath::kAppend_AddPathMode;
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(runtime,
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 = count > 2 ? static_cast<unsigned>(arguments[2].asNumber()) : 1;
243
- auto direction =
244
- isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
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(runtime,
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(runtime,
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(runtime,
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(runtime,
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 = JsiSkPoint::fromValue(
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(runtime,
307
- "arcToOval", "Use Skia.PathBuilder.Make().arcToOval() instead.");
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(runtime,
318
- "arcToRotated", "Use Skia.PathBuilder.Make().arcToRotated() instead.");
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(runtime,
357
- "arcToTangent", "Use Skia.PathBuilder.Make().arcToTangent() instead.");
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(runtime,
369
- "setFillType", "Use Skia.PathBuilder.Make().setFillType() instead.");
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(runtime,
377
- "setIsVolatile", "Use Skia.PathBuilder.Make().setIsVolatile() instead.");
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(runtime,
387
- "transform", "Use Skia.PathBuilder.Make().transform() instead.");
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", "Use Skia.Path.MakeFromOp() instead.");
419
+ warnDeprecatedPathMethod(runtime, "op",
420
+ "Use Skia.Path.MakeFromOp() instead.");
417
421
  auto path2 = JsiSkPath::fromValue(runtime, arguments[0]);
418
- auto pathOp = static_cast<SkPathOp>(static_cast<int>(arguments[1].asNumber()));
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(runtime, "dash",
441
- "Use Skia.Path.Dash(path, on, off, phase) instead.");
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(static_cast<SkPaint::Cap>(static_cast<int>(jsiCap.asNumber())));
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(static_cast<SkPaint::Join>(static_cast<int>(jsiJoin.asNumber())));
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(runtime,
499
- "trim", "Use Skia.Path.Trim(path, start, end, isComplement) instead.");
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, rMoveTo),
707
- JSI_EXPORT_FUNC(JsiSkPath, lineTo),
708
- JSI_EXPORT_FUNC(JsiSkPath, rLineTo),
709
- JSI_EXPORT_FUNC(JsiSkPath, quadTo),
710
- JSI_EXPORT_FUNC(JsiSkPath, rQuadTo),
711
- JSI_EXPORT_FUNC(JsiSkPath, conicTo),
712
- JSI_EXPORT_FUNC(JsiSkPath, rConicTo),
713
- JSI_EXPORT_FUNC(JsiSkPath, cubicTo),
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(), SkPath1DPathEffect::Make(path->snapshot(), advance, phase, style));
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
- SkPath result;
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
- SkPath one = JsiSkPath::fromValue(runtime, arguments[0])->snapshot();
70
- SkPath two = JsiSkPath::fromValue(runtime, arguments[1])->snapshot();
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
- SkPath result;
73
- bool success = Op(one, two, op, &result);
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
- SkPath path;
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
- path.moveTo(x, y);
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
- path.lineTo(x, y);
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
- path.quadTo(x1, y1, x2, y2);
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
- path.conicTo(x1, y1, x2, y2, w);
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
- path.cubicTo(x1, y1, x2, y2, x3, y3);
149
+ builder.cubicTo(x1, y1, x2, y2, x3, y3);
153
150
  break;
154
151
  }
155
152
  case CLOSE: {
156
- path.close();
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(), std::move(path));
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
- SkPath path;
193
- path.addRect(*rect, direction);
189
+ SkPathBuilder builder;
190
+ builder.addRect(*rect, direction);
194
191
  auto hostObjectInstance =
195
- std::make_shared<JsiSkPath>(getContext(), std::move(path));
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
- SkPath path;
208
- path.addOval(*rect, direction, startIndex);
204
+ SkPathBuilder builder;
205
+ builder.addOval(*rect, direction, startIndex);
209
206
  auto hostObjectInstance =
210
- std::make_shared<JsiSkPath>(getContext(), std::move(path));
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
- SkPath path;
220
- path.addCircle(x, y, r);
216
+ SkPathBuilder builder;
217
+ builder.addCircle(x, y, r);
221
218
  auto hostObjectInstance =
222
- std::make_shared<JsiSkPath>(getContext(), std::move(path));
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
- SkPath path;
234
- path.addRRect(*rrect, direction);
230
+ SkPathBuilder builder;
231
+ builder.addRRect(*rrect, direction);
235
232
  auto hostObjectInstance =
236
- std::make_shared<JsiSkPath>(getContext(), std::move(path));
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
- 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);
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(), std::move(path));
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
- SkPath path;
267
- auto p = SkSpan(points.data(), points.size());
268
- path.addPoly(p, close);
261
+ SkPathBuilder builder;
262
+ builder.addPolygon(SkSpan(points), close);
269
263
  auto hostObjectInstance =
270
- std::make_shared<JsiSkPath>(getContext(), std::move(path));
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
- SkPath result;
305
+ SkPathBuilder resultBuilder;
306
+ auto ctm = SkMatrix::Scale(precision, precision);
312
307
  auto success =
313
- skpathutils::FillPathWithPaint(path, p, &result, nullptr, precision);
308
+ skpathutils::FillPathWithPaint(path, p, &resultBuilder, nullptr, ctm);
314
309
  if (success) {
315
310
  auto hostObjectInstance =
316
- std::make_shared<JsiSkPath>(getContext(), std::move(result));
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
- SkPath result;
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(), std::move(result));
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 = 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);
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) {
@@ -11,7 +11,7 @@
11
11
  #pragma clang diagnostic ignored "-Wdocumentation"
12
12
 
13
13
  #include "include/core/SkShader.h"
14
- #include "include/effects/SkGradientShader.h"
14
+ #include "include/effects/SkGradient.h"
15
15
 
16
16
  #pragma clang diagnostic pop
17
17