Tue, 06 Jan 2015 21:39:09 +0100
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-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c |
michael@0 | 2 | --- a/gfx/cairo/cairo/src/cairo-quartz-surface.c |
michael@0 | 3 | +++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c |
michael@0 | 4 | @@ -2040,17 +2040,18 @@ _cairo_quartz_surface_create_similar (vo |
michael@0 | 5 | cairo_content_t content, |
michael@0 | 6 | int width, |
michael@0 | 7 | int height) |
michael@0 | 8 | { |
michael@0 | 9 | cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; |
michael@0 | 10 | cairo_format_t format; |
michael@0 | 11 | |
michael@0 | 12 | if (surface->cgLayer) |
michael@0 | 13 | - return cairo_quartz_surface_create_cg_layer (abstract_surface, width, height); |
michael@0 | 14 | + return cairo_quartz_surface_create_cg_layer (abstract_surface, content, |
michael@0 | 15 | + width, height); |
michael@0 | 16 | |
michael@0 | 17 | if (content == CAIRO_CONTENT_COLOR_ALPHA) |
michael@0 | 18 | format = CAIRO_FORMAT_ARGB32; |
michael@0 | 19 | else if (content == CAIRO_CONTENT_COLOR) |
michael@0 | 20 | format = CAIRO_FORMAT_RGB24; |
michael@0 | 21 | else if (content == CAIRO_CONTENT_ALPHA) |
michael@0 | 22 | format = CAIRO_FORMAT_A8; |
michael@0 | 23 | else |
michael@0 | 24 | @@ -2960,54 +2961,55 @@ cairo_quartz_surface_create_for_cg_conte |
michael@0 | 25 | |
michael@0 | 26 | return (cairo_surface_t *) surf; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | /** |
michael@0 | 30 | * cairo_quartz_cglayer_surface_create_similar |
michael@0 | 31 | * @surface: The returned surface can be efficiently drawn into this |
michael@0 | 32 | * destination surface (if tiling is not used)." |
michael@0 | 33 | + * @content: the content type of the surface |
michael@0 | 34 | * @width: width of the surface, in pixels |
michael@0 | 35 | * @height: height of the surface, in pixels |
michael@0 | 36 | * |
michael@0 | 37 | * Creates a Quartz surface backed by a CGLayer, if the given surface |
michael@0 | 38 | * is a Quartz surface; the CGLayer is created to match the surface's |
michael@0 | 39 | - * Quartz context. Otherwise just calls cairo_surface_create_similar |
michael@0 | 40 | - * with CAIRO_CONTENT_COLOR_ALPHA. |
michael@0 | 41 | + * Quartz context. Otherwise just calls cairo_surface_create_similar. |
michael@0 | 42 | * The returned surface can be efficiently blitted to the given surface, |
michael@0 | 43 | * but tiling and 'extend' modes other than NONE are not so efficient. |
michael@0 | 44 | * |
michael@0 | 45 | * Return value: the newly created surface. |
michael@0 | 46 | * |
michael@0 | 47 | * Since: 1.10 |
michael@0 | 48 | **/ |
michael@0 | 49 | cairo_surface_t * |
michael@0 | 50 | cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface, |
michael@0 | 51 | + cairo_content_t content, |
michael@0 | 52 | unsigned int width, |
michael@0 | 53 | unsigned int height) |
michael@0 | 54 | { |
michael@0 | 55 | cairo_quartz_surface_t *surf; |
michael@0 | 56 | CGLayerRef layer; |
michael@0 | 57 | CGContextRef ctx; |
michael@0 | 58 | CGContextRef cgContext; |
michael@0 | 59 | |
michael@0 | 60 | cgContext = cairo_quartz_surface_get_cg_context (surface); |
michael@0 | 61 | if (!cgContext) |
michael@0 | 62 | - return cairo_surface_create_similar (surface, CAIRO_CONTENT_COLOR_ALPHA, |
michael@0 | 63 | + return cairo_surface_create_similar (surface, content, |
michael@0 | 64 | width, height); |
michael@0 | 65 | |
michael@0 | 66 | if (!_cairo_quartz_verify_surface_size(width, height)) |
michael@0 | 67 | return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); |
michael@0 | 68 | |
michael@0 | 69 | /* If we pass zero width or height into CGLayerCreateWithContext below, |
michael@0 | 70 | * it will fail. |
michael@0 | 71 | */ |
michael@0 | 72 | if (width == 0 || height == 0) { |
michael@0 | 73 | return (cairo_surface_t*) |
michael@0 | 74 | - _cairo_quartz_surface_create_internal (NULL, CAIRO_CONTENT_COLOR_ALPHA, |
michael@0 | 75 | + _cairo_quartz_surface_create_internal (NULL, content, |
michael@0 | 76 | width, height); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | layer = CGLayerCreateWithContext (cgContext, |
michael@0 | 80 | CGSizeMake (width, height), |
michael@0 | 81 | NULL); |
michael@0 | 82 | if (!layer) |
michael@0 | 83 | return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); |
michael@0 | 84 | @@ -3016,18 +3018,18 @@ cairo_quartz_surface_create_cg_layer (ca |
michael@0 | 85 | /* Flip it when we draw into it, so that when we finally composite it |
michael@0 | 86 | * to a flipped target, the directions match and Quartz will optimize |
michael@0 | 87 | * the composition properly |
michael@0 | 88 | */ |
michael@0 | 89 | CGContextTranslateCTM (ctx, 0, height); |
michael@0 | 90 | CGContextScaleCTM (ctx, 1, -1); |
michael@0 | 91 | |
michael@0 | 92 | CGContextRetain (ctx); |
michael@0 | 93 | - surf = _cairo_quartz_surface_create_internal (ctx, CAIRO_CONTENT_COLOR_ALPHA, |
michael@0 | 94 | - width, height); |
michael@0 | 95 | + surf = _cairo_quartz_surface_create_internal (ctx, content, |
michael@0 | 96 | + width, height); |
michael@0 | 97 | if (surf->base.status) { |
michael@0 | 98 | CGLayerRelease (layer); |
michael@0 | 99 | // create_internal will have set an error |
michael@0 | 100 | return (cairo_surface_t*) surf; |
michael@0 | 101 | } |
michael@0 | 102 | surf->cgLayer = layer; |
michael@0 | 103 | |
michael@0 | 104 | return (cairo_surface_t *) surf; |
michael@0 | 105 | diff --git a/gfx/cairo/cairo/src/cairo-quartz.h b/gfx/cairo/cairo/src/cairo-quartz.h |
michael@0 | 106 | --- a/gfx/cairo/cairo/src/cairo-quartz.h |
michael@0 | 107 | +++ b/gfx/cairo/cairo/src/cairo-quartz.h |
michael@0 | 108 | @@ -46,16 +46,17 @@ CAIRO_BEGIN_DECLS |
michael@0 | 109 | |
michael@0 | 110 | cairo_public cairo_surface_t * |
michael@0 | 111 | cairo_quartz_surface_create (cairo_format_t format, |
michael@0 | 112 | unsigned int width, |
michael@0 | 113 | unsigned int height); |
michael@0 | 114 | |
michael@0 | 115 | cairo_public cairo_surface_t * |
michael@0 | 116 | cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface, |
michael@0 | 117 | + cairo_content_t content, |
michael@0 | 118 | unsigned int width, |
michael@0 | 119 | unsigned int height); |
michael@0 | 120 | |
michael@0 | 121 | cairo_public cairo_surface_t * |
michael@0 | 122 | cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext, |
michael@0 | 123 | unsigned int width, |
michael@0 | 124 | unsigned int height); |
michael@0 | 125 |