Repository navigation
Commit c091098
authored
Use round() for height inference in ImageDescriptor.instantiateCodec (#190925)
When ImageDescriptor.instantiateCodec receives only targetWidth, it
derives targetHeight using `targetHeight = targetWidth ~/ (width /
height)`. The mirror calculation in the same function derives
`targetWidth = (targetHeight * (width / height)).round()`. The former
calculation ends up flooring results and can change the original image's
aspect ratio.
In web_ui, both inferences use `round()`.
https://github.com/flutter/flutter/blob/b5971cabf92bbc126be2a82bc87052af6aeae5a2/engine/src/flutter/lib/web_ui/lib/src/engine/image_decoder.dart#L517.
The original PR
flutter-team-archive/engine#19537 doesn't
mention a rationale for this discrepancy. Because the current logic can
change the original image's aspect ratio, it's probably the right move
to make this calculation consistent with the rest.
Fixes #1905281 parent 27d9688 commit c091098
3 files changed
Lines changed: 29 additions & 1 deletion
File tree
- engine/src/flutter
- lib/ui
- testing/dart
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9123 | 9123 | | |
9124 | 9124 | | |
9125 | 9125 | | |
9126 | | - | |
| 9126 | + | |
9127 | 9127 | | |
9128 | 9128 | | |
9129 | 9129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
77 | 97 | | |
78 | 98 | | |
79 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
117 | 125 | | |
118 | 126 | | |
119 | 127 | | |
| |||
0 commit comments