diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-04-27 21:04:52 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-04-28 08:39:21 +0100 |
commit | d3c4349730be991db0c85094103c744fc2d94836 (patch) | |
tree | 51000654083972900fd7346a8c03ccf8901a3aeb /test | |
parent | a5f54e48e3136076f3c8c60fc068f6a2105d9a33 (diff) |
test: Mark surfaces as finished if the data goes out of scope.
The issue being that as the on-stack data is being referenced via a
zero-copy snapshot outside of the functions scope as the surface is only
finished and the source written long after the draw() returns. The
correct procedure is that the user must call cairo_surface_finish()
prior to any surface becoming inaccessible. In this case, this triggers
the snapshot to preserve a copy of the data whilst it is still valid.
Diffstat (limited to 'test')
-rw-r--r-- | test/bilevel-image.c | 4 | ||||
-rw-r--r-- | test/filter-nearest-offset.c | 1 | ||||
-rw-r--r-- | test/mask-ctm.c | 4 | ||||
-rw-r--r-- | test/mask-surface-ctm.c | 1 | ||||
-rw-r--r-- | test/move-to-show-surface.c | 2 | ||||
-rw-r--r-- | test/paint-repeat.c | 1 | ||||
-rw-r--r-- | test/paint-source-alpha.c | 1 | ||||
-rw-r--r-- | test/paint-with-alpha.c | 1 | ||||
-rw-r--r-- | test/rgb24-ignore-alpha.c | 1 | ||||
-rw-r--r-- | test/scale-down-source-surface-paint.c | 1 | ||||
-rw-r--r-- | test/scale-source-surface-paint.c | 1 | ||||
-rw-r--r-- | test/set-source.c | 1 | ||||
-rw-r--r-- | test/smask-image-mask.c | 4 | ||||
-rw-r--r-- | test/smask.c | 4 | ||||
-rw-r--r-- | test/source-surface-scale-paint.c | 1 | ||||
-rw-r--r-- | test/translate-show-surface.c | 1 | ||||
-rw-r--r-- | test/zero-alpha.c | 1 |
17 files changed, 26 insertions, 4 deletions
diff --git a/test/bilevel-image.c b/test/bilevel-image.c index 7435a2bc..4feff0e7 100644 --- a/test/bilevel-image.c +++ b/test/bilevel-image.c @@ -46,10 +46,12 @@ draw (cairo_t *cr, int width, int height) cairo_set_source_surface (cr, mask, 0, 0); cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST); - cairo_surface_destroy (mask); cairo_paint (cr); + cairo_surface_finish (mask); /* data goes out of scope */ + cairo_surface_destroy (mask); + return CAIRO_TEST_SUCCESS; } diff --git a/test/filter-nearest-offset.c b/test/filter-nearest-offset.c index f22dcf13..4df60970 100644 --- a/test/filter-nearest-offset.c +++ b/test/filter-nearest-offset.c @@ -94,6 +94,7 @@ draw (cairo_t *cr, int width, int height) } } + cairo_surface_finish (surface); /* data goes out of scope */ cairo_surface_destroy (surface); return CAIRO_TEST_SUCCESS; diff --git a/test/mask-ctm.c b/test/mask-ctm.c index 7b3a3943..205ab069 100644 --- a/test/mask-ctm.c +++ b/test/mask-ctm.c @@ -39,7 +39,6 @@ draw (cairo_t *cr, int width, int height) mask_surface = cairo_image_surface_create_for_data ((unsigned char *) data, CAIRO_FORMAT_ARGB32, 2, 2, 8); mask = cairo_pattern_create_for_surface (mask_surface); - cairo_surface_destroy (mask_surface); cairo_set_source_rgb (cr, 1.0, 0, 0); @@ -66,6 +65,9 @@ draw (cairo_t *cr, int width, int height) cairo_pattern_destroy (mask); + cairo_surface_finish (mask_surface); /* data goes out of scope */ + cairo_surface_destroy (mask_surface); + return CAIRO_TEST_SUCCESS; } diff --git a/test/mask-surface-ctm.c b/test/mask-surface-ctm.c index 50f6d018..064de3c5 100644 --- a/test/mask-surface-ctm.c +++ b/test/mask-surface-ctm.c @@ -57,6 +57,7 @@ draw (cairo_t *cr, int width, int height) cairo_translate (cr, 2, 2); cairo_mask_surface (cr, mask, 4, 4); + cairo_surface_finish (mask); /* data goes out of scope */ cairo_surface_destroy (mask); return CAIRO_TEST_SUCCESS; diff --git a/test/move-to-show-surface.c b/test/move-to-show-surface.c index 6caad1b8..a52b4682 100644 --- a/test/move-to-show-surface.c +++ b/test/move-to-show-surface.c @@ -62,6 +62,8 @@ draw (cairo_t *cr, int width, int height) cairo_set_source_surface (cr, surface, i % 2, i / 2); cairo_paint (cr); + + cairo_surface_finish (surface); /* colors will go out of scope */ cairo_surface_destroy (surface); } diff --git a/test/paint-repeat.c b/test/paint-repeat.c index 35b383c4..c48d84c0 100644 --- a/test/paint-repeat.c +++ b/test/paint-repeat.c @@ -47,6 +47,7 @@ draw (cairo_t *cr, int width, int height) cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT); cairo_paint (cr); + cairo_surface_finish (surface); /* data will go out of scope */ cairo_surface_destroy (surface); return CAIRO_TEST_SUCCESS; diff --git a/test/paint-source-alpha.c b/test/paint-source-alpha.c index 09e82b0a..cb2d488c 100644 --- a/test/paint-source-alpha.c +++ b/test/paint-source-alpha.c @@ -49,6 +49,7 @@ draw (cairo_t *cr, int width, int height) cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST); cairo_paint (cr); + cairo_surface_finish (surface); /* data will go out of scope */ cairo_surface_destroy (surface); return CAIRO_TEST_SUCCESS; diff --git a/test/paint-with-alpha.c b/test/paint-with-alpha.c index 678d3133..19b9e447 100644 --- a/test/paint-with-alpha.c +++ b/test/paint-with-alpha.c @@ -49,6 +49,7 @@ draw (cairo_t *cr, int width, int height) cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST); cairo_paint_with_alpha (cr, 0.5); + cairo_surface_finish (surface); /* data will go out of scope */ cairo_surface_destroy (surface); return CAIRO_TEST_SUCCESS; diff --git a/test/rgb24-ignore-alpha.c b/test/rgb24-ignore-alpha.c index cd67ed3a..1c9d57e9 100644 --- a/test/rgb24-ignore-alpha.c +++ b/test/rgb24-ignore-alpha.c @@ -46,6 +46,7 @@ draw (cairo_t *cr, int width, int height) cairo_set_source_surface (cr, surface, 0, 0); cairo_paint (cr); + cairo_surface_finish (surface); /* colors will go out of scope */ cairo_surface_destroy (surface); return CAIRO_TEST_SUCCESS; diff --git a/test/scale-down-source-surface-paint.c b/test/scale-down-source-surface-paint.c index 293cbda0..8cf0e06f 100644 --- a/test/scale-down-source-surface-paint.c +++ b/test/scale-down-source-surface-paint.c @@ -51,6 +51,7 @@ draw (cairo_t *cr, int width, int height) cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST); cairo_paint (cr); + cairo_surface_finish (surface); /* data will go out of scope */ cairo_surface_destroy (surface); return CAIRO_TEST_SUCCESS; diff --git a/test/scale-source-surface-paint.c b/test/scale-source-surface-paint.c index 1e36afdb..0c0a3acd 100644 --- a/test/scale-source-surface-paint.c +++ b/test/scale-source-surface-paint.c @@ -46,6 +46,7 @@ draw (cairo_t *cr, int width, int height) cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST); cairo_paint (cr); + cairo_surface_finish (surface); /* data will go out of scope */ cairo_surface_destroy (surface); return CAIRO_TEST_SUCCESS; diff --git a/test/set-source.c b/test/set-source.c index f3261039..7e54626a 100644 --- a/test/set-source.c +++ b/test/set-source.c @@ -67,6 +67,7 @@ draw (cairo_t *cr, int width, int height) } cairo_pattern_destroy (pattern); + cairo_surface_finish (surface); /* data will go out of scope */ cairo_surface_destroy (surface); return CAIRO_TEST_SUCCESS; diff --git a/test/smask-image-mask.c b/test/smask-image-mask.c index 14187217..3d8b5d5a 100644 --- a/test/smask-image-mask.c +++ b/test/smask-image-mask.c @@ -63,7 +63,6 @@ draw (cairo_t *cr, int width, int height) mask2 = cairo_image_surface_create_for_data ((unsigned char *) data, CAIRO_FORMAT_ARGB32, 2, 2, 8); pattern = cairo_pattern_create_for_surface (mask2); - cairo_surface_destroy (mask2); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); cairo_mask (cr2, pattern); cairo_pattern_destroy (pattern); @@ -72,6 +71,9 @@ draw (cairo_t *cr, int width, int height) cairo_mask_surface (cr, cairo_get_target (cr2), 0, 0); cairo_destroy (cr2); + cairo_surface_finish (mask2); /* data will go out of scope */ + cairo_surface_destroy (mask2); + return CAIRO_TEST_SUCCESS; } diff --git a/test/smask.c b/test/smask.c index d28caca2..867fb696 100644 --- a/test/smask.c +++ b/test/smask.c @@ -71,7 +71,6 @@ draw (cairo_t *cr, int width, int height) mask2 = cairo_image_surface_create_for_data ((unsigned char *) data, CAIRO_FORMAT_ARGB32, 2, 2, 8); pattern = cairo_pattern_create_for_surface (mask2); - cairo_surface_destroy (mask2); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); cairo_mask (cr2, pattern); cairo_pattern_destroy (pattern); @@ -110,6 +109,9 @@ draw (cairo_t *cr, int width, int height) cairo_mask_surface (cr, cairo_get_target (cr2), 0, 0); cairo_destroy (cr2); + cairo_surface_finish (mask2); /* data will go out of scope */ + cairo_surface_destroy (mask2); + return CAIRO_TEST_SUCCESS; } diff --git a/test/source-surface-scale-paint.c b/test/source-surface-scale-paint.c index 565a1ff4..4ac62490 100644 --- a/test/source-surface-scale-paint.c +++ b/test/source-surface-scale-paint.c @@ -45,6 +45,7 @@ draw (cairo_t *cr, int width, int height) cairo_scale (cr, 2, 2); cairo_paint (cr); + cairo_surface_finish (surface); /* data will go out of scope */ cairo_surface_destroy (surface); return CAIRO_TEST_SUCCESS; diff --git a/test/translate-show-surface.c b/test/translate-show-surface.c index bf084fea..9f7af8db 100644 --- a/test/translate-show-surface.c +++ b/test/translate-show-surface.c @@ -64,6 +64,7 @@ draw (cairo_t *cr, int width, int height) cairo_paint (cr); } cairo_restore (cr); + cairo_surface_finish (surface); /* colors will go out of scope */ cairo_surface_destroy (surface); } diff --git a/test/zero-alpha.c b/test/zero-alpha.c index 1c7c94b0..0105cc8e 100644 --- a/test/zero-alpha.c +++ b/test/zero-alpha.c @@ -81,6 +81,7 @@ draw (cairo_t *cr, int width, int height) for (i=0; i < REPS; i++) cairo_paint (cr); + cairo_surface_finish (surface); /* zero will go out of scope */ cairo_surface_destroy (surface); return CAIRO_TEST_SUCCESS; |