[cairo-commit] 2 commits - src/cairo-surface.c
Chris Wilson
ickle at kemper.freedesktop.org
Sat Jun 13 09:21:21 PDT 2009
src/cairo-surface.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
New commits:
commit 0eca1b17b14057ef88ae2df500679e62ffb50118
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sat Jun 13 17:16:20 2009 +0100
[surface] Give ownership of the snapshot to the snapshotter.
Previously the reference to the newly created snapshot was owned by the
containing pattern. The consequence of this was that when the pattern was
destroyed the snapshot was cleaned up which prevent reuse of the snapshot
across multiple pages. Transferring ownership upon attachment of the
snapshot to the target means that the snapshot stays in existence until
the target itself is destroyed or modified *and* the containing pattern
is consumed. Obvious in hindsight.
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 9cc170c..0a927ff 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -233,6 +233,8 @@ _cairo_surface_detach_snapshots (cairo_surface_t *surface)
if (snapshots[i]->snapshot_detach != NULL)
snapshots[i]->snapshot_detach (snapshots[i]);
+
+ cairo_surface_destroy (snapshots[i]);
}
surface->snapshots.num_elements = 0;
@@ -244,6 +246,8 @@ _cairo_surface_attach_snapshot (cairo_surface_t *surface,
cairo_surface_t *snapshot,
cairo_surface_func_t detach_func)
{
+ cairo_status_t status;
+
assert (surface != snapshot);
if (snapshot->snapshot_of != NULL)
@@ -252,7 +256,12 @@ _cairo_surface_attach_snapshot (cairo_surface_t *surface,
snapshot->snapshot_of = surface;
snapshot->snapshot_detach = detach_func;
- return _cairo_array_append (&surface->snapshots, &snapshot);
+ status = _cairo_array_append (&surface->snapshots, &snapshot);
+ if (unlikely (status))
+ return status;
+
+ cairo_surface_reference (snapshot);
+ return CAIRO_STATUS_SUCCESS;
}
cairo_surface_t *
@@ -297,6 +306,8 @@ _cairo_surface_detach_snapshot (cairo_surface_t *snapshot)
if (snapshot->snapshot_detach != NULL)
snapshot->snapshot_detach (snapshot);
+
+ cairo_surface_destroy (snapshot);
}
static cairo_bool_t
@@ -575,6 +586,8 @@ cairo_surface_destroy (cairo_surface_t *surface)
if (! _cairo_reference_count_dec_and_test (&surface->ref_count))
return;
+ assert (surface->snapshot_of == NULL);
+
if (! surface->finished)
cairo_surface_finish (surface);
commit a1b3392e60b6b4ff4b650f4d48d56568c1851245
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sat Jun 13 16:37:43 2009 +0100
[surface] Mark cairo_surface_show_page() with begin-modification
cairo_surface_show_page() clears the surface after presentation, so we
need to discard the snapshots here.
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index fdb25fa..9cc170c 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -2277,7 +2277,7 @@ cairo_surface_show_page (cairo_surface_t *surface)
if (surface->status)
return;
- assert (surface->snapshot_of == NULL);
+ _cairo_surface_begin_modification (surface);
if (surface->finished) {
status_ignored = _cairo_surface_set_error (surface,
More information about the cairo-commit
mailing list