rmagick 4.2.2 → 5.3.0
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/.devcontainer/Dockerfile +14 -0
- data/.devcontainer/ImageMagick6/devcontainer.json +11 -0
- data/.devcontainer/devcontainer.json +11 -0
- data/.devcontainer/setup-repo.sh +10 -0
- data/.devcontainer/setup-user.sh +45 -0
- data/.github/workflows/ci.yml +55 -24
- data/.gitignore +2 -0
- data/.rubocop_todo.yml +0 -1
- data/CHANGELOG.md +93 -0
- data/README.md +8 -16
- data/Rakefile +53 -81
- data/before_install_linux.sh +4 -4
- data/before_install_osx.sh +7 -6
- data/ext/RMagick/extconf.rb +81 -37
- data/ext/RMagick/rmagick.h +29 -20
- data/ext/RMagick/rmagick_gvl.h +224 -0
- data/ext/RMagick/rmdraw.c +140 -127
- data/ext/RMagick/rmenum.c +34 -15
- data/ext/RMagick/rmfill.c +77 -16
- data/ext/RMagick/rmilist.c +163 -74
- data/ext/RMagick/rmimage.c +1130 -630
- data/ext/RMagick/rminfo.c +109 -121
- data/ext/RMagick/rmkinfo.c +43 -13
- data/ext/RMagick/rmmain.c +15 -11
- data/ext/RMagick/rmmontage.c +45 -24
- data/ext/RMagick/rmpixel.c +66 -42
- data/ext/RMagick/rmstruct.c +6 -6
- data/ext/RMagick/rmutil.c +29 -88
- data/lib/rmagick/version.rb +3 -1
- data/lib/rmagick.rb +2 -0
- data/lib/rmagick_internal.rb +9 -48
- data/lib/rvg/rvg.rb +2 -2
- data/rmagick.gemspec +6 -6
- metadata +25 -8
- data/.codeclimate.yml +0 -63
- data/deprecated/RMagick.rb +0 -6
data/ext/RMagick/rmenum.c
CHANGED
@@ -18,9 +18,15 @@
|
|
18
18
|
|
19
19
|
static VALUE Enum_type_values(VALUE);
|
20
20
|
static VALUE Enum_type_inspect(VALUE);
|
21
|
+
static void rm_enum_free(void *magick_enum);
|
22
|
+
static size_t rm_enum_memsize(const void *magick_enum);
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
const rb_data_type_t rm_enum_data_type = {
|
25
|
+
"Magick::Enum",
|
26
|
+
{ NULL, rm_enum_free, rm_enum_memsize, },
|
27
|
+
0, 0,
|
28
|
+
RUBY_TYPED_FROZEN_SHAREABLE,
|
29
|
+
};
|
24
30
|
|
25
31
|
|
26
32
|
/**
|
@@ -78,7 +84,7 @@ rm_enum_to_cstr(VALUE enum_type)
|
|
78
84
|
{
|
79
85
|
MagickEnum *magick_enum;
|
80
86
|
|
81
|
-
|
87
|
+
TypedData_Get_Struct(enum_type, MagickEnum, &rm_enum_data_type, magick_enum);
|
82
88
|
return rb_id2name(magick_enum->id);
|
83
89
|
}
|
84
90
|
|
@@ -93,6 +99,19 @@ static void rm_enum_free(void *magick_enum)
|
|
93
99
|
{
|
94
100
|
xfree(magick_enum);
|
95
101
|
}
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Get Enum object size.
|
105
|
+
*
|
106
|
+
* No Ruby usage (internal function)
|
107
|
+
*
|
108
|
+
* @param magick_enum the enum
|
109
|
+
*/
|
110
|
+
static size_t rm_enum_memsize(const void *magick_enum)
|
111
|
+
{
|
112
|
+
return sizeof(MagickEnum);
|
113
|
+
}
|
114
|
+
|
96
115
|
/**
|
97
116
|
* Enum class alloc function.
|
98
117
|
*
|
@@ -104,7 +123,7 @@ Enum_alloc(VALUE class)
|
|
104
123
|
MagickEnum *magick_enum;
|
105
124
|
VALUE enumr;
|
106
125
|
|
107
|
-
enumr =
|
126
|
+
enumr = TypedData_Make_Struct(class, MagickEnum, &rm_enum_data_type, magick_enum);
|
108
127
|
rb_obj_freeze(enumr);
|
109
128
|
|
110
129
|
return enumr;
|
@@ -124,8 +143,8 @@ Enum_case_eq(VALUE self, VALUE other)
|
|
124
143
|
{
|
125
144
|
MagickEnum *this, *that;
|
126
145
|
|
127
|
-
|
128
|
-
|
146
|
+
TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, this);
|
147
|
+
TypedData_Get_Struct(other, MagickEnum, &rm_enum_data_type, that);
|
129
148
|
return this->val == that->val ? Qtrue : Qfalse;
|
130
149
|
}
|
131
150
|
|
@@ -145,7 +164,7 @@ Enum_initialize(VALUE self, VALUE sym, VALUE val)
|
|
145
164
|
{
|
146
165
|
MagickEnum *magick_enum;
|
147
166
|
|
148
|
-
|
167
|
+
TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, magick_enum);
|
149
168
|
magick_enum->id = rb_to_id(sym); /* convert symbol to ID */
|
150
169
|
magick_enum->val = NUM2INT(val);
|
151
170
|
|
@@ -163,7 +182,7 @@ Enum_to_i(VALUE self)
|
|
163
182
|
{
|
164
183
|
MagickEnum *magick_enum;
|
165
184
|
|
166
|
-
|
185
|
+
TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, magick_enum);
|
167
186
|
return INT2NUM(magick_enum->val);
|
168
187
|
}
|
169
188
|
|
@@ -183,8 +202,8 @@ Enum_spaceship(VALUE self, VALUE other)
|
|
183
202
|
return Qnil;
|
184
203
|
}
|
185
204
|
|
186
|
-
|
187
|
-
|
205
|
+
TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, this);
|
206
|
+
TypedData_Get_Struct(other, MagickEnum, &rm_enum_data_type, that);
|
188
207
|
|
189
208
|
if (this->val > that->val)
|
190
209
|
{
|
@@ -218,9 +237,9 @@ Enum_bitwise_or(VALUE self, VALUE another)
|
|
218
237
|
|
219
238
|
new_enum = Enum_alloc(cls);
|
220
239
|
|
221
|
-
|
222
|
-
|
223
|
-
|
240
|
+
TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, this);
|
241
|
+
TypedData_Get_Struct(another, MagickEnum, &rm_enum_data_type, that);
|
242
|
+
TypedData_Get_Struct(new_enum, MagickEnum, &rm_enum_data_type, new_enum_data);
|
224
243
|
|
225
244
|
new_enum_data->id = rb_to_id(rb_sprintf("%s|%s", rb_id2name(this->id), rb_id2name(that->id)));
|
226
245
|
new_enum_data->val = this->val | that->val;
|
@@ -282,7 +301,7 @@ Enum_type_inspect(VALUE self)
|
|
282
301
|
char str[100];
|
283
302
|
MagickEnum *magick_enum;
|
284
303
|
|
285
|
-
|
304
|
+
TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, magick_enum);
|
286
305
|
snprintf(str, sizeof(str), "%.48s=%d", rb_id2name(magick_enum->id), magick_enum->val);
|
287
306
|
|
288
307
|
return rb_str_new2(str);
|
@@ -359,7 +378,7 @@ Enum_find(VALUE class, int val)
|
|
359
378
|
for (x = 0; x < RARRAY_LEN(enumerators); x++)
|
360
379
|
{
|
361
380
|
VALUE enumerator = rb_ary_entry(enumerators, x);
|
362
|
-
|
381
|
+
TypedData_Get_Struct(enumerator, MagickEnum, &rm_enum_data_type, magick_enum);
|
363
382
|
if (magick_enum->val == val)
|
364
383
|
{
|
365
384
|
return enumerator;
|
data/ext/RMagick/rmfill.c
CHANGED
@@ -12,6 +12,11 @@
|
|
12
12
|
|
13
13
|
#include "rmagick.h"
|
14
14
|
|
15
|
+
static void GradientFill_free(void *fill);
|
16
|
+
static size_t GradientFill_memsize(const void *ptr);
|
17
|
+
static void TextureFill_free(void *fill_obj);
|
18
|
+
static size_t TextureFill_memsize(const void *ptr);
|
19
|
+
|
15
20
|
/** Data associated with a GradientFill */
|
16
21
|
typedef struct
|
17
22
|
{
|
@@ -29,18 +34,52 @@ typedef struct
|
|
29
34
|
Image *texture; /**< the texture */
|
30
35
|
} rm_TextureFill;
|
31
36
|
|
37
|
+
const rb_data_type_t rm_gradient_fill_data_type = {
|
38
|
+
"Magick::GradientFill",
|
39
|
+
{ NULL, GradientFill_free, GradientFill_memsize, },
|
40
|
+
0, 0,
|
41
|
+
RUBY_TYPED_FROZEN_SHAREABLE,
|
42
|
+
};
|
43
|
+
|
44
|
+
const rb_data_type_t rm_texture_fill_data_type = {
|
45
|
+
"Magick::TextureFill",
|
46
|
+
{ NULL, TextureFill_free, TextureFill_memsize, },
|
47
|
+
0, 0,
|
48
|
+
RUBY_TYPED_FROZEN_SHAREABLE,
|
49
|
+
};
|
50
|
+
|
51
|
+
|
52
|
+
DEFINE_GVL_STUB2(SyncAuthenticPixels, Image *, ExceptionInfo *);
|
53
|
+
|
54
|
+
|
32
55
|
/**
|
33
|
-
* Free
|
56
|
+
* Free GradientFill or GradientFill subclass object (except for TextureFill).
|
34
57
|
*
|
35
58
|
* No Ruby usage (internal function)
|
36
59
|
*
|
37
60
|
* @param fill the fill
|
38
61
|
*/
|
39
|
-
static void
|
62
|
+
static void
|
63
|
+
GradientFill_free(void *fill)
|
40
64
|
{
|
41
65
|
xfree(fill);
|
42
66
|
}
|
43
67
|
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Get GradientFill object size.
|
71
|
+
*
|
72
|
+
* No Ruby usage (internal function)
|
73
|
+
*
|
74
|
+
* @param ptr pointer to the GradientFill object
|
75
|
+
*/
|
76
|
+
static size_t
|
77
|
+
GradientFill_memsize(const void *ptr)
|
78
|
+
{
|
79
|
+
return sizeof(rm_GradientFill);
|
80
|
+
}
|
81
|
+
|
82
|
+
|
44
83
|
/**
|
45
84
|
* Create new GradientFill object.
|
46
85
|
*
|
@@ -51,7 +90,7 @@ GradientFill_alloc(VALUE class)
|
|
51
90
|
{
|
52
91
|
rm_GradientFill *fill;
|
53
92
|
|
54
|
-
return
|
93
|
+
return TypedData_Make_Struct(class, rm_GradientFill, &rm_gradient_fill_data_type, fill);
|
55
94
|
}
|
56
95
|
|
57
96
|
|
@@ -78,7 +117,7 @@ GradientFill_initialize(
|
|
78
117
|
{
|
79
118
|
rm_GradientFill *fill;
|
80
119
|
|
81
|
-
|
120
|
+
TypedData_Get_Struct(self, rm_GradientFill, &rm_gradient_fill_data_type, fill);
|
82
121
|
|
83
122
|
fill->x1 = NUM2DBL(x1);
|
84
123
|
fill->y1 = NUM2DBL(y1);
|
@@ -153,7 +192,8 @@ point_fill(
|
|
153
192
|
#endif
|
154
193
|
}
|
155
194
|
|
156
|
-
SyncAuthenticPixels
|
195
|
+
GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
|
196
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
|
157
197
|
CHECK_EXCEPTION();
|
158
198
|
}
|
159
199
|
|
@@ -222,7 +262,8 @@ vertical_fill(
|
|
222
262
|
row_pixels += GetPixelChannels(image);
|
223
263
|
}
|
224
264
|
|
225
|
-
SyncAuthenticPixels
|
265
|
+
GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
|
266
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
|
226
267
|
CHECK_EXCEPTION();
|
227
268
|
}
|
228
269
|
|
@@ -255,7 +296,8 @@ vertical_fill(
|
|
255
296
|
|
256
297
|
memcpy(row_pixels, master, image->columns * sizeof(PixelPacket));
|
257
298
|
|
258
|
-
SyncAuthenticPixels
|
299
|
+
GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
|
300
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
|
259
301
|
if (rm_should_raise_exception(exception, RetainExceptionRetention))
|
260
302
|
{
|
261
303
|
xfree((void *)master);
|
@@ -328,7 +370,8 @@ horizontal_fill(
|
|
328
370
|
row_pixels += GetPixelChannels(image);
|
329
371
|
}
|
330
372
|
|
331
|
-
SyncAuthenticPixels
|
373
|
+
GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
|
374
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
|
332
375
|
CHECK_EXCEPTION();
|
333
376
|
}
|
334
377
|
|
@@ -360,7 +403,8 @@ horizontal_fill(
|
|
360
403
|
|
361
404
|
memcpy(col_pixels, master, image->rows * sizeof(PixelPacket));
|
362
405
|
|
363
|
-
SyncAuthenticPixels
|
406
|
+
GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
|
407
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
|
364
408
|
if (rm_should_raise_exception(exception, RetainExceptionRetention))
|
365
409
|
{
|
366
410
|
xfree((void *)master);
|
@@ -471,7 +515,8 @@ v_diagonal_fill(
|
|
471
515
|
#endif
|
472
516
|
}
|
473
517
|
|
474
|
-
SyncAuthenticPixels
|
518
|
+
GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
|
519
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
|
475
520
|
CHECK_EXCEPTION();
|
476
521
|
}
|
477
522
|
|
@@ -577,7 +622,8 @@ h_diagonal_fill(
|
|
577
622
|
#endif
|
578
623
|
}
|
579
624
|
|
580
|
-
SyncAuthenticPixels
|
625
|
+
GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
|
626
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
|
581
627
|
CHECK_EXCEPTION();
|
582
628
|
}
|
583
629
|
|
@@ -599,7 +645,7 @@ GradientFill_fill(VALUE self, VALUE image_obj)
|
|
599
645
|
PixelColor start_color, stop_color;
|
600
646
|
double x1, y1, x2, y2; // points on the line
|
601
647
|
|
602
|
-
|
648
|
+
TypedData_Get_Struct(self, rm_GradientFill, &rm_gradient_fill_data_type, fill);
|
603
649
|
image = rm_check_destroyed(image_obj);
|
604
650
|
|
605
651
|
x1 = fill->x1;
|
@@ -662,7 +708,7 @@ GradientFill_fill(VALUE self, VALUE image_obj)
|
|
662
708
|
* @param fill_obj the TextureFill
|
663
709
|
*/
|
664
710
|
static void
|
665
|
-
|
711
|
+
TextureFill_free(void *fill_obj)
|
666
712
|
{
|
667
713
|
rm_TextureFill *fill = (rm_TextureFill *)fill_obj;
|
668
714
|
|
@@ -674,6 +720,21 @@ free_TextureFill(void *fill_obj)
|
|
674
720
|
xfree(fill);
|
675
721
|
}
|
676
722
|
|
723
|
+
|
724
|
+
/**
|
725
|
+
* Get TextureFill object size.
|
726
|
+
*
|
727
|
+
* No Ruby usage (internal function)
|
728
|
+
*
|
729
|
+
* @param ptr pointer to the TextureFill object
|
730
|
+
*/
|
731
|
+
static size_t
|
732
|
+
TextureFill_memsize(const void *ptr)
|
733
|
+
{
|
734
|
+
return sizeof(rm_TextureFill);
|
735
|
+
}
|
736
|
+
|
737
|
+
|
677
738
|
/**
|
678
739
|
* Create new TextureFill object.
|
679
740
|
*
|
@@ -683,7 +744,7 @@ VALUE
|
|
683
744
|
TextureFill_alloc(VALUE class)
|
684
745
|
{
|
685
746
|
rm_TextureFill *fill;
|
686
|
-
return
|
747
|
+
return TypedData_Make_Struct(class, rm_TextureFill, &rm_texture_fill_data_type, fill);
|
687
748
|
}
|
688
749
|
|
689
750
|
/**
|
@@ -700,7 +761,7 @@ TextureFill_initialize(VALUE self, VALUE texture_arg)
|
|
700
761
|
Image *texture;
|
701
762
|
VALUE texture_image;
|
702
763
|
|
703
|
-
|
764
|
+
TypedData_Get_Struct(self, rm_TextureFill, &rm_texture_fill_data_type, fill);
|
704
765
|
|
705
766
|
texture_image = rm_cur_image(texture_arg);
|
706
767
|
|
@@ -732,7 +793,7 @@ TextureFill_fill(VALUE self, VALUE image_obj)
|
|
732
793
|
#endif
|
733
794
|
|
734
795
|
image = rm_check_destroyed(image_obj);
|
735
|
-
|
796
|
+
TypedData_Get_Struct(self, rm_TextureFill, &rm_texture_fill_data_type, fill);
|
736
797
|
|
737
798
|
#if defined(IMAGEMAGICK_7)
|
738
799
|
exception = AcquireExceptionInfo();
|