[DRE-commits] [ruby-cairo] 05/13: New upstream version 1.14.2

Daisuke Higuchi dai at moszumanska.debian.org
Wed Oct 26 05:57:08 UTC 2016


This is an automated email from the git hooks/post-receive script.

dai pushed a commit to branch master
in repository ruby-cairo.

commit 2a08a7363f49186cfcd6173683dad8efec622977
Author: HIGUCHI Daisuke (VDR dai) <dai at debian.org>
Date:   Wed Oct 26 12:41:39 2016 +0900

    New upstream version 1.14.2
---
 .travis.yml                                     |   2 +-
 NEWS                                            |  21 ++
 Rakefile                                        |  23 +-
 build/Vagrantfile                               |   4 +-
 build/build-windows.sh                          |   4 +-
 ext/cairo/cairo.def                             |   1 +
 ext/cairo/extconf.rb                            |  33 ++-
 ext/cairo/rb_cairo.c                            |   3 +
 ext/cairo/rb_cairo.h                            |   6 +-
 ext/cairo/rb_cairo_context.c                    |   2 +-
 ext/cairo/rb_cairo_io.c                         |   4 +
 ext/cairo/rb_cairo_io.h                         |   2 +
 ext/cairo/rb_cairo_pattern.c                    |   8 +-
 ext/cairo/rb_cairo_private.h                    |   2 +
 ext/cairo/rb_cairo_quartz_surface.m             | 207 +++++++++++++++++
 ext/cairo/rb_cairo_surface.c                    | 296 +++++-------------------
 lib/cairo.rb                                    |  39 ++--
 lib/cairo/region.rb                             |  14 ++
 patches/cairo-1.14-missing-exeext-float-m4.diff |  17 --
 test/test_region.rb                             |  26 +++
 20 files changed, 417 insertions(+), 297 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 5c34277..be18ced 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
 notifications:
   recipients:
-    - ruby-gnome2-cvs at lists.sourceforge.net
+    - rcairo at ml.commit-email.info
 rvm:
   - 2.0.0
   - 2.1
diff --git a/NEWS b/NEWS
index 92a790a..0512554 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,24 @@
+Release 1.14.2 (2015-09-06) Kouhei Sutou <kou at cozmixng.org>
+===========================================================
+
+Improvements
+------------
+
+ * Supported showing command execution result on failure.
+   [GitHub#36][Reported by Paul McMahon]
+ * Cairo::Region#each_rectangle: Added a convenience method.
+ * Cairo::Region#rectangles: Added a convenience method.
+ * Supported Pathname as output target for surface.
+   [GitHub#37][Reported by scivola]
+ * Exported rb_cairo_surface_check_status().
+ * Windows: Upgraded bundled libraries.
+
+Thanks
+------
+
+ * Paul McMahon
+ * scivola
+
 Release 1.14.1 (2014-12-23) Kouhei Sutou <kou at cozmixng.org>
 ===========================================================
 
diff --git a/Rakefile b/Rakefile
index 7af9004..1bb203e 100644
--- a/Rakefile
+++ b/Rakefile
@@ -450,16 +450,16 @@ windows_task = WindowsTask.new(spec) do |task|
     },
     {
       :name => "libpng",
-      :version => "1.6.16",
-      :download_base_url => "http://sourceforge.net/projects/libpng/files/libpng16/1.6.16",
+      :version => "1.6.18",
+      :download_base_url => "http://sourceforge.net/projects/libpng/files/libpng16/1.6.18",
       :windows => {
         :built_file => "bin/libpng16-16.dll",
       },
     },
     {
       :name => "freetype",
-      :version => "2.5.4",
-      :download_base_url => "http://sourceforge.net/projects/freetype/files/freetype2/2.5.4",
+      :version => "2.6",
+      :download_base_url => "http://sourceforge.net/projects/freetype/files/freetype2/2.6",
       :compression_method => "bz2",
       :windows => {
         :built_file => "bin/libfreetype-6.dll",
@@ -509,7 +509,7 @@ windows_task = WindowsTask.new(spec) do |task|
     },
     {
       :name => "cairo",
-      :version => "1.14.0",
+      :version => "1.14.2",
       :download_site => :cairo,
       :windows => {
         :built_file => "bin/libcairo-2.dll",
@@ -517,7 +517,6 @@ windows_task = WindowsTask.new(spec) do |task|
           "--enable-gobject",
         ],
         :patches => [
-          "cairo-1.14-missing-exeext-float-m4.diff"
         ],
         :need_autoreconf => true,
       },
@@ -526,6 +525,18 @@ windows_task = WindowsTask.new(spec) do |task|
 end
 windows_task.define
 
+namespace :vm do
+  namespace :windows do
+    desc "Build all packages for Windows in VM"
+    task :build do
+      cd("build") do
+        sh("vagrant", "destroy", "--force")
+        sh("vagrant", "up")
+      end
+    end
+  end
+end
+
 # for releasing
 task :dist do
   sh "./dist.sh", spec.version.to_s
diff --git a/build/Vagrantfile b/build/Vagrantfile
index 6f8cfb8..ebdda9e 100644
--- a/build/Vagrantfile
+++ b/build/Vagrantfile
@@ -12,8 +12,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
 
   targets.each do |target|
     config.vm.define(target) do |node|
-      node.vm.box = "ubuntu-14.10-x86_64"
-      node.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.10_chef-provisionerless.box"
+      node.vm.box = "ubuntu-15.04-x86_64"
+      node.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-15.04_chef-provisionerless.box"
 
       node.vm.synced_folder("../", "/rcairo")
       node.vm.synced_folder("../../pkg-config", "/pkg-config")
diff --git a/build/build-windows.sh b/build/build-windows.sh
index 090b41a..717c49f 100755
--- a/build/build-windows.sh
+++ b/build/build-windows.sh
@@ -3,8 +3,8 @@
 export LANG=C
 export DEBIAN_FRONTEND=noninteractive
 
-ruby_versions="2.0.0-p598 2.1.5 2.2.0-preview1"
-export RUBY_CC_VERSION="2.0.0:2.1.5:2.2.0"
+ruby_versions="2.0.0-p647 2.1.7 2.2.3"
+export RUBY_CC_VERSION="2.0.0:2.1.7:2.2.3"
 
 N_CPUS=$(grep '^processor' /proc/cpuinfo | wc -l)
 export MAKE_N_JOBS=${N_CPUS}
diff --git a/ext/cairo/cairo.def b/ext/cairo/cairo.def
index 0b66b59..656211e 100644
--- a/ext/cairo/cairo.def
+++ b/ext/cairo/cairo.def
@@ -138,3 +138,4 @@ EXPORTS
     rb_cairo_pdf_version_from_ruby_object
     rb_cairo_text_cluster_flags_from_ruby_object
     rb_cairo_check_status
+    rb_cairo_surface_check_status
diff --git a/ext/cairo/extconf.rb b/ext/cairo/extconf.rb
index b8a66d1..ccdf26d 100755
--- a/ext/cairo/extconf.rb
+++ b/ext/cairo/extconf.rb
@@ -103,16 +103,24 @@ def install_missing_native_package(native_package_info)
   installing_message = "installing '#{package}' native package... "
   message("%s", installing_message)
   failed_to_get_super_user_priviledge = false
-  if have_priviledge
-    succeeded = xsystem(install_command)
-  else
-    if sudo
-      install_command = "#{sudo} #{install_command}"
+
+  succeeded = false
+  execution_result = ""
+  File.open("mkmf.log") do |log|
+    log.seek(0, IO::SEEK_END)
+    if have_priviledge
       succeeded = xsystem(install_command)
     else
-      succeeded = false
-      failed_to_get_super_user_priviledge = true
+      if sudo
+        install_command = "#{sudo} #{install_command}"
+        succeeded = xsystem(install_command)
+      else
+        succeeded = false
+        failed_to_get_super_user_priviledge = true
+      end
     end
+    executed_command_line = log.gets
+    execution_result = log.read
   end
 
   if failed_to_get_super_user_priviledge
@@ -130,12 +138,15 @@ def install_missing_native_package(native_package_info)
     if failed_to_get_super_user_priviledge
       error_message = <<-EOM
 '#{package}' native package is required.
-run the following command as super user to install required native package:
+Run the following command as super user to install required native package:
   \# #{install_command}
 EOM
     else
       error_message = <<-EOM
-failed to run '#{install_command}'.
+Failed to run '#{install_command}':
+--
+#{execution_result.chomp}
+--
 EOM
     end
   end
@@ -177,7 +188,7 @@ checking_for(checking_message("Mac OS X")) do
     if have_macro("CAIRO_HAS_QUARTZ_SURFACE", ["cairo.h"])
       checking_for("RubyCocoa") do
         begin
-          require 'osx/cocoa'
+          require "osx/cocoa"
           $defs << "-DHAVE_RUBY_COCOA"
           $DLDFLAGS << " -Wl,-framework,RubyCocoa"
           true
@@ -188,6 +199,8 @@ checking_for(checking_message("Mac OS X")) do
     end
     true
   else
+    MakeMakefile::C_EXT.delete("m")
+    MakeMakefile::SRC_EXT.delete("m")
     false
   end
 end
diff --git a/ext/cairo/rb_cairo.c b/ext/cairo/rb_cairo.c
index e6898fc..c46f571 100644
--- a/ext/cairo/rb_cairo.c
+++ b/ext/cairo/rb_cairo.c
@@ -99,6 +99,9 @@ Init_cairo ()
   Init_cairo_region ();
   Init_cairo_device ();
   Init_cairo_surface ();
+#ifdef CAIRO_HAS_QUARTZ_SURFACE
+  Init_cairo_quartz_surface ();
+#endif
   Init_cairo_exception ();
   Init_cairo_font ();
   Init_cairo_font_extents ();
diff --git a/ext/cairo/rb_cairo.h b/ext/cairo/rb_cairo.h
index 7791454..821e5d4 100644
--- a/ext/cairo/rb_cairo.h
+++ b/ext/cairo/rb_cairo.h
@@ -73,7 +73,7 @@ RB_CAIRO_BEGIN_DECLS
 
 #define RB_CAIRO_VERSION_MAJOR 1
 #define RB_CAIRO_VERSION_MINOR 14
-#define RB_CAIRO_VERSION_MICRO 1
+#define RB_CAIRO_VERSION_MICRO 2
 
 RB_CAIRO_VAR VALUE rb_mCairo;
 RB_CAIRO_VAR VALUE rb_cCairo_Context;
@@ -296,7 +296,7 @@ VALUE                 rb_cairo_device_to_ruby_object         (cairo_device_t *de
 #define RVAL2CRSCRIPTMODE(obj)    (rb_cairo_script_mode_from_ruby_object(obj))
 #endif
 #if CAIRO_CHECK_VERSION(1, 10, 0)
-#define RVAL2CRREGIONOVERLAP(obj) (rb_cairo_region_overalap_from_ruby_object(obj))
+#define RVAL2CRREGIONOVERLAP(obj) (rb_cairo_region_overlap_from_ruby_object(obj))
 #endif
 
 cairo_operator_t       rb_cairo_operator_from_ruby_object       (VALUE obj);
@@ -338,7 +338,7 @@ cairo_region_overlap_t  rb_cairo_region_overlap_from_ruby_object(VALUE obj);
 #endif
 
 void rb_cairo_check_status (cairo_status_t status);
-
+void rb_cairo_surface_check_status (cairo_surface_t *surface);
 
 #define RB_CAIRO_DEF_SETTERS(klass) rb_cairo_def_setters(klass);
 void rb_cairo_def_setters (VALUE klass);
diff --git a/ext/cairo/rb_cairo_context.c b/ext/cairo/rb_cairo_context.c
index b4cf590..53b8cd4 100644
--- a/ext/cairo/rb_cairo_context.c
+++ b/ext/cairo/rb_cairo_context.c
@@ -880,7 +880,7 @@ cr_paint_with_alpha (VALUE self, VALUE alpha)
 }
 
 static VALUE
-cr_paint_generic(int argc, VALUE *argv, VALUE self)
+cr_paint_generic (int argc, VALUE *argv, VALUE self)
 {
   VALUE alpha;
   int n;
diff --git a/ext/cairo/rb_cairo_io.c b/ext/cairo/rb_cairo_io.c
index 31c905e..90c1f08 100644
--- a/ext/cairo/rb_cairo_io.c
+++ b/ext/cairo/rb_cairo_io.c
@@ -15,6 +15,8 @@
 ID rb_cairo__io_id_read;
 ID rb_cairo__io_id_write;
 ID rb_cairo__io_id_output;
+ID rb_cairo__io_id_to_io;
+ID rb_cairo__io_id_to_path;
 
 /* read/write callback */
 rb_cairo__io_callback_closure_t *
@@ -163,4 +165,6 @@ Init_cairo_io (void)
   rb_cairo__io_id_read = rb_intern ("read");
   rb_cairo__io_id_write = rb_intern ("write");
   rb_cairo__io_id_output = rb_intern ("output");
+  rb_cairo__io_id_to_io = rb_intern ("to_io");
+  rb_cairo__io_id_to_path = rb_intern ("to_path");
 }
diff --git a/ext/cairo/rb_cairo_io.h b/ext/cairo/rb_cairo_io.h
index e5df784..7fe060b 100644
--- a/ext/cairo/rb_cairo_io.h
+++ b/ext/cairo/rb_cairo_io.h
@@ -28,6 +28,8 @@ typedef struct rb_cairo__io_invoke_data {
 RB_CAIRO_VAR ID rb_cairo__io_id_read;
 RB_CAIRO_VAR ID rb_cairo__io_id_write;
 RB_CAIRO_VAR ID rb_cairo__io_id_output;
+RB_CAIRO_VAR ID rb_cairo__io_id_to_io;
+RB_CAIRO_VAR ID rb_cairo__io_id_to_path;
 
 rb_cairo__io_callback_closure_t *
                rb_cairo__io_closure_new     (VALUE                target);
diff --git a/ext/cairo/rb_cairo_pattern.c b/ext/cairo/rb_cairo_pattern.c
index 4e7eaec..18f1b4c 100644
--- a/ext/cairo/rb_cairo_pattern.c
+++ b/ext/cairo/rb_cairo_pattern.c
@@ -595,7 +595,7 @@ cr_mesh_pattern_set_control_point (VALUE self, VALUE rb_nth_point,
 
   pattern = _SELF (self);
   nth_point = NUM2UINT (rb_nth_point);
-  if (0 <= nth_point && nth_point <= 3)
+  if (nth_point <= 3)
     {
       cairo_mesh_pattern_set_control_point (pattern, nth_point,
                                             NUM2DBL (rb_x), NUM2DBL (rb_y));
@@ -625,7 +625,7 @@ cr_mesh_pattern_set_corner_color_generic (int argc, VALUE *argv, VALUE self)
                 &rb_nth_corner, &rb_red, &rb_green, &rb_blue, &rb_alpha);
 
   nth_corner = NUM2UINT (rb_nth_corner);
-  if (!(0 <= nth_corner && nth_corner <= 3))
+  if (nth_corner > 3)
     {
       VALUE inspected;
 
@@ -689,7 +689,7 @@ cr_mesh_pattern_get_corner_color (VALUE self,
 
   nth_patch = NUM2UINT (rb_nth_patch);
   nth_corner = NUM2UINT (rb_nth_corner);
-  if (!(0 <= nth_corner && nth_corner <= 3))
+  if (nth_corner > 3)
     {
       VALUE inspected;
 
@@ -723,7 +723,7 @@ cr_mesh_pattern_get_control_point (VALUE self,
 
   nth_patch = NUM2UINT (rb_nth_patch);
   nth_point = NUM2UINT (rb_nth_point);
-  if (!(0 <= nth_point && nth_point <= 3))
+  if (nth_point > 3)
     {
       VALUE inspected;
 
diff --git a/ext/cairo/rb_cairo_private.h b/ext/cairo/rb_cairo_private.h
index 14ad842..b973b50 100644
--- a/ext/cairo/rb_cairo_private.h
+++ b/ext/cairo/rb_cairo_private.h
@@ -126,4 +126,6 @@ VALUE rb_cairo__invoke_callback (cr_callback_func_t func, VALUE user_data);
 
 extern VALUE rb_cairo__cFFIPointer;
 
+void rb_cairo__surface_yield_and_finish (VALUE self);
+
 #endif
diff --git a/ext/cairo/rb_cairo_quartz_surface.m b/ext/cairo/rb_cairo_quartz_surface.m
new file mode 100644
index 0000000..1568ead
--- /dev/null
+++ b/ext/cairo/rb_cairo_quartz_surface.m
@@ -0,0 +1,207 @@
+/* -*- mode: objc; c-file-style: "gnu"; indent-tabs-mode: nil -*- */
+/*
+ * Ruby Cairo Binding
+ *
+ * Copyright 2008-2015 Kouhei Sutou <kou at cozmixng.org>
+ * Copyright 2014 Patrick Hanevold <patrick.hanevold at gmail.com>
+ *
+ * This file is made available under the same terms as Ruby
+ *
+ */
+
+#include "rb_cairo.h"
+#include "rb_cairo_private.h"
+
+#if CAIRO_CHECK_VERSION(1, 5, 12)
+#  define RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE_TYPE
+#endif
+
+#ifdef CAIRO_HAS_QUARTZ_SURFACE
+#  ifndef HAVE_TYPE_ENUM_RUBY_VALUE_TYPE
+enum ruby_value_type {
+  RUBY_T_DATA = T_DATA
+};
+#  endif
+#  undef T_DATA
+#  include <cairo-quartz.h>
+#  define T_DATA RUBY_T_DATA
+#  define RB_CAIRO_HAS_QUARTZ_SURFACE
+#  ifdef CAIRO_HAS_QUARTZ_IMAGE_SURFACE
+#    include <cairo-quartz-image.h>
+#    define RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
+#  endif
+#endif
+
+#define _SELF  (RVAL2CRSURFACE(self))
+
+#ifdef RB_CAIRO_HAS_QUARTZ_SURFACE
+/* Quartz-surface functions */
+#include <objc/objc-runtime.h>
+
+#  ifdef HAVE_RUBY_COCOA
+BOOL rbobj_to_nsobj (VALUE obj, id* nsobj);
+VALUE ocid_to_rbobj (VALUE context_obj, id ocid);
+#  endif
+
+static VALUE
+cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
+{
+  id objc_object = nil;
+  CGContextRef context;
+  unsigned int width, height;
+  cairo_surface_t *surface = NULL;
+  cairo_format_t format = CAIRO_FORMAT_ARGB32;
+  VALUE arg1, arg2, arg3, rb_width, rb_height;
+#  ifdef HAVE_RUBY_COCOA
+  static VALUE rb_cOSXCGContextRef = Qnil;
+#  endif
+
+  rb_scan_args (argc, argv, "21", &arg1, &arg2, &arg3);
+
+  if (argc == 2)
+    {
+      rb_width = arg1;
+      rb_height = arg2;
+    }
+  else
+    {
+      switch (TYPE (arg1))
+        {
+        case T_NIL:
+          break;
+        case T_STRING:
+        case T_SYMBOL:
+        case T_FIXNUM:
+          format = RVAL2CRFORMAT (arg1);
+          break;
+        default:
+#  ifdef HAVE_RUBY_COCOA
+          if (NIL_P (rb_cOSXCGContextRef))
+            rb_cOSXCGContextRef =
+              rb_const_get (rb_const_get (rb_cObject, rb_intern ("OSX")),
+                            rb_intern ("CGContextRef"));
+#  endif
+
+#  ifdef HAVE_RUBY_COCOA
+          if (RTEST (rb_obj_is_kind_of (arg1, rb_cOSXCGContextRef)))
+            {
+              rbobj_to_nsobj (arg1, &objc_object);
+            }
+          else
+#  endif
+            {
+              if (!NIL_P (rb_cairo__cFFIPointer) &&
+                  RTEST (rb_obj_is_kind_of (arg1, rb_cairo__cFFIPointer)))
+                {
+                  VALUE rb_objc_pointer;
+                  rb_objc_pointer = rb_funcall (arg1,
+                                                rb_intern ("address"),
+                                                0);
+                  objc_object = (id) NUM2ULONG (rb_objc_pointer);
+                }
+              else
+                {
+                  rb_raise (rb_eArgError,
+                            "invalid argument (expect "
+                            "(width, height), "
+                            "(format, width, height), "
+                            "(cg_context, width, height) or "
+                            "(ffi_pointer, width, height)): %s",
+                            rb_cairo__inspect (rb_ary_new3 (3, arg1, arg2, arg3)));
+                }
+            }
+          break;
+        }
+
+      rb_width = arg2;
+      rb_height = arg3;
+    }
+
+  width = NUM2UINT (rb_width);
+  height = NUM2UINT (rb_height);
+
+  if (objc_object == nil)
+    {
+      surface = cairo_quartz_surface_create (format, width, height);
+    }
+  else
+    {
+      context = (CGContextRef)objc_object;
+      surface =
+        cairo_quartz_surface_create_for_cg_context (context, width, height);
+    }
+
+  rb_cairo_surface_check_status (surface);
+  DATA_PTR (self) = surface;
+  if (rb_block_given_p ())
+    rb_cairo__surface_yield_and_finish (self);
+  return Qnil;
+}
+
+static VALUE
+cr_quartz_surface_get_cg_context (VALUE self)
+{
+#  ifdef HAVE_RUBY_COCOA
+  CGContextRef context;
+  id objc_object;
+
+  context = cairo_quartz_surface_get_cg_context (_SELF);
+  objc_object = (id)context;
+  return ocid_to_rbobj (Qnil, objc_object);
+#  else
+  rb_raise (rb_eNotImpError,
+            "%s#cg_context requires RubyCocoa",
+            rb_obj_classname(self));
+  return Qnil;
+#  endif
+}
+#endif
+
+#ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
+
+/* Quartz image surface functions */
+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));
+  rb_cairo_surface_check_status (surface);
+  DATA_PTR (self) = surface;
+  if (rb_block_given_p ())
+    rb_cairo__surface_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;
+  rb_cairo_surface_check_status (surface);
+  return CRSURFACE2RVAL (surface);
+}
+#endif
+
+void
+Init_cairo_quartz_surface (void)
+{
+  /* Quartz surface */
+#ifdef RB_CAIRO_HAS_QUARTZ_SURFACE
+  rb_define_method (rb_cCairo_QuartzSurface, "initialize",
+                    cr_quartz_surface_initialize, -1);
+  rb_define_method (rb_cCairo_QuartzSurface, "cg_context",
+                    cr_quartz_surface_get_cg_context, 0);
+#endif
+
+  /* Quartz image surface */
+#ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
+  rb_define_method (rb_cCairo_QuartzImageSurface, "initialize",
+                    cr_quartz_image_surface_initialize, 1);
+  rb_define_method (rb_cCairo_QuartzImageSurface, "image",
+                    cr_quartz_image_surface_get_image, 0);
+#endif
+}
diff --git a/ext/cairo/rb_cairo_surface.c b/ext/cairo/rb_cairo_surface.c
index 66e846e..cb224ab 100644
--- a/ext/cairo/rb_cairo_surface.c
+++ b/ext/cairo/rb_cairo_surface.c
@@ -2,7 +2,7 @@
 /*
  * Ruby Cairo Binding
  *
- * Copyright 2005-2014 Kouhei Sutou <kou at cozmixng.org>
+ * Copyright 2005-2015 Kouhei Sutou <kou at cozmixng.org>
  * Copyright 2014 Patrick Hanevold <patrick.hanevold at gmail.com>
  * Copyright 2005 Øyvind Kolås <pippin at freedesktop.org>
  * Copyright 2004-2005 MenTaLguY <mental at rydia.com>
@@ -45,17 +45,7 @@
 #endif
 
 #ifdef CAIRO_HAS_QUARTZ_SURFACE
-#  ifndef HAVE_TYPE_ENUM_RUBY_VALUE_TYPE
-enum ruby_value_type {
-  RUBY_T_DATA = T_DATA
-};
-#  endif
-#  undef T_DATA
-#  include <cairo-quartz.h>
-#  define T_DATA RUBY_T_DATA
-#  define RB_CAIRO_HAS_QUARTZ_SURFACE
 #  ifdef CAIRO_HAS_QUARTZ_IMAGE_SURFACE
-#    include <cairo-quartz-image.h>
 #    define RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
 #  endif
 #endif
@@ -130,8 +120,8 @@ cr_paper_to_size_in_points (VALUE paper_description, VALUE *width, VALUE *height
   *height = RARRAY_PTR (size)[1];
 }
 
-static inline void
-cr_surface_check_status (cairo_surface_t *surface)
+void
+rb_cairo_surface_check_status (cairo_surface_t *surface)
 {
   rb_cairo_check_status (cairo_surface_status (surface));
 }
@@ -467,13 +457,13 @@ cr_surface_finish (VALUE self)
 
   if (closure && !NIL_P (closure->error))
     rb_exc_raise (closure->error);
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
 
   return self;
 }
 
-static void
-yield_and_finish (VALUE self)
+void
+rb_cairo__surface_yield_and_finish (VALUE self)
 {
   cairo_surface_t *surface;
 
@@ -514,7 +504,7 @@ cr_surface_create_similar (int argc, VALUE *argv, VALUE self)
 
   similar_surface = cairo_surface_create_similar (surface, content,
                                                   width, height);
-  cr_surface_check_status (similar_surface);
+  rb_cairo_surface_check_status (similar_surface);
   return CRSURFACE2RVAL_WITH_DESTROY (similar_surface);
 }
 
@@ -552,7 +542,7 @@ cr_surface_create_similar_image (int argc, VALUE *argv, VALUE self)
 
   similar_image = cairo_surface_create_similar_image (surface, format,
                                                       width, height);
-  cr_surface_check_status (similar_image);
+  rb_cairo_surface_check_status (similar_image);
   return CRSURFACE2RVAL_WITH_DESTROY (similar_image);
 }
 
@@ -590,7 +580,7 @@ cr_surface_map_to_image (int argc, VALUE *argv, VALUE self)
     }
 
   mapped_image = cairo_surface_map_to_image (surface, extents);
-  cr_surface_check_status (mapped_image);
+  rb_cairo_surface_check_status (mapped_image);
   return CRSURFACE2RVAL_WITH_DESTROY (mapped_image);
 }
 
@@ -627,7 +617,7 @@ cr_surface_create_sub_rectangle_surface (VALUE self, VALUE x, VALUE y,
                                                 NUM2DBL (y),
                                                 NUM2DBL (width),
                                                 NUM2INT (height));
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   rb_surface = CRSURFACE2RVAL_WITH_DESTROY (surface);
   if (rb_block_given_p ())
     return rb_ensure (rb_yield, rb_surface,
@@ -759,7 +749,7 @@ cr_surface_get_font_options (VALUE self)
 {
   cairo_font_options_t *options = cairo_font_options_create();
   cairo_surface_get_font_options (_SELF, options);
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   rb_cairo_check_status (cairo_font_options_status (options));
   return CRFONTOPTIONS2RVAL (options);
 }
@@ -768,7 +758,7 @@ static VALUE
 cr_surface_flush (VALUE self)
 {
   cairo_surface_flush (_SELF);
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   return self;
 }
 
@@ -806,7 +796,7 @@ cr_surface_mark_dirty (int argc, VALUE *argv, VALUE self)
                 rb_cairo__inspect (args));
     }
 
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   return self;
 }
 
@@ -816,7 +806,7 @@ cr_surface_set_device_offset (VALUE self, VALUE x_offset, VALUE y_offset)
   cairo_surface_set_device_offset (_SELF,
                                    NUM2DBL (x_offset),
                                    NUM2DBL (y_offset));
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   return self;
 }
 
@@ -826,7 +816,7 @@ 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);
+  rb_cairo_surface_check_status (_SELF);
   return rb_ary_new3 (2, rb_float_new (x_offset), rb_float_new (y_offset));
 }
 
@@ -837,7 +827,7 @@ cr_surface_set_device_scale (VALUE self, VALUE x_scale, VALUE y_scale)
   cairo_surface_set_device_scale (_SELF,
                                   NUM2DBL (x_scale),
                                   NUM2DBL (y_scale));
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   return self;
 }
 
@@ -859,7 +849,7 @@ cr_surface_set_fallback_resolution (VALUE self,
   cairo_surface_set_fallback_resolution (_SELF,
                                          NUM2DBL (x_pixels_per_inch),
                                          NUM2DBL (y_pixels_per_inch));
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   return self;
 }
 
@@ -872,7 +862,7 @@ cr_surface_get_fallback_resolution (VALUE self)
   cairo_surface_get_fallback_resolution (_SELF,
                                          &x_pixels_per_inch,
                                          &y_pixels_per_inch);
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   return rb_ary_new3 (2,
                       rb_float_new (x_pixels_per_inch),
                       rb_float_new (y_pixels_per_inch));
@@ -885,7 +875,7 @@ static VALUE
 cr_surface_copy_page (VALUE self)
 {
   cairo_surface_copy_page (_SELF);
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   return self;
 }
 
@@ -893,7 +883,7 @@ static VALUE
 cr_surface_show_page (VALUE self)
 {
   cairo_surface_show_page (_SELF);
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   return self;
 }
 #endif
@@ -934,7 +924,7 @@ cr_image_surface_create_from_png_generic (VALUE klass, VALUE target)
   else
     surface = cr_image_surface_create_from_png (target);
 
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   rb_surface = cr_surface_allocate (klass);
   DATA_PTR (rb_surface) = surface;
   return rb_surface;
@@ -992,10 +982,10 @@ cr_image_surface_initialize (int argc, VALUE *argv, VALUE self)
               "(data, format, width, height, stride)): %s",
               rb_cairo__inspect (rb_ary_new3 (4, arg1, arg2, arg3, arg4)));
 
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   DATA_PTR (self) = surface;
   if (rb_block_given_p ())
-    yield_and_finish (self);
+    rb_cairo__surface_yield_and_finish (self);
   return Qnil;
 }
 
@@ -1069,6 +1059,12 @@ cr_ ## type ## _surface_initialize (int argc, VALUE *argv, VALUE self)  \
   width_in_points = NUM2DBL (rb_width_in_points);                       \
   height_in_points = NUM2DBL (rb_height_in_points);                     \
                                                                         \
+  if (rb_respond_to (target, rb_cairo__io_id_to_path) &&                \
+      !rb_respond_to (target, rb_cairo__io_id_to_io))                   \
+    {                                                                   \
+      target = rb_funcall (target, rb_cairo__io_id_to_path, 0);         \
+    }                                                                   \
+                                                                        \
   if (rb_respond_to (target, rb_cairo__io_id_write))                    \
     {                                                                   \
       rb_cairo__io_callback_closure_t *closure;                         \
@@ -1104,10 +1100,10 @@ cr_ ## type ## _surface_initialize (int argc, VALUE *argv, VALUE self)  \
                                            height_in_points);           \
     }                                                                   \
                                                                         \
-  cr_surface_check_status (surface);                                    \
+  rb_cairo_surface_check_status (surface);                              \
   DATA_PTR (self) = surface;                                            \
   if (rb_block_given_p ())                                              \
-    yield_and_finish (self);                                            \
+    rb_cairo__surface_yield_and_finish (self);                          \
   return Qnil;                                                          \
 }
 
@@ -1137,7 +1133,7 @@ cr_ ## type ## _surface_set_size (int argc, VALUE *argv, VALUE self)    \
   cairo_ ## type ## _surface_set_size (_SELF,                           \
                                        NUM2DBL (width_in_points),       \
                                        NUM2DBL (height_in_points));     \
-  cr_surface_check_status (_SELF);                                      \
+  rb_cairo_surface_check_status (_SELF);                                      \
   return Qnil;                                                          \
 }
 
@@ -1151,7 +1147,7 @@ static VALUE
 cr_pdf_surface_restrict_to_version (VALUE self, VALUE version)
 {
   cairo_pdf_surface_restrict_to_version (_SELF, RVAL2CRPDFVERSION (version));
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   return Qnil;
 }
 #  endif
@@ -1166,7 +1162,7 @@ static VALUE
 cr_ps_surface_dsc_comment (VALUE self, VALUE comment)
 {
   cairo_ps_surface_dsc_comment (_SELF, StringValueCStr (comment));
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   return Qnil;
 }
 
@@ -1174,7 +1170,7 @@ static VALUE
 cr_ps_surface_dsc_begin_setup (VALUE self)
 {
   cairo_ps_surface_dsc_begin_setup (_SELF);
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   if (rb_block_given_p ())
     return rb_yield (self);
   else
@@ -1185,7 +1181,7 @@ static VALUE
 cr_ps_surface_dsc_begin_page_setup (VALUE self)
 {
   cairo_ps_surface_dsc_begin_page_setup (_SELF);
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   if (rb_block_given_p ())
     return rb_yield (self);
   else
@@ -1197,7 +1193,7 @@ static VALUE
 cr_ps_surface_restrict_to_level (VALUE self, VALUE level)
 {
   cairo_ps_surface_restrict_to_level (_SELF, RVAL2CRPSLEVEL (level));
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   return Qnil;
 }
 
@@ -1211,135 +1207,12 @@ static VALUE
 cr_ps_surface_set_eps (VALUE self, VALUE eps)
 {
   cairo_ps_surface_set_eps (_SELF, RTEST (eps));
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   return Qnil;
 }
 #  endif
 #endif
 
-#ifdef RB_CAIRO_HAS_QUARTZ_SURFACE
-/* Quartz-surface functions */
-#include <objc/objc-runtime.h>
-
-#  ifdef HAVE_RUBY_COCOA
-BOOL rbobj_to_nsobj (VALUE obj, id* nsobj);
-VALUE ocid_to_rbobj (VALUE context_obj, id ocid);
-#  endif
-
-static VALUE
-cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
-{
-  id objc_object = nil;
-  CGContextRef context;
-  unsigned int width, height;
-  cairo_surface_t *surface = NULL;
-  cairo_format_t format = CAIRO_FORMAT_ARGB32;
-  VALUE arg1, arg2, arg3, rb_width, rb_height;
-#  ifdef HAVE_RUBY_COCOA
-  static VALUE rb_cOSXCGContextRef = Qnil;
-#  endif
-
-  rb_scan_args (argc, argv, "21", &arg1, &arg2, &arg3);
-
-  if (argc == 2)
-    {
-      rb_width = arg1;
-      rb_height = arg2;
-    }
-  else
-    {
-      switch (TYPE (arg1))
-        {
-        case T_NIL:
-          break;
-        case T_STRING:
-        case T_SYMBOL:
-        case T_FIXNUM:
-          format = RVAL2CRFORMAT (arg1);
-          break;
-        default:
-#  ifdef HAVE_RUBY_COCOA
-          if (NIL_P (rb_cOSXCGContextRef))
-            rb_cOSXCGContextRef =
-              rb_const_get (rb_const_get (rb_cObject, rb_intern ("OSX")),
-                            rb_intern ("CGContextRef"));
-#  endif
-
-#  ifdef HAVE_RUBY_COCOA
-          if (RTEST (rb_obj_is_kind_of (arg1, rb_cOSXCGContextRef)))
-            {
-              rbobj_to_nsobj (arg1, &objc_object);
-            }
-          else
-#  endif
-            {
-              if (!NIL_P (rb_cairo__cFFIPointer) &&
-                  RTEST (rb_obj_is_kind_of (arg1, rb_cairo__cFFIPointer)))
-                {
-                  VALUE rb_objc_pointer;
-                  rb_objc_pointer = rb_funcall (arg1,
-                                                rb_intern ("address"),
-                                                0);
-                  objc_object = NUM2ULONG (rb_objc_pointer);
-                }
-              else
-                {
-                  rb_raise (rb_eArgError,
-                            "invalid argument (expect "
-                            "(width, height), "
-                            "(format, width, height), "
-                            "(cg_context, width, height) or "
-                            "(ffi_pointer, width, height)): %s",
-                            rb_cairo__inspect (rb_ary_new3 (3, arg1, arg2, arg3)));
-                }
-            }
-          break;
-        }
-
-      rb_width = arg2;
-      rb_height = arg3;
-    }
-
-  width = NUM2UINT (rb_width);
-  height = NUM2UINT (rb_height);
-
-  if (objc_object == nil)
-    {
-      surface = cairo_quartz_surface_create (format, width, height);
-    }
-  else
-    {
-      context = (CGContextRef)objc_object;
-      surface =
-        cairo_quartz_surface_create_for_cg_context (context, width, height);
-    }
-
-  cr_surface_check_status (surface);
-  DATA_PTR (self) = surface;
-  if (rb_block_given_p ())
-    yield_and_finish (self);
-  return Qnil;
-}
-
-static VALUE
-cr_quartz_surface_get_cg_context (VALUE self)
-{
-#  ifdef HAVE_RUBY_COCOA
-  CGContextRef context;
-  id objc_object;
-
-  context = cairo_quartz_surface_get_cg_context (_SELF);
-  objc_object = (id)context;
-  return ocid_to_rbobj (Qnil, objc_object);
-#  else
-  rb_raise (rb_eNotImpError,
-            "%s#cg_context requires RubyCocoa",
-            rb_obj_classname(self));
-  return Qnil;
-#  endif
-}
-#endif
-
 #ifdef CAIRO_HAS_WIN32_SURFACE
 /* Win32 surface functions */
 
@@ -1420,10 +1293,10 @@ cr_win32_surface_initialize (int argc, VALUE *argv, VALUE self)
 
   if (!surface)
     rb_cairo_check_status (CAIRO_STATUS_INVALID_FORMAT);
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   DATA_PTR (self) = surface;
   if (rb_block_given_p ())
-    yield_and_finish (self);
+    rb_cairo__surface_yield_and_finish (self);
   return Qnil;
 }
 
@@ -1448,7 +1321,7 @@ cr_win32_surface_get_image (VALUE self)
   surface = cairo_win32_surface_get_image (_SELF);
   if (!surface)
     return Qnil;
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   return CRSURFACE2RVAL (surface);
 }
 #  endif
@@ -1462,7 +1335,7 @@ static VALUE
 cr_svg_surface_restrict_to_version (VALUE self, VALUE version)
 {
   cairo_svg_surface_restrict_to_version (_SELF, RVAL2CRSVGVERSION (version));
-  cr_surface_check_status (_SELF);
+  rb_cairo_surface_check_status (_SELF);
   return Qnil;
 }
 #endif
@@ -1475,41 +1348,12 @@ cr_win32_printing_surface_initialize (VALUE self, VALUE hdc)
   cairo_surface_t *surface = NULL;
 
   surface = cairo_win32_printing_surface_create (NUM2PTR (hdc));
-  cr_surface_check_status (surface);
-  DATA_PTR (self) = surface;
-  if (rb_block_given_p ())
-    yield_and_finish (self);
-  return Qnil;
-}
-#endif
-
-#ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
-
-/* Quartz image surface functions */
-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);
+  rb_cairo_surface_check_status (surface);
   DATA_PTR (self) = surface;
   if (rb_block_given_p ())
-    yield_and_finish (self);
+    rb_cairo__surface_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
 
 #ifdef CAIRO_HAS_SCRIPT_SURFACE
@@ -1559,10 +1403,10 @@ cr_script_surface_initialize (int argc, VALUE *argv, VALUE self)
   else
     surface = cairo_script_surface_create (device, content, width, height);
 
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   DATA_PTR (self) = surface;
   if (rb_block_given_p ())
-    yield_and_finish (self);
+    rb_cairo__surface_yield_and_finish (self);
   return Qnil;
 }
 #endif
@@ -1614,10 +1458,10 @@ cr_recording_surface_initialize (int argc, VALUE *argv, VALUE self)
     }
 
   surface = cairo_recording_surface_create (content, &extents);
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   DATA_PTR (self) = surface;
   if (rb_block_given_p ())
-    yield_and_finish (self);
+    rb_cairo__surface_yield_and_finish (self);
   return Qnil;
 }
 
@@ -1629,7 +1473,7 @@ cr_recording_surface_get_ink_extents (VALUE self)
 
   surface = _SELF;
   cairo_recording_surface_ink_extents (surface, &x, &y, &width, &height);
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   return rb_ary_new3 (4,
                       rb_float_new (x), rb_float_new (y),
                       rb_float_new (width), rb_float_new (height));
@@ -1644,7 +1488,7 @@ cr_recording_surface_get_extents (VALUE self)
 
   surface = _SELF;
   cairo_recording_surface_get_extents (surface, &extents);
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   return rb_ary_new3 (4,
                       rb_float_new (extents.x),
                       rb_float_new (extents.y),
@@ -1691,10 +1535,10 @@ cr_gl_surface_initialize (int argc, VALUE *argv, VALUE self)
 
   surface = cairo_gl_surface_create (device, content, width, height);
 
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   DATA_PTR (self) = surface;
   if (rb_block_given_p ())
-    yield_and_finish (self);
+    rb_cairo__surface_yield_and_finish (self);
   return Qnil;
 }
 
@@ -1738,10 +1582,10 @@ cr_gl_texture_surface_initialize (int argc, VALUE *argv, VALUE self)
                                                  width,
                                                  height);
 
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   DATA_PTR (self) = surface;
   if (rb_block_given_p ())
-    yield_and_finish (self);
+    rb_cairo__surface_yield_and_finish (self);
   return Qnil;
 }
 
@@ -1752,7 +1596,7 @@ cr_gl_surface_set_size (VALUE self, VALUE width, VALUE height)
 
   surface = _SELF;
   cairo_gl_surface_set_size (surface, NUM2INT (width), NUM2INT (height));
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   return Qnil;
 }
 
@@ -1775,7 +1619,7 @@ cr_gl_surface_swap_buffers (VALUE self)
 
   surface = _SELF;
   cairo_gl_surface_swapbuffers (surface);
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   return Qnil;
 }
 #endif
@@ -1788,11 +1632,11 @@ cr_tee_surface_initialize (VALUE self, VALUE master)
   cairo_surface_t *surface = NULL;
 
   surface = cairo_tee_surface_create (RVAL2CRSURFACE (master));
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   DATA_PTR (self) = surface;
   rb_iv_set (self, "surfaces", rb_ary_new3 (1, master));
   if (rb_block_given_p ())
-    yield_and_finish (self);
+    rb_cairo__surface_yield_and_finish (self);
   return Qnil;
 }
 
@@ -1803,7 +1647,7 @@ cr_tee_surface_add (VALUE self, VALUE target)
 
   surface = _SELF;
   cairo_tee_surface_add (surface, RVAL2CRSURFACE (target));
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   rb_ary_push (rb_iv_get (self, "surfaces"), target);
   return Qnil;
 }
@@ -1839,7 +1683,7 @@ cr_tee_surface_remove (VALUE self, VALUE target_or_index)
       target = cairo_tee_surface_index (surface, NUM2INT (index));
     }
   cairo_tee_surface_remove (surface, target);
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
 
   rb_surfaces = rb_iv_get (self, "surfaces");
   for (i = 0; i < RARRAY_LEN (rb_surfaces); i++)
@@ -1867,8 +1711,8 @@ cr_tee_surface_array_reference (VALUE self, VALUE index)
   surface = _SELF;
   index = rb_Integer (index);
   target = cairo_tee_surface_index (surface, NUM2UINT (index));
-  cr_surface_check_status (surface);
-  cr_surface_check_status (target);
+  rb_cairo_surface_check_status (surface);
+  rb_cairo_surface_check_status (target);
   return CRSURFACE2RVAL (target);
 }
 #endif
@@ -1910,10 +1754,10 @@ cr_xml_surface_initialize (int argc, VALUE *argv, VALUE self)
 
   surface = cairo_xml_surface_create (device, content, width, height);
 
-  cr_surface_check_status (surface);
+  rb_cairo_surface_check_status (surface);
   DATA_PTR (self) = surface;
   if (rb_block_given_p ())
-    yield_and_finish (self);
+    rb_cairo__surface_yield_and_finish (self);
   return Qnil;
 }
 #endif
@@ -2125,12 +1969,6 @@ Init_cairo_surface (void)
   /* Quartz surface */
   rb_cCairo_QuartzSurface =
     rb_define_class_under (rb_mCairo, "QuartzSurface", rb_cCairo_Surface);
-#ifdef RB_CAIRO_HAS_QUARTZ_SURFACE
-  rb_define_method (rb_cCairo_QuartzSurface, "initialize",
-                    cr_quartz_surface_initialize, -1);
-  rb_define_method (rb_cCairo_QuartzSurface, "cg_context",
-                    cr_quartz_surface_get_cg_context, 0);
-#endif
 
   /* Win32 surface */
   rb_cCairo_Win32Surface =
@@ -2171,12 +2009,6 @@ Init_cairo_surface (void)
   /* Quartz image surface */
   rb_cCairo_QuartzImageSurface =
     rb_define_class_under (rb_mCairo, "QuartzImageSurface", rb_cCairo_Surface);
-#ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
-  rb_define_method (rb_cCairo_QuartzImageSurface, "initialize",
-                    cr_quartz_image_surface_initialize, 1);
-  rb_define_method (rb_cCairo_QuartzImageSurface, "image",
-                    cr_quartz_image_surface_get_image, 0);
-#endif
 
   /* script surface */
   rb_cCairo_ScriptSurface =
diff --git a/lib/cairo.rb b/lib/cairo.rb
index ec6ceef..208f2c3 100644
--- a/lib/cairo.rb
+++ b/lib/cairo.rb
@@ -1,19 +1,19 @@
 # vim: filetype=ruby:expandtab:shiftwidth=2:tabstop=8:softtabstop=2 :
 
 if /mingw|mswin|mswin32/ =~ RUBY_PLATFORM
-  require 'pathname'
+  require "pathname"
   base_dir = Pathname(File.dirname(__FILE__))
   base_dir = base_dir.parent + "vendor" + "local"
   if base_dir.exist?
     base_dir = base_dir.to_s.gsub(/\//, "\\")
-    ENV['PATH'] = %w(bin lib).collect do |dir|
+    ENV["PATH"] = %w(bin lib).collect do |dir|
       "#{base_dir}\\#{dir};"
-    end.join('') + ENV['PATH']
+    end.join("") + ENV["PATH"]
   else
-    require 'rbconfig'
-    ENV['PATH'] = %w(bin lib).collect do |dir|
+    require "rbconfig"
+    ENV["PATH"] = %w(bin lib).collect do |dir|
       "#{RbConfig::CONFIG["prefix"]}\\lib\\GTK\\#{dir};"
-    end.join('') + ENV['PATH']
+    end.join("") + ENV["PATH"]
   end
 end
 
@@ -36,16 +36,16 @@ module Cairo
   end
 end
 
-require 'cairo/color'
-require 'cairo/paper'
+require "cairo/color"
+require "cairo/paper"
 
 begin
   major, minor, _ = RUBY_VERSION.split(/\./)
   require "#{major}.#{minor}/cairo.so"
 rescue LoadError
-  require 'cairo.so'
+  require "cairo.so"
 end
-require 'cairo/constants'
+require "cairo/constants"
 
 module Cairo
   class << self
@@ -53,7 +53,7 @@ module Cairo
 
     def bindings_version
       major, minor, micro, tag = BINDINGS_VERSION
-      version = [major, minor, micro].join('.')
+      version = [major, minor, micro].join(".")
       version << "-#{tag}" if tag
       version
     end
@@ -138,14 +138,15 @@ module Cairo
   end
 end
 
-require 'cairo/point'
-require 'cairo/colors'
-require 'cairo/papers'
-require 'cairo/context'
-require 'cairo/device'
-require 'cairo/surface'
-require 'cairo/pattern'
-require 'cairo/path'
+require "cairo/point"
+require "cairo/colors"
+require "cairo/papers"
+require "cairo/context"
+require "cairo/device"
+require "cairo/surface"
+require "cairo/pattern"
+require "cairo/path"
+require "cairo/region"
 
 module Cairo
   if const_defined?(:Win32Surface)
diff --git a/lib/cairo/region.rb b/lib/cairo/region.rb
new file mode 100644
index 0000000..56d2982
--- /dev/null
+++ b/lib/cairo/region.rb
@@ -0,0 +1,14 @@
+module Cairo
+  class Region
+    def each_rectangle
+      return to_enum(:each_rectangle) unless block_given?
+      num_rectangles.times.each do |i|
+        yield(self[i])
+      end
+    end
+
+    def rectangles
+      each_rectangle.to_a
+    end
+  end
+end
diff --git a/patches/cairo-1.14-missing-exeext-float-m4.diff b/patches/cairo-1.14-missing-exeext-float-m4.diff
deleted file mode 100644
index cf373b3..0000000
--- a/patches/cairo-1.14-missing-exeext-float-m4.diff
+++ /dev/null
@@ -1,17 +0,0 @@
-diff --git a/build/aclocal.float.m4 b/build/aclocal.float.m4
-index bc0a91c..8f85f08 100644
---- a/build/aclocal.float.m4
-+++ b/build/aclocal.float.m4
-@@ -31,10 +31,10 @@ int main() { return 0; }
- 
- ]])], [
- 
--if strings - conftest | grep noonsees >/dev/null ; then
-+if strings - conftest$ac_exeext | grep noonsees >/dev/null ; then
-   ax_cv_c_float_words_bigendian=yes
- fi
--if strings - conftest | grep seesnoon >/dev/null ; then
-+if strings - conftest$ac_exeext | grep seesnoon >/dev/null ; then
-   if test "$ax_cv_c_float_words_bigendian" = unknown; then
-     ax_cv_c_float_words_bigendian=no
-   else
diff --git a/test/test_region.rb b/test/test_region.rb
index f7b4dd2..6e98c92 100644
--- a/test/test_region.rb
+++ b/test/test_region.rb
@@ -25,6 +25,32 @@ class RegionTest < Test::Unit::TestCase
     assert_equal([0, 0, 10, 10], region[0])
   end
 
+  def test_each_rectangle
+    region = Cairo::Region.new
+    region.union!([0, 0, 10, 10])
+    region.union!([20, 20, 40, 40])
+    rectangles = []
+    region.each_rectangle do |rectangle|
+      rectangles << rectangle
+    end
+    assert_equal([
+                   [0, 0, 10, 10],
+                   [20, 20, 40, 40],
+                 ],
+                 rectangles)
+  end
+
+  def test_rectangles
+    region = Cairo::Region.new
+    region.union!([0, 0, 10, 10])
+    region.union!([20, 20, 40, 40])
+    assert_equal([
+                   [0, 0, 10, 10],
+                   [20, 20, 40, 40],
+                 ],
+                 region.rectangles)
+  end
+
   def test_dup
     region = Cairo::Region.new([0, 0, 10, 10])
     region.dup.subtract!([5, 5, 5, 5])

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-cairo.git



More information about the Pkg-ruby-extras-commits mailing list