summaryrefslogtreecommitdiff
path: root/test/trap-clip.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-05-26 21:07:07 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-06-02 15:13:47 +0100
commitcffb398f5a484000be458d04ef8f8bce3f6c7e3d (patch)
tree3b620279d063b567389a24b8533b6c1801dec673 /test/trap-clip.c
parent7ed050fd435f17d25c7b757b02cfe200f8779fc2 (diff)
Add a generic cow-snapshotting framework
Provide a mechanism for backends to attach and remove snapshots. This can be used by backends to provide a cache for _cairo_surface_clone_similar(), or by the meta-surfaces to only emit a single pattern for each unique snapshot. In order to prevent stale data being returned upon a snapshot operation, if the surface is modified (via the 5 high level operations, and on notification of external modification) we break the association with any current snapshot of the surface and thus preserve the current data for their use.
Diffstat (limited to 'test/trap-clip.c')
-rw-r--r--test/trap-clip.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/trap-clip.c b/test/trap-clip.c
index 3a8d5c01..0999d971 100644
--- a/test/trap-clip.c
+++ b/test/trap-clip.c
@@ -32,6 +32,7 @@
#define PAD 2
static const char *png_filename = "romedalen.png";
+static cairo_surface_t *image;
static void
set_solid_pattern (const cairo_test_context_t *ctx, cairo_t *cr, int x, int y)
@@ -63,7 +64,13 @@ set_image_pattern (const cairo_test_context_t *ctx, cairo_t *cr, int x, int y)
{
cairo_pattern_t *pattern;
- pattern = cairo_test_create_pattern_from_png (ctx, png_filename);
+ if (image == NULL || cairo_surface_status (image)) {
+ cairo_surface_destroy (image);
+ image = cairo_test_create_surface_from_png (ctx, png_filename);
+ }
+
+ pattern = cairo_pattern_create_for_surface (image);
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
}
@@ -193,6 +200,9 @@ draw (cairo_t *cr, int width, int height)
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
cairo_test_log (ctx, "%d %d .HERE!\n", (int)i, (int)j);
+ cairo_surface_destroy (image);
+ image = NULL;
+
return CAIRO_TEST_SUCCESS;
}