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

[Impeller] New impeller round rect class #55946

Merged
merged 3 commits into from
Oct 20, 2024

Conversation

flar
Copy link
Contributor

@flar flar commented Oct 18, 2024

Impeller geometry class analogous to SkRRect - soon to be the standard round rectangle class throughout most of the engine that doesn't talk directly to Skia.

More unit tests are being written, but this PR will enable developers to look at the API of the new class and comment as well as test its effect on any goldens (there should be none).

@@ -0,0 +1,212 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what method we'll use for detection of SimpleRRects, but just a note that we should tolerate floating point errors on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rendering code already has its own NearlySimple method that I thought should be fine as that is a rendering issue. I originally had a method here that was similar, but then I decided to leave that to the caller since it wasn't clear what level of epsilon to use (and eventually we should be taking the matrix into account for any epsilon and that would complicate the methods even more).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned down below, rather than have the rendering code do its own thing, the RoundRect method now applies a tolerance which can be supplied by the caller. We should supply a transform-based tolerance for rendering code and eventually we have to figure out what to do about all of these transform-dependent tolerances in the DL code that doesn't have access to the final transform.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach!

@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

Changes reported for pull request #55946 at sha 7cbf4ca

@gaaclarke
Copy link
Member

gaaclarke commented Oct 18, 2024

I tried this out with the interactive test from #55929 to see if the dimples show up with different parameters, I don't see them.

There is one bug with this thought that when the width is 0 nothing is drawn, it winks out of existence. I expect it to look almost exactly like width 0.01

edit: Before this change a rect was drawn, which isn't correct either but is better than nothing.

GetCanvas().DrawRRect(skia_conversions::ToRect(rrect.rect()),
skia_conversions::ToSize(rrect.getSimpleRadii()),
paint_);
if (rrect.GetRadii().AreAllSame()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to use the IsNearlySimpleRRect rrect that has a tolerance for floating point errors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the method to apply a (configurable) tolerance so it should behave as before wherever it is used.

@flar
Copy link
Contributor Author

flar commented Oct 19, 2024

There is one bug with this thought that when the width is 0 nothing is drawn, it winks out of existence. I expect it to look almost exactly like width 0.01

edit: Before this change a rect was drawn, which isn't correct either but is better than nothing.

I'll take a look at this, but one of the changes I made in the last commit was that I had been replacing the rect with a default rect if it was empty. That would account for what you saw in that the rect might have had a width or height and it would lose both of the other was empty. Now I just transfer the rect along, but set the radii to all 0s which is what would happen when they were normalized anyway.

(Confirmed, it now goes to a rectangle due to the loss of corner radii)

Copy link
Member

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Slightly related:

One problem with stroked or non-simple round rects is that we will re-convert them to paths on every single dispatch, whereas if they had been recorded in the display list as a path we'd only do that conversion once. Similar for the difference rrect, where we do the conversion on each frame.

I don't think it would be harmful to the skia backend if we eagerly did the path conversion during recording, but its also probably out of scope for this chage.

@@ -115,8 +115,8 @@ namespace flutter {
V(DrawRect) \
V(DrawOval) \
V(DrawCircle) \
V(DrawRRect) \
V(DrawDRRect) \
V(DrawRoundRect) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@@ -0,0 +1,212 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach!

@flar
Copy link
Contributor Author

flar commented Oct 20, 2024

One problem with stroked or non-simple round rects is that we will re-convert them to paths on every single dispatch, whereas if they had been recorded in the display list as a path we'd only do that conversion once. Similar for the difference rrect, where we do the conversion on each frame.

I don't think it would be harmful to the skia backend if we eagerly did the path conversion during recording, but its also probably out of scope for this chage.

It caused 11k scuba diffs and the diffs were visible to the naked eye. Their path rendering does not match their primitive rendering. See #55376 and #55410 which were closed until we stop testing with Skia...

@flar flar added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 20, 2024
@auto-submit auto-submit bot merged commit 68f9225 into flutter:main Oct 20, 2024
32 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants