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
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Oct 21, 2024
…157246)

flutter/engine@53e187a...68f9225

2024-10-20 [email protected] [Impeller] New impeller round rect class (flutter/engine#55946)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@flar
Copy link
Contributor Author

flar commented Oct 21, 2024

There was some benchmark movement on this PR, I think positive?

Down

https://flutter-engine-perf.skia.org/e/?begin=1729290271&end=1729532343&keys=X5a168f61690cd0d2547ea2a1dd55b365&num_commits=50&request_type=1&xbaroffset=43324

Up

https://flutter-engine-perf.skia.org/e/?begin=1729290271&end=1729532343&keys=X3075c2ba7cb934cce6a4d765b7060982&num_commits=50&request_type=1&xbaroffset=43324

Those are all (mostly? I didn't check each one) Region benchmarks which should not have been affected by the RoundRect work at all. I saw a similar change in these benchmarks a few weeks back on another completely unrelated PR. It's a mystery.

I zoomed out and scrolled back a bit and you can see where the test was changing performance a few times:

https://flutter-engine-perf.skia.org/e/?begin=1718243397&end=1729532342&keys=X5a168f61690cd0d2547ea2a1dd55b365&requestType=0&selected=commit%3D42649%26name%3D%252Cconfig%253Ddefault%252Ccpu_scaling_enabled%253Dfalse%252Cexecutable%253D_b_s_w_ir_cache_builder_src_out_ci_host_release_benchmarks_display_list_region_benchmarks%252Clibrary_build_type%253Drelease%252Cmhz_per_cpu%253D2200%252Cnum_cpus%253D8%252Csub_result%253Dreal_time%252Ctest%253DBM_SkRegion_FromRects_Tiny%252Cunit%253Dus%252C&xbaroffset=43324

and

https://flutter-engine-perf.skia.org/e/?begin=1705971152&end=1729524674&keys=X5a168f61690cd0d2547ea2a1dd55b365&requestType=0&selected=commit%3D40883%26name%3D%252Cconfig%253Ddefault%252Ccpu_scaling_enabled%253Dfalse%252Cexecutable%253D_b_s_w_ir_cache_builder_src_out_ci_host_release_benchmarks_display_list_region_benchmarks%252Clibrary_build_type%253Drelease%252Cmhz_per_cpu%253D2200%252Cnum_cpus%253D8%252Csub_result%253Dcpu_time%252Ctest%253DBM_SkRegion_FromRects_Small%252Cunit%253Dus%252C&xbaroffset=43324

It looks bimodal, but it locks into one or the other measurements for many runs in a row triggered by seemingly random changes.

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