cairo 1.10.2-x86-mingw32 → 1.12.0-x86-mingw32
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/AUTHORS +4 -1
- data/Gemfile +1 -11
- data/NEWS +28 -0
- data/README.rdoc +3 -2
- data/Rakefile +5 -46
- data/ext/cairo/cairo.def +9 -0
- data/ext/cairo/rb_cairo.h +7 -2
- data/ext/cairo/rb_cairo_constants.c +43 -7
- data/ext/cairo/rb_cairo_context.c +1 -1
- data/ext/cairo/rb_cairo_device.c +31 -5
- data/ext/cairo/rb_cairo_exception.c +21 -1
- data/ext/cairo/rb_cairo_pattern.c +579 -1
- data/ext/cairo/rb_cairo_surface.c +159 -7
- data/lib/1.8/cairo.so +0 -0
- data/lib/1.9/cairo.so +0 -0
- data/test/test_raster_source_pattern.rb +148 -0
- data/test/test_recording_surface.rb +2 -4
- data/test/test_xml_surface.rb +2 -1
- metadata +90 -22
@@ -5,6 +5,7 @@
|
|
5
5
|
* $Author: kou $
|
6
6
|
* $Date: 2008-06-12 10:59:54 $
|
7
7
|
*
|
8
|
+
* Copyright 2012 Kouhei Sutou <kou@cozmixng.org>
|
8
9
|
* Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
|
9
10
|
* Copyright 2004-2005 MenTaLguY <mental@rydia.com>
|
10
11
|
*
|
@@ -21,8 +22,10 @@ VALUE rb_cCairo_SurfacePattern;
|
|
21
22
|
VALUE rb_cCairo_GradientPattern;
|
22
23
|
VALUE rb_cCairo_LinearPattern;
|
23
24
|
VALUE rb_cCairo_RadialPattern;
|
25
|
+
VALUE rb_cCairo_MeshPattern;
|
26
|
+
VALUE rb_cCairo_RasterSourcePattern;
|
24
27
|
|
25
|
-
static ID id_parse, id_to_rgb, id_to_a, id_inspect;
|
28
|
+
static ID id_parse, id_to_rgb, id_to_a, id_inspect, id_new, id_call;
|
26
29
|
|
27
30
|
#define _SELF(self) (RVAL2CRPATTERN(self))
|
28
31
|
|
@@ -59,6 +62,14 @@ cr_pattern_get_klass (cairo_pattern_t *pattern)
|
|
59
62
|
case CAIRO_PATTERN_TYPE_RADIAL:
|
60
63
|
klass = rb_cCairo_RadialPattern;
|
61
64
|
break;
|
65
|
+
#if CAIRO_CHECK_VERSION(1, 11, 4)
|
66
|
+
case CAIRO_PATTERN_TYPE_MESH:
|
67
|
+
klass = rb_cCairo_MeshPattern;
|
68
|
+
break;
|
69
|
+
case CAIRO_PATTERN_TYPE_RASTER_SOURCE:
|
70
|
+
klass = rb_cCairo_RasterSourcePattern;
|
71
|
+
break;
|
72
|
+
#endif
|
62
73
|
default:
|
63
74
|
rb_raise (rb_eArgError, "unknown pattern type: %d", type);
|
64
75
|
break;
|
@@ -441,6 +452,517 @@ cr_radial_pattern_get_radial_circles (VALUE self)
|
|
441
452
|
/* Cairo::SurfacePattern */
|
442
453
|
/* none */
|
443
454
|
|
455
|
+
#if CAIRO_CHECK_VERSION(1, 11, 4)
|
456
|
+
/* Cairo::MeshPattern */
|
457
|
+
static VALUE
|
458
|
+
cr_mesh_pattern_initialize (VALUE self)
|
459
|
+
{
|
460
|
+
cairo_pattern_t *pattern;
|
461
|
+
|
462
|
+
pattern = cairo_pattern_create_mesh ();
|
463
|
+
cr_pattern_check_status (pattern);
|
464
|
+
DATA_PTR (self) = pattern;
|
465
|
+
return Qnil;
|
466
|
+
}
|
467
|
+
|
468
|
+
static VALUE
|
469
|
+
cr_mesh_pattern_end_patch (VALUE self)
|
470
|
+
{
|
471
|
+
cairo_pattern_t *pattern;
|
472
|
+
|
473
|
+
pattern = _SELF (self);
|
474
|
+
cairo_mesh_pattern_end_patch (pattern);
|
475
|
+
cr_pattern_check_status (pattern);
|
476
|
+
return self;
|
477
|
+
}
|
478
|
+
|
479
|
+
static VALUE
|
480
|
+
cr_mesh_pattern_begin_patch (VALUE self)
|
481
|
+
{
|
482
|
+
cairo_pattern_t *pattern;
|
483
|
+
|
484
|
+
pattern = _SELF (self);
|
485
|
+
cairo_mesh_pattern_begin_patch (pattern);
|
486
|
+
cr_pattern_check_status (pattern);
|
487
|
+
if (rb_block_given_p ())
|
488
|
+
return rb_ensure (rb_yield, self, cr_mesh_pattern_end_patch, self);
|
489
|
+
else
|
490
|
+
return self;
|
491
|
+
}
|
492
|
+
|
493
|
+
static VALUE
|
494
|
+
cr_mesh_pattern_curve_to (VALUE self,
|
495
|
+
VALUE x1, VALUE y1,
|
496
|
+
VALUE x2, VALUE y2,
|
497
|
+
VALUE x3, VALUE y3)
|
498
|
+
{
|
499
|
+
cairo_pattern_t *pattern;
|
500
|
+
|
501
|
+
pattern = _SELF (self);
|
502
|
+
cairo_mesh_pattern_curve_to (pattern,
|
503
|
+
NUM2DBL (x1), NUM2DBL (y1),
|
504
|
+
NUM2DBL (x2), NUM2DBL (y2),
|
505
|
+
NUM2DBL (x3), NUM2DBL (y3));
|
506
|
+
cr_pattern_check_status (pattern);
|
507
|
+
return self;
|
508
|
+
}
|
509
|
+
|
510
|
+
static VALUE
|
511
|
+
cr_mesh_pattern_line_to (VALUE self, VALUE x, VALUE y)
|
512
|
+
{
|
513
|
+
cairo_pattern_t *pattern;
|
514
|
+
|
515
|
+
pattern = _SELF (self);
|
516
|
+
cairo_mesh_pattern_line_to (pattern, NUM2DBL (x), NUM2DBL (y));
|
517
|
+
cr_pattern_check_status (pattern);
|
518
|
+
return self;
|
519
|
+
}
|
520
|
+
|
521
|
+
static VALUE
|
522
|
+
cr_mesh_pattern_move_to (VALUE self, VALUE x, VALUE y)
|
523
|
+
{
|
524
|
+
cairo_pattern_t *pattern;
|
525
|
+
|
526
|
+
pattern = _SELF (self);
|
527
|
+
cairo_mesh_pattern_move_to (pattern, NUM2DBL (x), NUM2DBL (y));
|
528
|
+
cr_pattern_check_status (pattern);
|
529
|
+
return self;
|
530
|
+
}
|
531
|
+
|
532
|
+
static VALUE
|
533
|
+
cr_mesh_pattern_set_control_point (VALUE self, VALUE rb_nth_point,
|
534
|
+
VALUE rb_x, VALUE rb_y)
|
535
|
+
{
|
536
|
+
cairo_pattern_t *pattern;
|
537
|
+
unsigned int nth_point;
|
538
|
+
|
539
|
+
pattern = _SELF (self);
|
540
|
+
nth_point = NUM2UINT (rb_nth_point);
|
541
|
+
if (0 <= nth_point && nth_point <= 3)
|
542
|
+
{
|
543
|
+
cairo_mesh_pattern_set_control_point (pattern, nth_point,
|
544
|
+
NUM2DBL (rb_x), NUM2DBL (rb_y));
|
545
|
+
}
|
546
|
+
else
|
547
|
+
{
|
548
|
+
VALUE inspected;
|
549
|
+
|
550
|
+
inspected = rb_funcall (rb_ary_new3 (3, rb_nth_point, rb_x, rb_y),
|
551
|
+
id_inspect, 0);
|
552
|
+
rb_raise (rb_eArgError, "nth_point must be 0, 1, 2 or 3: <%u>: <%s>",
|
553
|
+
nth_point, RVAL2CSTR (inspected));
|
554
|
+
}
|
555
|
+
cr_pattern_check_status (pattern);
|
556
|
+
return self;
|
557
|
+
}
|
558
|
+
|
559
|
+
static VALUE
|
560
|
+
cr_mesh_pattern_set_corner_color_generic (int argc, VALUE *argv, VALUE self)
|
561
|
+
{
|
562
|
+
cairo_pattern_t *pattern;
|
563
|
+
VALUE rb_nth_corner, rb_red, rb_green, rb_blue, rb_alpha;
|
564
|
+
unsigned int nth_corner;
|
565
|
+
double red, green, blue, alpha;
|
566
|
+
|
567
|
+
rb_scan_args (argc, argv, "41",
|
568
|
+
&rb_nth_corner, &rb_red, &rb_green, &rb_blue, &rb_alpha);
|
569
|
+
|
570
|
+
nth_corner = NUM2UINT (rb_nth_corner);
|
571
|
+
if (!(0 <= nth_corner && nth_corner <= 3))
|
572
|
+
{
|
573
|
+
VALUE inspected;
|
574
|
+
|
575
|
+
inspected = rb_funcall (rb_ary_new4 (argc, argv), id_inspect, 0);
|
576
|
+
rb_raise (rb_eArgError, "nth_corner must be 0, 1, 2 or 3: <%u>: <%s>",
|
577
|
+
nth_corner, RVAL2CSTR (inspected));
|
578
|
+
}
|
579
|
+
|
580
|
+
pattern = _SELF (self);
|
581
|
+
red = NUM2DBL (rb_red);
|
582
|
+
green = NUM2DBL (rb_green);
|
583
|
+
blue = NUM2DBL (rb_blue);
|
584
|
+
if (NIL_P (rb_alpha))
|
585
|
+
{
|
586
|
+
cairo_mesh_pattern_set_corner_color_rgb (pattern, nth_corner,
|
587
|
+
red, green, blue);
|
588
|
+
}
|
589
|
+
else
|
590
|
+
{
|
591
|
+
alpha = NUM2DBL (rb_alpha);
|
592
|
+
cairo_mesh_pattern_set_corner_color_rgba (pattern, nth_corner,
|
593
|
+
red, green, blue, alpha);
|
594
|
+
}
|
595
|
+
cr_pattern_check_status (pattern);
|
596
|
+
return self;
|
597
|
+
}
|
598
|
+
|
599
|
+
static VALUE
|
600
|
+
cr_mesh_pattern_get_patch_count (VALUE self)
|
601
|
+
{
|
602
|
+
cairo_pattern_t *pattern;
|
603
|
+
unsigned int count;
|
604
|
+
cairo_status_t status;
|
605
|
+
|
606
|
+
pattern = _SELF (self);
|
607
|
+
status = cairo_mesh_pattern_get_patch_count (pattern, &count);
|
608
|
+
rb_cairo_check_status (status);
|
609
|
+
return UINT2NUM (count);
|
610
|
+
}
|
611
|
+
|
612
|
+
static VALUE
|
613
|
+
cr_mesh_pattern_get_path (VALUE self, VALUE nth_patch)
|
614
|
+
{
|
615
|
+
cairo_pattern_t *pattern;
|
616
|
+
cairo_path_t *path;
|
617
|
+
|
618
|
+
pattern = _SELF (self);
|
619
|
+
path = cairo_mesh_pattern_get_path (pattern, NUM2UINT (nth_patch));
|
620
|
+
rb_cairo_check_status (path->status);
|
621
|
+
return CRPATH2RVAL (path);
|
622
|
+
}
|
623
|
+
|
624
|
+
static VALUE
|
625
|
+
cr_mesh_pattern_get_corner_color (VALUE self,
|
626
|
+
VALUE rb_nth_patch, VALUE rb_nth_corner)
|
627
|
+
{
|
628
|
+
cairo_pattern_t *pattern;
|
629
|
+
unsigned int nth_patch, nth_corner;
|
630
|
+
double red, green, blue, alpha;
|
631
|
+
cairo_status_t status;
|
632
|
+
|
633
|
+
nth_patch = NUM2UINT (rb_nth_patch);
|
634
|
+
nth_corner = NUM2UINT (rb_nth_corner);
|
635
|
+
if (!(0 <= nth_corner && nth_corner <= 3))
|
636
|
+
{
|
637
|
+
VALUE inspected;
|
638
|
+
|
639
|
+
inspected = rb_funcall (rb_ary_new3 (2, rb_nth_patch, rb_nth_corner),
|
640
|
+
id_inspect, 0);
|
641
|
+
rb_raise (rb_eArgError, "nth_corner must be 0, 1, 2 or 3: <%u>: <%s>",
|
642
|
+
nth_corner, RVAL2CSTR (inspected));
|
643
|
+
}
|
644
|
+
|
645
|
+
pattern = _SELF (self);
|
646
|
+
status = cairo_mesh_pattern_get_corner_color_rgba (pattern,
|
647
|
+
nth_patch, nth_corner,
|
648
|
+
&red,
|
649
|
+
&green,
|
650
|
+
&blue,
|
651
|
+
&alpha);
|
652
|
+
rb_cairo_check_status (status);
|
653
|
+
return rb_ary_new3 (4,
|
654
|
+
rb_float_new (red), rb_float_new (green),
|
655
|
+
rb_float_new (blue), rb_float_new (alpha));
|
656
|
+
}
|
657
|
+
|
658
|
+
static VALUE
|
659
|
+
cr_mesh_pattern_get_control_point (VALUE self,
|
660
|
+
VALUE rb_nth_patch, VALUE rb_nth_point)
|
661
|
+
{
|
662
|
+
cairo_pattern_t *pattern;
|
663
|
+
unsigned int nth_patch, nth_point;
|
664
|
+
double x, y;
|
665
|
+
cairo_status_t status;
|
666
|
+
|
667
|
+
nth_patch = NUM2UINT (rb_nth_patch);
|
668
|
+
nth_point = NUM2UINT (rb_nth_point);
|
669
|
+
if (!(0 <= nth_point && nth_point <= 3))
|
670
|
+
{
|
671
|
+
VALUE inspected;
|
672
|
+
|
673
|
+
inspected = rb_funcall (rb_ary_new3 (2, rb_nth_patch, rb_nth_point),
|
674
|
+
id_inspect, 0);
|
675
|
+
rb_raise (rb_eArgError, "nth_point must be 0, 1, 2 or 3: <%u>: <%s>",
|
676
|
+
nth_point, RVAL2CSTR (inspected));
|
677
|
+
}
|
678
|
+
|
679
|
+
pattern = _SELF (self);
|
680
|
+
status = cairo_mesh_pattern_get_control_point (pattern,
|
681
|
+
nth_patch, nth_point,
|
682
|
+
&x, &y);
|
683
|
+
rb_cairo_check_status (status);
|
684
|
+
return rb_ary_new3 (2, rb_float_new (x), rb_float_new (y));
|
685
|
+
}
|
686
|
+
|
687
|
+
/* Cairo::RasterPattern */
|
688
|
+
static cairo_surface_t *
|
689
|
+
cr_raster_source_acquire_callback (cairo_pattern_t *pattern,
|
690
|
+
void *callback_data,
|
691
|
+
cairo_surface_t *target,
|
692
|
+
const cairo_rectangle_int_t *extents)
|
693
|
+
{
|
694
|
+
VALUE rb_pattern;
|
695
|
+
VALUE rb_acquire;
|
696
|
+
cairo_surface_t *acquired_surface = NULL;
|
697
|
+
|
698
|
+
rb_pattern = POINTER2RVAL (callback_data);
|
699
|
+
rb_acquire = rb_iv_get (rb_pattern, "@acquire");
|
700
|
+
if (!NIL_P (rb_acquire))
|
701
|
+
{
|
702
|
+
VALUE rb_acquired_surface;
|
703
|
+
VALUE rb_target;
|
704
|
+
VALUE rb_extents;
|
705
|
+
|
706
|
+
rb_target = CRSURFACE2RVAL (target);
|
707
|
+
rb_extents = rb_funcall (rb_cCairo_Rectangle, id_new, 4,
|
708
|
+
INT2NUM (extents->x),
|
709
|
+
INT2NUM (extents->y),
|
710
|
+
INT2NUM (extents->width),
|
711
|
+
INT2NUM (extents->height));
|
712
|
+
rb_acquired_surface = rb_funcall (rb_acquire, id_call, 3,
|
713
|
+
rb_pattern, rb_target, rb_extents);
|
714
|
+
if (!NIL_P (rb_acquired_surface))
|
715
|
+
acquired_surface = RVAL2CRSURFACE (rb_acquired_surface);
|
716
|
+
}
|
717
|
+
|
718
|
+
return acquired_surface;
|
719
|
+
}
|
720
|
+
|
721
|
+
static void
|
722
|
+
cr_raster_source_release_callback (cairo_pattern_t *pattern,
|
723
|
+
void *callback_data,
|
724
|
+
cairo_surface_t *surface)
|
725
|
+
{
|
726
|
+
VALUE rb_pattern;
|
727
|
+
VALUE rb_release;
|
728
|
+
VALUE rb_surface;
|
729
|
+
|
730
|
+
rb_pattern = POINTER2RVAL (callback_data);
|
731
|
+
rb_release = rb_iv_get (rb_pattern, "@release");
|
732
|
+
if (NIL_P (rb_release))
|
733
|
+
return;
|
734
|
+
|
735
|
+
rb_surface = CRSURFACE2RVAL (surface);
|
736
|
+
rb_funcall (rb_release, id_call, 2, rb_pattern, rb_surface);
|
737
|
+
}
|
738
|
+
|
739
|
+
typedef struct cr_raster_source_notify_callback_data
|
740
|
+
{
|
741
|
+
VALUE pattern;
|
742
|
+
VALUE callback;
|
743
|
+
cairo_status_t status;
|
744
|
+
} cr_raster_source_notify_callback_data_t;
|
745
|
+
|
746
|
+
static VALUE
|
747
|
+
cr_raster_source_notify_callback_body (VALUE data)
|
748
|
+
{
|
749
|
+
cr_raster_source_notify_callback_data_t* callback_data;
|
750
|
+
|
751
|
+
callback_data = RVAL2POINTER (data);
|
752
|
+
rb_funcall (callback_data->callback, id_call, 1, callback_data->pattern);
|
753
|
+
return Qnil;
|
754
|
+
}
|
755
|
+
|
756
|
+
static VALUE
|
757
|
+
cr_raster_source_notify_callback_rescue (VALUE data, VALUE exception)
|
758
|
+
{
|
759
|
+
cr_raster_source_notify_callback_data_t *callback_data;
|
760
|
+
|
761
|
+
callback_data = RVAL2POINTER (data);
|
762
|
+
callback_data->status = rb_cairo__exception_to_status (exception);
|
763
|
+
|
764
|
+
if (callback_data->status == (cairo_status_t)-1)
|
765
|
+
rb_exc_raise (exception);
|
766
|
+
|
767
|
+
return Qnil;
|
768
|
+
}
|
769
|
+
|
770
|
+
static cairo_status_t
|
771
|
+
cr_raster_source_snapshot_callback (cairo_pattern_t *pattern,
|
772
|
+
void *callback_data)
|
773
|
+
{
|
774
|
+
VALUE rb_pattern;
|
775
|
+
VALUE rb_snapshot;
|
776
|
+
cr_raster_source_notify_callback_data_t data;
|
777
|
+
|
778
|
+
rb_pattern = POINTER2RVAL (callback_data);
|
779
|
+
rb_snapshot = rb_iv_get (rb_pattern, "@snapshot");
|
780
|
+
if (NIL_P (rb_snapshot))
|
781
|
+
return CAIRO_STATUS_SUCCESS;
|
782
|
+
|
783
|
+
data.pattern = rb_pattern;
|
784
|
+
data.callback = rb_snapshot;
|
785
|
+
data.status = CAIRO_STATUS_SUCCESS;
|
786
|
+
rb_rescue2 (cr_raster_source_notify_callback_body,
|
787
|
+
POINTER2RVAL (&data),
|
788
|
+
cr_raster_source_notify_callback_rescue,
|
789
|
+
POINTER2RVAL (&data),
|
790
|
+
rb_eException);
|
791
|
+
return data.status;
|
792
|
+
}
|
793
|
+
|
794
|
+
static cairo_status_t
|
795
|
+
cr_raster_source_copy_callback (cairo_pattern_t *pattern,
|
796
|
+
void *callback_data,
|
797
|
+
const cairo_pattern_t *other)
|
798
|
+
{
|
799
|
+
VALUE rb_pattern;
|
800
|
+
VALUE rb_copy;
|
801
|
+
cr_raster_source_notify_callback_data_t data;
|
802
|
+
|
803
|
+
rb_pattern = POINTER2RVAL (callback_data);
|
804
|
+
rb_copy = rb_iv_get (rb_pattern, "@copy");
|
805
|
+
if (NIL_P (rb_copy))
|
806
|
+
return CAIRO_STATUS_SUCCESS;
|
807
|
+
|
808
|
+
data.pattern = rb_pattern;
|
809
|
+
data.callback = rb_copy;
|
810
|
+
data.status = CAIRO_STATUS_SUCCESS;
|
811
|
+
rb_rescue2 (cr_raster_source_notify_callback_body,
|
812
|
+
POINTER2RVAL (&data),
|
813
|
+
cr_raster_source_notify_callback_rescue,
|
814
|
+
POINTER2RVAL (&data),
|
815
|
+
rb_eException);
|
816
|
+
return data.status;
|
817
|
+
}
|
818
|
+
|
819
|
+
static void
|
820
|
+
cr_raster_source_finish_callback (cairo_pattern_t *pattern, void *callback_data)
|
821
|
+
{
|
822
|
+
VALUE rb_pattern;
|
823
|
+
VALUE rb_finish;
|
824
|
+
|
825
|
+
rb_pattern = POINTER2RVAL (callback_data);
|
826
|
+
rb_finish = rb_iv_get (rb_pattern, "@finish");
|
827
|
+
if (NIL_P (rb_finish))
|
828
|
+
return;
|
829
|
+
|
830
|
+
rb_function (rb_finish, id_call, 1, rb_pattern);
|
831
|
+
}
|
832
|
+
|
833
|
+
static VALUE
|
834
|
+
cr_raster_source_pattern_initialize (int argc, VALUE *argv, VALUE self)
|
835
|
+
{
|
836
|
+
cairo_pattern_t *pattern;
|
837
|
+
cairo_content_t content;
|
838
|
+
int width, height;
|
839
|
+
VALUE arg1, arg2, arg3;
|
840
|
+
|
841
|
+
rb_scan_args (argc, argv, "21", &arg1, &arg2, &arg3);
|
842
|
+
|
843
|
+
if (argc == 2)
|
844
|
+
{
|
845
|
+
content = CAIRO_CONTENT_COLOR_ALPHA;
|
846
|
+
width = NUM2INT (arg1);
|
847
|
+
height = NUM2INT (arg2);
|
848
|
+
}
|
849
|
+
else
|
850
|
+
{
|
851
|
+
content = RVAL2CRCONTENT (arg1);
|
852
|
+
width = NUM2INT (arg2);
|
853
|
+
height = NUM2INT (arg3);
|
854
|
+
}
|
855
|
+
|
856
|
+
pattern = cairo_pattern_create_raster_source (RVAL2POINTER (self),
|
857
|
+
content, width, height);
|
858
|
+
cr_pattern_check_status (pattern);
|
859
|
+
|
860
|
+
DATA_PTR (self) = pattern;
|
861
|
+
rb_iv_set (self, "@acquire", Qnil);
|
862
|
+
rb_iv_set (self, "@release", Qnil);
|
863
|
+
rb_iv_set (self, "@snapshot", Qnil);
|
864
|
+
rb_iv_set (self, "@copy", Qnil);
|
865
|
+
rb_iv_set (self, "@finish", Qnil);
|
866
|
+
|
867
|
+
cairo_raster_source_pattern_set_acquire (pattern,
|
868
|
+
cr_raster_source_acquire_callback,
|
869
|
+
cr_raster_source_release_callback);
|
870
|
+
cairo_raster_source_pattern_set_snapshot (pattern,
|
871
|
+
cr_raster_source_snapshot_callback);
|
872
|
+
cairo_raster_source_pattern_set_copy (pattern,
|
873
|
+
cr_raster_source_copy_callback);
|
874
|
+
cairo_raster_source_pattern_set_finish (pattern,
|
875
|
+
cr_raster_source_finish_callback);
|
876
|
+
|
877
|
+
return Qnil;
|
878
|
+
}
|
879
|
+
|
880
|
+
static VALUE
|
881
|
+
cr_raster_source_pattern_acquire (VALUE self)
|
882
|
+
{
|
883
|
+
if (!rb_block_given_p ())
|
884
|
+
{
|
885
|
+
VALUE inspected;
|
886
|
+
|
887
|
+
inspected = rb_funcall (self, id_inspect, 0);
|
888
|
+
rb_raise (rb_eArgError, "acquire block is missing: %s",
|
889
|
+
RVAL2CSTR (inspected));
|
890
|
+
}
|
891
|
+
|
892
|
+
rb_iv_set (self, "@acquire", rb_block_proc ());
|
893
|
+
|
894
|
+
return self;
|
895
|
+
}
|
896
|
+
|
897
|
+
static VALUE
|
898
|
+
cr_raster_source_pattern_release (VALUE self)
|
899
|
+
{
|
900
|
+
if (!rb_block_given_p ())
|
901
|
+
{
|
902
|
+
VALUE inspected;
|
903
|
+
|
904
|
+
inspected = rb_funcall (self, id_inspect, 0);
|
905
|
+
rb_raise (rb_eArgError, "release block is missing: %s",
|
906
|
+
RVAL2CSTR (inspected));
|
907
|
+
}
|
908
|
+
|
909
|
+
rb_iv_set (self, "@release", rb_block_proc ());
|
910
|
+
|
911
|
+
return self;
|
912
|
+
}
|
913
|
+
|
914
|
+
static VALUE
|
915
|
+
cr_raster_source_pattern_snapshot (VALUE self)
|
916
|
+
{
|
917
|
+
if (!rb_block_given_p ())
|
918
|
+
{
|
919
|
+
VALUE inspected;
|
920
|
+
|
921
|
+
inspected = rb_funcall (self, id_inspect, 0);
|
922
|
+
rb_raise (rb_eArgError, "snapshot block is missing: %s",
|
923
|
+
RVAL2CSTR (inspected));
|
924
|
+
}
|
925
|
+
|
926
|
+
rb_iv_set (self, "@snapshot", rb_block_proc ());
|
927
|
+
|
928
|
+
return self;
|
929
|
+
}
|
930
|
+
|
931
|
+
static VALUE
|
932
|
+
cr_raster_source_pattern_copy (VALUE self)
|
933
|
+
{
|
934
|
+
if (!rb_block_given_p ())
|
935
|
+
{
|
936
|
+
VALUE inspected;
|
937
|
+
|
938
|
+
inspected = rb_funcall (self, id_inspect, 0);
|
939
|
+
rb_raise (rb_eArgError, "copy block is missing: %s",
|
940
|
+
RVAL2CSTR (inspected));
|
941
|
+
}
|
942
|
+
|
943
|
+
rb_iv_set (self, "@copy", rb_block_proc ());
|
944
|
+
|
945
|
+
return self;
|
946
|
+
}
|
947
|
+
|
948
|
+
static VALUE
|
949
|
+
cr_raster_source_pattern_finish (VALUE self)
|
950
|
+
{
|
951
|
+
if (!rb_block_given_p ())
|
952
|
+
{
|
953
|
+
VALUE inspected;
|
954
|
+
|
955
|
+
inspected = rb_funcall (self, id_inspect, 0);
|
956
|
+
rb_raise (rb_eArgError, "finish block is missing: %s",
|
957
|
+
RVAL2CSTR (inspected));
|
958
|
+
}
|
959
|
+
|
960
|
+
rb_iv_set (self, "@finish", rb_block_proc ());
|
961
|
+
|
962
|
+
return self;
|
963
|
+
}
|
964
|
+
#endif
|
965
|
+
|
444
966
|
void
|
445
967
|
Init_cairo_pattern (void)
|
446
968
|
{
|
@@ -448,6 +970,8 @@ Init_cairo_pattern (void)
|
|
448
970
|
id_to_rgb = rb_intern ("to_rgb");
|
449
971
|
id_to_a = rb_intern ("to_a");
|
450
972
|
id_inspect = rb_intern ("inspect");
|
973
|
+
id_new = rb_intern ("new");
|
974
|
+
id_call = rb_intern ("call");
|
451
975
|
|
452
976
|
rb_cCairo_Pattern =
|
453
977
|
rb_define_class_under (rb_mCairo, "Pattern", rb_cObject);
|
@@ -537,4 +1061,58 @@ Init_cairo_pattern (void)
|
|
537
1061
|
#endif
|
538
1062
|
|
539
1063
|
RB_CAIRO_DEF_SETTERS (rb_cCairo_RadialPattern);
|
1064
|
+
|
1065
|
+
rb_cCairo_MeshPattern =
|
1066
|
+
rb_define_class_under (rb_mCairo, "MeshPattern",
|
1067
|
+
rb_cCairo_Pattern);
|
1068
|
+
#if CAIRO_CHECK_VERSION(1, 11, 4)
|
1069
|
+
rb_define_method (rb_cCairo_MeshPattern, "initialize",
|
1070
|
+
cr_mesh_pattern_initialize, 0);
|
1071
|
+
rb_define_method (rb_cCairo_MeshPattern, "begin_patch",
|
1072
|
+
cr_mesh_pattern_begin_patch, 0);
|
1073
|
+
rb_define_method (rb_cCairo_MeshPattern, "end_patch",
|
1074
|
+
cr_mesh_pattern_end_patch, 0);
|
1075
|
+
rb_define_method (rb_cCairo_MeshPattern, "curve_to",
|
1076
|
+
cr_mesh_pattern_curve_to, 6);
|
1077
|
+
rb_define_method (rb_cCairo_MeshPattern, "line_to",
|
1078
|
+
cr_mesh_pattern_line_to, 2);
|
1079
|
+
rb_define_method (rb_cCairo_MeshPattern, "move_to",
|
1080
|
+
cr_mesh_pattern_move_to, 2);
|
1081
|
+
rb_define_method (rb_cCairo_MeshPattern, "set_control_point",
|
1082
|
+
cr_mesh_pattern_set_control_point, 3);
|
1083
|
+
rb_define_method (rb_cCairo_MeshPattern, "set_corner_color",
|
1084
|
+
cr_mesh_pattern_set_corner_color_generic, -1);
|
1085
|
+
rb_define_alias (rb_cCairo_MeshPattern,
|
1086
|
+
"set_corner_color_rgb", "set_corner_color");
|
1087
|
+
rb_define_alias (rb_cCairo_MeshPattern,
|
1088
|
+
"set_corner_color_rgba", "set_corner_color");
|
1089
|
+
rb_define_method (rb_cCairo_MeshPattern, "patch_count",
|
1090
|
+
cr_mesh_pattern_get_patch_count, 0);
|
1091
|
+
rb_define_method (rb_cCairo_MeshPattern, "get_path",
|
1092
|
+
cr_mesh_pattern_get_path, 1);
|
1093
|
+
rb_define_method (rb_cCairo_MeshPattern, "get_corner_color",
|
1094
|
+
cr_mesh_pattern_get_corner_color, 2);
|
1095
|
+
rb_define_method (rb_cCairo_MeshPattern, "get_control_point",
|
1096
|
+
cr_mesh_pattern_get_control_point, 2);
|
1097
|
+
#endif
|
1098
|
+
RB_CAIRO_DEF_SETTERS (rb_cCairo_MeshPattern);
|
1099
|
+
|
1100
|
+
rb_cCairo_RasterSourcePattern =
|
1101
|
+
rb_define_class_under (rb_mCairo, "RasterSourcePattern",
|
1102
|
+
rb_cCairo_Pattern);
|
1103
|
+
#if CAIRO_CHECK_VERSION(1, 11, 4)
|
1104
|
+
rb_define_method (rb_cCairo_RasterSourcePattern, "initialize",
|
1105
|
+
cr_raster_source_pattern_initialize, -1);
|
1106
|
+
rb_define_method (rb_cCairo_RasterSourcePattern, "acquire",
|
1107
|
+
cr_raster_source_pattern_acquire, 0);
|
1108
|
+
rb_define_method (rb_cCairo_RasterSourcePattern, "release",
|
1109
|
+
cr_raster_source_pattern_release, 0);
|
1110
|
+
rb_define_method (rb_cCairo_RasterSourcePattern, "snapshot",
|
1111
|
+
cr_raster_source_pattern_snapshot, 0);
|
1112
|
+
rb_define_method (rb_cCairo_RasterSourcePattern, "copy",
|
1113
|
+
cr_raster_source_pattern_copy, 0);
|
1114
|
+
rb_define_method (rb_cCairo_RasterSourcePattern, "finish",
|
1115
|
+
cr_raster_source_pattern_finish, 0);
|
1116
|
+
#endif
|
1117
|
+
RB_CAIRO_DEF_SETTERS (rb_cCairo_RasterSourcePattern);
|
540
1118
|
}
|