[cairo-commit] cairo-5c ChangeLog, 1.19, 1.20 cairo-5c.h, 1.12, 1.13 cairo.5c, 1.9, 1.10 cairo.c, 1.3, 1.4 event.c, 1.3, 1.4 gstate.c, 1.7, 1.8 gtk.c, 1.7, 1.8 init.c, 1.12, 1.13 matrix.c, 1.2, 1.3 pattern.c, 1.4, 1.5 surface.c, 1.10, 1.11 text.c, 1.6, 1.7

Keith Packard commit at pdx.freedesktop.org
Mon May 2 13:24:41 PDT 2005


Committed by: keithp

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

Modified Files:
	ChangeLog cairo-5c.h cairo.5c cairo.c event.c gstate.c gtk.c 
	init.c matrix.c pattern.c surface.c text.c 
Log Message:
2005-05-02  Keith Packard  <keithp at keithp.com>

	* cairo-5c.h:
	* cairo.5c:
	* cairo.c: (cairo_5c_dirty), (cairo_5c_enable), (cairo_5c_disable),
	(do_Cairo_get_target_surface):
	* event.c: (do_Cairo_Surface_open_event):
	* gstate.c: (do_Cairo_set_source_rgb), (do_Cairo_set_source_rgba),
	(do_Cairo_get_matrix), (do_Cairo_concat_matrix),
	(do_Cairo_set_matrix), (do_Cairo_get_operator),
	(do_Cairo_get_tolerance), (do_Cairo_get_current_point),
	(do_Cairo_get_fill_rule), (do_Cairo_get_line_width),
	(do_Cairo_get_line_cap), (do_Cairo_get_line_join),
	(do_Cairo_get_miter_limit):
	* gtk.c: (delete_drawing_area), (motion_notify_event),
	(button_press_event), (button_release_event),
	(gtk_repaint_timeout), (gtk_thread_main), (gtk_global_free),
	(create_gtk_global), (cairo_5c_tool_dirty), (cairo_5c_tool_enable):
	* init.c: (init_types), (nickle_init):
	* matrix.c: (cairo_matrix_part), (new_cairo_matrix):
	* pattern.c: (do_Cairo_set_source), (do_Cairo_get_source),
	(do_Cairo_Pattern_set_matrix), (do_Cairo_Pattern_get_matrix):
	* surface.c: (cairo_5c_surface_get), (cairo_5c_surface_mark),
	(cairo_5c_surface_destroy), (do_Cairo_Surface_create_image),
	(do_Cairo_Surface_write_to_png):
	* text.c: (do_Cairo_set_font), (do_Cairo_set_font_size),
	(do_Cairo_set_font_matrix), (do_Cairo_font_extents):
	Match cairo API as of today.

	* examples/draw.5c:
	* examples/fob.5c:
	* examples/graph.5c:
	* examples/grid.5c:
	* examples/led.5c:
	* examples/pie-new.5c:
	* examples/pie.5c:
	* examples/rottext.5c:
	* examples/sin.5c:
	* examples/spin-cairo.5c:
	* examples/spin.5c:
	* examples/spinman.5c:
	* examples/test.5c:
	* examples/text45.5c:
	Update examples to match API changes


Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-5c/ChangeLog,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- ChangeLog	14 Mar 2005 21:52:22 -0000	1.19
+++ ChangeLog	2 May 2005 20:24:38 -0000	1.20
@@ -1,3 +1,48 @@
+2005-05-02  Keith Packard  <keithp at keithp.com>
+
+	* cairo-5c.h:
+	* cairo.5c:
+	* cairo.c: (cairo_5c_dirty), (cairo_5c_enable), (cairo_5c_disable),
+	(do_Cairo_get_target_surface):
+	* event.c: (do_Cairo_Surface_open_event):
+	* gstate.c: (do_Cairo_set_source_rgb), (do_Cairo_set_source_rgba),
+	(do_Cairo_get_matrix), (do_Cairo_concat_matrix),
+	(do_Cairo_set_matrix), (do_Cairo_get_operator),
+	(do_Cairo_get_tolerance), (do_Cairo_get_current_point),
+	(do_Cairo_get_fill_rule), (do_Cairo_get_line_width),
+	(do_Cairo_get_line_cap), (do_Cairo_get_line_join),
+	(do_Cairo_get_miter_limit):
+	* gtk.c: (delete_drawing_area), (motion_notify_event),
+	(button_press_event), (button_release_event),
+	(gtk_repaint_timeout), (gtk_thread_main), (gtk_global_free),
+	(create_gtk_global), (cairo_5c_tool_dirty), (cairo_5c_tool_enable):
+	* init.c: (init_types), (nickle_init):
+	* matrix.c: (cairo_matrix_part), (new_cairo_matrix):
+	* pattern.c: (do_Cairo_set_source), (do_Cairo_get_source),
+	(do_Cairo_Pattern_set_matrix), (do_Cairo_Pattern_get_matrix):
+	* surface.c: (cairo_5c_surface_get), (cairo_5c_surface_mark),
+	(cairo_5c_surface_destroy), (do_Cairo_Surface_create_image),
+	(do_Cairo_Surface_write_to_png):
+	* text.c: (do_Cairo_set_font), (do_Cairo_set_font_size),
+	(do_Cairo_set_font_matrix), (do_Cairo_font_extents):
+	Match cairo API as of today.
+
+	* examples/draw.5c:
+	* examples/fob.5c:
+	* examples/graph.5c:
+	* examples/grid.5c:
+	* examples/led.5c:
+	* examples/pie-new.5c:
+	* examples/pie.5c:
+	* examples/rottext.5c:
+	* examples/sin.5c:
+	* examples/spin-cairo.5c:
+	* examples/spin.5c:
+	* examples/spinman.5c:
+	* examples/test.5c:
+	* examples/text45.5c:
+	Update examples to match API changes
+
 2005-03-14  Keith Packard  <keithp at keithp.com>
 
 	* examples/animate.5c:

Index: cairo-5c.h
===================================================================
RCS file: /cvs/cairo/cairo-5c/cairo-5c.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cairo-5c.h	14 Mar 2005 21:43:06 -0000	1.12
+++ cairo-5c.h	2 May 2005 20:24:38 -0000	1.13
@@ -49,7 +49,7 @@
 #include <unistd.h>
 #undef Atom
 
-typedef enum { CAIRO_5C_WINDOW, CAIRO_5C_PNG, CAIRO_5C_PS, CAIRO_5C_SCRATCH } cairo_5c_kind_t;
+typedef enum { CAIRO_5C_WINDOW, CAIRO_5C_IMAGE, CAIRO_5C_PS, CAIRO_5C_SCRATCH } cairo_5c_kind_t;
 
 typedef struct _cairo_5c_tool	cairo_5c_tool_t;
 
@@ -60,10 +60,6 @@
     FILE	    *send_events;
 } cairo_5c_window_t;
 
-typedef struct _cairo_png_t {
-    FILE	*file;
-} cairo_5c_png_t;
-
 typedef struct _cairo_ps_t {
     FILE	*file;
 } cairo_5c_ps_t;
@@ -85,7 +81,6 @@
     Bool	    copied;
     union {
 	cairo_5c_window_t   window;
-	cairo_5c_png_t	    png;
 	cairo_5c_ps_t	    ps;
     } u;
 } cairo_5c_surface_t;
@@ -105,6 +100,7 @@
 extern Type		*typeCairoPoint;
 extern Type		*typeCairoRect;
 extern Type		*typeCairoRgbColor;
+extern Type		*typeCairoRgbaColor;
 extern Type		*typeCairoPattern;
 extern Type		*typeCairoPath;
 extern Type		*typeCairoMoveTo;
@@ -134,7 +130,7 @@
 do_Cairo_set_target_surface (Value cv, Value sv);
     
 Value
-do_Cairo_current_target_surface (Value cv);
+do_Cairo_get_target_surface (Value cv);
     
 Value
 do_Cairo_copy (Value dstv, Value srcv);
@@ -160,7 +156,10 @@
 do_Cairo_Surface_create_window (Value namev, Value wv, Value hv);
 
 Value
-do_Cairo_Surface_create_png (Value fv, Value wv, Value hv);
+do_Cairo_Surface_create_image (Value wv, Value hv);
+
+Value
+do_Cairo_Surface_write_to_png (Value sv, Value fv);
 
 Value
 do_Cairo_Surface_create_ps (Value fv, Value wv, Value hv, Value xppiv, Value yppiv);
@@ -209,10 +208,10 @@
 do_Cairo_identity_matrix (Value cv);
 
 Value
-do_Cairo_set_rgb_color (Value av, Value rv, Value gv, Value bv);
+do_Cairo_set_source_rgb (Value cv, Value rv, Value gv, Value bv);
 
 Value
-do_Cairo_set_alpha (Value cv, Value av);
+do_Cairo_set_source_rgba (Value cv, Value rv, Value gv, Value bv, Value av);
 
 Value
 do_Cairo_set_tolerance (Value cv, Value tv);
@@ -245,7 +244,7 @@
 do_Cairo_rotate (Value cv, Value av);
 
 Value
-do_Cairo_current_matrix (Value cv);
+do_Cairo_get_matrix (Value cv);
 
 Value
 do_Cairo_concat_matrix (Value cv, Value mv);
@@ -272,34 +271,28 @@
 do_Cairo_clip (Value cv);
 
 Value
-do_Cairo_current_operator (Value cv);
-
-Value
-do_Cairo_current_rgb_color (Value cv);
-
-Value
-do_Cairo_current_alpha (Value cv);
+do_Cairo_get_operator (Value cv);
 
 Value
-do_Cairo_current_tolerance (Value cv);
+do_Cairo_get_tolerance (Value cv);
 
 Value
-do_Cairo_current_point (Value cv);
+do_Cairo_get_current_point (Value cv);
 
 Value
-do_Cairo_current_fill_rule (Value cv);
+do_Cairo_get_fill_rule (Value cv);
 
 Value
-do_Cairo_current_line_width (Value cv);
+do_Cairo_get_line_width (Value cv);
 
 Value
-do_Cairo_current_line_cap (Value cv);
+do_Cairo_get_line_cap (Value cv);
 
 Value
-do_Cairo_current_line_join (Value cv);
+do_Cairo_get_line_join (Value cv);
 
 Value
-do_Cairo_current_miter_limit (Value cv);
+do_Cairo_get_miter_limit (Value cv);
 
 /* draw.c */
 Value
@@ -378,8 +371,8 @@
 do_Cairo_current_path_flat_list (Value cv);
 
 /* matrix.c */
-cairo_matrix_t *
-cairo_matrix_part (Value matrixv, char *err);
+void
+cairo_matrix_part (Value matrixv, cairo_matrix_t *matrix, char *err);
 
 Value
 new_cairo_matrix (cairo_matrix_t *matrix);
@@ -389,10 +382,10 @@
 get_cairo_pattern (Value pv);
     
 Value
-do_Cairo_current_pattern (Value cv);
+do_Cairo_get_source (Value cv);
 
 Value
-do_Cairo_set_pattern (Value cv, Value patv);
+do_Cairo_set_source (Value cv, Value patv);
 
 Value
 do_Cairo_Pattern_create_png (Value filenamev);
@@ -438,13 +431,13 @@
 do_Cairo_set_font (Value cv, Value fv);
 
 Value
-do_Cairo_scale_font (Value cv, Value sv);
+do_Cairo_set_font_size (Value cv, Value sv);
 
 Value
-do_Cairo_transform_font (Value cv, Value mv);
+do_Cairo_set_font_matrix (Value cv, Value mv);
 
 Value
-do_Cairo_current_font_extents (Value cv);
+do_Cairo_font_extents (Value cv);
 
 Value
 do_Cairo_show_text (Value cv, Value uv);

Index: cairo.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/cairo.5c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- cairo.5c	11 Feb 2005 21:15:46 -0000	1.9
+++ cairo.5c	2 May 2005 20:24:38 -0000	1.10
@@ -47,13 +47,13 @@
     } hsv_color_t;
     
     public int width (cairo_t cr) = 
-	Surface::width (current_target_surface (cr));
+	Surface::width (get_target_surface (cr));
     
     public int height (cairo_t cr) = 
-	Surface::height (current_target_surface (cr));
+	Surface::height (get_target_surface (cr));
     
     public file open_event (cairo_t cr) =
-	Surface::open_event (current_target_surface (cr));
+	Surface::open_event (get_target_surface (cr));
 
     public cairo_t new (int args...) {
 	int w = dim(args) > 0 ? args[0] : 0;
@@ -82,7 +82,7 @@
 		    string name = (dim (argv) > 0) ? argv[0] : "nickle";
 		    surface.surface = Surface::create_window (name, w, h);
 		    set_target_surface (cr, surface.surface);
-		    set_rgb_color (cr, 1, 1, 1);
+		    set_source_rgba (cr, 1, 1, 1, 1);
 		    rectangle (cr, 0, 0, Cairo::width (cr), Cairo::height (cr));
 		    fill (cr);
 		    break;
@@ -100,7 +100,7 @@
 	    surface = surface_or_none_t.none;
 	    ensure_surface ();
 	}
-	set_rgb_color (cr, 0, 0, 0);
+	set_source_rgba (cr, 0, 0, 0, 1);
 	return cr;
     }
 
@@ -111,29 +111,33 @@
 	cairo_t	    cr = create ();
 	
 	set_target_surface (cr, surface);
-	set_rgb_color (cr, 1, 1, 1);
+	set_source_rgba (cr, 1, 1, 1, 1);
 	rectangle (cr, 0, 0, Cairo::width (cr), Cairo::height (cr));
 	fill (cr);
-	set_rgb_color (cr, 0, 0, 0);
+	set_source_rgba (cr, 0, 0, 0, 1);
 	return cr;
     }
 
-    public cairo_t new_png (string filename, int width, int height)
+    public cairo_t new_image (int width, int height)
     {
-	surface_t   surface = Surface::create_png (filename, width, height);
+	surface_t   surface = Surface::create_image (width, height);
 	cairo_t	    cr = create ();
 	set_target_surface (cr, surface);
-	set_rgb_color (cr, 0, 0, 0);
-	set_alpha (cr, 0);
+	set_source_rgba (cr, 0, 0, 0, 0);
 	set_operator (cr, operator_t.SRC);
 	rectangle (cr, 0, 0, Cairo::width (cr), Cairo::height (cr));
 	fill (cr);
 	set_operator (cr, operator_t.OVER);
-	set_rgb_color (cr, 0, 0, 0);
-	set_alpha (cr, 1);
+	set_source_rgba (cr, 0, 0, 0, 1);
 	return cr;
     }
     
+    public void write_to_png (cairo_t cr, string filename)
+    {
+	surface_t   surface = get_target_surface (cr);
+	Surface::write_to_png (surface, filename);
+    }
+    
     public cairo_t new_ps (string filename, 
 			   real width, real height,
 			   real xppi, real yppi)
@@ -142,10 +146,10 @@
 						  xppi, yppi);
 	cairo_t	    cr = create ();
 	set_target_surface (cr, surface);
-	set_rgb_color (cr, 1, 1, 1);
+	set_source_rgba (cr, 1, 1, 1, 1);
 	rectangle (cr, 0, 0, Cairo::width (cr), Cairo::height (cr));
 	fill (cr);
-	set_rgb_color (cr, 0, 0, 0);
+	set_source_rgba (cr, 0, 0, 0, 1);
 	return cr;
     }
     
@@ -153,7 +157,7 @@
     {
 	cairo_t	n = create ();
 
-	set_target_surface (n, current_target_surface (cr));
+	set_target_surface (n, get_target_surface (cr));
 	copy (n, cr);
 	return n;
     }
@@ -267,7 +271,7 @@
 	}
     }
 
-    public void set_hsv_color (cairo_t cr, real h, real s, real v)
+    public void set_source_hsv (cairo_t cr, real h, real s, real v)
 	/*
 	 * Set color using HSV specification
 	 *  H: hue	    0 = red, 0.{3} = green, 0.{6} = blue
@@ -275,36 +279,25 @@
 	 *  V: value	    0..1
 	 */
     {
-	set_rgb_color (cr, from_hsv (h, s, v) ...);
-    }
-
-    public hsv_color_t current_hsv_color (cairo_t cr)
-	/*
-	 * Return current color using HSV specification
-	 *
-	 *  H: hue	    0 = red, 0.{3} = green, 0.{6} = blue
-	 *  S: satuation    0..1
-	 *  V: value	    0..1
-	 */
-    {
-	rgb_color_t rgb = current_rgb_color (cr);
-	real[3]	    t = to_hsv (rgb.red, rgb.green, rgb.blue);
-	return (hsv_color_t) { 
-	    hue = t[0],
-	    saturation = t[1],
-	    value = t[2]
-	};
+	set_source_rgb (cr, from_hsv (h, s, v) ...);
     }
 
     public namespace Matrix {
 	matrix_t multiply_scalar (matrix_t a, real scalar) = 
-	    (matrix_t) { [row,col] = a[row,col] * scalar };
+	    (matrix_t) { 
+		xx = a.xx * scalar, yx = a.yx * scalar,
+		xy = a.xy * scalar, yy = a.yy * scalar,
+		x0 = a.x0 * scalar, y0 = a.y0 * scalar };
+		
 
 	public matrix_t identity () =
-	    (matrix_t) { [row,col] = row == col ? 1 : 0 };
+	    (matrix_t) { 
+		xx = 1, yx = 0,
+		xy = 0, yy = 1,
+		x0 = 0, y0 = 0 };
 
 	public real determinant (matrix_t m) = 
-	    m[0,0] * m[1,1] - m[0,1] * m[1,0];
+	    m.xx * m.yy - m.yx * m.xy;
 	
 	/* This function isn't a correct adjoint in that the implicit 1 in the
 	 homogeneous result should actually be ad-bc instead. But, since this
@@ -312,47 +305,52 @@
 	 divides by det (A)=ad-bc anyway, everything works out in the end. */
 	matrix_t adjoint (matrix_t m) = 
 	    (matrix_t) {
-		{    m[1,1], -m[0,1] },
-		{   -m[1,0],  m[0,0] },
-		{    m[1,0] * m[2,1] - m[1,1] * m[2,0], 
-		     m[0,1] * m[2,0] - m[0,0] * m[2,1] }};
+		xx = m.yy,  yx = -m.xy,
+		xy = -m.yx, yy = m.xx,
+		x0 = m.yx * m.y0 - m.yy * m.x0,
+		y0 = m.xy * m.x0 - m.xx * m.y0 };
 	
 	/* inv (A) = 1/det (A) * adj (A) */
 	public matrix_t invert (matrix_t a) =
 	    multiply_scalar (adjoint (a), 1 / determinant (a));
 
 	public matrix_t multiply (matrix_t a, matrix_t b) =
-	    (matrix_t) { [row,col] { 
-		real t = 0;
-		if (row == 2)
-		    t = b[2,col];
-		for (int n = 0; n < 2; n++)
-		    t += a[row,n] * b[n,col];
-		return t;
-	    }};
+	    (matrix_t) {
+		xx = a.xx * b.xx + a.yx * b.xy,
+		yx = a.xx * b.yx + a.yx * b.yy,
+		xy = a.xy * b.xx + a.yy * b.xy,
+		yy = a.xy * b.yx + a.yy * b.yy,
+		x0 = a.x0 * b.xx + a.y0 * b.xy + b.x0,
+		y0 = a.x0 * b.yx + a.y0 * b.yy + b.y0 };
 
 	public matrix_t translate (matrix_t m, real tx, real ty) =
-	    multiply ((matrix_t) { { 1, 0 }, { 0, 1 }, { tx, ty } }, m);
+	    multiply ((matrix_t) { 
+		xx = 1,  yx = 0,
+		xy = 0,  yy = 1,
+		x0 = tx, y0 = ty }, m);
 	
 	public matrix_t scale (matrix_t m, real sx, real sy) =
-	    multiply ((matrix_t) { { sx, 0 }, { 0, sy }, { 0, 0 } }, m);
+	    multiply ((matrix_t) { 
+		xx = sx, yx =  0,
+		xy =  0, yy = sy,
+		x0 =  0, y0 =  0 }, m);
 	
 	public matrix_t rotate (matrix_t m, real a) =
 	    multiply ((matrix_t) { 
-		{  (real c = cos(a)), (real s = sin(a)) },
-		{      -s,                c },
-		{       0,                0 } }, m);
+		xx = (real c = cos(a)), yx = (real s = sin(a)),
+		xy = -s,                yy = c,
+		x0 = 0,                 y0 = 0 }, m);
 
 	public point_t point (matrix_t m, point_t p) =
 	    (point_t) { 
-		x = m[0,0] * p.x + m[1,0] * p.y + m[2,0],
-		y = m[0,1] * p.x + m[1,1] * p.y + m[2,1]
+		x = m.xx * p.x + m.yx * p.y + m.x0,
+		y = m.xy * p.x + m.yy * p.y + m.y0
 	    };
 	
 	public point_t distance (matrix_t m, point_t p) =
 	    (point_t) { 
-		x = m[0,0] * p.x + m[1,0] * p.y,
-		y = m[0,1] * p.x + m[1,1] * p.y
+		x = m.xx * p.x + m.yx * p.y,
+		y = m.xy * p.x + m.yy * p.y
 	    };
 	
      }	

Index: cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/cairo.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cairo.c	11 Feb 2005 21:15:46 -0000	1.3
+++ cairo.c	2 May 2005 20:24:38 -0000	1.4
@@ -155,7 +155,7 @@
 	    case CAIRO_5C_WINDOW:
 		cairo_5c_tool_dirty (c5s);
 		break;
-	    case CAIRO_5C_PNG:
+	    case CAIRO_5C_IMAGE:
 	    case CAIRO_5C_PS:
 	    case CAIRO_5C_SCRATCH:
 		break;
@@ -177,7 +177,7 @@
 	    case CAIRO_5C_WINDOW:
 		cairo_5c_tool_enable (c5s);
 		break;
-	    case CAIRO_5C_PNG:
+	    case CAIRO_5C_IMAGE:
 	    case CAIRO_5C_PS:
 	    case CAIRO_5C_SCRATCH:
 		break;
@@ -200,7 +200,7 @@
 	    case CAIRO_5C_WINDOW:
 		cairo_5c_tool_disable (c5s);
 		break;
-	    case CAIRO_5C_PNG:
+	    case CAIRO_5C_IMAGE:
 	    case CAIRO_5C_PS:
 	    case CAIRO_5C_SCRATCH:
 		break;
@@ -225,7 +225,7 @@
 }
 
 Value
-do_Cairo_current_target_surface (Value cv)
+do_Cairo_get_target_surface (Value cv)
 {
     ENTER ();
     cairo_5c_t		*c5c = cairo_5c_get (cv);

Index: event.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/event.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- event.c	11 Feb 2005 21:15:46 -0000	1.3
+++ event.c	2 May 2005 20:24:38 -0000	1.4
@@ -67,7 +67,7 @@
 	    write = fdopen (fd[1], "w");
 	    c5s->u.window.send_events = write;
 	    break;
-	case CAIRO_5C_PNG:
+	case CAIRO_5C_IMAGE:
 	case CAIRO_5C_PS:
 	case CAIRO_5C_SCRATCH:
 	    read = FileFopen ("/dev/null", "r", &err);

Index: gstate.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/gstate.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- gstate.c	11 Feb 2005 21:15:46 -0000	1.7
+++ gstate.c	2 May 2005 20:24:38 -0000	1.8
@@ -65,7 +65,7 @@
 }
 
 Value
-do_Cairo_set_rgb_color (Value cv, Value rv, Value gv, Value bv)
+do_Cairo_set_source_rgb (Value cv, Value rv, Value gv, Value bv)
 {
     cairo_5c_t	*c5c = cairo_5c_get (cv);
     double	r = DoublePart (rv, "invalid red value");
@@ -73,18 +73,21 @@
     double	b = DoublePart (bv, "invalid blue value");
     
     if (!aborting)
-	cairo_set_rgb_color (c5c->cr, r, g, b);
+	cairo_set_source_rgb (c5c->cr, r, g, b);
     return Void;
 }
 
 Value
-do_Cairo_set_alpha (Value cv, Value av)
+do_Cairo_set_source_rgba (Value cv, Value rv, Value gv, Value bv, Value av)
 {
     cairo_5c_t	*c5c = cairo_5c_get (cv);
+    double	r = DoublePart (rv, "invalid red value");
+    double	g = DoublePart (gv, "invalid green value");
+    double	b = DoublePart (bv, "invalid blue value");
     double	a = DoublePart (av, "invalid alpha value");
-
+    
     if (!aborting)
-	cairo_set_alpha (c5c->cr, a);
+	cairo_set_source_rgba (c5c->cr, r, g, b, a);
     return Void;
 }
 
@@ -232,28 +235,18 @@
 }
 
 Value
-do_Cairo_current_matrix (Value cv)
+do_Cairo_get_matrix (Value cv)
 {
     ENTER ();
     cairo_5c_t	    *c5c = cairo_5c_get (cv);
-    cairo_matrix_t  *matrix;
+    cairo_matrix_t  matrix;
     Value	    ret;
 
     if (aborting)
 	RETURN(Void);
     
-    matrix = cairo_matrix_create ();
-
-    if (!matrix)
-    {
-	RaiseStandardException (exception_invalid_argument,
-				"can't create matrix",
-				2, cv, Void);
-	RETURN(Void);
-    }
-    cairo_current_matrix (c5c->cr, matrix);
-    ret = new_cairo_matrix (matrix);
-    cairo_matrix_destroy (matrix);
+    cairo_get_matrix (c5c->cr, &matrix);
+    ret = new_cairo_matrix (&matrix);
     RETURN (ret);
 }
 
@@ -262,15 +255,14 @@
 {
     ENTER ();
     cairo_5c_t	    *c5c = cairo_5c_get (cv);
-    cairo_matrix_t  *matrix;
+    cairo_matrix_t  matrix;
 
     if (aborting)
 	RETURN(Void);
-    matrix = cairo_matrix_part (mv, "invalid matrix");
+    cairo_matrix_part (mv, &matrix, "invalid matrix");
     if (aborting)
 	RETURN(Void);
-    cairo_concat_matrix (c5c->cr, matrix);
-    cairo_matrix_destroy (matrix);
+    cairo_concat_matrix (c5c->cr, &matrix);
     RETURN (Void);
 }
 
@@ -279,15 +271,14 @@
 {
     ENTER ();
     cairo_5c_t	    *c5c = cairo_5c_get (cv);
-    cairo_matrix_t  *matrix;
+    cairo_matrix_t  matrix;
 
     if (aborting)
 	RETURN(Void);
-    matrix = cairo_matrix_part (mv, "invalid matrix");
+    cairo_matrix_part (mv, &matrix, "invalid matrix");
     if (aborting)
 	RETURN(Void);
-    cairo_set_matrix (c5c->cr, matrix);
-    cairo_matrix_destroy (matrix);
+    cairo_set_matrix (c5c->cr, &matrix);
     RETURN (Void);
 }
 
@@ -398,15 +389,16 @@
 }
 
 Value
-do_Cairo_current_operator (Value cv)
+do_Cairo_get_operator (Value cv)
 {
     cairo_5c_t	    *c5c = cairo_5c_get (cv);
     
     if (aborting)
 	return Void;
-    return IntToEnum (typeCairoOperator, cairo_current_operator (c5c->cr));
+    return IntToEnum (typeCairoOperator, cairo_get_operator (c5c->cr));
 }
 
+#if 0
 Value
 do_Cairo_current_rgb_color (Value cv)
 {
@@ -437,20 +429,21 @@
 	RETURN(Void);
     RETURN (NewDoubleFloat (cairo_current_alpha (c5c->cr)));
 }
+#endif
 
 Value
-do_Cairo_current_tolerance (Value cv)
+do_Cairo_get_tolerance (Value cv)
 {
     ENTER ();
     cairo_5c_t	    *c5c = cairo_5c_get (cv);
     
     if (aborting)
 	RETURN(Void);
-    RETURN (NewDoubleFloat (cairo_current_tolerance (c5c->cr)));
+    RETURN (NewDoubleFloat (cairo_get_tolerance (c5c->cr)));
 }
 
 Value
-do_Cairo_current_point (Value cv)
+do_Cairo_get_current_point (Value cv)
 {
     ENTER ();
     cairo_5c_t	    *c5c = cairo_5c_get (cv);
@@ -460,7 +453,7 @@
     
     if (aborting)
 	return Void;
-    cairo_current_point (c5c->cr, &x, &y);
+    cairo_get_current_point (c5c->cr, &x, &y);
     ret = NewStruct (TypeCanon (typeCairoPoint)->structs.structs, False);
     box = ret->structs.values;
     BoxValueSet (box, 0, NewDoubleFloat (x));
@@ -469,56 +462,56 @@
 }
 
 Value
-do_Cairo_current_fill_rule (Value cv)
+do_Cairo_get_fill_rule (Value cv)
 {
     ENTER ();
     cairo_5c_t	    *c5c = cairo_5c_get (cv);
     
     if (aborting)
 	RETURN(Void);
-    RETURN(IntToEnum (typeCairoFillRule, cairo_current_fill_rule (c5c->cr)));
+    RETURN(IntToEnum (typeCairoFillRule, cairo_get_fill_rule (c5c->cr)));
 }
 
 Value
-do_Cairo_current_line_width (Value cv)
+do_Cairo_get_line_width (Value cv)
 {
     ENTER ();
     cairo_5c_t	    *c5c = cairo_5c_get (cv);
     
     if (aborting)
 	RETURN(Void);
-    RETURN(NewDoubleFloat (cairo_current_line_width (c5c->cr)));
+    RETURN(NewDoubleFloat (cairo_get_line_width (c5c->cr)));
 }
 
 Value
-do_Cairo_current_line_cap (Value cv)
+do_Cairo_get_line_cap (Value cv)
 {
     ENTER ();
     cairo_5c_t	    *c5c = cairo_5c_get (cv);
     
     if (aborting)
 	RETURN(Void);
-    RETURN(IntToEnum (typeCairoLineCap, cairo_current_line_cap (c5c->cr)));
+    RETURN(IntToEnum (typeCairoLineCap, cairo_get_line_cap (c5c->cr)));
 }
 
 Value
-do_Cairo_current_line_join (Value cv)
+do_Cairo_get_line_join (Value cv)
 {
     ENTER ();
     cairo_5c_t	    *c5c = cairo_5c_get (cv);
     
     if (aborting)
 	RETURN(Void);
-    RETURN(IntToEnum (typeCairoLineJoin, cairo_current_line_join (c5c->cr)));
+    RETURN(IntToEnum (typeCairoLineJoin, cairo_get_line_join (c5c->cr)));
 }
 
 Value
-do_Cairo_current_miter_limit (Value cv)
+do_Cairo_get_miter_limit (Value cv)
 {
     ENTER ();
     cairo_5c_t	    *c5c = cairo_5c_get (cv);
     
     if (aborting)
 	RETURN(Void);
-    RETURN(NewDoubleFloat (cairo_current_miter_limit (c5c->cr)));
+    RETURN(NewDoubleFloat (cairo_get_miter_limit (c5c->cr)));
 }

Index: gtk.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/gtk.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- gtk.c	11 Feb 2005 21:15:46 -0000	1.7
+++ gtk.c	2 May 2005 20:24:38 -0000	1.8
@@ -59,7 +59,8 @@
 
 /*
  * This part runs in the gtk thread, so it must not refer to or use
- * any memory managed by nickle
+ * any memory managed by nickle.  Called from signal handler with
+ * gdk lock held.
  */
 static gboolean
 configure_event (GtkWidget *widget, GdkEventConfigure *event)
@@ -93,6 +94,9 @@
     return TRUE;
 }
 
+/*
+ * Called from signal handler with gdk lock held
+ */
 static gboolean
 expose_event( GtkWidget *widget, GdkEventExpose *event )
 {
@@ -108,6 +112,9 @@
     return FALSE;
 }
 
+/*
+ * Called from delete_event with gdk lock held
+ */
 static void
 delete_drawing_area (GtkWidget *widget, gpointer data)
 {			   
@@ -116,8 +123,10 @@
     
     if (c5s->u.window.send_events)
     {
+	gdk_threads_leave ();
 	fprintf (c5s->u.window.send_events, "%d delete\n", 0);
 	fflush (c5s->u.window.send_events);
+	gdk_threads_enter ();
     }
     tool->drawing_area = NULL;
     tool->window = NULL;
@@ -129,6 +138,9 @@
     c5s->u.window.pixmap = None;
 }
 
+/*
+ * Called from signal handler with lock held
+ */
 static gboolean
 delete_event( GtkWidget *widget, GdkEventAny *event )
 {
@@ -136,6 +148,9 @@
     return FALSE;
 }
 
+/*
+ * Called from signal handler with lock held
+ */
 static gboolean
 motion_notify_event( GtkWidget *widget, GdkEventMotion *event )
 {
@@ -143,14 +158,19 @@
     
     if (c5s->u.window.send_events)
     {
+	gdk_threads_leave ();
 	fprintf (c5s->u.window.send_events, "%d motion %g %g\n",
 		 event->time, event->x, event->y);
 	fflush (c5s->u.window.send_events);
+	gdk_threads_enter ();
     }
     return FALSE;
 }
 
 
+/*
+ * Called from signal handler with lock held
+ */
 static gboolean
 button_press_event( GtkWidget *widget, GdkEventButton *event )
 {
@@ -158,13 +178,18 @@
     
     if (c5s->u.window.send_events)
     {
+	gdk_threads_leave ();
 	fprintf (c5s->u.window.send_events, "%d press %d %g %g\n",
 		 event->time, event->button, event->x, event->y);
 	fflush (c5s->u.window.send_events);
+	gdk_threads_enter ();
     }
     return FALSE;
 }
 
+/*
+ * Called from signal handler with lock held
+ */
 static gboolean
 button_release_event( GtkWidget *widget, GdkEventButton *event )
 {
@@ -172,13 +197,18 @@
     
     if (c5s->u.window.send_events)
     {
+	gdk_threads_leave ();
 	fprintf (c5s->u.window.send_events, "%d release %d %g %g\n",
 		 event->time, event->button, event->x, event->y);
 	fflush (c5s->u.window.send_events);
+	gdk_threads_enter ();
     }
     return FALSE;
 }
 
+/*
+ * Called from signal handler with lock held
+ */
 static void
 gtk_repaint (cairo_5c_surface_t *c5s, int x, int y, int w, int h)
 {
@@ -205,23 +235,31 @@
     }
 }
 
+/*
+ * Called from timeout with gdk lock not held
+ */
 static gboolean
 gtk_repaint_timeout (gpointer data)
 {
-    cairo_5c_surface_t	*c5s = data;
-    cairo_5c_tool_t	*tool = c5s->u.window.tool;
-
-    if (tool->disable == 0)
+    gdk_threads_enter ();
     {
-	tool->dirty = 0;
-	gtk_repaint (c5s, 0, 0, 0, 0);
+	cairo_5c_surface_t	*c5s = data;
+	cairo_5c_tool_t	*tool = c5s->u.window.tool;
+    
+	if (tool->disable == 0)
+	{
+	    tool->dirty = 0;
+	    gtk_repaint (c5s, 0, 0, 0, 0);
+	}
     }
+    gdk_threads_leave ();
     return FALSE;
 }
 
 static void *
 gtk_thread_main (void *closure)
 {
+    gdk_threads_enter ();
     gtk_main ();
     gdk_threads_leave ();
     return 0;
@@ -242,9 +280,9 @@
 
     gdk_threads_enter ();
     gtk_main_quit ();
-    gdk_threads_leave ();
     if (gg == gtk_global)
 	gtk_global = NULL;
+    gdk_threads_leave ();
     return 1;
 }
 
@@ -262,12 +300,13 @@
 
     if (!been_here)
     {
-	XInitThreads ();
+	/* trust to gdk to lock the display; Xlib is horribly broken */
+/*	XInitThreads (); */
 	g_thread_init (NULL);
 	gdk_threads_init ();
 	been_here = 1;
     }
-    
+    gdk_threads_enter ();
     if (!gtk_init_check (&argc, &argv))
     {
 	const char *display_name_arg = gdk_get_display_arg_name ();
@@ -284,6 +323,7 @@
     pthread_create (&gg->gtk_thread, 0, gtk_thread_main, gg);
     if (!gtk_global)
 	gtk_global = gg;
+    gdk_threads_leave ();
     RETURN (gg);
 }
 
@@ -299,6 +339,9 @@
     MemReference (tool->global);
 }
 
+/*
+ * Called from nickle with gdk lock not held
+ */
 static int
 gtk_tool_free (void *object)
 {
@@ -322,6 +365,10 @@
 
 static DataType gtk_tool_type = { gtk_tool_mark, gtk_tool_free, "GtkTool" };
 
+/*
+ * Called from nickle with gdk lock not held
+ */
+
 Bool
 cairo_5c_tool_create (cairo_5c_surface_t *c5s, char *name, int width, int height)
 {
@@ -401,6 +448,9 @@
     return True;
 }
 
+/*
+ * called from nickle with the gdk lock not held
+ */
 Bool
 cairo_5c_tool_destroy (cairo_5c_surface_t *c5s)
 {
@@ -429,9 +479,7 @@
 	tool->dirty = 1;
 	if (tool->disable == 0)
 	{
-	    gdk_threads_enter ();
 	    g_timeout_add (16, gtk_repaint_timeout, c5s);
-	    gdk_threads_leave ();
 	}
     }
 }
@@ -445,6 +493,10 @@
     return True;
 }
 
+/*
+ * Called from nickle with gdk lock not held.  As no gtk/gdk
+ * functions are called, I don't think we need to grab it.
+ */
 Bool
 cairo_5c_tool_enable (cairo_5c_surface_t *c5s)
 {
@@ -454,11 +506,7 @@
 	return False;
     --tool->disable;
     if (!tool->disable && tool->dirty)
-    {
-	gdk_threads_enter ();
 	g_timeout_add (0, gtk_repaint_timeout, c5s);
-	gdk_threads_leave ();
-    }
     return True;
 }
 

Index: init.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/init.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- init.c	11 Feb 2005 21:15:46 -0000	1.12
+++ init.c	2 May 2005 20:24:38 -0000	1.13
@@ -53,6 +53,7 @@
 Type		*typeCairoPoint;
 Type		*typeCairoRect;
 Type		*typeCairoRgbColor;
+Type		*typeCairoRgbaColor;
 Type		*typeCairoPattern;
 Type		*typeCairoPath;
 Type		*typeCairoMoveTo;
@@ -93,18 +94,20 @@
 #define RECT_S		"13"
 #define RGB_COLOR_I	14
 #define RGB_COLOR_S	"14"
-#define PATTERN_I	15
-#define PATTERN_S	"15"
-#define PATH_I		16
-#define PATH_S		"16"
-#define MOVE_TO_I	17
-#define MOVE_TO_S	"17"
-#define LINE_TO_I	18
-#define LINE_TO_S	"18"
-#define CURVE_TO_I	19
-#define CURVE_TO_S	"19"
-#define CLOSE_PATH_I	20
-#define CLOSE_PATH_S	"20"
+#define RGBA_COLOR_I	15
+#define RGBA_COLOR_S	"15"
+#define PATTERN_I	16
+#define PATTERN_S	"16"
+#define PATH_I		17
+#define PATH_S		"17"
+#define MOVE_TO_I	18
+#define MOVE_TO_S	"18"
+#define LINE_TO_I	19
+#define LINE_TO_S	"19"
+#define CURVE_TO_I	20
+#define CURVE_TO_S	"20"
+#define CLOSE_PATH_I	21
+#define CLOSE_PATH_S	"21"
 
 #define EXTEND_I	30
 #define EXTEND_S	"30"
@@ -266,8 +269,13 @@
 				    publish_public,
 				    MATRIX_I,
 				    NULL,
-				    BuildArrayType (typePrim[rep_float],
-						    2, 2, 3));
+				    BuildStructType (6,
+						     typePrim[rep_float], "xx",
+						     typePrim[rep_float], "yx",
+						     typePrim[rep_float], "xy",
+						     typePrim[rep_float], "yy",
+						     typePrim[rep_float], "x0",
+						     typePrim[rep_float], "y0"));
 
     typeCairoPoint = make_typedef ("point_t",
 				   CairoNamespace,
@@ -299,6 +307,17 @@
 						       typePrim[rep_float], "green",
 						       typePrim[rep_float], "blue"));
 
+    typeCairoRgbaColor = make_typedef ("rgba_color_t",
+				       CairoNamespace,
+				       publish_public,
+				       RGBA_COLOR_I,
+				       NULL,
+				       BuildStructType (4,
+							typePrim[rep_float], "red",
+							typePrim[rep_float], "green",
+							typePrim[rep_float], "blue",
+							typePrim[rep_float], "alpha"));
+
     typeCairoPattern = make_typedef ("pattern_t",
 				     CairoNamespace,
 				     publish_public,
@@ -461,8 +480,8 @@
 	    " void destroy (cairo_t cairo)\n"
 	    "\n"
 	    " destroy a rendering context.\n"},
-	{ do_Cairo_current_target_surface, "current_target_surface", SURFACE_S, CAIRO_S, "\n"
-	    " surface_t current_target_surface (cairo_t cairo)\n"
+	{ do_Cairo_get_target_surface, "get_target_surface", SURFACE_S, CAIRO_S, "\n"
+	    " surface_t get_target_surface (cairo_t cairo)\n"
 	    "\n"
 	    " Return current target surface\n" },
 	{ do_Cairo_status, "status", STATUS_S, CAIRO_S, "\n"
@@ -555,67 +574,58 @@
 	    "\n"
 	    " Returns bounding box of filling current path\n" },
 	
-	{ do_Cairo_current_operator, "current_operator", OPERATOR_S, CAIRO_S, "\n"
-	    " operator_t current_operator (cairo_t cairo)\n"
+	{ do_Cairo_get_operator, "get_operator", OPERATOR_S, CAIRO_S, "\n"
+	    " operator_t get_operator (cairo_t cairo)\n"
 	    "\n"
 	    " Returns the current operator\n" },
 	
-	{ do_Cairo_current_rgb_color, "current_rgb_color", RGB_COLOR_S, CAIRO_S, "\n"
-	    " rgb_color_t current_rgb_color (cairo_t cairo)\n"
-	    "\n"
-	    " Returns the current rgb color\n" },
-	
-	{ do_Cairo_current_alpha, "current_alpha", "n", CAIRO_S, "\n"
-	    " real current_alpha (cairo_t cairo)\n"
+	{ do_Cairo_get_source, "get_source", PATTERN_S, CAIRO_S, "\n"
+	    " pattern_t get_source (cairo_t cairo)\n"
 	    "\n"
-	    " Returns the current alpha\n" },
+	    " Returns the current source pattern\n" },
 	
-	{ do_Cairo_current_pattern, "current_pattern", PATTERN_S, CAIRO_S, "\n"
-	    " pattern_t current_pattern (cairo_t cairo)\n"
-	    "\n"
-	    " Returns the current pattern\n" },
-	{ do_Cairo_current_tolerance, "current_tolerance", "n", CAIRO_S, "\n"
-	    " real current_tolerance (cairo_t cairo)\n"
+	{ do_Cairo_get_tolerance, "get_tolerance", "n", CAIRO_S, "\n"
+	    " real get_tolerance (cairo_t cairo)\n"
 	    "\n"
 	    " Returns the current tolerance\n" },
 	
-	{ do_Cairo_current_point, "current_point", RGB_COLOR_S, CAIRO_S, "\n"
+	{ do_Cairo_get_current_point, "get_current_point", POINT_S, CAIRO_S, "\n"
 	    " point_t current_point (cairo_t cairo)\n"
 	    "\n"
 	    " Returns the current point\n" },
 	
-	{ do_Cairo_current_fill_rule, "current_fill_rule", FILL_RULE_S, CAIRO_S, "\n"
-	    " fill_rule_t current_fill_rule (cairo_t cairo)\n"
+	{ do_Cairo_get_fill_rule, "get_fill_rule", FILL_RULE_S, CAIRO_S, "\n"
+	    " fill_rule_t get_fill_rule (cairo_t cairo)\n"
 	    "\n"
 	    " Returns the current fill rule\n" },
 	
-	{ do_Cairo_current_line_width, "current_line_width", "n", CAIRO_S, "\n"
-	    " real current_line_width (cairo_t cairo)\n"
+	{ do_Cairo_get_line_width, "get_line_width", "n", CAIRO_S, "\n"
+	    " real get_line_width (cairo_t cairo)\n"
 	    "\n"
 	    " Returns the current line width\n" },
 	
-	{ do_Cairo_current_line_cap, "current_line_cap", LINE_CAP_S, CAIRO_S, "\n"
-	    " line_cap_t current_line_cap (cairo_t cairo)\n"
+	{ do_Cairo_get_line_cap, "get_line_cap", LINE_CAP_S, CAIRO_S, "\n"
+	    " line_cap_t get_line_cap (cairo_t cairo)\n"
 	    "\n"
 	    " Returns the current line_cap\n" },
 	
-	{ do_Cairo_current_line_join, "current_line_join", LINE_JOIN_S, CAIRO_S, "\n"
-	    " line_join_t current_line_join (cairo_t cairo)\n"
+	{ do_Cairo_get_line_join, "get_line_join", LINE_JOIN_S, CAIRO_S, "\n"
+	    " line_join_t get_line_join (cairo_t cairo)\n"
 	    "\n"
 	    " Returns the current line join\n" },
 	
-	{ do_Cairo_current_miter_limit, "current_miter_limit", "n", CAIRO_S, "\n"
-	    " real current_miter_limit (cairo_t cairo)\n"
+	{ do_Cairo_get_miter_limit, "get_miter_limit", "n", CAIRO_S, "\n"
+	    " real get_miter_limit (cairo_t cairo)\n"
 	    "\n"
 	    " Returns the current miter limit\n" },
 	
-	{ do_Cairo_current_matrix, "current_matrix", MATRIX_S, CAIRO_S, "\n"
-	    " matrix_t current_matrix (cairo_t cairo)\n"
+	{ do_Cairo_get_matrix, "get_matrix", MATRIX_S, CAIRO_S, "\n"
+	    " matrix_t get_matrix (cairo_t cairo)\n"
 	    "\n"
 	    " Returns the current transformation matrix\n" },
 	
-	{ do_Cairo_current_font_extents, "current_font_extents", FONT_EXTENTS_S, CAIRO_S, "\n"
-	    " font_extents_t current_font_extents (cairo_t cairo)\n"
+	{ do_Cairo_font_extents, "font_extents", FONT_EXTENTS_S, CAIRO_S, "\n"
+	    " font_extents_t font_extents (cairo_t cairo)\n"
 	    "\n"
 	    " Returns metrics for current font\n" },
 	{ 0 }
@@ -634,14 +644,10 @@
 	    " void set_operator (cairo_t cr, operator_t operator)\n"
 	    "\n"
 	    " Set current operator\n" },
-	{ do_Cairo_set_pattern, "set_pattern", "v", CAIRO_S PATTERN_S, "\n"
-	    " void set_pattern (cairo_t cr, pattern_t pattern)\n"
-	    "\n"
-	    " Set current pattern\n" },
-	{ do_Cairo_set_alpha, "set_alpha", "v", CAIRO_S "n", "\n"
-	    " void set_alpha (cairo_t cr, real alpha)\n"
+	{ do_Cairo_set_source, "set_source", "v", CAIRO_S PATTERN_S, "\n"
+	    " void set_source (cairo_t cr, pattern_t pattern)\n"
 	    "\n"
-	    " Set current alpha\n" },
+	    " Set current source pattern\n" },
 	{ do_Cairo_set_tolerance, "set_tolerance", "v", CAIRO_S "n", "\n"
 	    " void set_tolerance (cairo_t cr, real alpha)\n"
 	    "\n"
@@ -674,14 +680,14 @@
 	    " void set_font (cairo_t cr, string name)\n"
 	    "\n"
 	    " Select and set current font from name.\n" },
-	{ do_Cairo_scale_font, "scale_font", "v", CAIRO_S "n", "\n"
-	    " void scale_font (cairo_t cr, real scale)\n"
+	{ do_Cairo_set_font_size, "set_font_size", "v", CAIRO_S "n", "\n"
+	    " void set_font_size (cairo_t cr, real size)\n"
 	    "\n"
-	    " Scales current font by specified amount\n" },
-	{ do_Cairo_transform_font, "transform_font", "v", CAIRO_S MATRIX_S, "\n"
-	    " void transform_font (cairo_t cr, matrix_t matrix)\n"
+	    " Sets font size\n" },
+	{ do_Cairo_set_font_matrix, "set_font_matrix", "v", CAIRO_S MATRIX_S, "\n"
+	    " void set_font_matrix (cairo_t cr, matrix_t matrix)\n"
 	    "\n"
-	    " Transforms current font by specified matrix\n" },
+	    " Sets current font matrix\n" },
 	{ do_Cairo_show_text, "show_text", "v", CAIRO_S "s", "\n"
 	    " void show_text (cairo_t cr, string text)\n"
 	    "\n"
@@ -772,10 +778,10 @@
     };
 
     static const struct fbuiltin_4 funcs_4[] = {
-	{ do_Cairo_set_rgb_color, "set_rgb_color", "v", CAIRO_S "nnn", "\n"
-	    " void set_rgb_color (cairo_t cr, real red, real green, real blue)\n"
+	{ do_Cairo_set_source_rgb, "set_source_rgb", "v", CAIRO_S "nnn", "\n"
+	    " void set_source_rgb (cairo_t cr, real red, real green, real blue)\n"
 	    "\n"
-	    " Set current color\n" },
+	    " Set solid color source\n" },
 	{ do_Cairo_select_font, "select_font", "v", CAIRO_S "s" FONT_SLANT_S FONT_WEIGHT_S, "\n"
 	    " void select_font (cairo_t cr, string family, slant_t slant, weight_t weight)\n"
 	    "\n"
@@ -788,6 +794,10 @@
 	    " void rectangle (cairo_t cr, real x, real y, real width, real height)\n"
 	    "\n"
 	    " Adds the specified rectangle to the current path\n" },
+	{ do_Cairo_set_source_rgba, "set_source_rgba", "v", CAIRO_S "nnnn", "\n"
+	    " void set_source_rgba (cairo_t cr, real red, real green, real blue, real alpha)\n"
+	    "\n"
+	    " Set solid color source with alpha (premultiplied)\n" },
 	{ 0 }
     };
     
@@ -835,15 +845,23 @@
 	{ 0 }
     };
 
+    static const struct fbuiltin_2 surfuncs_2[] = {
+	{ do_Cairo_Surface_create_image, "create_image", SURFACE_S, "nn", "\n"
+	    " surface_t create_image (real width, real height)\n"
+	    "\n"
+	    " Create an image surface\n" },
+	{ do_Cairo_Surface_write_to_png, "write_to_png", "v", SURFACE_S "s", "\n"
+	    " surface_t write_to_png (surface_t surface, string filename)\n"
+	    "\n"
+	    " Write a surface to a file in png format\n" },
+	{ 0 }
+    };
+    
     static const struct fbuiltin_3 surfuncs_3[] = {
 	{ do_Cairo_Surface_create_window, "create_window", SURFACE_S, "snn", "\n"
 	    " surface_t create_window (real width, real height)\n"
 	    "\n"
 	    " Create a window and return a surface pointer for it\n" },
-	{ do_Cairo_Surface_create_png, "create_png", SURFACE_S, "snn", "\n"
-	    " surface_t create_png (string filename, real width, real height)\n"
-	    "\n"
-	    " Create a png file and return a surface pointer for it\n" },
 	{ do_Cairo_Surface_create_similar, "create_similar", SURFACE_S, SURFACE_S "nn", "\n"
 	    " surface_t create_similar (surface_t related, real width, real height)\n"
 	    "\n"
@@ -931,6 +949,7 @@
     BuiltinFuncs7 (&CairoNamespace, funcs_7);
 
     BuiltinFuncs1 (&CairoSurfaceNamespace, surfuncs_1);
+    BuiltinFuncs2 (&CairoSurfaceNamespace, surfuncs_2);
     BuiltinFuncs3 (&CairoSurfaceNamespace, surfuncs_3);
     BuiltinFuncs5 (&CairoSurfaceNamespace, surfuncs_5);
     

Index: matrix.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/matrix.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- matrix.c	11 Feb 2005 21:15:46 -0000	1.2
+++ matrix.c	2 May 2005 20:24:38 -0000	1.3
@@ -35,47 +35,31 @@
 
 #include "cairo-5c.h"
 
-cairo_matrix_t *
-cairo_matrix_part (Value mv, char *err)
+void
+cairo_matrix_part (Value mv, cairo_matrix_t *matrix, char *err)
 {
-    double a = DoublePart (ArrayValue(&mv->array, 0), "invalid matrix");
-    double b = DoublePart (ArrayValue(&mv->array, 1), "invalid matrix");
-    double c = DoublePart (ArrayValue(&mv->array, 2), "invalid matrix");
-    double d = DoublePart (ArrayValue(&mv->array, 3), "invalid matrix");
-    double tx = DoublePart (ArrayValue(&mv->array, 4), "invalid matrix");
-    double ty = DoublePart (ArrayValue(&mv->array, 5), "invalid matrix");
-    cairo_matrix_t  *matrix;
-
-    if (aborting)
-	return 0;
-
-    matrix = cairo_matrix_create ();
-    if (!matrix)
-    {
-	RaiseStandardException (exception_invalid_argument,
-				err,
-				1, mv);
-	return 0;
-    }
-    cairo_matrix_set_affine (matrix, a, b, c, d, tx, ty);
-    return matrix;
+    matrix->xx = DoublePart (StructMemValue (mv, AtomId("xx")), "invalid xx");
+    matrix->yx = DoublePart (StructMemValue (mv, AtomId("yx")), "invalid yx");
+    matrix->xy = DoublePart (StructMemValue (mv, AtomId("xy")), "invalid xy");
+    matrix->yy = DoublePart (StructMemValue (mv, AtomId("yy")), "invalid yy");
+    matrix->x0 = DoublePart (StructMemValue (mv, AtomId("x0")), "invalid x0");
+    matrix->y0 = DoublePart (StructMemValue (mv, AtomId("y0")), "invalid y0");
 }
 
 Value
 new_cairo_matrix (cairo_matrix_t *matrix)
 {
     ENTER ();
-    double  a, b, c, d, tx, ty;
     Value   ret;
-    static int	dims[2] = { 2, 3 };
-    
-    cairo_matrix_get_affine (matrix, &a, &b, &c, &d, &tx, &ty);
-    ret = NewArray (False, False, typePrim[rep_float], 2, dims);
-    ArrayValueSet(&ret->array, 0, NewDoubleFloat (a));
-    ArrayValueSet(&ret->array, 1, NewDoubleFloat (b));
-    ArrayValueSet(&ret->array, 2, NewDoubleFloat (c));
-    ArrayValueSet(&ret->array, 3, NewDoubleFloat (d));
-    ArrayValueSet(&ret->array, 4, NewDoubleFloat (tx));
-    ArrayValueSet(&ret->array, 5, NewDoubleFloat (ty));
+    BoxPtr  box;
+
+    ret = NewStruct (TypeCanon (typeCairoMatrix)->structs.structs, False);
+    box = ret->structs.values;
+    BoxValueSet (box, 0, NewDoubleFloat (matrix->xx));
+    BoxValueSet (box, 1, NewDoubleFloat (matrix->yx));
+    BoxValueSet (box, 2, NewDoubleFloat (matrix->xy));
+    BoxValueSet (box, 3, NewDoubleFloat (matrix->yy));
+    BoxValueSet (box, 4, NewDoubleFloat (matrix->x0));
+    BoxValueSet (box, 5, NewDoubleFloat (matrix->y0));
     RETURN (ret);
 }

Index: pattern.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/pattern.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- pattern.c	14 Mar 2005 21:43:06 -0000	1.4
+++ pattern.c	2 May 2005 20:24:38 -0000	1.5
@@ -75,25 +75,25 @@
 }
 
 Value
-do_Cairo_set_pattern (Value cv, Value patv)
+do_Cairo_set_source (Value cv, Value patv)
 {
     cairo_5c_t	    *c5c = cairo_5c_get (cv);
     cairo_pattern_t *pat = get_cairo_pattern (patv);
 
     if (aborting)
 	return Void;
-    cairo_set_pattern (c5c->cr, pat);
+    cairo_set_source (c5c->cr, pat);
     return Void;
 }
 
 Value
-do_Cairo_current_pattern (Value cv)
+do_Cairo_get_source (Value cv)
 {
     cairo_5c_t	*c5c = cairo_5c_get (cv);
 
     if (aborting)
 	return Void;
-    return make_pattern_value (cairo_get_pattern (c5c->cr));
+    return make_pattern_value (cairo_get_source (c5c->cr));
 }
 
 Value
@@ -164,9 +164,11 @@
     }
 }
 
+#if 0
 struct _cairo_matrix {
     double m[3][2];
 };
+#endif
 
 struct _cairo_surface {
     const void *backend;
@@ -327,18 +329,17 @@
 }
 
 Value
-do_Cairo_Pattern_set_matrix (Value patv, Value matrixv)
+do_Cairo_Pattern_set_matrix (Value patv, Value mv)
 {
     ENTER ();
     cairo_pattern_t *pat = get_cairo_pattern (patv);
-    cairo_matrix_t  *mat;
+    cairo_matrix_t  matrix;
     cairo_status_t  status;
 
     if (aborting)
 	RETURN(Void);
-    mat = cairo_matrix_part (matrixv, "invalid pattern matrix");
-    status = cairo_pattern_set_matrix (pat, mat);
-    cairo_matrix_destroy (mat);
+    cairo_matrix_part (mv, &matrix, "invalid pattern matrix");
+    status = cairo_pattern_set_matrix (pat, &matrix);
     RETURN (IntToEnum (typeCairoStatus, status));
 }
 
@@ -347,15 +348,13 @@
 {
     ENTER ();
     cairo_pattern_t *pat = get_cairo_pattern (patv);
-    cairo_matrix_t  *matrix;
+    cairo_matrix_t  matrix;
     Value	    ret;
 
     if (aborting)
 	RETURN (Void);
-    matrix = cairo_matrix_create ();
-    cairo_pattern_get_matrix (pat, matrix);
-    ret = new_cairo_matrix (matrix);
-    cairo_matrix_destroy (matrix);
+    cairo_pattern_get_matrix (pat, &matrix);
+    ret = new_cairo_matrix (&matrix);
     RETURN (ret);
 }
 

Index: surface.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/surface.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- surface.c	11 Feb 2005 21:15:46 -0000	1.10
+++ surface.c	2 May 2005 20:24:38 -0000	1.11
@@ -92,7 +92,7 @@
 	    if (!create_cairo_window (c5s))
 		return 0;
 	break;
-    case CAIRO_5C_PNG:
+    case CAIRO_5C_IMAGE:
     case CAIRO_5C_PS:
     case CAIRO_5C_SCRATCH:
 	break;
@@ -115,7 +115,7 @@
     case CAIRO_5C_WINDOW:
 	cairo_5c_tool_mark (c5s);
 	break;
-    case CAIRO_5C_PNG:
+    case CAIRO_5C_IMAGE:
     case CAIRO_5C_PS:
     case CAIRO_5C_SCRATCH:
 	break;
@@ -130,7 +130,6 @@
 	return;
     
     switch (c5s->kind) {
-    case CAIRO_5C_PNG:
     case CAIRO_5C_PS:
 	FilePrintf (FileStdout, "Copied %d\n", c5s->copied);
 	if (!c5s->copied)
@@ -155,9 +154,7 @@
     case CAIRO_5C_WINDOW:
 	cairo_5c_tool_destroy (c5s);
 	break;
-    case CAIRO_5C_PNG:
-        fclose (c5s->u.png.file);
-        c5s->u.png.file = NULL;
+    case CAIRO_5C_IMAGE:
 	break;
     case CAIRO_5C_PS:
 	fclose (c5s->u.ps.file);
@@ -240,11 +237,10 @@
 }
 
 Value
-do_Cairo_Surface_create_png (Value fv, Value wv, Value hv)
+do_Cairo_Surface_create_image (Value wv, Value hv)
 {
     ENTER ();
     cairo_5c_surface_t	*c5s;
-    char		*filename = StrzPart (fv, "invalid filename");
     int			width = IntPart (wv, "invalid width");
     int			height = IntPart (hv, "invalid height");
     Value		ret;
@@ -253,7 +249,7 @@
 	RETURN (Void);
     
     c5s = ALLOCATE (&Cairo5cSurfaceType, sizeof (cairo_5c_surface_t));
-    c5s->kind = CAIRO_5C_PNG;
+    c5s->kind = CAIRO_5C_IMAGE;
     c5s->surface = 0;
     c5s->width = width;
     c5s->height = height;
@@ -261,20 +257,9 @@
     c5s->recv_events = Void;
     c5s->copied = False;
     
-    c5s->u.png.file = fopen (filename, "w");
-    
-    if (!c5s->u.png.file)
-    {
-	RaiseStandardException (exception_open_error,
-				"can't open file",
-				0, fv);
-	RETURN (Void);
-    }
-
-    c5s->surface = cairo_png_surface_create (c5s->u.png.file,
-					     CAIRO_FORMAT_ARGB32,
-					     width,
-					     height);
+    c5s->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+					       width,
+					       height);
     
     ret = NewForeign (CairoSurfaceId, c5s, 
 		      cairo_surface_foreign_mark, cairo_surface_foreign_free);
@@ -283,6 +268,20 @@
 }
 
 Value
+do_Cairo_Surface_write_to_png (Value sv, Value fv)
+{
+    ENTER ();
+    cairo_5c_surface_t	*c5s = cairo_5c_surface_get (sv);
+    char		*filename = StrzPart (fv, "invalid filename");
+    cairo_status_t	status;		
+    
+    if (aborting)
+	RETURN (Void);
+    status = cairo_surface_write_to_png (c5s->surface, filename);
+    RETURN (IntToEnum (typeCairoStatus, status));
+}
+
+Value
 do_Cairo_Surface_create_ps (Value fv, Value wv, Value hv, Value xppiv, Value yppiv)
 {
     ENTER ();

Index: text.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/text.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- text.c	14 Mar 2005 21:43:06 -0000	1.6
+++ text.c	2 May 2005 20:24:38 -0000	1.7
@@ -55,9 +55,8 @@
     cairo_5c_t		*c5c = cairo_5c_get (cv);
     char		*name = StrzPart (fv, "invalid name");
     FcPattern		*pat, *match;
-    cairo_font_t	*font;
+    cairo_font_face_t	*font_face;
     double		size = 0;
-    cairo_matrix_t	*scale;
     FcResult		result;
 
     if (aborting)
@@ -78,53 +77,50 @@
     }
 
     FcPatternGetDouble (match, FC_SIZE, 0, &size);
-    scale = cairo_matrix_create ();
-    font = cairo_ft_font_create (match, scale);
-    cairo_matrix_destroy (scale);
+    font_face = cairo_ft_font_face_create_for_pattern (match);
     FcPatternDestroy (match);
-    if (!font)
+    if (!font_face)
     {
 	RaiseStandardException (exception_open_error,
 				"can't open font",
 				1, fv);
 	RETURN (Void);
     }
-    cairo_set_font (c5c->cr, font);
-    cairo_scale_font (c5c->cr, size);
-    cairo_font_destroy (font);
+    cairo_set_font_face (c5c->cr, font_face);
+    cairo_set_font_size (c5c->cr, size);
+    cairo_font_face_destroy (font_face);
     RETURN(Void);
 }
 
 Value
-do_Cairo_scale_font (Value cv, Value sv)
+do_Cairo_set_font_size (Value cv, Value sv)
 {
     cairo_5c_t		*c5c = cairo_5c_get (cv);
-    double		scale = DoublePart (sv, "invalid scale");
+    double		size = DoublePart (sv, "invalid size");
     
     if (!aborting)
-	cairo_scale_font (c5c->cr, scale);
+	cairo_set_font_size (c5c->cr, size);
     return Void;
 }
 
 Value
-do_Cairo_transform_font (Value cv, Value mv)
+do_Cairo_set_font_matrix (Value cv, Value mv)
 {
     ENTER ();
     cairo_5c_t		*c5c = cairo_5c_get (cv);
-    cairo_matrix_t	*matrix;
+    cairo_matrix_t	matrix;
     
     if (aborting)
 	RETURN(Void);
-    matrix = cairo_matrix_part (mv, "invalid matrix");
+    cairo_matrix_part (mv, &matrix, "invalid matrix");
     if (aborting)
 	RETURN(Void);
-    cairo_transform_font (c5c->cr, matrix);
-    cairo_matrix_destroy (matrix);
+    cairo_set_font_matrix (c5c->cr, &matrix);
     RETURN(Void);
 }
 
 Value
-do_Cairo_current_font_extents (Value cv)
+do_Cairo_font_extents (Value cv)
 {
     ENTER ();
     cairo_5c_t		    *c5c = cairo_5c_get (cv);
@@ -134,7 +130,7 @@
 
     if (aborting)
 	return Void;
-    cairo_current_font_extents (c5c->cr, &extents);
+    cairo_font_extents (c5c->cr, &extents);
     ret = NewStruct (TypeCanon (typeCairoFontExtents)->structs.structs, False);
     box = ret->structs.values;
     BoxValueSet (box, 0, NewDoubleFloat (extents.ascent));




More information about the cairo-commit mailing list