From 8d86e725ceb58fd93a9e9638f86636f5a4d88833 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 25 May 2008 02:30:14 -0400 Subject: [PATCH] [cairo-gstate] Add code for switching to path;fill for huge show_glyph()s For really huge font sizes, we can just do path;fill instead of show_glyphs, as show_glyphs would put excess pressure on the cache, and moreover, not all components below us correctly handle huge font sizes. I wanted to set the limit at 256. But alas, seems like cairo's rasterizer is something like ten times slower than freetype's for huge sizes. So, no win just yet. For now, do it for insanely-huge sizes, just to make sure we don't make anyone unhappy. When we get a really fast rasterizer in cairo, we may want to readjust this. --- src/cairo-gstate.c | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c index fc69661c0..87512850c 100644 --- a/src/cairo-gstate.c +++ b/src/cairo-gstate.c @@ -1550,12 +1550,43 @@ _cairo_gstate_show_glyphs (cairo_gstate_t *gstate, if (status) goto CLEANUP_GLYPHS; - status = _cairo_surface_show_glyphs (gstate->target, - gstate->op, - &source_pattern.base, - transformed_glyphs, - num_glyphs, - gstate->scaled_font); + /* For really huge font sizes, we can just do path;fill instead of + * show_glyphs, as show_glyphs would put excess pressure on the cache, + * and moreover, not all components below us correctly handle huge font + * sizes. I wanted to set the limit at 256. But alas, seems like cairo's + * rasterizer is something like ten times slower than freetype's for huge + * sizes. So, no win just yet. For now, do it for insanely-huge sizes, + * just to make sure we don't make anyone unhappy. When we get a really + * fast rasterizer in cairo, we may want to readjust this. */ + if (_cairo_scaled_font_get_max_scale (gstate->scaled_font) <= 10240) { + status = _cairo_surface_show_glyphs (gstate->target, + gstate->op, + &source_pattern.base, + transformed_glyphs, + num_glyphs, + gstate->scaled_font); + } else { + cairo_path_fixed_t path; + + _cairo_path_fixed_init (&path); + + CAIRO_MUTEX_LOCK (gstate->scaled_font->mutex); + status = _cairo_scaled_font_glyph_path (gstate->scaled_font, + transformed_glyphs, num_glyphs, + &path); + CAIRO_MUTEX_UNLOCK (gstate->scaled_font->mutex); + + if (status == CAIRO_STATUS_SUCCESS) + status = _cairo_surface_fill (gstate->target, + gstate->op, + &source_pattern.base, + &path, + gstate->fill_rule, + gstate->tolerance, + gstate->antialias); + + _cairo_path_fixed_fini (&path); + } _cairo_pattern_fini (&source_pattern.base);