-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Use kPreventOverdraw for arcs with overlapping stroke caps #179312
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
Use kPreventOverdraw for arcs with overlapping stroke caps #179312
Conversation
flar
left a comment
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.
Some food for thought. I don't know if this can be moved somewhere where we compute the Arc::Iterator or not. It would give you helpful delta vectors to compute where the ends are.
flar
left a comment
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.
It all looks good, but I think I might have uncovered some related issues in my evaluation of the unit tests that bears investigation while we are solving the overlap issues.
| return ComputePositionGeometry(renderer, generator, entity, pass); | ||
| auto result = ComputePositionGeometry(renderer, generator, entity, pass); | ||
| if (CapsOverlap()) { | ||
| result.mode = GeometryResult::Mode::kPreventOverdraw; |
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.
Perhaps in a follow-on PR, we should consider having the generator specify the overlap type rather than patching it after the fact.
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.
Acknowledged. I'll follow up with this.
| // inside the inner edge of the start cap. For a visualization of when | ||
| // this occurs, see | ||
| // https://github.com/flutter/flutter/issues/178746#issuecomment-3554526727 | ||
| // Note that testing for overlap is completely non-dependent on the arc's |
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.
independent of
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.
Done
| // start angle is 0. | ||
| auto radius = arc_.GetOvalSize().width / 2.0f; | ||
| auto start_point = Point(radius, 0); | ||
| auto sweep_angle = Radians(arc_.GetSweep()).radians; |
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.
nit: sweep_radians since you've resolved it to radians and not just an angle
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.
Done
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.
LGTM, but we should have a golden that also verifies the output but I didn't see any golden changes from existing tests. Maybe a variety of angles and widths with each end cap. I don't think you need to test the non-overlaps (maybe 1 for reference?), just make sure a variety of overlaps don't overdraw. It might require 3 separate tests? Or if you can pack in a reasonably visible set of tests into one image that would be cool too. But we should have had golden changes for this and the fact that we didn't indicates a hole in our testing.
Some minor nits in the comments that would be nice to adopt.
| auto start_point = Point(radius, 0); | ||
| auto sweep_angle = Radians(arc_.GetSweep()).radians; | ||
| auto end_point = Point(cos(sweep_angle), sin(sweep_angle)) * radius; | ||
| return (end_point - start_point).GetLength() < stroke_width_; |
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.
start_point.GetDistanceSquared(end_point) < stroke_width * stroke_width to avoid the sqrt
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.
Done
| // coordinate of the ending cap, rather than needing to calculate overlap | ||
| // based on both x and y positions of both caps. | ||
| auto radius = arc_.GetOvalSize().width / 2.0f; | ||
| auto half_width = stroke_width_ / 2.0f; |
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.
* 0.5f might be faster than / 2.0f depending on compiler opts.
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.
Done
Added a golden test each for square and round caps. They're modified versions of the existing |
flar
left a comment
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.
LGTM
|
I'll want to take a final look at the goldens for the playground test, but I'm guessing it will work right. |
|
Goldens LGTM |
|
autosubmit label was removed for flutter/flutter/179312, because - The status or check suite Linux mac_clang_tidy has failed. Please fix the issues identified (or deflake) before re-applying this label.
|
…79312) Fixes flutter#178746 Before: <img width="341" height="527" alt="image" src="https://github.com/user-attachments/assets/b2458490-109f-4e6f-b35d-3bc0e5648de6" /> After: <img width="295" height="566" alt="image" src="https://github.com/user-attachments/assets/f5958934-dae2-4181-b142-9c68f8cdc2e8" /> ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
flutter/flutter@e25d71b...6e1aa82 2025-12-12 [email protected] Add documentation for what to do when bumping the minimum sdk version supported by flutter (flutter/flutter#179795) 2025-12-12 [email protected] Roll Skia from ee08571bbf67 to e66816c3645e (2 revisions) (flutter/flutter#179792) 2025-12-12 [email protected] Roll Packages from 36383d6 to 0ac7a03 (1 revision) (flutter/flutter#179793) 2025-12-12 [email protected] Roll Fuchsia Linux SDK from QssSL8DkxIbMvf89C... to fppT9ZrwbFx7iYrIh... (flutter/flutter#179785) 2025-12-12 [email protected] Roll Skia from 4251aa7454da to ee08571bbf67 (1 revision) (flutter/flutter#179783) 2025-12-12 [email protected] Roll Skia from 344ff9c41fb6 to 4251aa7454da (2 revisions) (flutter/flutter#179779) 2025-12-12 [email protected] Fix draggable scrollable sheet example drag speed is off (flutter/flutter#179179) 2025-12-12 [email protected] [ios][pv] accept/reject gesture based on hitTest (with new widget API) (flutter/flutter#179659) 2025-12-12 [email protected] Roll Skia from 7ad91f64b468 to 344ff9c41fb6 (1 revision) (flutter/flutter#179774) 2025-12-12 [email protected] [fuchsia] temporarily disable touch-input-test due to the flakiness (flutter/flutter#179747) 2025-12-12 [email protected] Roll Skia from 979b7ae09145 to 7ad91f64b468 (6 revisions) (flutter/flutter#179770) 2025-12-12 [email protected] Exit with code 1 when calling `flutter build` without arguments (flutter/flutter#175900) 2025-12-12 [email protected] [ Tool ] Assemble: "Improper" validation error when dealing with base64 encoded dart-define value (flutter/flutter#178737) 2025-12-12 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[ Analysis ] Added initial implementation of the `flutter_analyzer_plugin` (#175679)" (flutter/flutter#179766) 2025-12-11 [email protected] Add 3.38.5 changelog (flutter/flutter#179750) 2025-12-11 [email protected] Roll Dart SDK from 3d4b989bdc41 to 9a65db770758 (2 revisions) (flutter/flutter#179746) 2025-12-11 [email protected] fix: fresh install of windows support (flutter/flutter#179720) 2025-12-11 [email protected] [ Analysis ] Added initial implementation of the `flutter_analyzer_plugin` (flutter/flutter#175679) 2025-12-11 [email protected] Roll Skia from d570e2317110 to 979b7ae09145 (4 revisions) (flutter/flutter#179742) 2025-12-11 [email protected] chore: linux fuchsia tests are flaking (flutter/flutter#179744) 2025-12-11 [email protected] Roll Packages from 74a5a53 to 36383d6 (4 revisions) (flutter/flutter#179740) 2025-12-11 [email protected] Revert "Android implementation of content sizing" (flutter/flutter#179698) 2025-12-11 [email protected] [skia] Disable legacy image decoders (flutter/flutter#179277) 2025-12-11 [email protected] Roll Skia from deb0153719dd to d570e2317110 (2 revisions) (flutter/flutter#179734) 2025-12-11 [email protected] Roll Dart SDK from dbcb567e2432 to 3d4b989bdc41 (1 revision) (flutter/flutter#179733) 2025-12-11 [email protected] Roll Fuchsia Linux SDK from u5vxWTRT0HlxOP5_r... to QssSL8DkxIbMvf89C... (flutter/flutter#179729) 2025-12-11 [email protected] Roll Skia from 59c6cad539f7 to deb0153719dd (2 revisions) (flutter/flutter#179721) 2025-12-11 [email protected] Roll Dart SDK from 077062c5e515 to dbcb567e2432 (2 revisions) (flutter/flutter#179715) 2025-12-11 [email protected] Use kPreventOverdraw for arcs with overlapping stroke caps (flutter/flutter#179312) 2025-12-11 [email protected] Roll Skia from e61cc6d073fd to 59c6cad539f7 (22 revisions) (flutter/flutter#179714) 2025-12-10 [email protected] Reland: Add framework-side hitTestBehavior support to Semantics (#178817) (flutter/flutter#179352) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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




Fixes #178746
Before:

After:

Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.