← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~bratsche/xsplash/precompute-throbber into lp:xsplash

 

Cody Russell has proposed merging lp:~bratsche/xsplash/precompute-throbber into lp:xsplash.

    Requested reviews:
    Canonical Desktop Experience Team (canonical-dx-team)
Related bugs:
  #491029 Throbber sub-pixbufs should be pre-computed, not in throbber_frame_cb()
  https://bugs.launchpad.net/bugs/491029

-- 
https://code.launchpad.net/~bratsche/xsplash/precompute-throbber/+merge/15564
Your team ayatana-commits is subscribed to branch lp:xsplash.
=== modified file 'src/xsplash.c'
--- src/xsplash.c	2009-10-21 13:06:01 +0000
+++ src/xsplash.c	2009-12-02 17:30:24 +0000
@@ -62,6 +62,7 @@
   GtkWidget       *background;
   GdkPixbuf       *logo_pixbuf;
   GdkPixbuf       *throbber_pixbuf;
+  GdkPixbuf      **throbber_slices;
 
   gchar           *dbusobject;
   DBusGConnection *system_bus;
@@ -231,6 +232,7 @@
 xsplash_server_dispose (GObject *object)
 {
   XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (object);
+  int i;
 
   if (have_xcomposite && priv->cow)
     {
@@ -239,6 +241,16 @@
       g_object_unref (priv->cow);
     }
 
+  if (priv->throbber_slices)
+    {
+      for (i = 0; i < throbber_frames; i++)
+        {
+          g_object_unref (priv->throbber_slices[0]);
+        }
+
+      g_free (priv->throbber_slices);
+    }
+
   if (priv->throbber_pixbuf)
     g_object_unref (priv->throbber_pixbuf);
 
@@ -565,7 +577,23 @@
 
       if (throbber_filename && throbber_frames)
         {
+          int width, height;
+          int i;
+
           priv->throbber_pixbuf = gdk_pixbuf_new_from_file (throbber_filename, NULL);
+          width = gdk_pixbuf_get_width (priv->throbber_pixbuf);
+          height = gdk_pixbuf_get_height (priv->throbber_pixbuf) / throbber_frames;
+
+          priv->throbber_slices = g_malloc (sizeof (GdkPixbuf *) * throbber_frames);
+          for (i = 0; i < throbber_frames; i++)
+            {
+              GdkPixbuf *pixbuf = gdk_pixbuf_new_subpixbuf (priv->throbber_pixbuf,
+                                                            0,
+                                                            height * i,
+                                                            width,
+                                                            height);
+              priv->throbber_slices[i] = pixbuf;
+            }
 
           if (priv->throbber_pixbuf != NULL)
             {
@@ -708,18 +736,12 @@
   XsplashServerPrivate *priv;
   GdkPixbuf *pixbuf;
   gint frame;
-  gint height, y_offset;
 
   server = (XsplashServer *)user_data;
   priv = XSPLASH_SERVER_GET_PRIVATE (server);
+
   frame = MIN (throbber_frames * progress, throbber_frames - 1);
-
-  height = gdk_pixbuf_get_height (priv->throbber_pixbuf) / throbber_frames;
-  y_offset = height * (frame);
-
-  pixbuf = gdk_pixbuf_new_subpixbuf (priv->throbber_pixbuf,
-                                     0, y_offset,
-                                     gdk_pixbuf_get_width (priv->throbber_pixbuf), height);
+  pixbuf = priv->throbber_slices[frame];
 
   gtk_image_set_from_pixbuf (GTK_IMAGE (priv->throbber),
                              pixbuf);


Follow ups