gfx/cairo/text-path-filling-threshold.patch

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 diff --git a/gfx/cairo/cairo/src/cairo-gstate.c b/gfx/cairo/cairo/src/cairo-gstate.c
     2 --- a/gfx/cairo/cairo/src/cairo-gstate.c
     3 +++ b/gfx/cairo/cairo/src/cairo-gstate.c
     4 @@ -1673,26 +1673,31 @@ _cairo_gstate_show_text_glyphs (cairo_gs
     6      source_pattern = &source_pattern_stack.base;
     7      status = _cairo_gstate_copy_transformed_source (gstate, &source_pattern);
     8      if (unlikely (status))
     9  	goto CLEANUP_GLYPHS;
    11      /* For really huge font sizes, we can just do path;fill instead of
    12       * show_glyphs, as show_glyphs would put excess pressure on the cache,
    13 -     * and moreover, not all components below us correctly handle huge font
    14 -     * sizes.  I wanted to set the limit at 256.  But alas, seems like cairo's
    15 +     * not all components below us correctly handle huge font sizes, and
    16 +     * path filling can be cheaper since parts of glyphs are likely to be
    17 +     * clipped out.  256 seems like a good limit.  But alas, seems like cairo's
    18       * rasterizer is something like ten times slower than freetype's for huge
    19 -     * sizes.  So, no win just yet.  For now, do it for insanely-huge sizes,
    20 -     * just to make sure we don't make anyone unhappy.  When we get a really
    21 -     * fast rasterizer in cairo, we may want to readjust this.
    22 +     * sizes.  So, no win just yet when we're using cairo's rasterizer.
    23 +     * For now, if we're using cairo's rasterizer, use path filling only
    24 +     * for insanely-huge sizes, just to make sure we don't make anyone
    25 +     * unhappy.  When we get a really fast rasterizer in cairo, we may
    26 +     * want to readjust this.  The threshold calculation is
    27 +     * encapsulated in _cairo_surface_get_text_path_fill_threshold.
    28       *
    29       * Needless to say, do this only if show_text_glyphs is not available. */
    30      if (cairo_surface_has_show_text_glyphs (gstate->target) ||
    31 -	_cairo_scaled_font_get_max_scale (gstate->scaled_font) <= 10240) {
    32 +	_cairo_scaled_font_get_max_scale (gstate->scaled_font) <=
    33 +	_cairo_surface_get_text_path_fill_threshold (gstate->target)) {
    34  	status = _cairo_surface_show_text_glyphs (gstate->target,
    35  						  gstate->op,
    36  						  source_pattern,
    37  						  utf8, utf8_len,
    38  						  transformed_glyphs, num_glyphs,
    39  						  transformed_clusters, num_clusters,
    40  						  cluster_flags,
    41  						  gstate->scaled_font, NULL);
    42 diff --git a/gfx/cairo/cairo/src/cairo-surface.c b/gfx/cairo/cairo/src/cairo-surface.c
    43 --- a/gfx/cairo/cairo/src/cairo-surface.c
    44 +++ b/gfx/cairo/cairo/src/cairo-surface.c
    45 @@ -1120,16 +1120,22 @@ cairo_surface_get_fallback_resolution (c
    46  				       double		*y_pixels_per_inch)
    47  {
    48      if (x_pixels_per_inch)
    49  	*x_pixels_per_inch = surface->x_fallback_resolution;
    50      if (y_pixels_per_inch)
    51  	*y_pixels_per_inch = surface->y_fallback_resolution;
    52  }
    54 +int
    55 +_cairo_surface_get_text_path_fill_threshold (const cairo_surface_t *surface)
    56 +{
    57 +    return surface->backend->fill == NULL ? 10240 : 256;
    58 +}
    59 +
    60  cairo_bool_t
    61  _cairo_surface_has_device_transform (cairo_surface_t *surface)
    62  {
    63      return ! _cairo_matrix_is_identity (&surface->device_transform);
    64  }
    66  /**
    67   * _cairo_surface_acquire_source_image:
    68 diff --git a/gfx/cairo/cairo/src/cairoint.h b/gfx/cairo/cairo/src/cairoint.h
    69 --- a/gfx/cairo/cairo/src/cairoint.h
    70 +++ b/gfx/cairo/cairo/src/cairoint.h
    71 @@ -2065,16 +2065,19 @@ _cairo_surface_composite_shape_fixup_unb
    72  						int			    dst_x,
    73  						int			    dst_y,
    74  						unsigned int		    width,
    75  						unsigned int		    height);
    77  cairo_private cairo_bool_t
    78  _cairo_surface_is_opaque (const cairo_surface_t *surface);
    80 +cairo_private int
    81 +_cairo_surface_get_text_path_fill_threshold (const cairo_surface_t *surface);
    82 +
    83  cairo_private void
    84  _cairo_surface_set_device_scale (cairo_surface_t *surface,
    85  				 double		  sx,
    86  				 double		  sy);
    88  cairo_private cairo_bool_t
    89  _cairo_surface_has_device_transform (cairo_surface_t *surface);

mercurial