[518] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

[gtk-list] PATCH: gtk_image_expose()

daemon@ATHENA.MIT.EDU (Lauri Alanko)
Thu Jul 24 19:53:57 1997

Date: Fri, 25 Jul 1997 02:48:46 +0300 (EEST)
From: Lauri Alanko <la@iki.fi>
Reply-To: Lauri Alanko <la@iki.fi>
To: gtk-list@redhat.com
Resent-From: gtk-list@redhat.com


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
this.

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
la@iki.fi 



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,
 		      widget->style->black_gc,
-		      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)
 	{



--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post