Repository navigation
Commit 5544f00
authored
Fix square corner issue (flutter#191096)
Fixes flutter#190602, see my
[comment](flutter#190602 (comment))
on that issue for details about the problems I identified.
Also fixes flutter#162172
## What changed
When a route contained rounded clips (such as `CupertinoSheetRoute`),
intermediate child ink features, and a backdrop filter (such as a
blurred app bar), the clip stack replay logic prematurely popped parent
clips and exceeded the depth buffer budget across render pass splits,
causing subsequent header draws to render with 90° square corners. This
PR addresses both mechanisms:
First, `EntityPassClipStack::RecordRestore` was popping replay entities
unconditionally whenever any clip was restored. In a sheet containing
ink decorations (like list item ripple effects), child clip restores at
deeper heights would prematurely discard the root parent clip. We now
track `clip_height` in `ReplayResult` so that restorations only pop
entities when `clip_height > restore_height`, preserving parent clips
across sibling restores. When replaying those clips in
`ClipContents::Render`, we also supply the entity's model matrix to
properly recompute the MVP matrix against the new pass's orthographic
projection instead of reusing the stale matrix from the prior pass.
Second, the pass depth budget was exhausting across backdrop splits.
`Canvas::kMaxDepth` (`1 << 24`) was mismatched with
`Entity::kDepthEpsilon` (`1.0 / 262144.0`, or `2^-18`), allowing integer
depths to exceed the 18-bit precision of the depth buffer. Aligning
`Canvas::kMaxDepth` to `262,143` and capping depth allocations in
`Save`/`SaveLayer` to `min(current_depth_ + total_content_depth,
parent_clip_depth)` keeps clip replay and subsequent draw operations
within valid precision bounds. In `Canvas::Restore`, we also prevent
unconditional depth jumps to `kMaxDepth` for unclipped saves, preserving
the allocated budget for subsequent sibling draws.
## Testing
Reproducing this interaction in automated tests required testing the
onscreen pass-splitting branch (`IsOnscreen()`), which normal offscreen
unit tests bypass. We added a `ScopedOnscreenOverride` test hook in
`Canvas` and constructed a multi-layer display list recreating the route
clip, child ink items, blurred backdrop bar, and trailing app bar:
* `clip_stack_unittests.cc`: Added
`EntityPassClipStackTest.RestoringChildClipPreservesParentReplayEntities`
to isolate parent clip retention across sibling restores.
* `canvas_unittests.cc`: Added
`AiksTest.ClipDepthMaintainedAcrossBackdropFilterAndLayers` to verify
depth invariants and precision bounds (`<= kMaxDepth`), and
`AiksTest.ParentClipDepthBudgetPreservedAfterBackdropLayerRestore` to
verify parent depth budget restoration.
* `dl_golden_unittests.cc` (`impeller_golden_tests`): Added
`DlGoldenTest.CanRenderClippedBackdropFilterWithSuperellipse` for
pixel-accurate golden image verification in CI against Skia Gold.
## 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.
- [x] All existing and new tests are passing.
<!-- 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.md1 parent a1498f2 commit 5544f00
10 files changed
Lines changed: 342 additions & 42 deletions
File tree
- engine/src/flutter/impeller
- display_list
- entity
- contents
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
199 | 200 | | |
200 | 201 | | |
201 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
139 | 141 | | |
140 | 142 | | |
141 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
142 | 219 | | |
143 | 220 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1775 | 1775 | | |
1776 | 1776 | | |
1777 | 1777 | | |
1778 | | - | |
| 1778 | + | |
| 1779 | + | |
1779 | 1780 | | |
1780 | | - | |
1781 | | - | |
1782 | | - | |
1783 | 1781 | | |
1784 | 1782 | | |
1785 | 1783 | | |
| |||
1942 | 1940 | | |
1943 | 1941 | | |
1944 | 1942 | | |
1945 | | - | |
| 1943 | + | |
1946 | 1944 | | |
1947 | 1945 | | |
1948 | 1946 | | |
| |||
2028 | 2026 | | |
2029 | 2027 | | |
2030 | 2028 | | |
2031 | | - | |
2032 | | - | |
2033 | | - | |
2034 | | - | |
| 2029 | + | |
| 2030 | + | |
2035 | 2031 | | |
2036 | 2032 | | |
2037 | 2033 | | |
| |||
2076 | 2072 | | |
2077 | 2073 | | |
2078 | 2074 | | |
2079 | | - | |
2080 | | - | |
2081 | | - | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
2082 | 2085 | | |
2083 | 2086 | | |
2084 | 2087 | | |
| |||
2628 | 2631 | | |
2629 | 2632 | | |
2630 | 2633 | | |
2631 | | - | |
2632 | | - | |
2633 | 2634 | | |
2634 | 2635 | | |
2635 | 2636 | | |
| |||
2641 | 2642 | | |
2642 | 2643 | | |
2643 | 2644 | | |
2644 | | - | |
| 2645 | + | |
2645 | 2646 | | |
2646 | 2647 | | |
2647 | 2648 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
| |||
0 commit comments