gfx/cairo/copyarea-with-alpha.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.

michael@0 1 diff --git a/gfx/cairo/cairo/src/cairo-xlib-surface.c b/gfx/cairo/cairo/src/cairo-xlib-surface.c
michael@0 2 --- a/gfx/cairo/cairo/src/cairo-xlib-surface.c
michael@0 3 +++ b/gfx/cairo/cairo/src/cairo-xlib-surface.c
michael@0 4 @@ -1722,30 +1722,31 @@ _surface_has_alpha (cairo_xlib_surface_t
michael@0 5 else
michael@0 6 return FALSE;
michael@0 7 } else {
michael@0 8 /* In the no-render case, we never have alpha */
michael@0 9 return FALSE;
michael@0 10 }
michael@0 11 }
michael@0 12
michael@0 13 -/* Returns true if the given operator and source-alpha combination
michael@0 14 - * requires alpha compositing to complete.
michael@0 15 +/* Returns true if the given operator and alpha combination requires alpha
michael@0 16 + * compositing to complete on source and destination surfaces with the same
michael@0 17 + * format. i.e. if a simple bitwise copy is not appropriate.
michael@0 18 */
michael@0 19 static cairo_bool_t
michael@0 20 _operator_needs_alpha_composite (cairo_operator_t op,
michael@0 21 - cairo_bool_t destination_has_alpha,
michael@0 22 - cairo_bool_t source_has_alpha)
michael@0 23 + cairo_bool_t surfaces_have_alpha)
michael@0 24 {
michael@0 25 - if (op == CAIRO_OPERATOR_SOURCE ||
michael@0 26 - (! source_has_alpha &&
michael@0 27 - (op == CAIRO_OPERATOR_OVER ||
michael@0 28 - op == CAIRO_OPERATOR_ATOP ||
michael@0 29 - op == CAIRO_OPERATOR_IN)))
michael@0 30 - return destination_has_alpha;
michael@0 31 + if (op == CAIRO_OPERATOR_SOURCE)
michael@0 32 + return FALSE;
michael@0 33 +
michael@0 34 + if (op == CAIRO_OPERATOR_OVER ||
michael@0 35 + op == CAIRO_OPERATOR_IN ||
michael@0 36 + op == CAIRO_OPERATOR_ATOP)
michael@0 37 + return surfaces_have_alpha;
michael@0 38
michael@0 39 return TRUE;
michael@0 40 }
michael@0 41
michael@0 42 /* There is a bug in most older X servers with compositing using a
michael@0 43 * untransformed repeating source pattern when the source is in off-screen
michael@0 44 * video memory, and another with repeated transformed images using a
michael@0 45 * general transform matrix. When these bugs could be triggered, we need a
michael@0 46 @@ -1843,24 +1844,24 @@ _categorize_composite_operation (cairo_x
michael@0 47 */
michael@0 48 static composite_operation_t
michael@0 49 _recategorize_composite_operation (cairo_xlib_surface_t *dst,
michael@0 50 cairo_operator_t op,
michael@0 51 cairo_xlib_surface_t *src,
michael@0 52 cairo_surface_attributes_t *src_attr,
michael@0 53 cairo_bool_t have_mask)
michael@0 54 {
michael@0 55 - /* Can we use the core protocol? */
michael@0 56 + /* Can we use the core protocol? (If _surfaces_compatible, then src and
michael@0 57 + * dst have the same format and _surface_has_alpha is the same for each.)
michael@0 58 + */
michael@0 59 if (! have_mask &&
michael@0 60 src->owns_pixmap &&
michael@0 61 - src->depth == dst->depth &&
michael@0 62 + _surfaces_compatible (src, dst) &&
michael@0 63 _cairo_matrix_is_integer_translation (&src_attr->matrix, NULL, NULL) &&
michael@0 64 - ! _operator_needs_alpha_composite (op,
michael@0 65 - _surface_has_alpha (dst),
michael@0 66 - _surface_has_alpha (src)))
michael@0 67 + ! _operator_needs_alpha_composite (op, _surface_has_alpha (dst)))
michael@0 68 {
michael@0 69 if (src_attr->extend == CAIRO_EXTEND_NONE)
michael@0 70 return DO_XCOPYAREA;
michael@0 71
michael@0 72 if (dst->buggy_repeat && src_attr->extend == CAIRO_EXTEND_REPEAT)
michael@0 73 return DO_XTILE;
michael@0 74 }
michael@0 75
michael@0 76 @@ -2211,34 +2212,28 @@ _cairo_xlib_surface_composite (cairo_ope
michael@0 77 cairo_surface_attributes_t src_attr, mask_attr;
michael@0 78 cairo_xlib_surface_t *dst = abstract_dst;
michael@0 79 cairo_xlib_surface_t *src;
michael@0 80 cairo_xlib_surface_t *mask;
michael@0 81 cairo_int_status_t status;
michael@0 82 composite_operation_t operation;
michael@0 83 int itx, ity;
michael@0 84 cairo_bool_t is_integer_translation;
michael@0 85 - cairo_bool_t needs_alpha_composite;
michael@0 86 GC gc;
michael@0 87
michael@0 88 if (mask_pattern != NULL && ! CAIRO_SURFACE_RENDER_HAS_COMPOSITE (dst))
michael@0 89 return UNSUPPORTED ("no support for masks");
michael@0 90
michael@0 91 operation = _categorize_composite_operation (dst, op, src_pattern,
michael@0 92 mask_pattern != NULL);
michael@0 93 if (operation == DO_UNSUPPORTED)
michael@0 94 return UNSUPPORTED ("unsupported operation");
michael@0 95
michael@0 96 X_DEBUG ((dst->dpy, "composite (dst=%x)", (unsigned int) dst->drawable));
michael@0 97
michael@0 98 - needs_alpha_composite =
michael@0 99 - _operator_needs_alpha_composite (op,
michael@0 100 - _surface_has_alpha (dst),
michael@0 101 - ! _cairo_pattern_is_opaque (src_pattern));
michael@0 102 -
michael@0 103 _cairo_xlib_display_notify (dst->display);
michael@0 104
michael@0 105 status =
michael@0 106 _cairo_xlib_surface_acquire_pattern_surfaces (dst,
michael@0 107 src_pattern, mask_pattern,
michael@0 108 src_x, src_y,
michael@0 109 mask_x, mask_y,
michael@0 110 width, height,

mercurial