[cairo-commit] rcairo/src rb_cairo_context.c,1.6,1.7

Kouhei Sutou commit at pdx.freedesktop.org
Thu Apr 19 05:40:45 PDT 2007


Committed by: kou

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

Modified Files:
	rb_cairo_context.c 
Log Message:
* src/rb_cairo_context.c (Cairo::Context#stroke,
  Cairo::Context#fill, Cairo::Context#clip): accept 'prserve' option
  to change XXX and XXX_preserve.
* src/lib/cairo/context.rb (Cairo::Context#stroke_preserve,
  Cairo::Context#fill_preserve, Cairo::Context#clip_preserve): moved
  from src/rb_cairo_context.c.


Index: rb_cairo_context.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_context.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- rb_cairo_context.c	16 Apr 2007 03:12:49 -0000	1.6
+++ rb_cairo_context.c	19 Apr 2007 12:40:35 -0000	1.7
@@ -707,58 +707,50 @@
 }
 
 static VALUE
-cr_stroke (VALUE self)
+cr_stroke (int argc, VALUE *argv, VALUE self)
 {
-  if (rb_block_given_p ())
-    {
-      cr_new_path (self);
-      rb_yield (self);
-    }
-  cairo_stroke (_SELF);
-  cr_check_status (_SELF);
-  return self;
-}
+  VALUE preserve;
+
+  rb_scan_args (argc, argv, "01", &preserve);
 
-static VALUE
-cr_stroke_preserve (VALUE self)
-{
   if (rb_block_given_p ())
     {
       cr_new_path (self);
       rb_yield (self);
     }
-  cairo_stroke_preserve (_SELF);
+
+  if (RTEST (preserve))
+    cairo_stroke_preserve (_SELF);
+  else
+    cairo_stroke (_SELF);
+
   cr_check_status (_SELF);
   return self;
 }
 
 static VALUE
-cr_fill (VALUE self)
+cr_fill (int argc, VALUE *argv, VALUE self)
 {
-  if (rb_block_given_p ())
-    {
-      cr_new_path (self);
-      rb_yield (self);
-    }
-  cairo_fill (_SELF);
-  cr_check_status (_SELF);
-  return self;
-}
+  VALUE preserve;
 
+  rb_scan_args (argc, argv, "01", &preserve);
 
-static VALUE
-cr_fill_preserve (VALUE self)
-{
   if (rb_block_given_p ())
     {
       cr_new_path (self);
       rb_yield (self);
     }
-  cairo_fill_preserve (_SELF);
+
+  if (RTEST (preserve))
+    cairo_fill_preserve (_SELF);
+  else
+    cairo_fill (_SELF);
+
   cr_check_status (_SELF);
   return self;
 }
 
+
 static VALUE
 cr_copy_page (VALUE self)
 {
@@ -835,27 +827,23 @@
 }
 
 static VALUE
-cr_clip (VALUE self)
+cr_clip (int argc, VALUE *argv, VALUE self)
 {
-  if (rb_block_given_p ())
-    {
-      cr_new_path (self);
-      rb_yield (self);
-    }
-  cairo_clip (_SELF);
-  cr_check_status (_SELF);
-  return self;
-}
+  VALUE preserve;
+
+  rb_scan_args(argc, argv, "01", &preserve);
 
-static VALUE
-cr_clip_preserve (VALUE self)
-{
   if (rb_block_given_p ())
     {
       cr_new_path (self);
       rb_yield (self);
     }
-  cairo_clip_preserve (_SELF);
+
+  if (RTEST (preserve))
+    cairo_clip_preserve(_SELF);
+  else
+    cairo_clip (_SELF);
+
   cr_check_status (_SELF);
   return self;
 }
@@ -1335,11 +1323,8 @@
   /* Painting functions */
   rb_define_method (rb_cCairo_Context, "paint", cr_paint_generic, -1);
   rb_define_method (rb_cCairo_Context, "mask", cr_mask_generic, -1);
-  rb_define_method (rb_cCairo_Context, "stroke", cr_stroke, 0);
-  rb_define_method (rb_cCairo_Context, "stroke_preserve",
-                    cr_stroke_preserve, 0);
-  rb_define_method (rb_cCairo_Context, "fill", cr_fill, 0);
-  rb_define_method (rb_cCairo_Context, "fill_preserve", cr_fill_preserve, 0);
+  rb_define_method (rb_cCairo_Context, "stroke", cr_stroke, -1);
+  rb_define_method (rb_cCairo_Context, "fill", cr_fill, -1);
   rb_define_method (rb_cCairo_Context, "copy_page", cr_copy_page, 0);
   rb_define_method (rb_cCairo_Context, "show_page", cr_show_page, 0);
 
@@ -1353,8 +1338,7 @@
 
   /* Clipping */
   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);
+  rb_define_method (rb_cCairo_Context, "clip", cr_clip, -1);
 #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_rectangle_list",



More information about the cairo-commit mailing list