Bug 1377257 part 1 - Add cairo_scaled_font_get_hint_metrics to avoid malloc/free that is required to use cairo_scaled_font_get_font_options. r=jfkthame
authorMats Palmgren <mats@mozilla.com>
Thu, 29 Jun 2017 23:03:13 +0200
changeset 1173033 b6fca462dee7fa18100a56c2ccd80f4c992dd37a
parent 1172646 f3483af8ecf997453064201c49c48a682c7f3c29
child 1173034 7fc5916a7f158ab3c4258ba8b2139795f119e42e
push id201747
push usermpalmgren@mozilla.com
push dateThu, 29 Jun 2017 21:07:00 +0000
treeherdertry@3d58822a17ae [default view] [failures only]
reviewersjfkthame
bugs1377257
milestone56.0a1
Bug 1377257 part 1 - Add cairo_scaled_font_get_hint_metrics to avoid malloc/free that is required to use cairo_scaled_font_get_font_options. r=jfkthame
gfx/cairo/add-cairo_scaled_font_get_hint_metrics
gfx/cairo/cairo/src/cairo-rename.h
gfx/cairo/cairo/src/cairo-scaled-font.c
gfx/cairo/cairo/src/cairo.h
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/add-cairo_scaled_font_get_hint_metrics
@@ -0,0 +1,168 @@
+# HG changeset patch
+# User Mats Palmgren <mats@mozilla.com>
+# Parent  f3483af8ecf997453064201c49c48a682c7f3c29
+Bug 1377257 part 1 - Add cairo_scaled_font_get_hint_metrics to avoid malloc/free that is required to use cairo_scaled_font_get_font_options.  r=jfkthame
+
+diff --git a/gfx/cairo/add-cairo_scaled_font_get_hint_metrics b/gfx/cairo/add-cairo_scaled_font_get_hint_metrics
+new file mode 100644
+--- /dev/null
++++ b/gfx/cairo/add-cairo_scaled_font_get_hint_metrics
+@@ -0,0 +1,82 @@
++# HG changeset patch
++# User Mats Palmgren <mats@mozilla.com>
++# Parent  f3483af8ecf997453064201c49c48a682c7f3c29
++Bug 1377257 part 1 - Add cairo_scaled_font_get_hint_metrics to avoid malloc/free that is required to use cairo_scaled_font_get_font_options.  r=jfkthame
++
++diff --git a/gfx/cairo/cairo/src/cairo-rename.h b/gfx/cairo/cairo/src/cairo-rename.h
++--- a/gfx/cairo/cairo/src/cairo-rename.h
+++++ b/gfx/cairo/cairo/src/cairo-rename.h
++@@ -262,16 +262,17 @@
++ #define cairo_scale _moz_cairo_scale
++ #define cairo_scaled_font_create _moz_cairo_scaled_font_create
++ #define cairo_scaled_font_destroy _moz_cairo_scaled_font_destroy
++ #define cairo_scaled_font_extents _moz_cairo_scaled_font_extents
++ #define cairo_scaled_font_get_ctm _moz_cairo_scaled_font_get_ctm
++ #define cairo_scaled_font_get_font_face _moz_cairo_scaled_font_get_font_face
++ #define cairo_scaled_font_get_font_matrix _moz_cairo_scaled_font_get_font_matrix
++ #define cairo_scaled_font_get_font_options _moz_cairo_scaled_font_get_font_options
+++#define cairo_scaled_font_get_hint_metrics _moz_cairo_scaled_font_get_hint_metrics
++ #define cairo_scaled_font_get_reference_count _moz_cairo_scaled_font_get_reference_count
++ #define cairo_scaled_font_get_scale_matrix _moz_cairo_scaled_font_get_scale_matrix
++ #define cairo_scaled_font_get_type _moz_cairo_scaled_font_get_type
++ #define cairo_scaled_font_get_user_data _moz_cairo_scaled_font_get_user_data
++ #define cairo_scaled_font_glyph_extents _moz_cairo_scaled_font_glyph_extents
++ #define cairo_scaled_font_reference _moz_cairo_scaled_font_reference
++ #define cairo_scaled_font_set_user_data _moz_cairo_scaled_font_set_user_data
++ #define cairo_scaled_font_status _moz_cairo_scaled_font_status
++diff --git a/gfx/cairo/cairo/src/cairo-scaled-font.c b/gfx/cairo/cairo/src/cairo-scaled-font.c
++--- a/gfx/cairo/cairo/src/cairo-scaled-font.c
+++++ b/gfx/cairo/cairo/src/cairo-scaled-font.c
++@@ -2983,8 +2983,28 @@ cairo_scaled_font_get_font_options (cair
++     if (scaled_font->status) {
++ 	_cairo_font_options_init_default (options);
++ 	return;
++     }
++ 
++     _cairo_font_options_init_copy (options, &scaled_font->options);
++ }
++ slim_hidden_def (cairo_scaled_font_get_font_options);
+++
+++/**
+++ * cairo_scaled_font_get_hint_metrics:
+++ * @scaled_font: a #cairo_scaled_font_t
+++ *
+++ * Mozilla extension since the required malloc/free to use
+++ * cairo_scaled_font_get_font_options() above is too slow.
+++ **/
+++cairo_public cairo_hint_metrics_t
+++cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t		*scaled_font)
+++{
+++    cairo_font_options_t options;
+++    if (scaled_font->status) {
+++	_cairo_font_options_init_default (&options);
+++    } else {
+++	_cairo_font_options_init_copy (&options, &scaled_font->options);
+++    }
+++    return options.hint_metrics;
+++}
+++slim_hidden_def (cairo_scaled_font_get_hint_metrics);
++diff --git a/gfx/cairo/cairo/src/cairo.h b/gfx/cairo/cairo/src/cairo.h
++--- a/gfx/cairo/cairo/src/cairo.h
+++++ b/gfx/cairo/cairo/src/cairo.h
++@@ -1493,16 +1493,20 @@ cairo_scaled_font_get_ctm (cairo_scaled_
++ cairo_public void
++ cairo_scaled_font_get_scale_matrix (cairo_scaled_font_t	*scaled_font,
++ 				    cairo_matrix_t	*scale_matrix);
++ 
++ cairo_public void
++ cairo_scaled_font_get_font_options (cairo_scaled_font_t		*scaled_font,
++ 				    cairo_font_options_t	*options);
++ 
+++cairo_public cairo_hint_metrics_t
+++cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t		*scaled_font);
+++
+++
++ 
++ /* Toy fonts */
++ 
++ cairo_public cairo_font_face_t *
++ cairo_toy_font_face_create (const char           *family,
++ 			    cairo_font_slant_t    slant,
++ 			    cairo_font_weight_t   weight);
++ 
+diff --git a/gfx/cairo/cairo/src/cairo-rename.h b/gfx/cairo/cairo/src/cairo-rename.h
+--- a/gfx/cairo/cairo/src/cairo-rename.h
++++ b/gfx/cairo/cairo/src/cairo-rename.h
+@@ -262,16 +262,17 @@
+ #define cairo_scale _moz_cairo_scale
+ #define cairo_scaled_font_create _moz_cairo_scaled_font_create
+ #define cairo_scaled_font_destroy _moz_cairo_scaled_font_destroy
+ #define cairo_scaled_font_extents _moz_cairo_scaled_font_extents
+ #define cairo_scaled_font_get_ctm _moz_cairo_scaled_font_get_ctm
+ #define cairo_scaled_font_get_font_face _moz_cairo_scaled_font_get_font_face
+ #define cairo_scaled_font_get_font_matrix _moz_cairo_scaled_font_get_font_matrix
+ #define cairo_scaled_font_get_font_options _moz_cairo_scaled_font_get_font_options
++#define cairo_scaled_font_get_hint_metrics _moz_cairo_scaled_font_get_hint_metrics
+ #define cairo_scaled_font_get_reference_count _moz_cairo_scaled_font_get_reference_count
+ #define cairo_scaled_font_get_scale_matrix _moz_cairo_scaled_font_get_scale_matrix
+ #define cairo_scaled_font_get_type _moz_cairo_scaled_font_get_type
+ #define cairo_scaled_font_get_user_data _moz_cairo_scaled_font_get_user_data
+ #define cairo_scaled_font_glyph_extents _moz_cairo_scaled_font_glyph_extents
+ #define cairo_scaled_font_reference _moz_cairo_scaled_font_reference
+ #define cairo_scaled_font_set_user_data _moz_cairo_scaled_font_set_user_data
+ #define cairo_scaled_font_status _moz_cairo_scaled_font_status
+diff --git a/gfx/cairo/cairo/src/cairo-scaled-font.c b/gfx/cairo/cairo/src/cairo-scaled-font.c
+--- a/gfx/cairo/cairo/src/cairo-scaled-font.c
++++ b/gfx/cairo/cairo/src/cairo-scaled-font.c
+@@ -2983,8 +2983,28 @@ cairo_scaled_font_get_font_options (cair
+     if (scaled_font->status) {
+ 	_cairo_font_options_init_default (options);
+ 	return;
+     }
+ 
+     _cairo_font_options_init_copy (options, &scaled_font->options);
+ }
+ slim_hidden_def (cairo_scaled_font_get_font_options);
++
++/**
++ * cairo_scaled_font_get_hint_metrics:
++ * @scaled_font: a #cairo_scaled_font_t
++ *
++ * Mozilla extension since the required malloc/free to use
++ * cairo_scaled_font_get_font_options() above is too slow.
++ **/
++cairo_public cairo_hint_metrics_t
++cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t		*scaled_font)
++{
++    cairo_font_options_t options;
++    if (scaled_font->status) {
++	_cairo_font_options_init_default (&options);
++    } else {
++	_cairo_font_options_init_copy (&options, &scaled_font->options);
++    }
++    return options.hint_metrics;
++}
++slim_hidden_def (cairo_scaled_font_get_hint_metrics);
+diff --git a/gfx/cairo/cairo/src/cairo.h b/gfx/cairo/cairo/src/cairo.h
+--- a/gfx/cairo/cairo/src/cairo.h
++++ b/gfx/cairo/cairo/src/cairo.h
+@@ -1493,16 +1493,19 @@ cairo_scaled_font_get_ctm (cairo_scaled_
+ cairo_public void
+ cairo_scaled_font_get_scale_matrix (cairo_scaled_font_t	*scaled_font,
+ 				    cairo_matrix_t	*scale_matrix);
+ 
+ cairo_public void
+ cairo_scaled_font_get_font_options (cairo_scaled_font_t		*scaled_font,
+ 				    cairo_font_options_t	*options);
+ 
++cairo_public cairo_hint_metrics_t
++cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t		*scaled_font);
++
+ 
+ /* Toy fonts */
+ 
+ cairo_public cairo_font_face_t *
+ cairo_toy_font_face_create (const char           *family,
+ 			    cairo_font_slant_t    slant,
+ 			    cairo_font_weight_t   weight);
+ 
--- a/gfx/cairo/cairo/src/cairo-rename.h
+++ b/gfx/cairo/cairo/src/cairo-rename.h
@@ -262,16 +262,17 @@
 #define cairo_scale _moz_cairo_scale
 #define cairo_scaled_font_create _moz_cairo_scaled_font_create
 #define cairo_scaled_font_destroy _moz_cairo_scaled_font_destroy
 #define cairo_scaled_font_extents _moz_cairo_scaled_font_extents
 #define cairo_scaled_font_get_ctm _moz_cairo_scaled_font_get_ctm
 #define cairo_scaled_font_get_font_face _moz_cairo_scaled_font_get_font_face
 #define cairo_scaled_font_get_font_matrix _moz_cairo_scaled_font_get_font_matrix
 #define cairo_scaled_font_get_font_options _moz_cairo_scaled_font_get_font_options
+#define cairo_scaled_font_get_hint_metrics _moz_cairo_scaled_font_get_hint_metrics
 #define cairo_scaled_font_get_reference_count _moz_cairo_scaled_font_get_reference_count
 #define cairo_scaled_font_get_scale_matrix _moz_cairo_scaled_font_get_scale_matrix
 #define cairo_scaled_font_get_type _moz_cairo_scaled_font_get_type
 #define cairo_scaled_font_get_user_data _moz_cairo_scaled_font_get_user_data
 #define cairo_scaled_font_glyph_extents _moz_cairo_scaled_font_glyph_extents
 #define cairo_scaled_font_reference _moz_cairo_scaled_font_reference
 #define cairo_scaled_font_set_user_data _moz_cairo_scaled_font_set_user_data
 #define cairo_scaled_font_status _moz_cairo_scaled_font_status
--- a/gfx/cairo/cairo/src/cairo-scaled-font.c
+++ b/gfx/cairo/cairo/src/cairo-scaled-font.c
@@ -2983,8 +2983,28 @@ cairo_scaled_font_get_font_options (cair
     if (scaled_font->status) {
 	_cairo_font_options_init_default (options);
 	return;
     }
 
     _cairo_font_options_init_copy (options, &scaled_font->options);
 }
 slim_hidden_def (cairo_scaled_font_get_font_options);
+
+/**
+ * cairo_scaled_font_get_hint_metrics:
+ * @scaled_font: a #cairo_scaled_font_t
+ *
+ * Mozilla extension since the required malloc/free to use
+ * cairo_scaled_font_get_font_options() above is too slow.
+ **/
+cairo_public cairo_hint_metrics_t
+cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t		*scaled_font)
+{
+    cairo_font_options_t options;
+    if (scaled_font->status) {
+	_cairo_font_options_init_default (&options);
+    } else {
+	_cairo_font_options_init_copy (&options, &scaled_font->options);
+    }
+    return options.hint_metrics;
+}
+slim_hidden_def (cairo_scaled_font_get_hint_metrics);
--- a/gfx/cairo/cairo/src/cairo.h
+++ b/gfx/cairo/cairo/src/cairo.h
@@ -1493,16 +1493,19 @@ cairo_scaled_font_get_ctm (cairo_scaled_
 cairo_public void
 cairo_scaled_font_get_scale_matrix (cairo_scaled_font_t	*scaled_font,
 				    cairo_matrix_t	*scale_matrix);
 
 cairo_public void
 cairo_scaled_font_get_font_options (cairo_scaled_font_t		*scaled_font,
 				    cairo_font_options_t	*options);
 
+cairo_public cairo_hint_metrics_t
+cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t		*scaled_font);
+
 
 /* Toy fonts */
 
 cairo_public cairo_font_face_t *
 cairo_toy_font_face_create (const char           *family,
 			    cairo_font_slant_t    slant,
 			    cairo_font_weight_t   weight);