cairo 1.6.2 → 1.6.3
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/ChangeLog +45 -0
- data/NEWS +10 -0
- data/README +5 -1
- data/Rakefile +1 -0
- data/pkg-config.rb +51 -30
- data/src/rb_cairo.c +2 -2
- data/src/rb_cairo.h +8 -8
- data/src/rb_cairo_constants.c +16 -10
- data/src/rb_cairo_surface.c +123 -50
- data/test/test_surface.rb +28 -0
- metadata +3 -2
data/ChangeLog
CHANGED
@@ -1,5 +1,50 @@
|
|
1
|
+
2008-07-19 Kouhei Sutou <kou@cozmixng.org>
|
2
|
+
|
3
|
+
* NEWS: add a new entry for 1.6.3.
|
4
|
+
|
5
|
+
* src/rb_cairo.c: 1.7.0 -> 1.6.3.
|
6
|
+
|
7
|
+
2008-06-20 Kouhei Sutou <kou@cozmixng.org>
|
8
|
+
|
9
|
+
* README: update OBATA Akio's entry.
|
10
|
+
|
11
|
+
* src/depend (install-so): use INSTALL_DATA and RUBYARCHDIR.
|
12
|
+
Suggested by OBATA Akio. Thanks!!!
|
13
|
+
|
14
|
+
* pkg-config.rb: add libdata.
|
15
|
+
|
16
|
+
* pkg-config.rb:
|
17
|
+
- add /opt/local/lib/pkgconfig as default path.
|
18
|
+
- improve default path guess.
|
19
|
+
Suggested by Carsten Bormann. Thanks!!!
|
20
|
+
|
21
|
+
* README: add Carsten Bormann to thanks list. Thanks!!!
|
22
|
+
|
23
|
+
* test/test_surface.rb: add.
|
24
|
+
|
25
|
+
* src/rb_cairo_surface.c (yield_and_finish): don't finish if it
|
26
|
+
isn't needed.
|
27
|
+
|
28
|
+
* src/rb_cairo_surface.c: finish all guarded surfaces at end.
|
29
|
+
|
30
|
+
2008-06-19 Kouhei Sutou <kou@cozmixng.org>
|
31
|
+
|
32
|
+
* src/: use #ifdef for CAIRO_HAS_*.
|
33
|
+
|
34
|
+
* src/rb_cairo_surface.c: guard custom write surfaces from GC to
|
35
|
+
avoid writing in GC.
|
36
|
+
Reported by James Healy. Thanks!!!
|
37
|
+
|
38
|
+
* README: add James Healy to Thanks list.
|
39
|
+
|
40
|
+
* pkg-config.rb (PackageConfig#guess_default_path): add
|
41
|
+
/usr/share/pkgconfig to default path.
|
42
|
+
Suggested by James Healy. Thanks!!!
|
43
|
+
|
1
44
|
2008-06-14 Kouhei Sutou <kou@cozmixng.org>
|
2
45
|
|
46
|
+
* src/rb_cairo.c: 1.6.2 -> 1.7.0.
|
47
|
+
|
3
48
|
* Rakefile: don't clean on release target to keep generated document.
|
4
49
|
|
5
50
|
* src/rb_cairo_surface.c: rename OpenFile before include rubyio.h.
|
data/NEWS
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
Release 1.6.3 (2008-07-19) Kouhei Sutou <kou@cozmixng.org>)
|
2
|
+
===========================================================
|
3
|
+
|
4
|
+
Features
|
5
|
+
--------
|
6
|
+
* Fix build failure on Debian GNU/Linux. (reported by James Healy)
|
7
|
+
* Fix GC failure with Ruby 1.8.7. (reported by James Healy)
|
8
|
+
* Improve building on MacOS X. (suggested by Carsten Bormann)
|
9
|
+
* Fix install location of cairo.so. (suggested by OBATA Akio)
|
10
|
+
|
1
11
|
Release 1.6.2 (2008-06-14) Kouhei Sutou <kou@cozmixng.org>)
|
2
12
|
===========================================================
|
3
13
|
|
data/README
CHANGED
data/Rakefile
CHANGED
data/pkg-config.rb
CHANGED
@@ -164,46 +164,67 @@ class PackageConfig
|
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
+
def search_pkg_config_from_path(pkg_config)
|
168
|
+
(ENV["PATH"] || "").split(separator).each do |path|
|
169
|
+
try_pkg_config = Pathname(path) + pkg_config
|
170
|
+
return try_pkg_config if try_pkg_config.exist?
|
171
|
+
end
|
172
|
+
nil
|
173
|
+
end
|
174
|
+
|
175
|
+
def search_pkg_config_by_dln_find_exe(pkg_config)
|
176
|
+
begin
|
177
|
+
require "dl/import"
|
178
|
+
rescue LoadError
|
179
|
+
return nil
|
180
|
+
end
|
181
|
+
dln = Module.new
|
182
|
+
dln.module_eval do
|
183
|
+
if DL.const_defined?(:Importer)
|
184
|
+
extend DL::Importer
|
185
|
+
else
|
186
|
+
extend DL::Importable
|
187
|
+
end
|
188
|
+
begin
|
189
|
+
dlload RbConfig::CONFIG["LIBRUBY"]
|
190
|
+
rescue RuntimeError
|
191
|
+
return nil if $!.message == "unknown error"
|
192
|
+
return nil if /: image not found\z/ =~ $!.message
|
193
|
+
raise
|
194
|
+
rescue DL::DLError
|
195
|
+
return nil
|
196
|
+
end
|
197
|
+
extern "const char *dln_find_exe(const char *, const char *)"
|
198
|
+
end
|
199
|
+
dln.dln_find_exe(pkg_config.to_s, ".")
|
200
|
+
end
|
201
|
+
|
167
202
|
def guess_default_path
|
168
203
|
default_path = ["/usr/local/lib64/pkgconfig",
|
169
204
|
"/usr/local/lib/pkgconfig",
|
205
|
+
"/usr/local/libdata/pkgconfig",
|
206
|
+
"/opt/local/lib/pkgconfig",
|
170
207
|
"/usr/lib64/pkgconfig",
|
171
|
-
"/usr/lib/pkgconfig"
|
208
|
+
"/usr/lib/pkgconfig",
|
209
|
+
"/usr/share/pkgconfig"].join(separator)
|
172
210
|
libdir = ENV["PKG_CONFIG_LIBDIR"]
|
173
|
-
default_path =
|
211
|
+
default_path = [libdir, default_path].join(separator) if libdir
|
212
|
+
|
174
213
|
pkg_config = with_config("pkg-config", ENV["PKG_CONFIG"] || "pkg-config")
|
175
214
|
pkg_config = Pathname.new(pkg_config)
|
176
215
|
unless pkg_config.absolute?
|
177
|
-
|
178
|
-
|
179
|
-
rescue LoadError
|
180
|
-
return default_path
|
181
|
-
end
|
182
|
-
dln = Module.new
|
183
|
-
dln.module_eval do
|
184
|
-
if DL.const_defined?(:Importer)
|
185
|
-
extend DL::Importer
|
186
|
-
else
|
187
|
-
extend DL::Importable
|
188
|
-
end
|
189
|
-
begin
|
190
|
-
dlload RbConfig::CONFIG["LIBRUBY"]
|
191
|
-
rescue RuntimeError
|
192
|
-
return default_path if $!.message == "unknown error"
|
193
|
-
return default_path if /: image not found\z/ =~ $!.message
|
194
|
-
raise
|
195
|
-
rescue DL::DLError
|
196
|
-
return default_path
|
197
|
-
end
|
198
|
-
extern "const char *dln_find_exe(const char *, const char *)"
|
199
|
-
end
|
200
|
-
pkg_config = dln.dln_find_exe(pkg_config.to_s, ".")
|
201
|
-
return default_path if pkg_config.nil?
|
202
|
-
return default_path if pkg_config.size.zero?
|
203
|
-
pkg_config = Pathname.new(pkg_config)
|
216
|
+
found_pkg_config = search_pkg_config_from_path(pkg_config)
|
217
|
+
pkg_config = found_pkg_config if found_pkg_config
|
204
218
|
end
|
219
|
+
unless pkg_config.absolute?
|
220
|
+
found_pkg_config = search_pkg_config_by_dln_find_exe(pkg_config)
|
221
|
+
pkg_config = found_pkg_config if found_pkg_config
|
222
|
+
end
|
223
|
+
|
224
|
+
return default_path unless pkg_config.absolute?
|
205
225
|
[(pkg_config.parent.parent + "lib" + "pkgconfig").to_s,
|
206
|
-
|
226
|
+
(pkg_config.parent.parent + "libdata" + "pkgconfig").to_s,
|
227
|
+
default_path].join(separator)
|
207
228
|
end
|
208
229
|
end
|
209
230
|
|
data/src/rb_cairo.c
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* Ruby Cairo Binding
|
4
4
|
*
|
5
5
|
* $Author: kou $
|
6
|
-
* $Date: 2008-
|
6
|
+
* $Date: 2008-07-19 11:00:10 $
|
7
7
|
*
|
8
8
|
* Copyright 2006-2007 Kouhei Sutou <kou@cozmixng.org>
|
9
9
|
* Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
|
@@ -58,7 +58,7 @@ Init_cairo ()
|
|
58
58
|
|
59
59
|
rb_define_const (rb_mCairo, "BINDINGS_VERSION",
|
60
60
|
rb_ary_new3 (4,
|
61
|
-
INT2FIX (1), INT2FIX (6), INT2FIX (
|
61
|
+
INT2FIX (1), INT2FIX (6), INT2FIX (3), Qnil));
|
62
62
|
|
63
63
|
rb_mCairo_Color = rb_const_get (rb_mCairo, rb_intern ("Color"));
|
64
64
|
rb_cCairo_Color_Base = rb_const_get (rb_mCairo_Color, rb_intern ("Base"));
|
data/src/rb_cairo.h
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* Ruby Cairo Binding
|
4
4
|
*
|
5
5
|
* $Author: kou $
|
6
|
-
* $Date: 2008-
|
6
|
+
* $Date: 2008-06-19 13:00:18 $
|
7
7
|
*
|
8
8
|
* Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
|
9
9
|
* Copyright 2004-2005 MenTaLguY <mental@rydia.com>
|
@@ -18,15 +18,15 @@
|
|
18
18
|
|
19
19
|
#include <cairo.h>
|
20
20
|
|
21
|
-
#
|
21
|
+
#ifdef CAIRO_HAS_PS_SURFACE
|
22
22
|
# include <cairo-ps.h>
|
23
23
|
#endif
|
24
24
|
|
25
|
-
#
|
25
|
+
#ifdef CAIRO_HAS_PDF_SURFACE
|
26
26
|
# include <cairo-pdf.h>
|
27
27
|
#endif
|
28
28
|
|
29
|
-
#
|
29
|
+
#ifdef CAIRO_HAS_SVG_SURFACE
|
30
30
|
# include <cairo-svg.h>
|
31
31
|
#endif
|
32
32
|
|
@@ -210,10 +210,10 @@ VALUE rb_cairo_surface_to_ruby_object_with_destroy
|
|
210
210
|
#define RVAL2CRFORMAT(obj) (rb_cairo_format_from_ruby_object(obj))
|
211
211
|
#define RVAL2CREXTEND(obj) (rb_cairo_extend_from_ruby_object(obj))
|
212
212
|
#define RVAL2CRFILTER(obj) (rb_cairo_filter_from_ruby_object(obj))
|
213
|
-
#
|
213
|
+
#ifdef CAIRO_HAS_SVG_SURFACE
|
214
214
|
#define RVAL2CRSVGVERSION(obj) (rb_cairo_svg_version_from_ruby_object(obj))
|
215
215
|
#endif
|
216
|
-
#
|
216
|
+
#ifdef CAIRO_HAS_PS_SURFACE
|
217
217
|
# if CAIRO_CHECK_VERSION(1, 5, 2)
|
218
218
|
#define RVAL2CRPSLEVEL(obj) (rb_cairo_ps_level_from_ruby_object(obj))
|
219
219
|
# endif
|
@@ -234,10 +234,10 @@ cairo_content_t rb_cairo_content_from_ruby_object (VALUE obj);
|
|
234
234
|
cairo_format_t rb_cairo_format_from_ruby_object (VALUE obj);
|
235
235
|
cairo_extend_t rb_cairo_extend_from_ruby_object (VALUE obj);
|
236
236
|
cairo_filter_t rb_cairo_filter_from_ruby_object (VALUE obj);
|
237
|
-
#
|
237
|
+
#ifdef CAIRO_HAS_SVG_SURFACE
|
238
238
|
cairo_svg_version_t rb_cairo_svg_version_from_ruby_object (VALUE obj);
|
239
239
|
#endif
|
240
|
-
#
|
240
|
+
#ifdef CAIRO_HAS_PS_SURFACE
|
241
241
|
# if CAIRO_CHECK_VERSION(1, 5, 2)
|
242
242
|
cairo_ps_level_t rb_cairo_ps_level_from_ruby_object (VALUE obj);
|
243
243
|
# endif
|
data/src/rb_cairo_constants.c
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* Ruby Cairo Binding
|
4
4
|
*
|
5
5
|
* $Author: kou $
|
6
|
-
* $Date: 2008-
|
6
|
+
* $Date: 2008-06-19 13:00:18 $
|
7
7
|
*
|
8
8
|
* Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
|
9
9
|
* Copyright 2004-2005 MenTaLguY <mental@rydia.com>
|
@@ -124,23 +124,27 @@ DEFINE_RVAL2ENUM(content, CONTENT)
|
|
124
124
|
DEFINE_RVAL2ENUM(format, FORMAT)
|
125
125
|
DEFINE_RVAL2ENUM(extend, EXTEND)
|
126
126
|
DEFINE_RVAL2ENUM(filter, FILTER)
|
127
|
-
#
|
127
|
+
#ifdef CAIRO_HAS_SVG_SURFACE
|
128
128
|
DEFINE_RVAL2ENUM(svg_version, SVG_VERSION)
|
129
129
|
#endif
|
130
|
-
|
130
|
+
|
131
|
+
#ifdef CAIRO_HAS_PS_SURFACE
|
132
|
+
# if CAIRO_CHECK_VERSION(1, 5, 2)
|
131
133
|
DEFINE_RVAL2ENUM(ps_level, PS_LEVEL)
|
132
|
-
#
|
133
|
-
#
|
134
|
+
#define PS_LEVEL_ENUM_DEFINED 1
|
135
|
+
# endif
|
136
|
+
#endif
|
137
|
+
|
138
|
+
#if defined(RB_CAIRO_PLATFORM_WIN32) && !defined(PS_LEVEL_ENUM_DEFINED)
|
134
139
|
void
|
135
140
|
rb_cairo_ps_level_from_ruby_object (VALUE rb_ps_level)
|
136
141
|
{
|
137
142
|
/* dummy */
|
138
143
|
}
|
139
|
-
# endif
|
140
144
|
#endif
|
141
145
|
|
142
146
|
|
143
|
-
#
|
147
|
+
#ifdef CAIRO_HAS_SVG_SURFACE
|
144
148
|
static VALUE
|
145
149
|
cr_svg_get_versions (VALUE self)
|
146
150
|
{
|
@@ -187,7 +191,7 @@ cr_format_stride_for_width (VALUE self, VALUE format, VALUE width)
|
|
187
191
|
}
|
188
192
|
#endif
|
189
193
|
|
190
|
-
#
|
194
|
+
#ifdef CAIRO_HAS_PS_SURFACE
|
191
195
|
# if CAIRO_CHECK_VERSION(1, 5, 8)
|
192
196
|
static VALUE
|
193
197
|
cr_ps_get_levels (VALUE self)
|
@@ -428,7 +432,7 @@ Init_cairo_constants (void)
|
|
428
432
|
rb_define_const (rb_mCairo_Filter, "GAUSSIAN",
|
429
433
|
INT2FIX (CAIRO_FILTER_GAUSSIAN));
|
430
434
|
|
431
|
-
#
|
435
|
+
#ifdef CAIRO_HAS_SVG_SURFACE
|
432
436
|
/* cairo_svg_version_t */
|
433
437
|
rb_mCairo_SVGVersion = rb_define_module_under (rb_mCairo, "SVGVersion");
|
434
438
|
rb_define_const (rb_mCairo_SVGVersion, "VERSION_1_1",
|
@@ -442,7 +446,8 @@ Init_cairo_constants (void)
|
|
442
446
|
cr_svg_version_to_string, -1);
|
443
447
|
#endif
|
444
448
|
|
445
|
-
#
|
449
|
+
#ifdef CAIRO_HAS_PS_SURFACE
|
450
|
+
# if CAIRO_CHECK_VERSION(1, 5, 2)
|
446
451
|
/* cairo_ps_level_t */
|
447
452
|
rb_mCairo_PSLevel = rb_define_module_under (rb_mCairo, "PSLevel");
|
448
453
|
rb_define_const (rb_mCairo_PSLevel, "LEVEL_2", INT2FIX (CAIRO_PS_LEVEL_2));
|
@@ -452,5 +457,6 @@ Init_cairo_constants (void)
|
|
452
457
|
cr_ps_get_levels, 0);
|
453
458
|
rb_define_singleton_method (rb_mCairo_PSLevel, "name",
|
454
459
|
cr_ps_level_to_string, -1);
|
460
|
+
# endif
|
455
461
|
#endif
|
456
462
|
}
|
data/src/rb_cairo_surface.c
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* Ruby Cairo Binding
|
4
4
|
*
|
5
5
|
* $Author: kou $
|
6
|
-
* $Date: 2008-06-
|
6
|
+
* $Date: 2008-06-20 02:01:53 $
|
7
7
|
*
|
8
8
|
* Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
|
9
9
|
* Copyright 2004-2005 MenTaLguY <mental@rydia.com>
|
@@ -15,7 +15,9 @@
|
|
15
15
|
#include "rb_cairo.h"
|
16
16
|
#include "rb_cairo_private.h"
|
17
17
|
|
18
|
-
#
|
18
|
+
#include <st.h>
|
19
|
+
|
20
|
+
#ifdef CAIRO_HAS_WIN32_SURFACE
|
19
21
|
# define OpenFile OpenFile_win32
|
20
22
|
# include <cairo-win32.h>
|
21
23
|
# undef OpenFile
|
@@ -23,7 +25,7 @@
|
|
23
25
|
|
24
26
|
#include <rubyio.h>
|
25
27
|
|
26
|
-
#
|
28
|
+
#ifdef CAIRO_HAS_QUARTZ_SURFACE
|
27
29
|
# ifndef HAVE_TYPE_ENUM_RUBY_VALUE_TYPE
|
28
30
|
enum ruby_value_type {
|
29
31
|
RUBY_T_DATA = T_DATA
|
@@ -34,7 +36,9 @@ enum ruby_value_type {
|
|
34
36
|
# define T_DATA RUBY_T_DATA
|
35
37
|
#endif
|
36
38
|
|
37
|
-
#if CAIRO_HAS_PS_SURFACE ||
|
39
|
+
#if defined(CAIRO_HAS_PS_SURFACE) || \
|
40
|
+
defined(CAIRO_HAS_PDF_SURFACE) || \
|
41
|
+
defined(CAIRO_HAS_SVG_SURFACE)
|
38
42
|
# define HAS_CREATE_CR_CLOSURE_SURFACE 1
|
39
43
|
#else
|
40
44
|
# define HAS_CREATE_CR_CLOSURE_SURFACE 0
|
@@ -58,7 +62,11 @@ static ID cr_id_inspect;
|
|
58
62
|
static ID cr_id_parse;
|
59
63
|
static ID cr_id_size;
|
60
64
|
static ID cr_id_set_unit;
|
65
|
+
static ID cr_id_instances;
|
66
|
+
static ID cr_id_dup;
|
61
67
|
static cairo_user_data_key_t cr_closure_key;
|
68
|
+
static cairo_user_data_key_t cr_object_holder_key;
|
69
|
+
static cairo_user_data_key_t cr_finished_key;
|
62
70
|
|
63
71
|
#define _SELF (RVAL2CRSURFACE(self))
|
64
72
|
|
@@ -165,7 +173,7 @@ cr_closure_new (VALUE target)
|
|
165
173
|
static void
|
166
174
|
cr_closure_destroy (cr_io_callback_closure_t *closure)
|
167
175
|
{
|
168
|
-
|
176
|
+
xfree (closure);
|
169
177
|
}
|
170
178
|
|
171
179
|
static void
|
@@ -287,13 +295,53 @@ rb_cairo_surface_from_ruby_object (VALUE obj)
|
|
287
295
|
return surface;
|
288
296
|
}
|
289
297
|
|
298
|
+
static void
|
299
|
+
add_gc_guard (VALUE self)
|
300
|
+
{
|
301
|
+
rb_hash_aset (rb_ivar_get (rb_cCairo_Surface, cr_id_instances),
|
302
|
+
self, Qnil);
|
303
|
+
}
|
304
|
+
|
305
|
+
static void
|
306
|
+
remove_gc_guard (VALUE self)
|
307
|
+
{
|
308
|
+
rb_hash_delete (rb_ivar_get (rb_cCairo_Surface, cr_id_instances),
|
309
|
+
self);
|
310
|
+
}
|
311
|
+
|
312
|
+
typedef struct cr_object_holder {
|
313
|
+
VALUE object;
|
314
|
+
} cr_object_holder_t;
|
315
|
+
|
316
|
+
static cr_object_holder_t *
|
317
|
+
cr_object_holder_new (VALUE object)
|
318
|
+
{
|
319
|
+
cr_object_holder_t *holder;
|
320
|
+
|
321
|
+
holder = ALLOC(cr_object_holder_t);
|
322
|
+
add_gc_guard (object);
|
323
|
+
holder->object = object;
|
324
|
+
return holder;
|
325
|
+
}
|
326
|
+
|
327
|
+
static void
|
328
|
+
cr_object_holder_free (void *ptr)
|
329
|
+
{
|
330
|
+
cr_object_holder_t *holder = ptr;
|
331
|
+
|
332
|
+
if (!NIL_P (holder->object))
|
333
|
+
remove_gc_guard (holder->object);
|
334
|
+
|
335
|
+
xfree (holder);
|
336
|
+
}
|
337
|
+
|
290
338
|
static void
|
291
339
|
cr_surface_free (void *ptr)
|
292
340
|
{
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
341
|
+
cairo_surface_t *surface = ptr;
|
342
|
+
|
343
|
+
if (surface)
|
344
|
+
cairo_surface_destroy (surface);
|
297
345
|
}
|
298
346
|
|
299
347
|
VALUE
|
@@ -316,9 +364,11 @@ VALUE
|
|
316
364
|
rb_cairo_surface_to_ruby_object_with_destroy (cairo_surface_t *surface)
|
317
365
|
{
|
318
366
|
VALUE rb_surface;
|
367
|
+
|
319
368
|
rb_surface = rb_cairo_surface_to_ruby_object (surface);
|
320
369
|
if (surface)
|
321
370
|
cairo_surface_destroy (surface);
|
371
|
+
|
322
372
|
return rb_surface;
|
323
373
|
}
|
324
374
|
|
@@ -329,23 +379,36 @@ cr_surface_allocate (VALUE klass)
|
|
329
379
|
}
|
330
380
|
|
331
381
|
/* Surface manipulation */
|
382
|
+
static VALUE
|
383
|
+
cr_surface_finish (VALUE self)
|
384
|
+
{
|
385
|
+
cairo_surface_t *surface;
|
386
|
+
cr_io_callback_closure_t *closure;
|
387
|
+
|
388
|
+
surface = _SELF;
|
389
|
+
closure = cairo_surface_get_user_data (surface, &cr_closure_key);
|
390
|
+
|
391
|
+
cairo_surface_finish (surface);
|
392
|
+
cairo_surface_set_user_data (surface, &cr_finished_key, (void *)CR_TRUE, NULL);
|
393
|
+
cairo_surface_set_user_data (surface, &cr_object_holder_key, NULL, NULL);
|
394
|
+
|
395
|
+
if (closure && !NIL_P (closure->error))
|
396
|
+
rb_exc_raise (closure->error);
|
397
|
+
cr_surface_check_status (surface);
|
398
|
+
|
399
|
+
return self;
|
400
|
+
}
|
401
|
+
|
332
402
|
static void
|
333
403
|
yield_and_finish (VALUE self)
|
334
404
|
{
|
335
405
|
cairo_surface_t *surface;
|
336
|
-
cairo_status_t status;
|
337
406
|
|
338
407
|
rb_yield (self);
|
339
408
|
|
340
409
|
surface = _SELF;
|
341
|
-
if (
|
342
|
-
|
343
|
-
cairo_surface_finish (surface);
|
344
|
-
status = cairo_surface_status (surface);
|
345
|
-
if (status == CAIRO_STATUS_SUCCESS || status == CAIRO_STATUS_SURFACE_FINISHED)
|
346
|
-
return;
|
347
|
-
|
348
|
-
cr_surface_check_status (surface);
|
410
|
+
if (!cairo_surface_get_user_data (surface, &cr_finished_key))
|
411
|
+
cr_surface_finish (self);
|
349
412
|
}
|
350
413
|
|
351
414
|
static VALUE
|
@@ -360,21 +423,6 @@ cr_surface_create_similar (VALUE self, VALUE content, VALUE width, VALUE height)
|
|
360
423
|
return CRSURFACE2RVAL_WITH_DESTROY (surface);
|
361
424
|
}
|
362
425
|
|
363
|
-
static VALUE
|
364
|
-
cr_surface_finish (VALUE self)
|
365
|
-
{
|
366
|
-
cr_io_callback_closure_t *closure;
|
367
|
-
closure = cairo_surface_get_user_data (_SELF, &cr_closure_key);
|
368
|
-
|
369
|
-
cairo_surface_finish (_SELF);
|
370
|
-
|
371
|
-
if (closure && !NIL_P (closure->error))
|
372
|
-
rb_exc_raise (closure->error);
|
373
|
-
|
374
|
-
cr_surface_check_status (_SELF);
|
375
|
-
return self;
|
376
|
-
}
|
377
|
-
|
378
426
|
static VALUE
|
379
427
|
cr_surface_get_content (VALUE self)
|
380
428
|
{
|
@@ -382,7 +430,7 @@ cr_surface_get_content (VALUE self)
|
|
382
430
|
}
|
383
431
|
|
384
432
|
|
385
|
-
#
|
433
|
+
#ifdef CAIRO_HAS_PNG_FUNCTIONS
|
386
434
|
static VALUE
|
387
435
|
cr_surface_write_to_png_stream (VALUE self, VALUE target)
|
388
436
|
{
|
@@ -527,7 +575,7 @@ cr_surface_show_page (VALUE self)
|
|
527
575
|
#endif
|
528
576
|
|
529
577
|
/* Image-surface functions */
|
530
|
-
#
|
578
|
+
#ifdef CAIRO_HAS_PNG_FUNCTIONS
|
531
579
|
static cairo_surface_t *
|
532
580
|
cr_image_surface_create_from_png_stream (VALUE target)
|
533
581
|
{
|
@@ -717,6 +765,9 @@ cr_ ## type ## _surface_initialize (int argc, VALUE *argv, VALUE self) \
|
|
717
765
|
rb_ivar_set (self, cr_id_target, target); \
|
718
766
|
cairo_surface_set_user_data (surface, &cr_closure_key, \
|
719
767
|
closure, cr_closure_free); \
|
768
|
+
cairo_surface_set_user_data (surface, &cr_object_holder_key, \
|
769
|
+
cr_object_holder_new(self), \
|
770
|
+
cr_object_holder_free); \
|
720
771
|
} \
|
721
772
|
} \
|
722
773
|
else \
|
@@ -764,7 +815,7 @@ cr_ ## type ## _surface_set_size (int argc, VALUE *argv, VALUE self) \
|
|
764
815
|
return Qnil; \
|
765
816
|
}
|
766
817
|
|
767
|
-
#
|
818
|
+
#ifdef CAIRO_HAS_PS_SURFACE
|
768
819
|
/* PS-surface functions */
|
769
820
|
DEFINE_SURFACE(ps)
|
770
821
|
DEFINE_SURFACE_SET_SIZE(ps)
|
@@ -824,13 +875,13 @@ cr_ps_surface_set_eps (VALUE self, VALUE eps)
|
|
824
875
|
# endif
|
825
876
|
#endif
|
826
877
|
|
827
|
-
#
|
878
|
+
#ifdef CAIRO_HAS_PDF_SURFACE
|
828
879
|
/* PDF-surface functions */
|
829
880
|
DEFINE_SURFACE(pdf)
|
830
881
|
DEFINE_SURFACE_SET_SIZE(pdf)
|
831
882
|
#endif
|
832
883
|
|
833
|
-
#
|
884
|
+
#ifdef CAIRO_HAS_SVG_SURFACE
|
834
885
|
/* SVG-surface functions */
|
835
886
|
DEFINE_SURFACE(svg)
|
836
887
|
|
@@ -843,7 +894,7 @@ cr_svg_surface_restrict_to_version (VALUE self, VALUE version)
|
|
843
894
|
}
|
844
895
|
#endif
|
845
896
|
|
846
|
-
#
|
897
|
+
#ifdef CAIRO_HAS_WIN32_SURFACE
|
847
898
|
/* WIN32-surface functions */
|
848
899
|
|
849
900
|
/* from dl/dl.h (ruby 1.9) */
|
@@ -981,7 +1032,7 @@ cr_win32_surface_get_image (VALUE self)
|
|
981
1032
|
# endif
|
982
1033
|
#endif
|
983
1034
|
|
984
|
-
#if CAIRO_HAS_QUARTZ_SURFACE && defined(HAVE_RUBY_COCOA)
|
1035
|
+
#if defined(CAIRO_HAS_QUARTZ_SURFACE) && defined(HAVE_RUBY_COCOA)
|
985
1036
|
/* Quartz-surface functions */
|
986
1037
|
|
987
1038
|
#include <objc/objc-runtime.h>
|
@@ -1100,6 +1151,21 @@ cr_quartz_image_surface_get_image (VALUE self)
|
|
1100
1151
|
# endif
|
1101
1152
|
#endif
|
1102
1153
|
|
1154
|
+
static int
|
1155
|
+
cr_finish_all_guarded_surfaces_at_end_iter (VALUE key, VALUE value, VALUE data)
|
1156
|
+
{
|
1157
|
+
cr_surface_finish (key);
|
1158
|
+
return ST_CONTINUE;
|
1159
|
+
}
|
1160
|
+
|
1161
|
+
static void
|
1162
|
+
cr_finish_all_guarded_surfaces_at_end (VALUE data)
|
1163
|
+
{
|
1164
|
+
rb_hash_foreach (rb_funcall (rb_ivar_get (rb_cCairo_Surface, cr_id_instances),
|
1165
|
+
cr_id_dup, 0),
|
1166
|
+
cr_finish_all_guarded_surfaces_at_end_iter,
|
1167
|
+
Qnil);
|
1168
|
+
}
|
1103
1169
|
|
1104
1170
|
void
|
1105
1171
|
Init_cairo_surface (void)
|
@@ -1111,11 +1177,18 @@ Init_cairo_surface (void)
|
|
1111
1177
|
cr_id_parse = rb_intern ("parse");
|
1112
1178
|
cr_id_size = rb_intern ("size");
|
1113
1179
|
cr_id_set_unit = rb_intern ("unit=");
|
1180
|
+
cr_id_instances = rb_intern ("instances");
|
1181
|
+
cr_id_dup = rb_intern ("dup");
|
1182
|
+
|
1183
|
+
rb_set_end_proc(cr_finish_all_guarded_surfaces_at_end, Qnil);
|
1114
1184
|
|
1115
1185
|
rb_cCairo_Surface =
|
1116
1186
|
rb_define_class_under (rb_mCairo, "Surface", rb_cObject);
|
1117
1187
|
rb_define_alloc_func (rb_cCairo_Surface, cr_surface_allocate);
|
1118
|
-
|
1188
|
+
|
1189
|
+
rb_ivar_set (rb_cCairo_Surface, cr_id_instances, rb_hash_new ());
|
1190
|
+
|
1191
|
+
|
1119
1192
|
rb_define_method (rb_cCairo_Surface, "create_similar",
|
1120
1193
|
cr_surface_create_similar, 3);
|
1121
1194
|
rb_define_method (rb_cCairo_Surface, "finish", cr_surface_finish, 0);
|
@@ -1138,7 +1211,7 @@ Init_cairo_surface (void)
|
|
1138
1211
|
cr_surface_show_page, 2);
|
1139
1212
|
#endif
|
1140
1213
|
|
1141
|
-
#
|
1214
|
+
#ifdef CAIRO_HAS_PNG_FUNCTIONS
|
1142
1215
|
rb_define_method (rb_cCairo_Surface, "write_to_png",
|
1143
1216
|
cr_surface_write_to_png_generic, 1);
|
1144
1217
|
#endif
|
@@ -1149,7 +1222,7 @@ Init_cairo_surface (void)
|
|
1149
1222
|
rb_cCairo_ImageSurface =
|
1150
1223
|
rb_define_class_under (rb_mCairo, "ImageSurface", rb_cCairo_Surface);
|
1151
1224
|
|
1152
|
-
#
|
1225
|
+
#ifdef CAIRO_HAS_PNG_FUNCTIONS
|
1153
1226
|
rb_define_singleton_method (rb_cCairo_ImageSurface, "from_png",
|
1154
1227
|
cr_image_surface_create_from_png_generic, 1);
|
1155
1228
|
#endif
|
@@ -1176,7 +1249,7 @@ Init_cairo_surface (void)
|
|
1176
1249
|
rb_define_method (rb_cCairo_ ## name ## Surface, "initialize", \
|
1177
1250
|
cr_ ## type ## _surface_initialize, -1);
|
1178
1251
|
|
1179
|
-
#
|
1252
|
+
#ifdef CAIRO_HAS_PS_SURFACE
|
1180
1253
|
/* PS-surface */
|
1181
1254
|
INIT_SURFACE(ps, PS)
|
1182
1255
|
|
@@ -1188,17 +1261,17 @@ Init_cairo_surface (void)
|
|
1188
1261
|
rb_define_method (rb_cCairo_PSSurface, "dsc_begin_page_setup",
|
1189
1262
|
cr_ps_surface_dsc_begin_page_setup, 0);
|
1190
1263
|
|
1191
|
-
#if CAIRO_CHECK_VERSION(1, 5, 2)
|
1264
|
+
# if CAIRO_CHECK_VERSION(1, 5, 2)
|
1192
1265
|
rb_define_method (rb_cCairo_PSSurface, "restrict_to_level",
|
1193
1266
|
cr_ps_surface_restrict_to_level, 1);
|
1194
1267
|
rb_define_method (rb_cCairo_PSSurface, "eps?", cr_ps_surface_get_eps, 0);
|
1195
1268
|
rb_define_method (rb_cCairo_PSSurface, "set_eps", cr_ps_surface_set_eps, 1);
|
1196
|
-
#endif
|
1269
|
+
# endif
|
1197
1270
|
|
1198
1271
|
RB_CAIRO_DEF_SETTERS (rb_cCairo_PSSurface);
|
1199
1272
|
#endif
|
1200
1273
|
|
1201
|
-
#
|
1274
|
+
#ifdef CAIRO_HAS_PDF_SURFACE
|
1202
1275
|
/* PDF-surface */
|
1203
1276
|
INIT_SURFACE(pdf, PDF)
|
1204
1277
|
|
@@ -1208,7 +1281,7 @@ Init_cairo_surface (void)
|
|
1208
1281
|
RB_CAIRO_DEF_SETTERS (rb_cCairo_PDFSurface);
|
1209
1282
|
#endif
|
1210
1283
|
|
1211
|
-
#
|
1284
|
+
#ifdef CAIRO_HAS_SVG_SURFACE
|
1212
1285
|
/* SVG-surface */
|
1213
1286
|
INIT_SURFACE(svg, SVG)
|
1214
1287
|
|
@@ -1218,7 +1291,7 @@ Init_cairo_surface (void)
|
|
1218
1291
|
RB_CAIRO_DEF_SETTERS (rb_cCairo_SVGSurface);
|
1219
1292
|
#endif
|
1220
1293
|
|
1221
|
-
#
|
1294
|
+
#ifdef CAIRO_HAS_WIN32_SURFACE
|
1222
1295
|
/* Win32-surface */
|
1223
1296
|
rb_cCairo_Win32Surface =
|
1224
1297
|
rb_define_class_under (rb_mCairo, "Win32Surface", rb_cCairo_Surface);
|
@@ -1244,7 +1317,7 @@ Init_cairo_surface (void)
|
|
1244
1317
|
|
1245
1318
|
#endif
|
1246
1319
|
|
1247
|
-
#if CAIRO_HAS_QUARTZ_SURFACE && defined(HAVE_RUBY_COCOA)
|
1320
|
+
#if defined(CAIRO_HAS_QUARTZ_SURFACE) && defined(HAVE_RUBY_COCOA)
|
1248
1321
|
/* Quartz-surface */
|
1249
1322
|
|
1250
1323
|
rb_cCairo_QuartzSurface =
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'cairo'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
class SurfaceTest < Test::Unit::TestCase
|
5
|
+
def test_new
|
6
|
+
output = StringIO.new
|
7
|
+
surface = Cairo::PDFSurface.new(output, 10, 10)
|
8
|
+
assert_no_match(/%%EOF\s*\z/m, output.string)
|
9
|
+
surface.finish
|
10
|
+
assert_match(/%%EOF\s*\z/m, output.string)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_new_with_block
|
14
|
+
output = StringIO.new
|
15
|
+
Cairo::PDFSurface.new(output, 10, 10) do |surface|
|
16
|
+
assert_no_match(/%%EOF\s*\z/m, output.string)
|
17
|
+
end
|
18
|
+
assert_match(/%%EOF\s*\z/m, output.string)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_new_with_block_and_finish
|
22
|
+
assert_nothing_raised do
|
23
|
+
Cairo::PDFSurface.new(StringIO.new, 10, 10) do |surface|
|
24
|
+
surface.finish
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cairo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Marin
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2008-
|
15
|
+
date: 2008-07-19 00:00:00 +09:00
|
16
16
|
default_executable:
|
17
17
|
dependencies: []
|
18
18
|
|
@@ -387,6 +387,7 @@ files:
|
|
387
387
|
- test/run-test.rb
|
388
388
|
- test/test_paper.rb
|
389
389
|
- test/test_pkg_config.rb
|
390
|
+
- test/test_surface.rb
|
390
391
|
has_rdoc: false
|
391
392
|
homepage: http://cairographics.org/rcairo
|
392
393
|
post_install_message:
|