From 97288b0859bae6cea1e3bff84b632e00f1d10917 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 12 Jun 2010 13:34:27 +0100 Subject: [PATCH] test: More minute geometry exercised by partial-coverage. Moving beyond the capabilities of cairo... --- test/Makefile.am | 2 + ...artial-coverage-intersecting-quads.ref.png | Bin 0 -> 189 bytes ...al-coverage-intersecting-triangles.ref.png | Bin 0 -> 202 bytes test/partial-coverage.c | 131 ++++++++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 test/partial-coverage-intersecting-quads.ref.png create mode 100644 test/partial-coverage-intersecting-triangles.ref.png diff --git a/test/Makefile.am b/test/Makefile.am index 836b1b40c..641546266 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 new file mode 100644 index 0000000000000000000000000000000000000000..17f4ff06b367b25be02a7140335f88f322ee4048 GIT binary patch literal 189 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1SD0tpLGH$wj^(N7l!{JxM1({$v}}JPZ!6K zjK;U;Hwqqb;5oeE#`oXn=LkmZWM-eh_gU85c>C|&)zt+&6%2w7ECGxz45E}#S4|(V Ydm1sDN|l^q0ou;s>FVdQ&MBb@0D8kOT>t<8 literal 0 HcmV?d00001 diff --git a/test/partial-coverage-intersecting-triangles.ref.png b/test/partial-coverage-intersecting-triangles.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..9e4a6fe42be7b780e92a471be50536b645886d6e GIT binary patch literal 202 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1SD0tpLGH$wj^(N7l!{JxM1({$v}~MPZ!6K zjK;U;H*y|v5MXiC&G{!d|D)jv3om}#vV#{s@40iP=Jfk_cbiYwaUa;n@Rs`mHHiOq g3Fj=!`SpIwJ7jW-7zAz)0Xl`j)78&qol`;+0AWs1+yDRo literal 0 HcmV?d00001 diff --git a/test/partial-coverage.c b/test/partial-coverage.c index 128ca6b9f..ae0ee1ede 100644 --- a/test/partial-coverage.c +++ b/test/partial-coverage.c @@ -186,6 +186,54 @@ rectangles (cairo_t *cr, int width, int height) return CAIRO_TEST_SUCCESS; } +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) { @@ -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 */