background pixmap as buffer



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Ok. The following patch will make gtk use the background pixmap as a buffer.
The result is pretty good. Try the patch, and then try shading/unshading one
window over another. The update "appears" to be really fast (no update
happens).

I have placed the back buffer resize the event handling of gdkevents-x11. But
it seems alot of resize pass gdk_event_translate, but not all result in a
window redraw. Is there some place where a resize event does always result in
a repaint ?

- - Argh. Dunno what's wrong with me today -
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+clnbw4uuzvY55gsRAnCRAJ9LFxzsq/J8xwv9cW30K+AKE8dkdgCg6FvT
MHciN9b/alId0oE3NeyDwNI=
=RolT
-----END PGP SIGNATURE-----
Index: gdk/gdkwindow.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkwindow.c,v
retrieving revision 1.146
diff -u -r1.146 gdkwindow.c
--- gdk/gdkwindow.c	28 Nov 2002 00:33:03 -0000	1.146
+++ gdk/gdkwindow.c	14 Mar 2003 22:26:37 -0000
@@ -1094,11 +1094,22 @@
   gdk_gc_set_clip_region (tmp_gc, paint->region);
   gdk_gc_set_clip_origin (tmp_gc, -x_offset, -y_offset);
 
-  gdk_draw_drawable (private->impl, tmp_gc, paint->pixmap,
+/*  gdk_draw_drawable (private->impl, tmp_gc, paint->pixmap,
                      clip_box.x - paint->x_offset,
                      clip_box.y - paint->y_offset,
                      clip_box.x - x_offset, clip_box.y - y_offset,
-                     clip_box.width, clip_box.height);
+                     clip_box.width, clip_box.height); 
+  
+  printf("Drawing to back pixmap\n"); */
+  
+  gdk_draw_drawable (private->save_under_pixmap, tmp_gc, paint->pixmap,
+                     clip_box.x - paint->x_offset,
+                     clip_box.y - paint->y_offset,
+                     clip_box.x - x_offset, clip_box.y - y_offset,
+                     clip_box.width, clip_box.height); 
+
+  gdk_window_clear(window); 
+  
   g_object_unref (tmp_gc);
 
   if (private->paint_stack)
Index: gdk/gdkwindow.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkwindow.h,v
retrieving revision 1.45
diff -u -r1.45 gdkwindow.h
--- gdk/gdkwindow.h	17 Nov 2002 22:03:47 -0000	1.45
+++ gdk/gdkwindow.h	14 Mar 2003 22:26:38 -0000
@@ -243,6 +243,8 @@
 
   GdkColor bg_color;
   GdkPixmap *bg_pixmap;
+
+  GdkPixmap *save_under_pixmap;
   
   GSList *paint_stack;
   
Index: gdk/x11/gdkevents-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkevents-x11.c,v
retrieving revision 1.108
diff -u -r1.108 gdkevents-x11.c
--- gdk/x11/gdkevents-x11.c	8 Mar 2003 21:11:38 -0000	1.108
+++ gdk/x11/gdkevents-x11.c	14 Mar 2003 22:26:39 -0000
@@ -1585,6 +1585,26 @@
 	return_val = FALSE;
       else
 	{
+    
+	  GdkPixmapImplX11 *pix_impl = GDK_PIXMAP_IMPL_X11 (GDK_PIXMAP_OBJECT (window_private->save_under_pixmap)->impl);
+
+	  if((pix_impl->width != xevent->xconfigure.width || 
+	  	pix_impl->height != xevent->xconfigure.height) &&
+		window_private->save_under_pixmap != NULL) 
+	    {
+	      g_object_unref(window_private->save_under_pixmap);
+
+              window_private->save_under_pixmap = gdk_pixmap_new (window, 
+					xevent->xconfigure.width, 
+	  				xevent->xconfigure.height, -1);
+
+	      if (window_private->save_under_pixmap != NULL) 
+                XSetWindowBackgroundPixmap (GDK_DRAWABLE_XDISPLAY (window), 
+		    			    GDK_DRAWABLE_XID (window),	
+			                    GDK_PIXMAP_XID (window_private->save_under_pixmap));
+	    } 
+
+
 	  event->configure.type = GDK_CONFIGURE;
 	  event->configure.window = window;
 	  event->configure.width = xevent->xconfigure.width;
Index: gdk/x11/gdkwindow-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkwindow-x11.c,v
retrieving revision 1.183
diff -u -r1.183 gdkwindow-x11.c
--- gdk/x11/gdkwindow-x11.c	6 Mar 2003 20:19:10 -0000	1.183
+++ gdk/x11/gdkwindow-x11.c	14 Mar 2003 22:26:43 -0000
@@ -609,6 +609,16 @@
 				  (attributes->cursor) :
 				  NULL));
   
+  if (attributes->wclass == GDK_INPUT_OUTPUT) 
+    {
+      private->save_under_pixmap = gdk_pixmap_new (window, 
+	  impl->position_info.width, 
+	  impl->position_info.height, -1);
+
+      if (private->save_under_pixmap != NULL) 
+        XSetWindowBackgroundPixmap (xdisplay, xid, GDK_PIXMAP_XID(private->save_under_pixmap));
+    } 
+
   if (private->parent)
     private->parent->children = g_list_prepend (private->parent->children, window);
   
@@ -918,6 +928,7 @@
 void
 gdk_window_destroy_notify (GdkWindow *window)
 {
+  GdkWindowObject *private = (GdkWindowObject *)window; 	
   GdkWindowImplX11 *window_impl;
 
   g_return_if_fail (window != NULL);
@@ -937,7 +948,10 @@
     _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), window_impl->focus_window);
 
   _gdk_xgrab_check_destroy (window);
-  
+
+  if (private->save_under_pixmap != NULL) 
+    g_object_unref (private->save_under_pixmap); 	
+
   g_object_unref (window);
 }
 
@@ -2258,11 +2272,13 @@
   
   g_return_if_fail (window != NULL);
   g_return_if_fail (GDK_IS_WINDOW (window));
-  
+ 
+/*
   if (!GDK_WINDOW_DESTROYED (window))
     XSetWindowBackground (GDK_WINDOW_XDISPLAY (window),
 			  GDK_WINDOW_XID (window), color->pixel);
-
+*/
+  
   private->bg_color = *color;
 
   if (private->bg_pixmap &&
@@ -2335,9 +2351,11 @@
 	}
     }
   
+/*
   if (!GDK_WINDOW_DESTROYED (window))
     XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
 				GDK_WINDOW_XID (window), xpixmap);
+*/				
 }
 
 /**


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