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

Commit 148fd96

Browse files
[Impeller] check if path is Rect/RRect/Oval (#41744)
This avoids tessellation if the application draws a Rect or RREct with Path.addRect or Path.addRREct.
1 parent 3a16e52 commit 148fd96

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

impeller/display_list/dl_dispatcher.cc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,20 @@ void DlDispatcher::drawDRRect(const SkRRect& outer, const SkRRect& inner) {
893893

894894
// |flutter::DlOpReceiver|
895895
void DlDispatcher::drawPath(const SkPath& path) {
896-
canvas_.DrawPath(skia_conversions::ToPath(path), paint_);
896+
SkRect rect;
897+
SkRRect rrect;
898+
SkRect oval;
899+
if (path.isRect(&rect)) {
900+
canvas_.DrawRect(skia_conversions::ToRect(rect), paint_);
901+
} else if (path.isRRect(&rrect) && rrect.isSimple()) {
902+
canvas_.DrawRRect(skia_conversions::ToRect(rrect.rect()),
903+
rrect.getSimpleRadii().fX, paint_);
904+
} else if (path.isOval(&oval) && oval.width() == oval.height()) {
905+
canvas_.DrawCircle(skia_conversions::ToPoint(oval.center()),
906+
oval.width() * 0.5, paint_);
907+
} else {
908+
canvas_.DrawPath(skia_conversions::ToPath(path), paint_);
909+
}
897910
}
898911

899912
// |flutter::DlOpReceiver|

0 commit comments

Comments
 (0)