cairo 1.17.4 → 1.17.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/NEWS +49 -0
- data/ext/cairo/rb_cairo.c +1 -1
- data/ext/cairo/rb_cairo.h +1 -1
- data/ext/cairo/rb_cairo_constants.c +12 -2
- data/ext/cairo/rb_cairo_context.c +54 -16
- data/ext/cairo/rb_cairo_device.c +22 -13
- data/ext/cairo/rb_cairo_exception.c +20 -2
- data/ext/cairo/rb_cairo_font_extents.c +20 -3
- data/ext/cairo/rb_cairo_font_face.c +82 -21
- data/ext/cairo/rb_cairo_font_options.c +27 -15
- data/ext/cairo/rb_cairo_glyph.c +15 -12
- data/ext/cairo/rb_cairo_io.c +2 -2
- data/ext/cairo/rb_cairo_matrix.c +17 -14
- data/ext/cairo/rb_cairo_path.c +29 -44
- data/ext/cairo/rb_cairo_pattern.c +21 -13
- data/ext/cairo/rb_cairo_quartz_surface.c +5 -0
- data/ext/cairo/rb_cairo_rectangle.c +13 -2
- data/ext/cairo/rb_cairo_region.c +21 -13
- data/ext/cairo/rb_cairo_scaled_font.c +23 -14
- data/ext/cairo/rb_cairo_surface.c +65 -20
- data/ext/cairo/rb_cairo_text_cluster.c +20 -14
- data/ext/cairo/rb_cairo_text_extents.c +20 -3
- data/test/test_context.rb +14 -0
- data/test/test_font_face.rb +165 -70
- data/test/test_quartz_image_surface.rb +5 -3
- data/test/test_svg_surface.rb +5 -1
- metadata +3 -3
@@ -5,7 +5,7 @@
|
|
5
5
|
* $Author: kou $
|
6
6
|
* $Date: 2008-09-19 12:56:27 $
|
7
7
|
*
|
8
|
-
* Copyright 2005-
|
8
|
+
* Copyright 2005-2022 Sutou Kouhei <kou@cozmixng.org>
|
9
9
|
*
|
10
10
|
* This file is made available under the same terms as Ruby
|
11
11
|
*
|
@@ -18,6 +18,23 @@
|
|
18
18
|
|
19
19
|
VALUE rb_cCairo_FontOptions;
|
20
20
|
|
21
|
+
static void
|
22
|
+
cr_options_free (void *ptr)
|
23
|
+
{
|
24
|
+
cairo_font_options_destroy ((cairo_font_options_t *) ptr);
|
25
|
+
}
|
26
|
+
|
27
|
+
static const rb_data_type_t cr_font_options_type = {
|
28
|
+
"Cairo::FontOptions",
|
29
|
+
{
|
30
|
+
NULL,
|
31
|
+
cr_options_free,
|
32
|
+
},
|
33
|
+
NULL,
|
34
|
+
NULL,
|
35
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
36
|
+
};
|
37
|
+
|
21
38
|
static inline void
|
22
39
|
cr_options_check_status (cairo_font_options_t *options)
|
23
40
|
{
|
@@ -32,19 +49,13 @@ rb_cairo_font_options_from_ruby_object (VALUE obj)
|
|
32
49
|
{
|
33
50
|
rb_raise (rb_eTypeError, "not a cairo font options");
|
34
51
|
}
|
35
|
-
|
52
|
+
TypedData_Get_Struct (obj,
|
53
|
+
cairo_font_options_t,
|
54
|
+
&cr_font_options_type,
|
55
|
+
options);
|
36
56
|
return options;
|
37
57
|
}
|
38
58
|
|
39
|
-
static void
|
40
|
-
cr_options_free (void *ptr)
|
41
|
-
{
|
42
|
-
if (ptr)
|
43
|
-
{
|
44
|
-
cairo_font_options_destroy ((cairo_font_options_t *) ptr);
|
45
|
-
}
|
46
|
-
}
|
47
|
-
|
48
59
|
VALUE
|
49
60
|
rb_cairo_font_options_to_ruby_object (cairo_font_options_t *options)
|
50
61
|
{
|
@@ -53,8 +64,9 @@ rb_cairo_font_options_to_ruby_object (cairo_font_options_t *options)
|
|
53
64
|
cairo_font_options_t *copied_options;
|
54
65
|
copied_options = cairo_font_options_copy (options);
|
55
66
|
cr_options_check_status (copied_options);
|
56
|
-
return
|
57
|
-
|
67
|
+
return TypedData_Wrap_Struct (rb_cCairo_FontOptions,
|
68
|
+
&cr_font_options_type,
|
69
|
+
copied_options);
|
58
70
|
}
|
59
71
|
else
|
60
72
|
{
|
@@ -65,7 +77,7 @@ rb_cairo_font_options_to_ruby_object (cairo_font_options_t *options)
|
|
65
77
|
static VALUE
|
66
78
|
cr_options_allocate (VALUE klass)
|
67
79
|
{
|
68
|
-
return
|
80
|
+
return TypedData_Wrap_Struct (klass, &cr_font_options_type, NULL);
|
69
81
|
}
|
70
82
|
|
71
83
|
static VALUE
|
@@ -104,7 +116,7 @@ cr_options_equal (VALUE self, VALUE other)
|
|
104
116
|
static VALUE
|
105
117
|
cr_options_hash (VALUE self)
|
106
118
|
{
|
107
|
-
return
|
119
|
+
return ULONG2NUM (cairo_font_options_hash (_SELF (self)));
|
108
120
|
}
|
109
121
|
|
110
122
|
static VALUE
|
data/ext/cairo/rb_cairo_glyph.c
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
* $Author: kou $
|
6
6
|
* $Date: 2008-08-16 08:16:39 $
|
7
7
|
*
|
8
|
+
* Copyright 2005-2022 Sutou Kouhei <kou@cozmixng.org>
|
8
9
|
* Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
|
9
10
|
* Copyright 2004-2005 MenTaLguY <mental@rydia.com>
|
10
11
|
*
|
@@ -20,6 +21,17 @@ VALUE rb_cCairo_Glyph;
|
|
20
21
|
|
21
22
|
#define _SELF(self) (RVAL2CRGLYPH(self))
|
22
23
|
|
24
|
+
static const rb_data_type_t cr_glyph_type = {
|
25
|
+
"Cairo::Glyph",
|
26
|
+
{
|
27
|
+
NULL,
|
28
|
+
ruby_xfree,
|
29
|
+
},
|
30
|
+
NULL,
|
31
|
+
NULL,
|
32
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
33
|
+
};
|
34
|
+
|
23
35
|
cairo_glyph_t *
|
24
36
|
rb_cairo_glyph_from_ruby_object (VALUE obj)
|
25
37
|
{
|
@@ -28,19 +40,10 @@ rb_cairo_glyph_from_ruby_object (VALUE obj)
|
|
28
40
|
{
|
29
41
|
rb_raise (rb_eTypeError, "not a cairo glyph");
|
30
42
|
}
|
31
|
-
|
43
|
+
TypedData_Get_Struct (obj, cairo_glyph_t, &cr_glyph_type, glyph);
|
32
44
|
return glyph;
|
33
45
|
}
|
34
46
|
|
35
|
-
static void
|
36
|
-
cr_glyph_free (void *ptr)
|
37
|
-
{
|
38
|
-
if (ptr)
|
39
|
-
{
|
40
|
-
xfree (ptr);
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
47
|
VALUE
|
45
48
|
rb_cairo_glyph_to_ruby_object (cairo_glyph_t *glyph)
|
46
49
|
{
|
@@ -50,7 +53,7 @@ rb_cairo_glyph_to_ruby_object (cairo_glyph_t *glyph)
|
|
50
53
|
|
51
54
|
new_glyph = ALLOC (cairo_glyph_t);
|
52
55
|
*new_glyph = *glyph;
|
53
|
-
return
|
56
|
+
return TypedData_Wrap_Struct (rb_cCairo_Glyph, &cr_glyph_type, new_glyph);
|
54
57
|
}
|
55
58
|
else
|
56
59
|
{
|
@@ -61,7 +64,7 @@ rb_cairo_glyph_to_ruby_object (cairo_glyph_t *glyph)
|
|
61
64
|
static VALUE
|
62
65
|
cr_glyph_allocate (VALUE klass)
|
63
66
|
{
|
64
|
-
return
|
67
|
+
return TypedData_Wrap_Struct (klass, &cr_glyph_type, NULL);
|
65
68
|
}
|
66
69
|
|
67
70
|
static VALUE
|
data/ext/cairo/rb_cairo_io.c
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
/*
|
3
3
|
* Ruby Cairo Binding
|
4
4
|
*
|
5
|
-
* Copyright 2005-
|
5
|
+
* Copyright 2005-2021 Sutou Kouhei <kou@cozmixng.org>
|
6
6
|
*
|
7
7
|
* This file is made available under the same terms as Ruby
|
8
8
|
*
|
@@ -130,7 +130,7 @@ rb_cairo__io_read_func_invoke (VALUE read_closure)
|
|
130
130
|
{
|
131
131
|
rb_str_concat (result,
|
132
132
|
rb_funcall (input,
|
133
|
-
rb_cairo__io_id_read, 1,
|
133
|
+
rb_cairo__io_id_read, 1, LONG2NUM (rest)));
|
134
134
|
}
|
135
135
|
|
136
136
|
memcpy ((void *)closure->data, (const void *) StringValuePtr (result), length);
|
data/ext/cairo/rb_cairo_matrix.c
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
* $Author: kou $
|
6
6
|
* $Date: 2008-08-14 12:37:50 $
|
7
7
|
*
|
8
|
-
* Copyright 2006-
|
8
|
+
* Copyright 2006-2022 Sutou Kouhei <kou@cozmixng.org>
|
9
9
|
* Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
|
10
10
|
* Copyright 2004-2005 MenTaLguY <mental@rydia.com>
|
11
11
|
*
|
@@ -23,6 +23,17 @@ static ID cr_id_equal;
|
|
23
23
|
|
24
24
|
#define _SELF (RVAL2CRMATRIX(self))
|
25
25
|
|
26
|
+
static const rb_data_type_t cr_matrix_type = {
|
27
|
+
"Cairo::Matrix",
|
28
|
+
{
|
29
|
+
NULL,
|
30
|
+
ruby_xfree,
|
31
|
+
},
|
32
|
+
NULL,
|
33
|
+
NULL,
|
34
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
35
|
+
};
|
36
|
+
|
26
37
|
cairo_matrix_t *
|
27
38
|
rb_cairo_matrix_from_ruby_object (VALUE obj)
|
28
39
|
{
|
@@ -31,19 +42,10 @@ rb_cairo_matrix_from_ruby_object (VALUE obj)
|
|
31
42
|
{
|
32
43
|
rb_raise (rb_eTypeError, "not a cairo matrix");
|
33
44
|
}
|
34
|
-
|
45
|
+
TypedData_Get_Struct (obj, cairo_matrix_t, &cr_matrix_type, matrix);
|
35
46
|
return matrix;
|
36
47
|
}
|
37
48
|
|
38
|
-
static void
|
39
|
-
cr_matrix_free (void *ptr)
|
40
|
-
{
|
41
|
-
if (ptr)
|
42
|
-
{
|
43
|
-
xfree ((cairo_matrix_t *) ptr);
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
49
|
VALUE
|
48
50
|
rb_cairo_matrix_to_ruby_object (cairo_matrix_t *matrix)
|
49
51
|
{
|
@@ -51,8 +53,9 @@ rb_cairo_matrix_to_ruby_object (cairo_matrix_t *matrix)
|
|
51
53
|
{
|
52
54
|
cairo_matrix_t *new_matrix = ALLOC (cairo_matrix_t);
|
53
55
|
*new_matrix = *matrix;
|
54
|
-
return
|
55
|
-
|
56
|
+
return TypedData_Wrap_Struct (rb_cCairo_Matrix,
|
57
|
+
&cr_matrix_type,
|
58
|
+
new_matrix);
|
56
59
|
}
|
57
60
|
else
|
58
61
|
{
|
@@ -63,7 +66,7 @@ rb_cairo_matrix_to_ruby_object (cairo_matrix_t *matrix)
|
|
63
66
|
static VALUE
|
64
67
|
cr_matrix_allocate (VALUE klass)
|
65
68
|
{
|
66
|
-
return
|
69
|
+
return TypedData_Wrap_Struct (klass, &cr_matrix_type, NULL);
|
67
70
|
}
|
68
71
|
|
69
72
|
static VALUE
|
data/ext/cairo/rb_cairo_path.c
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
* $Author: kou $
|
6
6
|
* $Date: 2008-04-04 03:52:31 $
|
7
7
|
*
|
8
|
-
* Copyright 2005 Kouhei
|
8
|
+
* Copyright 2005-2022 Sutou Kouhei <kou@cozmixng.org>
|
9
9
|
*
|
10
10
|
* This file is made available under the same terms as Ruby
|
11
11
|
*
|
@@ -223,54 +223,34 @@ cr_path_close_path_initialize (VALUE self)
|
|
223
223
|
static void
|
224
224
|
cr_path_free (void *ptr)
|
225
225
|
{
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
}
|
226
|
+
cairo_path_t *path = ptr;
|
227
|
+
ruby_xfree (path->data);
|
228
|
+
ruby_xfree (path);
|
230
229
|
}
|
231
230
|
|
231
|
+
static const rb_data_type_t cr_path_type = {
|
232
|
+
"Cairo::Path",
|
233
|
+
{
|
234
|
+
NULL,
|
235
|
+
cr_path_free,
|
236
|
+
},
|
237
|
+
NULL,
|
238
|
+
NULL,
|
239
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
240
|
+
};
|
241
|
+
|
232
242
|
cairo_path_t *
|
233
243
|
rb_cairo_path_from_ruby_object (VALUE obj)
|
234
244
|
{
|
235
|
-
|
236
|
-
cairo_t *cr;
|
237
|
-
cairo_path_t *path, *copied_path;
|
245
|
+
cairo_path_t *path;
|
238
246
|
|
239
247
|
if (!rb_cairo__is_kind_of (obj, rb_cCairo_Path))
|
240
248
|
{
|
241
249
|
rb_raise (rb_eTypeError, "not a cairo path");
|
242
250
|
}
|
243
|
-
|
244
|
-
|
245
|
-
context = rb_ivar_get (obj, id_at_context);
|
246
|
-
if (NIL_P (context))
|
247
|
-
return path;
|
248
|
-
|
249
|
-
cr = RVAL2CRCONTEXT (context);
|
250
|
-
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
|
251
|
-
return path;
|
251
|
+
TypedData_Get_Struct (obj, cairo_path_t, &cr_path_type, path);
|
252
252
|
|
253
|
-
|
254
|
-
rb_ivar_set (obj, id_current_path, CRPATH2RVAL (copied_path));
|
255
|
-
return copied_path;
|
256
|
-
}
|
257
|
-
|
258
|
-
static void
|
259
|
-
cr_path_ensure_internal_context (VALUE rb_path, cairo_path_t *path)
|
260
|
-
{
|
261
|
-
cairo_surface_t *surface;
|
262
|
-
cairo_t *cr;
|
263
|
-
|
264
|
-
if (!NIL_P (rb_ivar_get (rb_path, id_at_context)))
|
265
|
-
return;
|
266
|
-
|
267
|
-
surface = cairo_image_surface_create (CAIRO_FORMAT_A1, 1, 1);
|
268
|
-
cr = cairo_create (surface);
|
269
|
-
if (path->num_data > 0)
|
270
|
-
cairo_append_path (cr, path);
|
271
|
-
rb_cairo_check_status (cairo_status (cr));
|
272
|
-
rb_ivar_set (rb_path, id_at_context, CRCONTEXT2RVAL (cr));
|
273
|
-
cairo_destroy (cr);
|
253
|
+
return path;
|
274
254
|
}
|
275
255
|
|
276
256
|
VALUE
|
@@ -279,8 +259,15 @@ rb_cairo_path_to_ruby_object (cairo_path_t *path)
|
|
279
259
|
if (path)
|
280
260
|
{
|
281
261
|
VALUE rb_path;
|
282
|
-
|
283
|
-
|
262
|
+
cairo_path_t *copied_path;
|
263
|
+
copied_path = RB_ALLOC (cairo_path_t);
|
264
|
+
copied_path->data = RB_ALLOC_N (cairo_path_data_t, path->num_data);
|
265
|
+
memcpy(copied_path->data,
|
266
|
+
path->data,
|
267
|
+
sizeof (cairo_path_data_t) * path->num_data);
|
268
|
+
rb_path = TypedData_Wrap_Struct (rb_cCairo_Path,
|
269
|
+
&cr_path_type,
|
270
|
+
copied_path);
|
284
271
|
return rb_path;
|
285
272
|
}
|
286
273
|
else
|
@@ -292,7 +279,7 @@ rb_cairo_path_to_ruby_object (cairo_path_t *path)
|
|
292
279
|
static VALUE
|
293
280
|
cr_path_allocate (VALUE klass)
|
294
281
|
{
|
295
|
-
return
|
282
|
+
return TypedData_Wrap_Struct (klass, &cr_path_type, NULL);
|
296
283
|
}
|
297
284
|
|
298
285
|
static VALUE
|
@@ -300,13 +287,11 @@ cr_path_initialize (VALUE self)
|
|
300
287
|
{
|
301
288
|
cairo_path_t *path;
|
302
289
|
|
303
|
-
path =
|
290
|
+
path = RB_ALLOC (cairo_path_t);
|
304
291
|
path->status = CAIRO_STATUS_SUCCESS;
|
305
292
|
path->data = NULL;
|
306
293
|
path->num_data = 0;
|
307
|
-
|
308
294
|
DATA_PTR (self) = path;
|
309
|
-
cr_path_ensure_internal_context (self, path);
|
310
295
|
|
311
296
|
return Qnil;
|
312
297
|
}
|
@@ -5,7 +5,7 @@
|
|
5
5
|
* $Author: kou $
|
6
6
|
* $Date: 2008-06-12 10:59:54 $
|
7
7
|
*
|
8
|
-
* Copyright 2012-
|
8
|
+
* Copyright 2012-2022 Sutou Kouhei <kou@cozmixng.org>
|
9
9
|
* Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
|
10
10
|
* Copyright 2004-2005 MenTaLguY <mental@rydia.com>
|
11
11
|
*
|
@@ -133,6 +133,23 @@ cr_pattern_raster_source_supported_p (VALUE klass)
|
|
133
133
|
#endif
|
134
134
|
}
|
135
135
|
|
136
|
+
static void
|
137
|
+
cr_pattern_free (void *ptr)
|
138
|
+
{
|
139
|
+
cairo_pattern_destroy ((cairo_pattern_t *) ptr);
|
140
|
+
}
|
141
|
+
|
142
|
+
static const rb_data_type_t cr_pattern_type = {
|
143
|
+
"Cairo::Pattern",
|
144
|
+
{
|
145
|
+
NULL,
|
146
|
+
cr_pattern_free,
|
147
|
+
},
|
148
|
+
NULL,
|
149
|
+
NULL,
|
150
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
151
|
+
};
|
152
|
+
|
136
153
|
cairo_pattern_t *
|
137
154
|
rb_cairo_pattern_from_ruby_object (VALUE obj)
|
138
155
|
{
|
@@ -141,19 +158,10 @@ rb_cairo_pattern_from_ruby_object (VALUE obj)
|
|
141
158
|
{
|
142
159
|
rb_raise (rb_eTypeError, "not a cairo pattern");
|
143
160
|
}
|
144
|
-
|
161
|
+
TypedData_Get_Struct (obj, cairo_pattern_t, &cr_pattern_type, pattern);
|
145
162
|
return pattern;
|
146
163
|
}
|
147
164
|
|
148
|
-
static void
|
149
|
-
cr_pattern_free (void *ptr)
|
150
|
-
{
|
151
|
-
if (ptr)
|
152
|
-
{
|
153
|
-
cairo_pattern_destroy ((cairo_pattern_t *) ptr);
|
154
|
-
}
|
155
|
-
}
|
156
|
-
|
157
165
|
VALUE
|
158
166
|
rb_cairo_pattern_to_ruby_object (cairo_pattern_t *pattern)
|
159
167
|
{
|
@@ -162,7 +170,7 @@ rb_cairo_pattern_to_ruby_object (cairo_pattern_t *pattern)
|
|
162
170
|
VALUE klass;
|
163
171
|
klass = cr_pattern_get_klass (pattern);
|
164
172
|
cairo_pattern_reference (pattern);
|
165
|
-
return
|
173
|
+
return TypedData_Wrap_Struct (klass, &cr_pattern_type, pattern);
|
166
174
|
}
|
167
175
|
else
|
168
176
|
{
|
@@ -173,7 +181,7 @@ rb_cairo_pattern_to_ruby_object (cairo_pattern_t *pattern)
|
|
173
181
|
static VALUE
|
174
182
|
cr_pattern_allocate (VALUE klass)
|
175
183
|
{
|
176
|
-
return
|
184
|
+
return TypedData_Wrap_Struct (klass, &cr_pattern_type, NULL);
|
177
185
|
}
|
178
186
|
|
179
187
|
static VALUE
|
@@ -17,6 +17,8 @@
|
|
17
17
|
#endif
|
18
18
|
|
19
19
|
#ifdef CAIRO_HAS_QUARTZ_SURFACE
|
20
|
+
static ID cr_id_image_surface;
|
21
|
+
|
20
22
|
# ifndef HAVE_TYPE_ENUM_RUBY_VALUE_TYPE
|
21
23
|
enum ruby_value_type {
|
22
24
|
RUBY_T_DATA = T_DATA
|
@@ -168,6 +170,7 @@ cr_quartz_image_surface_initialize (VALUE self, VALUE image_surface)
|
|
168
170
|
surface = cairo_quartz_image_surface_create (RVAL2CRSURFACE (image_surface));
|
169
171
|
rb_cairo_surface_check_status (surface);
|
170
172
|
DATA_PTR (self) = surface;
|
173
|
+
rb_ivar_set (self, cr_id_image_surface, image_surface);
|
171
174
|
if (rb_block_given_p ())
|
172
175
|
rb_cairo__surface_yield_and_finish (self);
|
173
176
|
return Qnil;
|
@@ -199,6 +202,8 @@ Init_cairo_quartz_surface (void)
|
|
199
202
|
|
200
203
|
/* Quartz image surface */
|
201
204
|
#ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
|
205
|
+
cr_id_image_surface = rb_intern ("image_surface");
|
206
|
+
|
202
207
|
rb_define_method (rb_cCairo_QuartzImageSurface, "initialize",
|
203
208
|
cr_quartz_image_surface_initialize, 1);
|
204
209
|
rb_define_method (rb_cCairo_QuartzImageSurface, "image",
|
@@ -2,7 +2,7 @@
|
|
2
2
|
/*
|
3
3
|
* Ruby Cairo Binding
|
4
4
|
*
|
5
|
-
* Copyright 2005-
|
5
|
+
* Copyright 2005-2022 Sutou Kouhei <kou@cozmixng.org>
|
6
6
|
*
|
7
7
|
* This file is made available under the same terms as Ruby
|
8
8
|
*
|
@@ -15,10 +15,21 @@ VALUE rb_cCairo_Rectangle;
|
|
15
15
|
#define _SELF ((cairo_rectangle_int_t *)DATA_PTR (self))
|
16
16
|
|
17
17
|
#if CAIRO_CHECK_VERSION(1, 10, 0)
|
18
|
+
static const rb_data_type_t cr_rectangle_type = {
|
19
|
+
"Cairo::Rectangle",
|
20
|
+
{
|
21
|
+
NULL,
|
22
|
+
ruby_xfree,
|
23
|
+
},
|
24
|
+
NULL,
|
25
|
+
NULL,
|
26
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
27
|
+
};
|
28
|
+
|
18
29
|
static VALUE
|
19
30
|
cr_rectangle_allocate (VALUE klass)
|
20
31
|
{
|
21
|
-
return
|
32
|
+
return TypedData_Wrap_Struct (klass, &cr_rectangle_type, NULL);
|
22
33
|
}
|
23
34
|
|
24
35
|
static VALUE
|
data/ext/cairo/rb_cairo_region.c
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
/*
|
3
3
|
* Ruby Cairo Binding
|
4
4
|
*
|
5
|
-
* Copyright 2010 Kouhei
|
5
|
+
* Copyright 2010-2022 Sutou Kouhei <kou@cozmixng.org>
|
6
6
|
*
|
7
7
|
* This file is made available under the same terms as Ruby
|
8
8
|
*
|
@@ -18,6 +18,23 @@ VALUE rb_cCairo_Region = Qnil;
|
|
18
18
|
|
19
19
|
#define _SELF (RVAL2CRREGION(self))
|
20
20
|
|
21
|
+
static void
|
22
|
+
cr_region_free (void *ptr)
|
23
|
+
{
|
24
|
+
cairo_region_destroy ((cairo_region_t *) ptr);
|
25
|
+
}
|
26
|
+
|
27
|
+
static const rb_data_type_t cr_region_type = {
|
28
|
+
"Cairo::Region",
|
29
|
+
{
|
30
|
+
NULL,
|
31
|
+
cr_region_free,
|
32
|
+
},
|
33
|
+
NULL,
|
34
|
+
NULL,
|
35
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
36
|
+
};
|
37
|
+
|
21
38
|
static inline void
|
22
39
|
cr_region_check_status (cairo_region_t *region)
|
23
40
|
{
|
@@ -32,26 +49,17 @@ rb_cairo_region_from_ruby_object (VALUE obj)
|
|
32
49
|
{
|
33
50
|
rb_raise (rb_eTypeError, "not a cairo region");
|
34
51
|
}
|
35
|
-
|
52
|
+
TypedData_Get_Struct (obj, cairo_region_t, &cr_region_type, region);
|
36
53
|
return region;
|
37
54
|
}
|
38
55
|
|
39
|
-
static void
|
40
|
-
cr_region_free (void *ptr)
|
41
|
-
{
|
42
|
-
if (ptr)
|
43
|
-
{
|
44
|
-
cairo_region_destroy ((cairo_region_t *) ptr);
|
45
|
-
}
|
46
|
-
}
|
47
|
-
|
48
56
|
VALUE
|
49
57
|
rb_cairo_region_to_ruby_object (cairo_region_t *region)
|
50
58
|
{
|
51
59
|
if (region)
|
52
60
|
{
|
53
61
|
cairo_region_reference (region);
|
54
|
-
return
|
62
|
+
return TypedData_Wrap_Struct (rb_cCairo_Region, &cr_region_type, region);
|
55
63
|
}
|
56
64
|
else
|
57
65
|
{
|
@@ -62,7 +70,7 @@ rb_cairo_region_to_ruby_object (cairo_region_t *region)
|
|
62
70
|
static VALUE
|
63
71
|
cr_region_allocate (VALUE klass)
|
64
72
|
{
|
65
|
-
return
|
73
|
+
return TypedData_Wrap_Struct (klass, &cr_region_type, NULL);
|
66
74
|
}
|
67
75
|
|
68
76
|
static VALUE
|
@@ -5,7 +5,7 @@
|
|
5
5
|
* $Author: kou $
|
6
6
|
* $Date: 2008-09-19 12:56:27 $
|
7
7
|
*
|
8
|
-
* Copyright 2005-
|
8
|
+
* Copyright 2005-2022 Sutou Kouhei <kou@cozmixng.org>
|
9
9
|
*
|
10
10
|
* This file is made available under the same terms as Ruby
|
11
11
|
*
|
@@ -19,6 +19,23 @@ VALUE rb_cCairo_ScaledFont;
|
|
19
19
|
|
20
20
|
#define _SELF(self) (RVAL2CRSCALEDFONT(self))
|
21
21
|
|
22
|
+
static void
|
23
|
+
cr_scaled_font_free (void *ptr)
|
24
|
+
{
|
25
|
+
cairo_scaled_font_destroy ((cairo_scaled_font_t *) ptr);
|
26
|
+
}
|
27
|
+
|
28
|
+
static const rb_data_type_t cr_scaled_font_type = {
|
29
|
+
"Cairo::ScaledFont",
|
30
|
+
{
|
31
|
+
NULL,
|
32
|
+
cr_scaled_font_free,
|
33
|
+
},
|
34
|
+
NULL,
|
35
|
+
NULL,
|
36
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
37
|
+
};
|
38
|
+
|
22
39
|
static inline void
|
23
40
|
cr_scaled_font_check_status (cairo_scaled_font_t *font)
|
24
41
|
{
|
@@ -33,27 +50,19 @@ rb_cairo_scaled_font_from_ruby_object (VALUE obj)
|
|
33
50
|
{
|
34
51
|
rb_raise (rb_eTypeError, "not a cairo scaled font");
|
35
52
|
}
|
36
|
-
|
53
|
+
TypedData_Get_Struct (obj, cairo_scaled_font_t, &cr_scaled_font_type, font);
|
37
54
|
return font;
|
38
55
|
}
|
39
56
|
|
40
|
-
static void
|
41
|
-
cr_scaled_font_free (void *ptr)
|
42
|
-
{
|
43
|
-
if (ptr)
|
44
|
-
{
|
45
|
-
cairo_scaled_font_destroy ((cairo_scaled_font_t *) ptr);
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
57
|
VALUE
|
50
58
|
rb_cairo_scaled_font_to_ruby_object (cairo_scaled_font_t *font)
|
51
59
|
{
|
52
60
|
if (font)
|
53
61
|
{
|
54
62
|
cairo_scaled_font_reference (font);
|
55
|
-
return
|
56
|
-
|
63
|
+
return TypedData_Wrap_Struct (rb_cCairo_ScaledFont,
|
64
|
+
&cr_scaled_font_type,
|
65
|
+
font);
|
57
66
|
}
|
58
67
|
else
|
59
68
|
{
|
@@ -64,7 +73,7 @@ rb_cairo_scaled_font_to_ruby_object (cairo_scaled_font_t *font)
|
|
64
73
|
static VALUE
|
65
74
|
cr_scaled_font_allocate (VALUE klass)
|
66
75
|
{
|
67
|
-
return
|
76
|
+
return TypedData_Wrap_Struct (klass, &cr_scaled_font_type, NULL);
|
68
77
|
}
|
69
78
|
|
70
79
|
static VALUE
|