cairo 1.16.1 → 1.16.6

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.
@@ -50,7 +50,6 @@ EXPORTS
50
50
  rb_cCairo_DRMSurface DATA
51
51
  rb_cCairo_TeeSurface DATA
52
52
  rb_cCairo_XMLSurface DATA
53
- rb_cCairo_SkiaSurface DATA
54
53
  rb_cCairo_SubSurface DATA
55
54
  rb_cCairo_CoglSurface DATA
56
55
 
@@ -22,21 +22,11 @@ package = "cairo"
22
22
  module_name = "cairo"
23
23
  major, minor, micro = 1, 2, 0
24
24
 
25
- base_dir = Pathname(__FILE__).dirname.parent.parent
26
- checking_for(checking_message("Win32 OS")) do
27
- case RUBY_PLATFORM
28
- when /mingw|mswin32/
29
- $defs << "-DRUBY_CAIRO_PLATFORM_WIN32"
30
- import_library_name = "libruby-#{module_name}.a"
31
- $DLDFLAGS << " -Wl,--out-implib=#{import_library_name}"
32
- $cleanfiles << import_library_name
33
- binary_base_dir = base_dir + "vendor" + "local"
34
- if with_config('vendor-override', binary_base_dir.exist?)
35
- $CFLAGS += " -I#{binary_base_dir}/include"
36
- pkg_config_dir = binary_base_dir + "lib" + "pkgconfig"
37
- PKGConfig.add_path(pkg_config_dir.to_s)
38
- PKGConfig.set_override_variable("prefix", binary_base_dir.to_s)
39
- end
25
+ checking_for(checking_message("Homebrew")) do
26
+ platform = NativePackageInstaller::Platform.detect
27
+ if platform.is_a?(NativePackageInstaller::Platform::Homebrew)
28
+ libffi_prefix = `brew --prefix libffi`.chomp
29
+ PKGConfig.add_path("#{libffi_prefix}/lib/pkgconfig")
40
30
  true
41
31
  else
42
32
  false
@@ -58,17 +48,18 @@ def required_pkg_config_package(package_info, native_package_info=nil)
58
48
  end
59
49
 
60
50
  unless required_pkg_config_package([package, major, minor, micro],
51
+ :arch_linux => "cairo",
61
52
  :debian => "libcairo2-dev",
62
- :redhat => "cairo-devel",
63
53
  :homebrew => "cairo",
64
54
  :macports => "cairo",
65
- :msys2 => "cairo")
55
+ :msys2 => "cairo",
56
+ :redhat => "cairo-devel")
66
57
  exit(false)
67
58
  end
68
59
 
69
60
  PKGConfig.have_package("cairo-ft")
70
61
 
71
- checking_for(checking_message("Mac OS X")) do
62
+ checking_for(checking_message("macOS")) do
72
63
  case RUBY_PLATFORM
73
64
  when /darwin/
74
65
  if have_macro("CAIRO_HAS_QUARTZ_SURFACE", ["cairo.h"])
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-09-19 12:56:27 $
7
7
  *
8
- * Copyright 2006-2018 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2006-2020 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
  *
@@ -53,17 +53,9 @@
53
53
 
54
54
  RB_CAIRO_BEGIN_DECLS
55
55
 
56
- #if defined(RUBY_CAIRO_PLATFORM_WIN32) && !defined(RB_CAIRO_PLATFORM_WIN32)
57
- # define RB_CAIRO_PLATFORM_WIN32 RUBY_CAIRO_PLATFORM_WIN32
58
- #endif
59
-
60
- #if defined(RUBY_CAIRO_STATIC_COMPILATION) && !defined(RB_CAIRO_STATIC_COMPILATION)
61
- # define RB_CAIRO_STATIC_COMPILATION RUBY_CAIRO_STATIC_COMPILATION
62
- #endif
63
-
64
- #if defined(RB_CAIRO_PLATFORM_WIN32) && !defined(RB_CAIRO_STATIC_COMPILATION)
56
+ #ifdef __WIN32__
65
57
  # ifdef RB_CAIRO_COMPILATION
66
- # define RB_CAIRO_VAR __declspec(dllexport)
58
+ # define RB_CAIRO_VAR extern __declspec(dllexport)
67
59
  # else
68
60
  # define RB_CAIRO_VAR extern __declspec(dllimport)
69
61
  # endif
@@ -73,7 +65,7 @@ RB_CAIRO_BEGIN_DECLS
73
65
 
74
66
  #define RB_CAIRO_VERSION_MAJOR 1
75
67
  #define RB_CAIRO_VERSION_MINOR 16
76
- #define RB_CAIRO_VERSION_MICRO 1
68
+ #define RB_CAIRO_VERSION_MICRO 6
77
69
 
78
70
  RB_CAIRO_VAR VALUE rb_mCairo;
79
71
  RB_CAIRO_VAR VALUE rb_cCairo_Context;
@@ -125,7 +117,6 @@ RB_CAIRO_VAR VALUE rb_cCairo_GLTextureSurface;
125
117
  RB_CAIRO_VAR VALUE rb_cCairo_DRMSurface;
126
118
  RB_CAIRO_VAR VALUE rb_cCairo_TeeSurface;
127
119
  RB_CAIRO_VAR VALUE rb_cCairo_XMLSurface;
128
- RB_CAIRO_VAR VALUE rb_cCairo_SkiaSurface;
129
120
  RB_CAIRO_VAR VALUE rb_cCairo_SubSurface;
130
121
  RB_CAIRO_VAR VALUE rb_cCairo_Device;
131
122
  RB_CAIRO_VAR VALUE rb_cCairo_DRMDevice;
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-09-19 12:56:27 $
7
7
  *
8
- * Copyright 2005-2017 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2005-2019 Kouhei Sutou <kou@cozmixng.org>
9
9
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
10
10
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
11
11
  *
@@ -92,7 +92,9 @@ VALUE rb_mCairo_SVGUnit = Qnil;
92
92
  #else
93
93
  # define CAIRO_FORMAT_MIN CAIRO_FORMAT_ARGB32
94
94
  #endif
95
- #if CAIRO_CHECK_VERSION(1, 11, 4)
95
+ #if CAIRO_CHECK_VERSION(1, 17, 2)
96
+ # define CAIRO_FORMAT_MAX CAIRO_FORMAT_RGBA128F
97
+ #elif CAIRO_CHECK_VERSION(1, 11, 4)
96
98
  # define CAIRO_FORMAT_MAX CAIRO_FORMAT_RGB30
97
99
  #else
98
100
  # define CAIRO_FORMAT_MAX CAIRO_FORMAT_RGB16_565
@@ -566,6 +568,12 @@ Init_cairo_constants (void)
566
568
  rb_define_const (rb_mCairo_Format, "RGB30",
567
569
  INT2FIX (CAIRO_FORMAT_RGB30));
568
570
  #endif
571
+ #if CAIRO_CHECK_VERSION(1, 17, 2)
572
+ rb_define_const (rb_mCairo_Format, "RGB96F",
573
+ INT2FIX (CAIRO_FORMAT_RGB96F));
574
+ rb_define_const (rb_mCairo_Format, "RGBA128F",
575
+ INT2FIX (CAIRO_FORMAT_RGBA128F));
576
+ #endif
569
577
 
570
578
  #if CAIRO_CHECK_VERSION(1, 5, 8)
571
579
  rb_define_singleton_method (rb_mCairo_Format, "stride_for_width",
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-09-26 13:52:08 $
7
7
  *
8
- * Copyright 2005-2018 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2005-2019 Kouhei Sutou <kou@cozmixng.org>
9
9
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
10
10
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
11
11
  *
@@ -240,6 +240,12 @@ cr_to_ptr (VALUE self)
240
240
  1, PTR2NUM (_SELF));
241
241
  }
242
242
 
243
+ static VALUE
244
+ cr_raw_address (VALUE self)
245
+ {
246
+ return PTR2NUM (_SELF);
247
+ }
248
+
243
249
 
244
250
  static VALUE
245
251
  cr_restore (VALUE self)
@@ -351,7 +357,7 @@ cr_set_source_rgb (int argc, VALUE *argv, VALUE self)
351
357
  if (n == 1 && rb_cairo__is_kind_of (red, rb_cArray))
352
358
  {
353
359
  VALUE ary = red;
354
- n = RARRAY_LEN (ary);
360
+ n = (int) RARRAY_LEN (ary);
355
361
  red = rb_ary_entry (ary, 0);
356
362
  green = rb_ary_entry (ary, 1);
357
363
  blue = rb_ary_entry (ary, 2);
@@ -388,7 +394,7 @@ cr_set_source_rgba (int argc, VALUE *argv, VALUE self)
388
394
  if (n == 1 && rb_cairo__is_kind_of (red, rb_cArray))
389
395
  {
390
396
  VALUE ary = red;
391
- n = RARRAY_LEN (ary);
397
+ n = (int) RARRAY_LEN (ary);
392
398
  red = rb_ary_entry (ary, 0);
393
399
  green = rb_ary_entry (ary, 1);
394
400
  blue = rb_ary_entry (ary, 2);
@@ -567,7 +573,7 @@ cr_set_dash (int argc, VALUE *argv, VALUE self)
567
573
  {
568
574
  int i, length;
569
575
  double *values;
570
- length = RARRAY_LEN (dash_array);
576
+ length = (int) RARRAY_LEN (dash_array);
571
577
  values = ALLOCA_N (double, length);
572
578
  if (!values)
573
579
  {
@@ -1323,7 +1329,7 @@ cr_show_text_glyphs (VALUE self, VALUE rb_utf8, VALUE rb_glyphs,
1323
1329
 
1324
1330
  cr = _SELF;
1325
1331
  utf8 = RSTRING_PTR (rb_utf8);
1326
- utf8_len = RSTRING_LEN (rb_utf8);
1332
+ utf8_len = (int) RSTRING_LEN (rb_utf8);
1327
1333
  rb_cairo__glyphs_from_ruby_object (rb_glyphs, &glyphs, &num_glyphs);
1328
1334
  rb_cairo__text_clusters_from_ruby_object (rb_clusters,
1329
1335
  &clusters, &num_clusters);
@@ -1874,6 +1880,8 @@ Init_cairo_context (void)
1874
1880
 
1875
1881
  rb_define_method (rb_cCairo_Context, "to_ptr", cr_to_ptr, 0);
1876
1882
 
1883
+ rb_define_method (rb_cCairo_Context, "raw_address", cr_raw_address, 0);
1884
+
1877
1885
  #if CAIRO_CHECK_VERSION(1, 15, 4)
1878
1886
  /* Logical structure tagging functions */
1879
1887
  {
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * Ruby Cairo Binding
4
4
  *
5
- * Copyright 2010-2012 Kouhei Sutou <kou@cozmixng.org>
5
+ * Copyright 2010-2019 Kouhei Sutou <kou@cozmixng.org>
6
6
  *
7
7
  * This file is made available under the same terms as Ruby
8
8
  *
@@ -343,7 +343,7 @@ cr_script_device_write_comment (VALUE self, VALUE comment)
343
343
  device = _SELF;
344
344
  cairo_script_write_comment (device,
345
345
  StringValuePtr (comment),
346
- RSTRING_LEN (comment));
346
+ (int) RSTRING_LEN (comment));
347
347
  cr_device_check_status (device);
348
348
  return Qnil;
349
349
  }
@@ -5,6 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-09-26 14:13:58 $
7
7
  *
8
+ * Copyright 2003-2019 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
  *
@@ -148,7 +149,11 @@ cr_font_face_freetype_supported_p (VALUE klass)
148
149
 
149
150
  #ifdef CAIRO_HAS_FT_FONT
150
151
  static VALUE
151
- cr_freetype_done_library (VALUE data)
152
+ cr_freetype_done_library (VALUE yielded_arg,
153
+ VALUE callback_arg,
154
+ int argc,
155
+ const VALUE *argv,
156
+ VALUE block_arg)
152
157
  {
153
158
  cr_freetype_finishing = CR_TRUE;
154
159
  if (cr_freetype_n_faces == 0)
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * Ruby Cairo Binding
4
4
  *
5
- * Copyright 2005-2010 Kouhei Sutou <kou@cozmixng.org>
5
+ * Copyright 2005-2019 Kouhei Sutou <kou@cozmixng.org>
6
6
  *
7
7
  * This file is made available under the same terms as Ruby
8
8
  *
@@ -44,11 +44,11 @@ rb_cairo__io_closure_free (void *closure)
44
44
  }
45
45
 
46
46
  static VALUE
47
- rb_cairo__io_func_rescue (VALUE io_closure)
47
+ rb_cairo__io_func_rescue (VALUE io_closure, VALUE error)
48
48
  {
49
49
  rb_cairo__io_callback_closure_t *closure;
50
50
  closure = (rb_cairo__io_callback_closure_t *)io_closure;
51
- closure->error = RB_ERRINFO;
51
+ closure->error = error;
52
52
  return Qnil;
53
53
  }
54
54
 
@@ -70,7 +70,7 @@ rb_cairo__io_write_func_invoke (VALUE write_closure)
70
70
  VALUE output, data;
71
71
  long written_bytes;
72
72
  rb_cairo__io_callback_closure_t *closure;
73
- unsigned int length;
73
+ long length;
74
74
 
75
75
  closure = (rb_cairo__io_callback_closure_t *)write_closure;
76
76
 
@@ -118,7 +118,7 @@ rb_cairo__io_read_func_invoke (VALUE read_closure)
118
118
  {
119
119
  VALUE input, result;
120
120
  rb_cairo__io_callback_closure_t *closure;
121
- unsigned int length, rest;
121
+ long length, rest;
122
122
 
123
123
  closure = (rb_cairo__io_callback_closure_t *)read_closure;
124
124
  input = closure->target;
@@ -133,7 +133,7 @@ rb_cairo__io_read_func_invoke (VALUE read_closure)
133
133
  rb_cairo__io_id_read, 1, INT2NUM (rest)));
134
134
  }
135
135
 
136
- memcpy ((void *)closure->data, (const void *)StringValuePtr (result), length);
136
+ memcpy ((void *)closure->data, (const void *) StringValuePtr (result), length);
137
137
 
138
138
  return Qnil;
139
139
  }
@@ -5,7 +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
+ * Copyright 2012-2019 Kouhei Sutou <kou@cozmixng.org>
9
9
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
10
10
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
11
11
  *
@@ -208,7 +208,7 @@ cr_solid_pattern_initialize (int argc, VALUE *argv, VALUE self)
208
208
  (RARRAY_LEN (red) == 3 || RARRAY_LEN (red) == 4))
209
209
  {
210
210
  VALUE ary = red;
211
- n = RARRAY_LEN (ary);
211
+ n = (int) RARRAY_LEN (ary);
212
212
 
213
213
  red = rb_ary_entry (ary, 0);
214
214
  green = rb_ary_entry (ary, 1);
@@ -315,7 +315,7 @@ cr_gradient_pattern_add_color_stop_generic (int argc, VALUE *argv, VALUE self)
315
315
  if (n == 2 && rb_cairo__is_kind_of (red, rb_cArray))
316
316
  {
317
317
  VALUE ary = red;
318
- n = RARRAY_LEN (ary) + 1;
318
+ n = (int) RARRAY_LEN (ary) + 1;
319
319
 
320
320
  red = rb_ary_entry (ary, 0);
321
321
  green = rb_ary_entry (ary, 1);
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-08-17 07:21:42 $
7
7
  *
8
- * Copyright 2005-2014 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2005-2019 Kouhei Sutou <kou@cozmixng.org>
9
9
  *
10
10
  * This file is made available under the same terms as Ruby
11
11
  *
@@ -64,9 +64,8 @@ rb_cairo__const_get (VALUE name, const char *prefix)
64
64
  normalized_name_len = strlen (normalized_name);
65
65
 
66
66
  const_name = ALLOCA_N (char, prefix_len + normalized_name_len + 1);
67
- strncpy (const_name, prefix, prefix_len);
68
- strncpy (const_name + prefix_len, normalized_name, normalized_name_len);
69
- const_name[prefix_len + normalized_name_len] = '\0';
67
+ strcpy (const_name, prefix);
68
+ strcpy (const_name + prefix_len, normalized_name);
70
69
 
71
70
  return rb_const_get (rb_mCairo, rb_intern (const_name));
72
71
  }
@@ -160,7 +159,7 @@ rb_cairo__glyphs_from_ruby_object (VALUE rb_glyphs,
160
159
  return;
161
160
  }
162
161
 
163
- len = RARRAY_LEN (rb_glyphs);
162
+ len = (int) RARRAY_LEN (rb_glyphs);
164
163
  if (*num_glyphs < len)
165
164
  *glyphs = cairo_glyph_allocate (len);
166
165
  *num_glyphs = len;
@@ -202,7 +201,7 @@ rb_cairo__text_clusters_from_ruby_object (VALUE rb_clusters,
202
201
  return;
203
202
  }
204
203
 
205
- len = RARRAY_LEN (rb_clusters);
204
+ len = (int) RARRAY_LEN (rb_clusters);
206
205
  if (*num_clusters < len)
207
206
  *clusters = cairo_text_cluster_allocate (len);
208
207
  *num_clusters = len;
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-08-17 07:21:42 $
7
7
  *
8
- * Copyright 2005-2018 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2005-2019 Kouhei Sutou <kou@cozmixng.org>
9
9
  *
10
10
  * This file is made available under the same terms as Ruby
11
11
  *
@@ -78,7 +78,7 @@ extern void Init_cairo_text_cluster (void);
78
78
  do \
79
79
  { \
80
80
  Check_Type (rb_array, T_ARRAY); \
81
- length = RARRAY_LEN (rb_array); \
81
+ length = (int) RARRAY_LEN (rb_array); \
82
82
  glyphs = ALLOCA_N (cairo_glyph_t, length); \
83
83
  \
84
84
  if (!glyphs) \
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-09-19 12:56:27 $
7
7
  *
8
- * Copyright 2005-2008 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2005-2019 Kouhei Sutou <kou@cozmixng.org>
9
9
  *
10
10
  * This file is made available under the same terms as Ruby
11
11
  *
@@ -132,7 +132,7 @@ cr_scaled_font_text_to_glyphs (VALUE self, VALUE rb_x, VALUE rb_y, VALUE rb_utf8
132
132
  x = NUM2DBL (rb_x);
133
133
  y = NUM2DBL (rb_y);
134
134
  utf8 = RSTRING_PTR (rb_utf8);
135
- utf8_len = RSTRING_LEN (rb_utf8);
135
+ utf8_len = (int) RSTRING_LEN (rb_utf8);
136
136
 
137
137
  status = cairo_scaled_font_text_to_glyphs (_SELF (self),
138
138
  x, y, utf8, utf8_len,
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * Ruby Cairo Binding
4
4
  *
5
- * Copyright 2005-2018 Kouhei Sutou <kou@cozmixng.org>
5
+ * Copyright 2005-2019 Kouhei Sutou <kou@cozmixng.org>
6
6
  * Copyright 2014 Patrick Hanevold <patrick.hanevold@gmail.com>
7
7
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
8
8
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
@@ -2107,9 +2107,9 @@ Init_cairo_surface (void)
2107
2107
  #endif
2108
2108
  #if CAIRO_CHECK_VERSION(1, 5, 2)
2109
2109
  rb_define_method (rb_cCairo_Surface, "copy_page",
2110
- cr_surface_copy_page, 2);
2110
+ cr_surface_copy_page, 0);
2111
2111
  rb_define_method (rb_cCairo_Surface, "show_page",
2112
- cr_surface_show_page, 2);
2112
+ cr_surface_show_page, 0);
2113
2113
  #endif
2114
2114
 
2115
2115
  #ifdef CAIRO_HAS_PNG_FUNCTIONS
@@ -14,7 +14,7 @@ module Cairo
14
14
  _, *value = value if [:rgb, :rgba].include?(value.first)
15
15
  RGB.new(*value)
16
16
  end
17
- when /\A#/ #
17
+ when /\A\#/
18
18
  parse_hex_color(value)
19
19
  when String, Symbol
20
20
  name = Cairo.normalize_const_name(value)
@@ -34,16 +34,16 @@ module Cairo
34
34
  HEX_RE = "(?i:[a-f\\d])"
35
35
  def parse_hex_color(value)
36
36
  case value
37
- when /\A#((?:#{HEX_RE}){3,4})\z/ #
37
+ when /\A\#((?:#{HEX_RE}){3,4})\z/
38
38
  RGB.new(*$1.scan(/./).collect {|part| part.hex / 15.0})
39
- when /\A#((?:#{HEX_RE}{2,2}){3,4})\z/ #
39
+ when /\A\#((?:#{HEX_RE}{2,2}){3,4})\z/
40
40
  RGB.new(*$1.scan(/.{2,2}/).collect {|part| part.hex / 255.0})
41
- when /\A#((?:#{HEX_RE}{4,4}){3,4})\z/ #
41
+ when /\A\#((?:#{HEX_RE}{4,4}){3,4})\z/
42
42
  RGB.new(*$1.scan(/.{4,4}/).collect {|part| part.hex / 65535.0})
43
43
  else
44
44
  message = "invalid hex color format: #{value} should be "
45
- message << "#RGB, #RGBA, #RRGGBB, #RRGGBBAA, #RRRRGGGGBBBB "
46
- message << "or #RRRRGGGGBBBBAAAA"
45
+ message << "\#RGB, \#RGBA, \#RRGGBB, \#RRGGBBAA, \#RRRRGGGGBBBB "
46
+ message << "or \#RRRRGGGGBBBBAAAA"
47
47
  raise ArgumentError, message
48
48
  end
49
49
  end
@@ -106,7 +106,7 @@ module Cairo
106
106
  alias_method :to_ary, :to_a
107
107
 
108
108
  def to_s
109
- "#%02X%02X%02X%02X" % to_a.collect {|v| (v * 255).ceil}
109
+ "#%02X%02X%02X%02X" % to_a.collect {|v| (v * 255).round(1)}
110
110
  end
111
111
 
112
112
  def to_rgb