pidgin: c6702617: Simplify: dest always equals src. No nee...
qulogic at pidgin.im
qulogic at pidgin.im
Wed Feb 24 00:10:59 EST 2010
-----------------------------------------------------------------
Revision: c6702617a937bd0b77620c209828d57563cc3f87
Ancestor: ddeec32813f54d5440b27a20c81743973d05079f
Author: qulogic at pidgin.im
Date: 2010-02-24T04:59:47
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/c6702617a937bd0b77620c209828d57563cc3f87
Modified files:
pidgin/gtkblist.c pidgin/pidginstock.c
ChangeLog:
Simplify: dest always equals src. No need to copy everything.
-------------- next part --------------
============================================================
--- pidgin/gtkblist.c e298a97509f6a2634d6ff8011e2e8ba4f3e8382b
+++ pidgin/gtkblist.c 75e12a867528816bbea127ed66339a66fefee05b
@@ -2660,39 +2660,30 @@ static void
/* Altered from do_colorshift in gnome-panel */
static void
-do_alphashift (GdkPixbuf *dest, GdkPixbuf *src, int shift)
+do_alphashift(GdkPixbuf *pixbuf, int shift)
{
gint i, j;
- gint width, height, has_alpha, srcrowstride, destrowstride;
- guchar *target_pixels;
- guchar *original_pixels;
- guchar *pixsrc;
- guchar *pixdest;
+ gint width, height, padding;
+ guchar *pixels;
int val;
- guchar a;
- has_alpha = gdk_pixbuf_get_has_alpha (src);
- if (!has_alpha)
+ if (!gdk_pixbuf_get_has_alpha(pixbuf))
return;
- width = gdk_pixbuf_get_width (src);
- height = gdk_pixbuf_get_height (src);
- srcrowstride = gdk_pixbuf_get_rowstride (src);
- destrowstride = gdk_pixbuf_get_rowstride (dest);
- target_pixels = gdk_pixbuf_get_pixels (dest);
- original_pixels = gdk_pixbuf_get_pixels (src);
+ width = gdk_pixbuf_get_width(pixbuf);
+ height = gdk_pixbuf_get_height(pixbuf);
+ padding = gdk_pixbuf_get_rowstride(pixbuf) - width * 4;
+ pixels = gdk_pixbuf_get_pixels(pixbuf);
for (i = 0; i < height; i++) {
- pixdest = target_pixels + i*destrowstride;
- pixsrc = original_pixels + i*srcrowstride;
for (j = 0; j < width; j++) {
- *(pixdest++) = *(pixsrc++);
- *(pixdest++) = *(pixsrc++);
- *(pixdest++) = *(pixsrc++);
- a = *(pixsrc++);
- val = a - shift;
- *(pixdest++) = CLAMP(val, 0, 255);
+ pixels++;
+ pixels++;
+ pixels++;
+ val = *pixels - shift;
+ *(pixels++) = CLAMP(val, 0, 255);
}
+ pixels += padding;
}
}
@@ -6367,7 +6358,7 @@ static void buddy_node(PurpleBuddy *budd
g_object_ref(G_OBJECT(gtkblist->empty_avatar));
avatar = gtkblist->empty_avatar;
} else if ((!PURPLE_BUDDY_IS_ONLINE(buddy) || purple_presence_is_idle(presence))) {
- do_alphashift(avatar, avatar, 77);
+ do_alphashift(avatar, 77);
}
emblem = pidgin_blist_get_emblem((PurpleBlistNode*) buddy);
============================================================
--- pidgin/pidginstock.c abe03fbe65bcb7a0cd43fced831dae3f7b90c4ab
+++ pidgin/pidginstock.c 27d760196319bd34c9099b911489e268beed07f8
@@ -270,37 +270,30 @@ static void
/* Altered from do_colorshift in gnome-panel */
static void
-do_alphashift(GdkPixbuf *dest, GdkPixbuf *src)
+do_alphashift(GdkPixbuf *pixbuf)
{
gint i, j;
- gint width, height, has_alpha, srcrowstride, destrowstride;
- guchar *target_pixels;
- guchar *original_pixels;
- guchar *pixsrc;
- guchar *pixdest;
+ gint width, height, padding;
+ guchar *pixels;
guchar a;
- has_alpha = gdk_pixbuf_get_has_alpha (src);
- if (!has_alpha)
+ if (!gdk_pixbuf_get_has_alpha(pixbuf))
return;
- width = gdk_pixbuf_get_width (src);
- height = gdk_pixbuf_get_height (src);
- srcrowstride = gdk_pixbuf_get_rowstride (src);
- destrowstride = gdk_pixbuf_get_rowstride (dest);
- target_pixels = gdk_pixbuf_get_pixels (dest);
- original_pixels = gdk_pixbuf_get_pixels (src);
+ width = gdk_pixbuf_get_width(pixbuf);
+ height = gdk_pixbuf_get_height(pixbuf);
+ padding = gdk_pixbuf_get_rowstride(pixbuf) - width * 4;
+ pixels = gdk_pixbuf_get_pixels(pixbuf);
for (i = 0; i < height; i++) {
- pixdest = target_pixels + i*destrowstride;
- pixsrc = original_pixels + i*srcrowstride;
for (j = 0; j < width; j++) {
- *(pixdest++) = *(pixsrc++);
- *(pixdest++) = *(pixsrc++);
- *(pixdest++) = *(pixsrc++);
- a = *(pixsrc++);
- *(pixdest++) = a / 2;
+ pixels++;
+ pixels++;
+ pixels++;
+ a = *(pixels);
+ *(pixels++) = a / 2;
}
+ pixels += padding;
}
}
@@ -348,7 +341,7 @@ add_sized_icon(GtkIconSet *iconset, GtkI
g_return_if_fail(filename != NULL);
pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
if (translucent)
- do_alphashift(pixbuf, pixbuf);
+ do_alphashift(pixbuf);
source = gtk_icon_source_new();
gtk_icon_source_set_pixbuf(source, pixbuf);
@@ -378,7 +371,7 @@ add_sized_icon(GtkIconSet *iconset, GtkI
g_return_if_fail(filename != NULL);
pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
if (translucent)
- do_alphashift(pixbuf, pixbuf);
+ do_alphashift(pixbuf);
source = gtk_icon_source_new();
gtk_icon_source_set_pixbuf(source, pixbuf);
More information about the Commits
mailing list