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 732375 - background: thumbnails are tiny in 3.13.3
background: thumbnails are tiny in 3.13.3
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Background
unspecified
Other All
: Normal normal
: ---
Assigned To: Debarshi Ray
Control-Center Maintainers
: 732845 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-06-28 03:52 UTC by Matthias Clasen
Modified: 2014-08-12 21:52 UTC
See Also:
GNOME target: 3.14
GNOME version: ---


Attachments
background: Composite the emblems ourselves (5.65 KB, patch)
2014-06-30 14:00 UTC, Debarshi Ray
needs-work Details | Review
background: Clean up uses of GIcon (7.18 KB, patch)
2014-06-30 14:00 UTC, Debarshi Ray
accepted-commit_now Details | Review
background: Composite the emblems ourselves (5.65 KB, patch)
2014-06-30 14:02 UTC, Debarshi Ray
needs-work Details | Review
background: Composite the emblems ourselves (5.90 KB, patch)
2014-07-02 12:11 UTC, Debarshi Ray
needs-work Details | Review
background: Composite the emblems ourselves (18.52 KB, patch)
2014-07-08 08:40 UTC, Debarshi Ray
none Details | Review
background: Composite the emblems ourselves (7.24 KB, patch)
2014-07-15 15:10 UTC, Bastien Nocera
needs-work Details | Review
background: Composite the emblems ourselves (19.59 KB, patch)
2014-07-15 16:31 UTC, Debarshi Ray
reviewed Details | Review
background: Composite the emblems ourselves (19.59 KB, patch)
2014-07-16 11:21 UTC, Debarshi Ray
none Details | Review
background: Composite the emblems ourselves (19.59 KB, patch)
2014-07-16 11:35 UTC, Debarshi Ray
committed Details | Review
background: Clean up uses of GIcon (8.36 KB, patch)
2014-08-12 21:51 UTC, Debarshi Ray
committed Details | Review

Description Matthias Clasen 2014-06-28 03:52:27 UTC
I suspect that this may be fallout from icon theme changes in gtk.
Comment 1 Debarshi Ray 2014-06-30 09:35:21 UTC
Continuing from #control-center in GIMPNet:

<hadess> i blame rishi's "hi dpi" work ;)

Instead, I think it has got to do with GTK_ICON_SIZE_DND and GtkCellRendererPixbuf because it doesn't matter if you use the HiDpi patches or not. Investigating ...
Comment 2 Bastien Nocera 2014-06-30 09:40:07 UTC
(In reply to comment #1)
> Continuing from #control-center in GIMPNet:
> 
> <hadess> i blame rishi's "hi dpi" work ;)
> 
> Instead, I think it has got to do with GTK_ICON_SIZE_DND and
> GtkCellRendererPixbuf because it doesn't matter if you use the HiDpi patches or
> not. Investigating ...

Not a regression then, that's good.
Comment 3 Debarshi Ray 2014-06-30 11:08:18 UTC
The GtkCellRendererPixbuf:stock-size is now causing the pixbufs to be scaled. That was not the case before.

We were setting stock-size to DND (ie. 32 pixels) so that emblems like "changes throughout the day" are rendered at 16 pixels, but that did not affect the size of the thumbnails. See bug 682123
Comment 4 Debarshi Ray 2014-06-30 11:19:49 UTC
This gtk+ commit is causing the tiny thumbnails:

commit f5d7e54d33ce72ba1cdcb2d4cd75ef61e946504a
Author: Matthias Clasen <mclasen@redhat.com>
Date:   Fri Jun 20 18:34:06 2014 -0400

    GtkCellRendererPixbuf: Set force_scale_pixbuf
    
    The recent icon theme scaling changes make the code more
    sensitive to mis-sized icons (e.g. application icons in
    the app chooser). A single row whose size gets blown out
    of proportion by a big icon is never wanted in a list.
    We can avoid this situation by telling GtkIconHelper to
    force-scale the pixbuf to the requested size.

However, the fix for bug 682123 has also been broken.
Comment 5 Debarshi Ray 2014-06-30 14:00:25 UTC
Created attachment 279601 [details] [review]
background: Composite the emblems ourselves
Comment 6 Debarshi Ray 2014-06-30 14:00:57 UTC
Created attachment 279602 [details] [review]
background: Clean up uses of GIcon
Comment 7 Debarshi Ray 2014-06-30 14:02:43 UTC
Created attachment 279603 [details] [review]
background: Composite the emblems ourselves

Fix typo in commit message.
Comment 8 Bastien Nocera 2014-07-01 13:42:45 UTC
Review of attachment 279601 [details] [review]:

Looks good otherwise.

::: panels/background/cc-background-item.c
@@ +101,3 @@
+        retval = g_object_ref (pixbuf);
+
+        icon = g_themed_icon_new ("slideshow-emblem");

You should cache this at the class level instead, so that we only need to get the slideshow-emblem pixbuf once.
Comment 9 Bastien Nocera 2014-07-01 13:43:56 UTC
Review of attachment 279602 [details] [review]:

That's a bit gratuitous, as a GdkPixbuf is a GIcon, but sure.
Comment 10 Bastien Nocera 2014-07-01 13:45:07 UTC
Review of attachment 279603 [details] [review]:

::: panels/background/cc-background-item.c
@@ +101,3 @@
+        retval = g_object_ref (pixbuf);
+
+        icon = g_themed_icon_new ("slideshow-emblem");

Ditto the previous review, the emblem pixbuf should be gotten once at the class level.
Comment 11 Debarshi Ray 2014-07-02 12:10:31 UTC
(In reply to comment #8)
> Review of attachment 279601 [details] [review]:
> 
> Looks good otherwise.
> 
> ::: panels/background/cc-background-item.c
> @@ +101,3 @@
> +        retval = g_object_ref (pixbuf);
> +
> +        icon = g_themed_icon_new ("slideshow-emblem");
> 
> You should cache this at the class level instead, so that we only need to get
> the slideshow-emblem pixbuf once.

Good idea. I have now used a static global to cache the pixbuf.
Comment 12 Debarshi Ray 2014-07-02 12:11:13 UTC
Created attachment 279745 [details] [review]
background: Composite the emblems ourselves
Comment 13 Bastien Nocera 2014-07-02 15:36:19 UTC
Review of attachment 279745 [details] [review]:

::: panels/background/cc-background-item.c
@@ +83,3 @@
 G_DEFINE_TYPE (CcBackgroundItem, cc_background_item, G_TYPE_OBJECT)
 
+static GdkPixbuf *slideshow_emblem = NULL;

Use a class-wide variable, not a static one, please.

Make the CcBackgroundItem struct private (in the C file), add a GdkPixbuf *member which you'd set in class_init(), and free in class_finalize.
Comment 14 Debarshi Ray 2014-07-07 12:37:56 UTC
(In reply to comment #13)
> Review of attachment 279745 [details] [review]:
> 
> ::: panels/background/cc-background-item.c
> @@ +83,3 @@
>  G_DEFINE_TYPE (CcBackgroundItem, cc_background_item, G_TYPE_OBJECT)
> 
> +static GdkPixbuf *slideshow_emblem = NULL;
> 
> Use a class-wide variable, not a static one, please.
> 
> Make the CcBackgroundItem struct private (in the C file), add a GdkPixbuf
> *member which you'd set in class_init(), and free in class_finalize.

You mean, add a member to CcBackgroundItemClass, right?  Each instance of the type will have a separate CcBackgroundItem struct.

Isn't it so that class_finalize is only used for dynamic types since static types are never destroyed? Declaring a cc_background_panel_class_finalize resulted in a 'defined but not used' warning, and a cursory reading of the GLib sources seems to indicate this? Or am I mistaken?
Comment 15 Debarshi Ray 2014-07-07 13:18:11 UTC
*** Bug 732845 has been marked as a duplicate of this bug. ***
Comment 16 Debarshi Ray 2014-07-07 16:40:10 UTC
Review of attachment 279745 [details] [review]:

::: panels/background/bg-source.c
@@ +158,3 @@
   priv = self->priv = SOURCE_PRIVATE (self);
 
+  priv->store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_OBJECT, G_TYPE_STRING);

We need to use Cairo surfaces instead of GdkPixbufs. Otherwise on HiDpi displays this will get scaled up to cover 512 application pixels instead of 256. This is because we hit this code path in ensure_surface_from_pixbuf: https://git.gnome.org/browse/gtk+/tree/gtk/gtkiconhelper.c#n583

It would have worked if 'scale' got set to 2 instead of 1, but such is life.
Comment 17 Debarshi Ray 2014-07-08 08:40:27 UTC
Created attachment 280123 [details] [review]
background: Composite the emblems ourselves

Using Cairo surfaces.
Comment 18 Bastien Nocera 2014-07-15 15:10:28 UTC
Created attachment 280723 [details] [review]
background: Composite the emblems ourselves

We were assuming that setting stock-size would affect the emblems in
GEmblemedIcons, but not the icons themselves. This is a bit weird.
GtkCellRendererPixbuf:gicon is meant to work with
GtkCellRendererPixbuf:stock-size, and this was only working so far
because GTK_ICON_LOOKUP_FORCE_SIZE was not being used when loading
the icon.

Lets composite the emblems ourselves so that we can use
GtkCellRendererPixbuf:pixbuf, which is unaffected by stock-size.

Also, as the GTK+ icon helpers will double the size of the preview
icons, don't bother doubling the default size of the icons.
Comment 19 Bastien Nocera 2014-07-15 15:15:02 UTC
This last patch is a modification of attachment 279745 [details] [review]. I fixed the double-doubling when using hi-dpi, letting the GTK+ icon code handle it, and fixed the memory management of the emblem icon.

You were correct about the class finalize only being used for dynamic types.
Comment 20 Debarshi Ray 2014-07-15 15:33:16 UTC
Review of attachment 280723 [details] [review]:

Unfortunately, the last patch was more correct than this one.

::: panels/background/bg-source.c
@@ -62,3 @@
-      priv->thumbnail_height *= scale_factor;
-      priv->thumbnail_width *= scale_factor;
-    }

This is wrong. We really should be creating pixbufs that have double the number of pixels. A pixbuf that has 512 pixels will look much better on a HiDpi display than a pixbuf that has 256 pixels but has been scaled up, even though both will appear of have the same size. In the latter case, there won't be any difference in the picture quality from a LoDpi display, which defeats the point of having a HiDpi display to begin with.

@@ +147,3 @@
   priv = self->priv = SOURCE_PRIVATE (self);
 
+  priv->store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_OBJECT, G_TYPE_STRING);

... We should be using a Cairo surface here because unlike a GdkPixbuf it knows about the scale factor.

Incidentally this is also what gnome-documents and gnome-photos does.
Comment 21 Bastien Nocera 2014-07-15 15:36:58 UTC
(In reply to comment #20)
> Review of attachment 280723 [details] [review]:
> 
> Unfortunately, the last patch was more correct than this one.
> 
> ::: panels/background/bg-source.c
> @@ -62,3 @@
> -      priv->thumbnail_height *= scale_factor;
> -      priv->thumbnail_width *= scale_factor;
> -    }
> 
> This is wrong. We really should be creating pixbufs that have double the number
> of pixels. A pixbuf that has 512 pixels will look much better on a HiDpi
> display than a pixbuf that has 256 pixels but has been scaled up, even though
> both will appear of have the same size. In the latter case, there won't be any
> difference in the picture quality from a LoDpi display, which defeats the point
> of having a HiDpi display to begin with.

Right.

> @@ +147,3 @@
>    priv = self->priv = SOURCE_PRIVATE (self);
> 
> +  priv->store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_OBJECT,
> G_TYPE_STRING);
> 
> ... We should be using a Cairo surface here because unlike a GdkPixbuf it knows
> about the scale factor.
> 
> Incidentally this is also what gnome-documents and gnome-photos does.

OK, I'll wait on your version of the last patch with the memory management for the emblem fixed.
Comment 22 Debarshi Ray 2014-07-15 16:31:15 UTC
Created attachment 280743 [details] [review]
background: Composite the emblems ourselves

Keep track of the references to the cached slideshow_emblem, and use a weak pointer to set it to NULL when the last reference is dropped, as done by Bastien in his last patch.

I slightly modified it so that each CcBackgroundItem explicitly keeps track of its reference to the cache. Otherwise if an item is destroyed before it had any reference to the cache, or if cc_background_item_get_frame_thumbnail was called multiple times on an item, then we would have a memory error.
Comment 23 Bastien Nocera 2014-07-16 09:44:41 UTC
Review of attachment 280743 [details] [review]:

"Let's"

Looks fine to commit other than that.

::: panels/background/bg-colors-source.c
@@ +79,3 @@
       GIcon *pixbuf;
+      cairo_surface_t *surface;
+      gint scale_factor;

Use int.

::: panels/background/bg-pictures-source.c
@@ +153,3 @@
   GtkListStore *store;
+  cairo_surface_t *surface = NULL;
+  gint scale_factor;

int.

::: panels/background/cc-background-item.c
@@ +128,3 @@
+        }
+
+        eh = gdk_pixbuf_get_height (slideshow_emblem);

What's the point of setting the item->priv->slideshow_emblem struct member if you're not going to use it?

@@ +135,3 @@
+        y = h - eh;
+
+        gdk_pixbuf_composite (slideshow_emblem, pixbuf, x, y, ew, eh, x, y, 1.0, 1.0, GDK_INTERP_BILINEAR, 255);

Ditto.
Comment 24 Debarshi Ray 2014-07-16 11:01:51 UTC
(In reply to comment #23)
> Review of attachment 280743 [details] [review]:
> 
> "Let's"

Ok.

> Looks fine to commit other than that.
> 
> ::: panels/background/bg-colors-source.c
> @@ +79,3 @@
>        GIcon *pixbuf;
> +      cairo_surface_t *surface;
> +      gint scale_factor;
> 
> Use int.

Ok.

> ::: panels/background/bg-pictures-source.c
> @@ +153,3 @@
>    GtkListStore *store;
> +  cairo_surface_t *surface = NULL;
> +  gint scale_factor;
> 
> int.

Ok.

> ::: panels/background/cc-background-item.c
> @@ +128,3 @@
> +        }
> +
> +        eh = gdk_pixbuf_get_height (slideshow_emblem);
> 
> What's the point of setting the item->priv->slideshow_emblem struct member if
> you're not going to use it?

priv->slideshow_emblem keeps track of an item's reference to the crash. Otherwise if an item is destroyed before it had any reference to the cache, or if cc_background_item_get_frame_thumbnail was called multiple times on an item, then we would have a memory error.
Comment 25 Debarshi Ray 2014-07-16 11:02:37 UTC
(In reply to comment #24)
> priv->slideshow_emblem keeps track of an item's reference to the crash.

s/crash/cache/
Comment 26 Debarshi Ray 2014-07-16 11:21:29 UTC
Created attachment 280800 [details] [review]
background: Composite the emblems ourselves
Comment 27 Debarshi Ray 2014-07-16 11:35:06 UTC
Created attachment 280803 [details] [review]
background: Composite the emblems ourselves
Comment 28 Bastien Nocera 2014-07-16 13:03:46 UTC
(In reply to comment #24)
> > What's the point of setting the item->priv->slideshow_emblem struct member if
> > you're not going to use it?
> 
> priv->slideshow_emblem keeps track of an item's reference to the crash.
> Otherwise if an item is destroyed before it had any reference to the cache, or
> if cc_background_item_get_frame_thumbnail was called multiple times on an item,
> then we would have a memory error.

Right, that'd be why it was done in _init() in my version of the patch. Looks fine either way.
Comment 29 Debarshi Ray 2014-07-16 15:04:25 UTC
(In reply to comment #28)
> (In reply to comment #24)
> > > What's the point of setting the item->priv->slideshow_emblem struct member if
> > > you're not going to use it?
> > 
> > priv->slideshow_emblem keeps track of an item's reference to the crash.
> > Otherwise if an item is destroyed before it had any reference to the cache, or
> > if cc_background_item_get_frame_thumbnail was called multiple times on an item,
> > then we would have a memory error.
> 
> Right, that'd be why it was done in _init() in my version of the patch. Looks
> fine either way.

Oh, yes, I had misread your patch. Sorry about that.

Now that I tried to put it in _init I think that it is not as robust as using a private struct member. eg., if gtk_icon_info_load_icon failed for the first item, but worked for the second, then we will get the reference count wrong. However I don't know if that is a realistic possibility. Maybe, in the middle of an update?
Comment 30 Bastien Nocera 2014-07-16 15:09:44 UTC
Your version looks fine to me.
Comment 31 Debarshi Ray 2014-08-12 21:51:55 UTC
Created attachment 283234 [details] [review]
background: Clean up uses of GIcon

Rebased against current master.