Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
Handle nested display list clips in Impeller dispatcher (#43442) (#43469
Browse files Browse the repository at this point in the history
)

CP issue: flutter/flutter#130149

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
  • Loading branch information
dnfield authored Jul 10, 2023
1 parent 45f6e00 commit f9bf65c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions impeller/display_list/display_list_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,10 @@ void DisplayListDispatcher::drawDisplayList(
Matrix saved_initial_matrix = initial_matrix_;
int restore_count = canvas_.GetSaveCount();

// The display list may alter the clip, which must be restored to the current
// clip at the end of playback.
canvas_.Save();

// Establish a new baseline for interpreting the new DL.
// Matrix and clip are left untouched, the current
// transform is saved as the new base matrix, and paint
Expand Down
15 changes: 15 additions & 0 deletions impeller/display_list/display_list_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ flutter::DlColor toColor(const float* components) {
using DisplayListTest = DisplayListPlayground;
INSTANTIATE_PLAYGROUND_SUITE(DisplayListTest);

TEST_P(DisplayListTest, DrawPictureWithAClip) {
flutter::DisplayListBuilder sub_builder;
sub_builder.ClipRect(SkRect::MakeXYWH(0, 0, 24, 24),
flutter::DlCanvas::ClipOp::kIntersect,
/*is_aa=*/false);
sub_builder.DrawPaint(flutter::DlPaint(flutter::DlColor::kBlue()));

auto display_list = sub_builder.Build();
flutter::DisplayListBuilder builder;
builder.DrawDisplayList(display_list);
builder.DrawRect(SkRect::MakeXYWH(30, 30, 24, 24),
flutter::DlPaint(flutter::DlColor::kRed()));
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}

TEST_P(DisplayListTest, CanDrawRect) {
flutter::DisplayListBuilder builder;
builder.DrawRect(SkRect::MakeXYWH(10, 10, 100, 100),
Expand Down

0 comments on commit f9bf65c

Please sign in to comment.