[cairo-commit] rcairo/packages/cairo/ext extconf.rb, 1.9, 1.10 rb_cairo_context.c, 1.26, 1.27 rb_cairo_exception.c, 1.9, 1.10 rb_cairo_surface.c, 1.23, 1.24

Kouhei Sutou commit at pdx.freedesktop.org
Tue May 30 22:02:43 PDT 2006


Committed by: kou

Update of /cvs/cairo/rcairo/packages/cairo/ext
In directory kemper:/tmp/cvs-serv8751/packages/cairo/ext

Modified Files:
	extconf.rb rb_cairo_context.c rb_cairo_exception.c 
	rb_cairo_surface.c 
Log Message:
* README, packages/cairo/ext/extconf.rb: supported only 1.1.6 or
  higher.

* packages/cairo/ext/rb_cairo_context.c: supported
  cairo_push_group(), cairo_push_group_with_content(),
  cairo_pop_group(), cairo_pop_group_to_source() and
  cairo_get_group_target().

* packages/cairo/ext/rb_cairo_exception.c: supported
  CAIRO_STATUS_INVALID_DSC_COMMENT.

* packages/cairo/ext/rb_cairo_surface.c: supported
  cairo_surface_get_device_offset().


Index: extconf.rb
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/extconf.rb,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- extconf.rb	2 May 2006 05:37:02 -0000	1.9
+++ extconf.rb	31 May 2006 05:02:41 -0000	1.10
@@ -63,7 +63,7 @@
 
 pkg = "cairo"
 modname = "cairo"
-major, minor, micro = 1, 1, 2
+major, minor, micro = 1, 1, 6
 
 PKGConfig.have_package(pkg, major, minor, micro) or exit 1
 

Index: rb_cairo_context.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_context.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- rb_cairo_context.c	2 May 2006 05:37:02 -0000	1.26
+++ rb_cairo_context.c	31 May 2006 05:02:41 -0000	1.27
@@ -101,6 +101,58 @@
   return result;
 }
 
+static VALUE
+cr_pop_group (VALUE self)
+{
+  cairo_pop_group (_SELF);
+  cr_check_status (_SELF);
+  return Qnil;
+}
+
+static VALUE
+cr_pop_group_to_source (VALUE self)
+{
+  cairo_pop_group_to_source (_SELF);
+  cr_check_status (_SELF);
+  return Qnil;
+}
+
+static VALUE
+cr_pop_group_generic (int argc, VALUE *argv, VALUE self)
+{
+  VALUE to_source;
+  rb_scan_args (argc, argv, "01", &to_source);
+  if (RTEST(to_source))
+    return cr_pop_group_to_source (self);
+  else
+    return cr_pop_group (self);
+}
+
+static VALUE
+cr_push_group (int argc, VALUE *argv, VALUE self)
+{
+  VALUE result = Qnil;
+  VALUE content, pop_to_source;
+  rb_scan_args (argc, argv, "02", &content, &pop_to_source);
+
+  if (NIL_P(content))
+    cairo_push_group (_SELF);
+  else
+    cairo_push_group_with_content (_SELF, RVAL2CRCONTENT(content));
+  cr_check_status (_SELF);
+
+  if (rb_block_given_p ())
+    {
+      if (RTEST (pop_to_source))
+        result = rb_ensure (rb_yield, self, cr_pop_group_to_source, self);
+      else
+        result = rb_ensure (rb_yield, self, cr_pop_group, self);
+    }
+
+  return result;
+}
+
+
 /* Modify state */
 static VALUE
 cr_set_operator (VALUE self, VALUE operator)
@@ -1006,6 +1058,16 @@
   return CRSURFACE2RVAL (surface);
 }
 
+static VALUE
+cr_get_group_target (VALUE self)
+{
+  cairo_surface_t *surface;
+
+  surface = cairo_get_group_target (_SELF);
+  rb_cairo_check_status (cairo_surface_status (surface));
+  return CRSURFACE2RVAL (surface);
+}
+
 /* Paths */
 static VALUE
 cr_copy_path (VALUE self)
@@ -1046,6 +1108,10 @@
 
   rb_define_method (rb_cCairo_Context, "save", cr_save, 0);
   rb_define_method (rb_cCairo_Context, "restore", cr_restore, 0);
+  rb_define_method (rb_cCairo_Context, "push_group", cr_push_group, -1);
+  rb_define_method (rb_cCairo_Context, "pop_group", cr_pop_group_generic, -1);
+  rb_define_method (rb_cCairo_Context, "pop_group_to_source",
+                    cr_pop_group_to_source, 0);
 
   /* Modify state */
   rb_define_method (rb_cCairo_Context, "set_operator", cr_set_operator, 1);
@@ -1154,7 +1220,8 @@
   rb_define_method (rb_cCairo_Context, "miter_limit", cr_get_miter_limit, 0);
   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);
+
   /* Paths */
   rb_define_method (rb_cCairo_Context, "copy_path", cr_copy_path, 0);
   rb_define_method (rb_cCairo_Context, "copy_path_flat", cr_copy_path_flat, 0);

Index: rb_cairo_exception.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_exception.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- rb_cairo_exception.c	10 Oct 2005 15:40:26 -0000	1.9
+++ rb_cairo_exception.c	31 May 2006 05:02:41 -0000	1.10
@@ -32,6 +32,7 @@
 static VALUE rb_eCairo_InvalidVisualError;
 static VALUE rb_eCairo_FileNotFoundError;
 static VALUE rb_eCairo_InvalidDashError;
+static VALUE rb_eCairo_InvalidDscCommentError;
 
 void
 rb_cairo_check_status (cairo_status_t status)
@@ -99,6 +100,9 @@
     case CAIRO_STATUS_INVALID_DASH:
       rb_raise (rb_eCairo_InvalidDashError, string);
       break;
+    case CAIRO_STATUS_INVALID_DSC_COMMENT:
+      rb_raise (rb_eCairo_InvalidDscCommentError, string);
+      break;
     }
 }
 
@@ -162,4 +166,7 @@
   rb_eCairo_InvalidDashError =
     rb_define_class_under (rb_mCairo, "InvalidDashError",
                            rb_eArgError);
+  rb_eCairo_InvalidDscCommentError =
+    rb_define_class_under (rb_mCairo, "InvalidDscCommentError",
+                           rb_eCairo_Error);
 }

Index: rb_cairo_surface.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_surface.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- rb_cairo_surface.c	2 May 2006 05:37:02 -0000	1.23
+++ rb_cairo_surface.c	31 May 2006 05:02:41 -0000	1.24
@@ -453,6 +453,16 @@
   return self;
 }
 
+static VALUE
+cr_surface_get_device_offset (VALUE self)
+{
+  double x_offset, y_offset;
+
+  cairo_surface_get_device_offset (_SELF, &x_offset, &y_offset);
+  cr_surface_check_status (_SELF);
+  return rb_ary_new3 (2, rb_float_new (x_offset), rb_float_new (y_offset));
+}
+
 
 /* Image-surface functions */
 #if CAIRO_HAS_PNG_FUNCTIONS
@@ -655,6 +665,8 @@
   rb_define_method (rb_cCairo_Surface, "mark_dirty", cr_surface_mark_dirty, 0);
   rb_define_method (rb_cCairo_Surface, "set_device_offset",
                     cr_surface_set_device_offset, 2);
+  rb_define_method (rb_cCairo_Surface, "device_offset",
+                    cr_surface_get_device_offset, 0);
 
   /* Image-surface */
   rb_cCairo_ImageSurface =



More information about the cairo-commit mailing list