Repository navigation
Commit fdb7550
committed
Avoid centerSlice assertion failure under floating-point rounding
The centerSlice path in `paintImage` used a strict `==` comparison
between `sourceSize` and `inputSize`. When the image's pixel dimensions
are not evenly divisible by `scale`, the `inputSize / scale * scale`
round trip lands a few ULPs away from the original `inputSize`, and the
assertion fires for what is otherwise a valid configuration.
The same code path also fires when the destination rect is too small to
fit the centerSlice borders: `outputSize` becomes non-positive,
`applyBoxFit` degenerates to `Size.zero`, and the assertion compares
against zero for an unrelated reason.
This change tolerates double-precision rounding via
`precisionErrorTolerance` and skips the assertion entirely when the
slice borders cannot fit, which preserves the original safety check for
real BoxFit-induced source dropping while no longer breaking on either
edge case.
Refs flutter#278271 parent c6b590b commit fdb7550
2 files changed
Lines changed: 56 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
556 | 561 | | |
557 | 562 | | |
558 | 563 | | |
559 | 564 | | |
| 565 | + | |
560 | 566 | | |
561 | 567 | | |
562 | 568 | | |
| |||
567 | 573 | | |
568 | 574 | | |
569 | 575 | | |
570 | | - | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
571 | 579 | | |
572 | | - | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
573 | 583 | | |
574 | 584 | | |
575 | 585 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
180 | 182 | | |
181 | 183 | | |
182 | 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 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
183 | 227 | | |
184 | 228 | | |
185 | 229 | | |
| |||
0 commit comments