[cairo-commit]
rcairo/packages/cairo/ext rb_cairo_constants.c, 1.13,
1.14 rb_cairo_context.c, 1.31, 1.32 rb_cairo_exception.c, 1.10,
1.11 rb_cairo_pattern.c, 1.17, 1.18 rb_cairo_private.h, 1.3,
1.4 rb_cairo_surface.c, 1.29, 1.30
Kouhei Sutou
commit at pdx.freedesktop.org
Thu Dec 21 07:34:40 PST 2006
Committed by: kou
Update of /cvs/cairo/rcairo/packages/cairo/ext
In directory kemper:/tmp/cvs-serv20976/packages/cairo/ext
Modified Files:
rb_cairo_constants.c rb_cairo_context.c rb_cairo_exception.c
rb_cairo_pattern.c rb_cairo_private.h rb_cairo_surface.c
Log Message:
* packages/cairo/ext/rb_cairo_context.c,
packages/cairo/ext/rb_cairo_surface.c,
packages/cairo/ext/rb_cairo_pattern.c,
packages/cairo/ext/rb_cairo_exception.c,
packages/cairo/ext/rb_cairo_constants.c,
packages/cairo/ext/rb_cairo_pattern.c,
packages/cairo/ext/rb_cairo_private.h: supported cairo 1.3.8.
Index: rb_cairo_constants.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_constants.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- rb_cairo_constants.c 11 Jul 2006 00:29:07 -0000 1.13
+++ rb_cairo_constants.c 21 Dec 2006 15:34:36 -0000 1.14
@@ -287,8 +287,10 @@
INT2FIX (CAIRO_FORMAT_A8));
rb_define_const (rb_mCairo, "FORMAT_A1",
INT2FIX (CAIRO_FORMAT_A1));
+#if !CAIRO_CHECK_VERSION(1, 3, 0)
rb_define_const (rb_mCairo, "FORMAT_RGB16_565",
INT2FIX (CAIRO_FORMAT_RGB16_565));
+#endif
/* cairo_pattern_type_t */
Index: rb_cairo_context.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_context.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- rb_cairo_context.c 25 Oct 2006 14:27:27 -0000 1.31
+++ rb_cairo_context.c 21 Dec 2006 15:34:36 -0000 1.32
@@ -21,6 +21,23 @@
#define _SELF (RVAL2CRCONTEXT(self))
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+static VALUE rb_cCairo_Rectangle;
+static ID at_x, at_y, at_width, at_height;
+
+static VALUE
+cr_rectangle_initialize (VALUE self, VALUE x, VALUE y,
+ VALUE width, VALUE height)
+{
+ rb_ivar_set (self, at_x, x);
+ rb_ivar_set (self, at_y, y);
+ rb_ivar_set (self, at_width, width);
+ rb_ivar_set (self, at_height, height);
+
+ return Qnil;
+}
+#endif
+
static inline void
cr_check_status (cairo_t *context)
{
@@ -826,6 +843,46 @@
return self;
}
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+static VALUE
+cr_clip_extents (VALUE self)
+{
+ double x1, y1, x2, y2;
+ cairo_clip_extents (_SELF, &x1, &y1, &x2, &y2);
+ cr_check_status (_SELF);
+ return rb_ary_new3 (4,
+ rb_float_new (x1), rb_float_new (y1),
+ rb_float_new (x2), rb_float_new (y2));
+}
+
+static VALUE
+cr_clip_rectangles (VALUE self)
+{
+ VALUE rb_rectangles;
+ cairo_rectangle_list_t *rectangles;
+ int i;
+
+ rectangles = cairo_copy_clip_rectangles (_SELF);
+ rb_cairo_check_status (rectangles->status);
+
+ rb_rectangles = rb_ary_new2 (rectangles->num_rectangles);
+ for (i = 0; i < rectangles->num_rectangles; i++) {
+ VALUE argv[4];
+ cairo_rectangle_t rectangle = rectangles->rectangles[i];
+
+ argv[0] = rb_float_new (rectangle.x);
+ argv[1] = rb_float_new (rectangle.y);
+ argv[2] = rb_float_new (rectangle.width);
+ argv[3] = rb_float_new (rectangle.height);
+ rb_ary_push (rb_rectangles,
+ rb_class_new_instance (4, argv, rb_cCairo_Rectangle));
+ }
+ cairo_rectangle_list_destroy (rectangles);
+
+ return rb_rectangles;
+}
+#endif
+
/* Font/Text functions */
static VALUE
cr_select_font_face (int argc, VALUE *argv, VALUE self)
@@ -1067,6 +1124,34 @@
return rb_float_new (cairo_get_miter_limit (_SELF));
}
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+static VALUE
+cr_get_dash_count (VALUE self)
+{
+ int count;
+ cairo_get_dash_count (_SELF, &count);
+ cr_check_status (_SELF);
+ return INT2NUM (count);
+}
+
+static VALUE
+cr_get_dash (VALUE self)
+{
+ int count;
+ double *dashes, offset;
+
+ cairo_get_dash_count (_SELF, &count);
+ cr_check_status (_SELF);
+
+ dashes = ALLOCA_N (double, count);
+ cairo_get_dash (_SELF, dashes, &offset);
+
+ return rb_ary_new3 (2,
+ rb_cairo__float_array (dashes, count),
+ rb_float_new (offset));
+}
+#endif
+
static VALUE
cr_get_matrix (VALUE self)
{
@@ -1125,7 +1210,24 @@
Init_cairo_context (void)
{
cr_id_source_class = rb_intern ("source_class");
-
+
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+ rb_cCairo_Rectangle =
+ rb_define_class_under (rb_mCairo, "Rectangle", rb_cObject);
+ at_x = rb_intern ("@x");
+ at_y = rb_intern ("@y");
+ at_width = rb_intern ("@width");
+ at_height = rb_intern ("@height");
+
+ rb_define_attr (rb_cCairo_Rectangle, "x", CR_TRUE, CR_TRUE);
+ rb_define_attr (rb_cCairo_Rectangle, "y", CR_TRUE, CR_TRUE);
+ rb_define_attr (rb_cCairo_Rectangle, "width", CR_TRUE, CR_TRUE);
+ rb_define_attr (rb_cCairo_Rectangle, "height", CR_TRUE, CR_TRUE);
+
+ rb_define_method (rb_cCairo_Rectangle, "initialize",
+ cr_rectangle_initialize, 4);
+#endif
+
rb_cCairo_Context =
rb_define_class_under (rb_mCairo, "Context", rb_cObject);
@@ -1210,6 +1312,11 @@
rb_define_method (rb_cCairo_Context, "reset_clip", cr_reset_clip, 0);
rb_define_method (rb_cCairo_Context, "clip", cr_clip, 0);
rb_define_method (rb_cCairo_Context, "clip_preserve", cr_clip_preserve, 0);
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+ rb_define_method (rb_cCairo_Context, "clip_extents", cr_clip_extents, 0);
+ rb_define_method (rb_cCairo_Context, "clip_rectangles",
+ cr_clip_rectangles, 0);
+#endif
/* Font/Text functions */
rb_define_method (rb_cCairo_Context, "select_font_face",
@@ -1246,6 +1353,10 @@
rb_define_method (rb_cCairo_Context, "line_cap", cr_get_line_cap, 0);
rb_define_method (rb_cCairo_Context, "line_join", cr_get_line_join, 0);
rb_define_method (rb_cCairo_Context, "miter_limit", cr_get_miter_limit, 0);
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+ rb_define_method (rb_cCairo_Context, "dash_count", cr_get_dash_count, 0);
+ rb_define_method (rb_cCairo_Context, "dash", cr_get_dash, 0);
+#endif
rb_define_method (rb_cCairo_Context, "matrix", cr_get_matrix, 0);
rb_define_method (rb_cCairo_Context, "target", cr_get_target, 0);
rb_define_method (rb_cCairo_Context, "group_target", cr_get_group_target, 0);
Index: rb_cairo_exception.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_exception.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- rb_cairo_exception.c 31 May 2006 05:02:41 -0000 1.10
+++ rb_cairo_exception.c 21 Dec 2006 15:34:36 -0000 1.11
@@ -33,6 +33,10 @@
static VALUE rb_eCairo_FileNotFoundError;
static VALUE rb_eCairo_InvalidDashError;
static VALUE rb_eCairo_InvalidDscCommentError;
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+static VALUE rb_eCairo_InvalidIndexError;
+static VALUE rb_eCairo_ClipNotRepresentableError;
+#endif
void
rb_cairo_check_status (cairo_status_t status)
@@ -103,6 +107,14 @@
case CAIRO_STATUS_INVALID_DSC_COMMENT:
rb_raise (rb_eCairo_InvalidDscCommentError, string);
break;
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+ case CAIRO_STATUS_INVALID_INDEX:
+ rb_raise (rb_eCairo_InvalidIndexError, string);
+ break;
+ case CAIRO_STATUS_CLIP_NOT_REPRESENTABLE:
+ rb_raise (rb_eCairo_ClipNotRepresentableError, string);
+ break;
+#endif
}
}
@@ -168,5 +180,13 @@
rb_eArgError);
rb_eCairo_InvalidDscCommentError =
rb_define_class_under (rb_mCairo, "InvalidDscCommentError",
+ rb_eArgError);
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+ rb_eCairo_InvalidIndexError =
+ rb_define_class_under (rb_mCairo, "InvalidIndexError",
+ rb_eArgError);
+ rb_eCairo_ClipNotRepresentableError =
+ rb_define_class_under (rb_mCairo, "ClipNotRepresentableError",
rb_eCairo_Error);
+#endif
}
Index: rb_cairo_pattern.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_pattern.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- rb_cairo_pattern.c 19 Dec 2006 14:28:48 -0000 1.17
+++ rb_cairo_pattern.c 21 Dec 2006 15:34:36 -0000 1.18
@@ -307,6 +307,83 @@
return INT2NUM (cairo_pattern_get_filter (_SELF (self)));
}
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+static VALUE
+cr_solid_pattern_get_rgba (VALUE self)
+{
+ double red, green, blue, alpha;
+
+ rb_cairo_check_status (cairo_pattern_get_rgba (_SELF (self),
+ &red, &green, &blue, &alpha));
+ return rb_ary_new3 (4,
+ rb_float_new (red), rb_float_new (green),
+ rb_float_new (blue), rb_float_new (alpha));
+}
+
+static VALUE
+cr_surface_pattern_get_surface (VALUE self)
+{
+ cairo_surface_t *surface;
+
+ rb_cairo_check_status (cairo_pattern_get_surface (_SELF (self), &surface));
+ return CRSURFACE2RVAL (surface);
+}
+
+static VALUE
+cr_gradient_pattern_get_color_stop_rgba (VALUE self, VALUE index)
+{
+ cairo_status_t status;
+ double offset, red, green, blue, alpha;
+
+ status = cairo_pattern_get_color_stop_rgba (_SELF (self), NUM2INT (index),
+ &offset, &red, &green, &blue,
+ &alpha);
+ rb_cairo_check_status (status);
+ return rb_ary_new3 (5, rb_float_new (offset),
+ rb_float_new (red), rb_float_new (green),
+ rb_float_new (blue), rb_float_new (alpha));
+}
+
+static VALUE
+cr_gradient_pattern_get_color_stop_count (VALUE self)
+{
+ cairo_status_t status;
+ int count;
+
+ status = cairo_pattern_get_color_stop_count (_SELF (self), &count);
+ rb_cairo_check_status (status);
+ return INT2NUM (count);
+}
+
+static VALUE
+cr_linear_pattern_get_linear_points (VALUE self)
+{
+ cairo_status_t status;
+ double x0, y0, x1, y1;
+
+ status = cairo_pattern_get_linear_points (_SELF (self), &x0, &y0, &x1, &y1);
+ rb_cairo_check_status (status);
+ return rb_ary_new3 (4,
+ rb_float_new (x0), rb_float_new (y0),
+ rb_float_new (x1), rb_float_new (y1));
+}
+
+static VALUE
+cr_radial_pattern_get_radial_circles (VALUE self)
+{
+ cairo_status_t status;
+ double x0, y0, r0, x1, y1, r1;
+
+ status = cairo_pattern_get_radial_circles (_SELF (self),
+ &x0, &y0, &r0,
+ &x1, &y1, &r1);
+ rb_cairo_check_status (status);
+ return rb_ary_new3 (6,
+ rb_float_new (x0), rb_float_new (y0), rb_float_new (r0),
+ rb_float_new (x1), rb_float_new (y1), rb_float_new (r1));
+}
+#endif
+
/* Cairo::SurfacePattern */
/* none */
@@ -324,7 +401,7 @@
rb_define_method (rb_cCairo_Pattern, "set_matrix", cr_pattern_set_matrix, 1);
rb_define_method (rb_cCairo_Pattern, "matrix", cr_pattern_get_matrix, 0);
rb_define_method (rb_cCairo_Pattern, "set_extend", cr_pattern_set_extend, 1);
- rb_alias (rb_cCairo_Pattern, rb_intern ("__extend__"), rb_intern ("extend"));
+ rb_define_alias (rb_cCairo_Pattern, "__extend__", "extend");
rb_define_method (rb_cCairo_Pattern, "extend", cr_pattern_get_extend, 0);
rb_define_method (rb_cCairo_Pattern, "set_filter", cr_pattern_set_filter, 1);
rb_define_method (rb_cCairo_Pattern, "filter", cr_pattern_get_filter, 0);
@@ -336,6 +413,10 @@
rb_define_method (rb_cCairo_SolidPattern, "initialize",
cr_solid_pattern_initialize, -1);
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+ rb_define_method (rb_cCairo_SolidPattern, "rgba",
+ cr_solid_pattern_get_rgba, 0);
+#endif
RB_CAIRO_DEF_SETTERS (rb_cCairo_SolidPattern);
@@ -344,6 +425,10 @@
rb_define_method (rb_cCairo_SurfacePattern, "initialize",
cr_surface_pattern_initialize, 1);
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+ rb_define_method (rb_cCairo_SurfacePattern, "surface",
+ cr_surface_pattern_get_surface, 0);
+#endif
RB_CAIRO_DEF_SETTERS (rb_cCairo_SurfacePattern);
@@ -356,6 +441,13 @@
cr_gradient_pattern_add_color_stop_rgba, -1);
rb_define_alias (rb_cCairo_GradientPattern,
"add_color_stop", "add_color_stop_rgba");
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+ rb_define_method (rb_cCairo_GradientPattern, "get_color_stop_rgba",
+ cr_gradient_pattern_get_color_stop_rgba, 1);
+ rb_define_alias (rb_cCairo_GradientPattern, "[]", "get_color_stop_rgba");
+ rb_define_method (rb_cCairo_GradientPattern, "color_stop_count",
+ cr_gradient_pattern_get_color_stop_count, 0);
+#endif
RB_CAIRO_DEF_SETTERS (rb_cCairo_GradientPattern);
@@ -365,6 +457,10 @@
rb_define_method (rb_cCairo_LinearPattern, "initialize",
cr_linear_pattern_initialize, 4);
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+ rb_define_method (rb_cCairo_LinearPattern, "points",
+ cr_linear_pattern_get_linear_points, 0);
+#endif
RB_CAIRO_DEF_SETTERS (rb_cCairo_LinearPattern);
@@ -374,6 +470,10 @@
rb_define_method (rb_cCairo_RadialPattern, "initialize",
cr_radial_pattern_initialize, 6);
+#if CAIRO_CHECK_VERSION(1, 3, 0)
+ rb_define_method (rb_cCairo_RadialPattern, "circles",
+ cr_radial_pattern_get_radial_circles, 0);
+#endif
RB_CAIRO_DEF_SETTERS (rb_cCairo_RadialPattern);
}
Index: rb_cairo_private.h
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_private.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- rb_cairo_private.h 10 Oct 2005 15:40:26 -0000 1.3
+++ rb_cairo_private.h 21 Dec 2006 15:34:36 -0000 1.4
@@ -14,6 +14,9 @@
#ifndef RB_CAIRO_PRIVATE_H
#define RB_CAIRO_PRIVATE_H
+#define CR_TRUE 1
+#define CR_FALSE 0
+
VALUE rb_cairo__float_array (double *values, unsigned count);
void rb_cairo__glyphs_to_array (VALUE rb_array, cairo_glyph_t **glyphs, int *length);
Index: rb_cairo_surface.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_surface.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- rb_cairo_surface.c 27 Nov 2006 14:35:11 -0000 1.29
+++ rb_cairo_surface.c 21 Dec 2006 15:34:36 -0000 1.30
@@ -13,6 +13,8 @@
*/
#include "rb_cairo.h"
+#include "rb_cairo_private.h"
+
#include "rubyio.h"
#if CAIRO_HAS_PS_SURFACE || CAIRO_HAS_PDF_SURFACE || CAIRO_HAS_SVG_SURFACE
@@ -38,9 +40,6 @@
#define _SELF (RVAL2CRSURFACE(self))
-#define CR_TRUE 1
-#define CR_FALSE 0
-
static inline void
cr_surface_check_status (cairo_surface_t *surface)
{
More information about the cairo-commit
mailing list