mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-23 19:50:21 +01:00
image: Allow a snapshot to steal the original memory upon finish
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
957a9cc619
commit
455b4de1fc
3 changed files with 22 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ struct _cairo_surface {
|
|||
unsigned int serial;
|
||||
cairo_damage_t *damage;
|
||||
|
||||
unsigned _finishing : 1;
|
||||
unsigned finished : 1;
|
||||
unsigned is_clear : 1;
|
||||
unsigned has_font_options : 1;
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ const cairo_surface_t name = { \
|
|||
0, /* unique id */ \
|
||||
0, /* serial */ \
|
||||
NULL, /* damage */ \
|
||||
FALSE, /* _finishing */ \
|
||||
FALSE, /* finished */ \
|
||||
TRUE, /* is_clear */ \
|
||||
FALSE, /* has_font_options */ \
|
||||
|
|
@ -905,6 +906,8 @@ _cairo_surface_finish (cairo_surface_t *surface)
|
|||
cairo_surface_flush (surface);
|
||||
|
||||
/* update the snapshots *before* we declare the surface as finished */
|
||||
surface->_finishing = TRUE;
|
||||
|
||||
_cairo_surface_detach_snapshots (surface);
|
||||
if (surface->snapshot_of != NULL)
|
||||
_cairo_surface_detach_snapshot (surface);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue