From e749b58af827e4cc28353bcc6bc4b2ab8d47aaf6 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 19 Sep 2008 13:19:51 +0100 Subject: [PATCH] [test] Add rectilinear-fill Add a test-case to exercise pixel-aligned fills to verify the optimised rectilinear filler. --- test/.gitignore | 1 + test/Makefile.am | 2 + test/rectilinear-fill-ref.png | Bin 0 -> 162 bytes test/rectilinear-fill.c | 92 ++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 test/rectilinear-fill-ref.png create mode 100644 test/rectilinear-fill.c diff --git a/test/.gitignore b/test/.gitignore index 6454dd334..0ad92da83 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -168,6 +168,7 @@ svg-surface-source.svg pixman-rotate pthread-show-text rectangle-rounding-error +rectilinear-fill rectilinear-miter-limit rectilinear-stroke reflected-stroke diff --git a/test/Makefile.am b/test/Makefile.am index 72aa9e0f2..1dcde7dda 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -121,6 +121,7 @@ push-group$(EXEEXT) \ radial-gradient$(EXEEXT) \ random-intersections$(EXEEXT) \ rectangle-rounding-error$(EXEEXT) \ +rectilinear-fill$(EXEEXT) \ rectilinear-miter-limit$(EXEEXT) \ rectilinear-stroke$(EXEEXT) \ reflected-stroke$(EXEEXT) \ @@ -600,6 +601,7 @@ REFERENCE_IMAGES = \ random-intersections-quartz-ref.png \ rgb24-ignore-alpha-ref.png \ rectangle-rounding-error-ref.png \ + rectilinear-fill-ref.png \ rectilinear-miter-limit-ref.png \ rectilinear-miter-limit-ps-ref.png \ rectilinear-stroke-ref.png \ diff --git a/test/rectilinear-fill-ref.png b/test/rectilinear-fill-ref.png new file mode 100644 index 0000000000000000000000000000000000000000..84b5967e25f966f8b2906484b848b65bbf4c99c5 GIT binary patch literal 162 zcmeAS@N?(olHy`uVBq!ia0vp^54-xq^ + */ + +#include "cairo-test.h" + +#define SIZE 24 + +static cairo_test_draw_function_t draw; + +static const cairo_test_t test = { + "rectilinear-fill", + "Test rectilinear fill operations (covering only whole pixels)", + SIZE, 2 * SIZE, + draw +}; + +static void +draw_rectangles (cairo_t *cr) +{ + cairo_save (cr); + + /* test constructing single rectangles */ + cairo_rectangle (cr, 0, 0, SIZE/2, 2); + cairo_fill (cr); + + cairo_rectangle (cr, 0, 5, SIZE/2, -2); + cairo_fill (cr); + + cairo_rectangle (cr, SIZE/2, 6, -SIZE/2, 2); + cairo_fill (cr); + + cairo_rectangle (cr, SIZE/2, 11, -SIZE/2, -2); + cairo_fill (cr); + + /* test constructing multiple rectangles */ + cairo_translate (cr, 0, 12); + cairo_rectangle (cr, 0, 0, SIZE/2, 2); + cairo_rectangle (cr, 0, 5, SIZE/2, -2); + cairo_rectangle (cr, SIZE/2, 6, -SIZE/2, 2); + cairo_rectangle (cr, SIZE/2, 11, -SIZE/2, -2); + cairo_fill (cr); + + cairo_restore (cr); +} + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + /* Paint background white, then draw in black. */ + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */ + + draw_rectangles (cr); + + /* and check using cw winding */ + cairo_translate (cr, SIZE, SIZE); + cairo_scale (cr, -1, 1); + + draw_rectangles (cr); + + return CAIRO_TEST_SUCCESS; +} + +int +main (void) +{ + return cairo_test (&test); +}