Icon: snap the aspect-preserving painted size to device pixels

In the roundToIconSize path the icon size is derived from roundedWidth, which is snapped to whole device pixels so the icon stays crisp at fractional device pixel ratios. The branch that keeps the source aspect ratio computes its size directly from the item and source dimensions with no such snapping, so a scaled image could land on a fractional device pixel and look slightly soft. Snap the resulting size to whole device pixels.

Why

At a fractional DPR (e.g. 1.75x), a 22 logical-px painted size maps to 38.5 device px, half a pixel off the grid, which softens the edges. Snapping rounds it to 39 device px so it stays aligned.

The difference is subtle. Below is a magnified (14x) illustration of a portrait icon at 1.75x DPR: left without the snap (38.5 device px, half-pixel), right with it (39 device px, grid-aligned).

Device-pixel snap comparison For an original image: gt

Edited by Méven Car

Merge request reports

Loading