[cairo-commit] rcairo/src cairo.def, 1.7, 1.8 rb_cairo.h, 1.10, 1.11 rb_cairo_constants.c, 1.5, 1.6 rb_cairo_context.c, 1.18, 1.19 rb_cairo_exception.c, 1.1, 1.2 rb_cairo_surface.c, 1.19, 1.20

Kouhei Sutou commit at pdx.freedesktop.org
Thu Feb 21 05:17:50 PST 2008


Committed by: kou

Update of /cvs/cairo/rcairo/src
In directory kemper:/tmp/cvs-serv1055/src

Modified Files:
	cairo.def rb_cairo.h rb_cairo_constants.c rb_cairo_context.c 
	rb_cairo_exception.c rb_cairo_surface.c 
Log Message:
* src/: supported <= 1.5.10.


Index: cairo.def
===================================================================
RCS file: /cvs/cairo/rcairo/src/cairo.def,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cairo.def	11 Jan 2008 12:18:34 -0000	1.7
+++ cairo.def	21 Feb 2008 13:18:10 -0000	1.8
@@ -45,6 +45,7 @@
     rb_mCairo_Extend          DATA
     rb_mCairo_Filter          DATA
     rb_mCairo_SVGVersion      DATA
+    rb_mCairo_PSLevel         DATA
 
     rb_mCairo_Color           DATA
     rb_cCairo_Color_Base      DATA
@@ -87,4 +88,5 @@
     rb_cairo_extend_from_ruby_object
     rb_cairo_filter_from_ruby_object
     rb_cairo_svg_version_from_ruby_object
+    rb_cairo_ps_level_from_ruby_object
     rb_cairo_check_status

Index: rb_cairo.h
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- rb_cairo.h	11 Jan 2008 12:18:34 -0000	1.10
+++ rb_cairo.h	21 Feb 2008 13:18:10 -0000	1.11
@@ -216,6 +216,11 @@
 #if CAIRO_HAS_SVG_SURFACE
 #define RVAL2CRSVGVERSION(obj)    (rb_cairo_svg_version_from_ruby_object(obj))
 #endif
+#if CAIRO_HAS_PS_SURFACE
+#  if CAIRO_CHECK_VERSION(1, 5, 2)
+#define RVAL2CRPSLEVEL(obj)       (rb_cairo_ps_level_from_ruby_object(obj))
+#  endif
+#endif
 
 cairo_operator_t       rb_cairo_operator_from_ruby_object       (VALUE obj);
 cairo_antialias_t      rb_cairo_antialias_from_ruby_object      (VALUE obj);
@@ -235,6 +240,11 @@
 #if CAIRO_HAS_SVG_SURFACE
 cairo_svg_version_t    rb_cairo_svg_version_from_ruby_object    (VALUE obj);
 #endif
+#if CAIRO_HAS_PS_SURFACE
+#  if CAIRO_CHECK_VERSION(1, 5, 2)
+cairo_ps_level_t       rb_cairo_ps_level_from_ruby_object       (VALUE obj);
+#  endif
+#endif
 
 void rb_cairo_check_status (cairo_status_t status);
 

Index: rb_cairo_constants.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_constants.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- rb_cairo_constants.c	20 May 2007 09:18:49 -0000	1.5
+++ rb_cairo_constants.c	21 Feb 2008 13:18:10 -0000	1.6
@@ -31,7 +31,8 @@
 VALUE rb_mCairo_Format;
 VALUE rb_mCairo_Extend;
 VALUE rb_mCairo_Filter;
-VALUE rb_mCairo_SVGVersion;
+VALUE rb_mCairo_SVGVersion = Qnil;
+VALUE rb_mCairo_PSLevel = Qnil;
 
 #define CAIRO_OPERATOR_MIN CAIRO_OPERATOR_CLEAR
 #define CAIRO_OPERATOR_MAX CAIRO_OPERATOR_SATURATE
@@ -81,6 +82,9 @@
 #define CAIRO_SVG_VERSION_MIN CAIRO_SVG_VERSION_1_1
 #define CAIRO_SVG_VERSION_MAX CAIRO_SVG_VERSION_1_2
 
+#define CAIRO_PS_LEVEL_MIN CAIRO_PS_LEVEL_2
+#define CAIRO_PS_LEVEL_MAX CAIRO_PS_LEVEL_3
+
 #define DEFINE_RVAL2ENUM(name, const_name)                      \
 cairo_ ## name ## _t                                            \
 rb_cairo_ ## name ## _from_ruby_object (VALUE rb_ ## name)      \
@@ -123,6 +127,96 @@
 #if CAIRO_HAS_SVG_SURFACE
 DEFINE_RVAL2ENUM(svg_version, SVG_VERSION)
 #endif
+#if CAIRO_HAS_PS_SURFACE
+#  if CAIRO_CHECK_VERSION(1, 5, 2)
+DEFINE_RVAL2ENUM(ps_level, PS_LEVEL)
+#  endif
+#endif
+
+
+#if CAIRO_HAS_SVG_SURFACE
+static VALUE
+cr_svg_get_versions (VALUE self)
+{
+  VALUE rb_versions;
+  int i, num_versions;
+  cairo_svg_version_t const *versions;
+
+  cairo_svg_get_versions (&versions, &num_versions);
+
+  rb_versions = rb_ary_new2 (num_versions);
+
+  for (i = 0; i < num_versions; i++)
+    {
+      rb_ary_push (rb_versions, INT2NUM (versions[i]));
+    }
+
+  return rb_versions;
+}
+
+static VALUE
+cr_svg_version_to_string (int argc, VALUE *argv, VALUE self)
+{
+  if (argc == 0)
+    {
+      return rb_call_super (argc, argv);
+    }
+  else
+    {
+      VALUE version;
+      const char *ver_str;
+      rb_scan_args (argc, argv, "1", &version);
+      ver_str = cairo_svg_version_to_string (RVAL2CRSVGVERSION(version));
+      return rb_str_new2 (ver_str);
+    }
+}
+#endif
+
+#if CAIRO_CHECK_VERSION(1, 5, 8)
+static VALUE
+cr_format_stride_for_width (VALUE self, VALUE format, VALUE width)
+{
+  return INT2NUM (cairo_format_stride_for_width (RVAL2CRFORMAT (format),
+                                                 NUM2INT (width)));
+}
+#endif
+
+#if CAIRO_HAS_PS_SURFACE
+#  if CAIRO_CHECK_VERSION(1, 5, 8)
+static VALUE
+cr_ps_get_levels (VALUE self)
+{
+  VALUE rb_levels;
+  const cairo_ps_level_t *levels;
+  int i, n_levels;
+
+  cairo_ps_get_levels (&levels, &n_levels);
+
+  rb_levels = rb_ary_new2 (n_levels);
+  for (i = 0; i < n_levels; i++)
+    {
+      rb_ary_push (rb_levels, INT2NUM (levels[i]));
+    }
+
+  return rb_levels;
+}
+
+static VALUE
+cr_ps_level_to_string (int argc, VALUE *argv, VALUE self)
+{
+  if (argc == 0)
+    {
+      return rb_call_super (argc, argv);
+    }
+  else
+    {
+      VALUE level;
+      rb_scan_args (argc, argv, "1", &level);
+      return rb_str_new2 (cairo_ps_level_to_string (RVAL2CRPSLEVEL (level)));
+    }
+}
+#  endif
+#endif
 
 void
 Init_cairo_constants (void)
@@ -295,6 +389,11 @@
                    INT2FIX (CAIRO_FORMAT_RGB16_565));
 #endif
 
+#if CAIRO_CHECK_VERSION(1, 5, 8)
+  rb_define_singleton_method (rb_mCairo_Format, "stride_for_width",
+                              cr_format_stride_for_width, 2);
+#endif
+
 
   /* cairo_extend_t */
   rb_mCairo_Extend = rb_define_module_under (rb_mCairo, "Extend");
@@ -330,5 +429,24 @@
                    INT2FIX (CAIRO_SVG_VERSION_1_1));
   rb_define_const (rb_mCairo_SVGVersion, "VERSION_1_2",
                    INT2FIX (CAIRO_SVG_VERSION_1_2));
+
+  rb_define_singleton_method (rb_mCairo_SVGVersion, "list",
+                              cr_svg_get_versions, 0);
+  rb_define_singleton_method (rb_mCairo_SVGVersion, "name",
+                              cr_svg_version_to_string, -1);
+#endif
+
+#if CAIRO_HAS_PS_SURFACE
+#  if CAIRO_CHECK_VERSION(1, 5, 2)
+  /* cairo_ps_level_t */
+  rb_mCairo_PSLevel = rb_define_module_under (rb_mCairo, "PSLevel");
+  rb_define_const (rb_mCairo_PSLevel, "LEVEL_2", INT2FIX (CAIRO_PS_LEVEL_2));
+  rb_define_const (rb_mCairo_PSLevel, "LEVEL_3", INT2FIX (CAIRO_PS_LEVEL_3));
+
+  rb_define_singleton_method (rb_mCairo_PSLevel, "list",
+                              cr_ps_get_levels, 0);
+  rb_define_singleton_method (rb_mCairo_PSLevel, "name",
+                              cr_ps_level_to_string, -1);
+#  endif
 #endif
 }

Index: rb_cairo_context.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_context.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- rb_cairo_context.c	29 Dec 2007 11:42:26 -0000	1.18
+++ rb_cairo_context.c	21 Feb 2008 13:18:10 -0000	1.19
@@ -738,6 +738,19 @@
   return self;
 }
 
+#if CAIRO_CHECK_VERSION(1, 5, 8)
+static VALUE
+cr_path_extents (VALUE self)
+{
+  double x1, y1, x2, y2;
+  cairo_path_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));
+}
+#endif
+
 /* Painting functions */
 static VALUE
 cr_paint (VALUE self)
@@ -1216,8 +1229,16 @@
 static VALUE
 cr_get_antialias(VALUE self)
 {
-  return INT2NUM (cairo_get_antialias(_SELF));
+  return INT2NUM (cairo_get_antialias (_SELF));
+}
+
+#if CAIRO_CHECK_VERSION(1, 5, 10)
+static VALUE
+cr_has_current_point(VALUE self)
+{
+  return RTEST (cairo_has_current_point (_SELF));
 }
+#endif
 
 static VALUE
 cr_get_current_point (VALUE self)
@@ -1438,6 +1459,9 @@
                     cr_rel_curve_to_generic, -1);
   rb_define_method (rb_cCairo_Context, "rectangle", cr_rectangle, 4);
   rb_define_method (rb_cCairo_Context, "close_path", cr_close_path, 0);
+#if CAIRO_CHECK_VERSION(1, 5, 8)
+  rb_define_method (rb_cCairo_Context, "path_extents", cr_path_extents, 0);
+#endif
 
   /* Painting functions */
   rb_define_method (rb_cCairo_Context, "paint", cr_paint_generic, -1);
@@ -1494,6 +1518,12 @@
   rb_define_method (rb_cCairo_Context, "source", cr_get_source, 0);
   rb_define_method (rb_cCairo_Context, "tolerance", cr_get_tolerance, 0);
   rb_define_method (rb_cCairo_Context, "antialias", cr_get_antialias, 0);
+#if CAIRO_CHECK_VERSION(1, 5, 10)
+  rb_define_method (rb_cCairo_Context, "have_current_point?",
+                    cr_has_current_point, 0);
+  rb_define_alias (rb_cCairo_Context,
+                   "has_current_point?", "have_current_point?");
+#endif
   rb_define_method (rb_cCairo_Context, "current_point",
                     cr_get_current_point, 0);
   rb_define_method (rb_cCairo_Context, "fill_rule", cr_get_fill_rule, 0);

Index: rb_cairo_exception.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_exception.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- rb_cairo_exception.c	6 Mar 2007 12:17:34 -0000	1.1
+++ rb_cairo_exception.c	21 Feb 2008 13:18:10 -0000	1.2
@@ -37,6 +37,10 @@
 static VALUE rb_eCairo_InvalidIndexError;
 static VALUE rb_eCairo_ClipNotRepresentableError;
 #endif
+#if CAIRO_CHECK_VERSION(1, 5, 6)
+static VALUE rb_eCairo_TempFileError;
+static VALUE rb_eCairo_InvalidStrideError;
+#endif
 
 void
 rb_cairo_check_status (cairo_status_t status)
@@ -115,6 +119,14 @@
       rb_raise (rb_eCairo_ClipNotRepresentableError, string);
       break;
 #endif
+#if CAIRO_CHECK_VERSION(1, 5, 6)
+    case CAIRO_STATUS_TEMP_FILE_ERROR:
+      rb_raise (rb_eCairo_TempFileError, string);
+      break;
+    case CAIRO_STATUS_INVALID_STRIDE:
+      rb_raise (rb_eCairo_InvalidStringError, string);
+      break;
+#endif
     }
 }
 
@@ -189,4 +201,14 @@
     rb_define_class_under (rb_mCairo, "ClipNotRepresentableError",
                            rb_eCairo_Error);
 #endif
+
+#if CAIRO_CHECK_VERSION(1, 5, 6)
+  rb_eCairo_TempFileError =
+    rb_define_class_under (rb_mCairo, "TempFileError",
+                           rb_eCairo_Error);
+
+  rb_eCairo_InvalidStrideError =
+        rb_define_class_under (rb_mCairo, "InvalidStrideError",
+                               rb_eArgError);
+#endif
 }

Index: rb_cairo_surface.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_surface.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- rb_cairo_surface.c	18 Jan 2008 05:04:25 -0000	1.19
+++ rb_cairo_surface.c	21 Feb 2008 13:18:10 -0000	1.20
@@ -444,6 +444,23 @@
   return self;
 }
 
+#if CAIRO_CHECK_VERSION(1, 5, 2)
+static VALUE
+cr_surface_copy_page (VALUE self)
+{
+  cairo_surface_copy_page (_SELF);
+  cr_surface_check_status (_SELF);
+  return self;
+}
+
+static VALUE
+cr_surface_show_page (VALUE self)
+{
+  cairo_surface_show_page (_SELF);
+  cr_surface_check_status (_SELF);
+  return self;
+}
+#endif
 
 /* Image-surface functions */
 #if CAIRO_HAS_PNG_FUNCTIONS
@@ -488,7 +505,6 @@
 }
 #endif
 
-
 static cairo_surface_t *
 cr_image_surface_create (VALUE self, VALUE format, VALUE width, VALUE height)
 {
@@ -684,6 +700,24 @@
   else
     return Qnil;
 }
+
+#  if CAIRO_CHECK_VERSION(1, 5, 2)
+static VALUE
+cr_ps_surface_restrict_to_level (VALUE self, VALUE level)
+{
+  cairo_ps_surface_restrict_to_level (_SELF, RVAL2CRPSLEVEL (level));
+  cr_surface_check_status (_SELF);
+  return Qnil;
+}
+
+static VALUE
+cr_ps_surface_set_eps (VALUE self, VALUE eps)
+{
+  cairo_ps_surface_set_eps (_SELF, RTEST (eps));
+  cr_surface_check_status (_SELF);
+  return Qnil;
+}
+#  endif
 #endif
 
 #if CAIRO_HAS_PDF_SURFACE
@@ -714,33 +748,6 @@
   cr_surface_check_status (_SELF);
   return Qnil;
 }
-
-static VALUE
-cr_svg_get_versions (VALUE self)
-{
-  VALUE rb_versions;
-  int i, num_versions;
-  cairo_svg_version_t const *versions;
-
-  cairo_svg_get_versions (&versions, &num_versions);
-
-  rb_versions = rb_ary_new2 (num_versions);
-
-  for (i = 0; i < num_versions; i++)
-    {
-      rb_ary_push (rb_versions, INT2NUM (versions[i]));
-    }
-
-  return rb_versions;
-}
-
-static VALUE
-cr_svg_version_to_string (VALUE self, VALUE version)
-{
-  const char *ver_str;
-  ver_str = cairo_svg_version_to_string (RVAL2CRSVGVERSION(version));
-  return rb_str_new2 (ver_str);
-}
 #endif
 
 #if CAIRO_HAS_WIN32_SURFACE
@@ -971,6 +978,12 @@
                     cr_surface_get_device_offset, 0);
   rb_define_method (rb_cCairo_Surface, "set_fallback_resolution",
                     cr_surface_set_fallback_resolution, 2);
+#if CAIRO_CHECK_VERSION(1, 5, 2)
+  rb_define_method (rb_cCairo_Surface, "copy_page",
+                    cr_surface_copy_page, 2);
+  rb_define_method (rb_cCairo_Surface, "show_page",
+                    cr_surface_show_page, 2);
+#endif
 
 #if CAIRO_HAS_PNG_FUNCTIONS
   rb_define_method (rb_cCairo_Surface, "write_to_png",
@@ -1022,6 +1035,13 @@
   rb_define_method (rb_cCairo_PSSurface, "dsc_begin_page_setup",
                     cr_ps_surface_dsc_begin_page_setup, 0);
 
+#if CAIRO_CHECK_VERSION(1, 5, 2)
+  rb_define_method (rb_cCairo_PSSurface, "restrict_to_level",
+                    cr_ps_surface_restrict_to_level, 1);
+  rb_define_method (rb_cCairo_PSSurface, "set_eps",
+                    cr_ps_surface_set_eps, 1);
+#endif
+
   RB_CAIRO_DEF_SETTERS (rb_cCairo_PSSurface);
 #endif
 
@@ -1039,11 +1059,6 @@
   /* SVG-surface */
   INIT_SURFACE(svg, SVG)
 
-  rb_define_singleton_method (rb_cCairo_SVGSurface, "versions",
-                              cr_svg_get_versions, 0);
-  rb_define_singleton_method (rb_cCairo_SVGSurface, "version_to_string",
-                              cr_svg_version_to_string, 1);
-
   rb_define_method (rb_cCairo_SVGSurface, "restrict_to_version",
                     cr_svg_surface_restrict_to_version, 1);
 



More information about the cairo-commit mailing list