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.h | |
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.h')
-rw-r--r-- | boilerplate/cairo-boilerplate.h | 62 |
1 files changed, 40 insertions, 22 deletions
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h index 8031df8e6..ccd30ffb0 100644 --- a/boilerplate/cairo-boilerplate.h +++ b/boilerplate/cairo-boilerplate.h @@ -51,22 +51,23 @@ typedef unsigned __int32 uint32_t; typedef __int64 int64_t; typedef unsigned __int64 uint64_t; -# ifndef HAVE_UINT64_T -# define HAVE_UINT64_T 1 -# endif -# ifndef INT16_MIN -# define INT16_MIN (-32767-1) -# endif -# ifndef INT16_MAX -# define INT16_MAX (32767) -# endif -# ifndef UINT16_MAX -# define UINT16_MAX (65535) -# endif #else #error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.) #endif +#ifndef HAVE_UINT64_T +# define HAVE_UINT64_T 1 +#endif +#ifndef INT16_MIN +# define INT16_MIN (-32767-1) +#endif +#ifndef INT16_MAX +# define INT16_MAX (32767) +#endif +#ifndef UINT16_MAX +# define UINT16_MAX (65535) +#endif + #ifndef CAIRO_BOILERPLATE_LOG #define CAIRO_BOILERPLATE_LOG(...) fprintf(stderr, __VA_ARGS__) #endif @@ -120,8 +121,14 @@ typedef cairo_surface_t * int id, void **closure); +typedef cairo_surface_t * +(*cairo_boilerplate_get_image_surface_t) (cairo_surface_t *surface, + int width, + int height); + typedef cairo_status_t -(*cairo_boilerplate_write_to_png_t) (cairo_surface_t *surface, const char *filename); +(*cairo_boilerplate_write_to_png_t) (cairo_surface_t *surface, + const char *filename); typedef void (*cairo_boilerplate_cleanup_t) (void *closure); @@ -131,15 +138,16 @@ typedef void typedef struct _cairo_boilerplate_target { - const char *name; - cairo_surface_type_t expected_type; - cairo_content_t content; - unsigned int error_tolerance; - cairo_boilerplate_create_surface_t create_surface; - cairo_boilerplate_write_to_png_t write_to_png; - cairo_boilerplate_cleanup_t cleanup; - cairo_boilerplate_wait_t synchronize; - cairo_bool_t is_vector; + const char *name; + cairo_surface_type_t expected_type; + cairo_content_t content; + unsigned int error_tolerance; + cairo_boilerplate_create_surface_t create_surface; + cairo_boilerplate_get_image_surface_t get_image_surface; + cairo_boilerplate_write_to_png_t write_to_png; + cairo_boilerplate_cleanup_t cleanup; + cairo_boilerplate_wait_t synchronize; + cairo_bool_t is_vector; } cairo_boilerplate_target_t; cairo_boilerplate_target_t ** @@ -149,6 +157,16 @@ void cairo_boilerplate_free_targets (cairo_boilerplate_target_t **targets); cairo_surface_t * +_cairo_boilerplate_get_image_surface (cairo_surface_t *src, + int width, + int height); +cairo_surface_t * +cairo_boilerplate_get_image_surface_from_png (const char *filename, + int width, + int height, + cairo_bool_t flatten); + +cairo_surface_t * cairo_boilerplate_surface_create_in_error (cairo_status_t status); #include "xmalloc.h" |