Virtualize gdk_window_invalidate_maybe_recurse()
- From: Soeren Sandmann <sandmann daimi au dk>
- To: gtk-devel-list gnome org
- Subject: Virtualize gdk_window_invalidate_maybe_recurse()
- Date: 07 Dec 2001 16:19:28 +0100
Here is a patch that
- changes --gtk-debug=updates, so that the exact invalid
region is filled with red color, not the clipbox of the
invalid region.
- virtualizes gdk_window_invalidate_maybe_recurse()
The last change is to make it possible for a derivation of GdkWindow
to keep track of what region is actually damaged (can't meaningfully
be read from) and what region must merely be redrawn (but the pixels
that were drawn last are still there).
The idea is to make it possible for a widget to reuse some of the old
pixels by using gdk_draw_drawable().
Søren
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.2673
diff -u -r1.2673 ChangeLog
--- ChangeLog 2001/12/07 11:08:07 1.2673
+++ ChangeLog 2001/12/07 15:05:51
@@ -1,3 +1,12 @@
+Fri Dec 7 15:58:08 2001 Soeren Sandmann <sandmann daimi au dk>
+
+ * gdk/gdkwindow.[ch]: virtualize
+ gdk_window_invalidate_maybe_recurse().
+
+ * gdk/gdkwindow.c (gdk_window_real_invalidate_maybe_recurse): When
+ debug_update == TRUE, draw the exact invalid area instead of the
+ clip box.
+
Fri Dec 7 12:07:15 2001 Tim Janik <timj gtk org>
* gtk/Makefile.am: each source generation rule needs to use its own
Index: gdk/gdkwindow.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkwindow.c,v
retrieving revision 1.127
diff -u -r1.127 gdkwindow.c
--- gdk/gdkwindow.c 2001/11/29 23:08:35 1.127
+++ gdk/gdkwindow.c 2001/12/07 15:05:51
@@ -143,6 +143,11 @@
GdkColormap *cmap);
static GdkColormap* gdk_window_real_get_colormap (GdkDrawable *drawable);
+static void gdk_window_real_invalidate_maybe_recurse (GdkWindow *window,
+ GdkRegion *region,
+ gboolean (*child_func) (GdkWindow *, gpointer),
+ gpointer user_data);
+
static GdkDrawable* gdk_window_get_composite_drawable (GdkDrawable *drawable,
gint x,
gint y,
@@ -206,6 +211,7 @@
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass);
+ GdkWindowObjectClass *window_class = GDK_WINDOW_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@@ -232,6 +238,8 @@
drawable_class->get_clip_region = gdk_window_get_clip_region;
drawable_class->get_visible_region = gdk_window_get_visible_region;
drawable_class->get_composite_drawable = gdk_window_get_composite_drawable;
+
+ window_class->invalidate_maybe_recurse = gdk_window_real_invalidate_maybe_recurse;
}
static void
@@ -2151,6 +2159,34 @@
gdk_region_destroy (region);
}
+static void
+draw_ugly_color (GdkWindow *window,
+ GdkRegion *region)
+{
+ /* Draw ugly color all over the newly-invalid region */
+ GdkColor ugly_color = { 0, 50000, 10000, 10000 };
+ GdkGC *ugly_gc;
+ GdkRectangle clipbox;
+
+ ugly_gc = gdk_gc_new (window);
+ gdk_gc_set_rgb_fg_color (ugly_gc, &ugly_color);
+ gdk_gc_set_clip_region (ugly_gc, region);
+
+ gdk_region_get_clipbox (region, &clipbox);
+
+ gdk_draw_rectangle (window,
+ ugly_gc,
+ TRUE,
+ clipbox.x, clipbox.y,
+ clipbox.width, clipbox.height);
+
+ g_object_unref (G_OBJECT (ugly_gc));
+
+ gdk_flush ();
+
+ g_usleep (10000);
+}
+
/**
* gdk_window_invalidate_maybe_recurse:
* @window: a #GdkWindow
@@ -2182,12 +2218,21 @@
gboolean (*child_func) (GdkWindow *, gpointer),
gpointer user_data)
{
- GdkWindowObject *private = (GdkWindowObject *)window;
- GdkRegion *visible_region;
-
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
+ GDK_WINDOW_GET_CLASS (window)->invalidate_maybe_recurse (window, region, child_func, user_data);
+}
+
+static void
+gdk_window_real_invalidate_maybe_recurse (GdkWindow *window,
+ GdkRegion *region,
+ gboolean (*child_func) (GdkWindow *, gpointer),
+ gpointer user_data)
+{
+ GdkWindowObject *private = (GdkWindowObject *)window;
+ GdkRegion *visible_region;
+
if (GDK_WINDOW_DESTROYED (window))
return;
@@ -2200,26 +2245,7 @@
if (!gdk_region_empty (visible_region))
{
if (debug_updates)
- {
- /* Draw ugly color all over the newly-invalid region */
- GdkRectangle ugly_rect;
- GdkGC *ugly_gc;
- GdkColor ugly_color = { 0, 60000, 10000, 10000 };
-
- ugly_gc = gdk_gc_new (window);
-
- gdk_gc_set_rgb_fg_color (ugly_gc, &ugly_color);
-
- gdk_region_get_clipbox (visible_region, &ugly_rect);
-
- gdk_draw_rectangle (window,
- ugly_gc,
- TRUE,
- ugly_rect.x, ugly_rect.y,
- ugly_rect.width, ugly_rect.height);
-
- g_object_unref (G_OBJECT (ugly_gc));
- }
+ draw_ugly_color (window, visible_region);
if (private->update_area)
{
Index: gdk/gdkwindow.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkwindow.h,v
retrieving revision 1.37
diff -u -r1.37 gdkwindow.h
--- gdk/gdkwindow.h 2001/12/06 21:37:50 1.37
+++ gdk/gdkwindow.h 2001/12/07 15:05:51
@@ -3,7 +3,6 @@
#include <gdk/gdkdrawable.h>
#include <gdk/gdktypes.h>
-#include <gdk/gdkwindow.h>
#include <gdk/gdkevents.h>
#ifdef __cplusplus
@@ -266,6 +265,11 @@
struct _GdkWindowObjectClass
{
GdkDrawableClass parent_class;
+
+ void (* invalidate_maybe_recurse) (GdkWindow *window,
+ GdkRegion *region,
+ gboolean (*child_func) (GdkWindow *, gpointer),
+ gpointer user_data);
};
/* Windows
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]