rmagick 5.0.0 → 5.1.0

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

Potentially problematic release.


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

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 Fill or Fill subclass object (except for TextureFill).
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 free_Fill(void *fill)
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 Data_Make_Struct(class, rm_GradientFill, NULL, free_Fill, fill);
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
- Data_Get_Struct(self, rm_GradientFill, fill);
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(image, exception);
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(image, exception);
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(image, exception);
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(image, exception);
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(image, exception);
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(image, exception);
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(image, exception);
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
- Data_Get_Struct(self, rm_GradientFill, fill);
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
- free_TextureFill(void *fill_obj)
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 Data_Make_Struct(class, rm_TextureFill, NULL, free_TextureFill, fill);
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
- Data_Get_Struct(self, rm_TextureFill, fill);
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
- Data_Get_Struct(self, rm_TextureFill, fill);
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();
@@ -20,7 +20,39 @@ static void imagelist_push(VALUE, VALUE);
20
20
  static VALUE ImageList_new(void);
21
21
 
22
22
 
23
+ DEFINE_GVL_STUB3(AppendImages, const Image *, const MagickBooleanType, ExceptionInfo *);
24
+ DEFINE_GVL_STUB5(CloneImage, const Image *, const size_t, const size_t, const MagickBooleanType, ExceptionInfo *);
25
+ DEFINE_GVL_STUB2(CloneImageList, const Image *, ExceptionInfo *);
26
+ DEFINE_GVL_STUB2(CoalesceImages, const Image *, ExceptionInfo *);
27
+ DEFINE_GVL_STUB2(DisposeImages, const Image *, ExceptionInfo *);
28
+ DEFINE_GVL_STUB3(EvaluateImages, const Image *, const MagickEvaluateOperator, ExceptionInfo *);
29
+ DEFINE_GVL_STUB4(ImagesToBlob, const ImageInfo *, Image *, size_t *, ExceptionInfo *);
30
+ DEFINE_GVL_STUB3(MergeImageLayers, Image *, const LayerMethod, ExceptionInfo *);
31
+ DEFINE_GVL_STUB3(MontageImages, const Image *, const MontageInfo *, ExceptionInfo *);
32
+ DEFINE_GVL_STUB3(MorphImages, const Image *, const size_t, ExceptionInfo *);
33
+ DEFINE_GVL_STUB2(OptimizeImageLayers, const Image *, ExceptionInfo *);
34
+ DEFINE_GVL_STUB2(OptimizePlusImageLayers, const Image *, ExceptionInfo *);
35
+ #if defined(IMAGEMAGICK_7)
36
+ DEFINE_GVL_STUB3(AnimateImages, const ImageInfo *, Image *, ExceptionInfo *);
37
+ DEFINE_GVL_STUB3(CombineImages, const Image *, const ColorspaceType, ExceptionInfo *);
38
+ DEFINE_GVL_STUB3(CompareImagesLayers, const Image *, const LayerMethod, ExceptionInfo *);
39
+ DEFINE_GVL_STUB3(QuantizeImages, const QuantizeInfo *, Image *, ExceptionInfo *);
40
+ DEFINE_GVL_STUB4(RemapImages, const QuantizeInfo *, Image *, const Image *, ExceptionInfo *);
41
+ DEFINE_GVL_STUB3(WriteImage, const ImageInfo *, Image *, ExceptionInfo *);
42
+ #else
43
+ DEFINE_GVL_STUB2(AnimateImages, const ImageInfo *, Image *);
44
+ DEFINE_GVL_STUB3(CombineImages, const Image *, const ChannelType, ExceptionInfo *);
45
+ DEFINE_GVL_STUB3(CompareImageLayers, const Image *, const ImageLayerMethod, ExceptionInfo *);
46
+ DEFINE_GVL_STUB2(DeconstructImages, const Image *, ExceptionInfo *);
47
+ DEFINE_GVL_STUB2(QuantizeImages, const QuantizeInfo *, Image *);
48
+ DEFINE_GVL_STUB3(RemapImages, const QuantizeInfo *, Image *, const Image *);
49
+ DEFINE_GVL_STUB2(WriteImage, const ImageInfo *, Image *);
50
+ #endif
23
51
 
52
+ DEFINE_GVL_VOID_STUB6(CompositeLayers, Image *, const CompositeOperator, Image *, const ssize_t, const ssize_t, ExceptionInfo *);
53
+ DEFINE_GVL_VOID_STUB2(OptimizeImageTransparency, const Image *, ExceptionInfo *);
54
+ DEFINE_GVL_VOID_STUB2(RemoveDuplicateLayers, Image **, ExceptionInfo *);
55
+ DEFINE_GVL_VOID_STUB2(RemoveZeroDelayLayers, Image **, ExceptionInfo *);
24
56
 
25
57
 
26
58
  /**
@@ -72,15 +104,17 @@ ImageList_animate(int argc, VALUE *argv, VALUE self)
72
104
  }
73
105
  }
74
106
 
75
- Data_Get_Struct(info_obj, Info, info);
107
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
76
108
  #if defined(IMAGEMAGICK_7)
77
109
  exception = AcquireExceptionInfo();
78
- AnimateImages(info, images, exception);
110
+ GVL_STRUCT_TYPE(AnimateImages) args = { info, images, exception };
111
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AnimateImages), &args);
79
112
  rm_split(images);
80
113
  CHECK_EXCEPTION();
81
114
  DestroyExceptionInfo(exception);
82
115
  #else
83
- AnimateImages(info, images);
116
+ GVL_STRUCT_TYPE(AnimateImages) args = { info, images };
117
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AnimateImages), &args);
84
118
  rm_split(images);
85
119
  rm_check_image_exception(images, RetainOnError);
86
120
  #endif
@@ -112,7 +146,8 @@ ImageList_append(VALUE self, VALUE stack_arg)
112
146
  stack = RTEST(stack_arg);
113
147
 
114
148
  exception = AcquireExceptionInfo();
115
- new_image = AppendImages(images, stack, exception);
149
+ GVL_STRUCT_TYPE(AppendImages) args = { images, stack, exception };
150
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AppendImages), &args);
116
151
  rm_split(images);
117
152
  rm_check_exception(exception, new_image, DestroyOnError);
118
153
  DestroyExceptionInfo(exception);
@@ -136,8 +171,8 @@ ImageList_average(VALUE self)
136
171
  images = images_from_imagelist(self);
137
172
 
138
173
  exception = AcquireExceptionInfo();
139
- new_image = EvaluateImages(images, MeanEvaluateOperator, exception);
140
-
174
+ GVL_STRUCT_TYPE(EvaluateImages) args = { images, MeanEvaluateOperator, exception };
175
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EvaluateImages), &args);
141
176
  rm_split(images);
142
177
  rm_check_exception(exception, new_image, DestroyOnError);
143
178
  DestroyExceptionInfo(exception);
@@ -164,7 +199,8 @@ ImageList_coalesce(VALUE self)
164
199
  images = images_from_imagelist(self);
165
200
 
166
201
  exception = AcquireExceptionInfo();
167
- new_images = CoalesceImages(images, exception);
202
+ GVL_STRUCT_TYPE(CoalesceImages) args = { images, exception };
203
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CoalesceImages), &args);
168
204
  rm_split(images);
169
205
  rm_check_exception(exception, new_images, DestroyOnError);
170
206
  DestroyExceptionInfo(exception);
@@ -252,10 +288,11 @@ VALUE ImageList_combine(int argc, VALUE *argv, VALUE self)
252
288
  #if defined(IMAGEMAGICK_6)
253
289
  old_colorspace = images->colorspace;
254
290
  SetImageColorspace(images, colorspace);
255
- new_image = CombineImages(images, channel, exception);
291
+ GVL_STRUCT_TYPE(CombineImages) args = { images, channel, exception };
256
292
  #else
257
- new_image = CombineImages(images, colorspace, exception);
293
+ GVL_STRUCT_TYPE(CombineImages) args = { images, colorspace, exception };
258
294
  #endif
295
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CombineImages), &args);
259
296
 
260
297
  rm_split(images);
261
298
  #if defined(IMAGEMAGICK_6)
@@ -319,7 +356,8 @@ ImageList_composite_layers(int argc, VALUE *argv, VALUE self)
319
356
  new_images->gravity, &geometry);
320
357
 
321
358
  exception = AcquireExceptionInfo();
322
- CompositeLayers(new_images, operator, source, geometry.x, geometry.y, exception);
359
+ GVL_STRUCT_TYPE(CompositeLayers) args = { new_images, operator, source, geometry.x, geometry.y, exception };
360
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeLayers), &args);
323
361
  rm_split(source);
324
362
  rm_check_exception(exception, new_images, DestroyOnError);
325
363
  DestroyExceptionInfo(exception);
@@ -345,9 +383,11 @@ ImageList_deconstruct(VALUE self)
345
383
  images = images_from_imagelist(self);
346
384
  exception = AcquireExceptionInfo();
347
385
  #if defined(IMAGEMAGICK_7)
348
- new_images = CompareImagesLayers(images, CompareAnyLayer, exception);
386
+ GVL_STRUCT_TYPE(CompareImagesLayers) args = { images, CompareAnyLayer, exception };
387
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompareImagesLayers), &args);
349
388
  #else
350
- new_images = DeconstructImages(images, exception);
389
+ GVL_STRUCT_TYPE(DeconstructImages) args = { images, exception };
390
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(DeconstructImages), &args);
351
391
  #endif
352
392
  rm_split(images);
353
393
  rm_check_exception(exception, new_images, DestroyOnError);
@@ -374,7 +414,7 @@ ImageList_display(VALUE self)
374
414
 
375
415
  // Create a new Info object to use with this call
376
416
  info_obj = rm_info_new();
377
- Data_Get_Struct(info_obj, Info, info);
417
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
378
418
 
379
419
  // Convert the images array to an images sequence.
380
420
  images = images_from_imagelist(self);
@@ -410,7 +450,8 @@ ImageList_flatten_images(VALUE self)
410
450
  images = images_from_imagelist(self);
411
451
  exception = AcquireExceptionInfo();
412
452
 
413
- new_image = MergeImageLayers(images, FlattenLayer, exception);
453
+ GVL_STRUCT_TYPE(MergeImageLayers) args = { images, FlattenLayer, exception };
454
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(MergeImageLayers), &args);
414
455
 
415
456
  rm_split(images);
416
457
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -447,7 +488,7 @@ ImageList_montage(VALUE self)
447
488
  rb_yield(montage_obj);
448
489
  }
449
490
 
450
- Data_Get_Struct(montage_obj, Montage, montage);
491
+ TypedData_Get_Struct(montage_obj, Montage, &rm_montage_data_type, montage);
451
492
 
452
493
  images = images_from_imagelist(self);
453
494
 
@@ -466,7 +507,8 @@ ImageList_montage(VALUE self)
466
507
  exception = AcquireExceptionInfo();
467
508
 
468
509
  // MontageImage can return more than one image.
469
- new_images = MontageImages(images, montage->info, exception);
510
+ GVL_STRUCT_TYPE(MontageImages) args = { images, montage->info, exception };
511
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(MontageImages), &args);
470
512
  rm_split(images);
471
513
  rm_check_exception(exception, new_images, DestroyOnError);
472
514
  DestroyExceptionInfo(exception);
@@ -502,7 +544,8 @@ ImageList_morph(VALUE self, VALUE nimages)
502
544
 
503
545
  images = images_from_imagelist(self);
504
546
  exception = AcquireExceptionInfo();
505
- new_images = MorphImages(images, (unsigned long)number_images, exception);
547
+ GVL_STRUCT_TYPE(MorphImages) args = { images, number_images, exception };
548
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(MorphImages), &args);
506
549
  rm_split(images);
507
550
  rm_check_exception(exception, new_images, DestroyOnError);
508
551
  DestroyExceptionInfo(exception);
@@ -525,7 +568,8 @@ ImageList_mosaic(VALUE self)
525
568
  images = images_from_imagelist(self);
526
569
 
527
570
  exception = AcquireExceptionInfo();
528
- new_image = MergeImageLayers(images, MosaicLayer, exception);
571
+ GVL_STRUCT_TYPE(MergeImageLayers) args = { images, MosaicLayer, exception };
572
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(MergeImageLayers), &args);
529
573
 
530
574
  rm_split(images);
531
575
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -559,22 +603,37 @@ ImageList_optimize_layers(VALUE self, VALUE method)
559
603
  switch (mthd)
560
604
  {
561
605
  case CoalesceLayer:
562
- new_images = CoalesceImages(images, exception);
606
+ {
607
+ GVL_STRUCT_TYPE(CoalesceImages) args = { images, exception };
608
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CoalesceImages), &args);
609
+ }
563
610
  break;
564
611
  case DisposeLayer:
565
- new_images = DisposeImages(images, exception);
612
+ {
613
+ GVL_STRUCT_TYPE(DisposeImages) args = { images, exception };
614
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(DisposeImages), &args);
615
+ }
566
616
  break;
567
617
  case OptimizeTransLayer:
568
- new_images = clone_imagelist(images);
569
- OptimizeImageTransparency(new_images, exception);
618
+ {
619
+ new_images = clone_imagelist(images);
620
+ GVL_STRUCT_TYPE(OptimizeImageTransparency) args = { new_images, exception };
621
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OptimizeImageTransparency), &args);
622
+ }
570
623
  break;
571
624
  case RemoveDupsLayer:
572
- new_images = clone_imagelist(images);
573
- RemoveDuplicateLayers(&new_images, exception);
625
+ {
626
+ new_images = clone_imagelist(images);
627
+ GVL_STRUCT_TYPE(RemoveDuplicateLayers) args = { &new_images, exception };
628
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RemoveDuplicateLayers), &args);
629
+ }
574
630
  break;
575
631
  case RemoveZeroLayer:
576
- new_images = clone_imagelist(images);
577
- RemoveZeroDelayLayers(&new_images, exception);
632
+ {
633
+ new_images = clone_imagelist(images);
634
+ GVL_STRUCT_TYPE(RemoveZeroDelayLayers) args = { &new_images, exception };
635
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RemoveZeroDelayLayers), &args);
636
+ }
578
637
  break;
579
638
  case CompositeLayer:
580
639
  rm_split(images);
@@ -583,50 +642,81 @@ ImageList_optimize_layers(VALUE self, VALUE method)
583
642
  break;
584
643
  // In 6.3.4-ish, OptimizeImageLayer replaced OptimizeLayer
585
644
  case OptimizeImageLayer:
586
- new_images = OptimizeImageLayers(images, exception);
645
+ {
646
+ GVL_STRUCT_TYPE(OptimizeImageLayers) args = { images, exception };
647
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OptimizeImageLayers), &args);
648
+ }
587
649
  break;
588
650
  // and OptimizeLayer became a "General Purpose, GIF Animation Optimizer" (ref. mogrify.c)
589
651
  case OptimizeLayer:
590
- new_images = CoalesceImages(images, exception);
591
- rm_split(images);
592
- rm_check_exception(exception, new_images, DestroyOnError);
593
- new_images2 = OptimizeImageLayers(new_images, exception);
594
- DestroyImageList(new_images);
595
- rm_check_exception(exception, new_images2, DestroyOnError);
596
- new_images = new_images2;
597
- OptimizeImageTransparency(new_images, exception);
598
- rm_check_exception(exception, new_images, DestroyOnError);
599
- // mogrify supports -dither here. We don't.
600
- GetQuantizeInfo(&quantize_info);
652
+ {
653
+ GVL_STRUCT_TYPE(CoalesceImages) args_CoalesceImages = { images, exception };
654
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CoalesceImages), &args_CoalesceImages);
655
+ rm_split(images);
656
+ rm_check_exception(exception, new_images, DestroyOnError);
657
+
658
+ GVL_STRUCT_TYPE(OptimizeImageLayers) args_OptimizeImageLayers = { new_images, exception };
659
+ new_images2 = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OptimizeImageLayers), &args_OptimizeImageLayers);
660
+ DestroyImageList(new_images);
661
+ rm_check_exception(exception, new_images2, DestroyOnError);
662
+
663
+ new_images = new_images2;
664
+ GVL_STRUCT_TYPE(OptimizeImageTransparency) args_OptimizeImageTransparency = { new_images, exception };
665
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OptimizeImageTransparency), &args_OptimizeImageTransparency);
666
+ rm_check_exception(exception, new_images, DestroyOnError);
667
+ // mogrify supports -dither here. We don't.
668
+ GetQuantizeInfo(&quantize_info);
601
669
  #if defined(IMAGEMAGICK_7)
602
- RemapImages(&quantize_info, new_images, NULL, exception);
670
+ GVL_STRUCT_TYPE(RemapImages) args_RemapImages = { &quantize_info, new_images, NULL, exception };
603
671
  #else
604
- RemapImages(&quantize_info, new_images, NULL);
672
+ GVL_STRUCT_TYPE(RemapImages) args_RemapImages = { &quantize_info, new_images, NULL };
605
673
  #endif
674
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RemapImages), &args_RemapImages);
675
+
676
+ }
606
677
  break;
607
678
  case OptimizePlusLayer:
608
- new_images = OptimizePlusImageLayers(images, exception);
679
+ {
680
+ GVL_STRUCT_TYPE(OptimizePlusImageLayers) args = { images, exception };
681
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OptimizePlusImageLayers), &args);
682
+ }
609
683
  break;
610
684
  case CompareAnyLayer:
611
685
  case CompareClearLayer:
612
686
  case CompareOverlayLayer:
687
+ {
613
688
  #if defined(IMAGEMAGICK_7)
614
- new_images = CompareImagesLayers(images, mthd, exception);
689
+ GVL_STRUCT_TYPE(CompareImagesLayers) args = { images, mthd, exception };
690
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompareImagesLayers), &args);
615
691
  #else
616
- new_images = CompareImageLayers(images, mthd, exception);
692
+ GVL_STRUCT_TYPE(CompareImageLayers) args = { images, mthd, exception };
693
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompareImageLayers), &args);
617
694
  #endif
695
+ }
618
696
  break;
619
697
  case MosaicLayer:
620
- new_images = MergeImageLayers(images, mthd, exception);
698
+ {
699
+ GVL_STRUCT_TYPE(MergeImageLayers) args = { images, mthd, exception };
700
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(MergeImageLayers), &args);
701
+ }
621
702
  break;
622
703
  case FlattenLayer:
623
- new_images = MergeImageLayers(images, mthd, exception);
704
+ {
705
+ GVL_STRUCT_TYPE(MergeImageLayers) args = { images, mthd, exception };
706
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(MergeImageLayers), &args);
707
+ }
624
708
  break;
625
709
  case MergeLayer:
626
- new_images = MergeImageLayers(images, mthd, exception);
710
+ {
711
+ GVL_STRUCT_TYPE(MergeImageLayers) args = { images, mthd, exception };
712
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(MergeImageLayers), &args);
713
+ }
627
714
  break;
628
715
  case TrimBoundsLayer:
629
- new_images = MergeImageLayers(images, mthd, exception);
716
+ {
717
+ GVL_STRUCT_TYPE(MergeImageLayers) args = { images, mthd, exception };
718
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(MergeImageLayers), &args);
719
+ }
630
720
  break;
631
721
  default:
632
722
  rm_split(images);
@@ -824,7 +914,8 @@ clone_imagelist(Image *images)
824
914
  {
825
915
  Image *clone;
826
916
 
827
- clone = CloneImage(image, 0, 0, MagickTrue, exception);
917
+ GVL_STRUCT_TYPE(CloneImage) args = { image, 0, 0, MagickTrue, exception };
918
+ clone = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CloneImage), &args);
828
919
  rm_check_exception(exception, new_imagelist, DestroyOnError);
829
920
  AppendImageToList(&new_imagelist, clone);
830
921
  image = GetNextImageInList(image);
@@ -901,17 +992,19 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self)
901
992
  // Convert image array to image sequence, clone image sequence.
902
993
  images = images_from_imagelist(self);
903
994
  exception = AcquireExceptionInfo();
904
- new_images = CloneImageList(images, exception);
995
+ GVL_STRUCT_TYPE(CloneImageList) args_CloneImageList = { images, exception };
996
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CloneImageList), &args_CloneImageList);
905
997
  rm_split(images);
906
998
  rm_check_exception(exception, new_images, DestroyOnError);
907
999
 
908
1000
  rm_ensure_result(new_images);
909
1001
 
910
1002
  #if defined(IMAGEMAGICK_7)
911
- QuantizeImages(&quantize_info, new_images, exception);
1003
+ GVL_STRUCT_TYPE(QuantizeImages) args_QuantizeImages = { &quantize_info, new_images, exception };
912
1004
  #else
913
- QuantizeImages(&quantize_info, new_images);
1005
+ GVL_STRUCT_TYPE(QuantizeImages) args_QuantizeImages = { &quantize_info, new_images };
914
1006
  #endif
1007
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(QuantizeImages), &args_QuantizeImages);
915
1008
  rm_check_exception(exception, new_images, DestroyOnError);
916
1009
  DestroyExceptionInfo(exception);
917
1010
 
@@ -978,12 +1071,14 @@ ImageList_remap(int argc, VALUE *argv, VALUE self)
978
1071
 
979
1072
  #if defined(IMAGEMAGICK_7)
980
1073
  exception = AcquireExceptionInfo();
981
- RemapImages(&quantize_info, images, remap_image, exception);
1074
+ GVL_STRUCT_TYPE(RemapImages) args = { &quantize_info, images, remap_image, exception };
1075
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RemapImages), &args);
982
1076
  rm_split(images);
983
1077
  CHECK_EXCEPTION();
984
1078
  DestroyExceptionInfo(exception);
985
1079
  #else
986
- RemapImages(&quantize_info, images, remap_image);
1080
+ GVL_STRUCT_TYPE(RemapImages) args = { &quantize_info, images, remap_image };
1081
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RemapImages), &args);
987
1082
  rm_split(images);
988
1083
  rm_check_image_exception(images, RetainOnError);
989
1084
  #endif
@@ -1015,7 +1110,7 @@ ImageList_to_blob(VALUE self)
1015
1110
  ExceptionInfo *exception;
1016
1111
 
1017
1112
  info_obj = rm_info_new();
1018
- Data_Get_Struct(info_obj, Info, info);
1113
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
1019
1114
 
1020
1115
  // Convert the images array to an images sequence.
1021
1116
  images = images_from_imagelist(self);
@@ -1042,7 +1137,8 @@ ImageList_to_blob(VALUE self)
1042
1137
  // can happen is that there's only one image or the format
1043
1138
  // doesn't support multi-image files.
1044
1139
  info->adjoin = MagickTrue;
1045
- blob = ImagesToBlob(info, images, &length, exception);
1140
+ GVL_STRUCT_TYPE(ImagesToBlob) args = { info, images, &length, exception };
1141
+ blob = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ImagesToBlob), &args);
1046
1142
  if (blob && exception->severity >= ErrorException)
1047
1143
  {
1048
1144
  magick_free((void*)blob);
@@ -1088,7 +1184,7 @@ ImageList_write(VALUE self, VALUE file)
1088
1184
  ExceptionInfo *exception;
1089
1185
 
1090
1186
  info_obj = rm_info_new();
1091
- Data_Get_Struct(info_obj, Info, info);
1187
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
1092
1188
 
1093
1189
 
1094
1190
  if (TYPE(file) == T_FILE)
@@ -1142,10 +1238,12 @@ ImageList_write(VALUE self, VALUE file)
1142
1238
  {
1143
1239
  rm_sync_image_options(img, info);
1144
1240
  #if defined(IMAGEMAGICK_7)
1145
- WriteImage(info, img, exception);
1241
+ GVL_STRUCT_TYPE(WriteImage) args = { info, img, exception };
1242
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(WriteImage), &args);
1146
1243
  rm_check_exception(exception, img, RetainOnError);
1147
1244
  #else
1148
- WriteImage(info, img);
1245
+ GVL_STRUCT_TYPE(WriteImage) args = { info, img };
1246
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(WriteImage), &args);
1149
1247
  // images will be split before raising an exception
1150
1248
  rm_check_image_exception(images, RetainOnError);
1151
1249
  #endif