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 | # HG changeset patch |
michael@0 | 2 | # User Robert O'Callahan <robert@ocallahan.org> |
michael@0 | 3 | # Date 1294019288 -46800 |
michael@0 | 4 | # Node ID bacc54d452a9fddb5a0d6a1442ec7be4de81ffa7 |
michael@0 | 5 | # Parent ccba8826be1451d0e61d0df38363dadffb20ba48 |
michael@0 | 6 | Bug 593604. Part 2: When compositing a tee surface into another tee surface, try to compose the subsurfaces pointwise. r=jrmuizel,a=blocking |
michael@0 | 7 | |
michael@0 | 8 | diff --git a/gfx/cairo/cairo/src/cairo-tee-surface.c b/gfx/cairo/cairo/src/cairo-tee-surface.c |
michael@0 | 9 | --- a/gfx/cairo/cairo/src/cairo-tee-surface.c |
michael@0 | 10 | +++ b/gfx/cairo/cairo/src/cairo-tee-surface.c |
michael@0 | 11 | @@ -186,35 +186,72 @@ static void |
michael@0 | 12 | _cairo_tee_surface_get_font_options (void *abstract_surface, |
michael@0 | 13 | cairo_font_options_t *options) |
michael@0 | 14 | { |
michael@0 | 15 | cairo_tee_surface_t *surface = abstract_surface; |
michael@0 | 16 | |
michael@0 | 17 | _cairo_surface_wrapper_get_font_options (&surface->master, options); |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | +static const cairo_pattern_t * |
michael@0 | 21 | +_cairo_tee_surface_match_source (cairo_tee_surface_t *surface, |
michael@0 | 22 | + const cairo_pattern_t *source, |
michael@0 | 23 | + int index, |
michael@0 | 24 | + cairo_surface_wrapper_t *dest, |
michael@0 | 25 | + cairo_surface_pattern_t *temp) |
michael@0 | 26 | +{ |
michael@0 | 27 | + cairo_surface_t *s; |
michael@0 | 28 | + cairo_status_t status = cairo_pattern_get_surface ((cairo_pattern_t *)source, &s); |
michael@0 | 29 | + if (status == CAIRO_STATUS_SUCCESS && |
michael@0 | 30 | + cairo_surface_get_type (s) == CAIRO_SURFACE_TYPE_TEE) { |
michael@0 | 31 | + cairo_surface_t *tee_surf = cairo_tee_surface_index (s, index); |
michael@0 | 32 | + if (tee_surf->status == CAIRO_STATUS_SUCCESS && |
michael@0 | 33 | + tee_surf->backend == dest->target->backend) { |
michael@0 | 34 | + status = _cairo_pattern_init_copy (&temp->base, source); |
michael@0 | 35 | + if (status == CAIRO_STATUS_SUCCESS) { |
michael@0 | 36 | + cairo_surface_destroy (temp->surface); |
michael@0 | 37 | + temp->surface = tee_surf; |
michael@0 | 38 | + cairo_surface_reference (temp->surface); |
michael@0 | 39 | + return &temp->base; |
michael@0 | 40 | + } |
michael@0 | 41 | + } |
michael@0 | 42 | + } |
michael@0 | 43 | + |
michael@0 | 44 | + return source; |
michael@0 | 45 | +} |
michael@0 | 46 | + |
michael@0 | 47 | static cairo_int_status_t |
michael@0 | 48 | _cairo_tee_surface_paint (void *abstract_surface, |
michael@0 | 49 | cairo_operator_t op, |
michael@0 | 50 | const cairo_pattern_t *source, |
michael@0 | 51 | cairo_clip_t *clip) |
michael@0 | 52 | { |
michael@0 | 53 | cairo_tee_surface_t *surface = abstract_surface; |
michael@0 | 54 | cairo_surface_wrapper_t *slaves; |
michael@0 | 55 | int n, num_slaves; |
michael@0 | 56 | cairo_status_t status; |
michael@0 | 57 | + const cairo_pattern_t *matched_source; |
michael@0 | 58 | + cairo_surface_pattern_t temp; |
michael@0 | 59 | |
michael@0 | 60 | - status = _cairo_surface_wrapper_paint (&surface->master, op, source, clip); |
michael@0 | 61 | + matched_source = _cairo_tee_surface_match_source (surface, source, 0, &surface->master, &temp); |
michael@0 | 62 | + status = _cairo_surface_wrapper_paint (&surface->master, op, matched_source, clip); |
michael@0 | 63 | + if (matched_source == &temp.base) { |
michael@0 | 64 | + _cairo_pattern_fini (&temp.base); |
michael@0 | 65 | + } |
michael@0 | 66 | if (unlikely (status)) |
michael@0 | 67 | return status; |
michael@0 | 68 | |
michael@0 | 69 | num_slaves = _cairo_array_num_elements (&surface->slaves); |
michael@0 | 70 | slaves = _cairo_array_index (&surface->slaves, 0); |
michael@0 | 71 | for (n = 0; n < num_slaves; n++) { |
michael@0 | 72 | - status = _cairo_surface_wrapper_paint (&slaves[n], op, source, clip); |
michael@0 | 73 | + matched_source = _cairo_tee_surface_match_source (surface, source, n + 1, &slaves[n], &temp); |
michael@0 | 74 | + status = _cairo_surface_wrapper_paint (&slaves[n], op, matched_source, clip); |
michael@0 | 75 | + if (matched_source == &temp.base) { |
michael@0 | 76 | + _cairo_pattern_fini (&temp.base); |
michael@0 | 77 | + } |
michael@0 | 78 | if (unlikely (status)) |
michael@0 | 79 | return status; |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | return CAIRO_STATUS_SUCCESS; |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | static cairo_int_status_t |
michael@0 | 86 | @@ -223,27 +260,37 @@ _cairo_tee_surface_mask (void *abstrac |
michael@0 | 87 | const cairo_pattern_t *source, |
michael@0 | 88 | const cairo_pattern_t *mask, |
michael@0 | 89 | cairo_clip_t *clip) |
michael@0 | 90 | { |
michael@0 | 91 | cairo_tee_surface_t *surface = abstract_surface; |
michael@0 | 92 | cairo_surface_wrapper_t *slaves; |
michael@0 | 93 | int n, num_slaves; |
michael@0 | 94 | cairo_status_t status; |
michael@0 | 95 | + const cairo_pattern_t *matched_source; |
michael@0 | 96 | + cairo_surface_pattern_t temp; |
michael@0 | 97 | |
michael@0 | 98 | + matched_source = _cairo_tee_surface_match_source (surface, source, 0, &surface->master, &temp); |
michael@0 | 99 | status = _cairo_surface_wrapper_mask (&surface->master, |
michael@0 | 100 | - op, source, mask, clip); |
michael@0 | 101 | + op, matched_source, mask, clip); |
michael@0 | 102 | + if (matched_source == &temp.base) { |
michael@0 | 103 | + _cairo_pattern_fini (&temp.base); |
michael@0 | 104 | + } |
michael@0 | 105 | if (unlikely (status)) |
michael@0 | 106 | return status; |
michael@0 | 107 | |
michael@0 | 108 | num_slaves = _cairo_array_num_elements (&surface->slaves); |
michael@0 | 109 | slaves = _cairo_array_index (&surface->slaves, 0); |
michael@0 | 110 | for (n = 0; n < num_slaves; n++) { |
michael@0 | 111 | + matched_source = _cairo_tee_surface_match_source (surface, source, n + 1, &slaves[n], &temp); |
michael@0 | 112 | status = _cairo_surface_wrapper_mask (&slaves[n], |
michael@0 | 113 | - op, source, mask, clip); |
michael@0 | 114 | + op, matched_source, mask, clip); |
michael@0 | 115 | + if (matched_source == &temp.base) { |
michael@0 | 116 | + _cairo_pattern_fini (&temp.base); |
michael@0 | 117 | + } |
michael@0 | 118 | if (unlikely (status)) |
michael@0 | 119 | return status; |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | return CAIRO_STATUS_SUCCESS; |
michael@0 | 123 | } |
michael@0 | 124 | |
michael@0 | 125 | static cairo_int_status_t |
michael@0 | 126 | @@ -257,35 +304,45 @@ _cairo_tee_surface_stroke (void *abst |
michael@0 | 127 | double tolerance, |
michael@0 | 128 | cairo_antialias_t antialias, |
michael@0 | 129 | cairo_clip_t *clip) |
michael@0 | 130 | { |
michael@0 | 131 | cairo_tee_surface_t *surface = abstract_surface; |
michael@0 | 132 | cairo_surface_wrapper_t *slaves; |
michael@0 | 133 | int n, num_slaves; |
michael@0 | 134 | cairo_status_t status; |
michael@0 | 135 | + const cairo_pattern_t *matched_source; |
michael@0 | 136 | + cairo_surface_pattern_t temp; |
michael@0 | 137 | |
michael@0 | 138 | + matched_source = _cairo_tee_surface_match_source (surface, source, 0, &surface->master, &temp); |
michael@0 | 139 | status = _cairo_surface_wrapper_stroke (&surface->master, |
michael@0 | 140 | - op, source, |
michael@0 | 141 | + op, matched_source, |
michael@0 | 142 | path, style, |
michael@0 | 143 | ctm, ctm_inverse, |
michael@0 | 144 | tolerance, antialias, |
michael@0 | 145 | clip); |
michael@0 | 146 | + if (matched_source == &temp.base) { |
michael@0 | 147 | + _cairo_pattern_fini (&temp.base); |
michael@0 | 148 | + } |
michael@0 | 149 | if (unlikely (status)) |
michael@0 | 150 | return status; |
michael@0 | 151 | |
michael@0 | 152 | num_slaves = _cairo_array_num_elements (&surface->slaves); |
michael@0 | 153 | slaves = _cairo_array_index (&surface->slaves, 0); |
michael@0 | 154 | for (n = 0; n < num_slaves; n++) { |
michael@0 | 155 | + matched_source = _cairo_tee_surface_match_source (surface, source, n + 1, &slaves[n], &temp); |
michael@0 | 156 | status = _cairo_surface_wrapper_stroke (&slaves[n], |
michael@0 | 157 | - op, source, |
michael@0 | 158 | + op, matched_source, |
michael@0 | 159 | path, style, |
michael@0 | 160 | ctm, ctm_inverse, |
michael@0 | 161 | tolerance, antialias, |
michael@0 | 162 | clip); |
michael@0 | 163 | + if (matched_source == &temp.base) { |
michael@0 | 164 | + _cairo_pattern_fini (&temp.base); |
michael@0 | 165 | + } |
michael@0 | 166 | if (unlikely (status)) |
michael@0 | 167 | return status; |
michael@0 | 168 | } |
michael@0 | 169 | |
michael@0 | 170 | return CAIRO_STATUS_SUCCESS; |
michael@0 | 171 | } |
michael@0 | 172 | |
michael@0 | 173 | static cairo_int_status_t |
michael@0 | 174 | @@ -297,33 +354,43 @@ _cairo_tee_surface_fill (void *abstra |
michael@0 | 175 | double tolerance, |
michael@0 | 176 | cairo_antialias_t antialias, |
michael@0 | 177 | cairo_clip_t *clip) |
michael@0 | 178 | { |
michael@0 | 179 | cairo_tee_surface_t *surface = abstract_surface; |
michael@0 | 180 | cairo_surface_wrapper_t *slaves; |
michael@0 | 181 | int n, num_slaves; |
michael@0 | 182 | cairo_status_t status; |
michael@0 | 183 | + const cairo_pattern_t *matched_source; |
michael@0 | 184 | + cairo_surface_pattern_t temp; |
michael@0 | 185 | |
michael@0 | 186 | + matched_source = _cairo_tee_surface_match_source (surface, source, 0, &surface->master, &temp); |
michael@0 | 187 | status = _cairo_surface_wrapper_fill (&surface->master, |
michael@0 | 188 | - op, source, |
michael@0 | 189 | + op, matched_source, |
michael@0 | 190 | path, fill_rule, |
michael@0 | 191 | tolerance, antialias, |
michael@0 | 192 | clip); |
michael@0 | 193 | + if (matched_source == &temp.base) { |
michael@0 | 194 | + _cairo_pattern_fini (&temp.base); |
michael@0 | 195 | + } |
michael@0 | 196 | if (unlikely (status)) |
michael@0 | 197 | return status; |
michael@0 | 198 | |
michael@0 | 199 | num_slaves = _cairo_array_num_elements (&surface->slaves); |
michael@0 | 200 | slaves = _cairo_array_index (&surface->slaves, 0); |
michael@0 | 201 | for (n = 0; n < num_slaves; n++) { |
michael@0 | 202 | + matched_source = _cairo_tee_surface_match_source (surface, source, n + 1, &slaves[n], &temp); |
michael@0 | 203 | status = _cairo_surface_wrapper_fill (&slaves[n], |
michael@0 | 204 | - op, source, |
michael@0 | 205 | + op, matched_source, |
michael@0 | 206 | path, fill_rule, |
michael@0 | 207 | tolerance, antialias, |
michael@0 | 208 | clip); |
michael@0 | 209 | + if (matched_source == &temp.base) { |
michael@0 | 210 | + _cairo_pattern_fini (&temp.base); |
michael@0 | 211 | + } |
michael@0 | 212 | if (unlikely (status)) |
michael@0 | 213 | return status; |
michael@0 | 214 | } |
michael@0 | 215 | |
michael@0 | 216 | return CAIRO_STATUS_SUCCESS; |
michael@0 | 217 | } |
michael@0 | 218 | |
michael@0 | 219 | static cairo_bool_t |
michael@0 | 220 | @@ -346,46 +413,56 @@ _cairo_tee_surface_show_text_glyphs (voi |
michael@0 | 221 | cairo_scaled_font_t *scaled_font, |
michael@0 | 222 | cairo_clip_t *clip) |
michael@0 | 223 | { |
michael@0 | 224 | cairo_tee_surface_t *surface = abstract_surface; |
michael@0 | 225 | cairo_surface_wrapper_t *slaves; |
michael@0 | 226 | int n, num_slaves; |
michael@0 | 227 | cairo_status_t status; |
michael@0 | 228 | cairo_glyph_t *glyphs_copy; |
michael@0 | 229 | + const cairo_pattern_t *matched_source; |
michael@0 | 230 | + cairo_surface_pattern_t temp; |
michael@0 | 231 | |
michael@0 | 232 | /* XXX: This copying is ugly. */ |
michael@0 | 233 | glyphs_copy = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t)); |
michael@0 | 234 | if (unlikely (glyphs_copy == NULL)) |
michael@0 | 235 | return _cairo_error (CAIRO_STATUS_NO_MEMORY); |
michael@0 | 236 | |
michael@0 | 237 | memcpy (glyphs_copy, glyphs, sizeof (cairo_glyph_t) * num_glyphs); |
michael@0 | 238 | + matched_source = _cairo_tee_surface_match_source (surface, source, 0, &surface->master, &temp); |
michael@0 | 239 | status = _cairo_surface_wrapper_show_text_glyphs (&surface->master, op, |
michael@0 | 240 | - source, |
michael@0 | 241 | + matched_source, |
michael@0 | 242 | utf8, utf8_len, |
michael@0 | 243 | glyphs_copy, num_glyphs, |
michael@0 | 244 | clusters, num_clusters, |
michael@0 | 245 | cluster_flags, |
michael@0 | 246 | scaled_font, |
michael@0 | 247 | clip); |
michael@0 | 248 | + if (matched_source == &temp.base) { |
michael@0 | 249 | + _cairo_pattern_fini (&temp.base); |
michael@0 | 250 | + } |
michael@0 | 251 | if (unlikely (status)) |
michael@0 | 252 | goto CLEANUP; |
michael@0 | 253 | |
michael@0 | 254 | num_slaves = _cairo_array_num_elements (&surface->slaves); |
michael@0 | 255 | slaves = _cairo_array_index (&surface->slaves, 0); |
michael@0 | 256 | for (n = 0; n < num_slaves; n++) { |
michael@0 | 257 | memcpy (glyphs_copy, glyphs, sizeof (cairo_glyph_t) * num_glyphs); |
michael@0 | 258 | + matched_source = _cairo_tee_surface_match_source (surface, source, n + 1, &slaves[n], &temp); |
michael@0 | 259 | status = _cairo_surface_wrapper_show_text_glyphs (&slaves[n], op, |
michael@0 | 260 | - source, |
michael@0 | 261 | + matched_source, |
michael@0 | 262 | utf8, utf8_len, |
michael@0 | 263 | glyphs_copy, num_glyphs, |
michael@0 | 264 | clusters, num_clusters, |
michael@0 | 265 | cluster_flags, |
michael@0 | 266 | scaled_font, |
michael@0 | 267 | clip); |
michael@0 | 268 | + if (matched_source == &temp.base) { |
michael@0 | 269 | + _cairo_pattern_fini (&temp.base); |
michael@0 | 270 | + } |
michael@0 | 271 | if (unlikely (status)) |
michael@0 | 272 | goto CLEANUP; |
michael@0 | 273 | } |
michael@0 | 274 | |
michael@0 | 275 | CLEANUP: |
michael@0 | 276 | free (glyphs_copy); |
michael@0 | 277 | return status; |
michael@0 | 278 | } |