diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-11-05 10:02:54 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-11-05 10:02:54 +0000 |
commit | 8a10c25c3f4036d17e24852e7dc970fa06fcb4af (patch) | |
tree | e842855e7ebfaaf907c3f8b9429da71717d36bde /test/xcomposite-projection.c | |
parent | a9f37953c71e16f65122097462e51b035783a965 (diff) | |
download | cairo-8a10c25c3f4036d17e24852e7dc970fa06fcb4af.tar.gz |
test: Tweak Benjamin's xcomposite-projection
Include Benjamin's advice on how to make the bug more visible inline
with the code.
Diffstat (limited to 'test/xcomposite-projection.c')
-rw-r--r-- | test/xcomposite-projection.c | 69 |
1 files changed, 48 insertions, 21 deletions
diff --git a/test/xcomposite-projection.c b/test/xcomposite-projection.c index f36697acf..cca60f5a0 100644 --- a/test/xcomposite-projection.c +++ b/test/xcomposite-projection.c @@ -6,9 +6,9 @@ * fee, provided that the above copyright notice appear in all copies * and that both that copyright notice and this permission notice * appear in supporting documentation, and that the name of - * Kai-Uwe Behrmann not be used in advertising or publicity pertaining to + * Benjamin Otte not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior - * permission. Kai-Uwe Behrmann makes no representations about the + * permission. Benjamin Otte makes no representations about the * suitability of this software for any purpose. It is provided "as * is" without express or implied warranty. * @@ -25,33 +25,60 @@ #include "cairo-test.h" +/* + * Exercise a bug in the projection of a rotated trapezoid mask. + * I used CAIRO_ANTIALIAS_NONE and a single-color source in the test to get + * rid of aliasing issues in the output images. This makes some issues + * slightly less visible, but still fails for all of them. If you want to + * get a clearer view: + * #define ANTIALIAS CAIRO_ANTIALIAS_DEFAULT + */ + +#define ANTIALIAS CAIRO_ANTIALIAS_NONE + static const char png_filename[] = "romedalen.png"; -static cairo_surface_t * -get_red_surface (void) +static cairo_pattern_t * +get_source (const cairo_test_context_t *ctx, + int *width, int *height) { - cairo_surface_t *surface; - cairo_t *cr; - - surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 256, 192); - - cr = cairo_create (surface); - cairo_set_source_rgb (cr, 0.75, 0.25, 0.25); - cairo_paint (cr); - cairo_destroy (cr); - - return surface; + cairo_surface_t *surface; + cairo_pattern_t *pattern; + + if (ANTIALIAS == CAIRO_ANTIALIAS_NONE) { + cairo_t *cr; + + surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 256, 192); + cr = cairo_create (surface); + + cairo_set_source_rgb (cr, 0.75, 0.25, 0.25); + cairo_paint (cr); + + pattern = cairo_pattern_create_for_surface (cairo_get_target (cr)); + cairo_destroy (cr); + } else { + surface = cairo_test_create_surface_from_png (ctx, png_filename); + pattern = cairo_pattern_create_for_surface (surface); + } + + *width = cairo_image_surface_get_width (surface); + *height = cairo_image_surface_get_height (surface); + cairo_surface_destroy (surface); + + return pattern; } static cairo_test_status_t draw (cairo_t *cr, int width, int height) { - cairo_surface_t *image; + cairo_pattern_t *image; + int img_width, img_height; - image = get_red_surface (); + image = get_source (cairo_test_get_context (cr), + &img_width, &img_height); /* we don't want to debug antialiasing artifacts */ - cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); + cairo_set_antialias (cr, ANTIALIAS); /* dark grey background */ cairo_set_source_rgb (cr, 0.25, 0.25, 0.25); @@ -62,13 +89,13 @@ draw (cairo_t *cr, int width, int height) cairo_rotate (cr, -0.05); /* place the image on our surface */ - cairo_set_source_surface (cr, image, 0, 0); + cairo_set_source (cr, image); /* paint the image */ - cairo_rectangle (cr, 0, 0, cairo_image_surface_get_width (image), cairo_image_surface_get_height (image)); + cairo_rectangle (cr, 0, 0, img_width, img_height); cairo_fill (cr); - cairo_surface_destroy (image); + cairo_pattern_destroy (image); return CAIRO_TEST_SUCCESS; } |