summaryrefslogtreecommitdiff
path: root/src/cairo-image-surface.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-04-27 11:41:41 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-04-27 11:41:41 +0100
commit455b4de1fc6be05f985b43c2f8f83eeed2b2a191 (patch)
tree79401dbcdd4ec2bea9b9df5eea8f71013e6608c2 /src/cairo-image-surface.c
parent957a9cc619965178a8927d114fe852034fc2385c (diff)
downloadcairo-455b4de1fc6be05f985b43c2f8f83eeed2b2a191.tar.gz
image: Allow a snapshot to steal the original memory upon finish
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-image-surface.c')
-rw-r--r--src/cairo-image-surface.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 8bbea0020..56914b06b 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -753,6 +753,24 @@ _cairo_image_surface_snapshot (void *abstract_surface)
cairo_image_surface_t *image = abstract_surface;
cairo_image_surface_t *clone;
+ /* If we own the image, we can simply steal the memory for the snapshot */
+ if (image->owns_data && image->base._finishing) {
+ clone = (cairo_image_surface_t *)
+ _cairo_image_surface_create_for_pixman_image (image->pixman_image,
+ image->pixman_format);
+ if (unlikely (clone->base.status))
+ return &clone->base;
+
+ image->pixman_image = NULL;
+ image->owns_data = FALSE;
+
+ clone->transparency = image->transparency;
+ clone->color = image->color;
+
+ clone->owns_data = FALSE;
+ return &clone->base;
+ }
+
clone = (cairo_image_surface_t *)
_cairo_image_surface_create_with_pixman_format (NULL,
image->pixman_format,