diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/compositor/path.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/compositor/path.dart index 44f07bb671..e501fb2cbb 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/compositor/path.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/compositor/path.dart @@ -230,33 +230,41 @@ class SkPath implements ui.Path { double rotation = 0.0, bool largeArc = false, bool clockwise = true}) { - throw 'relativeArcToPoint'; + _skPath.callMethod('rArcTo', [ + radius.x, + radius.y, + rotation, + !largeArc, + !clockwise, + arcEndDelta.dx, + arcEndDelta.dy, + ]); } @override void relativeConicTo(double x1, double y1, double x2, double y2, double w) { - throw 'relativeConicTo'; + _skPath.callMethod('rConicTo', [x1, y1, x2, y2, w]); } @override void relativeCubicTo( double x1, double y1, double x2, double y2, double x3, double y3) { - throw 'relativeCubicTo'; + _skPath.callMethod('rCubicTo', [x1, y1, x2, y2, x3, y3]); } @override void relativeLineTo(double dx, double dy) { - throw 'relativeLineTo'; + _skPath.callMethod('rLineTo', [dx, dy]); } @override void relativeMoveTo(double dx, double dy) { - throw 'relativeMoveTo'; + _skPath.callMethod('rMoveTo', [dx, dy]); } @override void relativeQuadraticBezierTo(double x1, double y1, double x2, double y2) { - throw 'relativeQuadraticBezierTo'; + _skPath.callMethod('rQuadTo', [x1, y1, x2, y2]); } @override @@ -274,10 +282,46 @@ class SkPath implements ui.Path { return SkPath._fromSkPath(newPath); } + static SkPath combine( + ui.PathOperation operation, + ui.Path uiPath1, + ui.Path uiPath2, + ) { + final SkPath path1 = uiPath1; + final SkPath path2 = uiPath2; + js.JsObject pathOp; + switch (operation) { + case ui.PathOperation.difference: + pathOp = canvasKit['PathOp']['Difference']; + break; + case ui.PathOperation.intersect: + pathOp = canvasKit['PathOp']['Intersect']; + break; + case ui.PathOperation.union: + pathOp = canvasKit['PathOp']['Union']; + break; + case ui.PathOperation.xor: + pathOp = canvasKit['PathOp']['XOR']; + break; + case ui.PathOperation.reverseDifference: + pathOp = canvasKit['PathOp']['ReverseDifference']; + break; + } + final js.JsObject newPath = canvasKit.callMethod( + 'MakePathFromOp', + [ + path1._skPath, + path2._skPath, + pathOp, + ], + ); + return SkPath._fromSkPath(newPath); + } + @override List get subpaths { throw UnimplementedError( - 'Path.subpaths is not supported in the CanvasKit backend.'); + 'Path.subpaths is not used in the CanvasKit backend.'); } @override diff --git a/engine/src/flutter/lib/web_ui/lib/src/ui/path.dart b/engine/src/flutter/lib/web_ui/lib/src/ui/path.dart index f22c9a679d..8774ffc984 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/ui/path.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/ui/path.dart @@ -1018,6 +1018,9 @@ class Path { static Path combine(PathOperation operation, Path path1, Path path2) { assert(path1 != null); assert(path2 != null); + if (engine.experimentalUseSkia) { + return engine.SkPath.combine(operation, path1, path2); + } throw UnimplementedError(); }