From cd9eef1aad87558d3f2d47cfcfa2f5b9b254692c Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 18 Jun 2009 16:42:56 +0100 Subject: [PATCH] [scaled-font] Check the MRU font before resolving the implementor This should hide most of the overhead of resolving a frequently used toy font. --- src/cairo-scaled-font.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c index e342eb8d2..0510264b4 100644 --- a/src/cairo-scaled-font.c +++ b/src/cairo-scaled-font.c @@ -651,7 +651,7 @@ _cairo_scaled_font_matches (const cairo_scaled_font_t *scaled_font, const cairo_matrix_t *ctm, const cairo_font_options_t *options) { - return scaled_font->font_face == font_face && + return scaled_font->original_font_face == font_face && memcmp ((unsigned char *)(&scaled_font->font_matrix.xx), (unsigned char *)(&font_matrix->xx), sizeof(cairo_matrix_t)) == 0 && @@ -899,13 +899,6 @@ cairo_scaled_font_create (cairo_font_face_t *font_face, /* Note that degenerate ctm or font_matrix *are* allowed. * We want to support a font size of 0. */ - if (font_face->backend->get_implementation != NULL) { - font_face = font_face->backend->get_implementation (font_face, - font_matrix, - ctm, - options); - } - font_map = _cairo_scaled_font_map_lock (); if (unlikely (font_map == NULL)) return _cairo_scaled_font_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); @@ -931,9 +924,23 @@ cairo_scaled_font_create (cairo_font_face_t *font_face, _cairo_hash_table_remove (font_map->hash_table, &scaled_font->hash_entry); scaled_font->hash_entry.hash = ZOMBIE; + + if (font_face->backend->get_implementation != NULL) { + font_face = font_face->backend->get_implementation (font_face, + font_matrix, + ctm, + options); + } } else { + if (font_face->backend->get_implementation != NULL) { + font_face = font_face->backend->get_implementation (font_face, + font_matrix, + ctm, + options); + } + _cairo_scaled_font_init_key (&key, font_face, font_matrix, ctm, options);