ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #00668
[Branch ~xsplash-team/xsplash/trunk] Rev 93: Precompute animation image slices
Merge authors:
Cody Russell (bratsche)
Related merge proposals:
https://code.launchpad.net/~bratsche/xsplash/precompute-throbber/+merge/15564
proposed by: Cody Russell (bratsche)
review: Needs Fixing - Ted Gould (ted)
------------------------------------------------------------
revno: 93 [merge]
committer: Cody Russell <crussell@xxxxxxxxxxxxx>
branch nick: trunk
timestamp: Wed 2009-12-09 10:47:40 -0600
message:
Precompute animation image slices
modified:
src/xsplash.c
--
lp:xsplash
https://code.launchpad.net/~xsplash-team/xsplash/trunk
Your team ayatana-commits is subscribed to branch lp:xsplash.
To unsubscribe from this branch go to https://code.launchpad.net/~xsplash-team/xsplash/trunk/+edit-subscription.
=== modified file 'src/xsplash.c'
--- src/xsplash.c 2009-11-04 22:19:27 +0000
+++ src/xsplash.c 2009-12-09 16:47:40 +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[i]);
+ }
+
+ 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);