Repository navigation
Commit de177df
authored
Fix
Fixes flutter#189807
See the issue for more context.
Adds a unit test that fails without this change, and passes with this
change.
Verified the demo app in the issue renders properly with this change.
From the issue:
## Root cause and fix
[Rect::ExpandToMinTransformedSize](https://github.com/flutter/flutter/blob/1c8b3088238220102df66761685f3a4718b5aa15/engine/src/flutter/impeller/geometry/rect.h#L705)
always constructs a new expanded rectangle from the input Rect from its
center point and half-extents.
If the input rectangle is already large enough and does not need
expansion, this should return an identical rectangle. The returned
rectangle is equality-checked against the input in
[Canvas::DrawRoundRect](https://github.com/flutter/flutter/blob/1c8b3088238220102df66761685f3a4718b5aa15/engine/src/flutter/impeller/display_list/canvas.cc#L1129)
to determine whether expansion happened. That code assumes that if the
output does not equal the input, pixel-expansion happened, which means
that the rounded rect had sub-pixel dimensions and can be safely drawn
as a non-rounded rectangle.
The issue is that for certain cases, particularly with non-integer
sizes, ExpandToMinTransformedSize returns a different rectangle even if
no expansion happened. This is due to small floating point imprecisions
when constructing the new rectangle using the input rectangle's center
and half-extents.
To fix this, ExpandToMinTransformedSize should not construct a new
rectangle unless expansion is actually needed.
## Removal of 1-pixel roundrect to rect simplification
This PR also removes the 1-pixel roundrect to rect simplification in
`Canvas::DrawRoundRect`. As described in
flutter#189807 (comment),
this optimization resulted in slightly different colors at the tips of
thin roundrects.
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [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.
- [ ] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
If this change needs to override an active code freeze, provide a
comment explaining why. The code freeze workflow can be overridden by
code reviewers. See pinned issues for any active code freezes with
guidance.
**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
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[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.mdRect::ExpandToMinTransformedSize to return the input rectangle when no expansion is needed, and remove 1-pixel roundrect to rect simplification (flutter#189808)1 parent cb34620 commit de177df
3 files changed
Lines changed: 26 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1111 | 1111 | | |
1112 | 1112 | | |
1113 | 1113 | | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
1114 | 1117 | | |
1115 | 1118 | | |
1116 | 1119 | | |
1117 | | - | |
1118 | | - | |
1119 | | - | |
1120 | | - | |
| 1120 | + | |
| 1121 | + | |
1121 | 1122 | | |
1122 | 1123 | | |
1123 | 1124 | | |
1124 | 1125 | | |
1125 | 1126 | | |
1126 | 1127 | | |
1127 | | - | |
1128 | | - | |
1129 | | - | |
1130 | | - | |
1131 | | - | |
1132 | | - | |
1133 | | - | |
1134 | | - | |
1135 | | - | |
1136 | | - | |
1137 | | - | |
1138 | | - | |
| 1128 | + | |
| 1129 | + | |
1139 | 1130 | | |
1140 | 1131 | | |
1141 | 1132 | | |
1142 | | - | |
1143 | | - | |
| 1133 | + | |
| 1134 | + | |
1144 | 1135 | | |
1145 | 1136 | | |
1146 | 1137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
719 | 719 | | |
720 | 720 | | |
721 | 721 | | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
722 | 729 | | |
723 | 730 | | |
724 | 731 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1444 | 1444 | | |
1445 | 1445 | | |
1446 | 1446 | | |
1447 | | - | |
1448 | | - | |
| 1447 | + | |
1449 | 1448 | | |
1450 | 1449 | | |
1451 | 1450 | | |
1452 | 1451 | | |
1453 | 1452 | | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
1454 | 1462 | | |
1455 | 1463 | | |
1456 | 1464 | | |
| |||
0 commit comments