gfx/cairo/wrap-source_image.patch

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
michael@0 2 diff --git a/src/cairo-surface.c b/src/cairo-surface.c
michael@0 3 index 8278694..12f6242 100644
michael@0 4 --- a/src/cairo-surface.c
michael@0 5 +++ b/src/cairo-surface.c
michael@0 6 @@ -1530,6 +1530,70 @@ _cairo_recording_surface_clone_similar (cairo_surface_t *surface,
michael@0 7 return CAIRO_STATUS_SUCCESS;
michael@0 8 }
michael@0 9
michael@0 10 +struct acquire_source_image_data
michael@0 11 +{
michael@0 12 + cairo_surface_t *src;
michael@0 13 + cairo_image_surface_t *image;
michael@0 14 + void *image_extra;
michael@0 15 +};
michael@0 16 +
michael@0 17 +static void
michael@0 18 +_wrap_release_source_image (void *data)
michael@0 19 +{
michael@0 20 + struct acquire_source_image_data *acquire_data = data;
michael@0 21 + _cairo_surface_release_source_image (acquire_data->src,
michael@0 22 + acquire_data->image,
michael@0 23 + acquire_data->image_extra);
michael@0 24 + free(data);
michael@0 25 +}
michael@0 26 +
michael@0 27 +static cairo_status_t
michael@0 28 +_wrap_image (cairo_surface_t *src,
michael@0 29 + cairo_image_surface_t *image,
michael@0 30 + void *image_extra,
michael@0 31 + cairo_image_surface_t **out)
michael@0 32 +{
michael@0 33 + static cairo_user_data_key_t wrap_image_key;
michael@0 34 + cairo_image_surface_t *surface;
michael@0 35 + cairo_status_t status;
michael@0 36 +
michael@0 37 + struct acquire_source_image_data *data = malloc (sizeof (*data));
michael@0 38 + if (unlikely (data == NULL))
michael@0 39 + return _cairo_error (CAIRO_STATUS_NO_MEMORY);
michael@0 40 + data->src = src;
michael@0 41 + data->image = image;
michael@0 42 + data->image_extra = image_extra;
michael@0 43 +
michael@0 44 + surface = (cairo_image_surface_t *)
michael@0 45 + _cairo_image_surface_create_with_pixman_format (image->data,
michael@0 46 + image->pixman_format,
michael@0 47 + image->width,
michael@0 48 + image->height,
michael@0 49 + image->stride);
michael@0 50 + status = surface->base.status;
michael@0 51 + if (status) {
michael@0 52 + free (data);
michael@0 53 + return status;
michael@0 54 + }
michael@0 55 +
michael@0 56 + status = _cairo_user_data_array_set_data (&surface->base.user_data,
michael@0 57 + &wrap_image_key,
michael@0 58 + data,
michael@0 59 + _wrap_release_source_image);
michael@0 60 + if (status) {
michael@0 61 + cairo_surface_destroy (&surface->base);
michael@0 62 + free (data);
michael@0 63 + return status;
michael@0 64 + }
michael@0 65 +
michael@0 66 + pixman_image_set_component_alpha (
michael@0 67 + surface->pixman_image,
michael@0 68 + pixman_image_get_component_alpha (surface->pixman_image));
michael@0 69 +
michael@0 70 + *out = surface;
michael@0 71 + return CAIRO_STATUS_SUCCESS;
michael@0 72 +}
michael@0 73 +
michael@0 74 /**
michael@0 75 * _cairo_surface_clone_similar:
michael@0 76 * @surface: a #cairo_surface_t
michael@0 77 @@ -1606,15 +1670,19 @@ _cairo_surface_clone_similar (cairo_surface_t *surface,
michael@0 78 /* If we failed, try again with an image surface */
michael@0 79 status = _cairo_surface_acquire_source_image (src, &image, &image_extra);
michael@0 80 if (status == CAIRO_STATUS_SUCCESS) {
michael@0 81 - status =
michael@0 82 - surface->backend->clone_similar (surface, &image->base,
michael@0 83 - src_x, src_y,
michael@0 84 - width, height,
michael@0 85 - clone_offset_x,
michael@0 86 - clone_offset_y,
michael@0 87 - clone_out);
michael@0 88 -
michael@0 89 - _cairo_surface_release_source_image (src, image, image_extra);
michael@0 90 + status = _wrap_image(src, image, image_extra, &image);
michael@0 91 + if (status != CAIRO_STATUS_SUCCESS) {
michael@0 92 + _cairo_surface_release_source_image (src, image, image_extra);
michael@0 93 + } else {
michael@0 94 + status =
michael@0 95 + surface->backend->clone_similar (surface, &image->base,
michael@0 96 + src_x, src_y,
michael@0 97 + width, height,
michael@0 98 + clone_offset_x,
michael@0 99 + clone_offset_y,
michael@0 100 + clone_out);
michael@0 101 + cairo_surface_destroy(&image->base);
michael@0 102 + }
michael@0 103 }
michael@0 104 }
michael@0 105 }

mercurial