summaryrefslogtreecommitdiff
path: root/gdk-pixbuf
diff options
context:
space:
mode:
authorSven Neumann <sven@gimp.org>2001-08-07 17:49:09 +0000
committerSven Neumann <neo@src.gnome.org>2001-08-07 17:49:09 +0000
commit85a58dddba28d49332c0cf8679a7f821e81c7c78 (patch)
treecc1a4667ed5a4385f90bedd83221d69bb6e39a73 /gdk-pixbuf
parent967c0f7c7b63c847ca52622e90c61914beb3d412 (diff)
downloadgdk-pixbuf-85a58dddba28d49332c0cf8679a7f821e81c7c78.tar.gz
a comment asked to optimize this function, so that's what I did.
2001-08-07 Sven Neumann <sven@gimp.org> * gdk-pixbuf.c (gdk_pixbuf_fill): a comment asked to optimize this function, so that's what I did.
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r--gdk-pixbuf/ChangeLog5
-rw-r--r--gdk-pixbuf/gdk-pixbuf.c35
2 files changed, 29 insertions, 11 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog
index ed830a35b..3f0cc9457 100644
--- a/gdk-pixbuf/ChangeLog
+++ b/gdk-pixbuf/ChangeLog
@@ -1,3 +1,8 @@
+2001-08-07 Sven Neumann <sven@gimp.org>
+
+ * gdk-pixbuf.c (gdk_pixbuf_fill): a comment asked to optimize this
+ function, so that's what I did.
+
2001-08-06 Kjartan Maraas <kmaraas@gnome.org>
* gdk-pixdata.c: Fix a typo.
diff --git a/gdk-pixbuf/gdk-pixbuf.c b/gdk-pixbuf/gdk-pixbuf.c
index cfc0bb323..60750f4a0 100644
--- a/gdk-pixbuf/gdk-pixbuf.c
+++ b/gdk-pixbuf/gdk-pixbuf.c
@@ -429,6 +429,9 @@ gdk_pixbuf_fill (GdkPixbuf *pixbuf,
g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
+ if (pixbuf->width == 0 || pixbuf->height == 0)
+ return;
+
pixels = pixbuf->pixels;
r = (pixel & 0xff000000) >> 24;
@@ -448,20 +451,30 @@ gdk_pixbuf_fill (GdkPixbuf *pixbuf,
pixbuf->rowstride * pixbuf->height);
} else {
guchar *p;
- guchar *end;
+ guchar c[4];
+ gint n;
- /* feel free to optimize this */
+ c[0] = r; c[1] = g; c[2] = b; c[3] = a;
p = pixels;
- end = pixels + pixbuf->rowstride * pixbuf->height;
- end -= (pixbuf->rowstride - pixbuf->width * pixbuf->n_channels);
-
- while (p < end) {
- *p++ = r;
- *p++ = g;
- *p++ = b;
- if (pixbuf->has_alpha)
- *p++ = a;
+ n = pixbuf->width;
+ if (pixbuf->has_alpha) {
+ do {
+ memcpy (p, c, 4);
+ p += 4;
+ } while (--n);
+ } else {
+ do {
+ memcpy (p, c, 3);
+ p += 3;
+ } while (--n);
+ }
+
+ p = pixels;
+ n = pixbuf->height - 1;
+ while (n--) {
+ p += pixbuf->rowstride;
+ memcpy (p, pixels, pixbuf->width * pixbuf->n_channels);
}
}
}