After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 708384 - icontheme: Make sure icon_info->scale doesn't end up 0
icontheme: Make sure icon_info->scale doesn't end up 0
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
unspecified
Other All
: High critical
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-09-19 15:09 UTC by Florian Müllner
Modified: 2013-09-23 10:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
icontheme: Make sure icon_info->scale doesn't end up 0 (1.75 KB, patch)
2013-09-19 15:09 UTC, Florian Müllner
committed Details | Review
icon-theme: Better handling of unscaled icon directories (5.11 KB, patch)
2013-09-23 10:45 UTC, Alexander Larsson
committed Details | Review

Description Florian Müllner 2013-09-19 15:09:29 UTC
See patch.

(Alex promised to take a look later)
Comment 1 Florian Müllner 2013-09-19 15:09:32 UTC
Created attachment 255310 [details] [review]
icontheme: Make sure icon_info->scale doesn't end up 0

GdkPixbuf will fail returning %NULL if we try to scale a pixbuf to (0, 0),
which will then trigger an assertion in gtk_icon_info_load_icon_finish();
we never want a scale of 0, so ensure it is at least 1.
Comment 2 Alexander Larsson 2013-09-19 15:11:24 UTC
This is fine as a workaround. I'll have a look for a better solution later.
Comment 3 Matthias Clasen 2013-09-19 18:50:55 UTC
Review of attachment 255310 [details] [review]:

ok
Comment 4 Alexander Larsson 2013-09-20 12:46:50 UTC
Comment on attachment 255310 [details] [review]
icontheme: Make sure icon_info->scale doesn't end up 0

Attachment 255310 [details] pushed as f081552 - icontheme: Make sure icon_info->scale doesn't end up 0
Comment 5 Alexander Larsson 2013-09-23 08:00:18 UTC
So, here is the real problem:

In the old days for e.g a FIXED directory, or a THRESHOLD directory when the requested size was inside the directory size limits, we *always* set the scale factor to 1, as these are not supposed to be scaled.

So, for example, suppose you look up a icon at size 28, and the only matching icon is of size 24. This will always result in us picking the 24 icon. If this is in a SCALABLE directory we will just scale it by 28/24 == 1.1667. However, if the directory is FIXED we always use scale factor 1, which means the app gets to pad to whatever size it wants.

Now, consider the case of HiDPI. We're looking up at 28@2x, and if we find an icon in a Size=24 Scale=2 directory we will just return it with scale=1. However, if there is no 24@2x icon but there is a 48@1x icon we generally want to act as if this was a 24@2x icon to avoid fuzzy icons. So, this would similarly just return a scale 1.0.

*However* Consider the case where we only had a 24@1x icon, like in the scale 1 case above. In order to look the same as the scale 1 case (but maybe a bit fuzzy) we *should* scale this by 2.0.

So, in the complex cases we have:
desired_size = 28
desired_scale = 2
scaled_desired_scale = 56

In one case we have:
dir_size=24
dir_scale=1
Here we want to return scale = 2

In the other case we have
dir_size=48
dir_scale=1
Here we want to return scale = 1

I don't know how to pick this in a good way here, as its kinda hard to disentangle the two cases. Maybe we need to do that at some earlier point...
Comment 6 Alexander Larsson 2013-09-23 10:45:16 UTC
Created attachment 255555 [details] [review]
icon-theme: Better handling of unscaled icon directories

If an icon is in a Fixed or Threshold directory we normally don't
scale it. However, in the case of HiDPI scaling we *do* want to
scale it, to avoid different layouts in Lo/HiDPI. We look up whatever
the size of the icon would have been in LoDPI and scale to that
in the no-scaling case, thus getting the same layout as the
unscaled case.
Comment 7 Alexander Larsson 2013-09-23 10:45:54 UTC
Attachment 255555 [details] pushed as 68c4504 - icon-theme: Better handling of unscaled icon directories