Bug 1744524: part 2) Add `WindowContext::GetUserGestureStart` and remove `WindowConte...
[gecko.git] / gfx / cairo / expose-snapshot.patch
blob879b1fc9053106c994ef18490ddcaf4a34f44398
1 diff --git a/gfx/cairo/cairo/src/cairo-analysis-surface-private.h b/gfx/cairo/cairo/src/cairo-analysis-surface-private.h
2 --- a/gfx/cairo/cairo/src/cairo-analysis-surface-private.h
3 +++ b/gfx/cairo/cairo/src/cairo-analysis-surface-private.h
4 @@ -65,14 +65,11 @@ _cairo_analysis_surface_has_unsupported
5 cairo_private void
6 _cairo_analysis_surface_get_bounding_box (cairo_surface_t *surface,
7 cairo_box_t *bbox);
9 cairo_private cairo_int_status_t
10 _cairo_analysis_surface_merge_status (cairo_int_status_t status_a,
11 cairo_int_status_t status_b);
13 -cairo_private cairo_surface_t *
14 -_cairo_null_surface_create (cairo_content_t content);
16 CAIRO_END_DECLS
18 #endif /* CAIRO_ANALYSIS_SURFACE_H */
19 diff --git a/gfx/cairo/cairo/src/cairo-analysis-surface.c b/gfx/cairo/cairo/src/cairo-analysis-surface.c
20 --- a/gfx/cairo/cairo/src/cairo-analysis-surface.c
21 +++ b/gfx/cairo/cairo/src/cairo-analysis-surface.c
22 @@ -902,17 +902,17 @@ static const cairo_surface_backend_t cai
23 NULL, /* fill_stroke */
24 NULL, /* create_solid_pattern_surface */
25 NULL, /* can_repaint_solid_pattern_surface */
26 NULL, /* has_show_text_glyphs */
27 NULL /* show_text_glyphs */
30 cairo_surface_t *
31 -_cairo_null_surface_create (cairo_content_t content)
32 +cairo_null_surface_create (cairo_content_t content)
34 cairo_surface_t *surface;
36 surface = malloc (sizeof (cairo_surface_t));
37 if (unlikely (surface == NULL)) {
38 return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
41 diff --git a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
42 --- a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
43 +++ b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
44 @@ -1951,24 +1951,24 @@ _cairo_d2d_create_brush_for_pattern(cair
45 rect = D2D1::RectU(1, 1, srcSurf->width + 1, srcSurf->height + 1);
46 } else {
47 rect = D2D1::RectU(0, 0, srcSurf->width, srcSurf->height);
49 sourceBitmap->CopyFromMemory(&rect,
50 srcSurf->data,
51 srcSurf->stride);
52 cairo_surface_t *nullSurf =
53 - _cairo_null_surface_create(CAIRO_CONTENT_COLOR_ALPHA);
54 + cairo_null_surface_create(CAIRO_CONTENT_COLOR_ALPHA);
55 cachebitmap->refs++;
56 cachebitmap->dirty = false;
57 cairo_surface_set_user_data(nullSurf,
58 &bitmap_key_snapshot,
59 cachebitmap,
60 NULL);
61 - _cairo_surface_attach_snapshot(surfacePattern->surface,
62 + cairo_surface_attach_snapshot(surfacePattern->surface,
63 nullSurf,
64 _d2d_snapshot_detached);
66 } else {
67 if (pattern->extend != CAIRO_EXTEND_NONE) {
68 d2dsurf->rt->CreateBitmap(D2D1::SizeU(width, height),
69 data + yoffset * stride + xoffset * Bpp,
70 stride,
71 @@ -2015,22 +2015,22 @@ _cairo_d2d_create_brush_for_pattern(cair
72 * and one more in the user data structure.
74 cachebitmap->refs = 2;
75 cairo_surface_set_user_data(surfacePattern->surface,
76 key,
77 cachebitmap,
78 _d2d_release_bitmap);
79 cairo_surface_t *nullSurf =
80 - _cairo_null_surface_create(CAIRO_CONTENT_COLOR_ALPHA);
81 + cairo_null_surface_create(CAIRO_CONTENT_COLOR_ALPHA);
82 cairo_surface_set_user_data(nullSurf,
83 &bitmap_key_snapshot,
84 cachebitmap,
85 NULL);
86 - _cairo_surface_attach_snapshot(surfacePattern->surface,
87 + cairo_surface_attach_snapshot(surfacePattern->surface,
88 nullSurf,
89 _d2d_snapshot_detached);
90 cache_usage += _d2d_compute_bitmap_mem_size(sourceBitmap);
92 if (pix_image) {
93 pixman_image_unref(pix_image);
96 diff --git a/gfx/cairo/cairo/src/cairo-recording-surface.c b/gfx/cairo/cairo/src/cairo-recording-surface.c
97 --- a/gfx/cairo/cairo/src/cairo-recording-surface.c
98 +++ b/gfx/cairo/cairo/src/cairo-recording-surface.c
99 @@ -276,17 +276,17 @@ _cairo_recording_surface_acquire_source_
100 -surface->extents.y);
102 status = _cairo_recording_surface_replay (&surface->base, image);
103 if (unlikely (status)) {
104 cairo_surface_destroy (image);
105 return status;
108 - _cairo_surface_attach_snapshot (&surface->base, image, NULL);
109 + cairo_surface_attach_snapshot (&surface->base, image, NULL);
111 *image_out = (cairo_image_surface_t *) image;
112 *image_extra = NULL;
113 return CAIRO_STATUS_SUCCESS;
116 static void
117 _cairo_recording_surface_release_source_image (void *abstract_surface,
118 @@ -1046,17 +1046,17 @@ static cairo_status_t
119 _recording_surface_get_ink_bbox (cairo_recording_surface_t *surface,
120 cairo_box_t *bbox,
121 const cairo_matrix_t *transform)
123 cairo_surface_t *null_surface;
124 cairo_surface_t *analysis_surface;
125 cairo_status_t status;
127 - null_surface = _cairo_null_surface_create (surface->content);
128 + null_surface = cairo_null_surface_create (surface->content);
129 analysis_surface = _cairo_analysis_surface_create (null_surface);
130 cairo_surface_destroy (null_surface);
132 status = analysis_surface->status;
133 if (unlikely (status))
134 return status;
136 if (transform != NULL)
137 diff --git a/gfx/cairo/cairo/src/cairo-surface-private.h b/gfx/cairo/cairo/src/cairo-surface-private.h
138 --- a/gfx/cairo/cairo/src/cairo-surface-private.h
139 +++ b/gfx/cairo/cairo/src/cairo-surface-private.h
140 @@ -40,18 +40,16 @@
142 #include "cairo.h"
144 #include "cairo-types-private.h"
145 #include "cairo-list-private.h"
146 #include "cairo-reference-count-private.h"
147 #include "cairo-clip-private.h"
149 -typedef void (*cairo_surface_func_t) (cairo_surface_t *);
151 struct _cairo_surface {
152 const cairo_surface_backend_t *backend;
153 cairo_device_t *device;
155 /* We allow surfaces to override the backend->type by shoving something
156 * else into surface->type. This is for "wrapper" surfaces that want to
157 * hide their internal type from the user-level API. */
158 cairo_surface_type_t type;
159 diff --git a/gfx/cairo/cairo/src/cairo-surface-snapshot.c b/gfx/cairo/cairo/src/cairo-surface-snapshot.c
160 --- a/gfx/cairo/cairo/src/cairo-surface-snapshot.c
161 +++ b/gfx/cairo/cairo/src/cairo-surface-snapshot.c
162 @@ -209,17 +209,17 @@ _cairo_surface_snapshot (cairo_surface_t
163 if (unlikely (status)) {
164 cairo_surface_destroy (snap);
165 return _cairo_surface_create_in_error (status);
168 snap->device_transform = surface->device_transform;
169 snap->device_transform_inverse = surface->device_transform_inverse;
171 - _cairo_surface_attach_snapshot (surface, snap, NULL);
172 + cairo_surface_attach_snapshot (surface, snap, NULL);
174 return snap;
178 snapshot = (cairo_surface_snapshot_t *)
179 _cairo_surface_has_snapshot (surface, &_cairo_surface_snapshot_backend);
180 if (snapshot != NULL)
181 @@ -242,14 +242,14 @@ _cairo_surface_snapshot (cairo_surface_t
182 if (unlikely (status)) {
183 cairo_surface_destroy (&snapshot->base);
184 return _cairo_surface_create_in_error (status);
187 snapshot->base.device_transform = surface->device_transform;
188 snapshot->base.device_transform_inverse = surface->device_transform_inverse;
190 - _cairo_surface_attach_snapshot (surface,
191 + cairo_surface_attach_snapshot (surface,
192 &snapshot->base,
193 _cairo_surface_snapshot_copy_on_write);
195 return &snapshot->base;
197 diff --git a/gfx/cairo/cairo/src/cairo-surface-subsurface.c b/gfx/cairo/cairo/src/cairo-surface-subsurface.c
198 --- a/gfx/cairo/cairo/src/cairo-surface-subsurface.c
199 +++ b/gfx/cairo/cairo/src/cairo-surface-subsurface.c
200 @@ -326,17 +326,17 @@ _cairo_surface_subsurface_acquire_source
201 _cairo_image_surface_create_with_content (meta->content,
202 surface->extents.width,
203 surface->extents.height);
204 if (unlikely (image->base.status))
205 return image->base.status;
207 cairo_surface_paint_to_target (&image->base, surface);
209 - _cairo_surface_attach_snapshot (&surface->base, &image->base, NULL);
210 + cairo_surface_attach_snapshot (&surface->base, &image->base, NULL);
212 *image_out = image;
213 *extra_out = NULL;
214 return CAIRO_STATUS_SUCCESS;
218 extra = malloc (sizeof (struct extra));
219 diff --git a/gfx/cairo/cairo/src/cairo-surface.c b/gfx/cairo/cairo/src/cairo-surface.c
220 --- a/gfx/cairo/cairo/src/cairo-surface.c
221 +++ b/gfx/cairo/cairo/src/cairo-surface.c
222 @@ -305,51 +305,51 @@ _cairo_surface_detach_mime_data (cairo_s
223 if (! _cairo_surface_has_mime_data (surface))
224 return;
226 _cairo_user_data_array_fini (&surface->mime_data);
227 _cairo_user_data_array_init (&surface->mime_data);
230 static void
231 -_cairo_surface_detach_snapshots (cairo_surface_t *surface)
232 +cairo_surface_detach_snapshots (cairo_surface_t *surface)
234 while (_cairo_surface_has_snapshots (surface)) {
235 - _cairo_surface_detach_snapshot (cairo_list_first_entry (&surface->snapshots,
236 + cairo_surface_detach_snapshot (cairo_list_first_entry (&surface->snapshots,
237 cairo_surface_t,
238 snapshot));
242 void
243 -_cairo_surface_detach_snapshot (cairo_surface_t *snapshot)
244 +cairo_surface_detach_snapshot (cairo_surface_t *snapshot)
246 assert (snapshot->snapshot_of != NULL);
248 snapshot->snapshot_of = NULL;
249 cairo_list_del (&snapshot->snapshot);
251 if (snapshot->snapshot_detach != NULL)
252 snapshot->snapshot_detach (snapshot);
254 cairo_surface_destroy (snapshot);
257 void
258 -_cairo_surface_attach_snapshot (cairo_surface_t *surface,
259 +cairo_surface_attach_snapshot (cairo_surface_t *surface,
260 cairo_surface_t *snapshot,
261 cairo_surface_func_t detach_func)
263 assert (surface != snapshot);
264 assert (snapshot->snapshot_of != surface);
266 cairo_surface_reference (snapshot);
268 if (snapshot->snapshot_of != NULL)
269 - _cairo_surface_detach_snapshot (snapshot);
270 + cairo_surface_detach_snapshot (snapshot);
272 snapshot->snapshot_of = surface;
273 snapshot->snapshot_detach = detach_func;
275 cairo_list_add (&snapshot->snapshot, &surface->snapshots);
277 assert (_cairo_surface_has_snapshot (surface, snapshot->backend) == snapshot);
279 @@ -382,17 +382,17 @@ _cairo_surface_is_writable (cairo_surfac
281 static void
282 _cairo_surface_begin_modification (cairo_surface_t *surface)
284 assert (surface->status == CAIRO_STATUS_SUCCESS);
285 assert (! surface->finished);
286 assert (surface->snapshot_of == NULL);
288 - _cairo_surface_detach_snapshots (surface);
289 + cairo_surface_detach_snapshots (surface);
290 _cairo_surface_detach_mime_data (surface);
293 void
294 _cairo_surface_init (cairo_surface_t *surface,
295 const cairo_surface_backend_t *backend,
296 cairo_device_t *device,
297 cairo_content_t content)
298 @@ -711,19 +711,19 @@ cairo_surface_finish (cairo_surface_t *s
300 if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count))
301 return;
303 if (surface->finished)
304 return;
306 /* update the snapshots *before* we declare the surface as finished */
307 - _cairo_surface_detach_snapshots (surface);
308 + cairo_surface_detach_snapshots (surface);
309 if (surface->snapshot_of != NULL)
310 - _cairo_surface_detach_snapshot (surface);
311 + cairo_surface_detach_snapshot (surface);
313 cairo_surface_flush (surface);
314 surface->finished = TRUE;
316 /* call finish even if in error mode */
317 if (surface->backend->finish) {
318 status = surface->backend->finish (surface);
319 if (unlikely (status))
320 @@ -1106,17 +1106,17 @@ cairo_surface_flush (cairo_surface_t *su
322 if (surface->status)
323 return;
325 if (surface->finished)
326 return;
328 /* update the current snapshots *before* the user updates the surface */
329 - _cairo_surface_detach_snapshots (surface);
330 + cairo_surface_detach_snapshots (surface);
332 if (surface->backend->flush) {
333 status = surface->backend->flush (surface);
334 if (unlikely (status))
335 status = _cairo_surface_set_error (surface, status);
338 slim_hidden_def (cairo_surface_flush);
339 @@ -1628,17 +1628,17 @@ _cairo_recording_surface_clone_similar (
340 return similar->status;
342 status = _cairo_recording_surface_replay (src, similar);
343 if (unlikely (status)) {
344 cairo_surface_destroy (similar);
345 return status;
348 - _cairo_surface_attach_snapshot (src, similar, NULL);
349 + cairo_surface_attach_snapshot (src, similar, NULL);
351 src_x = src_y = 0;
354 *clone_out = similar;
355 *clone_offset_x = src_x;
356 *clone_offset_y = src_y;
357 return CAIRO_STATUS_SUCCESS;
358 diff --git a/gfx/cairo/cairo/src/cairo-vg-surface.c b/gfx/cairo/cairo/src/cairo-vg-surface.c
359 --- a/gfx/cairo/cairo/src/cairo-vg-surface.c
360 +++ b/gfx/cairo/cairo/src/cairo-vg-surface.c
361 @@ -977,17 +977,17 @@ _vg_setup_surface_source (cairo_vg_conte
362 status = _cairo_cache_insert (&context->snapshot_cache,
363 &clone->snapshot_cache_entry);
364 if (unlikely (status)) {
365 clone->snapshot_cache_entry.hash = 0;
366 cairo_surface_destroy (&clone->base);
367 return status;
370 - _cairo_surface_attach_snapshot (spat->surface, &clone->base,
371 + cairo_surface_attach_snapshot (spat->surface, &clone->base,
372 _vg_surface_remove_from_cache);
374 DONE:
375 cairo_surface_destroy (&context->source->base);
376 context->source = clone;
378 vgSetParameteri (context->paint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
380 diff --git a/gfx/cairo/cairo/src/cairo-xcb-surface.c b/gfx/cairo/cairo/src/cairo-xcb-surface.c
381 --- a/gfx/cairo/cairo/src/cairo-xcb-surface.c
382 +++ b/gfx/cairo/cairo/src/cairo-xcb-surface.c
383 @@ -560,17 +560,17 @@ _cairo_xcb_surface_acquire_source_image
384 image = (cairo_image_surface_t *) cairo_surface_reference (&image->base);
385 goto DONE;
388 status = _get_image (surface, FALSE, &image);
389 if (unlikely (status))
390 return status;
392 - _cairo_surface_attach_snapshot (&surface->base, &image->base, NULL);
393 + cairo_surface_attach_snapshot (&surface->base, &image->base, NULL);
395 DONE:
396 *image_out = image;
397 *image_extra = NULL;
398 return CAIRO_STATUS_SUCCESS;
401 static void
402 @@ -713,17 +713,17 @@ _cairo_xcb_surface_flush (void *abstract
403 status = cairo_surface_status (surface->fallback);
405 if (status == CAIRO_STATUS_SUCCESS) {
406 status = _put_image (surface,
407 (cairo_image_surface_t *) surface->fallback);
410 if (status == CAIRO_STATUS_SUCCESS) {
411 - _cairo_surface_attach_snapshot (&surface->base,
412 + cairo_surface_attach_snapshot (&surface->base,
413 surface->fallback,
414 cairo_surface_finish);
418 cairo_surface_destroy (surface->fallback);
419 surface->fallback = NULL;
421 diff --git a/gfx/cairo/cairo/src/cairo.h b/gfx/cairo/cairo/src/cairo.h
422 --- a/gfx/cairo/cairo/src/cairo.h
423 +++ b/gfx/cairo/cairo/src/cairo.h
424 @@ -214,16 +214,25 @@ typedef struct _cairo_pattern cairo_patt
426 * #cairo_destroy_func_t the type of function which is called when a
427 * data element is destroyed. It is passed the pointer to the data
428 * element and should free any memory and resources allocated for it.
430 typedef void (*cairo_destroy_func_t) (void *data);
433 + * cairo_surface_func_t:
434 + * @surface: The surface being referred to.
436 + * #cairo_surface_func_t the type of function which is used for callback
437 + * when a surface needs to be apssed as a parameter.
438 + */
439 +typedef void (*cairo_surface_func_t) (cairo_surface_t *surface);
441 +/**
442 * cairo_user_data_key_t:
443 * @unused: not used; ignore.
445 * #cairo_user_data_key_t is used for attaching user data to cairo
446 * data structures. The actual contents of the struct is never used,
447 * and there is no need to initialize the object; only the unique
448 * address of a #cairo_data_key_t object is used. Typically, you
449 * would just use the address of a static #cairo_data_key_t object.
450 @@ -2150,16 +2159,24 @@ cairo_surface_get_user_data (cairo_surfa
451 const cairo_user_data_key_t *key);
453 cairo_public cairo_status_t
454 cairo_surface_set_user_data (cairo_surface_t *surface,
455 const cairo_user_data_key_t *key,
456 void *user_data,
457 cairo_destroy_func_t destroy);
459 +cairo_public void
460 +cairo_surface_attach_snapshot (cairo_surface_t *surface,
461 + cairo_surface_t *snapshot,
462 + cairo_surface_func_t detach_func);
464 +cairo_public void
465 +cairo_surface_detach_snapshot (cairo_surface_t *snapshot);
467 #define CAIRO_MIME_TYPE_JPEG "image/jpeg"
468 #define CAIRO_MIME_TYPE_PNG "image/png"
469 #define CAIRO_MIME_TYPE_JP2 "image/jp2"
470 #define CAIRO_MIME_TYPE_URI "text/x-uri"
472 cairo_public void
473 cairo_surface_get_mime_data (cairo_surface_t *surface,
474 const char *mime_type,
475 @@ -2328,16 +2345,21 @@ cairo_recording_surface_create (cairo_co
477 cairo_public void
478 cairo_recording_surface_ink_extents (cairo_surface_t *surface,
479 double *x0,
480 double *y0,
481 double *width,
482 double *height);
484 +/* Null-surface functions */
486 +cairo_public cairo_surface_t *
487 +cairo_null_surface_create (cairo_content_t content);
489 /* Pattern creation functions */
491 cairo_public cairo_pattern_t *
492 cairo_pattern_create_rgb (double red, double green, double blue);
494 cairo_public cairo_pattern_t *
495 cairo_pattern_create_rgba (double red, double green, double blue,
496 double alpha);
497 diff --git a/gfx/cairo/cairo/src/cairoint.h b/gfx/cairo/cairo/src/cairoint.h
498 --- a/gfx/cairo/cairo/src/cairoint.h
499 +++ b/gfx/cairo/cairo/src/cairoint.h
500 @@ -1770,27 +1770,19 @@ _cairo_surface_clone_similar (cairo_surf
501 int height,
502 int *clone_offset_x,
503 int *clone_offset_y,
504 cairo_surface_t **clone_out);
506 cairo_private cairo_surface_t *
507 _cairo_surface_snapshot (cairo_surface_t *surface);
509 -cairo_private void
510 -_cairo_surface_attach_snapshot (cairo_surface_t *surface,
511 - cairo_surface_t *snapshot,
512 - cairo_surface_func_t detach_func);
514 cairo_private cairo_surface_t *
515 _cairo_surface_has_snapshot (cairo_surface_t *surface,
516 - const cairo_surface_backend_t *backend);
518 -cairo_private void
519 -_cairo_surface_detach_snapshot (cairo_surface_t *snapshot);
520 + const cairo_surface_backend_t *backend);
522 cairo_private cairo_bool_t
523 _cairo_surface_is_similar (cairo_surface_t *surface_a,
524 cairo_surface_t *surface_b);
526 cairo_private cairo_bool_t
527 _cairo_surface_get_extents (cairo_surface_t *surface,
528 cairo_rectangle_int_t *extents);