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/README b/gfx/cairo/README |
michael@0 | 2 | --- a/gfx/cairo/README |
michael@0 | 3 | +++ b/gfx/cairo/README |
michael@0 | 4 | @@ -71,16 +71,18 @@ quartz-cache-CGImageRef.patch: cache CGI |
michael@0 | 5 | quartz-remove-snapshot.patch: remove broken implementation of backend snapshot |
michael@0 | 6 | |
michael@0 | 7 | quartz-cglayers.patch: add support for cairo surfaces backed by CGLayers |
michael@0 | 8 | |
michael@0 | 9 | quartz-cglayers-fix-fallback.patch: Bug 572912; fix bug in fallback code in previous patch |
michael@0 | 10 | |
michael@0 | 11 | quartz-get-image.patch: Bug 575521; add a way to get the image surface associated with a surface |
michael@0 | 12 | |
michael@0 | 13 | +quartz-create-for-data.patch: Bug 575521; add a way to create quartz surfaces backed with application-provided data |
michael@0 | 14 | + |
michael@0 | 15 | premultiply-alpha-solid-gradients.patch: bug 539165; multiply the solid color by the alpha component before using it for a solid surface |
michael@0 | 16 | |
michael@0 | 17 | xlib-initialize-members.path: bug 548793; initialize XRender version if the server doesn't have the extension |
michael@0 | 18 | |
michael@0 | 19 | remove-comma: remove a comma from enum |
michael@0 | 20 | |
michael@0 | 21 | d2d.patch: add d2d support |
michael@0 | 22 | |
michael@0 | 23 | diff --git a/gfx/cairo/cairo/src/cairo-quartz-private.h b/gfx/cairo/cairo/src/cairo-quartz-private.h |
michael@0 | 24 | --- a/gfx/cairo/cairo/src/cairo-quartz-private.h |
michael@0 | 25 | +++ b/gfx/cairo/cairo/src/cairo-quartz-private.h |
michael@0 | 26 | @@ -63,16 +63,18 @@ typedef struct cairo_quartz_surface { |
michael@0 | 27 | CGImageRef bitmapContextImage; |
michael@0 | 28 | |
michael@0 | 29 | /** |
michael@0 | 30 | * If non-null, this is the CGLayer for the surface. |
michael@0 | 31 | */ |
michael@0 | 32 | CGLayerRef cgLayer; |
michael@0 | 33 | |
michael@0 | 34 | cairo_rectangle_int_t extents; |
michael@0 | 35 | + |
michael@0 | 36 | + cairo_bool_t ownsData; |
michael@0 | 37 | } cairo_quartz_surface_t; |
michael@0 | 38 | |
michael@0 | 39 | typedef struct cairo_quartz_image_surface { |
michael@0 | 40 | cairo_surface_t base; |
michael@0 | 41 | |
michael@0 | 42 | cairo_rectangle_int_t extents; |
michael@0 | 43 | |
michael@0 | 44 | CGImageRef image; |
michael@0 | 45 | diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c |
michael@0 | 46 | --- a/gfx/cairo/cairo/src/cairo-quartz-surface.c |
michael@0 | 47 | +++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c |
michael@0 | 48 | @@ -1880,20 +1880,21 @@ _cairo_quartz_surface_finish (void *abst |
michael@0 | 49 | surface->cgContext = NULL; |
michael@0 | 50 | |
michael@0 | 51 | if (surface->bitmapContextImage) { |
michael@0 | 52 | CGImageRelease (surface->bitmapContextImage); |
michael@0 | 53 | surface->bitmapContextImage = NULL; |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | if (surface->imageSurfaceEquiv) { |
michael@0 | 57 | - _cairo_image_surface_assume_ownership_of_data (surface->imageSurfaceEquiv); |
michael@0 | 58 | + if (surface->ownsData) |
michael@0 | 59 | + _cairo_image_surface_assume_ownership_of_data (surface->imageSurfaceEquiv); |
michael@0 | 60 | cairo_surface_destroy (surface->imageSurfaceEquiv); |
michael@0 | 61 | surface->imageSurfaceEquiv = NULL; |
michael@0 | 62 | - } else if (surface->imageData) { |
michael@0 | 63 | + } else if (surface->imageData && surface->ownsData) { |
michael@0 | 64 | free (surface->imageData); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | surface->imageData = NULL; |
michael@0 | 68 | |
michael@0 | 69 | if (surface->cgLayer) { |
michael@0 | 70 | CGLayerRelease (surface->cgLayer); |
michael@0 | 71 | } |
michael@0 | 72 | @@ -2888,16 +2889,17 @@ _cairo_quartz_surface_create_internal (C |
michael@0 | 73 | |
michael@0 | 74 | surface->cgContext = cgContext; |
michael@0 | 75 | surface->cgContextBaseCTM = CGContextGetCTM (cgContext); |
michael@0 | 76 | |
michael@0 | 77 | surface->imageData = NULL; |
michael@0 | 78 | surface->imageSurfaceEquiv = NULL; |
michael@0 | 79 | surface->bitmapContextImage = NULL; |
michael@0 | 80 | surface->cgLayer = NULL; |
michael@0 | 81 | + surface->ownsData = TRUE; |
michael@0 | 82 | |
michael@0 | 83 | return surface; |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | /** |
michael@0 | 87 | * cairo_quartz_surface_create_for_cg_context |
michael@0 | 88 | * @cgContext: the existing CGContext for which to create the surface |
michael@0 | 89 | * @width: width of the surface, in pixels |
michael@0 | 90 | @@ -3031,23 +3033,103 @@ cairo_quartz_surface_create_cg_layer (ca |
michael@0 | 91 | * |
michael@0 | 92 | * Since: 1.4 |
michael@0 | 93 | **/ |
michael@0 | 94 | cairo_surface_t * |
michael@0 | 95 | cairo_quartz_surface_create (cairo_format_t format, |
michael@0 | 96 | unsigned int width, |
michael@0 | 97 | unsigned int height) |
michael@0 | 98 | { |
michael@0 | 99 | + int stride; |
michael@0 | 100 | + unsigned char *data; |
michael@0 | 101 | + |
michael@0 | 102 | + if (!_cairo_quartz_verify_surface_size(width, height)) |
michael@0 | 103 | + return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); |
michael@0 | 104 | + |
michael@0 | 105 | + if (width == 0 || height == 0) { |
michael@0 | 106 | + return (cairo_surface_t*) _cairo_quartz_surface_create_internal (NULL, _cairo_content_from_format (format), |
michael@0 | 107 | + width, height); |
michael@0 | 108 | + } |
michael@0 | 109 | + |
michael@0 | 110 | + if (format == CAIRO_FORMAT_ARGB32 || |
michael@0 | 111 | + format == CAIRO_FORMAT_RGB24) |
michael@0 | 112 | + { |
michael@0 | 113 | + stride = width * 4; |
michael@0 | 114 | + } else if (format == CAIRO_FORMAT_A8) { |
michael@0 | 115 | + stride = width; |
michael@0 | 116 | + } else if (format == CAIRO_FORMAT_A1) { |
michael@0 | 117 | + /* I don't think we can usefully support this, as defined by |
michael@0 | 118 | + * cairo_format_t -- these are 1-bit pixels stored in 32-bit |
michael@0 | 119 | + * quantities. |
michael@0 | 120 | + */ |
michael@0 | 121 | + return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT)); |
michael@0 | 122 | + } else { |
michael@0 | 123 | + return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT)); |
michael@0 | 124 | + } |
michael@0 | 125 | + |
michael@0 | 126 | + /* The Apple docs say that for best performance, the stride and the data |
michael@0 | 127 | + * pointer should be 16-byte aligned. malloc already aligns to 16-bytes, |
michael@0 | 128 | + * so we don't have to anything special on allocation. |
michael@0 | 129 | + */ |
michael@0 | 130 | + stride = (stride + 15) & ~15; |
michael@0 | 131 | + |
michael@0 | 132 | + data = _cairo_malloc_ab (height, stride); |
michael@0 | 133 | + if (!data) { |
michael@0 | 134 | + return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); |
michael@0 | 135 | + } |
michael@0 | 136 | + |
michael@0 | 137 | + /* zero the memory to match the image surface behaviour */ |
michael@0 | 138 | + memset (data, 0, height * stride); |
michael@0 | 139 | + |
michael@0 | 140 | + cairo_quartz_surface_t *surf; |
michael@0 | 141 | + surf = (cairo_quartz_surface_t *) cairo_quartz_surface_create_for_data |
michael@0 | 142 | + (data, format, width, height, stride); |
michael@0 | 143 | + if (surf->base.status) { |
michael@0 | 144 | + free (data); |
michael@0 | 145 | + return (cairo_surface_t *) surf; |
michael@0 | 146 | + } |
michael@0 | 147 | + |
michael@0 | 148 | + // We created this data, so we can delete it. |
michael@0 | 149 | + surf->ownsData = TRUE; |
michael@0 | 150 | + |
michael@0 | 151 | + return (cairo_surface_t *) surf; |
michael@0 | 152 | +} |
michael@0 | 153 | + |
michael@0 | 154 | +/** |
michael@0 | 155 | + * cairo_quartz_surface_create_for_data |
michael@0 | 156 | + * @data: a pointer to a buffer supplied by the application in which |
michael@0 | 157 | + * to write contents. This pointer must be suitably aligned for any |
michael@0 | 158 | + * kind of variable, (for example, a pointer returned by malloc). |
michael@0 | 159 | + * @format: format of pixels in the surface to create |
michael@0 | 160 | + * @width: width of the surface, in pixels |
michael@0 | 161 | + * @height: height of the surface, in pixels |
michael@0 | 162 | + * |
michael@0 | 163 | + * Creates a Quartz surface backed by a CGBitmap. The surface is |
michael@0 | 164 | + * created using the Device RGB (or Device Gray, for A8) color space. |
michael@0 | 165 | + * All Cairo operations, including those that require software |
michael@0 | 166 | + * rendering, will succeed on this surface. |
michael@0 | 167 | + * |
michael@0 | 168 | + * Return value: the newly created surface. |
michael@0 | 169 | + * |
michael@0 | 170 | + * Since: 1.12 |
michael@0 | 171 | + **/ |
michael@0 | 172 | +cairo_surface_t * |
michael@0 | 173 | +cairo_quartz_surface_create_for_data (unsigned char *data, |
michael@0 | 174 | + cairo_format_t format, |
michael@0 | 175 | + unsigned int width, |
michael@0 | 176 | + unsigned int height, |
michael@0 | 177 | + unsigned int stride) |
michael@0 | 178 | +{ |
michael@0 | 179 | cairo_quartz_surface_t *surf; |
michael@0 | 180 | CGContextRef cgc; |
michael@0 | 181 | CGColorSpaceRef cgColorspace; |
michael@0 | 182 | CGBitmapInfo bitinfo; |
michael@0 | 183 | - void *imageData; |
michael@0 | 184 | - int stride; |
michael@0 | 185 | + void *imageData = data; |
michael@0 | 186 | int bitsPerComponent; |
michael@0 | 187 | + unsigned int i; |
michael@0 | 188 | |
michael@0 | 189 | // verify width and height of surface |
michael@0 | 190 | if (!_cairo_quartz_verify_surface_size(width, height)) |
michael@0 | 191 | return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); |
michael@0 | 192 | |
michael@0 | 193 | if (width == 0 || height == 0) { |
michael@0 | 194 | return (cairo_surface_t*) _cairo_quartz_surface_create_internal (NULL, _cairo_content_from_format (format), |
michael@0 | 195 | width, height); |
michael@0 | 196 | @@ -3058,47 +3140,30 @@ cairo_quartz_surface_create (cairo_forma |
michael@0 | 197 | { |
michael@0 | 198 | cgColorspace = CGColorSpaceCreateDeviceRGB(); |
michael@0 | 199 | bitinfo = kCGBitmapByteOrder32Host; |
michael@0 | 200 | if (format == CAIRO_FORMAT_ARGB32) |
michael@0 | 201 | bitinfo |= kCGImageAlphaPremultipliedFirst; |
michael@0 | 202 | else |
michael@0 | 203 | bitinfo |= kCGImageAlphaNoneSkipFirst; |
michael@0 | 204 | bitsPerComponent = 8; |
michael@0 | 205 | - stride = width * 4; |
michael@0 | 206 | } else if (format == CAIRO_FORMAT_A8) { |
michael@0 | 207 | cgColorspace = NULL; |
michael@0 | 208 | - stride = width; |
michael@0 | 209 | bitinfo = kCGImageAlphaOnly; |
michael@0 | 210 | bitsPerComponent = 8; |
michael@0 | 211 | } else if (format == CAIRO_FORMAT_A1) { |
michael@0 | 212 | /* I don't think we can usefully support this, as defined by |
michael@0 | 213 | * cairo_format_t -- these are 1-bit pixels stored in 32-bit |
michael@0 | 214 | * quantities. |
michael@0 | 215 | */ |
michael@0 | 216 | return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT)); |
michael@0 | 217 | } else { |
michael@0 | 218 | return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT)); |
michael@0 | 219 | } |
michael@0 | 220 | |
michael@0 | 221 | - /* The Apple docs say that for best performance, the stride and the data |
michael@0 | 222 | - * pointer should be 16-byte aligned. malloc already aligns to 16-bytes, |
michael@0 | 223 | - * so we don't have to anything special on allocation. |
michael@0 | 224 | - */ |
michael@0 | 225 | - stride = (stride + 15) & ~15; |
michael@0 | 226 | - |
michael@0 | 227 | - imageData = _cairo_malloc_ab (height, stride); |
michael@0 | 228 | - if (!imageData) { |
michael@0 | 229 | - CGColorSpaceRelease (cgColorspace); |
michael@0 | 230 | - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); |
michael@0 | 231 | - } |
michael@0 | 232 | - |
michael@0 | 233 | - /* zero the memory to match the image surface behaviour */ |
michael@0 | 234 | - memset (imageData, 0, height * stride); |
michael@0 | 235 | - |
michael@0 | 236 | cgc = CGBitmapContextCreate (imageData, |
michael@0 | 237 | width, |
michael@0 | 238 | height, |
michael@0 | 239 | bitsPerComponent, |
michael@0 | 240 | stride, |
michael@0 | 241 | cgColorspace, |
michael@0 | 242 | bitinfo); |
michael@0 | 243 | CGColorSpaceRelease (cgColorspace); |
michael@0 | 244 | @@ -3118,16 +3183,17 @@ cairo_quartz_surface_create (cairo_forma |
michael@0 | 245 | CGContextRelease (cgc); |
michael@0 | 246 | free (imageData); |
michael@0 | 247 | // create_internal will have set an error |
michael@0 | 248 | return (cairo_surface_t*) surf; |
michael@0 | 249 | } |
michael@0 | 250 | |
michael@0 | 251 | surf->imageData = imageData; |
michael@0 | 252 | surf->imageSurfaceEquiv = cairo_image_surface_create_for_data (imageData, format, width, height, stride); |
michael@0 | 253 | + surf->ownsData = FALSE; |
michael@0 | 254 | |
michael@0 | 255 | return (cairo_surface_t *) surf; |
michael@0 | 256 | } |
michael@0 | 257 | |
michael@0 | 258 | /** |
michael@0 | 259 | * cairo_quartz_surface_get_cg_context |
michael@0 | 260 | * @surface: the Cairo Quartz surface |
michael@0 | 261 | * |
michael@0 | 262 | diff --git a/gfx/cairo/cairo/src/cairo-quartz.h b/gfx/cairo/cairo/src/cairo-quartz.h |
michael@0 | 263 | --- a/gfx/cairo/cairo/src/cairo-quartz.h |
michael@0 | 264 | +++ b/gfx/cairo/cairo/src/cairo-quartz.h |
michael@0 | 265 | @@ -45,16 +45,23 @@ |
michael@0 | 266 | CAIRO_BEGIN_DECLS |
michael@0 | 267 | |
michael@0 | 268 | cairo_public cairo_surface_t * |
michael@0 | 269 | cairo_quartz_surface_create (cairo_format_t format, |
michael@0 | 270 | unsigned int width, |
michael@0 | 271 | unsigned int height); |
michael@0 | 272 | |
michael@0 | 273 | cairo_public cairo_surface_t * |
michael@0 | 274 | +cairo_quartz_surface_create_for_data (unsigned char *data, |
michael@0 | 275 | + cairo_format_t format, |
michael@0 | 276 | + unsigned int width, |
michael@0 | 277 | + unsigned int height, |
michael@0 | 278 | + unsigned int stride); |
michael@0 | 279 | + |
michael@0 | 280 | +cairo_public cairo_surface_t * |
michael@0 | 281 | cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface, |
michael@0 | 282 | unsigned int width, |
michael@0 | 283 | unsigned int height); |
michael@0 | 284 | |
michael@0 | 285 | cairo_public cairo_surface_t * |
michael@0 | 286 | cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext, |
michael@0 | 287 | unsigned int width, |
michael@0 | 288 | unsigned int height); |
michael@0 | 289 | diff --git a/gfx/cairo/cairo/src/cairo-rename.h b/gfx/cairo/cairo/src/cairo-rename.h |
michael@0 | 290 | --- a/gfx/cairo/cairo/src/cairo-rename.h |
michael@0 | 291 | +++ b/gfx/cairo/cairo/src/cairo-rename.h |
michael@0 | 292 | @@ -176,16 +176,17 @@ |
michael@0 | 293 | #define cairo_qpainter_surface_get_image _moz_cairo_qpainter_surface_get_image |
michael@0 | 294 | #define cairo_qpainter_surface_get_qimage _moz_cairo_qpainter_surface_get_qimage |
michael@0 | 295 | #define cairo_qpainter_surface_get_qpainter _moz_cairo_qpainter_surface_get_qpainter |
michael@0 | 296 | #define cairo_quartz_font_face_create_for_atsu_font_id _moz_cairo_quartz_font_face_create_for_atsu_font_id |
michael@0 | 297 | #define cairo_quartz_font_face_create_for_cgfont _moz_cairo_quartz_font_face_create_for_cgfont |
michael@0 | 298 | #define cairo_quartz_image_surface_create _moz_cairo_quartz_image_surface_create |
michael@0 | 299 | #define cairo_quartz_image_surface_get_image _moz_cairo_quartz_image_surface_get_image |
michael@0 | 300 | #define cairo_quartz_surface_create _moz_cairo_quartz_surface_create |
michael@0 | 301 | +#define cairo_quartz_surface_create_for_data _moz_cairo_quartz_surface_create_for_data |
michael@0 | 302 | #define cairo_quartz_surface_create_for_cg_context _moz_cairo_quartz_surface_create_for_cg_context |
michael@0 | 303 | #define cairo_quartz_surface_get_cg_context _moz_cairo_quartz_surface_get_cg_context |
michael@0 | 304 | #define cairo_quartz_surface_get_image _moz_cairo_quartz_surface_get_image |
michael@0 | 305 | #define cairo_rectangle _moz_cairo_rectangle |
michael@0 | 306 | #define cairo_rectangle_list_destroy _moz_cairo_rectangle_list_destroy |
michael@0 | 307 | #define cairo_reference _moz_cairo_reference |
michael@0 | 308 | #define cairo_rel_curve_to _moz_cairo_rel_curve_to |
michael@0 | 309 | #define cairo_rel_line_to _moz_cairo_rel_line_to |