mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[web] fix the last matrix element in CkPath.shift (flutter/engine#28589)
This commit is contained in:
parent
661ef56013
commit
cb9ce54b77
@ -257,12 +257,16 @@ class CkPath extends ManagedSkiaObject<SkPath> implements ui.Path {
|
||||
}
|
||||
|
||||
@override
|
||||
ui.Path shift(ui.Offset offset) {
|
||||
// Since CanvasKit does not expose `SkPath.offset`, create a copy of this
|
||||
// path and call `transform` on it.
|
||||
final SkPath newPath = skiaObject.copy();
|
||||
newPath.transform(1.0, 0.0, offset.dx, 0.0, 1.0, offset.dy, 0.0, 0.0, 0.0);
|
||||
return CkPath.fromSkPath(newPath, _fillType);
|
||||
CkPath shift(ui.Offset offset) {
|
||||
// `SkPath.transform` mutates the existing path, so create a copy and call
|
||||
// `transform` on the copy.
|
||||
final SkPath shiftedPath = skiaObject.copy();
|
||||
shiftedPath.transform(
|
||||
1.0, 0.0, offset.dx,
|
||||
0.0, 1.0, offset.dy,
|
||||
0.0, 0.0, 1.0,
|
||||
);
|
||||
return CkPath.fromSkPath(shiftedPath, _fillType);
|
||||
}
|
||||
|
||||
static CkPath combine(
|
||||
|
||||
@ -85,6 +85,21 @@ void testMain() {
|
||||
expect(path.contains(const ui.Offset(5, 5)), isFalse);
|
||||
});
|
||||
|
||||
test('CkPath.shift creates a shifted copy of the path', () {
|
||||
const ui.Rect testRect = ui.Rect.fromLTRB(0, 0, 10, 10);
|
||||
final CkPath path = CkPath();
|
||||
path.addRect(testRect);
|
||||
expect(path.getBounds(), testRect);
|
||||
|
||||
expect(
|
||||
path.shift(const ui.Offset(20, 20)).getBounds(),
|
||||
testRect.shift(const ui.Offset(20, 20)),
|
||||
);
|
||||
|
||||
// Make sure the original path wasn't mutated.
|
||||
expect(path.getBounds(), testRect);
|
||||
});
|
||||
|
||||
test('CkPath resurrection', () {
|
||||
const ui.Rect rect = ui.Rect.fromLTRB(0, 0, 10, 10);
|
||||
final CkPath path = CkPath();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user