[cairo-commit] rcairo/packages/cairo/ext extconf.rb, 1.10, 1.11 rb_cairo_constants.c, 1.10, 1.11 rb_cairo_surface.c, 1.24, 1.25

Kouhei Sutou commit at pdx.freedesktop.org
Sun Jun 25 07:29:26 PDT 2006


Committed by: kou

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

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

* packages/cairo/ext/rb_cairo_constants.c: supported
  CAIRO_FORMAT_RGB16_565.

* packages/cairo/ext/rb_cairo_surface.c:
  - supported cairo_surface_get_content(),
    cairo_surface_set_fallback_resolution(),
    cairo_image_surface_get_data(),
    cairo_image_surface_get_format() and
    cairo_image_surface_get_stride().
  - removed cairo_ps_surface_set_dpi(),
    cairo_pdf_surface_set_dpi() and cairo_svg_surface_set_dpi()
    support.

* samples/png.rb: added Cairo::ImageSurface#data sample.


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

Index: rb_cairo_constants.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_constants.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- rb_cairo_constants.c	2 May 2006 05:37:02 -0000	1.10
+++ rb_cairo_constants.c	25 Jun 2006 14:29:24 -0000	1.11
@@ -282,6 +282,8 @@
                    INT2FIX (CAIRO_FORMAT_A8));
   rb_define_const (rb_mCairo,    "FORMAT_A1",
                    INT2FIX (CAIRO_FORMAT_A1));
+  rb_define_const (rb_mCairo,    "FORMAT_RGB16_565",
+                   INT2FIX (CAIRO_FORMAT_RGB16_565));
 
 
   /* cairo_pattern_type_t */

Index: rb_cairo_surface.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_surface.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- rb_cairo_surface.c	31 May 2006 05:02:41 -0000	1.24
+++ rb_cairo_surface.c	25 Jun 2006 14:29:24 -0000	1.25
@@ -348,6 +348,12 @@
   return INT2NUM (cairo_surface_get_type (_SELF));
 }
 
+static VALUE
+cr_surface_get_content (VALUE self)
+{
+  return INT2NUM (cairo_surface_get_content (_SELF));
+}
+
 
 #if CAIRO_HAS_PNG_FUNCTIONS
 static VALUE
@@ -463,6 +469,18 @@
   return rb_ary_new3 (2, rb_float_new (x_offset), rb_float_new (y_offset));
 }
 
+static VALUE
+cr_surface_set_fallback_resolution (VALUE self,
+                                    VALUE x_pixels_per_inch,
+                                    VALUE y_pixels_per_inch)
+{
+  cairo_surface_set_fallback_resolution (_SELF,
+                                         NUM2DBL (x_pixels_per_inch),
+                                         NUM2DBL (y_pixels_per_inch));
+  cr_surface_check_status (_SELF);
+  return self;
+}
+
 
 /* Image-surface functions */
 #if CAIRO_HAS_PNG_FUNCTIONS
@@ -562,6 +580,29 @@
 }
 
 static VALUE
+cr_image_surface_get_data (VALUE self)
+{
+  unsigned char *data;
+  cairo_surface_t *surface;
+
+  surface = _SELF;
+  data = cairo_image_surface_get_data (surface);
+
+  if (data)
+    return rb_str_new ((const char *)data,
+                       cairo_image_surface_get_stride (surface) *
+                       cairo_image_surface_get_height (surface));
+  else
+    return Qnil;
+}
+
+static VALUE
+cr_image_surface_get_format (VALUE self)
+{
+  return INT2NUM (cairo_image_surface_get_format (_SELF));
+}
+
+static VALUE
 cr_image_surface_get_width (VALUE self)
 {
   return INT2NUM (cairo_image_surface_get_width (_SELF));
@@ -573,7 +614,14 @@
   return INT2NUM (cairo_image_surface_get_height (_SELF));
 }
 
+static VALUE
+cr_image_surface_get_stride (VALUE self)
+{
+  return INT2NUM (cairo_image_surface_get_stride (_SELF));
+}
+
 
+/* Printing surfaces */
 #define DEFINE_SURFACE(type)                                              \
 static VALUE                                                              \
 cr_ ## type ## _surface_initialize (VALUE self, VALUE target,             \
@@ -614,18 +662,9 @@
   cr_surface_check_status (surface);                                      \
   DATA_PTR (self) = surface;                                              \
   return Qnil;                                                            \
-}                                                                         \
-                                                                          \
-static VALUE                                                              \
-cr_ ## type ## _surface_set_dpi (VALUE self, VALUE x_dpi, VALUE y_dpi)    \
-{                                                                         \
-  cairo_ ## type ## _surface_set_dpi (_SELF,                              \
-                                      NUM2DBL (x_dpi),                    \
-                                      NUM2DBL (y_dpi));                   \
-  cr_surface_check_status (_SELF);                                        \
-  return self;                                                            \
 }
 
+
 #if CAIRO_HAS_PS_SURFACE
 /* PS-surface functions */
 DEFINE_SURFACE(ps)
@@ -641,6 +680,7 @@
 DEFINE_SURFACE(svg)
 #endif
 
+
 void
 Init_cairo_surface (void)
 {
@@ -658,6 +698,7 @@
                     cr_surface_create_similar, 3);
   rb_define_method (rb_cCairo_Surface, "finish", cr_surface_finish, 0);
   rb_define_method (rb_cCairo_Surface, "type", cr_surface_get_type, 0);
+  rb_define_method (rb_cCairo_Surface, "content", cr_surface_get_content, 0);
 
   rb_define_method (rb_cCairo_Surface, "font_options",
                     cr_surface_get_font_options, 0);
@@ -667,6 +708,8 @@
                     cr_surface_set_device_offset, 2);
   rb_define_method (rb_cCairo_Surface, "device_offset",
                     cr_surface_get_device_offset, 0);
+  rb_define_method (rb_cCairo_Surface, "set_fallback_resolution",
+                    cr_surface_set_fallback_resolution, 2);
 
   /* Image-surface */
   rb_cCairo_ImageSurface =
@@ -680,11 +723,17 @@
   rb_define_method (rb_cCairo_ImageSurface, "initialize",
                     cr_image_surface_initialize, -1);
 
+  rb_define_method (rb_cCairo_ImageSurface, "data",
+                    cr_image_surface_get_data, 0);
+  rb_define_method (rb_cCairo_ImageSurface, "format",
+                    cr_image_surface_get_format, 0);
   rb_define_method (rb_cCairo_ImageSurface, "width",
                     cr_image_surface_get_width, 0);
   rb_define_method (rb_cCairo_ImageSurface, "height",
                     cr_image_surface_get_height, 0);
-  
+  rb_define_method (rb_cCairo_ImageSurface, "stride",
+                    cr_image_surface_get_stride, 0);
+
 #if CAIRO_HAS_PNG_FUNCTIONS
   rb_define_method (rb_cCairo_ImageSurface, "write_to_png",
                     cr_image_surface_write_to_png_generic, 1);
@@ -700,9 +749,7 @@
                cr_id_holder, rb_hash_new ());                           \
                                                                         \
   rb_define_method (rb_cCairo_ ## name ## Surface, "initialize",        \
-                    cr_ ## type ## _surface_initialize, 3);             \
-  rb_define_method (rb_cCairo_ ## name ## Surface, "set_dpi",           \
-                    cr_ ## type ## _surface_set_dpi, 2);
+                    cr_ ## type ## _surface_initialize, 3);
 
 #if CAIRO_HAS_PS_SURFACE
   /* PS-surface */



More information about the cairo-commit mailing list