[cairo-commit] cairo-5c ChangeLog, 1.4, 1.5 cairo-5c.h, 1.2, 1.3 gtk.c, 1.1, 1.2 init.c, 1.3, 1.4 surface.c, 1.2, 1.3

Keith Packard commit at pdx.freedesktop.org
Tue Dec 14 23:04:52 PST 2004


Committed by: keithp

Update of /cvs/cairo/cairo-5c
In directory gabe:/tmp/cvs-serv29582

Modified Files:
	ChangeLog cairo-5c.h gtk.c init.c surface.c 
Log Message:
2004-12-14  Keith Packard  <keithp at keithp.com>

	* cairo-5c.h:
	* gtk.c: (gtk_repaint_timeout), (dirty_x), (disable_x), (enable_x):
	* init.c: (nickle_init):
	* surface.c: (enable_cairo_5c), (disable_cairo_5c),
	(do_Cairo_enable), (do_Cairo_disable):
	Add enable/disable to take advantage of double buffering for
	smooth animation.
	
	* examples/animate.5c:
	Use enable/disable to smooth this animation out


Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-5c/ChangeLog,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ChangeLog	14 Dec 2004 08:34:27 -0000	1.4
+++ ChangeLog	15 Dec 2004 07:04:50 -0000	1.5
@@ -1,5 +1,18 @@
 2004-12-14  Keith Packard  <keithp at keithp.com>
 
+	* cairo-5c.h:
+	* gtk.c: (gtk_repaint_timeout), (dirty_x), (disable_x), (enable_x):
+	* init.c: (nickle_init):
+	* surface.c: (enable_cairo_5c), (disable_cairo_5c),
+	(do_Cairo_enable), (do_Cairo_disable):
+	Add enable/disable to take advantage of double buffering for
+	smooth animation.
+	
+	* examples/animate.5c:
+	Use enable/disable to smooth this animation out
+
+2004-12-14  Keith Packard  <keithp at keithp.com>
+
 	* .cvsignore:
 	* Makefile.am:
 	* cairo-5c.h:

Index: cairo-5c.h
===================================================================
RCS file: /cvs/cairo/cairo-5c/cairo-5c.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cairo-5c.h	14 Dec 2004 08:34:27 -0000	1.2
+++ cairo-5c.h	15 Dec 2004 07:04:50 -0000	1.3
@@ -100,6 +100,12 @@
 Value
 do_Cairo_dispose (Value av);
 
+Value
+do_Cairo_enable (Value cv);
+
+Value
+do_Cairo_disable (Value cv);
+
 /* init.c */
 Value
 nickle_init (void);
@@ -224,4 +230,11 @@
 void
 dirty_x (cairo_5c_x_t *c5cx, int x, int y, int w, int h);
 
+Bool
+enable_x  (cairo_5c_x_t *c5cx);
+
+Bool
+disable_x (cairo_5c_x_t *c5cx);
+
+    
 #endif /* _CAIRO_5C_H_ */

Index: gtk.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/gtk.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gtk.c	14 Dec 2004 08:34:27 -0000	1.1
+++ gtk.c	15 Dec 2004 07:04:50 -0000	1.2
@@ -43,6 +43,7 @@
 typedef struct _cairo_5c_gtk {
     cairo_5c_x_t    x;
     int		    dirty;
+    int		    disable;
     GtkWidget	    *window;
     GtkWidget	    *drawing_area;
     GdkPixmap	    *pixmap;
@@ -171,8 +172,11 @@
 {
     cairo_5c_gtk_t  *c5cg = data;
 
-    c5cg->dirty = 0;
-    repaint_x (&c5cg->x, 0, 0, 0, 0);
+    if (c5cg->disable == 0)
+    {
+	c5cg->dirty = 0;
+	repaint_x (&c5cg->x, 0, 0, 0, 0);
+    }
     return FALSE;
 }
 
@@ -214,8 +218,37 @@
     if (!c5cg->dirty)
     {
 	c5cg->dirty = 1;
+	if (c5cg->disable == 0)
+	{
+	    gdk_threads_enter ();
+	    g_timeout_add (16, gtk_repaint_timeout, c5cg);
+	    gdk_threads_leave ();
+	}
+    }
+}
+
+Bool
+disable_x (cairo_5c_x_t *c5cx)
+{
+    cairo_5c_gtk_t  *c5cg = (cairo_5c_gtk_t *) c5cx;
+
+    ++c5cg->disable;
+    return True;
+}
+
+Bool
+enable_x  (cairo_5c_x_t *c5cx)
+{
+    cairo_5c_gtk_t  *c5cg = (cairo_5c_gtk_t *) c5cx;
+
+    if (!c5cg->disable)
+	return False;
+    --c5cg->disable;
+    if (!c5cg->disable && c5cg->dirty)
+    {
 	gdk_threads_enter ();
-	g_timeout_add (16, gtk_repaint_timeout, c5cg);
+	g_timeout_add (0, gtk_repaint_timeout, c5cg);
 	gdk_threads_leave ();
     }
+    return True;
 }

Index: init.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/init.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- init.c	14 Dec 2004 08:34:27 -0000	1.3
+++ init.c	15 Dec 2004 07:04:50 -0000	1.4
@@ -71,6 +71,14 @@
 	    " void dispose (foreign cairo)\n"
 	    "\n"
 	    " Dispose a cairo surface\n" },
+	{ do_Cairo_enable, "enable", "v", "F", "\n"
+	    " void enable (foreign cairo)\n"
+	    "\n"
+	    " Enable screen updates from a cairo surface\n" },
+	{ do_Cairo_disable, "disable", "v", "F", "\n"
+	    " void disable (foreign cairo)\n"
+	    "\n"
+	    " Disable screen updates from a cairo surface\n" },
 	{ do_Cairo_save, "save", "v", "F", "\n"
 	    " void save (foreign cairo)\n"
 	    "\n"

Index: surface.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/surface.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- surface.c	14 Dec 2004 08:34:27 -0000	1.2
+++ surface.c	15 Dec 2004 07:04:50 -0000	1.3
@@ -104,6 +104,30 @@
     }
 }
 
+static Bool
+enable_cairo_5c (cairo_5c_t *c5c)
+{
+    switch (c5c->kind) {
+    case CAIRO_5C_WINDOW:
+	return enable_x (c5c->u.window.x);
+    case CAIRO_5C_PNG:
+	break;
+    }
+    return True;
+}
+
+static Bool
+disable_cairo_5c (cairo_5c_t *c5c)
+{
+    switch (c5c->kind) {
+    case CAIRO_5C_WINDOW:
+	return disable_x (c5c->u.window.x);
+    case CAIRO_5C_PNG:
+	break;
+    }
+    return True;
+}
+
 Value
 do_Cairo_new (int n, Value *v)
 {
@@ -254,3 +278,35 @@
     }
     RETURN (Void);
 }
+
+Value
+do_Cairo_enable (Value cv)
+{
+    cairo_5c_t	*c5c = get_cairo_5c (cv);
+    
+    if (aborting)
+	return Void;
+    if (!enable_cairo_5c (c5c))
+    {
+	RaiseStandardException (exception_invalid_argument,
+				"already enabled",
+				2, NewInt(0), cv);
+    }
+    return Void;
+}
+
+Value
+do_Cairo_disable (Value cv)
+{
+    cairo_5c_t	*c5c = get_cairo_5c (cv);
+    
+    if (aborting)
+	return Void;
+    if (!disable_cairo_5c (c5c))
+    {
+	RaiseStandardException (exception_invalid_argument,
+				"can't disable",
+				2, NewInt(0), cv);
+    }
+    return Void;
+}




More information about the cairo-commit mailing list