[cairo-commit] rcairo/packages/cairo/ext rb_cairo_surface.c, 1.31, 1.32

Kouhei Sutou commit at pdx.freedesktop.org
Sun Feb 4 01:53:05 PST 2007


Committed by: kou

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

Modified Files:
	rb_cairo_surface.c 
Log Message:
* packages/cairo/ext/rb_cairo_surface.c: the first argument of
  Cairo::ImageSurface#initialize, cairo_format_t, is optional.
* samples/*.rb: followed the change.


Index: rb_cairo_surface.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_surface.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- rb_cairo_surface.c	29 Dec 2006 12:37:25 -0000	1.31
+++ rb_cairo_surface.c	4 Feb 2007 09:53:00 -0000	1.32
@@ -471,7 +471,9 @@
 static cairo_surface_t *
 cr_image_surface_create (VALUE self, VALUE format, VALUE width, VALUE height)
 {
-  return cairo_image_surface_create (RVAL2CRFORMAT (format),
+  cairo_format_t cr_format;
+  cr_format = NIL_P (format) ? CAIRO_FORMAT_ARGB32 : RVAL2CRFORMAT (format);
+  return cairo_image_surface_create (cr_format,
                                      NUM2INT (width),
                                      NUM2INT (height));
 }
@@ -498,9 +500,11 @@
   VALUE arg1, arg2, arg3, arg4, arg5;
   int n;
   
-  n = rb_scan_args (argc, argv, "32", &arg1, &arg2, &arg3, &arg4, &arg5);
+  n = rb_scan_args (argc, argv, "23", &arg1, &arg2, &arg3, &arg4, &arg5);
 
-  if (n == 3)
+  if (n == 2)
+    surface = cr_image_surface_create (self, Qnil, arg1, arg2);
+  else if (n == 3)
     surface = cr_image_surface_create (self, arg1, arg2, arg3);
   else if (n == 5)
     surface =
@@ -508,6 +512,7 @@
   else
     rb_raise (rb_eArgError,
               "invalid argument (expect "
+              "(width, height) or "
               "(format, width, height) or "
               "(data, format, width, height, stride))");
 



More information about the cairo-commit mailing list