-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[Impeller] Fix overdraw in DrawRect geometry #174735
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] Fix overdraw in DrawRect geometry #174735
Conversation
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.
Code Review
This pull request addresses an overdraw issue in DrawRect geometry for stroked rectangles. For Bevel and Miter joins, the vertex generation has been updated to create geometry without inherent overdraw, and a special case has been added for thick strokes that collapse on themselves. For Round joins, the geometry is now flagged to use the pipeline's overdraw prevention, which fixes the visual artifact at a performance cost as noted. New tests are included to verify the rendering of wide stroked rectangles.
engine/src/flutter/impeller/display_list/aiks_dl_basic_unittests.cc
Outdated
Show resolved
Hide resolved
|
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. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
All tests passed and the goldens for the new tests look correct (no overdraw anomalies that I could see). This PR is ready for review now. |
|
ping @gaaclarke @chinmaygarde |
engine/src/flutter/impeller/display_list/aiks_dl_basic_unittests.cc
Outdated
Show resolved
Hide resolved
| // Most(all?) of our geometry is produced in full with an explicit mode | ||
| // specified in the returned GeometryResult, but just in case we missed | ||
| // a case, the safest mode to return here is kPreventOverdraw. | ||
| return 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.
I may be missing something obvious. But this should no longer be necessary now right?
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.
My reading of "PreventOverdraw" is "there may be overlapping triangles produced by this geometry but I want you to render them as though there aren't". The fix for the linked issue is either to just specify this result mode, or not produce any overlapping trianges. Not both I'd think.
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.
In case anyone adds a new case somewhere that isn't explicitly tagged, I wanted to make sure that we returned the safest option.
This "you can specify it if you want, the default is the one that is least safe but fastest, or you can return it from a method and some of our code might fill it in for you" spectrum of how this Mode is handled can be confusing and I don't think we are doing anyone any maintenance favors by having all of the defaults be "do it the fastest you can and don't worry about the consequences"...?
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.
Put another way, I bet the test passes if you only specify this and literally nothing else. So, why not just specify this for simplicity. As I understand, this specification forces a slower path to account for overlaps.
Or am I just mistaken?
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 also runs 50% slower.
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.
kPreventOverdraw isn't magic. It costs - a lot.
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.
Yeah, so why specify that as the default on the off chance we missed some edge case.
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.
Oh poop, I missed the spot where you explicitly set the mode to be normal for the known fast cases.
I take it that its by far the most common case? If so, all good 😊
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's not just the most common case, it never falls through. I removed it for now, but I don't like the entire design of this API that assumes things that have consequences that aren't immediately obvious and we construct an entire operation.
gaaclarke
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
| vertex_count * sizeof(Point), alignof(Point), | ||
| [hsw = half_stroke_width, &rect, vertex_count, | ||
| &trigs](uint8_t* buffer) { | ||
| [hsw = half_stroke_width, &rect, vertex_count, &trigs, |
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.
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.
Not going to change this. The following code would become unreadable and unmaintainable.
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.
However, a name should not distract the reader by repeating information that's present in the immediate context. Generally, this means that descriptiveness should be proportional to the name's scope of visibility.
hsw has a short scope of visibility and is defined in the calls of each of these lambdas. It also keeps the coordinate equations well-aligned and balanced.
| Scalar right = rect.GetRight(); | ||
| Scalar bottom = rect.GetBottom(); | ||
| auto vertices = reinterpret_cast<Point*>(buffer); | ||
| // Zig-zag pattern: UL, UR, LL, LR |
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.
Upper-left, upper-right, lower-left, lower-right?
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.
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.
Please, update the comment to avoid these abbreviations.
chinmaygarde
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.
Sorry about the confusion regarding overlap content mode in the default case.
I can totally empathize with the argument that we should fall back to a known safe but slow technique in case we missed something. OTOH, if we missed something, I'd rather folks report it to us as a bug instead of a mysterious performance issue that we'd have a harder time tracking down. Right now, I don't think there are cases we know we will miss. So I don't want to introduce a potential performance cliff.
Perhaps @gaaclarke has a different take but the current state of the patch without the fallback lgtm.
I'm not as familiar as you guys are with the ramifications of using different |
|
The gist of it is that strokes that overlap but also have a translucent stroke color will look weird where they overlap. I'll need to lookup the technique used to render them right but the a solid stroke is rendered offscreen and composited with the alpha component onscreen. Hence the slowness. |
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Looks like the golden diffs are for the test cases you added 🎉 |
Roll Flutter from 6b18740d5a23 to 87d5b753196c (88 revisions) flutter/flutter@6b18740...87d5b75 2025-09-05 [email protected] [ Device Lab ] Add regression testing for flutter/flutter#174952 (flutter/flutter#174956) 2025-09-05 [email protected] Roll Skia from 0ca53adfc6cc to 845ec125e94c (2 revisions) (flutter/flutter#174978) 2025-09-05 [email protected] [a11y-app] Fix NavigationRail leading and trailing labels (flutter/flutter#174861) 2025-09-05 [email protected] Roll Skia from d7e99be07d5d to 0ca53adfc6cc (5 revisions) (flutter/flutter#174972) 2025-09-05 [email protected] Roll Fuchsia Linux SDK from izfNA3o_2zL4Cjqmy... to xG_uERsxHvUwFHpF2... (flutter/flutter#174970) 2025-09-04 [email protected] Fix IconButton.color overrided by IconButtomTheme (flutter/flutter#174515) 2025-09-04 [email protected] [web] Reuse chrome instance to run all flutter tests (flutter/flutter#174957) 2025-09-04 [email protected] fix(Semantics): Ensure semantics properties take priority over button's (flutter/flutter#174473) 2025-09-04 [email protected] Make every LLDB Init error message actionable (flutter/flutter#174726) 2025-09-04 [email protected] Fix table cell semantics rect alignment issues. (flutter/flutter#174914) 2025-09-04 [email protected] Fix: Use route navigator for CupertinoSheetRoute pop (flutter/flutter#173103) 2025-09-04 [email protected] [ Widget Preview] Add `group` property to `Preview` (flutter/flutter#174849) 2025-09-04 [email protected] Allow OverlayPortal.overlayChildLayoutBuilder to choose root Overlay (flutter/flutter#174239) 2025-09-04 [email protected] Roll Skia from 7c2f502e3304 to d7e99be07d5d (18 revisions) (flutter/flutter#174936) 2025-09-04 [email protected] Remove 'terms of use' wording from web_unicode (flutter/flutter#174939) 2025-09-04 [email protected] [ Tool ] Remove leftover Android x86 deprecation warning constant (flutter/flutter#174941) 2025-09-04 [email protected] Prevent potential crash when accessing window in FlutterSceneDelegate (flutter/flutter#174873) 2025-09-04 [email protected] Roll Packages from 42bb347 to 98580c6 (5 revisions) (flutter/flutter#174943) 2025-09-04 [email protected] [ Device Lab ] Fix wakefulness check to only match log entries with string values (flutter/flutter#174953) 2025-09-04 [email protected] Fix expanded DropdownMenu panel is shorter than text field (flutter/flutter#174443) 2025-09-04 [email protected] Add a `viewController` property to the ios/macOS `FlutterPluginRegistrar` protocol (flutter/flutter#174168) 2025-09-03 [email protected] Roll Fuchsia Linux SDK from J3T_wZqL_57mRfWky... to izfNA3o_2zL4Cjqmy... (flutter/flutter#174908) 2025-09-03 [email protected] Wires up Android API to set section locale (flutter/flutter#173364) 2025-09-03 [email protected] Delete impeller::SPrintF. (flutter/flutter#174900) 2025-09-03 [email protected] Make sure that a DropdownMenuFormField doesn't crash in 0x0 environment (flutter/flutter#174777) 2025-09-03 [email protected] Remove unnecessary `presubmit_max_attempts` from .ci.yaml (flutter/flutter#174885) 2025-09-03 [email protected] Use local canvaskit in `dart_data_asset_test.dart` (flutter/flutter#174891) 2025-09-03 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Mark Linux web_canvaskit_tests_7_last as bringup (#174878)" (flutter/flutter#174897) 2025-09-03 [email protected] Correct intrinsics calculation for CupertinoTextField with placeholder (flutter/flutter#174889) 2025-09-03 [email protected] Considers large title height in CupertinoNavigationBar's preferred size (flutter/flutter#173722) 2025-09-03 [email protected] [A11y] Add semantics for CupertinoExpansionTile (flutter/flutter#174480) 2025-09-03 [email protected] Fix LinearProgressIndicator track painting. (flutter/flutter#173108) 2025-09-03 [email protected] update triage documentation to include team-android (flutter/flutter#174850) 2025-09-03 [email protected] Update `test_timeout_secs` to match `timeout` for `Linux web_skwasm_tests_*` and `Linux web_canvaskit_tests_*` (flutter/flutter#174881) 2025-09-03 [email protected] Roll Packages from 5d785a0 to 42bb347 (10 revisions) (flutter/flutter#174876) 2025-09-03 [email protected] Fixup formatting of gn files in the old buildroot. (flutter/flutter#174852) 2025-09-03 [email protected] Roll Dart SDK to 3.10.0-162.1.beta (flutter/flutter#174834) 2025-09-03 [email protected] Mark Linux web_canvaskit_tests_7_last as bringup (flutter/flutter#174878) 2025-09-02 [email protected] [Impeller] Fix overdraw in DrawRect geometry (flutter/flutter#174735) 2025-09-02 [email protected] Patch .clang-format files to specify C++20. (flutter/flutter#174848) 2025-09-02 [email protected] Add data assets (flutter/flutter#174685) 2025-09-02 [email protected] refactors `FlutterPlugin.kt` to use one line statement in the `into` bloc (flutter/flutter#174759) 2025-09-02 [email protected] Ensures initial semantics state is sent to engine (flutter/flutter#174845) 2025-09-02 [email protected] [Android] Break up plugin_test integration tests (flutter/flutter#174728) 2025-09-02 [email protected] Fix: Assertion failure in RawScrollbarState with dynamic controller assignment (flutter/flutter#173156) 2025-09-02 [email protected] Roll Skia from 359f3d7cc7ed to 7c2f502e3304 (1 revision) (flutter/flutter#174844) ...
Fixes flutter#174579 Vertex lists for stroked rects were fixed by being more careful about the creation of the vertices so that they have no inherent overdraw. These operations continue to use the fastest kNormal vertex mode but no longer create rendering artifacts due to multiple triangles covering the same area.
Fixes flutter#174579 Vertex lists for stroked rects were fixed by being more careful about the creation of the vertices so that they have no inherent overdraw. These operations continue to use the fastest kNormal vertex mode but no longer create rendering artifacts due to multiple triangles covering the same area.
…r#9962) Roll Flutter from 6b18740d5a23 to 87d5b753196c (88 revisions) flutter/flutter@6b18740...87d5b75 2025-09-05 [email protected] [ Device Lab ] Add regression testing for flutter/flutter#174952 (flutter/flutter#174956) 2025-09-05 [email protected] Roll Skia from 0ca53adfc6cc to 845ec125e94c (2 revisions) (flutter/flutter#174978) 2025-09-05 [email protected] [a11y-app] Fix NavigationRail leading and trailing labels (flutter/flutter#174861) 2025-09-05 [email protected] Roll Skia from d7e99be07d5d to 0ca53adfc6cc (5 revisions) (flutter/flutter#174972) 2025-09-05 [email protected] Roll Fuchsia Linux SDK from izfNA3o_2zL4Cjqmy... to xG_uERsxHvUwFHpF2... (flutter/flutter#174970) 2025-09-04 [email protected] Fix IconButton.color overrided by IconButtomTheme (flutter/flutter#174515) 2025-09-04 [email protected] [web] Reuse chrome instance to run all flutter tests (flutter/flutter#174957) 2025-09-04 [email protected] fix(Semantics): Ensure semantics properties take priority over button's (flutter/flutter#174473) 2025-09-04 [email protected] Make every LLDB Init error message actionable (flutter/flutter#174726) 2025-09-04 [email protected] Fix table cell semantics rect alignment issues. (flutter/flutter#174914) 2025-09-04 [email protected] Fix: Use route navigator for CupertinoSheetRoute pop (flutter/flutter#173103) 2025-09-04 [email protected] [ Widget Preview] Add `group` property to `Preview` (flutter/flutter#174849) 2025-09-04 [email protected] Allow OverlayPortal.overlayChildLayoutBuilder to choose root Overlay (flutter/flutter#174239) 2025-09-04 [email protected] Roll Skia from 7c2f502e3304 to d7e99be07d5d (18 revisions) (flutter/flutter#174936) 2025-09-04 [email protected] Remove 'terms of use' wording from web_unicode (flutter/flutter#174939) 2025-09-04 [email protected] [ Tool ] Remove leftover Android x86 deprecation warning constant (flutter/flutter#174941) 2025-09-04 [email protected] Prevent potential crash when accessing window in FlutterSceneDelegate (flutter/flutter#174873) 2025-09-04 [email protected] Roll Packages from 42bb347 to 98580c6 (5 revisions) (flutter/flutter#174943) 2025-09-04 [email protected] [ Device Lab ] Fix wakefulness check to only match log entries with string values (flutter/flutter#174953) 2025-09-04 [email protected] Fix expanded DropdownMenu panel is shorter than text field (flutter/flutter#174443) 2025-09-04 [email protected] Add a `viewController` property to the ios/macOS `FlutterPluginRegistrar` protocol (flutter/flutter#174168) 2025-09-03 [email protected] Roll Fuchsia Linux SDK from J3T_wZqL_57mRfWky... to izfNA3o_2zL4Cjqmy... (flutter/flutter#174908) 2025-09-03 [email protected] Wires up Android API to set section locale (flutter/flutter#173364) 2025-09-03 [email protected] Delete impeller::SPrintF. (flutter/flutter#174900) 2025-09-03 [email protected] Make sure that a DropdownMenuFormField doesn't crash in 0x0 environment (flutter/flutter#174777) 2025-09-03 [email protected] Remove unnecessary `presubmit_max_attempts` from .ci.yaml (flutter/flutter#174885) 2025-09-03 [email protected] Use local canvaskit in `dart_data_asset_test.dart` (flutter/flutter#174891) 2025-09-03 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Mark Linux web_canvaskit_tests_7_last as bringup (#174878)" (flutter/flutter#174897) 2025-09-03 [email protected] Correct intrinsics calculation for CupertinoTextField with placeholder (flutter/flutter#174889) 2025-09-03 [email protected] Considers large title height in CupertinoNavigationBar's preferred size (flutter/flutter#173722) 2025-09-03 [email protected] [A11y] Add semantics for CupertinoExpansionTile (flutter/flutter#174480) 2025-09-03 [email protected] Fix LinearProgressIndicator track painting. (flutter/flutter#173108) 2025-09-03 [email protected] update triage documentation to include team-android (flutter/flutter#174850) 2025-09-03 [email protected] Update `test_timeout_secs` to match `timeout` for `Linux web_skwasm_tests_*` and `Linux web_canvaskit_tests_*` (flutter/flutter#174881) 2025-09-03 [email protected] Roll Packages from 5d785a0 to 42bb347 (10 revisions) (flutter/flutter#174876) 2025-09-03 [email protected] Fixup formatting of gn files in the old buildroot. (flutter/flutter#174852) 2025-09-03 [email protected] Roll Dart SDK to 3.10.0-162.1.beta (flutter/flutter#174834) 2025-09-03 [email protected] Mark Linux web_canvaskit_tests_7_last as bringup (flutter/flutter#174878) 2025-09-02 [email protected] [Impeller] Fix overdraw in DrawRect geometry (flutter/flutter#174735) 2025-09-02 [email protected] Patch .clang-format files to specify C++20. (flutter/flutter#174848) 2025-09-02 [email protected] Add data assets (flutter/flutter#174685) 2025-09-02 [email protected] refactors `FlutterPlugin.kt` to use one line statement in the `into` bloc (flutter/flutter#174759) 2025-09-02 [email protected] Ensures initial semantics state is sent to engine (flutter/flutter#174845) 2025-09-02 [email protected] [Android] Break up plugin_test integration tests (flutter/flutter#174728) 2025-09-02 [email protected] Fix: Assertion failure in RawScrollbarState with dynamic controller assignment (flutter/flutter#173156) 2025-09-02 [email protected] Roll Skia from 359f3d7cc7ed to 7c2f502e3304 (1 revision) (flutter/flutter#174844) ...
Fixes flutter#174579 Vertex lists for stroked rects were fixed by being more careful about the creation of the vertices so that they have no inherent overdraw. These operations continue to use the fastest kNormal vertex mode but no longer create rendering artifacts due to multiple triangles covering the same area.
Fixes #174579
Vertex lists for stroked rects were fixed by being more careful about the creation of the vertices so that they have no inherent overdraw. These operations continue to use the fastest kNormal vertex mode but no longer create rendering artifacts due to multiple triangles covering the same area.