diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-06-12 13:34:27 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-06-12 14:06:06 +0100 |
commit | 97288b0859bae6cea1e3bff84b632e00f1d10917 (patch) | |
tree | 9d3f8db19fa98ec21bf7574d8e892d456173a9b9 | |
parent | 4e3ef57bc892b0b046c486390adc7164a1de64de (diff) |
test: More minute geometry exercised by partial-coverage.
Moving beyond the capabilities of cairo...
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/partial-coverage-intersecting-quads.ref.png | bin | 0 -> 189 bytes | |||
-rw-r--r-- | test/partial-coverage-intersecting-triangles.ref.png | bin | 0 -> 202 bytes | |||
-rw-r--r-- | test/partial-coverage.c | 131 |
4 files changed, 133 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 836b1b40..64154626 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -891,6 +891,8 @@ REFERENCE_IMAGES = \ paint.ref.png \ partial-coverage-half-reference.ref.png \ partial-coverage-half-triangles.ref.png \ + partial-coverage-intersecting-quads.ref.png \ + partial-coverage-intersecting-triangles.ref.png \ partial-coverage-overlap-half-triangles.ref.png \ partial-coverage-overlap-half-triangles-eo.ref.png \ partial-coverage-overlap-three-quarter-triangles.ref.png \ diff --git a/test/partial-coverage-intersecting-quads.ref.png b/test/partial-coverage-intersecting-quads.ref.png Binary files differnew file mode 100644 index 00000000..17f4ff06 --- /dev/null +++ b/test/partial-coverage-intersecting-quads.ref.png diff --git a/test/partial-coverage-intersecting-triangles.ref.png b/test/partial-coverage-intersecting-triangles.ref.png Binary files differnew file mode 100644 index 00000000..9e4a6fe4 --- /dev/null +++ b/test/partial-coverage-intersecting-triangles.ref.png diff --git a/test/partial-coverage.c b/test/partial-coverage.c index 128ca6b9..ae0ee1ed 100644 --- a/test/partial-coverage.c +++ b/test/partial-coverage.c @@ -187,6 +187,54 @@ rectangles (cairo_t *cr, int width, int height) } static cairo_test_status_t +intersecting_quads (cairo_t *cr, int width, int height) +{ + uint8_t *occupancy; + int i, j, channel; + + state = 0x12345678; + occupancy = xmalloc (SAMPLE*SAMPLE); + + cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); + cairo_paint (cr); + + cairo_set_operator (cr, CAIRO_OPERATOR_ADD); + for (channel = 0; channel < 3; channel++) { + switch (channel) { + default: + case 0: cairo_set_source_rgb (cr, 1.0, 0.0, 0.0); break; + case 1: cairo_set_source_rgb (cr, 0.0, 1.0, 0.0); break; + case 2: cairo_set_source_rgb (cr, 0.0, 0.0, 1.0); break; + } + + for (i = 0; i < SIZE*SIZE; i++) { + int xs, ys; + + compute_occupancy (occupancy, SAMPLE*SAMPLE * i / (SIZE * SIZE), SAMPLE*SAMPLE); + + xs = i % SIZE * SAMPLE; + ys = i / SIZE * SAMPLE; + for (j = 0; j < SAMPLE*SAMPLE; j++) { + if (occupancy[j]) { + cairo_move_to (cr, + (j % SAMPLE + xs) / (double) SAMPLE, + (j / SAMPLE + ys) / (double) SAMPLE); + cairo_rel_line_to (cr, 1 / (double) SAMPLE, 1 / (double) SAMPLE); + cairo_rel_line_to (cr, 0, -1 / (double) SAMPLE); + cairo_rel_line_to (cr, -1 / (double) SAMPLE, 1 / (double) SAMPLE); + cairo_close_path (cr); + } + } + cairo_fill (cr); + } + } + + free (occupancy); + + return CAIRO_TEST_SUCCESS; +} + +static cairo_test_status_t half_triangles (cairo_t *cr, int width, int height) { uint8_t *occupancy; @@ -491,6 +539,76 @@ triangles (cairo_t *cr, int width, int height) return CAIRO_TEST_SUCCESS; } +static cairo_test_status_t +intersecting_triangles (cairo_t *cr, int width, int height) +{ + uint8_t *occupancy; + int i, j, channel; + + state = 0x12345678; + occupancy = xmalloc (SAMPLE*SAMPLE); + + cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); + cairo_paint (cr); + + cairo_set_operator (cr, CAIRO_OPERATOR_ADD); + for (channel = 0; channel < 3; channel++) { + switch (channel) { + default: + case 0: cairo_set_source_rgb (cr, 1.0, 0.0, 0.0); break; + case 1: cairo_set_source_rgb (cr, 0.0, 1.0, 0.0); break; + case 2: cairo_set_source_rgb (cr, 0.0, 0.0, 1.0); break; + } + + for (i = 0; i < SIZE*SIZE; i++) { + int xs, ys; + + compute_occupancy (occupancy, SAMPLE*SAMPLE * i / (SIZE * SIZE), SAMPLE*SAMPLE); + + xs = i % SIZE * SAMPLE; + ys = i / SIZE * SAMPLE; + for (j = 0; j < SAMPLE*SAMPLE; j++) { + if (occupancy[j]) { + /* Add 2 overlapping tiles in a single cell, each composed + * of two non-overlapping triangles. + * .--. .--. + * | /| |\ | + * |/ | + | \| + * .--. .--. + */ + int x = j % SAMPLE + xs; + int y = j / SAMPLE + ys; + + /* first pair of triangles, diagonal bottom-left to top-right */ + cairo_move_to (cr, (x) / (double) SAMPLE, (y) / (double) SAMPLE); + cairo_line_to (cr, (x+1) / (double) SAMPLE, (y) / (double) SAMPLE); + cairo_line_to (cr, (x) / (double) SAMPLE, (y+1) / (double) SAMPLE); + cairo_close_path (cr); + cairo_move_to (cr, (x) / (double) SAMPLE, (y+1) / (double) SAMPLE); + cairo_line_to (cr, (x+1) / (double) SAMPLE, (y+1) / (double) SAMPLE); + cairo_line_to (cr, (x+1) / (double) SAMPLE, (y) / (double) SAMPLE); + cairo_close_path (cr); + + /* second pair of triangles, diagonal top-left to bottom-right */ + cairo_move_to (cr, (x) / (double) SAMPLE, (y) / (double) SAMPLE); + cairo_line_to (cr, (x+1) / (double) SAMPLE, (y+1) / (double) SAMPLE); + cairo_line_to (cr, (x+1) / (double) SAMPLE, (y) / (double) SAMPLE); + cairo_close_path (cr); + cairo_move_to (cr, (x) / (double) SAMPLE, (y) / (double) SAMPLE); + cairo_line_to (cr, (x+1) / (double) SAMPLE, (y+1) / (double) SAMPLE); + cairo_line_to (cr, (x) / (double) SAMPLE, (y+1) / (double) SAMPLE); + cairo_close_path (cr); + } + } + cairo_fill (cr); + } + } + + free (occupancy); + + return CAIRO_TEST_SUCCESS; +} + CAIRO_TEST (partial_coverage_rectangles, "Check the fidelity of the rasterisation.", "coverage raster", /* keywords */ @@ -498,6 +616,19 @@ CAIRO_TEST (partial_coverage_rectangles, SIZE, SIZE, NULL, rectangles) +CAIRO_TEST (partial_coverage_intersecting_quads, + "Check the fidelity of the rasterisation.", + "coverage raster", /* keywords */ + "target=raster", /* requirements */ + SIZE, SIZE, + NULL, intersecting_quads) + +CAIRO_TEST (partial_coverage_intersecting_triangles, + "Check the fidelity of the rasterisation.", + "coverage raster", /* keywords */ + "target=raster", /* requirements */ + SIZE, SIZE, + NULL, intersecting_triangles) CAIRO_TEST (partial_coverage_triangles, "Check the fidelity of the rasterisation.", "coverage raster", /* keywords */ |