subsurface: Don't assume we ever own the target.

Andrea pointed out that snapshots can be shared, and so the subsurface
should not be calling finish even on a snapshot.
This commit is contained in:
Chris Wilson 2010-07-10 10:43:40 +01:00
parent 59c83117d7
commit eb85ab998b
2 changed files with 8 additions and 10 deletions

View file

@ -44,7 +44,6 @@ struct _cairo_surface_subsurface {
cairo_rectangle_int_t extents;
cairo_surface_t *target;
cairo_bool_t owns_target;
};
#endif /* CAIRO_SURFACE_SUBSURFACE_PRIVATE_H */

View file

@ -46,16 +46,10 @@ static cairo_status_t
_cairo_surface_subsurface_finish (void *abstract_surface)
{
cairo_surface_subsurface_t *surface = abstract_surface;
cairo_status_t status = CAIRO_STATUS_SUCCESS;
if (surface->owns_target) {
cairo_surface_finish (surface->target);
status = surface->target->status;
}
cairo_surface_destroy (surface->target);
return status;
return CAIRO_STATUS_SUCCESS;
}
static cairo_surface_t *
@ -419,7 +413,13 @@ _cairo_surface_subsurface_snapshot (void *abstract_surface)
NULL, /* device */
surface->target->content);
snapshot->target = _cairo_surface_snapshot (surface->target);
snapshot->owns_target = TRUE;
if (unlikely (snapshot->target->status)) {
cairo_status_t status;
status = snapshot->target->status;
free (snapshot);
return _cairo_surface_create_in_error (status);
}
snapshot->base.type = snapshot->target->type;
snapshot->extents = surface->extents;
@ -532,7 +532,6 @@ cairo_surface_create_for_rectangle (cairo_surface_t *target,
}
surface->target = cairo_surface_reference (target);
surface->owns_target = FALSE;
return &surface->base;
}