summaryrefslogtreecommitdiff
path: root/test/xlib-expose-event.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-08-18 12:53:43 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2008-08-18 16:18:52 +0100
commit17fbb652b1c74ba0ccced48c14c63a4d24bb3891 (patch)
treed8204d532d21318140eb266c0a7a728e05b6b918 /test/xlib-expose-event.c
parent9b0b55cea724f91eb2835294f929c49224bd0bac (diff)
[test] Avoid redundant writes/reads of test surfaces via png.
As Behdad suggested, we can dramatically speed up the test suite by short-circuiting the write to a png file, only to then immediately read it back in. So for the raster based surfaces, we avoid the round-trip through libpng by implementing a new boilerplate method to directly extract the image buffer from the test result. A secondary speedup is achieved by caching the most recent reference image.
Diffstat (limited to 'test/xlib-expose-event.c')
-rw-r--r--test/xlib-expose-event.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/test/xlib-expose-event.c b/test/xlib-expose-event.c
index bf320dab..189b8f1f 100644
--- a/test/xlib-expose-event.c
+++ b/test/xlib-expose-event.c
@@ -175,6 +175,7 @@ compare (const cairo_test_context_t *ctx, cairo_surface_t *surface)
{
cairo_t *cr;
cairo_surface_t *image, *reference, *diff;
+ cairo_status_t status;
buffer_diff_result_t result;
diff = cairo_image_surface_create (CAIRO_FORMAT_RGB24, SIZE, SIZE);
@@ -187,17 +188,14 @@ compare (const cairo_test_context_t *ctx, cairo_surface_t *surface)
cairo_destroy (cr);
reference = cairo_test_create_surface_from_png (ctx, "xlib-expose-event-ref.png");
- if (cairo_image_surface_get_width (image) != cairo_image_surface_get_width (reference) ||
- cairo_image_surface_get_height (image) != cairo_image_surface_get_height (reference))
- return CAIRO_TEST_FAILURE;
-
- compare_surfaces (ctx, reference, image, diff, &result);
+ status = image_diff (ctx, reference, image, diff, &result);
cairo_surface_destroy (reference);
cairo_surface_destroy (image);
cairo_surface_destroy (diff);
- return result.pixels_changed ? CAIRO_TEST_FAILURE : CAIRO_TEST_SUCCESS;
+ return status == CAIRO_STATUS_SUCCESS && ! result.pixels_changed ?
+ CAIRO_TEST_SUCCESS : CAIRO_TEST_FAILURE;
}
int