From 19cec525aabe67c7abbc0f77233c4e9bfba56fd2 Mon Sep 17 00:00:00 2001 From: Ferhat Date: Mon, 11 Nov 2019 15:38:30 -0800 Subject: [PATCH] [web] Fix path to svg for drrect (flutter/engine#13779) --- .../src/flutter/lib/web_ui/dev/goldens_lock.yaml | 2 +- .../lib/web_ui/lib/src/engine/path_to_svg.dart | 4 ++-- .../engine/canvas_draw_image_golden_test.dart | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/lib/web_ui/dev/goldens_lock.yaml b/engine/src/flutter/lib/web_ui/dev/goldens_lock.yaml index e8b87138a00..bbd03eb4611 100644 --- a/engine/src/flutter/lib/web_ui/dev/goldens_lock.yaml +++ b/engine/src/flutter/lib/web_ui/dev/goldens_lock.yaml @@ -1,2 +1,2 @@ repository: https://github.com/flutter/goldens.git -revision: 009fbdd595aeec364eaff6b8f337f8ceb3c44ab9 +revision: 75729099b6f4d4e78ceb110b9305fc9905b91519 diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/path_to_svg.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/path_to_svg.dart index 10dc5455740..24f0fcf9389 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/path_to_svg.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/path_to_svg.dart @@ -96,9 +96,9 @@ void pathToSvg(ui.Path path, StringBuffer sb, final double blRadiusY = rrect.blRadiusY.abs(); final double brRadiusY = rrect.brRadiusY.abs(); - sb.write('L ${left + trRadiusX} $top '); + sb.write('M ${left + trRadiusX} $top '); // Top side and top-right corner - sb.write('M ${right - trRadiusX} $top '); + sb.write('L ${right - trRadiusX} $top '); _writeEllipse(sb, right - trRadiusX, top + trRadiusY, trRadiusX, trRadiusY, 0, 1.5 * math.pi, 2.0 * math.pi, false); // Right side and bottom-right corner diff --git a/engine/src/flutter/lib/web_ui/test/golden_tests/engine/canvas_draw_image_golden_test.dart b/engine/src/flutter/lib/web_ui/test/golden_tests/engine/canvas_draw_image_golden_test.dart index 9601d71afa9..ea789e03b77 100644 --- a/engine/src/flutter/lib/web_ui/test/golden_tests/engine/canvas_draw_image_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/golden_tests/engine/canvas_draw_image_golden_test.dart @@ -31,7 +31,7 @@ void main() async { try { sceneElement.append(engineCanvas.rootElement); html.document.body.append(sceneElement); - await matchGoldenFile('$fileName.png', region: region, maxDiffRate: 0.02); + await matchGoldenFile('$fileName.png', region: region, maxDiffRate: 0.2); } finally { // The page is reused across tests, so remove the element after taking the // Scuba screenshot. @@ -100,6 +100,19 @@ void main() async { await _checkScreenshot(rc, 'draw_image_rect_with_source'); }); + test('Paints image with source and destination and round clip', () async { + final RecordingCanvas rc = + RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300)); + Image testImage = createTestImage(); + double testWidth = testImage.width.toDouble(); + double testHeight = testImage.height.toDouble(); + rc.save(); + rc.clipRRect(RRect.fromLTRBR(100, 30, 2 * testWidth, 2 * testHeight, Radius.circular(16))); + rc.drawImageRect(testImage, Rect.fromLTRB(testWidth / 2, 0, testWidth, testHeight), + Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), new Paint()); + await _checkScreenshot(rc, 'draw_image_rect_with_source_and_clip'); + }); + test('Paints image with transform using source and destination', () async { final RecordingCanvas rc = RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));