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.
This commit is contained in:
Chris Wilson 2010-06-12 13:18:42 +01:00
parent 9b7cc7641b
commit 4e3ef57bc8
10 changed files with 251 additions and 6 deletions

View file

@ -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 \

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -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 */