cairo 1.8.5 → 1.10.0

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.

Files changed (106) hide show
  1. data/NEWS +2 -2
  2. data/Rakefile +44 -7
  3. data/ext/cairo/cairo.def +28 -1
  4. data/ext/cairo/extconf.rb +14 -16
  5. data/ext/cairo/rb_cairo.c +4 -1
  6. data/ext/cairo/rb_cairo.h +65 -1
  7. data/ext/cairo/rb_cairo_constants.c +150 -3
  8. data/ext/cairo/rb_cairo_context.c +17 -0
  9. data/ext/cairo/rb_cairo_device.c +406 -0
  10. data/ext/cairo/rb_cairo_exception.c +83 -32
  11. data/ext/cairo/rb_cairo_io.c +166 -0
  12. data/ext/cairo/rb_cairo_io.h +44 -0
  13. data/ext/cairo/rb_cairo_matrix.c +1 -1
  14. data/ext/cairo/rb_cairo_private.h +3 -0
  15. data/ext/cairo/rb_cairo_region.c +385 -0
  16. data/ext/cairo/rb_cairo_surface.c +674 -199
  17. data/samples/blur.rb +2 -3
  18. data/samples/{pac2.rb → pac-nomralize.rb} +5 -6
  19. data/samples/pac-tee.rb +170 -0
  20. data/samples/pac.rb +2 -3
  21. data/samples/png.rb +2 -3
  22. data/samples/scalable.rb +2 -3
  23. data/samples/text-on-path.rb +2 -3
  24. data/samples/text2.rb +2 -3
  25. data/test/cairo-test-utils.rb +15 -0
  26. data/test/run-test.rb +5 -4
  27. data/test/test_context.rb +4 -4
  28. data/test/test_font_face.rb +34 -21
  29. data/test/test_recording_surface.rb +18 -0
  30. data/test/test_region.rb +102 -0
  31. data/test/test_script_device.rb +46 -0
  32. data/test/test_script_surface.rb +13 -0
  33. data/test/test_surface.rb +14 -4
  34. data/test/test_tee_surface.rb +32 -0
  35. data/test/test_xml_device.rb +22 -0
  36. data/test/test_xml_surface.rb +32 -0
  37. metadata +49 -77
  38. data/pkg-config.rb +0 -313
  39. data/test-unit/Rakefile +0 -30
  40. data/test-unit/bin/testrb +0 -5
  41. data/test-unit/lib/test/unit.rb +0 -280
  42. data/test-unit/lib/test/unit/assertionfailederror.rb +0 -14
  43. data/test-unit/lib/test/unit/assertions.rb +0 -722
  44. data/test-unit/lib/test/unit/attribute.rb +0 -125
  45. data/test-unit/lib/test/unit/autorunner.rb +0 -254
  46. data/test-unit/lib/test/unit/collector.rb +0 -43
  47. data/test-unit/lib/test/unit/collector/descendant.rb +0 -23
  48. data/test-unit/lib/test/unit/collector/dir.rb +0 -108
  49. data/test-unit/lib/test/unit/collector/load.rb +0 -135
  50. data/test-unit/lib/test/unit/collector/objectspace.rb +0 -34
  51. data/test-unit/lib/test/unit/color.rb +0 -61
  52. data/test-unit/lib/test/unit/diff.rb +0 -524
  53. data/test-unit/lib/test/unit/error.rb +0 -124
  54. data/test-unit/lib/test/unit/exceptionhandler.rb +0 -39
  55. data/test-unit/lib/test/unit/failure.rb +0 -110
  56. data/test-unit/lib/test/unit/fixture.rb +0 -185
  57. data/test-unit/lib/test/unit/notification.rb +0 -125
  58. data/test-unit/lib/test/unit/omission.rb +0 -143
  59. data/test-unit/lib/test/unit/pending.rb +0 -146
  60. data/test-unit/lib/test/unit/priority.rb +0 -146
  61. data/test-unit/lib/test/unit/runner/console.rb +0 -46
  62. data/test-unit/lib/test/unit/runner/emacs.rb +0 -8
  63. data/test-unit/lib/test/unit/testcase.rb +0 -281
  64. data/test-unit/lib/test/unit/testresult.rb +0 -89
  65. data/test-unit/lib/test/unit/testsuite.rb +0 -110
  66. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +0 -14
  67. data/test-unit/lib/test/unit/ui/console/testrunner.rb +0 -195
  68. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +0 -49
  69. data/test-unit/lib/test/unit/ui/testrunner.rb +0 -20
  70. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +0 -77
  71. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +0 -41
  72. data/test-unit/lib/test/unit/util/backtracefilter.rb +0 -41
  73. data/test-unit/lib/test/unit/util/observable.rb +0 -90
  74. data/test-unit/lib/test/unit/util/procwrapper.rb +0 -48
  75. data/test-unit/lib/test/unit/version.rb +0 -7
  76. data/test-unit/sample/adder.rb +0 -13
  77. data/test-unit/sample/subtracter.rb +0 -12
  78. data/test-unit/sample/tc_adder.rb +0 -18
  79. data/test-unit/sample/tc_subtracter.rb +0 -18
  80. data/test-unit/sample/ts_examples.rb +0 -7
  81. data/test-unit/test/collector/test_descendant.rb +0 -135
  82. data/test-unit/test/collector/test_dir.rb +0 -406
  83. data/test-unit/test/collector/test_load.rb +0 -333
  84. data/test-unit/test/collector/test_objectspace.rb +0 -98
  85. data/test-unit/test/run-test.rb +0 -13
  86. data/test-unit/test/test_assertions.rb +0 -693
  87. data/test-unit/test/test_attribute.rb +0 -86
  88. data/test-unit/test/test_color.rb +0 -37
  89. data/test-unit/test/test_diff.rb +0 -477
  90. data/test-unit/test/test_emacs_runner.rb +0 -60
  91. data/test-unit/test/test_error.rb +0 -26
  92. data/test-unit/test/test_failure.rb +0 -33
  93. data/test-unit/test/test_fixture.rb +0 -252
  94. data/test-unit/test/test_notification.rb +0 -33
  95. data/test-unit/test/test_omission.rb +0 -81
  96. data/test-unit/test/test_pending.rb +0 -70
  97. data/test-unit/test/test_priority.rb +0 -89
  98. data/test-unit/test/test_testcase.rb +0 -430
  99. data/test-unit/test/test_testresult.rb +0 -113
  100. data/test-unit/test/test_testsuite.rb +0 -129
  101. data/test-unit/test/testunit_test_util.rb +0 -14
  102. data/test-unit/test/ui/test_testrunmediator.rb +0 -20
  103. data/test-unit/test/util/test_backtracefilter.rb +0 -41
  104. data/test-unit/test/util/test_observable.rb +0 -102
  105. data/test-unit/test/util/test_procwrapper.rb +0 -36
  106. data/test/test_pkg_config.rb +0 -123
@@ -5,6 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-11-01 14:23:14 $
7
7
  *
8
+ * Copyright 2005-2010 Kouhei Sutou <kou@cozmixng.org>
8
9
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
9
10
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
10
11
  *
@@ -14,6 +15,7 @@
14
15
 
15
16
  #include "rb_cairo.h"
16
17
  #include "rb_cairo_private.h"
18
+ #include "rb_cairo_io.h"
17
19
 
18
20
  #ifdef HAVE_RUBY_ST_H
19
21
  # include <ruby/st.h>
@@ -44,14 +46,17 @@ enum ruby_value_type {
44
46
  # define T_DATA RUBY_T_DATA
45
47
  #endif
46
48
 
47
- #if defined(CAIRO_HAS_PS_SURFACE) || \
48
- defined(CAIRO_HAS_PDF_SURFACE) || \
49
- defined(CAIRO_HAS_SVG_SURFACE)
50
- # define HAS_CREATE_CR_CLOSURE_SURFACE 1
51
- #else
52
- # define HAS_CREATE_CR_CLOSURE_SURFACE 0
49
+ #ifdef CAIRO_HAS_XML_SURFACE
50
+ # include <cairo-xml.h>
51
+ #endif
52
+
53
+ #ifdef CAIRO_HAS_TEE_SURFACE
54
+ # include <cairo-tee.h>
53
55
  #endif
54
56
 
57
+ #ifdef CAIRO_HAS_GL_SURFACE
58
+ # include <cairo-gl.h>
59
+ #endif
55
60
 
56
61
  VALUE rb_cCairo_Surface;
57
62
  VALUE rb_cCairo_ImageSurface;
@@ -62,11 +67,18 @@ VALUE rb_cCairo_Win32Surface = Qnil;
62
67
  VALUE rb_cCairo_Win32PrintingSurface = Qnil;
63
68
  VALUE rb_cCairo_QuartzSurface = Qnil;
64
69
  VALUE rb_cCairo_QuartzImageSurface = Qnil;
70
+ VALUE rb_cCairo_ScriptSurface = Qnil;
71
+ VALUE rb_cCairo_QtSurface = Qnil;
72
+ VALUE rb_cCairo_RecordingSurface = Qnil;
73
+ VALUE rb_cCairo_VGSurface = Qnil;
74
+ VALUE rb_cCairo_GLSurface = Qnil;
75
+ VALUE rb_cCairo_GLTextureSurface = Qnil;
76
+ VALUE rb_cCairo_DRMSurface = Qnil;
77
+ VALUE rb_cCairo_TeeSurface = Qnil;
78
+ VALUE rb_cCairo_XMLSurface = Qnil;
79
+ VALUE rb_cCairo_SkiaSurface = Qnil;
80
+ VALUE rb_cCairo_SubSurface = Qnil;
65
81
 
66
- static ID cr_id_target;
67
- static ID cr_id_read;
68
- static ID cr_id_write;
69
- static ID cr_id_inspect;
70
82
  static ID cr_id_parse;
71
83
  static ID cr_id_size;
72
84
  static ID cr_id_set_unit;
@@ -135,6 +147,38 @@ cr_surface_get_klass (cairo_surface_t *surface)
135
147
  case CAIRO_SURFACE_TYPE_QUARTZ_IMAGE:
136
148
  klass = rb_cCairo_QuartzImageSurface;
137
149
  break;
150
+ #endif
151
+ #if CAIRO_CHECK_VERSION(1, 10, 0)
152
+ case CAIRO_SURFACE_TYPE_SCRIPT:
153
+ klass = rb_cCairo_ScriptSurface;
154
+ break;
155
+ case CAIRO_SURFACE_TYPE_QT:
156
+ klass = rb_cCairo_QtSurface;
157
+ break;
158
+ case CAIRO_SURFACE_TYPE_RECORDING:
159
+ klass = rb_cCairo_RecordingSurface;
160
+ break;
161
+ case CAIRO_SURFACE_TYPE_VG:
162
+ klass = rb_cCairo_VGSurface;
163
+ break;
164
+ case CAIRO_SURFACE_TYPE_GL:
165
+ klass = rb_cCairo_GLSurface;
166
+ break;
167
+ case CAIRO_SURFACE_TYPE_DRM:
168
+ klass = rb_cCairo_DRMSurface;
169
+ break;
170
+ case CAIRO_SURFACE_TYPE_TEE:
171
+ klass = rb_cCairo_TeeSurface;
172
+ break;
173
+ case CAIRO_SURFACE_TYPE_XML:
174
+ klass = rb_cCairo_XMLSurface;
175
+ break;
176
+ case CAIRO_SURFACE_TYPE_SKIA:
177
+ klass = rb_cCairo_SkiaSurface;
178
+ break;
179
+ case CAIRO_SURFACE_TYPE_SUBSURFACE:
180
+ klass = rb_cCairo_SubSurface;
181
+ break;
138
182
  #endif
139
183
  default:
140
184
  klass = rb_cCairo_Surface;
@@ -147,166 +191,6 @@ cr_surface_get_klass (cairo_surface_t *surface)
147
191
  return klass;
148
192
  }
149
193
 
150
- static char *
151
- inspect (VALUE object)
152
- {
153
- VALUE inspected;
154
- inspected = rb_funcall (object, cr_id_inspect, 0);
155
- return StringValueCStr(inspected);
156
- }
157
-
158
- /* read/write callback */
159
- typedef struct cr_io_callback_closure {
160
- VALUE target;
161
- VALUE error;
162
- unsigned char *data;
163
- unsigned int length;
164
- } cr_io_callback_closure_t;
165
-
166
- typedef struct cr_invoke_data {
167
- cr_callback_func_t func;
168
- VALUE data;
169
- } cr_invoke_data_t;
170
-
171
- #if HAS_CREATE_CR_CLOSURE_SURFACE
172
- static cr_io_callback_closure_t *
173
- cr_closure_new (VALUE target)
174
- {
175
- cr_io_callback_closure_t *closure;
176
- closure = ALLOC (cr_io_callback_closure_t);
177
-
178
- closure->target = target;
179
- closure->error = Qnil;
180
-
181
- return closure;
182
- }
183
-
184
- static void
185
- cr_closure_destroy (cr_io_callback_closure_t *closure)
186
- {
187
- xfree (closure);
188
- }
189
-
190
- static void
191
- cr_closure_free (void *closure)
192
- {
193
- cr_closure_destroy ((cr_io_callback_closure_t *) closure);
194
- }
195
- #endif
196
-
197
- static VALUE
198
- cr_surface_io_func_rescue (VALUE io_closure)
199
- {
200
- cr_io_callback_closure_t *closure;
201
- closure = (cr_io_callback_closure_t *)io_closure;
202
- closure->error = RB_ERRINFO;
203
- return Qnil;
204
- }
205
-
206
- static VALUE
207
- cr_surface_invoke_io_func (VALUE user_data)
208
- {
209
- cr_invoke_data_t *data;
210
-
211
- data = (cr_invoke_data_t *)user_data;
212
- return rb_rescue2 (data->func, data->data,
213
- cr_surface_io_func_rescue, data->data, rb_eException,
214
- (VALUE)0);
215
- }
216
-
217
- /* write callback */
218
- static VALUE
219
- cr_surface_write_func_invoke (VALUE write_closure)
220
- {
221
- VALUE output, data;
222
- long written_bytes;
223
- cr_io_callback_closure_t *closure;
224
- unsigned int length;
225
-
226
- closure = (cr_io_callback_closure_t *)write_closure;
227
-
228
- output = closure->target;
229
- data = rb_str_new ((const char *)closure->data, closure->length);
230
-
231
- length = RSTRING_LEN (data);
232
- while (length != 0)
233
- {
234
- VALUE rb_written_bytes = rb_funcall (output, cr_id_write, 1, data);
235
- written_bytes = NUM2LONG (rb_written_bytes);
236
- data = rb_str_substr (data, written_bytes,
237
- RSTRING_LEN (data) - written_bytes);
238
- length -= written_bytes;
239
- }
240
-
241
- return Qnil;
242
- }
243
-
244
- static cairo_status_t
245
- cr_surface_write_func (void *write_closure,
246
- const unsigned char *data, unsigned int length)
247
- {
248
- cr_io_callback_closure_t *closure;
249
- cr_invoke_data_t invoke_data;
250
-
251
- closure = (cr_io_callback_closure_t *)write_closure;
252
- closure->data = (unsigned char *)data;
253
- closure->length = length;
254
-
255
- invoke_data.func = cr_surface_write_func_invoke;
256
- invoke_data.data = (VALUE)closure;
257
- rb_cairo__invoke_callback (cr_surface_invoke_io_func, (VALUE)&invoke_data);
258
-
259
- if (NIL_P (closure->error))
260
- return CAIRO_STATUS_SUCCESS;
261
- else
262
- return CAIRO_STATUS_WRITE_ERROR;
263
- }
264
-
265
- /* read callback */
266
- static VALUE
267
- cr_surface_read_func_invoke (VALUE read_closure)
268
- {
269
- VALUE input, result;
270
- cr_io_callback_closure_t *closure;
271
- unsigned int length, rest;
272
-
273
- closure = (cr_io_callback_closure_t *)read_closure;
274
- input = closure->target;
275
- length = closure->length;
276
-
277
- result = rb_str_new2 ("");
278
-
279
- for (rest = length; rest != 0; rest = length - RSTRING_LEN (result))
280
- {
281
- rb_str_concat (result, rb_funcall (input, cr_id_read, 1, INT2NUM (rest)));
282
- }
283
-
284
- memcpy ((void *)closure->data, (const void *)StringValuePtr (result), length);
285
-
286
- return Qnil;
287
- }
288
-
289
- static cairo_status_t
290
- cr_surface_read_func (void *read_closure,
291
- unsigned char *data, unsigned int length)
292
- {
293
- cr_io_callback_closure_t *closure;
294
- cr_invoke_data_t invoke_data;
295
-
296
- closure = (cr_io_callback_closure_t *)read_closure;
297
- closure->data = data;
298
- closure->length = length;
299
-
300
- invoke_data.func = cr_surface_read_func_invoke;
301
- invoke_data.data = (VALUE)closure;
302
- rb_cairo__invoke_callback (cr_surface_invoke_io_func, (VALUE)&invoke_data);
303
-
304
- if (NIL_P (closure->error))
305
- return CAIRO_STATUS_SUCCESS;
306
- else
307
- return CAIRO_STATUS_READ_ERROR;
308
- }
309
-
310
194
  /* constructor/de-constructor */
311
195
  cairo_surface_t *
312
196
  rb_cairo_surface_from_ruby_object (VALUE obj)
@@ -394,7 +278,7 @@ static VALUE
394
278
  cr_surface_finish (VALUE self)
395
279
  {
396
280
  cairo_surface_t *surface;
397
- cr_io_callback_closure_t *closure;
281
+ rb_cairo__io_callback_closure_t *closure;
398
282
 
399
283
  surface = _SELF;
400
284
  closure = cairo_surface_get_user_data (surface, &cr_closure_key);
@@ -423,17 +307,72 @@ yield_and_finish (VALUE self)
423
307
  }
424
308
 
425
309
  static VALUE
426
- cr_surface_create_similar (VALUE self, VALUE content, VALUE width, VALUE height)
310
+ cr_surface_create_similar (int argc, VALUE *argv, VALUE self)
311
+ {
312
+ cairo_surface_t *surface, *similar_surface;
313
+ cairo_content_t content;
314
+ int width, height;
315
+ VALUE arg1, arg2, arg3;
316
+
317
+ rb_scan_args (argc, argv, "21", &arg1, &arg2, &arg3);
318
+
319
+ surface = _SELF;
320
+ if (argc == 2)
321
+ {
322
+ content = cairo_surface_get_content (surface);
323
+ width = NUM2INT (arg1);
324
+ height = NUM2INT (arg2);
325
+ }
326
+ else
327
+ {
328
+ content = RVAL2CRCONTENT (arg1);
329
+ width = NUM2INT (arg2);
330
+ height = NUM2INT (arg3);
331
+ }
332
+
333
+ similar_surface = cairo_surface_create_similar (surface, content,
334
+ width, height);
335
+ cr_surface_check_status (similar_surface);
336
+ return CRSURFACE2RVAL_WITH_DESTROY (similar_surface);
337
+ }
338
+
339
+ #if CAIRO_CHECK_VERSION(1, 10, 0)
340
+ static VALUE
341
+ cr_surface_destroy_with_destroy_check (VALUE self)
342
+ {
343
+ if (DATA_PTR (self))
344
+ cr_surface_destroy (self);
345
+ return Qnil;
346
+ }
347
+
348
+ static VALUE
349
+ cr_surface_create_sub_rectangle_surface (VALUE self, VALUE x, VALUE y,
350
+ VALUE width, VALUE height)
427
351
  {
352
+ VALUE rb_surface;
428
353
  cairo_surface_t *surface;
429
354
 
430
- surface = cairo_surface_create_similar (RVAL2CRSURFACE (self),
431
- RVAL2CRCONTENT (content),
432
- NUM2INT (width), NUM2INT (height));
355
+ surface = cairo_surface_create_for_rectangle (RVAL2CRSURFACE (self),
356
+ NUM2DBL (x),
357
+ NUM2DBL (y),
358
+ NUM2DBL (width),
359
+ NUM2INT (height));
433
360
  cr_surface_check_status (surface);
434
- return CRSURFACE2RVAL_WITH_DESTROY (surface);
361
+ rb_surface = CRSURFACE2RVAL_WITH_DESTROY (surface);
362
+ if (rb_block_given_p ())
363
+ return rb_ensure (rb_yield, rb_surface,
364
+ cr_surface_destroy_with_destroy_check, rb_surface);
365
+ else
366
+ return rb_surface;
435
367
  }
436
368
 
369
+ static VALUE
370
+ cr_surface_get_device (VALUE self)
371
+ {
372
+ return CRDEVICE2RVAL (cairo_surface_get_device (_SELF));
373
+ }
374
+ #endif
375
+
437
376
  static VALUE
438
377
  cr_surface_get_content (VALUE self)
439
378
  {
@@ -446,12 +385,13 @@ static VALUE
446
385
  cr_surface_write_to_png_stream (VALUE self, VALUE target)
447
386
  {
448
387
  cairo_status_t status;
449
- cr_io_callback_closure_t closure;
388
+ rb_cairo__io_callback_closure_t closure;
450
389
 
451
390
  closure.target = target;
452
391
  closure.error = Qnil;
453
392
 
454
- status = cairo_surface_write_to_png_stream (_SELF, cr_surface_write_func,
393
+ status = cairo_surface_write_to_png_stream (_SELF,
394
+ rb_cairo__io_write_func,
455
395
  (void *)&closure);
456
396
  if (!NIL_P (closure.error))
457
397
  rb_exc_raise (closure.error);
@@ -472,13 +412,63 @@ cr_surface_write_to_png (VALUE self, VALUE filename)
472
412
  static VALUE
473
413
  cr_surface_write_to_png_generic (VALUE self, VALUE target)
474
414
  {
475
- if (rb_respond_to (target, cr_id_write))
415
+ if (rb_respond_to (target, rb_cairo__io_id_write))
476
416
  return cr_surface_write_to_png_stream (self, target);
477
417
  else
478
418
  return cr_surface_write_to_png (self, target);
479
419
  }
480
420
  #endif
481
421
 
422
+ #if CAIRO_CHECK_VERSION(1, 10, 0)
423
+ static VALUE
424
+ cr_surface_get_mime_data (VALUE self, VALUE mime_type)
425
+ {
426
+ cairo_surface_t *surface;
427
+ const unsigned char *data;
428
+ unsigned long length;
429
+
430
+ surface = _SELF;
431
+ cairo_surface_get_mime_data (surface, StringValueCStr (mime_type),
432
+ &data, &length);
433
+ if (data)
434
+ return rb_str_new ((const char *)data, length);
435
+ else
436
+ return Qnil;
437
+ }
438
+
439
+ static VALUE
440
+ cr_surface_set_mime_data (VALUE self, VALUE rb_mime_type, VALUE rb_data)
441
+ {
442
+ cairo_status_t status;
443
+ cairo_surface_t *surface;
444
+ const char *mime_type;
445
+
446
+ surface = _SELF;
447
+ mime_type = StringValueCStr (rb_mime_type);
448
+ if (NIL_P (rb_data))
449
+ {
450
+ status = cairo_surface_set_mime_data (surface, mime_type,
451
+ NULL, 0, NULL, NULL);
452
+ }
453
+ else
454
+ {
455
+ const char *raw_data;
456
+ unsigned char *data;
457
+ unsigned long length;
458
+
459
+ raw_data = StringValuePtr (rb_data);
460
+ length = RSTRING_LEN (rb_data);
461
+ data = xmalloc (length);
462
+ memcpy (data, raw_data, length);
463
+ status = cairo_surface_set_mime_data (surface, mime_type,
464
+ data, length,
465
+ xfree, data);
466
+ }
467
+ rb_cairo_check_status (status);
468
+ return Qnil;
469
+ }
470
+ #endif
471
+
482
472
  static VALUE
483
473
  cr_surface_get_font_options (VALUE self)
484
474
  {
@@ -528,7 +518,7 @@ cr_surface_mark_dirty (int argc, VALUE *argv, VALUE self)
528
518
 
529
519
  rb_raise (rb_eArgError,
530
520
  "invalid argument (expect () or (x, y, width, height)): %s",
531
- inspect (args));
521
+ rb_cairo__inspect (args));
532
522
  }
533
523
 
534
524
  cr_surface_check_status (_SELF);
@@ -607,17 +597,17 @@ cr_surface_show_page (VALUE self)
607
597
  static cairo_surface_t *
608
598
  cr_image_surface_create_from_png_stream (VALUE target)
609
599
  {
610
- cr_io_callback_closure_t closure;
600
+ rb_cairo__io_callback_closure_t closure;
611
601
  cairo_surface_t *surface;
612
602
 
613
603
  closure.target = target;
614
604
  closure.error = Qnil;
615
605
 
616
- surface = cairo_image_surface_create_from_png_stream (cr_surface_read_func,
606
+ surface = cairo_image_surface_create_from_png_stream (rb_cairo__io_read_func,
617
607
  (void *)&closure);
618
608
  if (!NIL_P (closure.error))
619
609
  rb_exc_raise (closure.error);
620
-
610
+
621
611
  return surface;
622
612
  }
623
613
 
@@ -633,7 +623,7 @@ cr_image_surface_create_from_png_generic (VALUE klass, VALUE target)
633
623
  VALUE rb_surface;
634
624
  cairo_surface_t *surface;
635
625
 
636
- if (rb_respond_to (target, cr_id_read))
626
+ if (rb_respond_to (target, rb_cairo__io_id_read))
637
627
  surface = cr_image_surface_create_from_png_stream (target);
638
628
  else
639
629
  surface = cr_image_surface_create_from_png (target);
@@ -692,7 +682,7 @@ cr_image_surface_initialize (int argc, VALUE *argv, VALUE self)
692
682
  "(width, height) or "
693
683
  "(format, width, height) or "
694
684
  "(data, format, width, height, stride)): %s",
695
- inspect (rb_ary_new3 (4, arg1, arg2, arg3, arg4)));
685
+ rb_cairo__inspect (rb_ary_new3 (4, arg1, arg2, arg3, arg4)));
696
686
 
697
687
  cr_surface_check_status (surface);
698
688
  DATA_PTR (self) = surface;
@@ -742,6 +732,74 @@ cr_image_surface_get_stride (VALUE self)
742
732
  return INT2NUM (cairo_image_surface_get_stride (_SELF));
743
733
  }
744
734
 
735
+ #ifdef CAIRO_HAS_RECORDING_SURFACE
736
+ /* Recording-surface functions */
737
+ static VALUE
738
+ cr_recording_surface_initialize (int argc, VALUE *argv, VALUE self)
739
+ {
740
+ VALUE arg1, arg2, arg3, arg4, arg5;
741
+ cairo_surface_t *surface;
742
+ cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
743
+ cairo_rectangle_t extents;
744
+ const char *error_message =
745
+ "invalid argument (expect "
746
+ "(x, y, width, height), "
747
+ "([x, y, width, height]),"
748
+ "(x, y, width, height, content) or "
749
+ "([x, y, width, height], content)): %s";
750
+
751
+ rb_scan_args (argc, argv, "14", &arg1, &arg2, &arg3, &arg4, &arg5);
752
+ if (argc == 1 || argc == 2)
753
+ {
754
+ VALUE rb_extents;
755
+
756
+ rb_extents = rb_check_array_type (arg1);
757
+ if (RARRAY_LEN (rb_extents) != 4)
758
+ rb_raise (rb_eArgError, error_message, rb_cairo__inspect (arg1));
759
+ extents.x = NUM2DBL (RARRAY_PTR (rb_extents)[0]);
760
+ extents.y = NUM2DBL (RARRAY_PTR (rb_extents)[1]);
761
+ extents.width = NUM2DBL (RARRAY_PTR (rb_extents)[2]);
762
+ extents.height = NUM2DBL (RARRAY_PTR (rb_extents)[3]);
763
+ if (!NIL_P (arg2))
764
+ content = RVAL2CRCONTENT (arg2);
765
+ }
766
+ else if (argc == 4 || argc == 5)
767
+ {
768
+ extents.x = NUM2DBL (arg1);
769
+ extents.y = NUM2DBL (arg2);
770
+ extents.width = NUM2DBL (arg3);
771
+ extents.height = NUM2DBL (arg4);
772
+ if (!NIL_P (arg5))
773
+ content = RVAL2CRCONTENT (arg5);
774
+ }
775
+ else
776
+ {
777
+ rb_raise (rb_eArgError, error_message,
778
+ rb_cairo__inspect (rb_ary_new4 (argc, argv)));
779
+ }
780
+
781
+ surface = cairo_recording_surface_create (content, &extents);
782
+ cr_surface_check_status (surface);
783
+ DATA_PTR (self) = surface;
784
+ if (rb_block_given_p ())
785
+ yield_and_finish (self);
786
+ return Qnil;
787
+ }
788
+
789
+ static VALUE
790
+ cr_recording_surface_get_ink_extents (VALUE self)
791
+ {
792
+ cairo_surface_t *surface;
793
+ double x, y, width, height;
794
+
795
+ surface = _SELF;
796
+ cairo_recording_surface_ink_extents (surface, &x, &y, &width, &height);
797
+ cr_surface_check_status (surface);
798
+ return rb_ary_new3 (4,
799
+ rb_float_new (x), rb_float_new (y),
800
+ rb_float_new (width), rb_float_new (height));
801
+ }
802
+ #endif
745
803
 
746
804
  /* Printing surfaces */
747
805
  #define DEFINE_SURFACE(type) \
@@ -772,29 +830,30 @@ cr_ ## type ## _surface_initialize (int argc, VALUE *argv, VALUE self) \
772
830
  width_in_points = NUM2DBL (rb_width_in_points); \
773
831
  height_in_points = NUM2DBL (rb_height_in_points); \
774
832
  \
775
- if (rb_respond_to (target, cr_id_write)) \
833
+ if (rb_respond_to (target, rb_cairo__io_id_write)) \
776
834
  { \
777
- cr_io_callback_closure_t *closure; \
835
+ rb_cairo__io_callback_closure_t *closure; \
778
836
  \
779
- closure = cr_closure_new (target); \
837
+ closure = rb_cairo__io_closure_new (target); \
780
838
  surface = \
781
839
  cairo_ ## type ## _surface_create_for_stream ( \
782
- cr_surface_write_func, \
840
+ rb_cairo__io_write_func, \
783
841
  (void *) closure, \
784
842
  width_in_points, \
785
843
  height_in_points); \
786
844
  \
787
845
  if (cairo_surface_status (surface)) \
788
846
  { \
789
- cr_closure_destroy (closure); \
847
+ rb_cairo__io_closure_destroy (closure); \
790
848
  } \
791
849
  else \
792
850
  { \
793
- rb_ivar_set (self, cr_id_target, target); \
851
+ rb_ivar_set (self, rb_cairo__io_id_output, target); \
794
852
  cairo_surface_set_user_data (surface, &cr_closure_key, \
795
- closure, cr_closure_free); \
853
+ closure, \
854
+ rb_cairo__io_closure_free); \
796
855
  cairo_surface_set_user_data (surface, &cr_object_holder_key, \
797
- cr_object_holder_new(self), \
856
+ cr_object_holder_new (self), \
798
857
  cr_object_holder_free); \
799
858
  } \
800
859
  } \
@@ -907,6 +966,16 @@ cr_ps_surface_set_eps (VALUE self, VALUE eps)
907
966
  /* PDF-surface functions */
908
967
  DEFINE_SURFACE(pdf)
909
968
  DEFINE_SURFACE_SET_SIZE(pdf)
969
+
970
+ # if CAIRO_CHECK_VERSION(1, 10, 0)
971
+ static VALUE
972
+ cr_pdf_surface_restrict_to_version (VALUE self, VALUE version)
973
+ {
974
+ cairo_pdf_surface_restrict_to_version (_SELF, RVAL2CRPDFVERSION (version));
975
+ cr_surface_check_status (_SELF);
976
+ return Qnil;
977
+ }
978
+ # endif
910
979
  #endif
911
980
 
912
981
  #ifdef CAIRO_HAS_SVG_SURFACE
@@ -1111,7 +1180,7 @@ cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
1111
1180
  "(width, height), "
1112
1181
  "(format, width, height) or "
1113
1182
  "(cg_context, width, height)): %s",
1114
- inspect (rb_ary_new3 (3, arg1, arg2, arg3)));
1183
+ rb_cairo__inspect (rb_ary_new3 (3, arg1, arg2, arg3)));
1115
1184
  break;
1116
1185
  }
1117
1186
 
@@ -1179,6 +1248,321 @@ cr_quartz_image_surface_get_image (VALUE self)
1179
1248
  # endif
1180
1249
  #endif
1181
1250
 
1251
+ #ifdef CAIRO_HAS_SCRIPT_SURFACE
1252
+ static VALUE
1253
+ cr_script_surface_initialize (int argc, VALUE *argv, VALUE self)
1254
+ {
1255
+ cairo_surface_t *surface = NULL, *target = NULL;
1256
+ cairo_device_t *device;
1257
+ double width = 0.0, height = 0.0;
1258
+ cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
1259
+ VALUE arg1, arg2, arg3, arg4;
1260
+
1261
+ rb_scan_args (argc, argv, "22", &arg1, &arg2, &arg3, &arg4);
1262
+
1263
+ device = RVAL2CRDEVICE (arg1);
1264
+ if (argc == 2)
1265
+ {
1266
+ target = RVAL2CRSURFACE (arg2);
1267
+ }
1268
+ else
1269
+ {
1270
+ width = NUM2DBL (arg2);
1271
+ height = NUM2DBL (arg3);
1272
+ switch (TYPE (arg4))
1273
+ {
1274
+ case T_NIL:
1275
+ break;
1276
+ case T_STRING:
1277
+ case T_SYMBOL:
1278
+ case T_FIXNUM:
1279
+ content = RVAL2CRCONTENT (arg4);
1280
+ break;
1281
+ default:
1282
+ rb_raise (rb_eArgError,
1283
+ "invalid argument (expect "
1284
+ "(device, width, height), "
1285
+ "(device, width, height, content) or "
1286
+ "(device, surface)): %s",
1287
+ rb_cairo__inspect (rb_ary_new4 (argc, argv)));
1288
+ break;
1289
+ }
1290
+ }
1291
+
1292
+ if (target)
1293
+ surface = cairo_script_surface_create_for_target (device, target);
1294
+ else
1295
+ surface = cairo_script_surface_create (device, content, width, height);
1296
+
1297
+ cr_surface_check_status (surface);
1298
+ DATA_PTR (self) = surface;
1299
+ if (rb_block_given_p ())
1300
+ yield_and_finish (self);
1301
+ return Qnil;
1302
+ }
1303
+ #endif
1304
+
1305
+ #ifdef CAIRO_HAS_XML_SURFACE
1306
+ static VALUE
1307
+ cr_xml_surface_initialize (int argc, VALUE *argv, VALUE self)
1308
+ {
1309
+ cairo_surface_t *surface;
1310
+ cairo_device_t *device;
1311
+ double width, height;
1312
+ cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
1313
+ VALUE rb_device, rb_width, rb_height, rb_content;
1314
+
1315
+ rb_scan_args (argc, argv, "31",
1316
+ &rb_device, &rb_width, &rb_height, &rb_content);
1317
+
1318
+ device = RVAL2CRDEVICE (rb_device);
1319
+ width = NUM2DBL (rb_width);
1320
+ height = NUM2DBL (rb_height);
1321
+ switch (TYPE (rb_content))
1322
+ {
1323
+ case T_NIL:
1324
+ break;
1325
+ case T_STRING:
1326
+ case T_SYMBOL:
1327
+ case T_FIXNUM:
1328
+ content = RVAL2CRCONTENT (rb_content);
1329
+ break;
1330
+ default:
1331
+ rb_raise (rb_eArgError,
1332
+ "invalid argument (expect "
1333
+ "(device, width, height) or "
1334
+ "(device, width, height, content)): %s",
1335
+ rb_cairo__inspect (rb_ary_new4 (argc, argv)));
1336
+ break;
1337
+ }
1338
+
1339
+ surface = cairo_xml_surface_create (device, content, width, height);
1340
+
1341
+ cr_surface_check_status (surface);
1342
+ DATA_PTR (self) = surface;
1343
+ if (rb_block_given_p ())
1344
+ yield_and_finish (self);
1345
+ return Qnil;
1346
+ }
1347
+ #endif
1348
+
1349
+ #ifdef CAIRO_HAS_TEE_SURFACE
1350
+ static VALUE
1351
+ cr_tee_surface_initialize (VALUE self, VALUE master)
1352
+ {
1353
+ cairo_surface_t *surface = NULL;
1354
+
1355
+ surface = cairo_tee_surface_create (RVAL2CRSURFACE (master));
1356
+ cr_surface_check_status (surface);
1357
+ DATA_PTR (self) = surface;
1358
+ rb_iv_set (self, "surfaces", rb_ary_new3 (1, master));
1359
+ if (rb_block_given_p ())
1360
+ yield_and_finish (self);
1361
+ return Qnil;
1362
+ }
1363
+
1364
+ static VALUE
1365
+ cr_tee_surface_add (VALUE self, VALUE target)
1366
+ {
1367
+ cairo_surface_t *surface = NULL;
1368
+
1369
+ surface = _SELF;
1370
+ cairo_tee_surface_add (surface, RVAL2CRSURFACE (target));
1371
+ cr_surface_check_status (surface);
1372
+ rb_ary_push (rb_iv_get (self, "surfaces"), target);
1373
+ return Qnil;
1374
+ }
1375
+
1376
+ static VALUE
1377
+ cr_tee_surface_shift_operator (VALUE self, VALUE target)
1378
+ {
1379
+ cr_tee_surface_add (self, target);
1380
+ return self;
1381
+ }
1382
+
1383
+ static VALUE
1384
+ cr_tee_surface_remove (VALUE self, VALUE target_or_index)
1385
+ {
1386
+ cairo_surface_t *surface = NULL, *target;
1387
+ VALUE rb_surfaces;
1388
+ int i;
1389
+
1390
+ surface = _SELF;
1391
+ if (rb_cairo__is_kind_of (target_or_index, rb_cCairo_Surface))
1392
+ {
1393
+ target = RVAL2CRSURFACE (target_or_index);
1394
+ }
1395
+ else
1396
+ {
1397
+ VALUE index;
1398
+
1399
+ index = rb_check_to_integer (target_or_index, "to_int");
1400
+ if (NIL_P (index))
1401
+ rb_raise (rb_eArgError,
1402
+ "invalid argument (expect (surface) or (index)): %s",
1403
+ rb_cairo__inspect (target_or_index));
1404
+ target = cairo_tee_surface_index (surface, NUM2INT (index));
1405
+ }
1406
+ cairo_tee_surface_remove (surface, target);
1407
+ cr_surface_check_status (surface);
1408
+
1409
+ rb_surfaces = rb_iv_get (self, "surfaces");
1410
+ for (i = 0; i < RARRAY_LEN (rb_surfaces); i++)
1411
+ {
1412
+ VALUE rb_marked_surface;
1413
+ cairo_surface_t *marked_surface;
1414
+
1415
+ rb_marked_surface = RARRAY_PTR (rb_surfaces)[i];
1416
+ marked_surface = RVAL2CRSURFACE (rb_marked_surface);
1417
+ if (marked_surface == target)
1418
+ {
1419
+ rb_ary_delete (rb_surfaces, rb_marked_surface);
1420
+ break;
1421
+ }
1422
+ }
1423
+
1424
+ return Qnil;
1425
+ }
1426
+
1427
+ static VALUE
1428
+ cr_tee_surface_array_reference (VALUE self, VALUE index)
1429
+ {
1430
+ cairo_surface_t *surface = NULL, *target;
1431
+
1432
+ surface = _SELF;
1433
+ index = rb_Integer (index);
1434
+ target = cairo_tee_surface_index (surface, NUM2INT (index));
1435
+ cr_surface_check_status (surface);
1436
+ cr_surface_check_status (target);
1437
+ return CRSURFACE2RVAL (target);
1438
+ }
1439
+ #endif
1440
+
1441
+ #ifdef CAIRO_HAS_GL_SURFACE
1442
+ static VALUE
1443
+ cr_gl_surface_initialize (int argc, VALUE *argv, VALUE self)
1444
+ {
1445
+ cairo_surface_t *surface;
1446
+ cairo_device_t *device;
1447
+ int width, height;
1448
+ cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
1449
+ VALUE rb_device, rb_width, rb_height, rb_content;
1450
+
1451
+ rb_scan_args (argc, argv, "31",
1452
+ &rb_device, &rb_width, &rb_height, &rb_content);
1453
+
1454
+ device = RVAL2CRDEVICE (rb_device);
1455
+ width = NUM2INT (rb_width);
1456
+ height = NUM2INT (rb_height);
1457
+ switch (TYPE (rb_content))
1458
+ {
1459
+ case T_NIL:
1460
+ break;
1461
+ case T_STRING:
1462
+ case T_SYMBOL:
1463
+ case T_FIXNUM:
1464
+ content = RVAL2CRCONTENT (rb_content);
1465
+ break;
1466
+ default:
1467
+ rb_raise (rb_eArgError,
1468
+ "invalid argument (expect "
1469
+ "(device, width, height) or "
1470
+ "(device, width, height, content)): %s",
1471
+ rb_cairo__inspect (rb_ary_new4 (argc, argv)));
1472
+ break;
1473
+ }
1474
+
1475
+ surface = cairo_gl_surface_create (device, content, width, height);
1476
+
1477
+ cr_surface_check_status (surface);
1478
+ DATA_PTR (self) = surface;
1479
+ if (rb_block_given_p ())
1480
+ yield_and_finish (self);
1481
+ return Qnil;
1482
+ }
1483
+
1484
+ static VALUE
1485
+ cr_gl_texture_surface_initialize (int argc, VALUE *argv, VALUE self)
1486
+ {
1487
+ cairo_surface_t *surface;
1488
+ cairo_device_t *device;
1489
+ unsigned int texture;
1490
+ int width, height;
1491
+ cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
1492
+ VALUE rb_device, rb_texture, rb_width, rb_height, rb_content;
1493
+
1494
+ rb_scan_args (argc, argv, "41",
1495
+ &rb_device, &rb_texture, &rb_width, &rb_height, &rb_content);
1496
+
1497
+ device = RVAL2CRDEVICE (rb_device);
1498
+ texture = NUM2UINT (rb_texture);
1499
+ width = NUM2INT (rb_width);
1500
+ height = NUM2INT (rb_height);
1501
+ switch (TYPE (rb_content))
1502
+ {
1503
+ case T_NIL:
1504
+ break;
1505
+ case T_STRING:
1506
+ case T_SYMBOL:
1507
+ case T_FIXNUM:
1508
+ content = RVAL2CRCONTENT (rb_content);
1509
+ break;
1510
+ default:
1511
+ rb_raise (rb_eArgError,
1512
+ "invalid argument (expect "
1513
+ "(device, texture, width, height) or "
1514
+ "(device, texture, width, height, content)): %s",
1515
+ rb_cairo__inspect (rb_ary_new4 (argc, argv)));
1516
+ break;
1517
+ }
1518
+
1519
+ surface = cairo_gl_surface_create_for_texture (device, content,
1520
+ texture,
1521
+ width,
1522
+ height);
1523
+
1524
+ cr_surface_check_status (surface);
1525
+ DATA_PTR (self) = surface;
1526
+ if (rb_block_given_p ())
1527
+ yield_and_finish (self);
1528
+ return Qnil;
1529
+ }
1530
+
1531
+ static VALUE
1532
+ cr_gl_surface_set_size (VALUE self, VALUE width, VALUE height)
1533
+ {
1534
+ cairo_surface_t *surface = NULL;
1535
+
1536
+ surface = _SELF;
1537
+ cairo_gl_surface_set_size (surface, NUM2INT (width), NUM2INT (height));
1538
+ cr_surface_check_status (surface);
1539
+ return Qnil;
1540
+ }
1541
+
1542
+ static VALUE
1543
+ cr_gl_surface_get_width (VALUE self)
1544
+ {
1545
+ return INT2NUM (cairo_gl_surface_get_width (_SELF));
1546
+ }
1547
+
1548
+ static VALUE
1549
+ cr_gl_surface_get_height (VALUE self)
1550
+ {
1551
+ return INT2NUM (cairo_gl_surface_get_height (_SELF));
1552
+ }
1553
+
1554
+ static VALUE
1555
+ cr_gl_surface_swap_buffers (VALUE self)
1556
+ {
1557
+ cairo_surface_t *surface = NULL;
1558
+
1559
+ surface = _SELF;
1560
+ cairo_gl_surface_swapbuffers (surface);
1561
+ cr_surface_check_status (surface);
1562
+ return Qnil;
1563
+ }
1564
+ #endif
1565
+
1182
1566
  static int
1183
1567
  cr_finish_all_guarded_surfaces_at_end_iter (VALUE key, VALUE value, VALUE data)
1184
1568
  {
@@ -1197,10 +1581,6 @@ cr_finish_all_guarded_surfaces_at_end (VALUE data)
1197
1581
  void
1198
1582
  Init_cairo_surface (void)
1199
1583
  {
1200
- cr_id_target = rb_intern ("target");
1201
- cr_id_read = rb_intern ("read");
1202
- cr_id_write = rb_intern ("write");
1203
- cr_id_inspect = rb_intern ("inspect");
1204
1584
  cr_id_parse = rb_intern ("parse");
1205
1585
  cr_id_size = rb_intern ("size");
1206
1586
  cr_id_set_unit = rb_intern ("unit=");
@@ -1214,11 +1594,24 @@ Init_cairo_surface (void)
1214
1594
 
1215
1595
 
1216
1596
  rb_define_method (rb_cCairo_Surface, "create_similar",
1217
- cr_surface_create_similar, 3);
1597
+ cr_surface_create_similar, -1);
1598
+ #if CAIRO_CHECK_VERSION(1, 10, 0)
1599
+ rb_define_method (rb_cCairo_Surface, "sub_rectangle_surface",
1600
+ cr_surface_create_sub_rectangle_surface, 4);
1601
+ rb_define_method (rb_cCairo_Surface, "device",
1602
+ cr_surface_get_device, 0);
1603
+ #endif
1218
1604
  rb_define_method (rb_cCairo_Surface, "destroy", cr_surface_destroy, 0);
1219
1605
  rb_define_method (rb_cCairo_Surface, "finish", cr_surface_finish, 0);
1220
1606
  rb_define_method (rb_cCairo_Surface, "content", cr_surface_get_content, 0);
1221
1607
 
1608
+ #if CAIRO_CHECK_VERSION(1, 10, 0)
1609
+ rb_define_method (rb_cCairo_Surface, "get_mime_data",
1610
+ cr_surface_get_mime_data, 1);
1611
+ rb_define_method (rb_cCairo_Surface, "set_mime_data",
1612
+ cr_surface_set_mime_data, 2);
1613
+ #endif
1614
+
1222
1615
  rb_define_method (rb_cCairo_Surface, "font_options",
1223
1616
  cr_surface_get_font_options, 0);
1224
1617
  rb_define_method (rb_cCairo_Surface, "flush", cr_surface_flush, 0);
@@ -1270,6 +1663,18 @@ Init_cairo_surface (void)
1270
1663
  rb_define_method (rb_cCairo_ImageSurface, "stride",
1271
1664
  cr_image_surface_get_stride, 0);
1272
1665
 
1666
+ #ifdef CAIRO_HAS_RECORDING_SURFACE
1667
+ /* Recording-surface */
1668
+ rb_cCairo_RecordingSurface =
1669
+ rb_define_class_under (rb_mCairo, "RecordingSurface", rb_cCairo_Surface);
1670
+
1671
+ rb_define_method (rb_cCairo_RecordingSurface, "initialize",
1672
+ cr_recording_surface_initialize, -1);
1673
+
1674
+ rb_define_method (rb_cCairo_RecordingSurface, "ink_extents",
1675
+ cr_recording_surface_get_ink_extents, 0);
1676
+ #endif
1677
+
1273
1678
  #define INIT_SURFACE(type, name) \
1274
1679
  rb_cCairo_ ## name ## Surface = \
1275
1680
  rb_define_class_under (rb_mCairo, # name "Surface", \
@@ -1307,6 +1712,11 @@ Init_cairo_surface (void)
1307
1712
  rb_define_method (rb_cCairo_PDFSurface, "set_size",
1308
1713
  cr_pdf_surface_set_size, -1);
1309
1714
 
1715
+ # if CAIRO_CHECK_VERSION(1, 10, 0)
1716
+ rb_define_method (rb_cCairo_PDFSurface, "restrict_to_version",
1717
+ cr_pdf_surface_restrict_to_version, 1);
1718
+ # endif
1719
+
1310
1720
  RB_CAIRO_DEF_SETTERS (rb_cCairo_PDFSurface);
1311
1721
  #endif
1312
1722
 
@@ -1366,6 +1776,71 @@ Init_cairo_surface (void)
1366
1776
  rb_define_method (rb_cCairo_QuartzImageSurface, "image",
1367
1777
  cr_quartz_image_surface_get_image, 0);
1368
1778
  # endif
1779
+ #endif
1780
+
1781
+ #ifdef CAIRO_HAS_SCRIPT_SURFACE
1782
+ rb_cCairo_ScriptSurface =
1783
+ rb_define_class_under (rb_mCairo, "ScriptSurface", rb_cCairo_Surface);
1784
+
1785
+ rb_define_method (rb_cCairo_ScriptSurface, "initialize",
1786
+ cr_script_surface_initialize, -1);
1787
+
1788
+ RB_CAIRO_DEF_SETTERS (rb_cCairo_ScriptSurface);
1789
+ #endif
1790
+
1791
+ #ifdef CAIRO_HAS_XML_SURFACE
1792
+ rb_cCairo_XMLSurface =
1793
+ rb_define_class_under (rb_mCairo, "XMLSurface", rb_cCairo_Surface);
1794
+
1795
+ rb_define_method (rb_cCairo_XMLSurface, "initialize",
1796
+ cr_xml_surface_initialize, -1);
1797
+
1798
+ RB_CAIRO_DEF_SETTERS (rb_cCairo_XMLSurface);
1799
+ #endif
1800
+
1801
+ #ifdef CAIRO_HAS_TEE_SURFACE
1802
+ rb_cCairo_TeeSurface =
1803
+ rb_define_class_under (rb_mCairo, "TeeSurface", rb_cCairo_Surface);
1804
+
1805
+ rb_define_method (rb_cCairo_TeeSurface, "initialize",
1806
+ cr_tee_surface_initialize, 1);
1807
+
1808
+ rb_define_method (rb_cCairo_TeeSurface, "add",
1809
+ cr_tee_surface_add, 1);
1810
+ rb_define_method (rb_cCairo_TeeSurface, "<<",
1811
+ cr_tee_surface_shift_operator, 1);
1812
+ rb_define_method (rb_cCairo_TeeSurface, "remove",
1813
+ cr_tee_surface_remove, 1);
1814
+ rb_define_method (rb_cCairo_TeeSurface, "[]",
1815
+ cr_tee_surface_array_reference, 1);
1816
+
1817
+ RB_CAIRO_DEF_SETTERS (rb_cCairo_TeeSurface);
1818
+ #endif
1819
+
1820
+ #ifdef CAIRO_HAS_GL_SURFACE
1821
+ rb_cCairo_GLSurface =
1822
+ rb_define_class_under (rb_mCairo, "GLSurface", rb_cCairo_Surface);
1823
+
1824
+ rb_define_method (rb_cCairo_GLSurface, "initialize",
1825
+ cr_gl_surface_initialize, 1);
1826
+
1827
+ rb_define_method (rb_cCairo_GLSurface, "set_size",
1828
+ cr_gl_surface_set_size, 2);
1829
+ rb_define_method (rb_cCairo_GLSurface, "width",
1830
+ cr_gl_surface_get_width, 0);
1831
+ rb_define_method (rb_cCairo_GLSurface, "height",
1832
+ cr_gl_surface_get_height, 0);
1833
+ rb_define_method (rb_cCairo_GLSurface, "swap_buffers",
1834
+ cr_gl_surface_swap_buffers, 0);
1835
+
1836
+ RB_CAIRO_DEF_SETTERS (rb_cCairo_GLSurface);
1837
+
1838
+ rb_cCairo_GLTextureSurface =
1839
+ rb_define_class_under (rb_mCairo, "GLTextureSurface", rb_cCairo_GLSurface);
1840
+
1841
+ rb_define_method (rb_cCairo_GLTextureSurface, "initialize",
1842
+ cr_gl_texture_surface_initialize, 1);
1369
1843
 
1844
+ RB_CAIRO_DEF_SETTERS (rb_cCairo_GLTextureSurface);
1370
1845
  #endif
1371
1846
  }