cairo 1.12.1-x86-mingw32 → 1.12.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of cairo might be problematic. Click here for more details.

data/Gemfile CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  source "http://rubygems.org/"
4
4
 
5
- gemfile
5
+ gemspec
data/NEWS CHANGED
@@ -1,3 +1,26 @@
1
+ Release 1.12.2 (2012-06-03) Kouhei Sutou <kou@cozmixng.org>)
2
+ ============================================================
3
+
4
+ Improvements
5
+ ------------
6
+
7
+ * Added Cairo::Device.supported?.
8
+ [GitHub#11] [Reported by Cédric Boutillier]
9
+ * Added Cairo::Device.gl_texture_supported?.
10
+ * Added Cairo::Surface.supported?.
11
+ * Defined all surfaces even if a surface isn't available. Use
12
+ Cairo::Surface.XXX_supported? method to check surface
13
+ availability.
14
+ * Added Cairo::Pattern.xxx_supported?.
15
+ [GitHub#12] [Reported by Mamoru Tasaka]
16
+ * [experimental] Supported auto native package install.
17
+
18
+ Thanks
19
+ ------
20
+
21
+ * Cédric Boutillier
22
+ * Mamoru Tasaka
23
+
1
24
  Release 1.12.1 (2012-03-31) Kouhei Sutou <kou@cozmixng.org>)
2
25
  ============================================================
3
26
 
data/ext/cairo/extconf.rb CHANGED
@@ -68,7 +68,127 @@ checking_for(checking_message("Mac OS X")) do
68
68
  end
69
69
  end
70
70
 
71
- PKGConfig.have_package(package, major, minor, micro) or exit 1
71
+ def package_platform
72
+ if File.exist?("/etc/debian_version")
73
+ :debian
74
+ elsif File.exist?("/etc/fedora-release")
75
+ :fedora
76
+ elsif File.exist?("/etc/redhat-release")
77
+ :redhat
78
+ elsif find_executable("brew")
79
+ :homebrew
80
+ elsif find_executable("port")
81
+ :macports
82
+ else
83
+ :unknown
84
+ end
85
+ end
86
+
87
+ def super_user?
88
+ Process.uid.zero?
89
+ end
90
+
91
+ def normalize_native_package_info(native_package_info)
92
+ native_package_info ||= {}
93
+ native_package_info = native_package_info.dup
94
+ native_package_info[:fedora] ||= native_package_info[:redhat]
95
+ native_package_info
96
+ end
97
+
98
+ def install_missing_native_package(native_package_info)
99
+ platform = package_platform
100
+ native_package_info = normalize_native_package_info(native_package_info)
101
+ package = native_package_info[platform]
102
+ return false if package.nil?
103
+
104
+ need_super_user_priviledge = true
105
+ case platform
106
+ when :debian
107
+ install_command = "apt-get install -V -y #{package}"
108
+ when :fedora, :redhat
109
+ install_command = "yum install -y #{package}"
110
+ when :homebrew
111
+ need_super_user_priviledge = false
112
+ install_command = "brew install #{package}"
113
+ when :macports
114
+ install_command = "port install -y #{package}"
115
+ else
116
+ return false
117
+ end
118
+
119
+ have_priviledge = (not need_super_user_priviledge or super_user?)
120
+ unless have_priviledge
121
+ sudo = find_executable("sudo")
122
+ end
123
+
124
+ installing_message = "installing '#{package}' native package... "
125
+ message("%s", installing_message)
126
+ failed_to_get_super_user_priviledge = false
127
+ if have_priviledge
128
+ succeeded = xsystem(install_command)
129
+ else
130
+ if sudo
131
+ install_command = "#{sudo} #{install_command}"
132
+ succeeded = xsystem(install_command)
133
+ else
134
+ succeeded = false
135
+ failed_to_get_super_user_priviledge = true
136
+ end
137
+ end
138
+
139
+ if failed_to_get_super_user_priviledge
140
+ result_message = "require super user privilege"
141
+ else
142
+ result_message = succeeded ? "succeeded" : "failed"
143
+ end
144
+ Logging.postpone do
145
+ "#{installing_message}#{result_message}\n"
146
+ end
147
+ message("#{result_message}\n")
148
+
149
+ error_message = nil
150
+ unless succeeded
151
+ if failed_to_get_super_user_priviledge
152
+ error_message = <<-EOM
153
+ '#{package}' native package is required.
154
+ run the following command as super user to install required native package:
155
+ \# #{install_command}
156
+ EOM
157
+ else
158
+ error_message = <<-EOM
159
+ failed to run '#{install_command}'.
160
+ EOM
161
+ end
162
+ end
163
+ if error_message
164
+ message("%s", error_message)
165
+ Logging.message("%s", error_message)
166
+ end
167
+
168
+ Logging.message("--------------------\n\n")
169
+
170
+ succeeded
171
+ end
172
+
173
+ def required_pkg_config_package(package_info, native_package_info=nil)
174
+ if package_info.is_a?(Array)
175
+ required_package_info = package_info
176
+ else
177
+ required_package_info = [package_info]
178
+ end
179
+ return true if PKGConfig.have_package(*required_package_info)
180
+
181
+ native_package_info ||= {}
182
+ return false unless install_missing_native_package(native_package_info)
183
+
184
+ PKGConfig.have_package(*required_package_info)
185
+ end
186
+
187
+ unless required_pkg_config_package([package, major, minor, micro],
188
+ :debian => "libcairo2-dev",
189
+ :redhat => "cairo-devel")
190
+ exit(false)
191
+ end
72
192
 
73
193
  $defs << "-DRB_CAIRO_COMPILATION"
74
194
 
data/ext/cairo/rb_cairo.h CHANGED
@@ -73,7 +73,7 @@ RB_CAIRO_BEGIN_DECLS
73
73
 
74
74
  #define RB_CAIRO_VERSION_MAJOR 1
75
75
  #define RB_CAIRO_VERSION_MINOR 12
76
- #define RB_CAIRO_VERSION_MICRO 1
76
+ #define RB_CAIRO_VERSION_MICRO 2
77
77
 
78
78
  RB_CAIRO_VAR VALUE rb_mCairo;
79
79
  RB_CAIRO_VAR VALUE rb_cCairo_Context;
@@ -96,6 +96,26 @@ cr_device_get_klass (cairo_device_t *device)
96
96
  return klass;
97
97
  }
98
98
 
99
+ static VALUE
100
+ cr_device_script_supported_p (VALUE klass)
101
+ {
102
+ #ifdef CAIRO_HAS_SCRIPT_SURFACE
103
+ return Qtrue;
104
+ #else
105
+ return Qfalse;
106
+ #endif
107
+ }
108
+
109
+ static VALUE
110
+ cr_device_xml_supported_p (VALUE klass)
111
+ {
112
+ #ifdef CAIRO_HAS_XML_SURFACE
113
+ return Qtrue;
114
+ #else
115
+ return Qfalse;
116
+ #endif
117
+ }
118
+
99
119
  /* constructor/de-constructor */
100
120
  cairo_device_t *
101
121
  rb_cairo_device_from_ruby_object (VALUE obj)
@@ -168,6 +188,16 @@ cr_device_allocate (VALUE klass)
168
188
  return Data_Wrap_Struct (klass, NULL, cr_device_free, NULL);
169
189
  }
170
190
 
191
+ static VALUE
192
+ cr_device_initialize (int argc, VALUE *argv, VALUE self)
193
+ {
194
+ rb_raise(rb_eNotImpError,
195
+ "%s class creation isn't supported on this cairo installation",
196
+ rb_obj_classname(self));
197
+
198
+ return Qnil;
199
+ }
200
+
171
201
  /* Backend device manipulation */
172
202
  static VALUE
173
203
  cr_device_destroy (VALUE self)
@@ -377,7 +407,12 @@ Init_cairo_device (void)
377
407
  rb_cairo__initialize_gc_guard_holder_class (rb_cCairo_Device);
378
408
  rb_set_end_proc(cr_finish_all_guarded_devices_at_end, Qnil);
379
409
 
410
+ rb_define_singleton_method (rb_cCairo_Device, "script_supported?",
411
+ cr_device_script_supported_p, 0);
412
+ rb_define_singleton_method (rb_cCairo_Device, "xml_supported?",
413
+ cr_device_xml_supported_p, 0);
380
414
 
415
+ rb_define_method (rb_cCairo_Device, "initialize", cr_device_initialize, -1);
381
416
  rb_define_method (rb_cCairo_Device, "destroy", cr_device_destroy, 0);
382
417
  rb_define_method (rb_cCairo_Device, "finish", cr_device_finish, 0);
383
418
  rb_define_method (rb_cCairo_Device, "flush", cr_device_flush, 0);
@@ -29,6 +29,11 @@ static ID id_parse, id_to_rgb, id_to_a, id_inspect, id_new, id_call;
29
29
 
30
30
  #define _SELF(self) (RVAL2CRPATTERN(self))
31
31
 
32
+ #if CAIRO_CHECK_VERSION(1, 11, 4)
33
+ # define RB_CAIRO_HAS_MESH_PATTERN
34
+ # define RB_CAIRO_HAS_RASTER_SOURCE_PATTERN
35
+ #endif
36
+
32
37
  static VALUE
33
38
  cr_color_parse (VALUE color)
34
39
  {
@@ -78,6 +83,55 @@ cr_pattern_get_klass (cairo_pattern_t *pattern)
78
83
  return klass;
79
84
  }
80
85
 
86
+ static VALUE
87
+ cr_pattern_solid_supported_p (VALUE klass)
88
+ {
89
+ return Qtrue;
90
+ }
91
+
92
+ static VALUE
93
+ cr_pattern_surface_supported_p (VALUE klass)
94
+ {
95
+ return Qtrue;
96
+ }
97
+
98
+ static VALUE
99
+ cr_pattern_gradient_supported_p (VALUE klass)
100
+ {
101
+ return Qtrue;
102
+ }
103
+
104
+ static VALUE
105
+ cr_pattern_linear_supported_p (VALUE klass)
106
+ {
107
+ return Qtrue;
108
+ }
109
+
110
+ static VALUE
111
+ cr_pattern_radial_supported_p (VALUE klass)
112
+ {
113
+ return Qtrue;
114
+ }
115
+
116
+ static VALUE
117
+ cr_pattern_mesh_supported_p (VALUE klass)
118
+ {
119
+ #ifdef RB_CAIRO_HAS_MESH_PATTERN
120
+ return Qtrue;
121
+ #else
122
+ return Qfalse;
123
+ #endif
124
+ }
125
+
126
+ static VALUE
127
+ cr_pattern_raster_source_supported_p (VALUE klass)
128
+ {
129
+ #ifdef RB_CAIRO_HAS_RASTER_SOURCE_PATTERN
130
+ return Qtrue;
131
+ #else
132
+ return Qfalse;
133
+ #endif
134
+ }
81
135
 
82
136
  cairo_pattern_t *
83
137
  rb_cairo_pattern_from_ruby_object (VALUE obj)
@@ -123,9 +177,12 @@ cr_pattern_allocate (VALUE klass)
123
177
  }
124
178
 
125
179
  static VALUE
126
- cr_pattern_initialize (VALUE self)
180
+ cr_pattern_initialize (int argc, VALUE *argv, VALUE self)
127
181
  {
128
- rb_raise (rb_eTypeError, "abstract class");
182
+ rb_raise(rb_eNotImpError,
183
+ "%s class instantiation isn't supported on this cairo installation",
184
+ rb_obj_classname(self));
185
+
129
186
  return Qnil;
130
187
  }
131
188
 
@@ -452,7 +509,7 @@ cr_radial_pattern_get_radial_circles (VALUE self)
452
509
  /* Cairo::SurfacePattern */
453
510
  /* none */
454
511
 
455
- #if CAIRO_CHECK_VERSION(1, 11, 4)
512
+ #ifdef RB_CAIRO_HAS_MESH_PATTERN
456
513
  /* Cairo::MeshPattern */
457
514
  static VALUE
458
515
  cr_mesh_pattern_initialize (VALUE self)
@@ -683,8 +740,10 @@ cr_mesh_pattern_get_control_point (VALUE self,
683
740
  rb_cairo_check_status (status);
684
741
  return rb_ary_new3 (2, rb_float_new (x), rb_float_new (y));
685
742
  }
743
+ #endif
686
744
 
687
- /* Cairo::RasterPattern */
745
+ #ifdef RB_CAIRO_HAS_RASTER_SOURCE_PATTERN
746
+ /* Cairo::RasterSourcePattern */
688
747
  static cairo_surface_t *
689
748
  cr_raster_source_acquire_callback (cairo_pattern_t *pattern,
690
749
  void *callback_data,
@@ -978,7 +1037,22 @@ Init_cairo_pattern (void)
978
1037
 
979
1038
  rb_define_alloc_func (rb_cCairo_Pattern, cr_pattern_allocate);
980
1039
 
981
- rb_define_method (rb_cCairo_Pattern, "initialize", cr_pattern_initialize, 0);
1040
+ rb_define_singleton_method (rb_cCairo_Pattern, "solid_supported?",
1041
+ cr_pattern_solid_supported_p, 0);
1042
+ rb_define_singleton_method (rb_cCairo_Pattern, "surface_supported?",
1043
+ cr_pattern_surface_supported_p, 0);
1044
+ rb_define_singleton_method (rb_cCairo_Pattern, "gradient_supported?",
1045
+ cr_pattern_gradient_supported_p, 0);
1046
+ rb_define_singleton_method (rb_cCairo_Pattern, "linear_supported?",
1047
+ cr_pattern_linear_supported_p, 0);
1048
+ rb_define_singleton_method (rb_cCairo_Pattern, "radial_supported?",
1049
+ cr_pattern_radial_supported_p, 0);
1050
+ rb_define_singleton_method (rb_cCairo_Pattern, "mesh_supported?",
1051
+ cr_pattern_mesh_supported_p, 0);
1052
+ rb_define_singleton_method (rb_cCairo_Pattern, "raster_source_supported?",
1053
+ cr_pattern_raster_source_supported_p, 0);
1054
+
1055
+ rb_define_method (rb_cCairo_Pattern, "initialize", cr_pattern_initialize, -1);
982
1056
 
983
1057
  rb_define_method (rb_cCairo_Pattern, "set_matrix", cr_pattern_set_matrix, 1);
984
1058
  rb_define_method (rb_cCairo_Pattern, "matrix", cr_pattern_get_matrix, 0);
@@ -1065,7 +1139,7 @@ Init_cairo_pattern (void)
1065
1139
  rb_cCairo_MeshPattern =
1066
1140
  rb_define_class_under (rb_mCairo, "MeshPattern",
1067
1141
  rb_cCairo_Pattern);
1068
- #if CAIRO_CHECK_VERSION(1, 11, 4)
1142
+ #ifdef RB_CAIRO_HAS_MESH_PATTERN
1069
1143
  rb_define_method (rb_cCairo_MeshPattern, "initialize",
1070
1144
  cr_mesh_pattern_initialize, 0);
1071
1145
  rb_define_method (rb_cCairo_MeshPattern, "begin_patch",
@@ -1100,7 +1174,7 @@ Init_cairo_pattern (void)
1100
1174
  rb_cCairo_RasterSourcePattern =
1101
1175
  rb_define_class_under (rb_mCairo, "RasterSourcePattern",
1102
1176
  rb_cCairo_Pattern);
1103
- #if CAIRO_CHECK_VERSION(1, 11, 4)
1177
+ #ifdef RB_CAIRO_HAS_RASTER_SOURCE_PATTERN
1104
1178
  rb_define_method (rb_cCairo_RasterSourcePattern, "initialize",
1105
1179
  cr_raster_source_pattern_initialize, -1);
1106
1180
  rb_define_method (rb_cCairo_RasterSourcePattern, "acquire",
@@ -23,10 +23,21 @@
23
23
  # include <st.h>
24
24
  #endif
25
25
 
26
+ #if CAIRO_CHECK_VERSION(1, 5, 2)
27
+ # define RB_CAIRO_HAS_WIN32_PRINTING_SURFACE_TYPE
28
+ #endif
29
+
30
+ #if CAIRO_CHECK_VERSION(1, 5, 12)
31
+ # define RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE_TYPE
32
+ #endif
33
+
26
34
  #ifdef CAIRO_HAS_WIN32_SURFACE
27
35
  # define OpenFile OpenFile_win32
28
36
  # include <cairo-win32.h>
29
37
  # undef OpenFile
38
+ # ifdef RB_CAIRO_HAS_WIN32_PRINTING_SURFACE_TYPE
39
+ # define RB_CAIRO_HAS_WIN32_PRINTING_SURFACE
40
+ # endif
30
41
  #endif
31
42
 
32
43
  #ifdef HAVE_RUBY_IO_H
@@ -44,6 +55,12 @@ enum ruby_value_type {
44
55
  # undef T_DATA
45
56
  # include <cairo-quartz.h>
46
57
  # define T_DATA RUBY_T_DATA
58
+ # ifdef HAVE_RUBY_COCOA
59
+ # define RB_CAIRO_HAS_QUARTZ_SURFACE
60
+ # ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE_TYPE
61
+ # define RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
62
+ # endif
63
+ # endif
47
64
  #endif
48
65
 
49
66
  #ifdef CAIRO_HAS_XML_SURFACE
@@ -151,12 +168,12 @@ cr_surface_get_klass (cairo_surface_t *surface)
151
168
  case CAIRO_SURFACE_TYPE_SVG:
152
169
  klass = rb_cCairo_SVGSurface;
153
170
  break;
154
- #if CAIRO_CHECK_VERSION(1, 5, 2)
171
+ #ifdef RB_CAIRO_HAS_WIN32_PRINTING_SURFACE_TYPE
155
172
  case CAIRO_SURFACE_TYPE_WIN32_PRINTING:
156
173
  klass = rb_cCairo_Win32PrintingSurface;
157
174
  break;
158
175
  #endif
159
- #if CAIRO_CHECK_VERSION(1, 5, 12)
176
+ #ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE_TYPE
160
177
  case CAIRO_SURFACE_TYPE_QUARTZ_IMAGE:
161
178
  klass = rb_cCairo_QuartzImageSurface;
162
179
  break;
@@ -209,6 +226,138 @@ cr_surface_get_klass (cairo_surface_t *surface)
209
226
  return klass;
210
227
  }
211
228
 
229
+ static VALUE
230
+ cr_surface_image_supported_p (VALUE klass)
231
+ {
232
+ return Qtrue;
233
+ }
234
+
235
+ static VALUE
236
+ cr_surface_pdf_supported_p (VALUE klass)
237
+ {
238
+ #ifdef CAIRO_HAS_PDF_SURFACE
239
+ return Qtrue;
240
+ #else
241
+ return Qfalse;
242
+ #endif
243
+ }
244
+
245
+ static VALUE
246
+ cr_surface_ps_supported_p (VALUE klass)
247
+ {
248
+ #ifdef CAIRO_HAS_PS_SURFACE
249
+ return Qtrue;
250
+ #else
251
+ return Qfalse;
252
+ #endif
253
+ }
254
+
255
+ static VALUE
256
+ cr_surface_quartz_supported_p (VALUE klass)
257
+ {
258
+ #ifdef RB_CAIRO_HAS_QUARTZ_SURFACE
259
+ return Qtrue;
260
+ #else
261
+ return Qfalse;
262
+ #endif
263
+ }
264
+
265
+ static VALUE
266
+ cr_surface_win32_supported_p (VALUE klass)
267
+ {
268
+ #ifdef CAIRO_HAS_WIN32_SURFACE
269
+ return Qtrue;
270
+ #else
271
+ return Qfalse;
272
+ #endif
273
+ }
274
+
275
+ static VALUE
276
+ cr_surface_svg_supported_p (VALUE klass)
277
+ {
278
+ #ifdef CAIRO_HAS_SVG_SURFACE
279
+ return Qtrue;
280
+ #else
281
+ return Qfalse;
282
+ #endif
283
+ }
284
+
285
+ static VALUE
286
+ cr_surface_win32_printing_supported_p (VALUE klass)
287
+ {
288
+ #ifdef RB_CAIRO_HAS_WIN32_PRINTING_SURFACE
289
+ return Qtrue;
290
+ #else
291
+ return Qfalse;
292
+ #endif
293
+ }
294
+
295
+ static VALUE
296
+ cr_surface_quartz_image_supported_p (VALUE klass)
297
+ {
298
+ #ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
299
+ return Qtrue;
300
+ #else
301
+ return Qfalse;
302
+ #endif
303
+ }
304
+
305
+ static VALUE
306
+ cr_surface_script_supported_p (VALUE klass)
307
+ {
308
+ #ifdef CAIRO_HAS_SCRIPT_SURFACE
309
+ return Qtrue;
310
+ #else
311
+ return Qfalse;
312
+ #endif
313
+ }
314
+
315
+ static VALUE
316
+ cr_surface_recording_supported_p (VALUE klass)
317
+ {
318
+ #ifdef CAIRO_HAS_RECORDING_SURFACE
319
+ return Qtrue;
320
+ #else
321
+ return Qfalse;
322
+ #endif
323
+ }
324
+
325
+ static VALUE
326
+ cr_surface_gl_supported_p (VALUE klass)
327
+ {
328
+ #ifdef RB_CAIRO_HAS_GL_SURFACE
329
+ return Qtrue;
330
+ #else
331
+ return Qfalse;
332
+ #endif
333
+ }
334
+
335
+ static VALUE
336
+ cr_surface_gl_texture_supported_p (VALUE klass)
337
+ {
338
+ return cr_surface_gl_supported_p(klass);
339
+ }
340
+
341
+ static VALUE
342
+ cr_surface_tee_supported_p (VALUE klass)
343
+ {
344
+ #ifdef CAIRO_HAS_TEE_SURFACE
345
+ return Qtrue;
346
+ #else
347
+ return Qfalse;
348
+ #endif
349
+ }
350
+
351
+ static VALUE
352
+ cr_surface_xml_supported_p (VALUE klass)
353
+ {
354
+ #ifdef CAIRO_HAS_XML_SURFACE
355
+ return Qtrue;
356
+ #else
357
+ return Qfalse;
358
+ #endif
359
+ }
360
+
212
361
  /* constructor/de-constructor */
213
362
  cairo_surface_t *
214
363
  rb_cairo_surface_from_ruby_object (VALUE obj)
@@ -279,6 +428,16 @@ cr_surface_allocate (VALUE klass)
279
428
  return Data_Wrap_Struct (klass, NULL, cr_surface_free, NULL);
280
429
  }
281
430
 
431
+ static VALUE
432
+ cr_surface_initialize (int argc, VALUE *argv, VALUE self)
433
+ {
434
+ rb_raise(rb_eNotImpError,
435
+ "%s class creation isn't supported on this cairo installation",
436
+ rb_obj_classname(self));
437
+
438
+ return Qnil;
439
+ }
440
+
282
441
  /* Surface manipulation */
283
442
  static VALUE
284
443
  cr_surface_destroy (VALUE self)
@@ -617,7 +776,7 @@ cr_surface_mark_dirty (int argc, VALUE *argv, VALUE self)
617
776
  {
618
777
  VALUE x, y, width, height;
619
778
  int n;
620
-
779
+
621
780
  n = rb_scan_args (argc, argv, "04", &x, &y, &width, &height);
622
781
 
623
782
  if (n == 0)
@@ -717,7 +876,7 @@ cr_surface_show_page (VALUE self)
717
876
  }
718
877
  #endif
719
878
 
720
- /* Image-surface functions */
879
+ /* image surface functions */
721
880
  #ifdef CAIRO_HAS_PNG_FUNCTIONS
722
881
  static cairo_surface_t *
723
882
  cr_image_surface_create_from_png_stream (VALUE target)
@@ -777,7 +936,7 @@ cr_image_surface_create_for_data (VALUE self, VALUE rb_data, VALUE format,
777
936
  unsigned char *data;
778
937
 
779
938
  data = (unsigned char *)StringValuePtr (rb_data);
780
-
939
+
781
940
  return cairo_image_surface_create_for_data (data,
782
941
  RVAL2CRFORMAT (format),
783
942
  NUM2INT (width),
@@ -791,7 +950,7 @@ cr_image_surface_initialize (int argc, VALUE *argv, VALUE self)
791
950
  cairo_surface_t *surface;
792
951
  VALUE arg1, arg2, arg3, arg4, arg5;
793
952
  int n;
794
-
953
+
795
954
  n = rb_scan_args (argc, argv, "23", &arg1, &arg2, &arg3, &arg4, &arg5);
796
955
 
797
956
  if (n == 2)
@@ -857,94 +1016,7 @@ cr_image_surface_get_stride (VALUE self)
857
1016
  return INT2NUM (cairo_image_surface_get_stride (_SELF));
858
1017
  }
859
1018
 
860
- #ifdef CAIRO_HAS_RECORDING_SURFACE
861
- /* Recording-surface functions */
862
- static VALUE
863
- cr_recording_surface_initialize (int argc, VALUE *argv, VALUE self)
864
- {
865
- VALUE arg1, arg2, arg3, arg4, arg5;
866
- cairo_surface_t *surface;
867
- cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
868
- cairo_rectangle_t extents;
869
- const char *error_message =
870
- "invalid argument (expect "
871
- "(x, y, width, height), "
872
- "([x, y, width, height]),"
873
- "(x, y, width, height, content) or "
874
- "([x, y, width, height], content)): %s";
875
-
876
- rb_scan_args (argc, argv, "14", &arg1, &arg2, &arg3, &arg4, &arg5);
877
- if (argc == 1 || argc == 2)
878
- {
879
- VALUE rb_extents;
880
-
881
- rb_extents = rb_check_array_type (arg1);
882
- if (RARRAY_LEN (rb_extents) != 4)
883
- rb_raise (rb_eArgError, error_message, rb_cairo__inspect (arg1));
884
- extents.x = NUM2DBL (RARRAY_PTR (rb_extents)[0]);
885
- extents.y = NUM2DBL (RARRAY_PTR (rb_extents)[1]);
886
- extents.width = NUM2DBL (RARRAY_PTR (rb_extents)[2]);
887
- extents.height = NUM2DBL (RARRAY_PTR (rb_extents)[3]);
888
- if (!NIL_P (arg2))
889
- content = RVAL2CRCONTENT (arg2);
890
- }
891
- else if (argc == 4 || argc == 5)
892
- {
893
- extents.x = NUM2DBL (arg1);
894
- extents.y = NUM2DBL (arg2);
895
- extents.width = NUM2DBL (arg3);
896
- extents.height = NUM2DBL (arg4);
897
- if (!NIL_P (arg5))
898
- content = RVAL2CRCONTENT (arg5);
899
- }
900
- else
901
- {
902
- rb_raise (rb_eArgError, error_message,
903
- rb_cairo__inspect (rb_ary_new4 (argc, argv)));
904
- }
905
-
906
- surface = cairo_recording_surface_create (content, &extents);
907
- cr_surface_check_status (surface);
908
- DATA_PTR (self) = surface;
909
- if (rb_block_given_p ())
910
- yield_and_finish (self);
911
- return Qnil;
912
- }
913
-
914
- static VALUE
915
- cr_recording_surface_get_ink_extents (VALUE self)
916
- {
917
- cairo_surface_t *surface;
918
- double x, y, width, height;
919
-
920
- surface = _SELF;
921
- cairo_recording_surface_ink_extents (surface, &x, &y, &width, &height);
922
- cr_surface_check_status (surface);
923
- return rb_ary_new3 (4,
924
- rb_float_new (x), rb_float_new (y),
925
- rb_float_new (width), rb_float_new (height));
926
- }
927
-
928
- # if CAIRO_CHECK_VERSION(1, 11, 4)
929
- static VALUE
930
- cr_recording_surface_get_extents (VALUE self)
931
- {
932
- cairo_surface_t *surface;
933
- cairo_rectangle_t extents;
934
-
935
- surface = _SELF;
936
- cairo_recording_surface_get_extents (surface, &extents);
937
- cr_surface_check_status (surface);
938
- return rb_ary_new3 (4,
939
- rb_float_new (extents.x),
940
- rb_float_new (extents.y),
941
- rb_float_new (extents.width),
942
- rb_float_new (extents.height));
943
- }
944
- # endif
945
- #endif
946
-
947
- /* Printing surfaces */
1019
+ /* printing surfaces */
948
1020
  #define DEFINE_SURFACE(type) \
949
1021
  static VALUE \
950
1022
  cr_ ## type ## _surface_initialize (int argc, VALUE *argv, VALUE self) \
@@ -1045,6 +1117,22 @@ cr_ ## type ## _surface_set_size (int argc, VALUE *argv, VALUE self) \
1045
1117
  return Qnil; \
1046
1118
  }
1047
1119
 
1120
+ #ifdef CAIRO_HAS_PDF_SURFACE
1121
+ /* PDF-surface functions */
1122
+ DEFINE_SURFACE(pdf)
1123
+ DEFINE_SURFACE_SET_SIZE(pdf)
1124
+
1125
+ # if CAIRO_CHECK_VERSION(1, 10, 0)
1126
+ static VALUE
1127
+ cr_pdf_surface_restrict_to_version (VALUE self, VALUE version)
1128
+ {
1129
+ cairo_pdf_surface_restrict_to_version (_SELF, RVAL2CRPDFVERSION (version));
1130
+ cr_surface_check_status (_SELF);
1131
+ return Qnil;
1132
+ }
1133
+ # endif
1134
+ #endif
1135
+
1048
1136
  #ifdef CAIRO_HAS_PS_SURFACE
1049
1137
  /* PS-surface functions */
1050
1138
  DEFINE_SURFACE(ps)
@@ -1105,64 +1193,108 @@ cr_ps_surface_set_eps (VALUE self, VALUE eps)
1105
1193
  # endif
1106
1194
  #endif
1107
1195
 
1108
- #ifdef CAIRO_HAS_PDF_SURFACE
1109
- /* PDF-surface functions */
1110
- DEFINE_SURFACE(pdf)
1111
- DEFINE_SURFACE_SET_SIZE(pdf)
1112
-
1113
- # if CAIRO_CHECK_VERSION(1, 10, 0)
1114
- static VALUE
1115
- cr_pdf_surface_restrict_to_version (VALUE self, VALUE version)
1116
- {
1117
- cairo_pdf_surface_restrict_to_version (_SELF, RVAL2CRPDFVERSION (version));
1118
- cr_surface_check_status (_SELF);
1119
- return Qnil;
1120
- }
1121
- # endif
1122
- #endif
1196
+ #ifdef RB_CAIRO_HAS_QUARTZ_SURFACE
1197
+ /* Quartz-surface functions */
1198
+ #include <objc/objc-runtime.h>
1123
1199
 
1124
- #ifdef CAIRO_HAS_XLIB_SURFACE
1125
- static VALUE
1126
- cr_xlib_surface_initialize (int argc, VALUE *argv, VALUE self)
1127
- {
1128
- rb_notimplement();
1129
- return Qnil;
1130
- }
1131
- #endif
1200
+ BOOL rbobj_to_nsobj (VALUE obj, id* nsobj);
1201
+ VALUE ocid_to_rbobj (VALUE context_obj, id ocid);
1132
1202
 
1133
- #ifdef CAIRO_HAS_XCB_SURFACE
1134
1203
  static VALUE
1135
- cr_xcb_surface_initialize (int argc, VALUE *argv, VALUE self)
1204
+ cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
1136
1205
  {
1137
- rb_notimplement();
1138
- return Qnil;
1139
- }
1140
- #endif
1206
+ id objc_object = nil;
1207
+ CGContextRef context;
1208
+ unsigned int width, height;
1209
+ cairo_surface_t *surface = NULL;
1210
+ cairo_format_t format = CAIRO_FORMAT_ARGB32;
1211
+ VALUE arg1, arg2, arg3, rb_width, rb_height;
1212
+ static VALUE rb_cOSXCGContextRef = Qnil;
1141
1213
 
1142
- #ifdef CAIRO_HAS_SVG_SURFACE
1143
- /* SVG-surface functions */
1144
- DEFINE_SURFACE(svg)
1214
+ rb_scan_args (argc, argv, "21", &arg1, &arg2, &arg3);
1145
1215
 
1146
- static VALUE
1147
- cr_svg_surface_restrict_to_version (VALUE self, VALUE version)
1148
- {
1149
- cairo_svg_surface_restrict_to_version (_SELF, RVAL2CRSVGVERSION (version));
1150
- cr_surface_check_status (_SELF);
1151
- return Qnil;
1152
- }
1216
+ if (argc == 2)
1217
+ {
1218
+ rb_width = arg1;
1219
+ rb_height = arg2;
1220
+ }
1221
+ else
1222
+ {
1223
+ switch (TYPE (arg1))
1224
+ {
1225
+ case T_NIL:
1226
+ break;
1227
+ case T_STRING:
1228
+ case T_SYMBOL:
1229
+ case T_FIXNUM:
1230
+ format = RVAL2CRFORMAT (arg1);
1231
+ break;
1232
+ default:
1233
+ if (NIL_P (rb_cOSXCGContextRef))
1234
+ rb_cOSXCGContextRef =
1235
+ rb_const_get (rb_const_get (rb_cObject, rb_intern ("OSX")),
1236
+ rb_intern ("CGContextRef"));
1237
+
1238
+ if (RTEST (rb_obj_is_kind_of (arg1, rb_cOSXCGContextRef)))
1239
+ rbobj_to_nsobj (arg1, &objc_object);
1240
+ else
1241
+ rb_raise (rb_eArgError,
1242
+ "invalid argument (expect "
1243
+ "(width, height), "
1244
+ "(format, width, height) or "
1245
+ "(cg_context, width, height)): %s",
1246
+ rb_cairo__inspect (rb_ary_new3 (3, arg1, arg2, arg3)));
1247
+ break;
1248
+ }
1249
+
1250
+ rb_width = arg2;
1251
+ rb_height = arg3;
1252
+ }
1253
+
1254
+ width = NUM2UINT (rb_width);
1255
+ height = NUM2UINT (rb_height);
1256
+
1257
+ if (objc_object == nil)
1258
+ {
1259
+ surface = cairo_quartz_surface_create (format, width, height);
1260
+ }
1261
+ else
1262
+ {
1263
+ context = (CGContextRef)objc_object;
1264
+ surface =
1265
+ cairo_quartz_surface_create_for_cg_context (context, width, height);
1266
+ }
1267
+
1268
+ cr_surface_check_status (surface);
1269
+ DATA_PTR (self) = surface;
1270
+ if (rb_block_given_p ())
1271
+ yield_and_finish (self);
1272
+ return Qnil;
1273
+ }
1274
+
1275
+ static VALUE
1276
+ cr_quartz_surface_get_cg_context (VALUE self)
1277
+ {
1278
+ CGContextRef context;
1279
+ id objc_object;
1280
+
1281
+ context = cairo_quartz_surface_get_cg_context (_SELF);
1282
+ objc_object = (id)context;
1283
+ return ocid_to_rbobj (Qnil, objc_object);
1284
+ }
1153
1285
  #endif
1154
1286
 
1155
1287
  #ifdef CAIRO_HAS_WIN32_SURFACE
1156
- /* WIN32-surface functions */
1288
+ /* Win32 surface functions */
1157
1289
 
1158
1290
  /* from dl/dl.h (ruby 1.9) */
1159
- #if SIZEOF_LONG == SIZEOF_VOIDP
1160
- # define PTR2NUM(x) (ULONG2NUM((unsigned long)(x)))
1161
- # define NUM2PTR(x) ((void *)(NUM2ULONG(x)))
1162
- #else
1163
- # define PTR2NUM(x) (ULL2NUM((unsigned long long)(x)))
1164
- # define NUM2PTR(x) ((void *)(NUM2ULL(x)))
1165
- #endif
1291
+ # if SIZEOF_LONG == SIZEOF_VOIDP
1292
+ # define PTR2NUM(x) (ULONG2NUM((unsigned long)(x)))
1293
+ # define NUM2PTR(x) ((void *)(NUM2ULONG(x)))
1294
+ # else
1295
+ # define PTR2NUM(x) (ULL2NUM((unsigned long long)(x)))
1296
+ # define NUM2PTR(x) ((void *)(NUM2ULL(x)))
1297
+ # endif
1166
1298
 
1167
1299
  static VALUE
1168
1300
  cr_win32_surface_initialize (int argc, VALUE *argv, VALUE self)
@@ -1248,21 +1380,6 @@ cr_win32_surface_initialize (int argc, VALUE *argv, VALUE self)
1248
1380
  return Qnil;
1249
1381
  }
1250
1382
 
1251
- # if CAIRO_CHECK_VERSION(1, 5, 2)
1252
- static VALUE
1253
- cr_win32_printing_surface_initialize (VALUE self, VALUE hdc)
1254
- {
1255
- cairo_surface_t *surface = NULL;
1256
-
1257
- surface = cairo_win32_printing_surface_create (NUM2PTR (hdc));
1258
- cr_surface_check_status (surface);
1259
- DATA_PTR (self) = surface;
1260
- if (rb_block_given_p ())
1261
- yield_and_finish (self);
1262
- return Qnil;
1263
- }
1264
- # endif
1265
-
1266
1383
  static VALUE
1267
1384
  cr_win32_surface_get_hdc (VALUE self)
1268
1385
  {
@@ -1290,98 +1407,37 @@ cr_win32_surface_get_image (VALUE self)
1290
1407
  # endif
1291
1408
  #endif
1292
1409
 
1293
- #if defined(CAIRO_HAS_QUARTZ_SURFACE) && defined(HAVE_RUBY_COCOA)
1294
- /* Quartz-surface functions */
1295
-
1296
- #include <objc/objc-runtime.h>
1410
+ #ifdef CAIRO_HAS_SVG_SURFACE
1411
+ /* SVG-surface functions */
1412
+ DEFINE_SURFACE(svg)
1297
1413
 
1298
- BOOL rbobj_to_nsobj (VALUE obj, id* nsobj);
1299
- VALUE ocid_to_rbobj (VALUE context_obj, id ocid);
1414
+ static VALUE
1415
+ cr_svg_surface_restrict_to_version (VALUE self, VALUE version)
1416
+ {
1417
+ cairo_svg_surface_restrict_to_version (_SELF, RVAL2CRSVGVERSION (version));
1418
+ cr_surface_check_status (_SELF);
1419
+ return Qnil;
1420
+ }
1421
+ #endif
1300
1422
 
1423
+ #ifdef RB_CAIRO_HAS_WIN32_PRINTING_SURFACE
1424
+ /* Win32 printing surface functions */
1301
1425
  static VALUE
1302
- cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
1426
+ cr_win32_printing_surface_initialize (VALUE self, VALUE hdc)
1303
1427
  {
1304
- id objc_object = nil;
1305
- CGContextRef context;
1306
- unsigned int width, height;
1307
1428
  cairo_surface_t *surface = NULL;
1308
- cairo_format_t format = CAIRO_FORMAT_ARGB32;
1309
- VALUE arg1, arg2, arg3, rb_width, rb_height;
1310
- static VALUE rb_cOSXCGContextRef = Qnil;
1311
-
1312
- rb_scan_args (argc, argv, "21", &arg1, &arg2, &arg3);
1313
-
1314
- if (argc == 2)
1315
- {
1316
- rb_width = arg1;
1317
- rb_height = arg2;
1318
- }
1319
- else
1320
- {
1321
- switch (TYPE (arg1))
1322
- {
1323
- case T_NIL:
1324
- break;
1325
- case T_STRING:
1326
- case T_SYMBOL:
1327
- case T_FIXNUM:
1328
- format = RVAL2CRFORMAT (arg1);
1329
- break;
1330
- default:
1331
- if (NIL_P (rb_cOSXCGContextRef))
1332
- rb_cOSXCGContextRef =
1333
- rb_const_get (rb_const_get (rb_cObject, rb_intern ("OSX")),
1334
- rb_intern ("CGContextRef"));
1335
-
1336
- if (RTEST (rb_obj_is_kind_of (arg1, rb_cOSXCGContextRef)))
1337
- rbobj_to_nsobj (arg1, &objc_object);
1338
- else
1339
- rb_raise (rb_eArgError,
1340
- "invalid argument (expect "
1341
- "(width, height), "
1342
- "(format, width, height) or "
1343
- "(cg_context, width, height)): %s",
1344
- rb_cairo__inspect (rb_ary_new3 (3, arg1, arg2, arg3)));
1345
- break;
1346
- }
1347
-
1348
- rb_width = arg2;
1349
- rb_height = arg3;
1350
- }
1351
-
1352
- width = NUM2UINT (rb_width);
1353
- height = NUM2UINT (rb_height);
1354
-
1355
- if (objc_object == nil)
1356
- {
1357
- surface = cairo_quartz_surface_create (format, width, height);
1358
- }
1359
- else
1360
- {
1361
- context = (CGContextRef)objc_object;
1362
- surface =
1363
- cairo_quartz_surface_create_for_cg_context (context, width, height);
1364
- }
1365
1429
 
1430
+ surface = cairo_win32_printing_surface_create (NUM2PTR (hdc));
1366
1431
  cr_surface_check_status (surface);
1367
1432
  DATA_PTR (self) = surface;
1368
1433
  if (rb_block_given_p ())
1369
1434
  yield_and_finish (self);
1370
1435
  return Qnil;
1371
1436
  }
1437
+ #endif
1372
1438
 
1373
- static VALUE
1374
- cr_quartz_surface_get_cg_context (VALUE self)
1375
- {
1376
- CGContextRef context;
1377
- id objc_object;
1378
-
1379
- context = cairo_quartz_surface_get_cg_context (_SELF);
1380
- objc_object = (id)context;
1381
- return ocid_to_rbobj (Qnil, objc_object);
1382
- }
1383
-
1384
- # if CAIRO_CHECK_VERSION(1, 5, 12)
1439
+ #ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
1440
+ /* Quartz image surface functions */
1385
1441
  static VALUE
1386
1442
  cr_quartz_image_surface_initialize (VALUE self, VALUE image_surface)
1387
1443
  {
@@ -1406,10 +1462,10 @@ cr_quartz_image_surface_get_image (VALUE self)
1406
1462
  cr_surface_check_status (surface);
1407
1463
  return CRSURFACE2RVAL (surface);
1408
1464
  }
1409
- # endif
1410
1465
  #endif
1411
1466
 
1412
1467
  #ifdef CAIRO_HAS_SCRIPT_SURFACE
1468
+ /* script surface functions */
1413
1469
  static VALUE
1414
1470
  cr_script_surface_initialize (int argc, VALUE *argv, VALUE self)
1415
1471
  {
@@ -1463,13 +1519,101 @@ cr_script_surface_initialize (int argc, VALUE *argv, VALUE self)
1463
1519
  }
1464
1520
  #endif
1465
1521
 
1466
- #ifdef CAIRO_HAS_XML_SURFACE
1522
+ #ifdef CAIRO_HAS_RECORDING_SURFACE
1523
+ /* recording surface functions */
1467
1524
  static VALUE
1468
- cr_xml_surface_initialize (int argc, VALUE *argv, VALUE self)
1525
+ cr_recording_surface_initialize (int argc, VALUE *argv, VALUE self)
1526
+ {
1527
+ VALUE arg1, arg2, arg3, arg4, arg5;
1528
+ cairo_surface_t *surface;
1529
+ cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
1530
+ cairo_rectangle_t extents;
1531
+ const char *error_message =
1532
+ "invalid argument (expect "
1533
+ "(x, y, width, height), "
1534
+ "([x, y, width, height]),"
1535
+ "(x, y, width, height, content) or "
1536
+ "([x, y, width, height], content)): %s";
1537
+
1538
+ rb_scan_args (argc, argv, "14", &arg1, &arg2, &arg3, &arg4, &arg5);
1539
+ if (argc == 1 || argc == 2)
1540
+ {
1541
+ VALUE rb_extents;
1542
+
1543
+ rb_extents = rb_check_array_type (arg1);
1544
+ if (RARRAY_LEN (rb_extents) != 4)
1545
+ rb_raise (rb_eArgError, error_message, rb_cairo__inspect (arg1));
1546
+ extents.x = NUM2DBL (RARRAY_PTR (rb_extents)[0]);
1547
+ extents.y = NUM2DBL (RARRAY_PTR (rb_extents)[1]);
1548
+ extents.width = NUM2DBL (RARRAY_PTR (rb_extents)[2]);
1549
+ extents.height = NUM2DBL (RARRAY_PTR (rb_extents)[3]);
1550
+ if (!NIL_P (arg2))
1551
+ content = RVAL2CRCONTENT (arg2);
1552
+ }
1553
+ else if (argc == 4 || argc == 5)
1554
+ {
1555
+ extents.x = NUM2DBL (arg1);
1556
+ extents.y = NUM2DBL (arg2);
1557
+ extents.width = NUM2DBL (arg3);
1558
+ extents.height = NUM2DBL (arg4);
1559
+ if (!NIL_P (arg5))
1560
+ content = RVAL2CRCONTENT (arg5);
1561
+ }
1562
+ else
1563
+ {
1564
+ rb_raise (rb_eArgError, error_message,
1565
+ rb_cairo__inspect (rb_ary_new4 (argc, argv)));
1566
+ }
1567
+
1568
+ surface = cairo_recording_surface_create (content, &extents);
1569
+ cr_surface_check_status (surface);
1570
+ DATA_PTR (self) = surface;
1571
+ if (rb_block_given_p ())
1572
+ yield_and_finish (self);
1573
+ return Qnil;
1574
+ }
1575
+
1576
+ static VALUE
1577
+ cr_recording_surface_get_ink_extents (VALUE self)
1578
+ {
1579
+ cairo_surface_t *surface;
1580
+ double x, y, width, height;
1581
+
1582
+ surface = _SELF;
1583
+ cairo_recording_surface_ink_extents (surface, &x, &y, &width, &height);
1584
+ cr_surface_check_status (surface);
1585
+ return rb_ary_new3 (4,
1586
+ rb_float_new (x), rb_float_new (y),
1587
+ rb_float_new (width), rb_float_new (height));
1588
+ }
1589
+
1590
+ # if CAIRO_CHECK_VERSION(1, 11, 4)
1591
+ static VALUE
1592
+ cr_recording_surface_get_extents (VALUE self)
1593
+ {
1594
+ cairo_surface_t *surface;
1595
+ cairo_rectangle_t extents;
1596
+
1597
+ surface = _SELF;
1598
+ cairo_recording_surface_get_extents (surface, &extents);
1599
+ cr_surface_check_status (surface);
1600
+ return rb_ary_new3 (4,
1601
+ rb_float_new (extents.x),
1602
+ rb_float_new (extents.y),
1603
+ rb_float_new (extents.width),
1604
+ rb_float_new (extents.height));
1605
+ }
1606
+ # endif
1607
+ #endif
1608
+
1609
+ #ifdef RB_CAIRO_HAS_GL_SURFACE
1610
+ /* GL surface functions */
1611
+ static VALUE
1612
+ cr_gl_surface_initialize (int argc, VALUE *argv, VALUE self)
1469
1613
  {
1470
1614
  cairo_surface_t *surface;
1471
1615
  cairo_device_t *device;
1472
- double width, height;
1616
+ int width, height;
1473
1617
  cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
1474
1618
  VALUE rb_device, rb_width, rb_height, rb_content;
1475
1619
 
@@ -1477,8 +1621,8 @@ cr_xml_surface_initialize (int argc, VALUE *argv, VALUE self)
1477
1621
  &rb_device, &rb_width, &rb_height, &rb_content);
1478
1622
 
1479
1623
  device = RVAL2CRDEVICE (rb_device);
1480
- width = NUM2DBL (rb_width);
1481
- height = NUM2DBL (rb_height);
1624
+ width = NUM2INT (rb_width);
1625
+ height = NUM2INT (rb_height);
1482
1626
  switch (TYPE (rb_content))
1483
1627
  {
1484
1628
  case T_NIL:
@@ -1497,17 +1641,99 @@ cr_xml_surface_initialize (int argc, VALUE *argv, VALUE self)
1497
1641
  break;
1498
1642
  }
1499
1643
 
1500
- surface = cairo_xml_surface_create (device, content, width, height);
1644
+ surface = cairo_gl_surface_create (device, content, width, height);
1645
+
1646
+ cr_surface_check_status (surface);
1647
+ DATA_PTR (self) = surface;
1648
+ if (rb_block_given_p ())
1649
+ yield_and_finish (self);
1650
+ return Qnil;
1651
+ }
1652
+
1653
+ static VALUE
1654
+ cr_gl_texture_surface_initialize (int argc, VALUE *argv, VALUE self)
1655
+ {
1656
+ cairo_surface_t *surface;
1657
+ cairo_device_t *device;
1658
+ unsigned int texture;
1659
+ int width, height;
1660
+ cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
1661
+ VALUE rb_device, rb_texture, rb_width, rb_height, rb_content;
1662
+
1663
+ rb_scan_args (argc, argv, "41",
1664
+ &rb_device, &rb_texture, &rb_width, &rb_height, &rb_content);
1665
+
1666
+ device = RVAL2CRDEVICE (rb_device);
1667
+ texture = NUM2UINT (rb_texture);
1668
+ width = NUM2INT (rb_width);
1669
+ height = NUM2INT (rb_height);
1670
+ switch (TYPE (rb_content))
1671
+ {
1672
+ case T_NIL:
1673
+ break;
1674
+ case T_STRING:
1675
+ case T_SYMBOL:
1676
+ case T_FIXNUM:
1677
+ content = RVAL2CRCONTENT (rb_content);
1678
+ break;
1679
+ default:
1680
+ rb_raise (rb_eArgError,
1681
+ "invalid argument (expect "
1682
+ "(device, texture, width, height) or "
1683
+ "(device, texture, width, height, content)): %s",
1684
+ rb_cairo__inspect (rb_ary_new4 (argc, argv)));
1685
+ break;
1686
+ }
1687
+
1688
+ surface = cairo_gl_surface_create_for_texture (device, content,
1689
+ texture,
1690
+ width,
1691
+ height);
1692
+
1693
+ cr_surface_check_status (surface);
1694
+ DATA_PTR (self) = surface;
1695
+ if (rb_block_given_p ())
1696
+ yield_and_finish (self);
1697
+ return Qnil;
1698
+ }
1699
+
1700
+ static VALUE
1701
+ cr_gl_surface_set_size (VALUE self, VALUE width, VALUE height)
1702
+ {
1703
+ cairo_surface_t *surface = NULL;
1704
+
1705
+ surface = _SELF;
1706
+ cairo_gl_surface_set_size (surface, NUM2INT (width), NUM2INT (height));
1707
+ cr_surface_check_status (surface);
1708
+ return Qnil;
1709
+ }
1710
+
1711
+ static VALUE
1712
+ cr_gl_surface_get_width (VALUE self)
1713
+ {
1714
+ return INT2NUM (cairo_gl_surface_get_width (_SELF));
1715
+ }
1716
+
1717
+ static VALUE
1718
+ cr_gl_surface_get_height (VALUE self)
1719
+ {
1720
+ return INT2NUM (cairo_gl_surface_get_height (_SELF));
1721
+ }
1722
+
1723
+ static VALUE
1724
+ cr_gl_surface_swap_buffers (VALUE self)
1725
+ {
1726
+ cairo_surface_t *surface = NULL;
1501
1727
 
1728
+ surface = _SELF;
1729
+ cairo_gl_surface_swapbuffers (surface);
1502
1730
  cr_surface_check_status (surface);
1503
- DATA_PTR (self) = surface;
1504
- if (rb_block_given_p ())
1505
- yield_and_finish (self);
1506
1731
  return Qnil;
1507
1732
  }
1508
1733
  #endif
1509
1734
 
1510
1735
  #ifdef CAIRO_HAS_TEE_SURFACE
1736
+ /* tee surface functions */
1511
1737
  static VALUE
1512
1738
  cr_tee_surface_initialize (VALUE self, VALUE master)
1513
1739
  {
@@ -1599,13 +1825,14 @@ cr_tee_surface_array_reference (VALUE self, VALUE index)
1599
1825
  }
1600
1826
  #endif
1601
1827
 
1602
- #ifdef RB_CAIRO_HAS_GL_SURFACE
1828
+ #ifdef CAIRO_HAS_XML_SURFACE
1829
+ /* XML surface functions */
1603
1830
  static VALUE
1604
- cr_gl_surface_initialize (int argc, VALUE *argv, VALUE self)
1831
+ cr_xml_surface_initialize (int argc, VALUE *argv, VALUE self)
1605
1832
  {
1606
1833
  cairo_surface_t *surface;
1607
1834
  cairo_device_t *device;
1608
- int width, height;
1835
+ double width, height;
1609
1836
  cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
1610
1837
  VALUE rb_device, rb_width, rb_height, rb_content;
1611
1838
 
@@ -1613,8 +1840,8 @@ cr_gl_surface_initialize (int argc, VALUE *argv, VALUE self)
1613
1840
  &rb_device, &rb_width, &rb_height, &rb_content);
1614
1841
 
1615
1842
  device = RVAL2CRDEVICE (rb_device);
1616
- width = NUM2INT (rb_width);
1617
- height = NUM2INT (rb_height);
1843
+ width = NUM2DBL (rb_width);
1844
+ height = NUM2DBL (rb_height);
1618
1845
  switch (TYPE (rb_content))
1619
1846
  {
1620
1847
  case T_NIL:
@@ -1633,54 +1860,7 @@ cr_gl_surface_initialize (int argc, VALUE *argv, VALUE self)
1633
1860
  break;
1634
1861
  }
1635
1862
 
1636
- surface = cairo_gl_surface_create (device, content, width, height);
1637
-
1638
- cr_surface_check_status (surface);
1639
- DATA_PTR (self) = surface;
1640
- if (rb_block_given_p ())
1641
- yield_and_finish (self);
1642
- return Qnil;
1643
- }
1644
-
1645
- static VALUE
1646
- cr_gl_texture_surface_initialize (int argc, VALUE *argv, VALUE self)
1647
- {
1648
- cairo_surface_t *surface;
1649
- cairo_device_t *device;
1650
- unsigned int texture;
1651
- int width, height;
1652
- cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
1653
- VALUE rb_device, rb_texture, rb_width, rb_height, rb_content;
1654
-
1655
- rb_scan_args (argc, argv, "41",
1656
- &rb_device, &rb_texture, &rb_width, &rb_height, &rb_content);
1657
-
1658
- device = RVAL2CRDEVICE (rb_device);
1659
- texture = NUM2UINT (rb_texture);
1660
- width = NUM2INT (rb_width);
1661
- height = NUM2INT (rb_height);
1662
- switch (TYPE (rb_content))
1663
- {
1664
- case T_NIL:
1665
- break;
1666
- case T_STRING:
1667
- case T_SYMBOL:
1668
- case T_FIXNUM:
1669
- content = RVAL2CRCONTENT (rb_content);
1670
- break;
1671
- default:
1672
- rb_raise (rb_eArgError,
1673
- "invalid argument (expect "
1674
- "(device, texture, width, height) or "
1675
- "(device, texture, width, height, content)): %s",
1676
- rb_cairo__inspect (rb_ary_new4 (argc, argv)));
1677
- break;
1678
- }
1679
-
1680
- surface = cairo_gl_surface_create_for_texture (device, content,
1681
- texture,
1682
- width,
1683
- height);
1863
+ surface = cairo_xml_surface_create (device, content, width, height);
1684
1864
 
1685
1865
  cr_surface_check_status (surface);
1686
1866
  DATA_PTR (self) = surface;
@@ -1688,40 +1868,6 @@ cr_gl_texture_surface_initialize (int argc, VALUE *argv, VALUE self)
1688
1868
  yield_and_finish (self);
1689
1869
  return Qnil;
1690
1870
  }
1691
-
1692
- static VALUE
1693
- cr_gl_surface_set_size (VALUE self, VALUE width, VALUE height)
1694
- {
1695
- cairo_surface_t *surface = NULL;
1696
-
1697
- surface = _SELF;
1698
- cairo_gl_surface_set_size (surface, NUM2INT (width), NUM2INT (height));
1699
- cr_surface_check_status (surface);
1700
- return Qnil;
1701
- }
1702
-
1703
- static VALUE
1704
- cr_gl_surface_get_width (VALUE self)
1705
- {
1706
- return INT2NUM (cairo_gl_surface_get_width (_SELF));
1707
- }
1708
-
1709
- static VALUE
1710
- cr_gl_surface_get_height (VALUE self)
1711
- {
1712
- return INT2NUM (cairo_gl_surface_get_height (_SELF));
1713
- }
1714
-
1715
- static VALUE
1716
- cr_gl_surface_swap_buffers (VALUE self)
1717
- {
1718
- cairo_surface_t *surface = NULL;
1719
-
1720
- surface = _SELF;
1721
- cairo_gl_surface_swapbuffers (surface);
1722
- cr_surface_check_status (surface);
1723
- return Qnil;
1724
- }
1725
1871
  #endif
1726
1872
 
1727
1873
  static int
@@ -1753,6 +1899,37 @@ Init_cairo_surface (void)
1753
1899
  rb_cairo__initialize_gc_guard_holder_class (rb_cCairo_Surface);
1754
1900
  rb_set_end_proc(cr_finish_all_guarded_surfaces_at_end, Qnil);
1755
1901
 
1902
+ rb_define_singleton_method (rb_cCairo_Surface, "image_supported?",
1903
+ cr_surface_image_supported_p, 0);
1904
+ rb_define_singleton_method (rb_cCairo_Surface, "pdf_supported?",
1905
+ cr_surface_pdf_supported_p, 0);
1906
+ rb_define_singleton_method (rb_cCairo_Surface, "ps_supported?",
1907
+ cr_surface_ps_supported_p, 0);
1908
+ rb_define_singleton_method (rb_cCairo_Surface, "quartz_supported?",
1909
+ cr_surface_quartz_supported_p, 0);
1910
+ rb_define_singleton_method (rb_cCairo_Surface, "win32_supported?",
1911
+ cr_surface_win32_supported_p, 0);
1912
+ rb_define_singleton_method (rb_cCairo_Surface, "svg_supported?",
1913
+ cr_surface_svg_supported_p, 0);
1914
+ rb_define_singleton_method (rb_cCairo_Surface, "win32_printing_supported?",
1915
+ cr_surface_win32_printing_supported_p, 0);
1916
+ rb_define_singleton_method (rb_cCairo_Surface, "quartz_image_supported?",
1917
+ cr_surface_quartz_image_supported_p, 0);
1918
+ rb_define_singleton_method (rb_cCairo_Surface, "script_supported?",
1919
+ cr_surface_script_supported_p, 0);
1920
+ rb_define_singleton_method (rb_cCairo_Surface, "recording_supported?",
1921
+ cr_surface_recording_supported_p, 0);
1922
+ rb_define_singleton_method (rb_cCairo_Surface, "gl_supported?",
1923
+ cr_surface_gl_supported_p, 0);
1924
+ rb_define_singleton_method (rb_cCairo_Surface, "gl_texture_supported?",
1925
+ cr_surface_gl_texture_supported_p, 0);
1926
+ rb_define_singleton_method (rb_cCairo_Surface, "tee_supported?",
1927
+ cr_surface_tee_supported_p, 0);
1928
+ rb_define_singleton_method (rb_cCairo_Surface, "xml_supported?",
1929
+ cr_surface_xml_supported_p, 0);
1930
+
1931
+ rb_define_method (rb_cCairo_Surface, "initialize",
1932
+ cr_surface_initialize, -1);
1756
1933
 
1757
1934
  rb_define_method (rb_cCairo_Surface, "create_similar",
1758
1935
  cr_surface_create_similar, -1);
@@ -1814,15 +1991,15 @@ Init_cairo_surface (void)
1814
1991
 
1815
1992
  RB_CAIRO_DEF_SETTERS (rb_cCairo_Surface);
1816
1993
 
1817
- /* Image-surface */
1994
+ /* image surface */
1818
1995
  rb_cCairo_ImageSurface =
1819
1996
  rb_define_class_under (rb_mCairo, "ImageSurface", rb_cCairo_Surface);
1820
-
1997
+
1821
1998
  #ifdef CAIRO_HAS_PNG_FUNCTIONS
1822
1999
  rb_define_singleton_method (rb_cCairo_ImageSurface, "from_png",
1823
2000
  cr_image_surface_create_from_png_generic, 1);
1824
2001
  #endif
1825
-
2002
+
1826
2003
  rb_define_method (rb_cCairo_ImageSurface, "initialize",
1827
2004
  cr_image_surface_initialize, -1);
1828
2005
 
@@ -1837,34 +2014,30 @@ Init_cairo_surface (void)
1837
2014
  rb_define_method (rb_cCairo_ImageSurface, "stride",
1838
2015
  cr_image_surface_get_stride, 0);
1839
2016
 
1840
- #ifdef CAIRO_HAS_RECORDING_SURFACE
1841
- /* Recording-surface */
1842
- rb_cCairo_RecordingSurface =
1843
- rb_define_class_under (rb_mCairo, "RecordingSurface", rb_cCairo_Surface);
2017
+ /* PDF surface */
2018
+ rb_cCairo_PDFSurface =
2019
+ rb_define_class_under (rb_mCairo, "PDFSurface", rb_cCairo_Surface);
2020
+ #ifdef CAIRO_HAS_PDF_SURFACE
2021
+ rb_define_method (rb_cCairo_PDFSurface, "initialize",
2022
+ cr_pdf_surface_initialize, -1);
1844
2023
 
1845
- rb_define_method (rb_cCairo_RecordingSurface, "initialize",
1846
- cr_recording_surface_initialize, -1);
2024
+ rb_define_method (rb_cCairo_PDFSurface, "set_size",
2025
+ cr_pdf_surface_set_size, -1);
1847
2026
 
1848
- rb_define_method (rb_cCairo_RecordingSurface, "ink_extents",
1849
- cr_recording_surface_get_ink_extents, 0);
1850
- # if CAIRO_CHECK_VERSION(1, 11, 4)
1851
- rb_define_method (rb_cCairo_RecordingSurface, "extents",
1852
- cr_recording_surface_get_extents, 0);
2027
+ # if CAIRO_CHECK_VERSION(1, 10, 0)
2028
+ rb_define_method (rb_cCairo_PDFSurface, "restrict_to_version",
2029
+ cr_pdf_surface_restrict_to_version, 1);
1853
2030
  # endif
1854
- #endif
1855
2031
 
1856
- #define INIT_SURFACE(type, name) \
1857
- rb_cCairo_ ## name ## Surface = \
1858
- rb_define_class_under (rb_mCairo, # name "Surface", \
1859
- rb_cCairo_Surface); \
1860
- \
1861
- rb_define_method (rb_cCairo_ ## name ## Surface, "initialize", \
1862
- cr_ ## type ## _surface_initialize, -1);
2032
+ RB_CAIRO_DEF_SETTERS (rb_cCairo_PDFSurface);
2033
+ #endif
1863
2034
 
2035
+ /* PS surface */
2036
+ rb_cCairo_PSSurface =
2037
+ rb_define_class_under (rb_mCairo, "PSSurface", rb_cCairo_Surface);
1864
2038
  #ifdef CAIRO_HAS_PS_SURFACE
1865
- /* PS-surface */
1866
- INIT_SURFACE(ps, PS)
1867
-
2039
+ rb_define_method (rb_cCairo_PSSurface, "initialize",
2040
+ cr_ps_surface_initialize, -1);
1868
2041
  rb_define_method (rb_cCairo_PSSurface, "set_size", cr_ps_surface_set_size, -1);
1869
2042
  rb_define_method (rb_cCairo_PSSurface, "dsc_comment",
1870
2043
  cr_ps_surface_dsc_comment, 1);
@@ -1883,50 +2056,28 @@ Init_cairo_surface (void)
1883
2056
  RB_CAIRO_DEF_SETTERS (rb_cCairo_PSSurface);
1884
2057
  #endif
1885
2058
 
1886
- #ifdef CAIRO_HAS_PDF_SURFACE
1887
- /* PDF-surface */
1888
- INIT_SURFACE(pdf, PDF)
1889
-
1890
- rb_define_method (rb_cCairo_PDFSurface, "set_size",
1891
- cr_pdf_surface_set_size, -1);
1892
-
1893
- # if CAIRO_CHECK_VERSION(1, 10, 0)
1894
- rb_define_method (rb_cCairo_PDFSurface, "restrict_to_version",
1895
- cr_pdf_surface_restrict_to_version, 1);
1896
- # endif
1897
-
1898
- RB_CAIRO_DEF_SETTERS (rb_cCairo_PDFSurface);
1899
- #endif
1900
-
1901
- #ifdef CAIRO_HAS_XLIB_SURFACE
1902
- /* XLib-surface */
1903
- INIT_SURFACE(xlib, XLib)
1904
-
1905
- RB_CAIRO_DEF_SETTERS (rb_cCairo_XLibSurface);
1906
- #endif
1907
-
1908
- #ifdef CAIRO_HAS_XCB_SURFACE
1909
- /* XLib-surface */
1910
- INIT_SURFACE(xcb, XCB)
1911
-
1912
- RB_CAIRO_DEF_SETTERS (rb_cCairo_XCBSurface);
1913
- #endif
1914
-
1915
- #ifdef CAIRO_HAS_SVG_SURFACE
1916
- /* SVG-surface */
1917
- INIT_SURFACE(svg, SVG)
2059
+ /* XLib surface */
2060
+ rb_cCairo_XLibSurface =
2061
+ rb_define_class_under (rb_mCairo, "XLibSurface", rb_cCairo_Surface);
1918
2062
 
1919
- rb_define_method (rb_cCairo_SVGSurface, "restrict_to_version",
1920
- cr_svg_surface_restrict_to_version, 1);
2063
+ /* XCB surface */
2064
+ rb_cCairo_XCBSurface =
2065
+ rb_define_class_under (rb_mCairo, "XCBSurface", rb_cCairo_Surface);
1921
2066
 
1922
- RB_CAIRO_DEF_SETTERS (rb_cCairo_SVGSurface);
2067
+ /* Quartz surface */
2068
+ rb_cCairo_QuartzSurface =
2069
+ rb_define_class_under (rb_mCairo, "QuartzSurface", rb_cCairo_Surface);
2070
+ #ifdef RB_CAIRO_HAS_QUARTZ_SURFACE
2071
+ rb_define_method (rb_cCairo_QuartzSurface, "initialize",
2072
+ cr_quartz_surface_initialize, -1);
2073
+ rb_define_method (rb_cCairo_QuartzSurface, "cg_context",
2074
+ cr_quartz_surface_get_cg_context, 0);
1923
2075
  #endif
1924
2076
 
1925
- #ifdef CAIRO_HAS_WIN32_SURFACE
1926
- /* Win32-surface */
2077
+ /* Win32 surface */
1927
2078
  rb_cCairo_Win32Surface =
1928
2079
  rb_define_class_under (rb_mCairo, "Win32Surface", rb_cCairo_Surface);
1929
-
2080
+ #ifdef CAIRO_HAS_WIN32_SURFACE
1930
2081
  rb_define_method (rb_cCairo_Win32Surface, "initialize",
1931
2082
  cr_win32_surface_initialize, -1);
1932
2083
  rb_define_method (rb_cCairo_Win32Surface, "hdc",
@@ -1935,84 +2086,79 @@ Init_cairo_surface (void)
1935
2086
  rb_define_method (rb_cCairo_Win32Surface, "image",
1936
2087
  cr_win32_surface_get_image, 0);
1937
2088
  # endif
2089
+ #endif
1938
2090
 
1939
- # if CAIRO_CHECK_VERSION(1, 5, 2)
2091
+ /* SVG surface */
2092
+ rb_cCairo_SVGSurface =
2093
+ rb_define_class_under (rb_mCairo, "SVGSurface", rb_cCairo_Surface);
2094
+ #ifdef CAIRO_HAS_SVG_SURFACE
2095
+ rb_define_method (rb_cCairo_SVGSurface, "initialize",
2096
+ cr_svg_surface_initialize, -1);
2097
+ rb_define_method (rb_cCairo_SVGSurface, "restrict_to_version",
2098
+ cr_svg_surface_restrict_to_version, 1);
2099
+
2100
+ RB_CAIRO_DEF_SETTERS (rb_cCairo_SVGSurface);
2101
+ #endif
2102
+
2103
+ /* Win32 printing surface */
1940
2104
  rb_cCairo_Win32PrintingSurface =
1941
2105
  rb_define_class_under (rb_mCairo, "Win32PrintingSurface", rb_cCairo_Surface);
1942
-
2106
+ #ifdef RB_CAIRO_HAS_WIN32_PRINTING_SURFACE
1943
2107
  rb_define_method (rb_cCairo_Win32PrintingSurface, "initialize",
1944
2108
  cr_win32_printing_surface_initialize, -1);
1945
2109
  rb_define_method (rb_cCairo_Win32PrintingSurface, "hdc",
1946
2110
  cr_win32_surface_get_hdc, 0);
1947
- # endif
1948
-
1949
2111
  #endif
1950
2112
 
1951
- #if defined(CAIRO_HAS_QUARTZ_SURFACE) && defined(HAVE_RUBY_COCOA)
1952
- /* Quartz-surface */
1953
-
1954
- rb_cCairo_QuartzSurface =
1955
- rb_define_class_under (rb_mCairo, "QuartzSurface", rb_cCairo_Surface);
1956
-
1957
- rb_define_method (rb_cCairo_QuartzSurface, "initialize",
1958
- cr_quartz_surface_initialize, -1);
1959
- rb_define_method (rb_cCairo_QuartzSurface, "cg_context",
1960
- cr_quartz_surface_get_cg_context, 0);
1961
-
1962
- # if CAIRO_CHECK_VERSION(1, 5, 12)
2113
+ /* Quartz image surface */
1963
2114
  rb_cCairo_QuartzImageSurface =
1964
2115
  rb_define_class_under (rb_mCairo, "QuartzImageSurface", rb_cCairo_Surface);
1965
-
2116
+ #ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
1966
2117
  rb_define_method (rb_cCairo_QuartzImageSurface, "initialize",
1967
2118
  cr_quartz_image_surface_initialize, 1);
1968
2119
  rb_define_method (rb_cCairo_QuartzImageSurface, "image",
1969
2120
  cr_quartz_image_surface_get_image, 0);
1970
- # endif
1971
2121
  #endif
1972
2122
 
1973
- #ifdef CAIRO_HAS_SCRIPT_SURFACE
2123
+ /* script surface */
1974
2124
  rb_cCairo_ScriptSurface =
1975
2125
  rb_define_class_under (rb_mCairo, "ScriptSurface", rb_cCairo_Surface);
1976
-
2126
+ #ifdef CAIRO_HAS_SCRIPT_SURFACE
1977
2127
  rb_define_method (rb_cCairo_ScriptSurface, "initialize",
1978
2128
  cr_script_surface_initialize, -1);
1979
2129
 
1980
2130
  RB_CAIRO_DEF_SETTERS (rb_cCairo_ScriptSurface);
1981
2131
  #endif
1982
2132
 
1983
- #ifdef CAIRO_HAS_XML_SURFACE
1984
- rb_cCairo_XMLSurface =
1985
- rb_define_class_under (rb_mCairo, "XMLSurface", rb_cCairo_Surface);
2133
+ /* Qt surface */
2134
+ rb_cCairo_QtSurface =
2135
+ rb_define_class_under (rb_mCairo, "QtSurface", rb_cCairo_Surface);
1986
2136
 
1987
- rb_define_method (rb_cCairo_XMLSurface, "initialize",
1988
- cr_xml_surface_initialize, -1);
2137
+ /* recording surface */
2138
+ rb_cCairo_RecordingSurface =
2139
+ rb_define_class_under (rb_mCairo, "RecordingSurface", rb_cCairo_Surface);
2140
+ #ifdef CAIRO_HAS_RECORDING_SURFACE
2141
+ rb_define_method (rb_cCairo_RecordingSurface, "initialize",
2142
+ cr_recording_surface_initialize, -1);
1989
2143
 
1990
- RB_CAIRO_DEF_SETTERS (rb_cCairo_XMLSurface);
2144
+ rb_define_method (rb_cCairo_RecordingSurface, "ink_extents",
2145
+ cr_recording_surface_get_ink_extents, 0);
2146
+ # if CAIRO_CHECK_VERSION(1, 11, 4)
2147
+ rb_define_method (rb_cCairo_RecordingSurface, "extents",
2148
+ cr_recording_surface_get_extents, 0);
2149
+ # endif
1991
2150
  #endif
1992
2151
 
1993
- #ifdef CAIRO_HAS_TEE_SURFACE
1994
- rb_cCairo_TeeSurface =
1995
- rb_define_class_under (rb_mCairo, "TeeSurface", rb_cCairo_Surface);
1996
-
1997
- rb_define_method (rb_cCairo_TeeSurface, "initialize",
1998
- cr_tee_surface_initialize, 1);
1999
-
2000
- rb_define_method (rb_cCairo_TeeSurface, "add",
2001
- cr_tee_surface_add, 1);
2002
- rb_define_method (rb_cCairo_TeeSurface, "<<",
2003
- cr_tee_surface_shift_operator, 1);
2004
- rb_define_method (rb_cCairo_TeeSurface, "remove",
2005
- cr_tee_surface_remove, 1);
2006
- rb_define_method (rb_cCairo_TeeSurface, "[]",
2007
- cr_tee_surface_array_reference, 1);
2008
-
2009
- RB_CAIRO_DEF_SETTERS (rb_cCairo_TeeSurface);
2010
- #endif
2152
+ /* VG surface */
2153
+ rb_cCairo_VGSurface =
2154
+ rb_define_class_under (rb_mCairo, "VGSurface", rb_cCairo_Surface);
2011
2155
 
2012
- #ifdef RB_CAIRO_HAS_GL_SURFACE
2156
+ /* GL surface */
2013
2157
  rb_cCairo_GLSurface =
2014
2158
  rb_define_class_under (rb_mCairo, "GLSurface", rb_cCairo_Surface);
2015
-
2159
+ rb_cCairo_GLTextureSurface =
2160
+ rb_define_class_under (rb_mCairo, "GLTextureSurface", rb_cCairo_GLSurface);
2161
+ #ifdef RB_CAIRO_HAS_GL_SURFACE
2016
2162
  rb_define_method (rb_cCairo_GLSurface, "initialize",
2017
2163
  cr_gl_surface_initialize, 1);
2018
2164
 
@@ -2027,12 +2173,54 @@ Init_cairo_surface (void)
2027
2173
 
2028
2174
  RB_CAIRO_DEF_SETTERS (rb_cCairo_GLSurface);
2029
2175
 
2030
- rb_cCairo_GLTextureSurface =
2031
- rb_define_class_under (rb_mCairo, "GLTextureSurface", rb_cCairo_GLSurface);
2032
-
2033
2176
  rb_define_method (rb_cCairo_GLTextureSurface, "initialize",
2034
2177
  cr_gl_texture_surface_initialize, 1);
2035
2178
 
2036
2179
  RB_CAIRO_DEF_SETTERS (rb_cCairo_GLTextureSurface);
2037
2180
  #endif
2181
+
2182
+ /* DRM surface */
2183
+ rb_cCairo_DRMSurface =
2184
+ rb_define_class_under (rb_mCairo, "DRMSurface", rb_cCairo_Surface);
2185
+
2186
+ /* tee surface */
2187
+ rb_cCairo_TeeSurface =
2188
+ rb_define_class_under (rb_mCairo, "TeeSurface", rb_cCairo_Surface);
2189
+ #ifdef CAIRO_HAS_TEE_SURFACE
2190
+ rb_define_method (rb_cCairo_TeeSurface, "initialize",
2191
+ cr_tee_surface_initialize, 1);
2192
+
2193
+ rb_define_method (rb_cCairo_TeeSurface, "add",
2194
+ cr_tee_surface_add, 1);
2195
+ rb_define_method (rb_cCairo_TeeSurface, "<<",
2196
+ cr_tee_surface_shift_operator, 1);
2197
+ rb_define_method (rb_cCairo_TeeSurface, "remove",
2198
+ cr_tee_surface_remove, 1);
2199
+ rb_define_method (rb_cCairo_TeeSurface, "[]",
2200
+ cr_tee_surface_array_reference, 1);
2201
+
2202
+ RB_CAIRO_DEF_SETTERS (rb_cCairo_TeeSurface);
2203
+ #endif
2204
+
2205
+ /* XML surface */
2206
+ rb_cCairo_XMLSurface =
2207
+ rb_define_class_under (rb_mCairo, "XMLSurface", rb_cCairo_Surface);
2208
+ #ifdef CAIRO_HAS_XML_SURFACE
2209
+ rb_define_method (rb_cCairo_XMLSurface, "initialize",
2210
+ cr_xml_surface_initialize, -1);
2211
+
2212
+ RB_CAIRO_DEF_SETTERS (rb_cCairo_XMLSurface);
2213
+ #endif
2214
+
2215
+ /* Skia surface */
2216
+ rb_cCairo_SkiaSurface =
2217
+ rb_define_class_under (rb_mCairo, "SkiaSurface", rb_cCairo_Surface);
2218
+
2219
+ /* sub surface */
2220
+ rb_cCairo_SubSurface =
2221
+ rb_define_class_under (rb_mCairo, "SubSurface", rb_cCairo_Surface);
2222
+
2223
+ /* Cogl surface */
2224
+ rb_cCairo_CoglSurface =
2225
+ rb_define_class_under (rb_mCairo, "CoglSurface", rb_cCairo_Surface);
2038
2226
  }