[cairo-commit] rcairo/src cairo.def, 1.9, 1.10 rb_cairo.h, 1.12, 1.13 rb_cairo_surface.c, 1.22, 1.23

Kouhei Sutou commit at pdx.freedesktop.org
Fri Feb 29 15:52:44 PST 2008


Committed by: kou

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

Modified Files:
	cairo.def rb_cairo.h rb_cairo_surface.c 
Log Message:
* src/rb_cairo_surface.c, src/cairo.def: Cairo::QuartzImageSurface will work.
* src/rb_cairo_surface.c: supported <= 1.5.12.


Index: cairo.def
===================================================================
RCS file: /cvs/cairo/rcairo/src/cairo.def,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- cairo.def	21 Feb 2008 13:30:19 -0000	1.9
+++ cairo.def	29 Feb 2008 23:54:13 -0000	1.10
@@ -29,6 +29,7 @@
     rb_cCairo_Win32Surface    DATA
     rb_cCairo_Win32PrintingSurface DATA
     rb_cCairo_QuartzSurface   DATA
+    rb_cCairo_QuartzImageSurface DATA
 
     rb_mCairo_Operator        DATA
     rb_mCairo_Antialias       DATA

Index: rb_cairo.h
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- rb_cairo.h	21 Feb 2008 13:30:19 -0000	1.12
+++ rb_cairo.h	29 Feb 2008 23:54:13 -0000	1.13
@@ -108,6 +108,7 @@
 /* For backward compatibility*/
 #define rb_cCairo_WIN32Surface rb_cCairo_Win32Surface
 RB_CAIRO_VAR VALUE rb_cCairo_QuartzSurface;
+RB_CAIRO_VAR VALUE rb_cCairo_QuartzImageSurface;
 
 RB_CAIRO_VAR VALUE rb_mCairo_Operator;
 RB_CAIRO_VAR VALUE rb_mCairo_Antialias;

Index: rb_cairo_surface.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_surface.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- rb_cairo_surface.c	24 Feb 2008 07:37:18 -0000	1.22
+++ rb_cairo_surface.c	29 Feb 2008 23:54:14 -0000	1.23
@@ -32,6 +32,7 @@
 VALUE rb_cCairo_Win32Surface = Qnil;
 VALUE rb_cCairo_Win32PrintingSurface = Qnil;
 VALUE rb_cCairo_QuartzSurface = Qnil;
+VALUE rb_cCairo_QuartzImageSurface = Qnil;
 
 static ID cr_id_target;
 static ID cr_id_read;
@@ -65,17 +66,33 @@
     case CAIRO_SURFACE_TYPE_PS:
       klass = rb_cCairo_PSSurface;
       break;
-    case CAIRO_SURFACE_TYPE_SVG:
-      klass = rb_cCairo_SVGSurface;
+    case CAIRO_SURFACE_TYPE_QUARTZ:
+      klass = rb_cCairo_QuartzSurface;
       break;
     case CAIRO_SURFACE_TYPE_WIN32:
       klass = rb_cCairo_Win32Surface;
       break;
+    case CAIRO_SURFACE_TYPE_SVG:
+      klass = rb_cCairo_SVGSurface;
+      break;
+#if CAIRO_CHECK_VERSION(1, 5, 2)
+    case CAIRO_SURFACE_TYPE_WIN32_PRINTING:
+      klass = rb_cCairo_Win32PrintingSurface;
+      break;
+#endif
+#if CAIRO_CHECK_VERSION(1, 5, 12)
+    case CAIRO_SURFACE_TYPE_QUARTZ_IMAGE:
+      klass = rb_cCairo_QuartzImageSurface;
+      break;
+#endif
     default:
       rb_raise (rb_eArgError, "unknown source type: %d", type);
       break;
     }
 
+  if (NIL_P (klass))
+    rb_raise (rb_eArgError, "unknown source type: %d", type);
+
   return klass;
 }
 
@@ -883,7 +900,7 @@
   surface = cairo_win32_surface_get_image (_SELF);
   if (!surface)
     return Qnil;
-  rb_cairo_check_status (cairo_surface_status (surface));
+  cr_surface_check_status (surface);
   return CRSURFACE2RVAL (surface);
 }
 #  endif
@@ -979,6 +996,33 @@
   objc_object = (id)context;
   return ocid_to_rbobj (Qnil, objc_object);
 }
+
+#  if CAIRO_CHECK_VERSION(1, 5, 12)
+static VALUE
+cr_quartz_image_surface_initialize (VALUE self, VALUE image_surface)
+{
+  cairo_surface_t *surface;
+
+  surface = cairo_quartz_image_surface_create (RVAL2CRSURFACE (image_surface));
+  cr_surface_check_status (surface);
+  DATA_PTR (self) = surface;
+  if (rb_block_given_p ())
+    yield_and_finish (self);
+  return Qnil;
+}
+
+static VALUE
+cr_quartz_image_surface_get_image (VALUE self)
+{
+  cairo_surface_t *surface;
+
+  surface = cairo_quartz_image_surface_get_image (_SELF);
+  if (!surface)
+    return Qnil;
+  cr_surface_check_status (surface);
+  return CRSURFACE2RVAL (surface);
+}
+#  endif
 #endif
 
 
@@ -1114,7 +1158,7 @@
   rb_cCairo_Win32PrintingSurface =
     rb_define_class_under (rb_mCairo, "Win32PrintingSurface", rb_cCairo_Surface);
 
-  rb_define_method (rb_cCairo_Win32PrintingSurfaceSurface, "initialize",
+  rb_define_method (rb_cCairo_Win32PrintingSurface, "initialize",
                     cr_win32_printing_surface_initialize, -1);
   rb_define_method (rb_cCairo_Win32PrintingSurface, "hdc",
                     cr_win32_surface_get_hdc, 0);
@@ -1132,5 +1176,16 @@
                     cr_quartz_surface_initialize, -1);
   rb_define_method (rb_cCairo_QuartzSurface, "cg_context",
                     cr_quartz_surface_get_cg_context, 0);
+
+#  if CAIRO_CHECK_VERSION(1, 5, 12)
+  rb_cCairo_QuartzImageSurface =
+    rb_define_class_under (rb_mCairo, "QuartzImageSurface", rb_cCairo_Surface);
+
+  rb_define_method (rb_cCairo_QuartzImageSurface, "initialize",
+                    cr_quartz_image_surface_initialize, 1);
+  rb_define_method (rb_cCairo_Win32PrintingSurface, "hdc",
+                    cr_quartz_image_surfaceE_get_image, 0);
+#  endif
+
 #endif
 }



More information about the cairo-commit mailing list