gfx/cairo/win32-avoid-extend-pad-fallback.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-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
     2 --- a/gfx/cairo/cairo/src/cairo-win32-surface.c
     3 +++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
     4 @@ -1114,17 +1114,17 @@ static cairo_int_status_t
     5      cairo_win32_surface_t *dst = abstract_dst;
     6      cairo_win32_surface_t *src;
     7      cairo_surface_pattern_t *src_surface_pattern;
     8      int alpha;
     9      double scalex, scaley;
    10      cairo_fixed_t x0_fixed, y0_fixed;
    11      cairo_int_status_t status;
    13 -    cairo_bool_t needs_alpha, needs_scale, needs_repeat;
    14 +    cairo_bool_t needs_alpha, needs_scale, needs_repeat, needs_pad;
    15      cairo_image_surface_t *src_image = NULL;
    17      cairo_format_t src_format;
    18      cairo_rectangle_int_t src_extents;
    20      cairo_rectangle_int_t src_r = { src_x, src_y, width, height };
    21      cairo_rectangle_int_t dst_r = { dst_x, dst_y, width, height };
    23 @@ -1145,17 +1145,18 @@ static cairo_int_status_t
    24      {
    25  	goto UNSUPPORTED;
    26      }
    28      if (pattern->type != CAIRO_PATTERN_TYPE_SURFACE)
    29  	goto UNSUPPORTED;
    31      if (pattern->extend != CAIRO_EXTEND_NONE &&
    32 -	pattern->extend != CAIRO_EXTEND_REPEAT)
    33 +	pattern->extend != CAIRO_EXTEND_REPEAT &&
    34 +	pattern->extend != CAIRO_EXTEND_PAD)
    35  	goto UNSUPPORTED;
    37      if (mask_pattern) {
    38  	/* FIXME: When we fully support RENDER style 4-channel
    39  	 * masks we need to check r/g/b != 1.0.
    40  	 */
    41  	if (mask_pattern->type != CAIRO_PATTERN_TYPE_SOLID)
    42  	    return CAIRO_INT_STATUS_UNSUPPORTED;
    43 @@ -1252,16 +1253,17 @@ static cairo_int_status_t
    45      /* If the src rectangle doesn't wholly lie within the src extents,
    46       * fudge things.  We really need to do fixup on the unpainted
    47       * region -- e.g. the SOURCE operator is broken for areas outside
    48       * of the extents, because it won't clear that area to transparent
    49       * black.
    50       */
    52 +    needs_pad = FALSE;
    53      if (pattern->extend != CAIRO_EXTEND_REPEAT) {
    54  	needs_repeat = FALSE;
    56  	/* If the src rect and the extents of the source image don't overlap at all,
    57  	 * we can't do anything useful here.
    58  	 */
    59  	if (src_r.x > src_extents.width || src_r.y > src_extents.height ||
    60  	    (src_r.x + src_r.width) < 0 || (src_r.y + src_r.height) < 0)
    61 @@ -1273,40 +1275,48 @@ static cairo_int_status_t
    63  	if (src_r.x < 0) {
    64  	    src_r.width += src_r.x;
    66  	    dst_r.width += src_r.x;
    67  	    dst_r.x -= src_r.x;
    69              src_r.x = 0;
    70 +            needs_pad = TRUE;
    71  	}
    73  	if (src_r.y < 0) {
    74  	    src_r.height += src_r.y;
    76  	    dst_r.height += src_r.y;
    77  	    dst_r.y -= src_r.y;
    79              src_r.y = 0;
    80 +            needs_pad = TRUE;
    81  	}
    83  	if (src_r.x + src_r.width > src_extents.width) {
    84  	    src_r.width = src_extents.width - src_r.x;
    85  	    dst_r.width = src_r.width;
    86 +            needs_pad = TRUE;
    87  	}
    89  	if (src_r.y + src_r.height > src_extents.height) {
    90  	    src_r.height = src_extents.height - src_r.y;
    91  	    dst_r.height = src_r.height;
    92 +            needs_pad = TRUE;
    93  	}
    94      } else {
    95  	needs_repeat = TRUE;
    96      }
    98 +    if (pattern->extend == CAIRO_EXTEND_PAD && needs_pad) {
    99 +        goto UNSUPPORTED;
   100 +    }
   101 +
   102      /*
   103       * Operations that we can do:
   104       *
   105       * AlphaBlend uses the following formula for alpha when not use the per-pixel alpha (AlphaFormat = 0)
   106       *   Dst.Alpha = Src.Alpha * (SCA/255.0) + Dst.Alpha * (1.0 - (SCA/255.0))
   107       * This turns into Dst.Alpha = Src.Alpha when SCA = 255.
   108       * (http://msdn.microsoft.com/en-us/library/aa921335.aspx)
   109       *

mercurial