Skip to content

Commit 0a40f3d

Browse files
authored
Assert that arc end caps on canvases with root surface transformations are drawn correctly. (flutter#14359)
Verifies that the Skia commit https://skia-review.googlesource.com/c/skia/+/259174 has been pulled into the engine. This should have happened in the roll flutter/engine#14345. Fixes flutter#46691 Fixes b/142280381
1 parent 8595361 commit 0a40f3d

File tree

5 files changed

+70
-0
lines changed

5 files changed

+70
-0
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ FILE: ../../../flutter/shell/platform/embedder/embedder_task_runner.cc
908908
FILE: ../../../flutter/shell/platform/embedder/embedder_task_runner.h
909909
FILE: ../../../flutter/shell/platform/embedder/embedder_thread_host.cc
910910
FILE: ../../../flutter/shell/platform/embedder/embedder_thread_host.h
911+
FILE: ../../../flutter/shell/platform/embedder/fixtures/arc_end_caps.png
911912
FILE: ../../../flutter/shell/platform/embedder/fixtures/compositor.png
912913
FILE: ../../../flutter/shell/platform/embedder/fixtures/compositor_root_surface_xformation.png
913914
FILE: ../../../flutter/shell/platform/embedder/fixtures/compositor_software.png

shell/platform/embedder/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ config("embedder_prefix_config") {
8888
test_fixtures("fixtures") {
8989
dart_main = "fixtures/main.dart"
9090
fixtures = [
91+
"fixtures/arc_end_caps.png",
9192
"fixtures/compositor.png",
9293
"fixtures/compositor_root_surface_xformation.png",
9394
"fixtures/compositor_software.png",
5.87 KB
Loading

shell/platform/embedder/fixtures/main.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,3 +620,30 @@ void scene_with_no_container() {
620620
};
621621
window.scheduleFrame();
622622
}
623+
624+
Picture CreateArcEndCapsPicture() {
625+
PictureRecorder baseRecorder = PictureRecorder();
626+
Canvas canvas = Canvas(baseRecorder);
627+
628+
var style = Paint()
629+
..strokeWidth = 12.0
630+
..style = PaintingStyle.stroke
631+
..strokeCap = StrokeCap.round
632+
..strokeJoin = StrokeJoin.miter;
633+
634+
style.color = Color.fromARGB(255, 255, 0, 0);
635+
canvas.drawArc(Rect.fromLTRB(0.0, 0.0, 500.0, 500.0), 1.57, 1.0, false, style);
636+
637+
return baseRecorder.endRecording();
638+
639+
}
640+
641+
@pragma('vm:entry-point')
642+
void arc_end_caps_correct() {
643+
window.onBeginFrame = (Duration duration) {
644+
SceneBuilder builder = SceneBuilder();
645+
builder.addPicture(Offset(0.0, 0.0), CreateArcEndCapsPicture());
646+
window.render(builder.build());
647+
};
648+
window.scheduleFrame();
649+
}

shell/platform/embedder/tests/embedder_unittests.cc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3550,5 +3550,46 @@ TEST_F(EmbedderTest, SceneWithNoRootContainerIsAcceptable) {
35503550
latch.Wait();
35513551
}
35523552

3553+
// Verifies that https://skia-review.googlesource.com/c/skia/+/259174 is pulled
3554+
// into the engine.
3555+
TEST_F(EmbedderTest, ArcEndCapsAreDrawnCorrectly) {
3556+
auto& context = GetEmbedderContext();
3557+
3558+
EmbedderConfigBuilder builder(context);
3559+
builder.SetOpenGLRendererConfig(SkISize::Make(800, 1024));
3560+
builder.SetCompositor();
3561+
builder.SetDartEntrypoint("arc_end_caps_correct");
3562+
3563+
const auto root_surface_transformation = SkMatrix()
3564+
.preScale(1.0, -1.0)
3565+
.preTranslate(1024.0, -800.0)
3566+
.preRotate(90.0);
3567+
3568+
context.SetRootSurfaceTransformation(root_surface_transformation);
3569+
3570+
auto engine = builder.LaunchEngine();
3571+
3572+
fml::AutoResetWaitableEvent latch;
3573+
sk_sp<SkImage> scene_image;
3574+
context.SetNextSceneCallback([&](sk_sp<SkImage> scene) {
3575+
scene_image = std::move(scene);
3576+
latch.Signal();
3577+
});
3578+
3579+
ASSERT_TRUE(engine.is_valid());
3580+
3581+
FlutterWindowMetricsEvent event = {};
3582+
event.struct_size = sizeof(event);
3583+
event.width = 1024;
3584+
event.height = 800;
3585+
event.pixel_ratio = 1.0;
3586+
ASSERT_EQ(FlutterEngineSendWindowMetricsEvent(engine.get(), &event),
3587+
kSuccess);
3588+
3589+
latch.Wait();
3590+
3591+
ASSERT_TRUE(ImageMatchesFixture("arc_end_caps.png", scene_image));
3592+
}
3593+
35533594
} // namespace testing
35543595
} // namespace flutter

0 commit comments

Comments
 (0)