diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-08-18 12:53:43 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-08-18 16:18:52 +0100 |
commit | 17fbb652b1c74ba0ccced48c14c63a4d24bb3891 (patch) | |
tree | d8204d532d21318140eb266c0a7a728e05b6b918 /boilerplate/cairo-boilerplate-win32-printing.c | |
parent | 9b0b55cea724f91eb2835294f929c49224bd0bac (diff) | |
download | cairo-17fbb652b1c74ba0ccced48c14c63a4d24bb3891.tar.gz |
[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 'boilerplate/cairo-boilerplate-win32-printing.c')
-rw-r--r-- | boilerplate/cairo-boilerplate-win32-printing.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/boilerplate/cairo-boilerplate-win32-printing.c b/boilerplate/cairo-boilerplate-win32-printing.c index 617b08714..691552d1d 100644 --- a/boilerplate/cairo-boilerplate-win32-printing.c +++ b/boilerplate/cairo-boilerplate-win32-printing.c @@ -298,6 +298,32 @@ _cairo_boilerplate_win32_printing_surface_write_to_png (cairo_surface_t *surface return CAIRO_STATUS_SUCCESS; } +cairo_surface_t * +_cairo_boilerplate_win32_printing_get_image_surface (cairo_surface_t *surface, + int width, + int height) +{ + win32_target_closure_t *ptc = cairo_surface_get_user_data (surface, + &win32_closure_key); + char *filename; + cairo_status_t status; + + xasprintf (&filename, "%s.png", ptc->filename); + status = _cairo_boilerplate_win32_printing_surface_write_to_png (surface, filename); + if (status) + return cairo_boilerplate_surface_create_in_error (status); + + surface = cairo_boilerplate_get_image_surface_from_png (filename, + width, + height, + ptc->target == NULL); + + remove (filename); + free (filename); + + return surface; +} + void _cairo_boilerplate_win32_printing_cleanup (void *closure) { |