summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-11-20 16:58:45 +0000
committerMoonchild <moonchild@palemoon.org>2021-11-20 16:58:45 +0000
commitefc4f34664f01072dffe66ddabf17e6b74bbe173 (patch)
tree2f0951b65b748ac68e54422b8870ff29085771c5 /libs
parent52c7d91724eda8cbcfa6375ea285383ccaa0261c (diff)
downloadaura-central-efc4f34664f01072dffe66ddabf17e6b74bbe173.tar.gz
Issue %3039 - Extend cairo API with an explicit font_get_hint_metrics function.
This extension allows us to get font hint metrics without having to create and destroy cairo font options structs. Since this is used in loops, this will improve performance, especially in documents which have many text segments.
Diffstat (limited to 'libs')
-rw-r--r--libs/cairo/src/cairo-rename.h1
-rw-r--r--libs/cairo/src/cairo-scaled-font.c20
-rw-r--r--libs/cairo/src/cairo.h3
-rw-r--r--libs/cairo/src/cairoint.h1
4 files changed, 25 insertions, 0 deletions
diff --git a/libs/cairo/src/cairo-rename.h b/libs/cairo/src/cairo-rename.h
index db20352ea..0228596c3 100644
--- a/libs/cairo/src/cairo-rename.h
+++ b/libs/cairo/src/cairo-rename.h
@@ -267,6 +267,7 @@
#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
diff --git a/libs/cairo/src/cairo-scaled-font.c b/libs/cairo/src/cairo-scaled-font.c
index 37806bc63..1bffdce20 100644
--- a/libs/cairo/src/cairo-scaled-font.c
+++ b/libs/cairo/src/cairo-scaled-font.c
@@ -2952,3 +2952,23 @@ cairo_scaled_font_get_font_options (cairo_scaled_font_t *scaled_font,
_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); \ No newline at end of file
diff --git a/libs/cairo/src/cairo.h b/libs/cairo/src/cairo.h
index 3a34e80bf..f566687f9 100644
--- a/libs/cairo/src/cairo.h
+++ b/libs/cairo/src/cairo.h
@@ -1465,6 +1465,9 @@ cairo_public void
cairo_scaled_font_get_font_options (cairo_scaled_font_t *scaled_font,
cairo_font_options_t *options);
+// API extension for GRE.
+cairo_public cairo_hint_metrics_t
+cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t *scaled_font);
/* Toy fonts */
diff --git a/libs/cairo/src/cairoint.h b/libs/cairo/src/cairoint.h
index 2f638f2d7..f5dc0da81 100644
--- a/libs/cairo/src/cairoint.h
+++ b/libs/cairo/src/cairoint.h
@@ -2434,6 +2434,7 @@ 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); // GRE API extension
slim_hidden_proto (cairo_scaled_font_glyph_extents);
slim_hidden_proto_no_warn (cairo_scaled_font_reference);
slim_hidden_proto (cairo_scaled_font_status);