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>
Mon, 14 Aug 2017 12:35:30 +0100
changeset 374531 bca0e256c3cf97e142c17a43b0129a08b90acad0
parent 374530 72d456d328c7c3c9c0da55a42558ed42bbda7fc1
child 374532 53118a4b39b1b09ac796aa406ea8f4b02ce55a0e
push id93691
push userjkew@mozilla.com
push dateMon, 14 Aug 2017 12:06:32 +0000
treeherdermozilla-inbound@53118a4b39b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1377257
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
gfx/cairo/cairo/src/cairoint.h
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/add-cairo_scaled_font_get_hint_metrics
@@ -0,0 +1,169 @@
+# 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,21 @@ 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);
++ 
+++/* mozilla extension, see https://bugzilla.mozilla.org/show_bug.cgi?id=1377257 */
+++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,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);
 
+/* mozilla extension, see https://bugzilla.mozilla.org/show_bug.cgi?id=1377257 */
+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/cairoint.h
+++ b/gfx/cairo/cairo/src/cairoint.h
@@ -2468,16 +2468,17 @@ slim_hidden_proto (cairo_save);
 slim_hidden_proto (cairo_scale);
 slim_hidden_proto (cairo_scaled_font_create);
 slim_hidden_proto (cairo_scaled_font_destroy);
 slim_hidden_proto (cairo_scaled_font_extents);
 slim_hidden_proto (cairo_scaled_font_get_ctm);
 slim_hidden_proto (cairo_scaled_font_get_font_face);
 slim_hidden_proto (cairo_scaled_font_get_font_matrix);
 slim_hidden_proto (cairo_scaled_font_get_font_options);
+slim_hidden_proto (cairo_scaled_font_get_hint_metrics);
 slim_hidden_proto (cairo_scaled_font_glyph_extents);
 slim_hidden_proto_no_warn (cairo_scaled_font_reference);
 slim_hidden_proto (cairo_scaled_font_status);
 slim_hidden_proto (cairo_scaled_font_get_user_data);
 slim_hidden_proto (cairo_scaled_font_set_user_data);
 slim_hidden_proto (cairo_scaled_font_text_to_glyphs);
 slim_hidden_proto (cairo_set_font_options);
 slim_hidden_proto (cairo_set_font_size);