From null+rcairo at clear-code.com Sat Apr 7 04:56:27 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sat, 07 Apr 2012 13:56:27 +0900 Subject: [cairo-commit:00181] rcairo/rcairo [master] Fix a typo... Message-ID: <20120407045639.8FB849A0A5@jenkins.clear-code.com> Kouhei Sutou 2012-04-07 13:56:27 +0900 (Sat, 07 Apr 2012) New Revision: 914bcc8ae40c082c54b32a852d87d12fbcbf9f9e Log: Fix a typo... Modified files: Gemfile Modified: Gemfile (+1 -1) =================================================================== --- Gemfile 2012-03-31 16:08:58 +0900 (914657b) +++ Gemfile 2012-04-07 13:56:27 +0900 (eee9408) @@ -2,4 +2,4 @@ source "http://rubygems.org/" -gemfile +gemspec From null+rcairo at clear-code.com Sat Apr 7 04:59:19 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sat, 07 Apr 2012 13:59:19 +0900 Subject: [cairo-commit:00182] rcairo/rcairo [master] Use new style test-unit require Message-ID: <20120407045929.E0A439A0A5@jenkins.clear-code.com> Kouhei Sutou 2012-04-07 13:59:19 +0900 (Sat, 07 Apr 2012) New Revision: c6a70e6665b4560f922c2da0a958898e4ae7e7a6 Log: Use new style test-unit require Modified files: test/run-test.rb Modified: test/run-test.rb (+1 -1) =================================================================== --- test/run-test.rb 2012-04-07 13:56:27 +0900 (6e22d3e) +++ test/run-test.rb 2012-04-07 13:59:19 +0900 (db6ba69) @@ -13,7 +13,7 @@ end require 'rubygems' require 'bundler/setup' -require 'test/unit' +require 'test-unit' $LOAD_PATH.unshift(base_dir) $LOAD_PATH.unshift(ext_dir) From null+rcairo at clear-code.com Sat Apr 7 05:01:55 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sat, 07 Apr 2012 14:01:55 +0900 Subject: [cairo-commit:00183] rcairo/rcairo [master] Ignore an auto generated file Message-ID: <20120407050207.A94589A0A5@jenkins.clear-code.com> Kouhei Sutou 2012-04-07 14:01:55 +0900 (Sat, 07 Apr 2012) New Revision: 3bf7446d36c75b7cb92ef09daa24c8882c004205 Log: Ignore an auto generated file Modified files: .gitignore Modified: .gitignore (+1 -0) =================================================================== --- .gitignore 2012-04-07 13:59:19 +0900 (0952d04) +++ .gitignore 2012-04-07 14:01:55 +0900 (b3d9fc1) @@ -11,3 +11,4 @@ /pkg/ /Makefile /Makefile.lib +/Gemfile.lock From null+rcairo at clear-code.com Sun Apr 8 07:57:03 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sun, 08 Apr 2012 16:57:03 +0900 Subject: [cairo-commit:00184] rcairo/rcairo [master] Add Cairo::Device.supported? Message-ID: <20120408075715.385069A0A5@jenkins.clear-code.com> Kouhei Sutou 2012-04-08 16:57:03 +0900 (Sun, 08 Apr 2012) New Revision: a41354c49b418e3310e53f25dd2bddd1f1ea38be Log: Add Cairo::Device.supported? It checks whether a device type is supported on the cairo installation. Tests for rcairo use it to omit tests for unavailable devices. GitHub: fixes #11 Reported by C?dric Boutillier. Thanks!!! Added files: lib/cairo/device.rb Modified files: ext/cairo/rb_cairo_device.c lib/cairo.rb test/cairo-test-utils.rb Modified: ext/cairo/rb_cairo_device.c (+35 -0) =================================================================== --- ext/cairo/rb_cairo_device.c 2012-04-07 14:01:55 +0900 (00ead72) +++ ext/cairo/rb_cairo_device.c 2012-04-08 16:57:03 +0900 (7926ea4) @@ -96,6 +96,26 @@ cr_device_get_klass (cairo_device_t *device) return klass; } +static VALUE +cr_device_script_supported_p (VALUE klass) +{ +#ifdef CAIRO_HAS_SCRIPT_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +cr_device_xml_supported_p (VALUE klass) +{ +#ifdef CAIRO_HAS_XML_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + /* constructor/de-constructor */ cairo_device_t * rb_cairo_device_from_ruby_object (VALUE obj) @@ -168,6 +188,16 @@ cr_device_allocate (VALUE klass) return Data_Wrap_Struct (klass, NULL, cr_device_free, NULL); } +static VALUE +cr_device_initialize (int argc, VALUE *argv, VALUE self) +{ + rb_raise(rb_eNotImpError, + "%s class creation isn't supported on this cairo installation", + rb_obj_classname(self)); + + return Qnil; +} + /* Backend device manipulation */ static VALUE cr_device_destroy (VALUE self) @@ -377,7 +407,12 @@ Init_cairo_device (void) rb_cairo__initialize_gc_guard_holder_class (rb_cCairo_Device); rb_set_end_proc(cr_finish_all_guarded_devices_at_end, Qnil); + rb_define_singleton_method (rb_cCairo_Device, "script_supported?", + cr_device_script_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Device, "xml_supported?", + cr_device_xml_supported_p, 0); + rb_define_method (rb_cCairo_Device, "initialize", cr_device_initialize, -1); rb_define_method (rb_cCairo_Device, "destroy", cr_device_destroy, 0); rb_define_method (rb_cCairo_Device, "finish", cr_device_finish, 0); rb_define_method (rb_cCairo_Device, "flush", cr_device_flush, 0); Modified: lib/cairo.rb (+1 -0) =================================================================== --- lib/cairo.rb 2012-04-07 14:01:55 +0900 (e05e50c) +++ lib/cairo.rb 2012-04-08 16:57:03 +0900 (690d5be) @@ -142,6 +142,7 @@ require 'cairo/point' require 'cairo/colors' require 'cairo/papers' require 'cairo/context' +require 'cairo/device' require 'cairo/path' module Cairo Added: lib/cairo/device.rb (+13 -0) 100644 =================================================================== --- /dev/null +++ lib/cairo/device.rb 2012-04-08 16:57:03 +0900 (037b875) @@ -0,0 +1,13 @@ +module Cairo + if const_defined?(:Device) + class Device + class << self + def supported?(type) + supported_predicate = "#{type.to_s.downcase}_supported?" + return false unless respond_to?(supported_predicate) + send(supported_predicate) + end + end + end + end +end Modified: test/cairo-test-utils.rb (+4 -3) =================================================================== --- test/cairo-test-utils.rb 2012-04-07 14:01:55 +0900 (6df73c9) +++ test/cairo-test-utils.rb 2012-04-08 16:57:03 +0900 (133e214) @@ -18,9 +18,10 @@ module CairoTestUtils end def only_device(name) - device_class = "#{name}Device" - unless Cairo.const_defined?(device_class) - omit("Only for #{device_class} device available") + only_cairo_version(1, 10) + + unless Cairo::Device.supported?(name) + omit("Only for #{name} device available") end end From null+rcairo at clear-code.com Sun Apr 8 08:14:40 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sun, 08 Apr 2012 17:14:40 +0900 Subject: [cairo-commit:00185] rcairo/rcairo [master] Add Cairo::Surface.supported? Message-ID: <20120408081453.B66979A0A5@jenkins.clear-code.com> Kouhei Sutou 2012-04-08 17:14:40 +0900 (Sun, 08 Apr 2012) New Revision: c0f172ec4d21ba97dc7c8c63e934ddb4beb8a51c Log: Add Cairo::Surface.supported? It checks whether a surface type is supported on the cairo installation. Tests for rcairo use it to omit tests for unavailable surfaces. Added files: lib/cairo/surface.rb Modified files: ext/cairo/rb_cairo_surface.c lib/cairo.rb test/cairo-test-utils.rb Modified: ext/cairo/rb_cairo_surface.c (+158 -2) =================================================================== --- ext/cairo/rb_cairo_surface.c 2012-04-08 16:57:03 +0900 (df07e15) +++ ext/cairo/rb_cairo_surface.c 2012-04-08 17:14:40 +0900 (764809f) @@ -44,6 +44,9 @@ enum ruby_value_type { # undef T_DATA # include # define T_DATA RUBY_T_DATA +# ifdef HAVE_RUBY_COCOA +# define RB_CAIRO_HAS_QUARTZ_SURFACE +# endif #endif #ifdef CAIRO_HAS_XML_SURFACE @@ -209,6 +212,122 @@ cr_surface_get_klass (cairo_surface_t *surface) return klass; } +static VALUE +cr_surface_image_supported_p (VALUE klass) +{ + return Qtrue; +} + +static VALUE +cr_surface_recording_supported_p (VALUE klass) +{ +#ifdef CAIRO_HAS_RECORDING_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +cr_surface_ps_supported_p (VALUE klass) +{ +#ifdef CAIRO_HAS_PS_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +cr_surface_pdf_supported_p (VALUE klass) +{ +#ifdef CAIRO_HAS_PDF_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +cr_surface_xcb_supported_p (VALUE klass) +{ +#ifdef CAIRO_HAS_XCB_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +cr_surface_svg_supported_p (VALUE klass) +{ +#ifdef CAIRO_HAS_SVG_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +cr_surface_win32_supported_p (VALUE klass) +{ +#ifdef CAIRO_HAS_WIN32_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +cr_surface_quartz_supported_p (VALUE klass) +{ +#ifdef RB_CAIRO_HAS_QUARTZ_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +cr_surface_script_supported_p (VALUE klass) +{ +#ifdef CAIRO_HAS_SCRIPT_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +cr_surface_xml_supported_p (VALUE klass) +{ +#ifdef CAIRO_HAS_XML_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +cr_surface_tee_supported_p (VALUE klass) +{ +#ifdef CAIRO_HAS_TEE_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +cr_surface_gl_supported_p (VALUE klass) +{ +#ifdef RB_CAIRO_HAS_GL_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + /* constructor/de-constructor */ cairo_surface_t * rb_cairo_surface_from_ruby_object (VALUE obj) @@ -279,6 +398,16 @@ cr_surface_allocate (VALUE klass) return Data_Wrap_Struct (klass, NULL, cr_surface_free, NULL); } +static VALUE +cr_surface_initialize (int argc, VALUE *argv, VALUE self) +{ + rb_raise(rb_eNotImpError, + "%s class creation isn't supported on this cairo installation", + rb_obj_classname(self)); + + return Qnil; +} + /* Surface manipulation */ static VALUE cr_surface_destroy (VALUE self) @@ -1290,7 +1419,7 @@ cr_win32_surface_get_image (VALUE self) # endif #endif -#if defined(CAIRO_HAS_QUARTZ_SURFACE) && defined(HAVE_RUBY_COCOA) +#ifdef RB_CAIRO_HAS_QUARTZ_SURFACE /* Quartz-surface functions */ #include @@ -1753,6 +1882,33 @@ Init_cairo_surface (void) rb_cairo__initialize_gc_guard_holder_class (rb_cCairo_Surface); rb_set_end_proc(cr_finish_all_guarded_surfaces_at_end, Qnil); + rb_define_singleton_method (rb_cCairo_Surface, "image_supported?", + cr_surface_image_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "recording_supported?", + cr_surface_recording_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "ps_supported?", + cr_surface_ps_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "pdf_supported?", + cr_surface_pdf_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "xcb_supported?", + cr_surface_xcb_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "svg_supported?", + cr_surface_svg_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "win32_supported?", + cr_surface_win32_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "quartz_supported?", + cr_surface_quartz_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "script_supported?", + cr_surface_script_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "xml_supported?", + cr_surface_xml_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "tee_supported?", + cr_surface_tee_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "gl_supported?", + cr_surface_gl_supported_p, 0); + + rb_define_method (rb_cCairo_Surface, "initialize", + cr_surface_initialize, -1); rb_define_method (rb_cCairo_Surface, "create_similar", cr_surface_create_similar, -1); @@ -1948,7 +2104,7 @@ Init_cairo_surface (void) #endif -#if defined(CAIRO_HAS_QUARTZ_SURFACE) && defined(HAVE_RUBY_COCOA) +#ifdef RB_CAIRO_HAS_QUARTZ_SURFACE /* Quartz-surface */ rb_cCairo_QuartzSurface = Modified: lib/cairo.rb (+1 -0) =================================================================== --- lib/cairo.rb 2012-04-08 16:57:03 +0900 (690d5be) +++ lib/cairo.rb 2012-04-08 17:14:40 +0900 (c73b216) @@ -143,6 +143,7 @@ require 'cairo/colors' require 'cairo/papers' require 'cairo/context' require 'cairo/device' +require 'cairo/surface' require 'cairo/path' module Cairo Added: lib/cairo/surface.rb (+11 -0) 100644 =================================================================== --- /dev/null +++ lib/cairo/surface.rb 2012-04-08 17:14:40 +0900 (5eccefc) @@ -0,0 +1,11 @@ +module Cairo + class Surface + class << self + def supported?(type) + supported_predicate = "#{type.to_s.downcase}_supported?" + return false unless respond_to?(supported_predicate) + send(supported_predicate) + end + end + end +end Modified: test/cairo-test-utils.rb (+2 -3) =================================================================== --- test/cairo-test-utils.rb 2012-04-08 16:57:03 +0900 (133e214) +++ test/cairo-test-utils.rb 2012-04-08 17:14:40 +0900 (978d9eb) @@ -26,9 +26,8 @@ module CairoTestUtils end def only_surface(name) - surface_class = "#{name}Surface" - unless Cairo.const_defined?(surface_class) - omit("Only for #{surface_class} surface available") + unless Cairo::Surface.supported?(name) + omit("Only for #{name} device available") end end end From null+rcairo at clear-code.com Sun Apr 8 08:17:14 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sun, 08 Apr 2012 17:17:14 +0900 Subject: [cairo-commit:00186] rcairo/rcairo [master] Add Cairo::Device.gl_texture_supported? Message-ID: <20120408081726.128589A0A5@jenkins.clear-code.com> Kouhei Sutou 2012-04-08 17:17:14 +0900 (Sun, 08 Apr 2012) New Revision: c5eaf2fc6482c3dafe1e9ff72b45ee70298d34af Log: Add Cairo::Device.gl_texture_supported? Modified files: ext/cairo/rb_cairo_surface.c Modified: ext/cairo/rb_cairo_surface.c (+12 -0) =================================================================== --- ext/cairo/rb_cairo_surface.c 2012-04-08 17:14:40 +0900 (764809f) +++ ext/cairo/rb_cairo_surface.c 2012-04-08 17:17:14 +0900 (f1924c7) @@ -328,6 +328,16 @@ cr_surface_gl_supported_p (VALUE klass) #endif } +static VALUE +cr_surface_gl_texture_supported_p (VALUE klass) +{ +#ifdef RB_CAIRO_HAS_GL_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + /* constructor/de-constructor */ cairo_surface_t * rb_cairo_surface_from_ruby_object (VALUE obj) @@ -1906,6 +1916,8 @@ Init_cairo_surface (void) cr_surface_tee_supported_p, 0); rb_define_singleton_method (rb_cCairo_Surface, "gl_supported?", cr_surface_gl_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "gl_texture_supported?", + cr_surface_gl_texture_supported_p, 0); rb_define_method (rb_cCairo_Surface, "initialize", cr_surface_initialize, -1); From null+rcairo at clear-code.com Sun Apr 8 08:18:10 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sun, 08 Apr 2012 17:18:10 +0900 Subject: [cairo-commit:00187] rcairo/rcairo [master] Remove trailing spaces Message-ID: <20120408081821.9A4EC9A0A5@jenkins.clear-code.com> Kouhei Sutou 2012-04-08 17:18:10 +0900 (Sun, 08 Apr 2012) New Revision: 9decdf274f0597bfabdeb9357e07f54555674471 Log: Remove trailing spaces Modified files: ext/cairo/rb_cairo_surface.c Modified: ext/cairo/rb_cairo_surface.c (+5 -5) =================================================================== --- ext/cairo/rb_cairo_surface.c 2012-04-08 17:17:14 +0900 (f1924c7) +++ ext/cairo/rb_cairo_surface.c 2012-04-08 17:18:10 +0900 (7794bed) @@ -756,7 +756,7 @@ cr_surface_mark_dirty (int argc, VALUE *argv, VALUE self) { VALUE x, y, width, height; int n; - + n = rb_scan_args (argc, argv, "04", &x, &y, &width, &height); if (n == 0) @@ -916,7 +916,7 @@ cr_image_surface_create_for_data (VALUE self, VALUE rb_data, VALUE format, unsigned char *data; data = (unsigned char *)StringValuePtr (rb_data); - + return cairo_image_surface_create_for_data (data, RVAL2CRFORMAT (format), NUM2INT (width), @@ -930,7 +930,7 @@ cr_image_surface_initialize (int argc, VALUE *argv, VALUE self) cairo_surface_t *surface; VALUE arg1, arg2, arg3, arg4, arg5; int n; - + n = rb_scan_args (argc, argv, "23", &arg1, &arg2, &arg3, &arg4, &arg5); if (n == 2) @@ -1985,12 +1985,12 @@ Init_cairo_surface (void) /* Image-surface */ rb_cCairo_ImageSurface = rb_define_class_under (rb_mCairo, "ImageSurface", rb_cCairo_Surface); - + #ifdef CAIRO_HAS_PNG_FUNCTIONS rb_define_singleton_method (rb_cCairo_ImageSurface, "from_png", cr_image_surface_create_from_png_generic, 1); #endif - + rb_define_method (rb_cCairo_ImageSurface, "initialize", cr_image_surface_initialize, -1); From null+rcairo at clear-code.com Sun Apr 8 09:59:08 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sun, 08 Apr 2012 18:59:08 +0900 Subject: [cairo-commit:00188] rcairo/rcairo [master] surface: define classes even if the surface isn't available Message-ID: <20120408095921.48ABC9A0A5@jenkins.clear-code.com> Kouhei Sutou 2012-04-08 18:59:08 +0900 (Sun, 08 Apr 2012) New Revision: 044d4a10f5cf6eb109e190a37fe2e9f679840a5a Log: surface: define classes even if the surface isn't available Modified files: ext/cairo/rb_cairo_surface.c Modified: ext/cairo/rb_cairo_surface.c (+38 -44) =================================================================== --- ext/cairo/rb_cairo_surface.c 2012-04-08 17:18:10 +0900 (7794bed) +++ ext/cairo/rb_cairo_surface.c 2012-04-08 18:59:08 +0900 (a420fdd) @@ -2005,11 +2005,10 @@ Init_cairo_surface (void) rb_define_method (rb_cCairo_ImageSurface, "stride", cr_image_surface_get_stride, 0); -#ifdef CAIRO_HAS_RECORDING_SURFACE /* Recording-surface */ rb_cCairo_RecordingSurface = rb_define_class_under (rb_mCairo, "RecordingSurface", rb_cCairo_Surface); - +#ifdef CAIRO_HAS_RECORDING_SURFACE rb_define_method (rb_cCairo_RecordingSurface, "initialize", cr_recording_surface_initialize, -1); @@ -2021,18 +2020,12 @@ Init_cairo_surface (void) # endif #endif -#define INIT_SURFACE(type, name) \ - rb_cCairo_ ## name ## Surface = \ - rb_define_class_under (rb_mCairo, # name "Surface", \ - rb_cCairo_Surface); \ - \ - rb_define_method (rb_cCairo_ ## name ## Surface, "initialize", \ - cr_ ## type ## _surface_initialize, -1); - -#ifdef CAIRO_HAS_PS_SURFACE /* PS-surface */ - INIT_SURFACE(ps, PS) - + rb_cCairo_PSSurface = + rb_define_class_under (rb_mCairo, "PSSurface", rb_cCairo_Surface); +#ifdef CAIRO_HAS_PS_SURFACE + rb_define_method (rb_cCairo_PSSurface, "initialize", + cr_ps_surface_initialize, -1); rb_define_method (rb_cCairo_PSSurface, "set_size", cr_ps_surface_set_size, -1); rb_define_method (rb_cCairo_PSSurface, "dsc_comment", cr_ps_surface_dsc_comment, 1); @@ -2051,9 +2044,12 @@ Init_cairo_surface (void) RB_CAIRO_DEF_SETTERS (rb_cCairo_PSSurface); #endif -#ifdef CAIRO_HAS_PDF_SURFACE /* PDF-surface */ - INIT_SURFACE(pdf, PDF) + rb_cCairo_PDFSurface = + rb_define_class_under (rb_mCairo, "PDFSurface", rb_cCairo_Surface); +#ifdef CAIRO_HAS_PDF_SURFACE + rb_define_method (rb_cCairo_PDFSurface, "initialize", + cr_pdf_surface_initialize, -1); rb_define_method (rb_cCairo_PDFSurface, "set_size", cr_pdf_surface_set_size, -1); @@ -2066,35 +2062,44 @@ Init_cairo_surface (void) RB_CAIRO_DEF_SETTERS (rb_cCairo_PDFSurface); #endif -#ifdef CAIRO_HAS_XLIB_SURFACE /* XLib-surface */ - INIT_SURFACE(xlib, XLib) + rb_cCairo_XLibSurface = + rb_define_class_under (rb_mCairo, "XLibSurface", rb_cCairo_Surface); +#ifdef CAIRO_HAS_XLIB_SURFACE + rb_define_method (rb_cCairo_XLibSurface, "initialize", + cr_xlib_surface_initialize, -1); RB_CAIRO_DEF_SETTERS (rb_cCairo_XLibSurface); #endif + /* XCB-surface */ + rb_cCairo_XCBSurface = + rb_define_class_under (rb_mCairo, "XCBSurface", rb_cCairo_Surface); #ifdef CAIRO_HAS_XCB_SURFACE - /* XLib-surface */ - INIT_SURFACE(xcb, XCB) + rb_define_method (rb_cCairo_XCBSurface, "initialize", + cr_xcb_surface_initialize, -1); RB_CAIRO_DEF_SETTERS (rb_cCairo_XCBSurface); #endif -#ifdef CAIRO_HAS_SVG_SURFACE /* SVG-surface */ - INIT_SURFACE(svg, SVG) - + rb_cCairo_SVGSurface = + rb_define_class_under (rb_mCairo, "SVGSurface", rb_cCairo_Surface); +#ifdef CAIRO_HAS_SVG_SURFACE + rb_define_method (rb_cCairo_SVGSurface, "initialize", + cr_svg_surface_initialize, -1); rb_define_method (rb_cCairo_SVGSurface, "restrict_to_version", cr_svg_surface_restrict_to_version, 1); RB_CAIRO_DEF_SETTERS (rb_cCairo_SVGSurface); #endif -#ifdef CAIRO_HAS_WIN32_SURFACE /* Win32-surface */ rb_cCairo_Win32Surface = rb_define_class_under (rb_mCairo, "Win32Surface", rb_cCairo_Surface); - + rb_cCairo_Win32PrintingSurface = + rb_define_class_under (rb_mCairo, "Win32PrintingSurface", rb_cCairo_Surface); +#ifdef CAIRO_HAS_WIN32_SURFACE rb_define_method (rb_cCairo_Win32Surface, "initialize", cr_win32_surface_initialize, -1); rb_define_method (rb_cCairo_Win32Surface, "hdc", @@ -2105,9 +2110,6 @@ Init_cairo_surface (void) # endif # if CAIRO_CHECK_VERSION(1, 5, 2) - rb_cCairo_Win32PrintingSurface = - rb_define_class_under (rb_mCairo, "Win32PrintingSurface", rb_cCairo_Surface); - rb_define_method (rb_cCairo_Win32PrintingSurface, "initialize", cr_win32_printing_surface_initialize, -1); rb_define_method (rb_cCairo_Win32PrintingSurface, "hdc", @@ -2116,21 +2118,18 @@ Init_cairo_surface (void) #endif -#ifdef RB_CAIRO_HAS_QUARTZ_SURFACE /* Quartz-surface */ - rb_cCairo_QuartzSurface = rb_define_class_under (rb_mCairo, "QuartzSurface", rb_cCairo_Surface); - + rb_cCairo_QuartzImageSurface = + rb_define_class_under (rb_mCairo, "QuartzImageSurface", 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); # 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_QuartzImageSurface, "image", @@ -2138,30 +2137,27 @@ Init_cairo_surface (void) # endif #endif -#ifdef CAIRO_HAS_SCRIPT_SURFACE rb_cCairo_ScriptSurface = rb_define_class_under (rb_mCairo, "ScriptSurface", rb_cCairo_Surface); - +#ifdef CAIRO_HAS_SCRIPT_SURFACE rb_define_method (rb_cCairo_ScriptSurface, "initialize", cr_script_surface_initialize, -1); RB_CAIRO_DEF_SETTERS (rb_cCairo_ScriptSurface); #endif -#ifdef CAIRO_HAS_XML_SURFACE rb_cCairo_XMLSurface = rb_define_class_under (rb_mCairo, "XMLSurface", rb_cCairo_Surface); - +#ifdef CAIRO_HAS_XML_SURFACE rb_define_method (rb_cCairo_XMLSurface, "initialize", cr_xml_surface_initialize, -1); RB_CAIRO_DEF_SETTERS (rb_cCairo_XMLSurface); #endif -#ifdef CAIRO_HAS_TEE_SURFACE rb_cCairo_TeeSurface = rb_define_class_under (rb_mCairo, "TeeSurface", rb_cCairo_Surface); - +#ifdef CAIRO_HAS_TEE_SURFACE rb_define_method (rb_cCairo_TeeSurface, "initialize", cr_tee_surface_initialize, 1); @@ -2177,10 +2173,11 @@ Init_cairo_surface (void) RB_CAIRO_DEF_SETTERS (rb_cCairo_TeeSurface); #endif -#ifdef RB_CAIRO_HAS_GL_SURFACE rb_cCairo_GLSurface = rb_define_class_under (rb_mCairo, "GLSurface", rb_cCairo_Surface); - + rb_cCairo_GLTextureSurface = + rb_define_class_under (rb_mCairo, "GLTextureSurface", rb_cCairo_GLSurface); +#ifdef RB_CAIRO_HAS_GL_SURFACE rb_define_method (rb_cCairo_GLSurface, "initialize", cr_gl_surface_initialize, 1); @@ -2195,9 +2192,6 @@ Init_cairo_surface (void) RB_CAIRO_DEF_SETTERS (rb_cCairo_GLSurface); - rb_cCairo_GLTextureSurface = - rb_define_class_under (rb_mCairo, "GLTextureSurface", rb_cCairo_GLSurface); - rb_define_method (rb_cCairo_GLTextureSurface, "initialize", cr_gl_texture_surface_initialize, 1); From null+rcairo at clear-code.com Sun Apr 8 10:23:43 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sun, 08 Apr 2012 19:23:43 +0900 Subject: [cairo-commit:00189] rcairo/rcairo [master] surface: order supported? methods by CAIRO_SURFACE_TYPE_* Message-ID: <20120408102354.2C6939A0A5@jenkins.clear-code.com> Kouhei Sutou 2012-04-08 19:23:43 +0900 (Sun, 08 Apr 2012) New Revision: 461c13b2d25cc5838b8f71d4f083b7d445de4d80 Log: surface: order supported? methods by CAIRO_SURFACE_TYPE_* Modified files: ext/cairo/rb_cairo_surface.c Modified: ext/cairo/rb_cairo_surface.c (+34 -34) =================================================================== --- ext/cairo/rb_cairo_surface.c 2012-04-08 18:59:08 +0900 (a420fdd) +++ ext/cairo/rb_cairo_surface.c 2012-04-08 19:23:43 +0900 (bd57b00) @@ -219,9 +219,9 @@ cr_surface_image_supported_p (VALUE klass) } static VALUE -cr_surface_recording_supported_p (VALUE klass) +cr_surface_pdf_supported_p (VALUE klass) { -#ifdef CAIRO_HAS_RECORDING_SURFACE +#ifdef CAIRO_HAS_PDF_SURFACE return Qtrue; #else return Qfalse; @@ -239,9 +239,9 @@ cr_surface_ps_supported_p (VALUE klass) } static VALUE -cr_surface_pdf_supported_p (VALUE klass) +cr_surface_xcb_supported_p (VALUE klass) { -#ifdef CAIRO_HAS_PDF_SURFACE +#ifdef CAIRO_HAS_XCB_SURFACE return Qtrue; #else return Qfalse; @@ -249,9 +249,9 @@ cr_surface_pdf_supported_p (VALUE klass) } static VALUE -cr_surface_xcb_supported_p (VALUE klass) +cr_surface_quartz_supported_p (VALUE klass) { -#ifdef CAIRO_HAS_XCB_SURFACE +#ifdef RB_CAIRO_HAS_QUARTZ_SURFACE return Qtrue; #else return Qfalse; @@ -259,9 +259,9 @@ cr_surface_xcb_supported_p (VALUE klass) } static VALUE -cr_surface_svg_supported_p (VALUE klass) +cr_surface_win32_supported_p (VALUE klass) { -#ifdef CAIRO_HAS_SVG_SURFACE +#ifdef CAIRO_HAS_WIN32_SURFACE return Qtrue; #else return Qfalse; @@ -269,9 +269,9 @@ cr_surface_svg_supported_p (VALUE klass) } static VALUE -cr_surface_win32_supported_p (VALUE klass) +cr_surface_svg_supported_p (VALUE klass) { -#ifdef CAIRO_HAS_WIN32_SURFACE +#ifdef CAIRO_HAS_SVG_SURFACE return Qtrue; #else return Qfalse; @@ -279,9 +279,9 @@ cr_surface_win32_supported_p (VALUE klass) } static VALUE -cr_surface_quartz_supported_p (VALUE klass) +cr_surface_script_supported_p (VALUE klass) { -#ifdef RB_CAIRO_HAS_QUARTZ_SURFACE +#ifdef CAIRO_HAS_SCRIPT_SURFACE return Qtrue; #else return Qfalse; @@ -289,9 +289,9 @@ cr_surface_quartz_supported_p (VALUE klass) } static VALUE -cr_surface_script_supported_p (VALUE klass) +cr_surface_recording_supported_p (VALUE klass) { -#ifdef CAIRO_HAS_SCRIPT_SURFACE +#ifdef CAIRO_HAS_RECORDING_SURFACE return Qtrue; #else return Qfalse; @@ -299,9 +299,9 @@ cr_surface_script_supported_p (VALUE klass) } static VALUE -cr_surface_xml_supported_p (VALUE klass) +cr_surface_gl_supported_p (VALUE klass) { -#ifdef CAIRO_HAS_XML_SURFACE +#ifdef RB_CAIRO_HAS_GL_SURFACE return Qtrue; #else return Qfalse; @@ -309,9 +309,9 @@ cr_surface_xml_supported_p (VALUE klass) } static VALUE -cr_surface_tee_supported_p (VALUE klass) +cr_surface_gl_texture_supported_p (VALUE klass) { -#ifdef CAIRO_HAS_TEE_SURFACE +#ifdef RB_CAIRO_HAS_GL_SURFACE return Qtrue; #else return Qfalse; @@ -319,9 +319,9 @@ cr_surface_tee_supported_p (VALUE klass) } static VALUE -cr_surface_gl_supported_p (VALUE klass) +cr_surface_tee_supported_p (VALUE klass) { -#ifdef RB_CAIRO_HAS_GL_SURFACE +#ifdef CAIRO_HAS_TEE_SURFACE return Qtrue; #else return Qfalse; @@ -329,9 +329,9 @@ cr_surface_gl_supported_p (VALUE klass) } static VALUE -cr_surface_gl_texture_supported_p (VALUE klass) +cr_surface_xml_supported_p (VALUE klass) { -#ifdef RB_CAIRO_HAS_GL_SURFACE +#ifdef CAIRO_HAS_XML_SURFACE return Qtrue; #else return Qfalse; @@ -1894,30 +1894,30 @@ Init_cairo_surface (void) rb_define_singleton_method (rb_cCairo_Surface, "image_supported?", cr_surface_image_supported_p, 0); - rb_define_singleton_method (rb_cCairo_Surface, "recording_supported?", - cr_surface_recording_supported_p, 0); - rb_define_singleton_method (rb_cCairo_Surface, "ps_supported?", - cr_surface_ps_supported_p, 0); rb_define_singleton_method (rb_cCairo_Surface, "pdf_supported?", cr_surface_pdf_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "ps_supported?", + cr_surface_ps_supported_p, 0); rb_define_singleton_method (rb_cCairo_Surface, "xcb_supported?", cr_surface_xcb_supported_p, 0); - rb_define_singleton_method (rb_cCairo_Surface, "svg_supported?", - cr_surface_svg_supported_p, 0); - rb_define_singleton_method (rb_cCairo_Surface, "win32_supported?", - cr_surface_win32_supported_p, 0); rb_define_singleton_method (rb_cCairo_Surface, "quartz_supported?", cr_surface_quartz_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "win32_supported?", + cr_surface_win32_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "svg_supported?", + cr_surface_svg_supported_p, 0); rb_define_singleton_method (rb_cCairo_Surface, "script_supported?", cr_surface_script_supported_p, 0); - rb_define_singleton_method (rb_cCairo_Surface, "xml_supported?", - cr_surface_xml_supported_p, 0); - rb_define_singleton_method (rb_cCairo_Surface, "tee_supported?", - cr_surface_tee_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "recording_supported?", + cr_surface_recording_supported_p, 0); rb_define_singleton_method (rb_cCairo_Surface, "gl_supported?", cr_surface_gl_supported_p, 0); rb_define_singleton_method (rb_cCairo_Surface, "gl_texture_supported?", cr_surface_gl_texture_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "tee_supported?", + cr_surface_tee_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "xml_supported?", + cr_surface_xml_supported_p, 0); rb_define_method (rb_cCairo_Surface, "initialize", cr_surface_initialize, -1); From null+rcairo at clear-code.com Sun Apr 8 10:44:44 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sun, 08 Apr 2012 19:44:44 +0900 Subject: [cairo-commit:00190] rcairo/rcairo [master] surface: add missing supported? methods and remove needless one Message-ID: <20120408104457.27D109A0A5@jenkins.clear-code.com> Kouhei Sutou 2012-04-08 19:44:44 +0900 (Sun, 08 Apr 2012) New Revision: e52cd532016577597c440b8bd24c97ee31454be2 Log: surface: add missing supported? methods and remove needless one Modified files: ext/cairo/rb_cairo_surface.c Modified: ext/cairo/rb_cairo_surface.c (+29 -15) =================================================================== --- ext/cairo/rb_cairo_surface.c 2012-04-08 19:23:43 +0900 (bd57b00) +++ ext/cairo/rb_cairo_surface.c 2012-04-08 19:44:44 +0900 (c41e99b) @@ -27,6 +27,9 @@ # define OpenFile OpenFile_win32 # include # undef OpenFile +# if CAIRO_CHECK_VERSION(1, 5, 2) +# define RB_CAIRO_HAS_WIN32_PRINTING_SURFACE +# endif #endif #ifdef HAVE_RUBY_IO_H @@ -46,6 +49,9 @@ enum ruby_value_type { # define T_DATA RUBY_T_DATA # ifdef HAVE_RUBY_COCOA # define RB_CAIRO_HAS_QUARTZ_SURFACE +# if CAIRO_CHECK_VERSION(1, 5, 12) +# define RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE +# endif # endif #endif @@ -239,9 +245,9 @@ cr_surface_ps_supported_p (VALUE klass) } static VALUE -cr_surface_xcb_supported_p (VALUE klass) +cr_surface_quartz_supported_p (VALUE klass) { -#ifdef CAIRO_HAS_XCB_SURFACE +#ifdef RB_CAIRO_HAS_QUARTZ_SURFACE return Qtrue; #else return Qfalse; @@ -249,9 +255,9 @@ cr_surface_xcb_supported_p (VALUE klass) } static VALUE -cr_surface_quartz_supported_p (VALUE klass) +cr_surface_win32_supported_p (VALUE klass) { -#ifdef RB_CAIRO_HAS_QUARTZ_SURFACE +#ifdef CAIRO_HAS_WIN32_SURFACE return Qtrue; #else return Qfalse; @@ -259,9 +265,9 @@ cr_surface_quartz_supported_p (VALUE klass) } static VALUE -cr_surface_win32_supported_p (VALUE klass) +cr_surface_svg_supported_p (VALUE klass) { -#ifdef CAIRO_HAS_WIN32_SURFACE +#ifdef CAIRO_HAS_SVG_SURFACE return Qtrue; #else return Qfalse; @@ -269,9 +275,19 @@ cr_surface_win32_supported_p (VALUE klass) } static VALUE -cr_surface_svg_supported_p (VALUE klass) +cr_surface_win32_printing_supported_p (VALUE klass) { -#ifdef CAIRO_HAS_SVG_SURFACE +#ifdef RB_CAIRO_HAS_WIN32_PRINTING_SURFACE + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +cr_surface_quartz_image_supported_p (VALUE klass) +{ +#ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE return Qtrue; #else return Qfalse; @@ -311,11 +327,7 @@ cr_surface_gl_supported_p (VALUE klass) static VALUE cr_surface_gl_texture_supported_p (VALUE klass) { -#ifdef RB_CAIRO_HAS_GL_SURFACE - return Qtrue; -#else - return Qfalse; -#endif + return cr_surface_gl_supported_p(klass); } static VALUE @@ -1898,14 +1910,16 @@ Init_cairo_surface (void) cr_surface_pdf_supported_p, 0); rb_define_singleton_method (rb_cCairo_Surface, "ps_supported?", cr_surface_ps_supported_p, 0); - rb_define_singleton_method (rb_cCairo_Surface, "xcb_supported?", - cr_surface_xcb_supported_p, 0); rb_define_singleton_method (rb_cCairo_Surface, "quartz_supported?", cr_surface_quartz_supported_p, 0); rb_define_singleton_method (rb_cCairo_Surface, "win32_supported?", cr_surface_win32_supported_p, 0); rb_define_singleton_method (rb_cCairo_Surface, "svg_supported?", cr_surface_svg_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "win32_printing_supported?", + cr_surface_win32_printing_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Surface, "quartz_image_supported?", + cr_surface_quartz_image_supported_p, 0); rb_define_singleton_method (rb_cCairo_Surface, "script_supported?", cr_surface_script_supported_p, 0); rb_define_singleton_method (rb_cCairo_Surface, "recording_supported?", From null+rcairo at clear-code.com Sun Apr 8 10:52:21 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sun, 08 Apr 2012 19:52:21 +0900 Subject: [cairo-commit:00191] rcairo/rcairo [master] surface: use type availablity check macros instead of version check macros Message-ID: <20120408105234.F35949A0A5@jenkins.clear-code.com> Kouhei Sutou 2012-04-08 19:52:21 +0900 (Sun, 08 Apr 2012) New Revision: 3b23aa8f9749630d9c2247e20ecddb16d963899c Log: surface: use type availablity check macros instead of version check macros Modified files: ext/cairo/rb_cairo_surface.c Modified: ext/cairo/rb_cairo_surface.c (+34 -26) =================================================================== --- ext/cairo/rb_cairo_surface.c 2012-04-08 19:44:44 +0900 (c41e99b) +++ ext/cairo/rb_cairo_surface.c 2012-04-08 19:52:21 +0900 (ed55ae1) @@ -23,11 +23,19 @@ # include #endif +#if CAIRO_CHECK_VERSION(1, 5, 2) +# define RB_CAIRO_HAS_WIN32_PRINTING_SURFACE_TYPE +#endif + +#if CAIRO_CHECK_VERSION(1, 5, 12) +# define RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE_TYPE +#endif + #ifdef CAIRO_HAS_WIN32_SURFACE # define OpenFile OpenFile_win32 # include # undef OpenFile -# if CAIRO_CHECK_VERSION(1, 5, 2) +# ifdef RB_CAIRO_HAS_WIN32_PRINTING_SURFACE_TYPE # define RB_CAIRO_HAS_WIN32_PRINTING_SURFACE # endif #endif @@ -49,7 +57,7 @@ enum ruby_value_type { # define T_DATA RUBY_T_DATA # ifdef HAVE_RUBY_COCOA # define RB_CAIRO_HAS_QUARTZ_SURFACE -# if CAIRO_CHECK_VERSION(1, 5, 12) +# ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE_TYPE # define RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE # endif # endif @@ -160,12 +168,12 @@ cr_surface_get_klass (cairo_surface_t *surface) case CAIRO_SURFACE_TYPE_SVG: klass = rb_cCairo_SVGSurface; break; -#if CAIRO_CHECK_VERSION(1, 5, 2) +#ifdef RB_CAIRO_HAS_WIN32_PRINTING_SURFACE_TYPE case CAIRO_SURFACE_TYPE_WIN32_PRINTING: klass = rb_cCairo_Win32PrintingSurface; break; #endif -#if CAIRO_CHECK_VERSION(1, 5, 12) +#ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE_TYPE case CAIRO_SURFACE_TYPE_QUARTZ_IMAGE: klass = rb_cCairo_QuartzImageSurface; break; @@ -1399,21 +1407,6 @@ cr_win32_surface_initialize (int argc, VALUE *argv, VALUE self) return Qnil; } -# if CAIRO_CHECK_VERSION(1, 5, 2) -static VALUE -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 - static VALUE cr_win32_surface_get_hdc (VALUE self) { @@ -1441,6 +1434,21 @@ cr_win32_surface_get_image (VALUE self) # endif #endif +#ifdef RB_CAIRO_HAS_WIN32_PRINTING_SURFACE +static VALUE +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_SURFACE /* Quartz-surface functions */ @@ -1532,7 +1540,9 @@ cr_quartz_surface_get_cg_context (VALUE self) return ocid_to_rbobj (Qnil, objc_object); } -# if CAIRO_CHECK_VERSION(1, 5, 12) +#endif + +#ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE static VALUE cr_quartz_image_surface_initialize (VALUE self, VALUE image_surface) { @@ -1557,7 +1567,6 @@ cr_quartz_image_surface_get_image (VALUE self) cr_surface_check_status (surface); return CRSURFACE2RVAL (surface); } -# endif #endif #ifdef CAIRO_HAS_SCRIPT_SURFACE @@ -2122,14 +2131,13 @@ Init_cairo_surface (void) rb_define_method (rb_cCairo_Win32Surface, "image", cr_win32_surface_get_image, 0); # endif +#endif -# if CAIRO_CHECK_VERSION(1, 5, 2) +#ifdef RB_CAIRO_HAS_WIN32_PRINTING_SURFACE 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); -# endif - #endif /* Quartz-surface */ @@ -2142,13 +2150,13 @@ Init_cairo_surface (void) cr_quartz_surface_initialize, -1); rb_define_method (rb_cCairo_QuartzSurface, "cg_context", cr_quartz_surface_get_cg_context, 0); +#endif -# if CAIRO_CHECK_VERSION(1, 5, 12) +#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 #endif rb_cCairo_ScriptSurface = From null+rcairo at clear-code.com Sun Apr 8 10:53:56 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sun, 08 Apr 2012 19:53:56 +0900 Subject: [cairo-commit:00192] rcairo/rcairo [master] surface: remove meaningless intitialize methods Message-ID: <20120408105408.AFF849A0A5@jenkins.clear-code.com> Kouhei Sutou 2012-04-08 19:53:56 +0900 (Sun, 08 Apr 2012) New Revision: da5516998c4317a79a5622627eb3bfa8421d1b23 Log: surface: remove meaningless intitialize methods Modified files: ext/cairo/rb_cairo_surface.c Modified: ext/cairo/rb_cairo_surface.c (+0 -30) =================================================================== --- ext/cairo/rb_cairo_surface.c 2012-04-08 19:52:21 +0900 (ed55ae1) +++ ext/cairo/rb_cairo_surface.c 2012-04-08 19:53:56 +0900 (52e4cad) @@ -1280,24 +1280,6 @@ cr_pdf_surface_restrict_to_version (VALUE self, VALUE version) # endif #endif -#ifdef CAIRO_HAS_XLIB_SURFACE -static VALUE -cr_xlib_surface_initialize (int argc, VALUE *argv, VALUE self) -{ - rb_notimplement(); - return Qnil; -} -#endif - -#ifdef CAIRO_HAS_XCB_SURFACE -static VALUE -cr_xcb_surface_initialize (int argc, VALUE *argv, VALUE self) -{ - rb_notimplement(); - return Qnil; -} -#endif - #ifdef CAIRO_HAS_SVG_SURFACE /* SVG-surface functions */ DEFINE_SURFACE(svg) @@ -2088,22 +2070,10 @@ Init_cairo_surface (void) /* XLib-surface */ rb_cCairo_XLibSurface = rb_define_class_under (rb_mCairo, "XLibSurface", rb_cCairo_Surface); -#ifdef CAIRO_HAS_XLIB_SURFACE - rb_define_method (rb_cCairo_XLibSurface, "initialize", - cr_xlib_surface_initialize, -1); - - RB_CAIRO_DEF_SETTERS (rb_cCairo_XLibSurface); -#endif /* XCB-surface */ rb_cCairo_XCBSurface = rb_define_class_under (rb_mCairo, "XCBSurface", rb_cCairo_Surface); -#ifdef CAIRO_HAS_XCB_SURFACE - rb_define_method (rb_cCairo_XCBSurface, "initialize", - cr_xcb_surface_initialize, -1); - - RB_CAIRO_DEF_SETTERS (rb_cCairo_XCBSurface); -#endif /* SVG-surface */ rb_cCairo_SVGSurface = From null+rcairo at clear-code.com Sun Apr 8 11:06:32 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sun, 08 Apr 2012 20:06:32 +0900 Subject: [cairo-commit:00193] rcairo/rcairo [master] surface: order surface definitions by CAIRO_SURFACE_TYPE_* Message-ID: <20120408110644.36E419A0A5@jenkins.clear-code.com> Kouhei Sutou 2012-04-08 20:06:32 +0900 (Sun, 08 Apr 2012) New Revision: b0fc1fdf2c6157145d50cb467c6d69ebee2b0e32 Log: surface: order surface definitions by CAIRO_SURFACE_TYPE_* Modified files: ext/cairo/rb_cairo_surface.c Modified: ext/cairo/rb_cairo_surface.c (+391 -381) =================================================================== --- ext/cairo/rb_cairo_surface.c 2012-04-08 19:53:56 +0900 (52e4cad) +++ ext/cairo/rb_cairo_surface.c 2012-04-08 20:06:32 +0900 (99839fc) @@ -876,7 +876,7 @@ cr_surface_show_page (VALUE self) } #endif -/* Image-surface functions */ +/* image surface functions */ #ifdef CAIRO_HAS_PNG_FUNCTIONS static cairo_surface_t * cr_image_surface_create_from_png_stream (VALUE target) @@ -1016,94 +1016,7 @@ cr_image_surface_get_stride (VALUE self) return INT2NUM (cairo_image_surface_get_stride (_SELF)); } -#ifdef CAIRO_HAS_RECORDING_SURFACE -/* Recording-surface functions */ -static VALUE -cr_recording_surface_initialize (int argc, VALUE *argv, VALUE self) -{ - VALUE arg1, arg2, arg3, arg4, arg5; - cairo_surface_t *surface; - cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA; - cairo_rectangle_t extents; - const char *error_message = - "invalid argument (expect " - "(x, y, width, height), " - "([x, y, width, height])," - "(x, y, width, height, content) or " - "([x, y, width, height], content)): %s"; - - rb_scan_args (argc, argv, "14", &arg1, &arg2, &arg3, &arg4, &arg5); - if (argc == 1 || argc == 2) - { - VALUE rb_extents; - - rb_extents = rb_check_array_type (arg1); - if (RARRAY_LEN (rb_extents) != 4) - rb_raise (rb_eArgError, error_message, rb_cairo__inspect (arg1)); - extents.x = NUM2DBL (RARRAY_PTR (rb_extents)[0]); - extents.y = NUM2DBL (RARRAY_PTR (rb_extents)[1]); - extents.width = NUM2DBL (RARRAY_PTR (rb_extents)[2]); - extents.height = NUM2DBL (RARRAY_PTR (rb_extents)[3]); - if (!NIL_P (arg2)) - content = RVAL2CRCONTENT (arg2); - } - else if (argc == 4 || argc == 5) - { - extents.x = NUM2DBL (arg1); - extents.y = NUM2DBL (arg2); - extents.width = NUM2DBL (arg3); - extents.height = NUM2DBL (arg4); - if (!NIL_P (arg5)) - content = RVAL2CRCONTENT (arg5); - } - else - { - rb_raise (rb_eArgError, error_message, - rb_cairo__inspect (rb_ary_new4 (argc, argv))); - } - - surface = cairo_recording_surface_create (content, &extents); - cr_surface_check_status (surface); - DATA_PTR (self) = surface; - if (rb_block_given_p ()) - yield_and_finish (self); - return Qnil; -} - -static VALUE -cr_recording_surface_get_ink_extents (VALUE self) -{ - cairo_surface_t *surface; - double x, y, width, height; - - surface = _SELF; - cairo_recording_surface_ink_extents (surface, &x, &y, &width, &height); - cr_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)); -} - -# if CAIRO_CHECK_VERSION(1, 11, 4) -static VALUE -cr_recording_surface_get_extents (VALUE self) -{ - cairo_surface_t *surface; - cairo_rectangle_t extents; - - surface = _SELF; - cairo_recording_surface_get_extents (surface, &extents); - cr_surface_check_status (surface); - return rb_ary_new3 (4, - rb_float_new (extents.x), - rb_float_new (extents.y), - rb_float_new (extents.width), - rb_float_new (extents.height)); -} -# endif -#endif - -/* Printing surfaces */ +/* printing surfaces */ #define DEFINE_SURFACE(type) \ static VALUE \ cr_ ## type ## _surface_initialize (int argc, VALUE *argv, VALUE self) \ @@ -1204,6 +1117,22 @@ cr_ ## type ## _surface_set_size (int argc, VALUE *argv, VALUE self) \ return Qnil; \ } +#ifdef CAIRO_HAS_PDF_SURFACE +/* PDF-surface functions */ +DEFINE_SURFACE(pdf) +DEFINE_SURFACE_SET_SIZE(pdf) + +# if CAIRO_CHECK_VERSION(1, 10, 0) +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); + return Qnil; +} +# endif +#endif + #ifdef CAIRO_HAS_PS_SURFACE /* PS-surface functions */ DEFINE_SURFACE(ps) @@ -1264,46 +1193,108 @@ cr_ps_surface_set_eps (VALUE self, VALUE eps) # endif #endif -#ifdef CAIRO_HAS_PDF_SURFACE -/* PDF-surface functions */ -DEFINE_SURFACE(pdf) -DEFINE_SURFACE_SET_SIZE(pdf) +#ifdef RB_CAIRO_HAS_QUARTZ_SURFACE +/* Quartz-surface functions */ +#include + +BOOL rbobj_to_nsobj (VALUE obj, id* nsobj); +VALUE ocid_to_rbobj (VALUE context_obj, id ocid); -# if CAIRO_CHECK_VERSION(1, 10, 0) static VALUE -cr_pdf_surface_restrict_to_version (VALUE self, VALUE version) +cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self) { - cairo_pdf_surface_restrict_to_version (_SELF, RVAL2CRPDFVERSION (version)); - cr_surface_check_status (_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; + static VALUE rb_cOSXCGContextRef = Qnil; + + 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: + if (NIL_P (rb_cOSXCGContextRef)) + rb_cOSXCGContextRef = + rb_const_get (rb_const_get (rb_cObject, rb_intern ("OSX")), + rb_intern ("CGContextRef")); + + if (RTEST (rb_obj_is_kind_of (arg1, rb_cOSXCGContextRef))) + rbobj_to_nsobj (arg1, &objc_object); + else + rb_raise (rb_eArgError, + "invalid argument (expect " + "(width, height), " + "(format, width, height) or " + "(cg_context, 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; } -# endif -#endif - -#ifdef CAIRO_HAS_SVG_SURFACE -/* SVG-surface functions */ -DEFINE_SURFACE(svg) static VALUE -cr_svg_surface_restrict_to_version (VALUE self, VALUE version) +cr_quartz_surface_get_cg_context (VALUE self) { - cairo_svg_surface_restrict_to_version (_SELF, RVAL2CRSVGVERSION (version)); - cr_surface_check_status (_SELF); - return Qnil; + CGContextRef context; + id objc_object; + + context = cairo_quartz_surface_get_cg_context (_SELF); + objc_object = (id)context; + return ocid_to_rbobj (Qnil, objc_object); } #endif #ifdef CAIRO_HAS_WIN32_SURFACE -/* WIN32-surface functions */ +/* Win32 surface functions */ /* from dl/dl.h (ruby 1.9) */ -#if SIZEOF_LONG == SIZEOF_VOIDP -# define PTR2NUM(x) (ULONG2NUM((unsigned long)(x))) -# define NUM2PTR(x) ((void *)(NUM2ULONG(x))) -#else -# define PTR2NUM(x) (ULL2NUM((unsigned long long)(x))) -# define NUM2PTR(x) ((void *)(NUM2ULL(x))) -#endif +# if SIZEOF_LONG == SIZEOF_VOIDP +# define PTR2NUM(x) (ULONG2NUM((unsigned long)(x))) +# define NUM2PTR(x) ((void *)(NUM2ULONG(x))) +# else +# define PTR2NUM(x) (ULL2NUM((unsigned long long)(x))) +# define NUM2PTR(x) ((void *)(NUM2ULL(x))) +# endif static VALUE cr_win32_surface_initialize (int argc, VALUE *argv, VALUE self) @@ -1416,115 +1407,37 @@ cr_win32_surface_get_image (VALUE self) # endif #endif -#ifdef RB_CAIRO_HAS_WIN32_PRINTING_SURFACE +#ifdef CAIRO_HAS_SVG_SURFACE +/* SVG-surface functions */ +DEFINE_SURFACE(svg) + static VALUE -cr_win32_printing_surface_initialize (VALUE self, VALUE hdc) +cr_svg_surface_restrict_to_version (VALUE self, VALUE version) { - 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); + cairo_svg_surface_restrict_to_version (_SELF, RVAL2CRSVGVERSION (version)); + cr_surface_check_status (_SELF); return Qnil; } #endif -#ifdef RB_CAIRO_HAS_QUARTZ_SURFACE -/* Quartz-surface functions */ - -#include - -BOOL rbobj_to_nsobj (VALUE obj, id* nsobj); -VALUE ocid_to_rbobj (VALUE context_obj, id ocid); - +#ifdef RB_CAIRO_HAS_WIN32_PRINTING_SURFACE +/* Win32 printing surface functions */ static VALUE -cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self) +cr_win32_printing_surface_initialize (VALUE self, VALUE hdc) { - 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; - static VALUE rb_cOSXCGContextRef = Qnil; - - 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: - if (NIL_P (rb_cOSXCGContextRef)) - rb_cOSXCGContextRef = - rb_const_get (rb_const_get (rb_cObject, rb_intern ("OSX")), - rb_intern ("CGContextRef")); - - if (RTEST (rb_obj_is_kind_of (arg1, rb_cOSXCGContextRef))) - rbobj_to_nsobj (arg1, &objc_object); - else - rb_raise (rb_eArgError, - "invalid argument (expect " - "(width, height), " - "(format, width, height) or " - "(cg_context, 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); - } + 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; } - -static VALUE -cr_quartz_surface_get_cg_context (VALUE self) -{ - CGContextRef context; - id objc_object; - - context = cairo_quartz_surface_get_cg_context (_SELF); - objc_object = (id)context; - return ocid_to_rbobj (Qnil, objc_object); -} - #endif #ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE +/* Quartz image surface functions */ static VALUE cr_quartz_image_surface_initialize (VALUE self, VALUE image_surface) { @@ -1552,6 +1465,7 @@ cr_quartz_image_surface_get_image (VALUE self) #endif #ifdef CAIRO_HAS_SCRIPT_SURFACE +/* script surface functions */ static VALUE cr_script_surface_initialize (int argc, VALUE *argv, VALUE self) { @@ -1605,13 +1519,101 @@ cr_script_surface_initialize (int argc, VALUE *argv, VALUE self) } #endif -#ifdef CAIRO_HAS_XML_SURFACE +#ifdef CAIRO_HAS_RECORDING_SURFACE +/* recording surface functions */ static VALUE -cr_xml_surface_initialize (int argc, VALUE *argv, VALUE self) +cr_recording_surface_initialize (int argc, VALUE *argv, VALUE self) +{ + VALUE arg1, arg2, arg3, arg4, arg5; + cairo_surface_t *surface; + cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA; + cairo_rectangle_t extents; + const char *error_message = + "invalid argument (expect " + "(x, y, width, height), " + "([x, y, width, height])," + "(x, y, width, height, content) or " + "([x, y, width, height], content)): %s"; + + rb_scan_args (argc, argv, "14", &arg1, &arg2, &arg3, &arg4, &arg5); + if (argc == 1 || argc == 2) + { + VALUE rb_extents; + + rb_extents = rb_check_array_type (arg1); + if (RARRAY_LEN (rb_extents) != 4) + rb_raise (rb_eArgError, error_message, rb_cairo__inspect (arg1)); + extents.x = NUM2DBL (RARRAY_PTR (rb_extents)[0]); + extents.y = NUM2DBL (RARRAY_PTR (rb_extents)[1]); + extents.width = NUM2DBL (RARRAY_PTR (rb_extents)[2]); + extents.height = NUM2DBL (RARRAY_PTR (rb_extents)[3]); + if (!NIL_P (arg2)) + content = RVAL2CRCONTENT (arg2); + } + else if (argc == 4 || argc == 5) + { + extents.x = NUM2DBL (arg1); + extents.y = NUM2DBL (arg2); + extents.width = NUM2DBL (arg3); + extents.height = NUM2DBL (arg4); + if (!NIL_P (arg5)) + content = RVAL2CRCONTENT (arg5); + } + else + { + rb_raise (rb_eArgError, error_message, + rb_cairo__inspect (rb_ary_new4 (argc, argv))); + } + + surface = cairo_recording_surface_create (content, &extents); + cr_surface_check_status (surface); + DATA_PTR (self) = surface; + if (rb_block_given_p ()) + yield_and_finish (self); + return Qnil; +} + +static VALUE +cr_recording_surface_get_ink_extents (VALUE self) +{ + cairo_surface_t *surface; + double x, y, width, height; + + surface = _SELF; + cairo_recording_surface_ink_extents (surface, &x, &y, &width, &height); + cr_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)); +} + +# if CAIRO_CHECK_VERSION(1, 11, 4) +static VALUE +cr_recording_surface_get_extents (VALUE self) +{ + cairo_surface_t *surface; + cairo_rectangle_t extents; + + surface = _SELF; + cairo_recording_surface_get_extents (surface, &extents); + cr_surface_check_status (surface); + return rb_ary_new3 (4, + rb_float_new (extents.x), + rb_float_new (extents.y), + rb_float_new (extents.width), + rb_float_new (extents.height)); +} +# endif +#endif + +#ifdef RB_CAIRO_HAS_GL_SURFACE +/* GL surface functions */ +static VALUE +cr_gl_surface_initialize (int argc, VALUE *argv, VALUE self) { cairo_surface_t *surface; cairo_device_t *device; - double width, height; + int width, height; cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA; VALUE rb_device, rb_width, rb_height, rb_content; @@ -1619,8 +1621,8 @@ cr_xml_surface_initialize (int argc, VALUE *argv, VALUE self) &rb_device, &rb_width, &rb_height, &rb_content); device = RVAL2CRDEVICE (rb_device); - width = NUM2DBL (rb_width); - height = NUM2DBL (rb_height); + width = NUM2INT (rb_width); + height = NUM2INT (rb_height); switch (TYPE (rb_content)) { case T_NIL: @@ -1639,17 +1641,99 @@ cr_xml_surface_initialize (int argc, VALUE *argv, VALUE self) break; } - surface = cairo_xml_surface_create (device, content, width, height); + surface = cairo_gl_surface_create (device, content, 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_gl_texture_surface_initialize (int argc, VALUE *argv, VALUE self) +{ + cairo_surface_t *surface; + cairo_device_t *device; + unsigned int texture; + int width, height; + cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA; + VALUE rb_device, rb_texture, rb_width, rb_height, rb_content; + + rb_scan_args (argc, argv, "41", + &rb_device, &rb_texture, &rb_width, &rb_height, &rb_content); + + device = RVAL2CRDEVICE (rb_device); + texture = NUM2UINT (rb_texture); + width = NUM2INT (rb_width); + height = NUM2INT (rb_height); + switch (TYPE (rb_content)) + { + case T_NIL: + break; + case T_STRING: + case T_SYMBOL: + case T_FIXNUM: + content = RVAL2CRCONTENT (rb_content); + break; + default: + rb_raise (rb_eArgError, + "invalid argument (expect " + "(device, texture, width, height) or " + "(device, texture, width, height, content)): %s", + rb_cairo__inspect (rb_ary_new4 (argc, argv))); + break; + } + + surface = cairo_gl_surface_create_for_texture (device, content, + texture, + 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_gl_surface_set_size (VALUE self, VALUE width, VALUE height) +{ + cairo_surface_t *surface = NULL; + + surface = _SELF; + cairo_gl_surface_set_size (surface, NUM2INT (width), NUM2INT (height)); + cr_surface_check_status (surface); + return Qnil; +} + +static VALUE +cr_gl_surface_get_width (VALUE self) +{ + return INT2NUM (cairo_gl_surface_get_width (_SELF)); +} + +static VALUE +cr_gl_surface_get_height (VALUE self) +{ + return INT2NUM (cairo_gl_surface_get_height (_SELF)); +} + +static VALUE +cr_gl_surface_swap_buffers (VALUE self) +{ + cairo_surface_t *surface = NULL; + surface = _SELF; + cairo_gl_surface_swapbuffers (surface); cr_surface_check_status (surface); - DATA_PTR (self) = surface; - if (rb_block_given_p ()) - yield_and_finish (self); return Qnil; } #endif #ifdef CAIRO_HAS_TEE_SURFACE +/* tee surface functions */ static VALUE cr_tee_surface_initialize (VALUE self, VALUE master) { @@ -1741,13 +1825,14 @@ cr_tee_surface_array_reference (VALUE self, VALUE index) } #endif -#ifdef RB_CAIRO_HAS_GL_SURFACE +#ifdef CAIRO_HAS_XML_SURFACE +/* XML surface functions */ static VALUE -cr_gl_surface_initialize (int argc, VALUE *argv, VALUE self) +cr_xml_surface_initialize (int argc, VALUE *argv, VALUE self) { cairo_surface_t *surface; cairo_device_t *device; - int width, height; + double width, height; cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA; VALUE rb_device, rb_width, rb_height, rb_content; @@ -1755,8 +1840,8 @@ cr_gl_surface_initialize (int argc, VALUE *argv, VALUE self) &rb_device, &rb_width, &rb_height, &rb_content); device = RVAL2CRDEVICE (rb_device); - width = NUM2INT (rb_width); - height = NUM2INT (rb_height); + width = NUM2DBL (rb_width); + height = NUM2DBL (rb_height); switch (TYPE (rb_content)) { case T_NIL: @@ -1775,54 +1860,7 @@ cr_gl_surface_initialize (int argc, VALUE *argv, VALUE self) break; } - surface = cairo_gl_surface_create (device, content, 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_gl_texture_surface_initialize (int argc, VALUE *argv, VALUE self) -{ - cairo_surface_t *surface; - cairo_device_t *device; - unsigned int texture; - int width, height; - cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA; - VALUE rb_device, rb_texture, rb_width, rb_height, rb_content; - - rb_scan_args (argc, argv, "41", - &rb_device, &rb_texture, &rb_width, &rb_height, &rb_content); - - device = RVAL2CRDEVICE (rb_device); - texture = NUM2UINT (rb_texture); - width = NUM2INT (rb_width); - height = NUM2INT (rb_height); - switch (TYPE (rb_content)) - { - case T_NIL: - break; - case T_STRING: - case T_SYMBOL: - case T_FIXNUM: - content = RVAL2CRCONTENT (rb_content); - break; - default: - rb_raise (rb_eArgError, - "invalid argument (expect " - "(device, texture, width, height) or " - "(device, texture, width, height, content)): %s", - rb_cairo__inspect (rb_ary_new4 (argc, argv))); - break; - } - - surface = cairo_gl_surface_create_for_texture (device, content, - texture, - width, - height); + surface = cairo_xml_surface_create (device, content, width, height); cr_surface_check_status (surface); DATA_PTR (self) = surface; @@ -1830,40 +1868,6 @@ cr_gl_texture_surface_initialize (int argc, VALUE *argv, VALUE self) yield_and_finish (self); return Qnil; } - -static VALUE -cr_gl_surface_set_size (VALUE self, VALUE width, VALUE height) -{ - cairo_surface_t *surface = NULL; - - surface = _SELF; - cairo_gl_surface_set_size (surface, NUM2INT (width), NUM2INT (height)); - cr_surface_check_status (surface); - return Qnil; -} - -static VALUE -cr_gl_surface_get_width (VALUE self) -{ - return INT2NUM (cairo_gl_surface_get_width (_SELF)); -} - -static VALUE -cr_gl_surface_get_height (VALUE self) -{ - return INT2NUM (cairo_gl_surface_get_height (_SELF)); -} - -static VALUE -cr_gl_surface_swap_buffers (VALUE self) -{ - cairo_surface_t *surface = NULL; - - surface = _SELF; - cairo_gl_surface_swapbuffers (surface); - cr_surface_check_status (surface); - return Qnil; -} #endif static int @@ -1987,7 +1991,7 @@ Init_cairo_surface (void) RB_CAIRO_DEF_SETTERS (rb_cCairo_Surface); - /* Image-surface */ + /* image surface */ rb_cCairo_ImageSurface = rb_define_class_under (rb_mCairo, "ImageSurface", rb_cCairo_Surface); @@ -2010,22 +2014,25 @@ Init_cairo_surface (void) rb_define_method (rb_cCairo_ImageSurface, "stride", cr_image_surface_get_stride, 0); - /* Recording-surface */ - rb_cCairo_RecordingSurface = - rb_define_class_under (rb_mCairo, "RecordingSurface", rb_cCairo_Surface); -#ifdef CAIRO_HAS_RECORDING_SURFACE - rb_define_method (rb_cCairo_RecordingSurface, "initialize", - cr_recording_surface_initialize, -1); + /* PDF surface */ + rb_cCairo_PDFSurface = + rb_define_class_under (rb_mCairo, "PDFSurface", rb_cCairo_Surface); +#ifdef CAIRO_HAS_PDF_SURFACE + rb_define_method (rb_cCairo_PDFSurface, "initialize", + cr_pdf_surface_initialize, -1); - rb_define_method (rb_cCairo_RecordingSurface, "ink_extents", - cr_recording_surface_get_ink_extents, 0); -# if CAIRO_CHECK_VERSION(1, 11, 4) - rb_define_method (rb_cCairo_RecordingSurface, "extents", - cr_recording_surface_get_extents, 0); + rb_define_method (rb_cCairo_PDFSurface, "set_size", + cr_pdf_surface_set_size, -1); + +# if CAIRO_CHECK_VERSION(1, 10, 0) + rb_define_method (rb_cCairo_PDFSurface, "restrict_to_version", + cr_pdf_surface_restrict_to_version, 1); # endif + + RB_CAIRO_DEF_SETTERS (rb_cCairo_PDFSurface); #endif - /* PS-surface */ + /* PS surface */ rb_cCairo_PSSurface = rb_define_class_under (rb_mCairo, "PSSurface", rb_cCairo_Surface); #ifdef CAIRO_HAS_PS_SURFACE @@ -2049,49 +2056,27 @@ Init_cairo_surface (void) RB_CAIRO_DEF_SETTERS (rb_cCairo_PSSurface); #endif - /* PDF-surface */ - rb_cCairo_PDFSurface = - rb_define_class_under (rb_mCairo, "PDFSurface", rb_cCairo_Surface); -#ifdef CAIRO_HAS_PDF_SURFACE - rb_define_method (rb_cCairo_PDFSurface, "initialize", - cr_pdf_surface_initialize, -1); - - rb_define_method (rb_cCairo_PDFSurface, "set_size", - cr_pdf_surface_set_size, -1); - -# if CAIRO_CHECK_VERSION(1, 10, 0) - rb_define_method (rb_cCairo_PDFSurface, "restrict_to_version", - cr_pdf_surface_restrict_to_version, 1); -# endif - - RB_CAIRO_DEF_SETTERS (rb_cCairo_PDFSurface); -#endif - - /* XLib-surface */ + /* XLib surface */ rb_cCairo_XLibSurface = rb_define_class_under (rb_mCairo, "XLibSurface", rb_cCairo_Surface); - /* XCB-surface */ + /* XCB surface */ rb_cCairo_XCBSurface = rb_define_class_under (rb_mCairo, "XCBSurface", rb_cCairo_Surface); - /* SVG-surface */ - rb_cCairo_SVGSurface = - rb_define_class_under (rb_mCairo, "SVGSurface", rb_cCairo_Surface); -#ifdef CAIRO_HAS_SVG_SURFACE - rb_define_method (rb_cCairo_SVGSurface, "initialize", - cr_svg_surface_initialize, -1); - rb_define_method (rb_cCairo_SVGSurface, "restrict_to_version", - cr_svg_surface_restrict_to_version, 1); - - RB_CAIRO_DEF_SETTERS (rb_cCairo_SVGSurface); + /* 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 */ + /* Win32 surface */ rb_cCairo_Win32Surface = rb_define_class_under (rb_mCairo, "Win32Surface", rb_cCairo_Surface); - rb_cCairo_Win32PrintingSurface = - rb_define_class_under (rb_mCairo, "Win32PrintingSurface", rb_cCairo_Surface); #ifdef CAIRO_HAS_WIN32_SURFACE rb_define_method (rb_cCairo_Win32Surface, "initialize", cr_win32_surface_initialize, -1); @@ -2103,6 +2088,21 @@ Init_cairo_surface (void) # endif #endif + /* SVG surface */ + rb_cCairo_SVGSurface = + rb_define_class_under (rb_mCairo, "SVGSurface", rb_cCairo_Surface); +#ifdef CAIRO_HAS_SVG_SURFACE + rb_define_method (rb_cCairo_SVGSurface, "initialize", + cr_svg_surface_initialize, -1); + rb_define_method (rb_cCairo_SVGSurface, "restrict_to_version", + cr_svg_surface_restrict_to_version, 1); + + RB_CAIRO_DEF_SETTERS (rb_cCairo_SVGSurface); +#endif + + /* Win32 printing surface */ + rb_cCairo_Win32PrintingSurface = + rb_define_class_under (rb_mCairo, "Win32PrintingSurface", rb_cCairo_Surface); #ifdef RB_CAIRO_HAS_WIN32_PRINTING_SURFACE rb_define_method (rb_cCairo_Win32PrintingSurface, "initialize", cr_win32_printing_surface_initialize, -1); @@ -2110,18 +2110,9 @@ Init_cairo_surface (void) cr_win32_surface_get_hdc, 0); #endif - /* Quartz-surface */ - rb_cCairo_QuartzSurface = - rb_define_class_under (rb_mCairo, "QuartzSurface", rb_cCairo_Surface); + /* Quartz image surface */ rb_cCairo_QuartzImageSurface = rb_define_class_under (rb_mCairo, "QuartzImageSurface", 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 - #ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE rb_define_method (rb_cCairo_QuartzImageSurface, "initialize", cr_quartz_image_surface_initialize, 1); @@ -2129,6 +2120,7 @@ Init_cairo_surface (void) cr_quartz_image_surface_get_image, 0); #endif + /* script surface */ rb_cCairo_ScriptSurface = rb_define_class_under (rb_mCairo, "ScriptSurface", rb_cCairo_Surface); #ifdef CAIRO_HAS_SCRIPT_SURFACE @@ -2138,33 +2130,22 @@ Init_cairo_surface (void) RB_CAIRO_DEF_SETTERS (rb_cCairo_ScriptSurface); #endif - rb_cCairo_XMLSurface = - rb_define_class_under (rb_mCairo, "XMLSurface", rb_cCairo_Surface); -#ifdef CAIRO_HAS_XML_SURFACE - rb_define_method (rb_cCairo_XMLSurface, "initialize", - cr_xml_surface_initialize, -1); - - RB_CAIRO_DEF_SETTERS (rb_cCairo_XMLSurface); -#endif - - rb_cCairo_TeeSurface = - rb_define_class_under (rb_mCairo, "TeeSurface", rb_cCairo_Surface); -#ifdef CAIRO_HAS_TEE_SURFACE - rb_define_method (rb_cCairo_TeeSurface, "initialize", - cr_tee_surface_initialize, 1); - - rb_define_method (rb_cCairo_TeeSurface, "add", - cr_tee_surface_add, 1); - rb_define_method (rb_cCairo_TeeSurface, "<<", - cr_tee_surface_shift_operator, 1); - rb_define_method (rb_cCairo_TeeSurface, "remove", - cr_tee_surface_remove, 1); - rb_define_method (rb_cCairo_TeeSurface, "[]", - cr_tee_surface_array_reference, 1); + /* recording surface */ + rb_cCairo_RecordingSurface = + rb_define_class_under (rb_mCairo, "RecordingSurface", rb_cCairo_Surface); +#ifdef CAIRO_HAS_RECORDING_SURFACE + rb_define_method (rb_cCairo_RecordingSurface, "initialize", + cr_recording_surface_initialize, -1); - RB_CAIRO_DEF_SETTERS (rb_cCairo_TeeSurface); + rb_define_method (rb_cCairo_RecordingSurface, "ink_extents", + cr_recording_surface_get_ink_extents, 0); +# if CAIRO_CHECK_VERSION(1, 11, 4) + rb_define_method (rb_cCairo_RecordingSurface, "extents", + cr_recording_surface_get_extents, 0); +# endif #endif + /* GL surface */ rb_cCairo_GLSurface = rb_define_class_under (rb_mCairo, "GLSurface", rb_cCairo_Surface); rb_cCairo_GLTextureSurface = @@ -2189,4 +2170,33 @@ Init_cairo_surface (void) RB_CAIRO_DEF_SETTERS (rb_cCairo_GLTextureSurface); #endif + + /* tee surface */ + rb_cCairo_TeeSurface = + rb_define_class_under (rb_mCairo, "TeeSurface", rb_cCairo_Surface); +#ifdef CAIRO_HAS_TEE_SURFACE + rb_define_method (rb_cCairo_TeeSurface, "initialize", + cr_tee_surface_initialize, 1); + + rb_define_method (rb_cCairo_TeeSurface, "add", + cr_tee_surface_add, 1); + rb_define_method (rb_cCairo_TeeSurface, "<<", + cr_tee_surface_shift_operator, 1); + rb_define_method (rb_cCairo_TeeSurface, "remove", + cr_tee_surface_remove, 1); + rb_define_method (rb_cCairo_TeeSurface, "[]", + cr_tee_surface_array_reference, 1); + + RB_CAIRO_DEF_SETTERS (rb_cCairo_TeeSurface); +#endif + + /* XML surface */ + rb_cCairo_XMLSurface = + rb_define_class_under (rb_mCairo, "XMLSurface", rb_cCairo_Surface); +#ifdef CAIRO_HAS_XML_SURFACE + rb_define_method (rb_cCairo_XMLSurface, "initialize", + cr_xml_surface_initialize, -1); + + RB_CAIRO_DEF_SETTERS (rb_cCairo_XMLSurface); +#endif } From null+rcairo at clear-code.com Sun Apr 8 11:09:45 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sun, 08 Apr 2012 20:09:45 +0900 Subject: [cairo-commit:00194] rcairo/rcairo [master] surface: define all surfaces Message-ID: <20120408110955.9BE5B9A0A5@jenkins.clear-code.com> Kouhei Sutou 2012-04-08 20:09:45 +0900 (Sun, 08 Apr 2012) New Revision: c9f4b327d32d0345c5d2b7a15d0c78936941f264 Log: surface: define all surfaces Modified files: ext/cairo/rb_cairo_surface.c Modified: ext/cairo/rb_cairo_surface.c (+24 -0) =================================================================== --- ext/cairo/rb_cairo_surface.c 2012-04-08 20:06:32 +0900 (99839fc) +++ ext/cairo/rb_cairo_surface.c 2012-04-08 20:09:45 +0900 (e14c422) @@ -2130,6 +2130,10 @@ Init_cairo_surface (void) RB_CAIRO_DEF_SETTERS (rb_cCairo_ScriptSurface); #endif + /* Qt surface */ + rb_cCairo_QtSurface = + rb_define_class_under (rb_mCairo, "QtSurface", rb_cCairo_Surface); + /* recording surface */ rb_cCairo_RecordingSurface = rb_define_class_under (rb_mCairo, "RecordingSurface", rb_cCairo_Surface); @@ -2145,6 +2149,10 @@ Init_cairo_surface (void) # endif #endif + /* VG surface */ + rb_cCairo_VGSurface = + rb_define_class_under (rb_mCairo, "VGSurface", rb_cCairo_Surface); + /* GL surface */ rb_cCairo_GLSurface = rb_define_class_under (rb_mCairo, "GLSurface", rb_cCairo_Surface); @@ -2171,6 +2179,10 @@ Init_cairo_surface (void) RB_CAIRO_DEF_SETTERS (rb_cCairo_GLTextureSurface); #endif + /* DRM surface */ + rb_cCairo_DRMSurface = + rb_define_class_under (rb_mCairo, "DRMSurface", rb_cCairo_Surface); + /* tee surface */ rb_cCairo_TeeSurface = rb_define_class_under (rb_mCairo, "TeeSurface", rb_cCairo_Surface); @@ -2199,4 +2211,16 @@ Init_cairo_surface (void) RB_CAIRO_DEF_SETTERS (rb_cCairo_XMLSurface); #endif + + /* Skia surface */ + rb_cCairo_SkiaSurface = + rb_define_class_under (rb_mCairo, "SkiaSurface", rb_cCairo_Surface); + + /* sub surface */ + rb_cCairo_SubSurface = + rb_define_class_under (rb_mCairo, "SubSurface", rb_cCairo_Surface); + + /* Cogl surface */ + rb_cCairo_CoglSurface = + rb_define_class_under (rb_mCairo, "CoglSurface", rb_cCairo_Surface); } From null+rcairo at clear-code.com Sun Apr 15 04:59:34 2012 From: null+rcairo at clear-code.com (null+rcairo at clear-code.com) Date: Sun, 15 Apr 2012 13:59:34 +0900 Subject: [cairo-commit:00195] rcairo/rcairo [master] Add Cairo::Pattern.xxx_supported? Message-ID: <20120415045954.19C559A0A6@jenkins.clear-code.com> Kouhei Sutou 2012-04-15 13:59:34 +0900 (Sun, 15 Apr 2012) New Revision: af3e3fc0599692356ee1315803bf8f458847cd79 Log: Add Cairo::Pattern.xxx_supported? Tests for unsupported patterns are omitted. GitHub: fixes #12 Reported by mtasaka. Thanks!!! Added files: lib/cairo/pattern.rb Modified files: ext/cairo/rb_cairo_pattern.c lib/cairo.rb test/cairo-test-utils.rb test/test_raster_source_pattern.rb Modified: ext/cairo/rb_cairo_pattern.c (+81 -7) =================================================================== --- ext/cairo/rb_cairo_pattern.c 2012-04-08 20:09:45 +0900 (625243d) +++ ext/cairo/rb_cairo_pattern.c 2012-04-15 13:59:34 +0900 (4e7eaec) @@ -29,6 +29,11 @@ static ID id_parse, id_to_rgb, id_to_a, id_inspect, id_new, id_call; #define _SELF(self) (RVAL2CRPATTERN(self)) +#if CAIRO_CHECK_VERSION(1, 11, 4) +# define RB_CAIRO_HAS_MESH_PATTERN +# define RB_CAIRO_HAS_RASTER_SOURCE_PATTERN +#endif + static VALUE cr_color_parse (VALUE color) { @@ -78,6 +83,55 @@ cr_pattern_get_klass (cairo_pattern_t *pattern) return klass; } +static VALUE +cr_pattern_solid_supported_p (VALUE klass) +{ + return Qtrue; +} + +static VALUE +cr_pattern_surface_supported_p (VALUE klass) +{ + return Qtrue; +} + +static VALUE +cr_pattern_gradient_supported_p (VALUE klass) +{ + return Qtrue; +} + +static VALUE +cr_pattern_linear_supported_p (VALUE klass) +{ + return Qtrue; +} + +static VALUE +cr_pattern_radial_supported_p (VALUE klass) +{ + return Qtrue; +} + +static VALUE +cr_pattern_mesh_supported_p (VALUE klass) +{ +#ifdef RB_CAIRO_HAS_MESH_PATTERN + return Qtrue; +#else + return Qfalse; +#endif +} + +static VALUE +cr_pattern_raster_source_supported_p (VALUE klass) +{ +#ifdef RB_CAIRO_HAS_RASTER_SOURCE_PATTERN + return Qtrue; +#else + return Qfalse; +#endif +} cairo_pattern_t * rb_cairo_pattern_from_ruby_object (VALUE obj) @@ -123,9 +177,12 @@ cr_pattern_allocate (VALUE klass) } static VALUE -cr_pattern_initialize (VALUE self) +cr_pattern_initialize (int argc, VALUE *argv, VALUE self) { - rb_raise (rb_eTypeError, "abstract class"); + rb_raise(rb_eNotImpError, + "%s class instantiation isn't supported on this cairo installation", + rb_obj_classname(self)); + return Qnil; } @@ -452,7 +509,7 @@ cr_radial_pattern_get_radial_circles (VALUE self) /* Cairo::SurfacePattern */ /* none */ -#if CAIRO_CHECK_VERSION(1, 11, 4) +#ifdef RB_CAIRO_HAS_MESH_PATTERN /* Cairo::MeshPattern */ static VALUE cr_mesh_pattern_initialize (VALUE self) @@ -683,8 +740,10 @@ cr_mesh_pattern_get_control_point (VALUE self, rb_cairo_check_status (status); return rb_ary_new3 (2, rb_float_new (x), rb_float_new (y)); } +#endif -/* Cairo::RasterPattern */ +#ifdef RB_CAIRO_HAS_RASTER_SOURCE_PATTERN +/* Cairo::RasterSourcePattern */ static cairo_surface_t * cr_raster_source_acquire_callback (cairo_pattern_t *pattern, void *callback_data, @@ -978,7 +1037,22 @@ Init_cairo_pattern (void) rb_define_alloc_func (rb_cCairo_Pattern, cr_pattern_allocate); - rb_define_method (rb_cCairo_Pattern, "initialize", cr_pattern_initialize, 0); + rb_define_singleton_method (rb_cCairo_Pattern, "solid_supported?", + cr_pattern_solid_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Pattern, "surface_supported?", + cr_pattern_surface_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Pattern, "gradient_supported?", + cr_pattern_gradient_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Pattern, "linear_supported?", + cr_pattern_linear_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Pattern, "radial_supported?", + cr_pattern_radial_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Pattern, "mesh_supported?", + cr_pattern_mesh_supported_p, 0); + rb_define_singleton_method (rb_cCairo_Pattern, "raster_source_supported?", + cr_pattern_raster_source_supported_p, 0); + + rb_define_method (rb_cCairo_Pattern, "initialize", cr_pattern_initialize, -1); rb_define_method (rb_cCairo_Pattern, "set_matrix", cr_pattern_set_matrix, 1); rb_define_method (rb_cCairo_Pattern, "matrix", cr_pattern_get_matrix, 0); @@ -1065,7 +1139,7 @@ Init_cairo_pattern (void) rb_cCairo_MeshPattern = rb_define_class_under (rb_mCairo, "MeshPattern", rb_cCairo_Pattern); -#if CAIRO_CHECK_VERSION(1, 11, 4) +#ifdef RB_CAIRO_HAS_MESH_PATTERN rb_define_method (rb_cCairo_MeshPattern, "initialize", cr_mesh_pattern_initialize, 0); rb_define_method (rb_cCairo_MeshPattern, "begin_patch", @@ -1100,7 +1174,7 @@ Init_cairo_pattern (void) rb_cCairo_RasterSourcePattern = rb_define_class_under (rb_mCairo, "RasterSourcePattern", rb_cCairo_Pattern); -#if CAIRO_CHECK_VERSION(1, 11, 4) +#ifdef RB_CAIRO_HAS_RASTER_SOURCE_PATTERN rb_define_method (rb_cCairo_RasterSourcePattern, "initialize", cr_raster_source_pattern_initialize, -1); rb_define_method (rb_cCairo_RasterSourcePattern, "acquire", Modified: lib/cairo.rb (+1 -0) =================================================================== --- lib/cairo.rb 2012-04-08 20:09:45 +0900 (c73b216) +++ lib/cairo.rb 2012-04-15 13:59:34 +0900 (ec6ceef) @@ -144,6 +144,7 @@ require 'cairo/papers' require 'cairo/context' require 'cairo/device' require 'cairo/surface' +require 'cairo/pattern' require 'cairo/path' module Cairo Added: lib/cairo/pattern.rb (+12 -0) 100644 =================================================================== --- /dev/null +++ lib/cairo/pattern.rb 2012-04-15 13:59:34 +0900 (df23313) @@ -0,0 +1,12 @@ +module Cairo + class Pattern + class << self + def supported?(type) + type = type.to_s.gsub(/([a-z])([A-Z])/, '\\1_\\2').downcase + supported_predicate = "#{type}_supported?" + return false unless respond_to?(supported_predicate) + send(supported_predicate) + end + end + end +end Modified: test/cairo-test-utils.rb (+6 -0) =================================================================== --- test/cairo-test-utils.rb 2012-04-08 20:09:45 +0900 (978d9eb) +++ test/cairo-test-utils.rb 2012-04-15 13:59:34 +0900 (894920c) @@ -30,4 +30,10 @@ module CairoTestUtils omit("Only for #{name} device available") end end + + def only_pattern(name) + unless Cairo::Pattern.supported?(name) + omit("Only for #{name} device available") + end + end end Modified: test/test_raster_source_pattern.rb (+15 -1) =================================================================== --- test/test_raster_source_pattern.rb 2012-04-08 20:09:45 +0900 (924c0cd) +++ test/test_raster_source_pattern.rb 2012-04-15 13:59:34 +0900 (5397c9b) @@ -1,9 +1,13 @@ require "cairo" require "tempfile" -class RasterPatternSourceTest < Test::Unit::TestCase +class RasterSourcePatternTest < Test::Unit::TestCase include CairoTestUtils + def setup + only_pattern("RasterSource") + end + def test_acquire_and_release Cairo::ImageSurface.new(100, 100) do |surface| Cairo::Context.new(surface) do |context| @@ -36,6 +40,11 @@ class RasterPatternSourceTest < Test::Unit::TestCase end class SnapshotTest < self + def setup + super + only_surface("Recording") + end + def test_success Cairo::RecordingSurface.new(0, 0, 100, 100) do |surface| Cairo::Context.new(surface) do |context| @@ -75,6 +84,11 @@ class RasterPatternSourceTest < Test::Unit::TestCase end class CopyTest < self + def setup + super + only_surface("Script") + end + def test_success output = StringIO.new device = Cairo::ScriptDevice.new(output)