Bug 491595. Use path filling instead of platform glyph rasterization at a smaller size threshold of 256 device pixels, if the backend supports native filling (which we assume will be fast). r=vlad
authorRobert O'Callahan <robert@ocallahan.org>
Wed, 13 May 2009 21:39:19 +1200
changeset 28293 fe1c87fa95a38a5d4d22ce2815caac15261a1fbc
parent 28292 42832a65a57952529b2aaf89d86859b54d4081a8
child 28294 68d219cad3a0ea346293b646e8baf3e402dabe82
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvlad
bugs491595
milestone1.9.2a1pre
Bug 491595. Use path filling instead of platform glyph rasterization at a smaller size threshold of 256 device pixels, if the backend supports native filling (which we assume will be fast). r=vlad
gfx/cairo/README
gfx/cairo/cairo/src/cairo-gstate.c
gfx/cairo/text-path-filling-threshold.patch
--- a/gfx/cairo/README
+++ b/gfx/cairo/README
@@ -43,16 +43,18 @@ win32-canvas-glyph-position.patch: bug 4
 win32-cleartype-clipping.patch: bug 445087; some glyphs are clipped, mainly on right-hand edge, when ClearType is enabled and drawing to RGBA canvas
 
 on-edge.patch: reverts the in-fill semantic change.
 
 wrap-source_image.patch: make sure we don't free the source image until we're done with it.
 
 zero-sized.patch: deal with zero sized surface in ways less likely to crash.
 
+text-path-filling-threshold.patch: use path filling instead of platform glyph rasterization at a smaller size threshold of 256 device pixels, if the backend supports native filling (which we assume will be fast).
+
 ==== pixman patches ====
 
 pixman-neon.patch: add ARM NEON optimized compositing functions
 
 endian.patch: include cairo-platform.h for endian macros
 
 ==== disable printing patch ====
 
--- a/gfx/cairo/cairo/src/cairo-gstate.c
+++ b/gfx/cairo/cairo/src/cairo-gstate.c
@@ -1673,26 +1673,30 @@ cairo_status_t
 
     source_pattern = &source_pattern_stack.base;
     status = _cairo_gstate_copy_transformed_source (gstate, &source_pattern);
     if (unlikely (status))
 	goto CLEANUP_GLYPHS;
 
     /* 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
+     * not all components below us correctly handle huge font sizes, and
+     * path filling can be cheaper since parts of glyphs are likely to be
+     * clipped out.  256 seems like a good limit.  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.
+     * sizes.  So, no win just yet when we're using cairo's rasterizer.
+     * For now, if we're using cairo's rasterizer, use path filling only
+     * 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.
      *
      * Needless to say, do this only if show_text_glyphs is not available. */
+    int path_fill_threshold = gstate->target->backend->fill ? 256 : 10240;
     if (cairo_surface_has_show_text_glyphs (gstate->target) ||
-	_cairo_scaled_font_get_max_scale (gstate->scaled_font) <= 10240) {
+	_cairo_scaled_font_get_max_scale (gstate->scaled_font) <= path_fill_threshold) {
 	status = _cairo_surface_show_text_glyphs (gstate->target,
 						  gstate->op,
 						  source_pattern,
 						  utf8, utf8_len,
 						  transformed_glyphs, num_glyphs,
 						  transformed_clusters, num_clusters,
 						  cluster_flags,
 						  gstate->scaled_font, NULL);
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/text-path-filling-threshold.patch
@@ -0,0 +1,40 @@
+diff --git a/gfx/cairo/cairo/src/cairo-gstate.c b/gfx/cairo/cairo/src/cairo-gstate.c
+--- a/gfx/cairo/cairo/src/cairo-gstate.c
++++ b/gfx/cairo/cairo/src/cairo-gstate.c
+@@ -1673,26 +1673,30 @@ _cairo_gstate_show_text_glyphs (cairo_gs
+ 
+     source_pattern = &source_pattern_stack.base;
+     status = _cairo_gstate_copy_transformed_source (gstate, &source_pattern);
+     if (unlikely (status))
+ 	goto CLEANUP_GLYPHS;
+ 
+     /* 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
++     * not all components below us correctly handle huge font sizes, and
++     * path filling can be cheaper since parts of glyphs are likely to be
++     * clipped out.  256 seems like a good limit.  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.
++     * sizes.  So, no win just yet when we're using cairo's rasterizer.
++     * For now, if we're using cairo's rasterizer, use path filling only
++     * 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.
+      *
+      * Needless to say, do this only if show_text_glyphs is not available. */
++    int path_fill_threshold = gstate->target->backend->fill ? 256 : 10240;
+     if (cairo_surface_has_show_text_glyphs (gstate->target) ||
+-	_cairo_scaled_font_get_max_scale (gstate->scaled_font) <= 10240) {
++	_cairo_scaled_font_get_max_scale (gstate->scaled_font) <= path_fill_threshold) {
+ 	status = _cairo_surface_show_text_glyphs (gstate->target,
+ 						  gstate->op,
+ 						  source_pattern,
+ 						  utf8, utf8_len,
+ 						  transformed_glyphs, num_glyphs,
+ 						  transformed_clusters, num_clusters,
+ 						  cluster_flags,
+ 						  gstate->scaled_font, NULL);