This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Ensure known geometry has simple bounds computation. #46623
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,6 +252,7 @@ void Canvas::DrawRRect(Rect rect, Scalar corner_radius, const Paint& paint) { | |
auto path = PathBuilder{} | ||
.SetConvexity(Convexity::kConvex) | ||
.AddRoundedRect(rect, corner_radius) | ||
.SetBounds(rect) | ||
.TakePath(); | ||
if (paint.style == Paint::Style::kFill) { | ||
Entity entity; | ||
|
@@ -273,10 +274,13 @@ void Canvas::DrawCircle(Point center, Scalar radius, const Paint& paint) { | |
paint)) { | ||
return; | ||
} | ||
auto circle_path = PathBuilder{} | ||
.AddCircle(center, radius) | ||
.SetConvexity(Convexity::kConvex) | ||
.TakePath(); | ||
auto circle_path = | ||
PathBuilder{} | ||
.AddCircle(center, radius) | ||
.SetConvexity(Convexity::kConvex) | ||
.SetBounds(Rect::MakeLTRB(center.x - radius, center.y - radius, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this part also have a unit test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
center.x + radius, center.y + radius)) | ||
.TakePath(); | ||
DrawPath(circle_path, paint); | ||
} | ||
|
||
|
@@ -317,6 +321,7 @@ void Canvas::ClipRRect(const Rect& rect, | |
auto path = PathBuilder{} | ||
.SetConvexity(Convexity::kConvex) | ||
.AddRoundedRect(rect, corner_radius) | ||
.SetBounds(rect) | ||
.TakePath(); | ||
|
||
std::optional<Rect> inner_rect = (corner_radius * 2 < rect.size.width && | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the gist is that if you don't call SetBounds, it is getting calculated instead? What about rounded rects that have extreme corner radii? Does that become a shape whose bounds are different than the one specified in the draw call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, normally we use the Skia computed bounds - but the Aiks API doesn't accomidated that. What are you thinking of for extreme corner radii?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running some tests:
Result:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if when the corner radius was high would it start looking more like a circle that was inset in the rect. LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try this with reversed rects? RRects is one of the areas where Skia was doing "auto-sorting" of the corners of the rects...