snapshot: Attach the backend generated snapshot to the target

Cache the result of snapshotting using the backend vfunc in the normal
manner by attaching the snapshot to the target. This should reduce
resource usage in these cases.
This commit is contained in:
Chris Wilson 2010-04-29 18:50:32 +01:00
parent 07122f37d1
commit ab2776c9a1

View file

@ -196,9 +196,28 @@ _cairo_surface_snapshot (cairo_surface_t *surface)
if (surface->backend->snapshot != NULL) {
cairo_surface_t *snap;
snap = surface->backend->snapshot (surface);
snap = _cairo_surface_has_snapshot (surface, surface->backend);
if (snap != NULL)
return cairo_surface_reference (snap);
snap = surface->backend->snapshot (surface);
if (snap != NULL) {
if (unlikely (snap->status))
return snap;
status = _cairo_surface_copy_mime_data (snap, surface);
if (unlikely (status)) {
cairo_surface_destroy (snap);
return _cairo_surface_create_in_error (status);
}
snap->device_transform = surface->device_transform;
snap->device_transform_inverse = surface->device_transform_inverse;
_cairo_surface_attach_snapshot (surface, snap, NULL);
return snap;
}
}
snapshot = (cairo_surface_snapshot_t *)