[gtk+] gtkicontheme: check for GdkPixbuf first



commit 03147b0e7253928b150fe1fbba23b454b42b7c28
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Aug 1 23:06:00 2013 +0200

    gtkicontheme: check for GdkPixbuf first
    
    We checked for G_IS_LOADABLE_ICON() before GDK_IS_PIXBUF().
    
    Since we made GdkPixbuf implement GLoadableIcon, the special case for
    pixbufs is never used, and the much much slower GLoadableIcon path is
    taken instead.  Move the GdkPixbuf one to be first to fix that.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705320

 gtk/gtkicontheme.c |   68 ++++++++++++++++++++++++++--------------------------
 1 files changed, 34 insertions(+), 34 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index e509197..5be7dbc 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -5184,7 +5184,40 @@ gtk_icon_theme_lookup_by_gicon_for_scale (GtkIconTheme       *icon_theme,
   g_return_val_if_fail (GTK_IS_ICON_THEME (icon_theme), NULL);
   g_return_val_if_fail (G_IS_ICON (icon), NULL);
 
-  if (G_IS_LOADABLE_ICON (icon))
+  if (GDK_IS_PIXBUF (icon))
+    {
+      GdkPixbuf *pixbuf;
+
+      pixbuf = GDK_PIXBUF (icon);
+
+      if ((flags & GTK_ICON_LOOKUP_FORCE_SIZE) != 0)
+        {
+          gint width, height, max;
+          gdouble pixbuf_scale;
+          GdkPixbuf *scaled;
+
+          width = gdk_pixbuf_get_width (pixbuf);
+          height = gdk_pixbuf_get_height (pixbuf);
+          max = MAX (width, height);
+          pixbuf_scale = (gdouble) size * scale / (gdouble) max;
+
+          scaled = gdk_pixbuf_scale_simple (pixbuf,
+                                            0.5 + width * pixbuf_scale,
+                                            0.5 + height * pixbuf_scale,
+                                            GDK_INTERP_BILINEAR);
+
+          info = gtk_icon_info_new_for_pixbuf (icon_theme, scaled);
+
+          g_object_unref (scaled);
+        }
+      else
+        {
+          info = gtk_icon_info_new_for_pixbuf (icon_theme, pixbuf);
+        }
+
+      return info;
+    }
+  else if (G_IS_LOADABLE_ICON (icon))
     {
       info = icon_info_new ();
       info->loadable = G_LOADABLE_ICON (g_object_ref (icon));
@@ -5248,39 +5281,6 @@ gtk_icon_theme_lookup_by_gicon_for_scale (GtkIconTheme       *icon_theme,
       else
         return NULL;
     }
-  else if (GDK_IS_PIXBUF (icon))
-    {
-      GdkPixbuf *pixbuf;
-
-      pixbuf = GDK_PIXBUF (icon);
-
-      if ((flags & GTK_ICON_LOOKUP_FORCE_SIZE) != 0)
-       {
-         gint width, height, max;
-         gdouble pixbuf_scale;
-         GdkPixbuf *scaled;
-
-         width = gdk_pixbuf_get_width (pixbuf);
-         height = gdk_pixbuf_get_height (pixbuf);
-         max = MAX (width, height);
-         pixbuf_scale = (gdouble) size * scale / (gdouble) max;
-
-         scaled = gdk_pixbuf_scale_simple (pixbuf,
-                                           0.5 + width * pixbuf_scale,
-                                           0.5 + height * pixbuf_scale,
-                                           GDK_INTERP_BILINEAR);
-
-         info = gtk_icon_info_new_for_pixbuf (icon_theme, scaled);
-
-         g_object_unref (scaled);
-       }
-      else
-       {
-         info = gtk_icon_info_new_for_pixbuf (icon_theme, pixbuf);
-       }
-
-      return info;
-    }
 
   return NULL;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]