summaryrefslogtreecommitdiff
path: root/test/mask.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/mask.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/mask.c')
-rw-r--r--test/mask.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/mask.c b/test/mask.c
index bc1adfdb..451054e3 100644
--- a/test/mask.c
+++ b/test/mask.c
@@ -33,6 +33,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)
@@ -64,7 +65,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);
}
@@ -225,6 +232,9 @@ draw (cairo_t *cr, int width, int height)
cairo_destroy (cr2);
+ cairo_surface_destroy (image);
+ image = NULL;
+
return CAIRO_TEST_SUCCESS;
}