Implement the rest of ui.Path methods for CanvasKit (flutter/engine#13851)

- the relative path methods
- Path.combine
This commit is contained in:
Harry Terkelsen
2019-11-14 11:08:34 -08:00
committed by GitHub
parent afe298e698
commit 92c365b630
2 changed files with 54 additions and 7 deletions

View File

@@ -230,33 +230,41 @@ class SkPath implements ui.Path {
double rotation = 0.0,
bool largeArc = false,
bool clockwise = true}) {
throw 'relativeArcToPoint';
_skPath.callMethod('rArcTo', <dynamic>[
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', <double>[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', <double>[x1, y1, x2, y2, x3, y3]);
}
@override
void relativeLineTo(double dx, double dy) {
throw 'relativeLineTo';
_skPath.callMethod('rLineTo', <double>[dx, dy]);
}
@override
void relativeMoveTo(double dx, double dy) {
throw 'relativeMoveTo';
_skPath.callMethod('rMoveTo', <double>[dx, dy]);
}
@override
void relativeQuadraticBezierTo(double x1, double y1, double x2, double y2) {
throw 'relativeQuadraticBezierTo';
_skPath.callMethod('rQuadTo', <double>[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',
<js.JsObject>[
path1._skPath,
path2._skPath,
pathOp,
],
);
return SkPath._fromSkPath(newPath);
}
@override
List<Subpath> get subpaths {
throw UnimplementedError(
'Path.subpaths is not supported in the CanvasKit backend.');
'Path.subpaths is not used in the CanvasKit backend.');
}
@override

View File

@@ -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();
}