summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-11-20 16:58:45 +0000
committerMoonchild <moonchild@palemoon.org>2022-04-05 19:23:28 +0200
commit327f5499ca6252c4b5ed75e4fc69dddcbfd3b72f (patch)
tree52a3fdadb907f73366f8e5def27298be544186bc
parent97f911427a49c410644ff54b2dcaab832636113b (diff)
downloaduxp-327f5499ca6252c4b5ed75e4fc69dddcbfd3b72f.tar.gz
Issue #1795 - 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.
-rw-r--r--gfx/cairo/cairo/src/cairo-rename.h1
-rw-r--r--gfx/cairo/cairo/src/cairo-scaled-font.c20
-rw-r--r--gfx/cairo/cairo/src/cairo.h3
-rw-r--r--gfx/cairo/cairo/src/cairoint.h1
-rw-r--r--gfx/thebes/gfxFont.cpp5
-rw-r--r--layout/media/symbols.def.in1
6 files changed, 27 insertions, 4 deletions
diff --git a/gfx/cairo/cairo/src/cairo-rename.h b/gfx/cairo/cairo/src/cairo-rename.h
index db20352ea6..0228596c3d 100644
--- a/gfx/cairo/cairo/src/cairo-rename.h
+++ b/gfx/cairo/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/gfx/cairo/cairo/src/cairo-scaled-font.c b/gfx/cairo/cairo/src/cairo-scaled-font.c
index 37806bc63c..1bffdce203 100644
--- a/gfx/cairo/cairo/src/cairo-scaled-font.c
+++ b/gfx/cairo/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/gfx/cairo/cairo/src/cairo.h b/gfx/cairo/cairo/src/cairo.h
index 3a34e80bfe..f566687f98 100644
--- a/gfx/cairo/cairo/src/cairo.h
+++ b/gfx/cairo/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/gfx/cairo/cairo/src/cairoint.h b/gfx/cairo/cairo/src/cairoint.h
index 2f638f2d7f..f5dc0da817 100644
--- a/gfx/cairo/cairo/src/cairoint.h
+++ b/gfx/cairo/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);
diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp
index a732527598..dba322521f 100644
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -591,11 +591,8 @@ gfxFontShaper::GetRoundOffsetsToPixels(DrawTarget* aDrawTarget,
}
// Sometimes hint metrics gets set for us, most notably for printing.
- cairo_font_options_t *font_options = cairo_font_options_create();
- cairo_scaled_font_get_font_options(scaled_font, font_options);
cairo_hint_metrics_t hint_metrics =
- cairo_font_options_get_hint_metrics(font_options);
- cairo_font_options_destroy(font_options);
+ cairo_scaled_font_get_hint_metrics(scaled_font);
switch (hint_metrics) {
case CAIRO_HINT_METRICS_OFF:
diff --git a/layout/media/symbols.def.in b/layout/media/symbols.def.in
index 6e2364f51a..94866cc2ba 100644
--- a/layout/media/symbols.def.in
+++ b/layout/media/symbols.def.in
@@ -487,6 +487,7 @@ _moz_cairo_scaled_font_create
_moz_cairo_scaled_font_destroy
_moz_cairo_scaled_font_get_font_matrix
_moz_cairo_scaled_font_get_font_options
+_moz_cairo_scaled_font_get_hint_metrics
_moz_cairo_scaled_font_get_type
_moz_cairo_scaled_font_glyph_extents
_moz_cairo_scaled_font_reference