Skip to content

Commit

Permalink
Assert that arc end caps on canvases with root surface transformation…
Browse files Browse the repository at this point in the history
…s 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
  • Loading branch information
chinmaygarde committed Dec 11, 2019
1 parent 8595361 commit 0a40f3d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions ci/licenses_golden/licenses_flutter
Expand Up @@ -908,6 +908,7 @@ FILE: ../../../flutter/shell/platform/embedder/embedder_task_runner.cc
FILE: ../../../flutter/shell/platform/embedder/embedder_task_runner.h
FILE: ../../../flutter/shell/platform/embedder/embedder_thread_host.cc
FILE: ../../../flutter/shell/platform/embedder/embedder_thread_host.h
FILE: ../../../flutter/shell/platform/embedder/fixtures/arc_end_caps.png
FILE: ../../../flutter/shell/platform/embedder/fixtures/compositor.png
FILE: ../../../flutter/shell/platform/embedder/fixtures/compositor_root_surface_xformation.png
FILE: ../../../flutter/shell/platform/embedder/fixtures/compositor_software.png
Expand Down
1 change: 1 addition & 0 deletions shell/platform/embedder/BUILD.gn
Expand Up @@ -88,6 +88,7 @@ config("embedder_prefix_config") {
test_fixtures("fixtures") {
dart_main = "fixtures/main.dart"
fixtures = [
"fixtures/arc_end_caps.png",
"fixtures/compositor.png",
"fixtures/compositor_root_surface_xformation.png",
"fixtures/compositor_software.png",
Expand Down
Binary file added shell/platform/embedder/fixtures/arc_end_caps.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions shell/platform/embedder/fixtures/main.dart
Expand Up @@ -620,3 +620,30 @@ void scene_with_no_container() {
};
window.scheduleFrame();
}

Picture CreateArcEndCapsPicture() {
PictureRecorder baseRecorder = PictureRecorder();
Canvas canvas = Canvas(baseRecorder);

var style = Paint()
..strokeWidth = 12.0
..style = PaintingStyle.stroke
..strokeCap = StrokeCap.round
..strokeJoin = StrokeJoin.miter;

style.color = Color.fromARGB(255, 255, 0, 0);
canvas.drawArc(Rect.fromLTRB(0.0, 0.0, 500.0, 500.0), 1.57, 1.0, false, style);

return baseRecorder.endRecording();

}

@pragma('vm:entry-point')
void arc_end_caps_correct() {
window.onBeginFrame = (Duration duration) {
SceneBuilder builder = SceneBuilder();
builder.addPicture(Offset(0.0, 0.0), CreateArcEndCapsPicture());
window.render(builder.build());
};
window.scheduleFrame();
}
41 changes: 41 additions & 0 deletions shell/platform/embedder/tests/embedder_unittests.cc
Expand Up @@ -3550,5 +3550,46 @@ TEST_F(EmbedderTest, SceneWithNoRootContainerIsAcceptable) {
latch.Wait();
}

// Verifies that https://skia-review.googlesource.com/c/skia/+/259174 is pulled
// into the engine.
TEST_F(EmbedderTest, ArcEndCapsAreDrawnCorrectly) {
auto& context = GetEmbedderContext();

EmbedderConfigBuilder builder(context);
builder.SetOpenGLRendererConfig(SkISize::Make(800, 1024));
builder.SetCompositor();
builder.SetDartEntrypoint("arc_end_caps_correct");

const auto root_surface_transformation = SkMatrix()
.preScale(1.0, -1.0)
.preTranslate(1024.0, -800.0)
.preRotate(90.0);

context.SetRootSurfaceTransformation(root_surface_transformation);

auto engine = builder.LaunchEngine();

fml::AutoResetWaitableEvent latch;
sk_sp<SkImage> scene_image;
context.SetNextSceneCallback([&](sk_sp<SkImage> scene) {
scene_image = std::move(scene);
latch.Signal();
});

ASSERT_TRUE(engine.is_valid());

FlutterWindowMetricsEvent event = {};
event.struct_size = sizeof(event);
event.width = 1024;
event.height = 800;
event.pixel_ratio = 1.0;
ASSERT_EQ(FlutterEngineSendWindowMetricsEvent(engine.get(), &event),
kSuccess);

latch.Wait();

ASSERT_TRUE(ImageMatchesFixture("arc_end_caps.png", scene_image));
}

} // namespace testing
} // namespace flutter

0 comments on commit 0a40f3d

Please sign in to comment.