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 -r c1195334f839 gfx/cairo/cairo/src/cairo-xlib-surface.c |
michael@0 | 2 | --- a/gfx/cairo/cairo/src/cairo-xlib-surface.c Fri May 21 17:42:55 2010 +0300 |
michael@0 | 3 | +++ b/gfx/cairo/cairo/src/cairo-xlib-surface.c Fri May 21 19:12:29 2010 +0300 |
michael@0 | 4 | @@ -189,16 +189,57 @@ static const XTransform identity = { { |
michael@0 | 5 | |
michael@0 | 6 | #define CAIRO_SURFACE_RENDER_HAS_PDF_OPERATORS(surface) CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 11) |
michael@0 | 7 | |
michael@0 | 8 | #define CAIRO_SURFACE_RENDER_SUPPORTS_OPERATOR(surface, op) \ |
michael@0 | 9 | ((op) <= CAIRO_OPERATOR_SATURATE || \ |
michael@0 | 10 | (CAIRO_SURFACE_RENDER_HAS_PDF_OPERATORS(surface) && \ |
michael@0 | 11 | (op) <= CAIRO_OPERATOR_HSL_LUMINOSITY)) |
michael@0 | 12 | |
michael@0 | 13 | +static Visual * |
michael@0 | 14 | +_visual_for_xrender_format(Screen *screen, |
michael@0 | 15 | + XRenderPictFormat *xrender_format) |
michael@0 | 16 | +{ |
michael@0 | 17 | + int d, v; |
michael@0 | 18 | + for (d = 0; d < screen->ndepths; d++) { |
michael@0 | 19 | + Depth *d_info = &screen->depths[d]; |
michael@0 | 20 | + if (d_info->depth != xrender_format->depth) |
michael@0 | 21 | + continue; |
michael@0 | 22 | + |
michael@0 | 23 | + for (v = 0; v < d_info->nvisuals; v++) { |
michael@0 | 24 | + Visual *visual = &d_info->visuals[v]; |
michael@0 | 25 | + |
michael@0 | 26 | + switch (visual->class) { |
michael@0 | 27 | + case TrueColor: |
michael@0 | 28 | + if (xrender_format->type != PictTypeDirect) |
michael@0 | 29 | + continue; |
michael@0 | 30 | + break; |
michael@0 | 31 | + case DirectColor: |
michael@0 | 32 | + /* Prefer TrueColor to DirectColor. |
michael@0 | 33 | + (XRenderFindVisualFormat considers both TrueColor and |
michael@0 | 34 | + DirectColor Visuals to match the same PictFormat.) */ |
michael@0 | 35 | + continue; |
michael@0 | 36 | + case StaticGray: |
michael@0 | 37 | + case GrayScale: |
michael@0 | 38 | + case StaticColor: |
michael@0 | 39 | + case PseudoColor: |
michael@0 | 40 | + if (xrender_format->type != PictTypeIndexed) |
michael@0 | 41 | + continue; |
michael@0 | 42 | + break; |
michael@0 | 43 | + } |
michael@0 | 44 | + |
michael@0 | 45 | + if (xrender_format == |
michael@0 | 46 | + XRenderFindVisualFormat (DisplayOfScreen(screen), visual)) |
michael@0 | 47 | + return visual; |
michael@0 | 48 | + } |
michael@0 | 49 | + } |
michael@0 | 50 | + |
michael@0 | 51 | + return NULL; |
michael@0 | 52 | +} |
michael@0 | 53 | + |
michael@0 | 54 | static cairo_status_t |
michael@0 | 55 | _cairo_xlib_surface_set_clip_region (cairo_xlib_surface_t *surface, |
michael@0 | 56 | cairo_region_t *region) |
michael@0 | 57 | { |
michael@0 | 58 | cairo_bool_t had_clip_rects = surface->clip_region != NULL; |
michael@0 | 59 | |
michael@0 | 60 | if (had_clip_rects == FALSE && region == NULL) |
michael@0 | 61 | return CAIRO_STATUS_SUCCESS; |
michael@0 | 62 | @@ -313,16 +354,19 @@ _cairo_xlib_surface_create_similar (void |
michael@0 | 63 | * visual/depth etc. as possible. */ |
michael@0 | 64 | pix = XCreatePixmap (src->dpy, src->drawable, |
michael@0 | 65 | width <= 0 ? 1 : width, height <= 0 ? 1 : height, |
michael@0 | 66 | xrender_format->depth); |
michael@0 | 67 | |
michael@0 | 68 | visual = NULL; |
michael@0 | 69 | if (xrender_format == src->xrender_format) |
michael@0 | 70 | visual = src->visual; |
michael@0 | 71 | + else |
michael@0 | 72 | + visual = _visual_for_xrender_format(src->screen->screen, |
michael@0 | 73 | + xrender_format); |
michael@0 | 74 | |
michael@0 | 75 | surface = (cairo_xlib_surface_t *) |
michael@0 | 76 | _cairo_xlib_surface_create_internal (src->screen, pix, |
michael@0 | 77 | visual, |
michael@0 | 78 | xrender_format, |
michael@0 | 79 | width, height, |
michael@0 | 80 | xrender_format->depth); |
michael@0 | 81 | } |
michael@0 | 82 | @@ -3178,28 +3222,32 @@ cairo_xlib_surface_create_with_xrender_f |
michael@0 | 83 | Screen *scr, |
michael@0 | 84 | XRenderPictFormat *format, |
michael@0 | 85 | int width, |
michael@0 | 86 | int height) |
michael@0 | 87 | { |
michael@0 | 88 | cairo_xlib_screen_t *screen; |
michael@0 | 89 | cairo_surface_t *surface; |
michael@0 | 90 | cairo_status_t status; |
michael@0 | 91 | + Visual *visual; |
michael@0 | 92 | |
michael@0 | 93 | if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX) |
michael@0 | 94 | return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_SIZE); |
michael@0 | 95 | |
michael@0 | 96 | status = _cairo_xlib_screen_get (dpy, scr, &screen); |
michael@0 | 97 | if (unlikely (status)) |
michael@0 | 98 | return _cairo_surface_create_in_error (status); |
michael@0 | 99 | |
michael@0 | 100 | X_DEBUG ((dpy, "create_with_xrender_format (drawable=%x)", (unsigned int) drawable)); |
michael@0 | 101 | |
michael@0 | 102 | + if (format) |
michael@0 | 103 | + visual = _visual_for_xrender_format (scr, format); |
michael@0 | 104 | + |
michael@0 | 105 | surface = _cairo_xlib_surface_create_internal (screen, drawable, |
michael@0 | 106 | - NULL, format, |
michael@0 | 107 | + visual, format, |
michael@0 | 108 | width, height, 0); |
michael@0 | 109 | _cairo_xlib_screen_destroy (screen); |
michael@0 | 110 | |
michael@0 | 111 | return surface; |
michael@0 | 112 | } |
michael@0 | 113 | slim_hidden_def (cairo_xlib_surface_create_with_xrender_format); |
michael@0 | 114 | |
michael@0 | 115 | /** |
michael@0 | 116 | @@ -3413,33 +3461,37 @@ cairo_xlib_surface_get_screen (cairo_sur |
michael@0 | 117 | |
michael@0 | 118 | return surface->screen->screen; |
michael@0 | 119 | } |
michael@0 | 120 | |
michael@0 | 121 | /** |
michael@0 | 122 | * cairo_xlib_surface_get_visual: |
michael@0 | 123 | * @surface: a #cairo_xlib_surface_t |
michael@0 | 124 | * |
michael@0 | 125 | - * Get the X Visual used for underlying X Drawable. |
michael@0 | 126 | + * Gets the X Visual associated with @surface, suitable for use with the |
michael@0 | 127 | + * underlying X Drawable. If @surface was created by |
michael@0 | 128 | + * cairo_xlib_surface_create(), the return value is the Visual passed to that |
michael@0 | 129 | + * constructor. |
michael@0 | 130 | * |
michael@0 | 131 | - * Return value: the visual. |
michael@0 | 132 | + * Return value: the Visual or %NULL if there is no appropriate Visual for |
michael@0 | 133 | + * @surface. |
michael@0 | 134 | * |
michael@0 | 135 | * Since: 1.2 |
michael@0 | 136 | **/ |
michael@0 | 137 | Visual * |
michael@0 | 138 | -cairo_xlib_surface_get_visual (cairo_surface_t *abstract_surface) |
michael@0 | 139 | +cairo_xlib_surface_get_visual (cairo_surface_t *surface) |
michael@0 | 140 | { |
michael@0 | 141 | - cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface; |
michael@0 | 142 | - |
michael@0 | 143 | - if (! _cairo_surface_is_xlib (abstract_surface)) { |
michael@0 | 144 | + cairo_xlib_surface_t *xlib_surface = (cairo_xlib_surface_t *) surface; |
michael@0 | 145 | + |
michael@0 | 146 | + if (! _cairo_surface_is_xlib (surface)) { |
michael@0 | 147 | _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); |
michael@0 | 148 | return NULL; |
michael@0 | 149 | } |
michael@0 | 150 | |
michael@0 | 151 | - return surface->visual; |
michael@0 | 152 | + return xlib_surface->visual; |
michael@0 | 153 | } |
michael@0 | 154 | |
michael@0 | 155 | /** |
michael@0 | 156 | * cairo_xlib_surface_get_depth: |
michael@0 | 157 | * @surface: a #cairo_xlib_surface_t |
michael@0 | 158 | * |
michael@0 | 159 | * Get the number of bits used to represent each pixel value. |
michael@0 | 160 | * |