PATCH: gtk_image_expose()

Hello, all.

I've been trying to learn GTK, and while I was playing with GtkImages I
shuffled through the source trying to learn how GTK and GDK interact.
Anyway, I noticed that updating very small areas GtkImages with
gtk_widget_draw was rather slow, when compared to straight GDK stuff. This
was because gtk_image_expose() always updated the _entire_ image, for some
reason. Below is a patch that fixes this. My experimental
update-a-row-at-a-time -Mandelbrot program ran ca. 6 times faster after

Note that this version still updates the image entirely, when given a
bogus area, as happens after gtk_widget_init, when widget->allocation has
strange values (-1,-1,1,1). I thought that in such a case there shouldn't
really be any updating, but I wasn't sure, since the image is, in theory,
ready, and I didn't want to break anything... please tell me if everything
can be bypassed in such a case.

Lauri Alanko 

Here's the patch:

--- gtkimage.c.orig	Fri Jul 25 01:45:54 1997
+++ gtkimage.c	Fri Jul 25 01:53:25 1997
@@ -129,6 +129,7 @@
   GtkImage *image;
   GtkMisc *misc;
+  GdkRectangle area;
   gint x, y;
   g_return_val_if_fail (widget != NULL, FALSE);
@@ -155,11 +156,18 @@
 	  gdk_gc_set_clip_origin (widget->style->black_gc, x, y);
+      area=event->area;
+      if(area.x<0 || area.y<0)
+	{
+	      area.x=area.y=0;
+	      area.width=image->image->width;
+	      area.height=image->image->height;
+	}
       gdk_draw_image (widget->window,
-		      image->image, 0, 0, x, y,
-		      image->image->width,
-		      image->image->height);
+		      image->image, area.x, area.y, x+area.x, y+area.y,
+		      area.width,
+		      area.height);
       if (image->mask)

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