[cairo-commit] 4 commits - test/cairo-test-runner.c test/coverage.c test/coverage-column-triangles.ref.png test/coverage-column-triangles.xlib.xfail.png test/coverage-intersecting-quads.ref.png test/coverage-intersecting-quads.xlib.xfail.png test/coverage-intersecting-triangles.ref.png test/coverage-intersecting-triangles.xlib.xfail.png test/coverage-row-triangles.ref.png test/coverage-row-triangles.xlib.xfail.png test/half-coverage.c test/Makefile.am test/mask-glyphs.c test/partial-coverage.c test/partial-coverage-intersecting-quads.ref.png test/partial-coverage-intersecting-triangles.ref.png
Chris Wilson
ickle at kemper.freedesktop.org
Sat Jun 12 06:06:50 PDT 2010
test/Makefile.am | 10
test/cairo-test-runner.c | 60 ++--
test/coverage-column-triangles.ref.png |binary
test/coverage-column-triangles.xlib.xfail.png |binary
test/coverage-intersecting-quads.ref.png |binary
test/coverage-intersecting-quads.xlib.xfail.png |binary
test/coverage-intersecting-triangles.ref.png |binary
test/coverage-intersecting-triangles.xlib.xfail.png |binary
test/coverage-row-triangles.ref.png |binary
test/coverage-row-triangles.xlib.xfail.png |binary
test/coverage.c | 253 ++++++++++++++++++-
test/half-coverage.c | 4
test/mask-glyphs.c | 2
test/partial-coverage-intersecting-quads.ref.png |binary
test/partial-coverage-intersecting-triangles.ref.png |binary
test/partial-coverage.c | 143 ++++++++++
16 files changed, 431 insertions(+), 41 deletions(-)
New commits:
commit 299263f8c912d3468d51ed22bcb6ab96275709f0
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sat Jun 12 13:48:12 2010 +0100
test: Disable tests that are too slow to run by default.
Introduce a slow mode [-s] to the runner, and add "slow" to the
requirements for the very long running tests like the coverage stress
tests.
diff --git a/test/cairo-test-runner.c b/test/cairo-test-runner.c
index 0b0ac9c..207ad60 100644
--- a/test/cairo-test-runner.c
+++ b/test/cairo-test-runner.c
@@ -98,6 +98,7 @@ typedef struct _cairo_test_runner {
cairo_bool_t list_only;
cairo_bool_t full_test;
cairo_bool_t keyword_match;
+ cairo_bool_t slow;
cairo_bool_t force_pass;
} cairo_test_runner_t;
@@ -321,7 +322,7 @@ static void
usage (const char *argv0)
{
fprintf (stderr,
- "Usage: %s [-afkxl] [test-names|keywords ...]\n"
+ "Usage: %s [-afkxsl] [test-names|keywords ...]\n"
" %s -l\n"
"\n"
"Run the cairo conformance test suite over the given tests (all by default)\n"
@@ -331,6 +332,7 @@ usage (const char *argv0)
" skips similar surface and device offset testing.\n"
" -f foreground; do not fork\n"
" -k match tests by keyword\n"
+ " -s include slow, long running tests\n"
" -x exit on first failure\n"
" -l list only; just list selected test case names without executing\n"
"\n"
@@ -347,7 +349,7 @@ _parse_cmdline (cairo_test_runner_t *runner, int *argc, char **argv[])
int c;
while (1) {
- c = _cairo_getopt (*argc, *argv, ":aflxt");
+ c = _cairo_getopt (*argc, *argv, ":aflstx");
if (c == -1)
break;
@@ -355,6 +357,9 @@ _parse_cmdline (cairo_test_runner_t *runner, int *argc, char **argv[])
case 'a':
runner->full_test = TRUE;
break;
+ case 's':
+ runner->slow = TRUE;
+ break;
case 'l':
runner->list_only = TRUE;
break;
@@ -790,6 +795,14 @@ main (int argc, char **argv)
const char *requirements = test->requirements;
const char *str;
+ str = strstr (requirements, "slow");
+ if (str != NULL && ! runner.slow) {
+ if (runner.list_only)
+ goto TEST_NEXT;
+ else
+ goto TEST_SKIPPED;
+ }
+
str = strstr (requirements, "cairo");
if (str != NULL && ! _has_required_cairo_version (str)) {
if (runner.list_only)
diff --git a/test/coverage.c b/test/coverage.c
index 198ebae..d77b1e3 100644
--- a/test/coverage.c
+++ b/test/coverage.c
@@ -335,38 +335,38 @@ row_triangles (cairo_t *cr, int width, int height)
CAIRO_TEST (coverage_rectangles,
"Check the fidelity of the rasterisation.",
NULL, /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
WIDTH, HEIGHT,
NULL, rectangles)
CAIRO_TEST (coverage_intersecting_quads,
"Check the fidelity of the rasterisation.",
NULL, /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
WIDTH, HEIGHT,
NULL, intersecting_quads)
CAIRO_TEST (coverage_intersecting_triangles,
"Check the fidelity of the rasterisation.",
NULL, /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
WIDTH, HEIGHT,
NULL, intersecting_triangles)
CAIRO_TEST (coverage_row_triangles,
"Check the fidelity of the rasterisation.",
NULL, /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
WIDTH, HEIGHT,
NULL, row_triangles)
CAIRO_TEST (coverage_column_triangles,
"Check the fidelity of the rasterisation.",
NULL, /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
WIDTH, HEIGHT,
NULL, column_triangles)
CAIRO_TEST (coverage_triangles,
"Check the fidelity of the rasterisation.",
NULL, /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
WIDTH, HEIGHT,
NULL, triangles)
diff --git a/test/half-coverage.c b/test/half-coverage.c
index 50f3b85..38cafda 100644
--- a/test/half-coverage.c
+++ b/test/half-coverage.c
@@ -143,13 +143,13 @@ triangles (cairo_t *cr, int width, int height)
CAIRO_TEST (half_coverage_rectangles,
"Check the fidelity of the rasterisation.",
NULL, /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
WIDTH * SIZE, HEIGHT,
NULL, rectangles)
CAIRO_TEST (half_coverage_triangles,
"Check the fidelity of the rasterisation.",
NULL, /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
WIDTH * SIZE, HEIGHT,
NULL, triangles)
diff --git a/test/mask-glyphs.c b/test/mask-glyphs.c
index 1a76c4e..0a912e1 100644
--- a/test/mask-glyphs.c
+++ b/test/mask-glyphs.c
@@ -184,6 +184,6 @@ draw (cairo_t *cr, int width, int height)
CAIRO_TEST (mask_glyphs,
"Creates a mask using a distorted array of overlapping glyphs",
"mask, glyphs", /* keywords */
- NULL, /* requirements */
+ "slow", /* requirements */
WIDTH, HEIGHT,
NULL, draw)
diff --git a/test/partial-coverage.c b/test/partial-coverage.c
index ae0ee1e..0b5cbdc 100644
--- a/test/partial-coverage.c
+++ b/test/partial-coverage.c
@@ -612,51 +612,51 @@ intersecting_triangles (cairo_t *cr, int width, int height)
CAIRO_TEST (partial_coverage_rectangles,
"Check the fidelity of the rasterisation.",
"coverage raster", /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
SIZE, SIZE,
NULL, rectangles)
CAIRO_TEST (partial_coverage_intersecting_quads,
"Check the fidelity of the rasterisation.",
"coverage raster", /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
SIZE, SIZE,
NULL, intersecting_quads)
CAIRO_TEST (partial_coverage_intersecting_triangles,
"Check the fidelity of the rasterisation.",
"coverage raster", /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
SIZE, SIZE,
NULL, intersecting_triangles)
CAIRO_TEST (partial_coverage_triangles,
"Check the fidelity of the rasterisation.",
"coverage raster", /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
SIZE, SIZE,
NULL, triangles)
CAIRO_TEST (partial_coverage_overlap_three_quarter_triangles,
"Check the fidelity of the rasterisation.",
"coverage raster", /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
SIZE, SIZE,
NULL, overlap_three_quarter_triangles)
CAIRO_TEST (partial_coverage_overlap_half_triangles_eo,
"Check the fidelity of the rasterisation.",
"coverage raster", /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
SIZE, SIZE,
NULL, overlap_half_triangles_eo)
CAIRO_TEST (partial_coverage_overlap_half_triangles,
"Check the fidelity of the rasterisation.",
"coverage raster", /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
SIZE, SIZE,
NULL, overlap_half_triangles)
CAIRO_TEST (partial_coverage_half_triangles,
"Check the fidelity of the rasterisation.",
"coverage raster", /* keywords */
- "target=raster", /* requirements */
+ "target=raster slow", /* requirements */
SIZE, SIZE,
NULL, half_triangles)
commit 53139261c7ba1a4cc0b869cb48c136b0362a3b0c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sat Jun 12 13:40:17 2010 +0100
test: Use exact matching on test names by default.
Specifying individual tests to run is more common than using a group
chosen from a keyword, so change the default matching mode and introduce
'-k' to select by keyword.
diff --git a/test/cairo-test-runner.c b/test/cairo-test-runner.c
index aa9e101..0b0ac9c 100644
--- a/test/cairo-test-runner.c
+++ b/test/cairo-test-runner.c
@@ -97,7 +97,7 @@ typedef struct _cairo_test_runner {
cairo_bool_t exit_on_failure;
cairo_bool_t list_only;
cairo_bool_t full_test;
- cairo_bool_t exact_test_names;
+ cairo_bool_t keyword_match;
cairo_bool_t force_pass;
} cairo_test_runner_t;
@@ -321,7 +321,7 @@ static void
usage (const char *argv0)
{
fprintf (stderr,
- "Usage: %s [-afxlt] [test-names|keywords ...]\n"
+ "Usage: %s [-afkxl] [test-names|keywords ...]\n"
" %s -l\n"
"\n"
"Run the cairo conformance test suite over the given tests (all by default)\n"
@@ -330,13 +330,14 @@ usage (const char *argv0)
" -a all; run the full set of tests. By default the test suite\n"
" skips similar surface and device offset testing.\n"
" -f foreground; do not fork\n"
- " -t exact test names, no keyword matching\n"
+ " -k match tests by keyword\n"
" -x exit on first failure\n"
" -l list only; just list selected test case names without executing\n"
"\n"
"If test names are given they are used as matches either to a specific\n"
"test case or to a keyword, so a command such as\n"
- "\"cairo-test-suite text\" can be used to run all text test cases.\n",
+ "\"cairo-test-suite -k text\" can be used to run all text test cases, and\n"
+ "\"cairo-test-suite text-transform\" to run the individual case.\n",
argv0, argv0);
}
@@ -363,8 +364,8 @@ _parse_cmdline (cairo_test_runner_t *runner, int *argc, char **argv[])
case 'x':
runner->exit_on_failure = TRUE;
break;
- case 't':
- runner->exact_test_names = TRUE;
+ case 'k':
+ runner->keyword_match = TRUE;
break;
default:
fprintf (stderr, "Internal error: unhandled option: %c\n", c);
@@ -760,23 +761,21 @@ main (int argc, char **argv)
if (invert)
match++;
- /* exact match on test name */
- if (strcmp (name, match) == 0) {
- found = ! invert;
- break;
- } else if (invert) {
- found = TRUE;
- }
-
- if (runner.exact_test_names)
- continue;
-
- /* XXX keyword match */
- if (keywords != NULL && strstr (keywords, match) != NULL) {
- found = ! invert;
- break;
- } else if (invert) {
- found = TRUE;
+ if (runner.keyword_match) {
+ if (keywords != NULL && strstr (keywords, match) != NULL) {
+ found = ! invert;
+ break;
+ } else if (invert) {
+ found = TRUE;
+ }
+ } else {
+ /* exact match on test name */
+ if (strcmp (name, match) == 0) {
+ found = ! invert;
+ break;
+ } else if (invert) {
+ found = TRUE;
+ }
}
}
commit 97288b0859bae6cea1e3bff84b632e00f1d10917
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sat Jun 12 13:34:27 2010 +0100
test: More minute geometry exercised by partial-coverage.
Moving beyond the capabilities of cairo...
diff --git a/test/Makefile.am b/test/Makefile.am
index 836b1b4..6415462 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 0000000..17f4ff0
Binary files /dev/null and b/test/partial-coverage-intersecting-quads.ref.png differ
diff --git a/test/partial-coverage-intersecting-triangles.ref.png b/test/partial-coverage-intersecting-triangles.ref.png
new file mode 100644
index 0000000..9e4a6fe
Binary files /dev/null and b/test/partial-coverage-intersecting-triangles.ref.png differ
diff --git a/test/partial-coverage.c b/test/partial-coverage.c
index 128ca6b..ae0ee1e 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 */
commit 4e3ef57bc892b0b046c486390adc7164a1de64de
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sat Jun 12 13:18:42 2010 +0100
test: More coverage coverage.
A couple of different shapes that aim to test the tessellation side of
the rasterisers more... And worryingly there does seem to be an
unexpected systematic error.
diff --git a/test/Makefile.am b/test/Makefile.am
index bc43e48..836b1b4 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -345,6 +345,14 @@ REFERENCE_IMAGES = \
copy-path.ref.png \
coverage-rectangles.ref.png \
coverage-rectangles.xlib.xfail.png \
+ coverage-intersecting-triangles.ref.png \
+ coverage-intersecting-triangles.xlib.xfail.png \
+ coverage-intersecting-quads.ref.png \
+ coverage-intersecting-quads.xlib.xfail.png \
+ coverage-row-trianges.ref.png \
+ coverage-row-trianges.xlib.xfail.png \
+ coverage-column-trianges.ref.png \
+ coverage-column-trianges.xlib.xfail.png \
coverage-triangles.ref.png \
coverage-triangles.xlib.xfail.png \
create-from-png-stream.ref.png \
diff --git a/test/coverage-column-triangles.ref.png b/test/coverage-column-triangles.ref.png
new file mode 100644
index 0000000..aa61031
Binary files /dev/null and b/test/coverage-column-triangles.ref.png differ
diff --git a/test/coverage-column-triangles.xlib.xfail.png b/test/coverage-column-triangles.xlib.xfail.png
new file mode 100644
index 0000000..f433b7a
Binary files /dev/null and b/test/coverage-column-triangles.xlib.xfail.png differ
diff --git a/test/coverage-intersecting-quads.ref.png b/test/coverage-intersecting-quads.ref.png
new file mode 100644
index 0000000..f56cb55
Binary files /dev/null and b/test/coverage-intersecting-quads.ref.png differ
diff --git a/test/coverage-intersecting-quads.xlib.xfail.png b/test/coverage-intersecting-quads.xlib.xfail.png
new file mode 100644
index 0000000..d6b8c2e
Binary files /dev/null and b/test/coverage-intersecting-quads.xlib.xfail.png differ
diff --git a/test/coverage-intersecting-triangles.ref.png b/test/coverage-intersecting-triangles.ref.png
new file mode 100644
index 0000000..40a48c1
Binary files /dev/null and b/test/coverage-intersecting-triangles.ref.png differ
diff --git a/test/coverage-intersecting-triangles.xlib.xfail.png b/test/coverage-intersecting-triangles.xlib.xfail.png
new file mode 100644
index 0000000..e64cd47
Binary files /dev/null and b/test/coverage-intersecting-triangles.xlib.xfail.png differ
diff --git a/test/coverage-row-triangles.ref.png b/test/coverage-row-triangles.ref.png
new file mode 100644
index 0000000..aa61031
Binary files /dev/null and b/test/coverage-row-triangles.ref.png differ
diff --git a/test/coverage-row-triangles.xlib.xfail.png b/test/coverage-row-triangles.xlib.xfail.png
new file mode 100644
index 0000000..f8582fb
Binary files /dev/null and b/test/coverage-row-triangles.xlib.xfail.png differ
diff --git a/test/coverage.c b/test/coverage.c
index 70ef97b..198ebae 100644
--- a/test/coverage.c
+++ b/test/coverage.c
@@ -30,12 +30,15 @@
* driver test suite.
*/
+#define GENERATE_REFERENCE 0
+
#define WIDTH 256
#define HEIGHT 40
#include "../src/cairo-fixed-type-private.h"
#define PRECISION (1 << CAIRO_FIXED_FRAC_BITS)
+/* XXX beware multithreading! */
static uint32_t state;
static uint32_t
@@ -47,10 +50,12 @@ hars_petruska_f54_1_random (void)
}
static double
-random_offset (int range)
+random_offset (int range, int precise)
{
double x = hars_petruska_f54_1_random() / (double) UINT32_MAX * range / WIDTH;
- return floor (x * PRECISION) / PRECISION;
+ if (precise)
+ x = floor (x * PRECISION) / PRECISION;
+ return x;
}
static cairo_test_status_t
@@ -63,6 +68,13 @@ rectangles (cairo_t *cr, int width, int height)
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_paint (cr);
+#if GENERATE_REFERENCE
+ for (x = 0; x < WIDTH; x++) {
+ cairo_set_source_rgba (cr, 1, 1, 1, x * x * 1.0 / (WIDTH * WIDTH));
+ cairo_rectangle (cr, x, 0, 1, HEIGHT);
+ cairo_fill (cr);
+ }
+#else
cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
for (channel = 0; channel < 3; channel++) {
switch (channel) {
@@ -74,13 +86,111 @@ rectangles (cairo_t *cr, int width, int height)
for (x = 0; x < WIDTH; x++) {
for (y = 0; y < HEIGHT; y++) {
- double dx = random_offset (WIDTH - x);
- double dy = random_offset (WIDTH - x);
+ double dx = random_offset (WIDTH - x, TRUE);
+ double dy = random_offset (WIDTH - x, TRUE);
cairo_rectangle (cr, x + dx, y + dy, x / (double) WIDTH, x / (double) WIDTH);
}
}
cairo_fill (cr);
}
+#endif
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+static cairo_test_status_t
+intersecting_quads (cairo_t *cr, int width, int height)
+{
+ int x, y, channel;
+
+ state = 0x12345678;
+
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+ cairo_paint (cr);
+
+#if GENERATE_REFERENCE
+ for (x = 0; x < WIDTH; x++) {
+ cairo_set_source_rgba (cr, 1, 1, 1, x * x * 0.5 / (WIDTH * WIDTH));
+ cairo_rectangle (cr, x, 0, 1, HEIGHT);
+ cairo_fill (cr);
+ }
+#else
+ 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 (x = 0; x < WIDTH; x++) {
+ double step = x / (double) WIDTH;
+ for (y = 0; y < HEIGHT; y++) {
+ double dx = random_offset (WIDTH - x, TRUE);
+ double dy = random_offset (WIDTH - x, TRUE);
+ cairo_move_to (cr, x + dx, y + dy);
+ cairo_rel_line_to (cr, step, step);
+ cairo_rel_line_to (cr, 0, -step);
+ cairo_rel_line_to (cr, -step, step);
+ cairo_close_path (cr);
+ }
+ }
+ cairo_fill (cr);
+ }
+#endif
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+static cairo_test_status_t
+intersecting_triangles (cairo_t *cr, int width, int height)
+{
+ int x, y, channel;
+
+ state = 0x12345678;
+
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+ cairo_paint (cr);
+
+#if GENERATE_REFERENCE
+ for (x = 0; x < WIDTH; x++) {
+ cairo_set_source_rgba (cr, 1, 1, 1, x * 0.75 / WIDTH);
+ cairo_rectangle (cr, x, 0, 1, HEIGHT);
+ cairo_fill (cr);
+ }
+#else
+ 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 (x = 0; x < WIDTH; x++) {
+ double step = x / (double) WIDTH;
+ for (y = 0; y < HEIGHT; y++) {
+ double dx = random_offset (WIDTH - x, TRUE);
+ double dy = random_offset (WIDTH - x, TRUE);
+
+ /* left */
+ cairo_move_to (cr, x + dx, y + dy);
+ cairo_rel_line_to (cr, 0, step);
+ cairo_rel_line_to (cr, step, 0);
+ cairo_close_path (cr);
+
+ /* right, mirrored */
+ cairo_move_to (cr, x + dx + step, y + dy + step);
+ cairo_rel_line_to (cr, 0, -step);
+ cairo_rel_line_to (cr, -step, step);
+ cairo_close_path (cr);
+ }
+ }
+ cairo_fill (cr);
+ }
+#endif
return CAIRO_TEST_SUCCESS;
}
@@ -95,6 +205,13 @@ triangles (cairo_t *cr, int width, int height)
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_paint (cr);
+#if GENERATE_REFERENCE
+ for (x = 0; x < WIDTH; x++) {
+ cairo_set_source_rgba (cr, 1, 1, 1, x * x * 0.5 / (WIDTH * WIDTH));
+ cairo_rectangle (cr, x, 0, 1, HEIGHT);
+ cairo_fill (cr);
+ }
+#else
cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
for (channel = 0; channel < 3; channel++) {
switch (channel) {
@@ -106,8 +223,8 @@ triangles (cairo_t *cr, int width, int height)
for (x = 0; x < WIDTH; x++) {
for (y = 0; y < HEIGHT; y++) {
- double dx = random_offset (WIDTH - x);
- double dy = random_offset (WIDTH - x);
+ double dx = random_offset (WIDTH - x, TRUE);
+ double dy = random_offset (WIDTH - x, TRUE);
cairo_move_to (cr, x + dx, y + dy);
cairo_rel_line_to (cr, x / (double) WIDTH, 0);
cairo_rel_line_to (cr, 0, x / (double) WIDTH);
@@ -116,6 +233,101 @@ triangles (cairo_t *cr, int width, int height)
}
cairo_fill (cr);
}
+#endif
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+static cairo_test_status_t
+column_triangles (cairo_t *cr, int width, int height)
+{
+ int x, y, i, channel;
+
+ state = 0x12345678;
+
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+ cairo_paint (cr);
+
+#if GENERATE_REFERENCE
+ for (x = 0; x < WIDTH; x++) {
+ cairo_set_source_rgba (cr, 1, 1, 1, x * 0.5 / WIDTH);
+ cairo_rectangle (cr, x, 0, 1, HEIGHT);
+ cairo_fill (cr);
+ }
+#else
+ 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 (x = 0; x < WIDTH; x++) {
+ double step = x / (double) (2 * WIDTH);
+ for (y = 0; y < HEIGHT; y++) {
+ for (i = 0; i < PRECISION; i++) {
+ double dy = random_offset (WIDTH - x, FALSE);
+
+ cairo_move_to (cr, x + i / (double) PRECISION, y + dy);
+ cairo_rel_line_to (cr, 0, step);
+ cairo_rel_line_to (cr, 1 / (double) PRECISION, step);
+ cairo_rel_line_to (cr, 0, -step);
+ cairo_close_path (cr);
+ }
+ cairo_fill (cr); /* do these per-pixel due to the extra volume of edges */
+ }
+ }
+ }
+#endif
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+static cairo_test_status_t
+row_triangles (cairo_t *cr, int width, int height)
+{
+ int x, y, i, channel;
+
+ state = 0x12345678;
+
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+ cairo_paint (cr);
+
+#if GENERATE_REFERENCE
+ for (x = 0; x < WIDTH; x++) {
+ cairo_set_source_rgba (cr, 1, 1, 1, x * 0.5 / WIDTH);
+ cairo_rectangle (cr, x, 0, 1, HEIGHT);
+ cairo_fill (cr);
+ }
+#else
+ 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 (x = 0; x < WIDTH; x++) {
+ double step = x / (double) (2 * WIDTH);
+ for (y = 0; y < HEIGHT; y++) {
+ for (i = 0; i < PRECISION; i++) {
+ double dx = random_offset (WIDTH - x, FALSE);
+
+ cairo_move_to (cr, x + dx, y + i / (double) PRECISION);
+ cairo_rel_line_to (cr, step, 0);
+ cairo_rel_line_to (cr, step, 1 / (double) PRECISION);
+ cairo_rel_line_to (cr, -step, 0);
+ cairo_close_path (cr);
+ }
+ cairo_fill (cr); /* do these per-pixel due to the extra volume of edges */
+ }
+ }
+ }
+#endif
return CAIRO_TEST_SUCCESS;
}
@@ -127,6 +339,31 @@ CAIRO_TEST (coverage_rectangles,
WIDTH, HEIGHT,
NULL, rectangles)
+CAIRO_TEST (coverage_intersecting_quads,
+ "Check the fidelity of the rasterisation.",
+ NULL, /* keywords */
+ "target=raster", /* requirements */
+ WIDTH, HEIGHT,
+ NULL, intersecting_quads)
+
+CAIRO_TEST (coverage_intersecting_triangles,
+ "Check the fidelity of the rasterisation.",
+ NULL, /* keywords */
+ "target=raster", /* requirements */
+ WIDTH, HEIGHT,
+ NULL, intersecting_triangles)
+CAIRO_TEST (coverage_row_triangles,
+ "Check the fidelity of the rasterisation.",
+ NULL, /* keywords */
+ "target=raster", /* requirements */
+ WIDTH, HEIGHT,
+ NULL, row_triangles)
+CAIRO_TEST (coverage_column_triangles,
+ "Check the fidelity of the rasterisation.",
+ NULL, /* keywords */
+ "target=raster", /* requirements */
+ WIDTH, HEIGHT,
+ NULL, column_triangles)
CAIRO_TEST (coverage_triangles,
"Check the fidelity of the rasterisation.",
NULL, /* keywords */
More information about the cairo-commit
mailing list