rmagick 7.2.0 → 7.3.1

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.
@@ -12,7 +12,7 @@
12
12
  #include "rmagick.h"
13
13
 
14
14
 
15
- #define ENUMERATORS_CLASS_VAR "@@enumerators"
15
+ #define ENUMERATORS_IVAR "@enumerators"
16
16
 
17
17
 
18
18
  static VALUE Enum_type_values(VALUE);
@@ -24,7 +24,7 @@ const rb_data_type_t rm_enum_data_type = {
24
24
  "Magick::Enum",
25
25
  { NULL, rm_enum_free, rm_enum_memsize, },
26
26
  0, 0,
27
- RUBY_TYPED_FROZEN_SHAREABLE,
27
+ RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_FREE_IMMEDIATELY,
28
28
  };
29
29
 
30
30
 
@@ -43,9 +43,9 @@ rm_define_enum_type(const char *tag)
43
43
 
44
44
  klass = rb_define_class_under(Module_Magick, tag, Class_Enum);\
45
45
 
46
- rb_define_singleton_method(klass, "values", RUBY_METHOD_FUNC(Enum_type_values), 0);
47
- rb_define_method(klass, "initialize", RUBY_METHOD_FUNC(Enum_type_initialize), 2);
48
- rb_define_method(klass, "inspect", RUBY_METHOD_FUNC(Enum_type_inspect), 0);
46
+ rb_define_singleton_method(klass, "values", Enum_type_values, 0);
47
+ rb_define_method(klass, "initialize", Enum_type_initialize, 2);
48
+ rb_define_method(klass, "inspect", Enum_type_inspect, 0);
49
49
  return klass;
50
50
  }
51
51
 
@@ -84,6 +84,12 @@ rm_enum_to_cstr(VALUE enum_type)
84
84
  MagickEnum *magick_enum;
85
85
 
86
86
  TypedData_Get_Struct(enum_type, MagickEnum, &rm_enum_data_type, magick_enum);
87
+ // An Enum made with allocate but never initialized has no symbol (id 0),
88
+ // and rb_id2name would return NULL.
89
+ if (magick_enum->id == 0)
90
+ {
91
+ return "";
92
+ }
87
93
  return rb_id2name(magick_enum->id);
88
94
  }
89
95
 
@@ -157,15 +163,29 @@ Enum_case_eq(VALUE self, VALUE other)
157
163
  * @param sym [Symbol] the symbol as enum name
158
164
  * @param val [Numeric] the value for enum
159
165
  * @return [Magick::Enum] self
166
+ * @raise [FrozenError] if the Enum is already initialized
160
167
  */
161
168
  VALUE
162
169
  Enum_initialize(VALUE self, VALUE sym, VALUE val)
163
170
  {
164
171
  MagickEnum *magick_enum;
172
+ ID id;
173
+ int value;
174
+
175
+ // Convert both arguments first, so that a failing conversion leaves the
176
+ // Enum uninitialized.
177
+ id = rb_to_id(sym); /* convert symbol to ID */
178
+ value = NUM2INT(val);
165
179
 
166
180
  TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, magick_enum);
167
- magick_enum->id = rb_to_id(sym); /* convert symbol to ID */
168
- magick_enum->val = NUM2INT(val);
181
+ // An Enum is frozen from the start and shared between Ractors, so it must
182
+ // not be initialized again.
183
+ if (magick_enum->id != 0)
184
+ {
185
+ rb_error_frozen_object(self);
186
+ }
187
+ magick_enum->id = id;
188
+ magick_enum->val = value;
169
189
 
170
190
  return self;
171
191
  }
@@ -240,7 +260,7 @@ Enum_bitwise_or(VALUE self, VALUE other)
240
260
  TypedData_Get_Struct(other, MagickEnum, &rm_enum_data_type, other_enum);
241
261
  TypedData_Get_Struct(new_enum, MagickEnum, &rm_enum_data_type, new_enum_data);
242
262
 
243
- new_enum_data->id = rb_to_id(rb_sprintf("%s|%s", rb_id2name(self_enum->id), rb_id2name(other_enum->id)));
263
+ new_enum_data->id = rb_to_id(rb_sprintf("%s|%s", rm_enum_to_cstr(self), rm_enum_to_cstr(other)));
244
264
  new_enum_data->val = self_enum->val | other_enum->val;
245
265
 
246
266
  return new_enum;
@@ -258,6 +278,27 @@ Enum_to_s(VALUE self)
258
278
  }
259
279
 
260
280
 
281
+ /**
282
+ * Get the Enum subclass that keeps the values of a class derived from it.
283
+ *
284
+ * No Ruby usage (internal function)
285
+ *
286
+ * @param klass the Enum subclass or a class derived from it
287
+ * @return the Enum subclass
288
+ */
289
+ static VALUE
290
+ enum_type_class(VALUE klass)
291
+ {
292
+ VALUE super;
293
+
294
+ while ((super = rb_class_superclass(klass)) != Class_Enum)
295
+ {
296
+ klass = super;
297
+ }
298
+ return klass;
299
+ }
300
+
301
+
261
302
  /**
262
303
  * Initialize method for all Enum subclasses.
263
304
  *
@@ -269,19 +310,17 @@ VALUE
269
310
  Enum_type_initialize(VALUE self, VALUE sym, VALUE val)
270
311
  {
271
312
  VALUE super_argv[2];
272
- VALUE enumerators;
313
+ VALUE klass, enumerators;
273
314
 
274
315
  super_argv[0] = sym;
275
316
  super_argv[1] = val;
276
317
  rb_call_super(2, (const VALUE *)super_argv);
277
318
 
278
- if (rb_cvar_defined(CLASS_OF(self), rb_intern(ENUMERATORS_CLASS_VAR)) != Qtrue)
279
- {
280
- rb_cv_set(CLASS_OF(self), ENUMERATORS_CLASS_VAR, rb_ary_new());
281
- }
282
-
283
- enumerators = rb_cv_get(CLASS_OF(self), ENUMERATORS_CLASS_VAR);
319
+ klass = enum_type_class(CLASS_OF(self));
320
+ enumerators = rb_iv_get(klass, ENUMERATORS_IVAR);
321
+ enumerators = NIL_P(enumerators) ? rb_ary_new() : rb_ary_dup(enumerators);
284
322
  rb_ary_push(enumerators, self);
323
+ rb_iv_set(klass, ENUMERATORS_IVAR, rb_ary_freeze(enumerators));
285
324
 
286
325
  RB_GC_GUARD(enumerators);
287
326
 
@@ -301,7 +340,7 @@ Enum_type_inspect(VALUE self)
301
340
  MagickEnum *magick_enum;
302
341
 
303
342
  TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, magick_enum);
304
- snprintf(str, sizeof(str), "%.48s=%d", rb_id2name(magick_enum->id), magick_enum->val);
343
+ snprintf(str, sizeof(str), "%.48s=%d", rm_enum_to_cstr(self), magick_enum->val);
305
344
 
306
345
  return rb_str_new2(str);
307
346
  }
@@ -322,11 +361,12 @@ Enum_type_inspect(VALUE self)
322
361
  static VALUE
323
362
  Enum_type_values(VALUE klass)
324
363
  {
325
- VALUE enumerators, copy;
364
+ VALUE enumerators, copy = Qnil;
326
365
  VALUE rv;
327
366
  int x;
328
367
 
329
- enumerators = rb_cv_get(klass, ENUMERATORS_CLASS_VAR);
368
+ enumerators = rb_iv_get(enum_type_class(klass), ENUMERATORS_IVAR);
369
+ enumerators = rm_check_ary_type(enumerators);
330
370
 
331
371
  if (rb_block_given_p())
332
372
  {
@@ -371,7 +411,7 @@ Enum_find(VALUE klass, int val)
371
411
  MagickEnum *magick_enum;
372
412
  int x;
373
413
 
374
- enumerators = rb_cv_get(klass, ENUMERATORS_CLASS_VAR);
414
+ enumerators = rb_iv_get(klass, ENUMERATORS_IVAR);
375
415
  enumerators = rm_check_ary_type(enumerators);
376
416
 
377
417
  for (x = 0; x < RARRAY_LEN(enumerators); x++)
@@ -25,26 +25,26 @@ typedef struct
25
25
  double y2; /**< y position of second point */
26
26
  PixelColor start_color; /**< the start color */
27
27
  PixelColor stop_color; /**< the stop color */
28
- } rm_GradientFill;
28
+ } MagickGradientFill;
29
29
 
30
30
  /** Data associated with a TextureFill */
31
31
  typedef struct
32
32
  {
33
33
  Image *texture; /**< the texture */
34
- } rm_TextureFill;
34
+ } MagickTextureFill;
35
35
 
36
36
  const rb_data_type_t rm_gradient_fill_data_type = {
37
37
  "Magick::GradientFill",
38
38
  { NULL, GradientFill_free, GradientFill_memsize, },
39
39
  0, 0,
40
- RUBY_TYPED_FROZEN_SHAREABLE,
40
+ RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_FREE_IMMEDIATELY,
41
41
  };
42
42
 
43
43
  const rb_data_type_t rm_texture_fill_data_type = {
44
44
  "Magick::TextureFill",
45
45
  { NULL, TextureFill_free, TextureFill_memsize, },
46
46
  0, 0,
47
- RUBY_TYPED_FROZEN_SHAREABLE,
47
+ RUBY_TYPED_FROZEN_SHAREABLE | RM_TYPED_FREE_IMMEDIATELY,
48
48
  };
49
49
 
50
50
 
@@ -70,12 +70,12 @@ GradientFill_free(void *fill)
70
70
  *
71
71
  * No Ruby usage (internal function)
72
72
  *
73
- * @param ptr pointer to the GradientFill object
73
+ * @param ptr pointer to the MagickGradientFill struct
74
74
  */
75
75
  static size_t
76
76
  GradientFill_memsize(const void *ptr)
77
77
  {
78
- return sizeof(rm_GradientFill);
78
+ return sizeof(MagickGradientFill);
79
79
  }
80
80
 
81
81
 
@@ -87,9 +87,9 @@ GradientFill_memsize(const void *ptr)
87
87
  VALUE
88
88
  GradientFill_alloc(VALUE klass)
89
89
  {
90
- rm_GradientFill *fill;
90
+ MagickGradientFill *fill;
91
91
 
92
- return TypedData_Make_Struct(klass, rm_GradientFill, &rm_gradient_fill_data_type, fill);
92
+ return TypedData_Make_Struct(klass, MagickGradientFill, &rm_gradient_fill_data_type, fill);
93
93
  }
94
94
 
95
95
 
@@ -114,9 +114,9 @@ GradientFill_initialize(
114
114
  VALUE start_color,
115
115
  VALUE stop_color)
116
116
  {
117
- rm_GradientFill *fill;
117
+ MagickGradientFill *fill;
118
118
 
119
- TypedData_Get_Struct(self, rm_GradientFill, &rm_gradient_fill_data_type, fill);
119
+ TypedData_Get_Struct(self, MagickGradientFill, &rm_gradient_fill_data_type, fill);
120
120
 
121
121
  fill->x1 = NUM2DBL(x1);
122
122
  fill->y1 = NUM2DBL(y1);
@@ -128,12 +128,36 @@ GradientFill_initialize(
128
128
  return self;
129
129
  }
130
130
 
131
+
132
+ /**
133
+ * Initialize clone, dup methods.
134
+ *
135
+ * @param orig the original object
136
+ * @return [Magick::GradientFill] self
137
+ */
138
+ VALUE
139
+ GradientFill_init_copy(VALUE self, VALUE orig)
140
+ {
141
+ MagickGradientFill *copy, *original;
142
+
143
+ if (!rm_check_init_copy(self, orig))
144
+ {
145
+ return self;
146
+ }
147
+ TypedData_Get_Struct(orig, MagickGradientFill, &rm_gradient_fill_data_type, original);
148
+ TypedData_Get_Struct(self, MagickGradientFill, &rm_gradient_fill_data_type, copy);
149
+ *copy = *original;
150
+
151
+ return self;
152
+ }
153
+
131
154
  /**
132
155
  * Do a gradient that radiates from a point.
133
156
  *
134
157
  * No Ruby usage (internal function)
135
158
  *
136
159
  * @param image the image on which to do the gradient
160
+ * @param image_obj the Image object that holds image
137
161
  * @param x0 x position of the point
138
162
  * @param y0 y position of the point
139
163
  * @param start_color the start color
@@ -142,6 +166,7 @@ GradientFill_initialize(
142
166
  static void
143
167
  point_fill(
144
168
  Image *image,
169
+ VALUE image_obj,
145
170
  double x0,
146
171
  double y0,
147
172
  PixelColor *start_color,
@@ -192,7 +217,7 @@ point_fill(
192
217
  }
193
218
 
194
219
  DECLARE_GVL_CALL(call, SyncAuthenticPixels, image, exception);
195
- call.keep_thread().run<void>();
220
+ call.update(image_obj).keep_thread().release(exception).run<void>();
196
221
  CHECK_EXCEPTION();
197
222
  }
198
223
 
@@ -206,6 +231,7 @@ point_fill(
206
231
  * No Ruby usage (internal function)
207
232
  *
208
233
  * @param image the image on which to do the gradient
234
+ * @param image_obj the Image object that holds image
209
235
  * @param x1 x position of the vertical line
210
236
  * @param start_color the start color
211
237
  * @param stop_color the stop color
@@ -213,6 +239,7 @@ point_fill(
213
239
  static void
214
240
  vertical_fill(
215
241
  Image *image,
242
+ VALUE image_obj,
216
243
  double x1,
217
244
  PixelColor *start_color,
218
245
  PixelColor *stop_color)
@@ -262,7 +289,7 @@ vertical_fill(
262
289
  }
263
290
 
264
291
  DECLARE_GVL_CALL(call, SyncAuthenticPixels, image, exception);
265
- call.keep_thread().run<void>();
292
+ call.update(image_obj).keep_thread().release(exception).run<void>();
266
293
  CHECK_EXCEPTION();
267
294
  }
268
295
 
@@ -296,7 +323,7 @@ vertical_fill(
296
323
  memcpy(row_pixels, master, image->columns * sizeof(PixelPacket));
297
324
 
298
325
  DECLARE_GVL_CALL(call, SyncAuthenticPixels, image, exception);
299
- call.keep_thread().run<void>();
326
+ call.update(image_obj).keep_thread().free_buffer(master).release(exception).run<void>();
300
327
  if (rm_should_raise_exception(exception, RetainExceptionRetention))
301
328
  {
302
329
  xfree((void *)master);
@@ -316,6 +343,7 @@ vertical_fill(
316
343
  * No Ruby usage (internal function)
317
344
  *
318
345
  * @param image the image on which to do the gradient
346
+ * @param image_obj the Image object that holds image
319
347
  * @param y1 y position of the horizontal line
320
348
  * @param start_color the start color
321
349
  * @param stop_color the stop color
@@ -323,6 +351,7 @@ vertical_fill(
323
351
  static void
324
352
  horizontal_fill(
325
353
  Image *image,
354
+ VALUE image_obj,
326
355
  double y1,
327
356
  PixelColor *start_color,
328
357
  PixelColor *stop_color)
@@ -370,7 +399,7 @@ horizontal_fill(
370
399
  }
371
400
 
372
401
  DECLARE_GVL_CALL(call, SyncAuthenticPixels, image, exception);
373
- call.keep_thread().run<void>();
402
+ call.update(image_obj).keep_thread().release(exception).run<void>();
374
403
  CHECK_EXCEPTION();
375
404
  }
376
405
 
@@ -403,7 +432,7 @@ horizontal_fill(
403
432
  memcpy(col_pixels, master, image->rows * sizeof(PixelPacket));
404
433
 
405
434
  DECLARE_GVL_CALL(call, SyncAuthenticPixels, image, exception);
406
- call.keep_thread().run<void>();
435
+ call.update(image_obj).keep_thread().free_buffer(master).release(exception).run<void>();
407
436
  if (rm_should_raise_exception(exception, RetainExceptionRetention))
408
437
  {
409
438
  xfree((void *)master);
@@ -424,6 +453,7 @@ horizontal_fill(
424
453
  * No Ruby usage (internal function)
425
454
  *
426
455
  * @param image the image on which to do the gradient
456
+ * @param image_obj the Image object that holds image
427
457
  * @param x1 x position of the start of the diagonal line
428
458
  * @param y1 y position of the start of the diagonal line
429
459
  * @param x2 x position of the end of the diagonal line
@@ -434,6 +464,7 @@ horizontal_fill(
434
464
  static void
435
465
  v_diagonal_fill(
436
466
  Image *image,
467
+ VALUE image_obj,
437
468
  double x1,
438
469
  double y1,
439
470
  double x2,
@@ -515,7 +546,7 @@ v_diagonal_fill(
515
546
  }
516
547
 
517
548
  DECLARE_GVL_CALL(call, SyncAuthenticPixels, image, exception);
518
- call.keep_thread().run<void>();
549
+ call.update(image_obj).keep_thread().release(exception).run<void>();
519
550
  CHECK_EXCEPTION();
520
551
  }
521
552
 
@@ -529,6 +560,7 @@ v_diagonal_fill(
529
560
  * No Ruby usage (internal function)
530
561
  *
531
562
  * @param image the image on which to do the gradient
563
+ * @param image_obj the Image object that holds image
532
564
  * @param x1 x position of the start of the diagonal line
533
565
  * @param y1 y position of the start of the diagonal line
534
566
  * @param x2 x position of the end of the diagonal line
@@ -539,6 +571,7 @@ v_diagonal_fill(
539
571
  static void
540
572
  h_diagonal_fill(
541
573
  Image *image,
574
+ VALUE image_obj,
542
575
  double x1,
543
576
  double y1,
544
577
  double x2,
@@ -622,7 +655,7 @@ h_diagonal_fill(
622
655
  }
623
656
 
624
657
  DECLARE_GVL_CALL(call, SyncAuthenticPixels, image, exception);
625
- call.keep_thread().run<void>();
658
+ call.update(image_obj).keep_thread().release(exception).run<void>();
626
659
  CHECK_EXCEPTION();
627
660
  }
628
661
 
@@ -639,13 +672,14 @@ h_diagonal_fill(
639
672
  VALUE
640
673
  GradientFill_fill(VALUE self, VALUE image_obj)
641
674
  {
642
- rm_GradientFill *fill;
675
+ MagickGradientFill *fill;
643
676
  Image *image;
644
677
  PixelColor start_color, stop_color;
645
678
  double x1, y1, x2, y2; // points on the line
646
679
 
647
- TypedData_Get_Struct(self, rm_GradientFill, &rm_gradient_fill_data_type, fill);
648
- image = rm_check_writable(rm_cur_image(image_obj));
680
+ TypedData_Get_Struct(self, MagickGradientFill, &rm_gradient_fill_data_type, fill);
681
+ image_obj = rm_cur_image(image_obj);
682
+ image = rm_check_frozen(image_obj);
649
683
 
650
684
  x1 = fill->x1;
651
685
  y1 = fill->y1;
@@ -659,20 +693,20 @@ GradientFill_fill(VALUE self, VALUE image_obj)
659
693
  // If the x1,y1 and x2,y2 points are essentially the same
660
694
  if (fabs(y2-y1) < 0.5)
661
695
  {
662
- point_fill(image, x1, y1, &start_color, &stop_color);
696
+ point_fill(image, image_obj, x1, y1, &start_color, &stop_color);
663
697
  }
664
698
 
665
699
  // A vertical line is a special case.
666
700
  else
667
701
  {
668
- vertical_fill(image, x1, &start_color, &stop_color);
702
+ vertical_fill(image, image_obj, x1, &start_color, &stop_color);
669
703
  }
670
704
  }
671
705
 
672
706
  // A horizontal line is a special case.
673
707
  else if (fabs(y2-y1) < 0.5)
674
708
  {
675
- horizontal_fill(image, y1, &start_color, &stop_color);
709
+ horizontal_fill(image, image_obj, y1, &start_color, &stop_color);
676
710
  }
677
711
 
678
712
  // This is the general case - a diagonal line. If the line is more horizontal
@@ -684,14 +718,16 @@ GradientFill_fill(VALUE self, VALUE image_obj)
684
718
  double diagonal = ((double)image->rows)/image->columns;
685
719
  if (fabs(m) <= diagonal)
686
720
  {
687
- v_diagonal_fill(image, x1, y1, x2, y2, &start_color, &stop_color);
721
+ v_diagonal_fill(image, image_obj, x1, y1, x2, y2, &start_color, &stop_color);
688
722
  }
689
723
  else
690
724
  {
691
- h_diagonal_fill(image, x1, y1, x2, y2, &start_color, &stop_color);
725
+ h_diagonal_fill(image, image_obj, x1, y1, x2, y2, &start_color, &stop_color);
692
726
  }
693
727
  }
694
728
 
729
+ RB_GC_GUARD(image_obj);
730
+
695
731
  return self;
696
732
  }
697
733
 
@@ -709,7 +745,7 @@ GradientFill_fill(VALUE self, VALUE image_obj)
709
745
  static void
710
746
  TextureFill_free(void *fill_obj)
711
747
  {
712
- rm_TextureFill *fill = (rm_TextureFill *)fill_obj;
748
+ MagickTextureFill *fill = (MagickTextureFill *)fill_obj;
713
749
 
714
750
  // Do not trace destruction
715
751
  if (fill->texture)
@@ -725,12 +761,12 @@ TextureFill_free(void *fill_obj)
725
761
  *
726
762
  * No Ruby usage (internal function)
727
763
  *
728
- * @param ptr pointer to the TextureFill object
764
+ * @param ptr pointer to the MagickTextureFill struct
729
765
  */
730
766
  static size_t
731
767
  TextureFill_memsize(const void *ptr)
732
768
  {
733
- return sizeof(rm_TextureFill);
769
+ return sizeof(MagickTextureFill);
734
770
  }
735
771
 
736
772
 
@@ -742,8 +778,34 @@ TextureFill_memsize(const void *ptr)
742
778
  VALUE
743
779
  TextureFill_alloc(VALUE klass)
744
780
  {
745
- rm_TextureFill *fill;
746
- return TypedData_Make_Struct(klass, rm_TextureFill, &rm_texture_fill_data_type, fill);
781
+ MagickTextureFill *fill;
782
+ return TypedData_Make_Struct(klass, MagickTextureFill, &rm_texture_fill_data_type, fill);
783
+ }
784
+
785
+ /**
786
+ * Replace the texture of a TextureFill with a copy made for it.
787
+ *
788
+ * No Ruby usage (internal function)
789
+ *
790
+ * @param self the TextureFill object
791
+ * @param fill the MagickTextureFill struct of self
792
+ * @param texture the new texture, which is destroyed if self is frozen
793
+ */
794
+ static void
795
+ replace_texture(VALUE self, MagickTextureFill *fill, Image *texture)
796
+ {
797
+ // Making the copy releases the GVL, so other code can freeze self meanwhile.
798
+ if (OBJ_FROZEN(self))
799
+ {
800
+ DestroyImage(texture);
801
+ rb_error_frozen_object(self);
802
+ }
803
+
804
+ if (fill->texture)
805
+ {
806
+ DestroyImage(fill->texture);
807
+ }
808
+ fill->texture = texture;
747
809
  }
748
810
 
749
811
  /**
@@ -756,25 +818,50 @@ TextureFill_alloc(VALUE klass)
756
818
  VALUE
757
819
  TextureFill_initialize(VALUE self, VALUE texture_arg)
758
820
  {
759
- rm_TextureFill *fill;
821
+ MagickTextureFill *fill;
760
822
  Image *texture;
761
823
  VALUE texture_image;
762
824
 
763
- TypedData_Get_Struct(self, rm_TextureFill, &rm_texture_fill_data_type, fill);
825
+ rb_check_frozen(self);
826
+ TypedData_Get_Struct(self, MagickTextureFill, &rm_texture_fill_data_type, fill);
764
827
 
765
828
  texture_image = rm_cur_image(texture_arg);
766
829
 
767
- // Bump the reference count on the texture image.
768
- texture = rm_check_readable(texture_image);
769
- ReferenceImage(texture);
770
-
771
- fill->texture = texture;
830
+ texture = rm_copy_image(rm_check_readable(texture_image), texture_image);
831
+ replace_texture(self, fill, texture);
772
832
 
773
833
  RB_GC_GUARD(texture_image);
774
834
 
775
835
  return self;
776
836
  }
777
837
 
838
+ /**
839
+ * Initialize clone, dup methods.
840
+ *
841
+ * @param orig the original object
842
+ * @return [Magick::TextureFill] self
843
+ */
844
+ VALUE
845
+ TextureFill_init_copy(VALUE self, VALUE orig)
846
+ {
847
+ MagickTextureFill *copy, *original;
848
+
849
+ if (!rm_check_init_copy(self, orig))
850
+ {
851
+ return self;
852
+ }
853
+ TypedData_Get_Struct(orig, MagickTextureFill, &rm_texture_fill_data_type, original);
854
+ TypedData_Get_Struct(self, MagickTextureFill, &rm_texture_fill_data_type, copy);
855
+ if (!original->texture)
856
+ {
857
+ rb_raise(rb_eRuntimeError, "%s has not been initialized", rb_obj_classname(orig));
858
+ }
859
+
860
+ replace_texture(self, copy, rm_copy_image(original->texture, orig));
861
+
862
+ return self;
863
+ }
864
+
778
865
  /**
779
866
  * Call TextureFill with the texture specified when this fill object was
780
867
  * created.
@@ -785,14 +872,18 @@ TextureFill_initialize(VALUE self, VALUE texture_arg)
785
872
  VALUE
786
873
  TextureFill_fill(VALUE self, VALUE image_obj)
787
874
  {
788
- rm_TextureFill *fill;
875
+ MagickTextureFill *fill;
789
876
  Image *image;
790
877
  #if defined(IMAGEMAGICK_7)
791
878
  ExceptionInfo *exception;
792
879
  #endif
793
880
 
794
- image = rm_check_writable(rm_cur_image(image_obj));
795
- TypedData_Get_Struct(self, rm_TextureFill, &rm_texture_fill_data_type, fill);
881
+ image = rm_check_frozen(rm_cur_image(image_obj));
882
+ TypedData_Get_Struct(self, MagickTextureFill, &rm_texture_fill_data_type, fill);
883
+ if (!fill->texture)
884
+ {
885
+ rb_raise(rb_eRuntimeError, "%s has not been initialized", rb_obj_classname(self));
886
+ }
796
887
 
797
888
  #if defined(IMAGEMAGICK_7)
798
889
  exception = AcquireExceptionInfo();