Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DisplayList] Optimize ClipRRect and ClipPath to ClipOval when appropriate #54088

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions display_list/display_list_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4863,8 +4863,6 @@ TEST_F(DisplayListTest, ClipPathOvalNonCulling) {
auto non_encompassing_oval = clip.makeOutset(2.071f, 2.071f);
SkPath path;
path.addOval(non_encompassing_oval);
SkRRect rrect;
rrect.setOval(non_encompassing_oval);

DisplayListBuilder cull_builder;
cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
Expand All @@ -4873,9 +4871,8 @@ TEST_F(DisplayListTest, ClipPathOvalNonCulling) {

CLIP_EXPECTOR(expector);
expector.addExpectation(clip, ClipOp::kIntersect, false);
// Builder will not cull this clip, but it will turn it into a ClipRRect
// Eventually it should turn it into a ClipOval
expector.addExpectation(rrect, ClipOp::kIntersect, false);
// Builder will not cull this clip, but it will turn it into a ClipOval
expector.addOvalExpectation(non_encompassing_oval, ClipOp::kIntersect, false);
cull_dl->Dispatch(expector);
}

Expand Down Expand Up @@ -5088,9 +5085,7 @@ TEST_F(DisplayListTest, ClipOvalRRectPromoteToClipOval) {
expected.DrawRect(draw_rect, DlPaint());
auto expect_dl = expected.Build();

// Support for this will be re-added soon, until then verify that we
// do not promote.
ASSERT_TRUE(DisplayListsNE_Verbose(dl, expect_dl));
ASSERT_TRUE(DisplayListsEQ_Verbose(dl, expect_dl));
}

TEST_F(DisplayListTest, ClipRectPathPromoteToClipRect) {
Expand Down Expand Up @@ -5132,9 +5127,7 @@ TEST_F(DisplayListTest, ClipOvalPathPromoteToClipOval) {
expected.DrawRect(draw_rect, DlPaint());
auto expect_dl = expected.Build();

// Support for this will be re-added soon, until then verify that we
// do not promote.
ASSERT_TRUE(DisplayListsNE_Verbose(dl, expect_dl));
ASSERT_TRUE(DisplayListsEQ_Verbose(dl, expect_dl));
}

TEST_F(DisplayListTest, ClipRRectPathPromoteToClipRRect) {
Expand Down Expand Up @@ -5273,9 +5266,7 @@ TEST_F(DisplayListTest, ClipOvalRRectPathPromoteToClipOval) {
expected.DrawRect(draw_rect, DlPaint());
auto expect_dl = expected.Build();

// Support for this will be re-added soon, until then verify that we
// do not promote.
ASSERT_TRUE(DisplayListsNE_Verbose(dl, expect_dl));
ASSERT_TRUE(DisplayListsEQ_Verbose(dl, expect_dl));
}

TEST_F(DisplayListTest, BoundedRenderOpsDoNotReportUnbounded) {
Expand Down
15 changes: 9 additions & 6 deletions display_list/dl_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,11 @@ void DisplayListBuilder::ClipRRect(const SkRRect& rrect,
ClipOp clip_op,
bool is_aa) {
if (rrect.isRect()) {
clipRect(rrect.rect(), clip_op, is_aa);
ClipRect(rrect.rect(), clip_op, is_aa);
return;
}
if (rrect.isOval()) {
ClipOval(rrect.rect(), clip_op, is_aa);
return;
}
if (current_info().is_nop) {
Expand Down Expand Up @@ -1043,17 +1047,16 @@ void DisplayListBuilder::ClipPath(const SkPath& path,
if (!path.isInverseFillType()) {
SkRect rect;
if (path.isRect(&rect)) {
this->clipRect(rect, clip_op, is_aa);
ClipRect(rect, clip_op, is_aa);
return;
}
SkRRect rrect;
if (path.isOval(&rect)) {
rrect.setOval(rect);
this->clipRRect(rrect, clip_op, is_aa);
ClipOval(rect, clip_op, is_aa);
return;
}
SkRRect rrect;
if (path.isRRect(&rrect)) {
this->clipRRect(rrect, clip_op, is_aa);
ClipRRect(rrect, clip_op, is_aa);
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions display_list/testing/dl_test_snippets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,8 @@ std::vector<DisplayListInvocationGroup> CreateAllClipOps() {
[](DlOpReceiver& r) {
r.clipPath(kTestPathRect, DlCanvas::ClipOp::kIntersect, true);
}},
// clipPath(oval) becomes clipRRect
{1, 64, 0,
// clipPath(oval) becomes clipOval
{1, 24, 0,
[](DlOpReceiver& r) {
r.clipPath(kTestPathOval, DlCanvas::ClipOp::kIntersect, true);
}},
Expand Down