Skip to content

Commit 7013139

Browse files
committed
Handle nested display list clips in Impeller dispatcher (flutter#43442)
Fixes flutter/flutter#130084 If a display list is drawn into another display list and the child display list establishes a small clip, subsequent drawing operations are discarded when really they should not be. The test is expected to render both a blue and a red square; before the fix it renders only the blue square since the red square is incorrectly clipped out. See also dnfield/flutter_svg#938
1 parent 45f6e00 commit 7013139

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

impeller/display_list/display_list_dispatcher.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,10 @@ void DisplayListDispatcher::drawDisplayList(
12521252
Matrix saved_initial_matrix = initial_matrix_;
12531253
int restore_count = canvas_.GetSaveCount();
12541254

1255+
// The display list may alter the clip, which must be restored to the current
1256+
// clip at the end of playback.
1257+
canvas_.Save();
1258+
12551259
// Establish a new baseline for interpreting the new DL.
12561260
// Matrix and clip are left untouched, the current
12571261
// transform is saved as the new base matrix, and paint

impeller/display_list/display_list_unittests.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ flutter::DlColor toColor(const float* components) {
4545
using DisplayListTest = DisplayListPlayground;
4646
INSTANTIATE_PLAYGROUND_SUITE(DisplayListTest);
4747

48+
TEST_P(DisplayListTest, DrawPictureWithAClip) {
49+
flutter::DisplayListBuilder sub_builder;
50+
sub_builder.ClipRect(SkRect::MakeXYWH(0, 0, 24, 24));
51+
sub_builder.DrawPaint(flutter::DlPaint(flutter::DlColor::kBlue()));
52+
53+
auto display_list = sub_builder.Build();
54+
flutter::DisplayListBuilder builder;
55+
builder.DrawDisplayList(display_list);
56+
builder.DrawRect(SkRect::MakeXYWH(30, 30, 24, 24),
57+
flutter::DlPaint(flutter::DlColor::kRed()));
58+
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
59+
}
60+
4861
TEST_P(DisplayListTest, CanDrawRect) {
4962
flutter::DisplayListBuilder builder;
5063
builder.DrawRect(SkRect::MakeXYWH(10, 10, 100, 100),

0 commit comments

Comments
 (0)