Bug 474376 - Unnecessarily blurry icons with fractional scale factor
Summary: Unnecessarily blurry icons with fractional scale factor
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kirigami
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: Master
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: kdelibs bugs
URL:
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2023-09-10 20:39 UTC by guimarcalsilva
Modified: 2023-09-25 20:41 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0


Attachments
Blurry icons, sharp clock text (90.59 KB, image/png)
2023-09-10 20:39 UTC, guimarcalsilva
Details

Note You need to log in before you can comment on or make changes to this bug.
Description guimarcalsilva 2023-09-10 20:39:03 UTC
Created attachment 161543 [details]
Blurry icons, sharp clock text

SUMMARY
At 1080p with 125% scaling, even after restarting the session, and on both X11 and Wayland, the icons in the panel are blurry. Note how the clock text is sharp in the same screenshot. The same does not happen in 5.27.

STEPS TO REPRODUCE
1. Change the scaling
2. Re-login

OBSERVED RESULT
Blurry icons in the panel

EXPECTED RESULT
Sharp icons

SOFTWARE/OS VERSIONS
Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.27.80
KDE Frameworks Version: 5.240.0
Qt Version: 6.6.0
Kernel Version: 6.2.0-32-generic (64-bit)
Graphics Platform: X11
Processors: 6 × Intel® Core™ i5-9400F CPU @ 2.90GHz
Memory: 15.5 GiB of RAM
Graphics Processor: AMD Radeon RX 570 Series
Comment 1 Nate Graham 2023-09-11 18:16:43 UTC
Looks like whatever's going on, it would be an issue with Kirigami.Icon, since all of those UI elements are using it for drawing those icons. Should be fixed--or at least improved--with https://invent.kde.org/frameworks/kirigami/-/merge_requests/1187.
Comment 2 Nate Graham 2023-09-12 13:41:09 UTC
Git commit ce458836db76d2c457264ecd61034c1e0210b098 by Nate Graham, on behalf of Marco Martin.
Committed on 12/09/2023 at 15:41.
Pushed by ngraham into branch 'master'.

Icon: render double-sized icons for 1<scale<2 to improve quality

For scale factors that are more than 1 but less than 2, which are quite
common, if the icon is rendered double to what was needed (i.e. 250% on
a scale factor of 125%) then when the resulting QImage is scaled down,
the final quality of the rendered icon is noticeably better.

M  +17   -16   src/icon.cpp
M  +1    -0    src/icon.h

https://invent.kde.org/frameworks/kirigami/-/commit/ce458836db76d2c457264ecd61034c1e0210b098
Comment 3 Marco Martin 2023-09-15 07:26:48 UTC
Unfortunately the approach of this commit didn't quite work: caused the wrong icon mipmap to be chosen so the icon shapes weren't quite right
Comment 4 Bug Janitor Service 2023-09-15 15:07:56 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/1253
Comment 5 Marco Martin 2023-09-25 07:46:42 UTC
Git commit c171f3dbfdd64866fffe76837499de37fdd6d9ae by Marco Martin.
Committed on 25/09/2023 at 09:46.
Pushed by mart into branch 'master'.

Second attempt at upscaling icons

Similar to what Qt Image element does, use devicePixelRatio to get the proper geometry of the rectangle where the icon will be painted into, *not* rounded but compensated so that in the final rendered image will be aligned to the pixel grid

![image](/uploads/c3e4e8d79c3acadf697767095defec1c/image.png)

M  +50   -34   src/icon.cpp
M  +2    -0    src/icon.h

https://invent.kde.org/frameworks/kirigami/-/commit/c171f3dbfdd64866fffe76837499de37fdd6d9ae