[cairo-commit] cairo-5c ChangeLog, 1.9, 1.10 Makefile.am, 1.3, 1.4 cairo-5c.h, 1.5, 1.6 cairo.5c, 1.3, 1.4 gstate.c, 1.3, 1.4 init.c, 1.6, 1.7 matrix.c, NONE, 1.1 pattern.c, NONE, 1.1

Keith Packard commit at pdx.freedesktop.org
Fri Dec 17 17:09:44 PST 2004


Committed by: keithp

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

Modified Files:
	ChangeLog Makefile.am cairo-5c.h cairo.5c gstate.c init.c 
Added Files:
	matrix.c pattern.c 
Log Message:
2004-12-17  Keith Packard  <keithp at keithp.com>

	* Makefile.am:
	* cairo-5c.h:
	* cairo.5c:
	* gstate.c: (do_Cairo_set_alpha), (do_Cairo_current_matrix),
	(do_Cairo_set_matrix):
	* init.c: (make_typedef), (init_types), (nickle_init):
	* matrix.c: (cairo_matrix_part), (new_cairo_matrix):
	* pattern.c: (get_cairo_pattern), (free_cairo_pattern),
	(make_pattern_value), (do_Cairo_set_pattern),
	(do_Cairo_current_pattern), (do_Cairo_Pattern_create_linear),
	(do_Cairo_Pattern_create_radial),
	(do_Cairo_Pattern_add_color_stop), (do_Cairo_Pattern_set_matrix),
	(do_Cairo_Pattern_get_matrix), (do_Cairo_Pattern_set_extend),
	(do_Cairo_Pattern_get_extend), (do_Cairo_Pattern_set_filter),
	(do_Cairo_Pattern_get_filter):
	Add gradient pattern support.
	Split out matrix support to share.


Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-5c/ChangeLog,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- ChangeLog	17 Dec 2004 09:50:16 -0000	1.9
+++ ChangeLog	18 Dec 2004 01:09:40 -0000	1.10
@@ -1,5 +1,25 @@
 2004-12-17  Keith Packard  <keithp at keithp.com>
 
+	* Makefile.am:
+	* cairo-5c.h:
+	* cairo.5c:
+	* gstate.c: (do_Cairo_set_alpha), (do_Cairo_current_matrix),
+	(do_Cairo_set_matrix):
+	* init.c: (make_typedef), (init_types), (nickle_init):
+	* matrix.c: (cairo_matrix_part), (new_cairo_matrix):
+	* pattern.c: (get_cairo_pattern), (free_cairo_pattern),
+	(make_pattern_value), (do_Cairo_set_pattern),
+	(do_Cairo_current_pattern), (do_Cairo_Pattern_create_linear),
+	(do_Cairo_Pattern_create_radial),
+	(do_Cairo_Pattern_add_color_stop), (do_Cairo_Pattern_set_matrix),
+	(do_Cairo_Pattern_get_matrix), (do_Cairo_Pattern_set_extend),
+	(do_Cairo_Pattern_get_extend), (do_Cairo_Pattern_set_filter),
+	(do_Cairo_Pattern_get_filter):
+	Add gradient pattern support.
+	Split out matrix support to share.
+
+2004-12-17  Keith Packard  <keithp at keithp.com>
+
 	* cairo.5c:
 	Add HSV color space routine to cairo.5c
 

Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo-5c/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Makefile.am	17 Dec 2004 02:09:45 -0000	1.3
+++ Makefile.am	18 Dec 2004 01:09:40 -0000	1.4
@@ -42,6 +42,8 @@
 	gstate.c \
 	gtk.c \
 	init.c \
+	matrix.c \
+	pattern.c \
 	surface.c \
 	text.c
 

Index: cairo-5c.h
===================================================================
RCS file: /cvs/cairo/cairo-5c/cairo-5c.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cairo-5c.h	17 Dec 2004 09:40:43 -0000	1.5
+++ cairo-5c.h	18 Dec 2004 01:09:40 -0000	1.6
@@ -90,6 +90,10 @@
 extern Type		*typeCairoLineTo;
 extern Type		*typeCairoCurveTo;
 extern Type		*typeCairoClosePath;
+extern Type		*typeCairoFilter;
+
+extern Type		*typeCairoPatternExtend;
+extern Type		*typeCairoPatternFilter;
 
 /* surface.c */
 cairo_5c_t *
@@ -319,6 +323,53 @@
 Value
 do_Cairo_current_path_flat_list (Value cv);
 
+/* matrix.c */
+cairo_matrix_t *
+cairo_matrix_part (Value matrixv, char *err);
+
+Value
+new_cairo_matrix (cairo_matrix_t *matrix);
+
+/* pattern.c */
+cairo_pattern_t *
+get_cairo_pattern (Value pv);
+    
+Value
+do_Cairo_current_pattern (Value cv);
+
+Value
+do_Cairo_set_pattern (Value cv, Value patv);
+
+Value
+do_Cairo_Pattern_create_linear (Value x0v, Value y0v, Value x1v, Value y1v);
+
+Value
+do_Cairo_Pattern_create_radial (Value cx0v, Value cy0v, Value radius0v,
+				Value cx1v, Value cy1v, Value radius1v);
+
+Value
+do_Cairo_Pattern_add_color_stop (Value patv, Value offsetv,
+				 Value redv, Value greenv, Value bluev,
+				 Value alphav);
+
+Value
+do_Cairo_Pattern_set_matrix (Value patv, Value matrixv);
+
+Value
+do_Cairo_Pattern_get_matrix (Value patv);
+
+Value
+do_Cairo_Pattern_set_extend (Value patv, Value extendv);
+
+Value
+do_Cairo_Pattern_get_extend (Value patv);
+
+Value
+do_Cairo_Pattern_set_filter (Value patv, Value filterv);
+
+Value
+do_Cairo_Pattern_get_filter (Value patv);
+
 /* text.c */
 Value
 do_Cairo_select_font (Value cv, Value fv, Value sv, Value wv);

Index: cairo.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/cairo.5c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cairo.5c	17 Dec 2004 09:50:16 -0000	1.3
+++ cairo.5c	18 Dec 2004 01:09:40 -0000	1.4
@@ -154,6 +154,11 @@
 
     public void set_hsv_color (cairo_t cr, real h, real s, real v)
     {
-	Cairo::set_rgb_color (cr, from_hsv (h, s, v) ...);
+	set_rgb_color (cr, from_hsv (h, s, v) ...);
+    }
+
+    public real[3] current_hsv_color (cairo_t cr)
+    {
+	return to_hsv (current_rgb_color (cr) ...);
     }
 }

Index: gstate.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/gstate.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gstate.c	17 Dec 2004 02:09:45 -0000	1.3
+++ gstate.c	18 Dec 2004 01:09:40 -0000	1.4
@@ -80,7 +80,7 @@
 Value
 do_Cairo_set_alpha (Value cv, Value av)
 {
-   cairo_5c_t	*c5c = get_cairo_5c (cv);
+    cairo_5c_t	*c5c = get_cairo_5c (cv);
     double	a = DoublePart (av, "invalid alpha value");
 
     if (!aborting)
@@ -237,9 +237,7 @@
     ENTER ();
     cairo_5c_t	    *c5c = get_cairo_5c (cv);
     cairo_matrix_t  *matrix;
-    double	    a, b, c, d, tx, ty;
     Value	    ret;
-    static int	dims[2] = { 2, 3 };
 
     if (aborting)
 	RETURN(Void);
@@ -254,15 +252,8 @@
 	RETURN(Void);
     }
     cairo_current_matrix (c5c->cr, matrix);
-    cairo_matrix_get_affine (matrix, &a, &b, &c, &d, &tx, &ty);
+    ret = new_cairo_matrix (matrix);
     cairo_matrix_destroy (matrix);
-    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));
     RETURN (ret);
 }
 
@@ -272,26 +263,12 @@
     ENTER ();
     cairo_5c_t	    *c5c = get_cairo_5c (cv);
     cairo_matrix_t  *matrix;
-    double	    a, b, c, d, tx, ty;
 
     if (aborting)
 	RETURN(Void);
-    
-    matrix = cairo_matrix_create ();
-    if (!matrix)
-    {
-	RaiseStandardException (exception_invalid_argument,
-				"can't create matrix",
-				2, cv, Void);
+    matrix = cairo_matrix_part (mv, "invalid matrix");
+    if (aborting)
 	RETURN(Void);
-    }
-    a = DoublePart (ArrayValueGet(&mv->array, 0), "invalid matrix");
-    b = DoublePart (ArrayValueGet(&mv->array, 1), "invalid matrix");
-    c = DoublePart (ArrayValueGet(&mv->array, 2), "invalid matrix");
-    d = DoublePart (ArrayValueGet(&mv->array, 3), "invalid matrix");
-    tx = DoublePart (ArrayValueGet(&mv->array, 4), "invalid matrix");
-    ty = DoublePart (ArrayValueGet(&mv->array, 5), "invalid matrix");
-    cairo_matrix_set_affine (matrix, a, b, c, d, tx, ty);
     cairo_set_matrix (c5c->cr, matrix);
     cairo_matrix_destroy (matrix);
     RETURN (Void);

Index: init.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/init.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- init.c	17 Dec 2004 09:40:43 -0000	1.6
+++ init.c	18 Dec 2004 01:09:40 -0000	1.7
@@ -36,6 +36,7 @@
 #include "cairo-5c.h"
 
 NamespacePtr	CairoNamespace;
+NamespacePtr	CairoPatternNamespace;
 Type		*typeCairo;
 Type		*typeCairoStatus;
 Type		*typeCairoOperator;
@@ -56,6 +57,9 @@
 Type		*typeCairoCurveTo;
 Type		*typeCairoClosePath;
 
+Type		*typeCairoPatternExtend;
+Type		*typeCairoPatternFilter;
+
 #define CAIRO_I		0
 #define CAIRO_S		"00"
 #define STATUS_I	1
@@ -95,8 +99,14 @@
 #define CLOSE_PATH_I	18
 #define CLOSE_PATH_S	"18"
 
+#define EXTEND_I	30
+#define EXTEND_S	"30"
+#define FILTER_I	31
+#define FILTER_S	"31"
+
 static Type *
 make_typedef (char	*name_str,
+	      Namespace	*namespace,
 	      Publish	publish,
 	      int	usertype_id,
 	      Symbol	**sret,
@@ -108,7 +118,7 @@
     Type    *typed = NewTypeName (NewExprAtom (name, 0, False),
 				  sym);
     
-    NamespaceAddName (CairoNamespace, sym, publish);
+    NamespaceAddName (namespace, sym, publish);
     
     BuiltinSetUserdefType (typed, usertype_id);
     MemAddRoot (typed);
@@ -126,12 +136,14 @@
     CairoNamespace = BuiltinNamespace (/* parent */ 0, "Cairo")->namespace.namespace;
 
     typeCairo = make_typedef ("cairo_t",
+			      CairoNamespace,
 			      publish_public,
 			      CAIRO_I,
 			      NULL,
 			      typePrim[rep_foreign]);
 
     typeCairoStatus = make_typedef ("status_t",
+				    CairoNamespace,
 				    publish_public,
 				    STATUS_I,
 				    NULL,
@@ -145,6 +157,7 @@
 						   "NO_TARGET_SURFACE",
 						   "NULL_POINTER"));
     typeCairoOperator = make_typedef ("operator_t",
+				      CairoNamespace,
 				      publish_public,
 				      OPERATOR_I,
 				      NULL,
@@ -165,6 +178,7 @@
 						     "SATURATE"));
 
     typeCairoFillRule = make_typedef ("fill_rule_t",
+				      CairoNamespace,
 				      publish_public,
 				      FILL_RULE_I,
 				      NULL,
@@ -173,6 +187,7 @@
 						     "EVEN_ODD"));
 
     typeCairoLineCap = make_typedef ("line_cap_t",
+				     CairoNamespace,
 				     publish_public,
 				     LINE_CAP_I,
 				     NULL,
@@ -182,6 +197,7 @@
 						    "SQUARE"));
 
     typeCairoLineJoin = make_typedef ("line_join_t",
+				      CairoNamespace,
 				      publish_public,
 				      LINE_JOIN_I,
 				      NULL,
@@ -191,6 +207,7 @@
 						     "BEVEL"));
 
     typeCairoFontSlant = make_typedef ("font_slant_t",
+				       CairoNamespace,
 				       publish_public,
 				       FONT_SLANT_I,
 				       NULL,
@@ -199,6 +216,7 @@
 						      "ITALIC",
 						      "OBLIQUE"));
     typeCairoFontWeight = make_typedef ("font_weight_t",
+					CairoNamespace,
 					publish_public,
 					FONT_WEIGHT_I,
 					NULL,
@@ -207,6 +225,7 @@
 						       "BOLD"));
 
     typeCairoTextExtents = make_typedef ("text_extents_t",
+					 CairoNamespace,
 					 publish_public,
 					 TEXT_EXTENTS_I,
 					 NULL,
@@ -218,6 +237,7 @@
 							  typePrim[rep_float], "x_advance",
 							  typePrim[rep_float], "y_advance"));
     typeCairoMatrix = make_typedef ("matrix_t",
+				    CairoNamespace,
 				    publish_public,
 				    MATRIX_I,
 				    NULL,
@@ -225,6 +245,7 @@
 						    2, 2, 3));
 
     typeCairoPoint = make_typedef ("point_t",
+				   CairoNamespace,
 				   publish_public,
 				   POINT_I,
 				   NULL,
@@ -233,6 +254,7 @@
 						    typePrim[rep_float], "y"));
 
     typeCairoRect = make_typedef ("rect_t",
+				  CairoNamespace,
 				  publish_public,
 				  RECT_I,
 				  NULL,
@@ -243,6 +265,7 @@
 						   typePrim[rep_float], "height"));
 
     typeCairoRgbColor = make_typedef ("rgb_color_t",
+				      CairoNamespace,
 				      publish_public,
 				      RGB_COLOR_I,
 				      NULL,
@@ -252,6 +275,7 @@
 						       typePrim[rep_float], "blue"));
 
     typeCairoPattern = make_typedef ("pattern_t",
+				     CairoNamespace,
 				     publish_public,
 				     PATTERN_I,
 				     NULL,
@@ -262,30 +286,35 @@
      */
 
     typeCairoMoveTo = make_typedef ("move_to_t",
+				    CairoNamespace,
 				    publish_public,
 				    MOVE_TO_I,
 				    &mt,
 				    0);
 
     typeCairoLineTo = make_typedef ("line_to_t",
+				    CairoNamespace,
 				    publish_public,
 				    LINE_TO_I,
 				    &lt,
 				    0);
 
     typeCairoCurveTo = make_typedef ("curve_to_t",
+				     CairoNamespace,
 				     publish_public,
 				     CURVE_TO_I,
 				     &ct,
 				     0);
 
     typeCairoClosePath = make_typedef ("close_path_t",
+				       CairoNamespace,
 				       publish_public,
 				       CLOSE_PATH_I,
 				       &cp,
 				       0);
 
     typeCairoPath = make_typedef ("path_t",
+				  CairoNamespace,
 				  publish_public,
 				  PATH_I,
 				  &path,
@@ -318,6 +347,31 @@
     cp->symbol.type = BuildStructType (1,
 				       typeCairoPath, "next");
 
+    CairoPatternNamespace = BuiltinNamespace (&CairoNamespace, "Pattern")->namespace.namespace;
+
+    typeCairoPatternExtend = make_typedef ("extend_t",
+					   CairoPatternNamespace,
+					   publish_public,
+					   EXTEND_I,
+					   NULL,
+					   BuildEnumType (3,
+							  "NONE",
+							  "REPEAT",
+							  "REFLECT"));
+
+    typeCairoPatternFilter = make_typedef ("filter_t",
+					   CairoPatternNamespace,
+					   publish_public,
+					   FILTER_I,
+					   NULL,
+					   BuildEnumType (6,
+							  "FAST",
+							  "GOOD",
+							  "BEST",
+							  "NEAREST",
+							  "BILINEAR",
+							  "GAUSSIAN"));
+
     EXIT();
 }
 
@@ -479,6 +533,10 @@
 	    "\n"
 	    " Returns the current alpha\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"
 	    "\n"
@@ -527,10 +585,14 @@
     };
     
     static const struct fbuiltin_2 funcs_2[] = {
-	{ do_Cairo_set_operator, "set_alpha", "v", CAIRO_S OPERATOR_S, "\n"
+	{ do_Cairo_set_operator, "set_operator", "v", CAIRO_S OPERATOR_S, "\n"
 	    " 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"
 	    "\n"
@@ -690,6 +752,58 @@
 	{ 0 }
     };
 
+    static const struct fbuiltin_1 patfuncs_1[] = {
+	{ do_Cairo_Pattern_get_matrix, "get_matrix", MATRIX_S, PATTERN_S, "\n"
+	    " matrix_t get_matrix (pattern_t pattern)\n"
+	    "\n"
+	    " Returns current pattern transformation matrix\n" },
+	{ do_Cairo_Pattern_get_extend, "get_extend", EXTEND_S, PATTERN_S, "\n"
+	    " status_t get_extend (pattern_t pattern, extend_t extend)\n"
+	    "\n"
+	    " Returns current pattern extend method\n" },
+	{ do_Cairo_Pattern_get_filter, "get_filter", FILTER_S, PATTERN_S, "\n"
+	    " status_t get_filter (pattern_t pattern, filter_t filter)\n"
+	    "\n"
+	    " Returns current pattern filter method\n" },
+	{ 0 }
+    };
+    
+    static const struct fbuiltin_2 patfuncs_2[] = {
+	{ do_Cairo_Pattern_set_matrix, "set_matrix", STATUS_S, PATTERN_S MATRIX_S, "\n"
+	    " status_t set_matrix (pattern_t pattern, matrix_t matrix)\n"
+	    "\n"
+	    " Set a transformation matrix for a pattern\n" },
+	{ do_Cairo_Pattern_set_extend, "set_extend", STATUS_S, PATTERN_S EXTEND_S, "\n"
+	    " status_t set_extend (pattern_t pattern, extend_t extend)\n"
+	    "\n"
+	    " Set a extend method for a pattern\n" },
+	{ do_Cairo_Pattern_set_filter, "set_filter", STATUS_S, PATTERN_S FILTER_S, "\n"
+	    " status_t set_filter (pattern_t pattern, filter_t filter)\n"
+	    "\n"
+	    " Set a filter method for a pattern\n" },
+	{ 0 }
+    };
+	
+    static const struct fbuiltin_4 patfuncs_4[] = {
+	{ do_Cairo_Pattern_create_linear, "create_linear", PATTERN_S, "nnnn", "\n"
+	    " pattern_t create_linear (real x0, real y0, real x1, real y1)\n"
+	    "\n"
+	    " Create a linear gradient pattern\n" },
+	{ 0 }
+    };
+
+    static const struct fbuiltin_6 patfuncs_6[] = {
+	{ do_Cairo_Pattern_create_radial, "create_radial", PATTERN_S, "nnnnnn", "\n"
+	    " pattern_t create_radial (real cx0, real cy0, real radius0, real cx1, real cy1, real radius1)\n"
+	    "\n"
+	    " Create a radial gradient pattern\n" },
+	{ do_Cairo_Pattern_add_color_stop, "add_color_stop", STATUS_S, PATTERN_S "nnnnn", "\n"
+	    " status_t add_color_stop (pattern_t cr, real offset, real red, real green, real blue, real alpha)\n"
+	    "\n"
+	    " Add a color stop in a gradient pattern.\n" },
+	{ 0 }
+    };
+
     init_types ();
     
     BuiltinFuncsV (&CairoNamespace, funcs_v);
@@ -701,5 +815,10 @@
     BuiltinFuncs6 (&CairoNamespace, funcs_6);
     BuiltinFuncs7 (&CairoNamespace, funcs_7);
 
+    BuiltinFuncs1 (&CairoPatternNamespace, patfuncs_1);
+    BuiltinFuncs2 (&CairoPatternNamespace, patfuncs_2);
+    BuiltinFuncs4 (&CairoPatternNamespace, patfuncs_4);
+    BuiltinFuncs6 (&CairoPatternNamespace, patfuncs_6);
+
     RETURN(TrueVal);
 }

--- NEW FILE: matrix.c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: pattern.c ---
(This appears to be a binary file; contents omitted.)




More information about the cairo-commit mailing list