test: Update partial coverage.

Gah, no wonder the output looked wrong for the triangles, they only
covered half the pixel. So separate triangles into two cases.
This commit is contained in:
Chris Wilson 2010-06-10 14:13:53 +01:00
parent 8d67186cb2
commit ef5f9b5c61
4 changed files with 96 additions and 4 deletions

View file

@ -862,6 +862,8 @@ REFERENCE_IMAGES = \
paint-with-alpha.ref.png \
paint-with-alpha.svg.ref.png \
paint.ref.png \
partial-coverage-half-reference.ref.png \
partial-coverage-half-triangles.ref.png \
partial-coverage-rectangles.ref.png \
partial-coverage-reference.ref.png \
partial-coverage-triangles.ref.png \

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

View file

@ -98,6 +98,24 @@ reference (cairo_t *cr, int width, int height)
return CAIRO_STATUS_SUCCESS;
}
static cairo_test_status_t
half_reference (cairo_t *cr, int width, int height)
{
int i;
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_paint (cr);
for (i = 0; i < SIZE*SIZE; i++) {
cairo_set_source_rgba (cr, 1., 1., 1.,
.5 * i / (double) (SIZE * SIZE));
cairo_rectangle (cr, i % SIZE, i / SIZE, 1, 1);
cairo_fill (cr);
}
return CAIRO_STATUS_SUCCESS;
}
static cairo_test_status_t
rectangles (cairo_t *cr, int width, int height)
{
@ -145,7 +163,7 @@ rectangles (cairo_t *cr, int width, int height)
}
static cairo_test_status_t
triangles (cairo_t *cr, int width, int height)
half_triangles (cairo_t *cr, int width, int height)
{
uint8_t *occupancy;
int i, j, channel;
@ -191,23 +209,95 @@ triangles (cairo_t *cr, int width, int height)
return CAIRO_TEST_SUCCESS;
}
static cairo_test_status_t
full_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));
xs = i % SIZE * SAMPLE;
ys = i / SIZE * SAMPLE;
for (j = 0; j < SAMPLE*SAMPLE; j++) {
if (occupancy[j]) {
/* Add a tile composed of two non-overlapping triangles.
* .__.
* | /|
* |/ |
* .--.
*/
int x = j % SAMPLE + xs;
int y = j / SAMPLE + ys;
/* top-left triangle */
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);
/* bottom-right triangle */
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);
}
}
cairo_fill (cr);
}
}
free (occupancy);
return CAIRO_TEST_SUCCESS;
}
CAIRO_TEST (partial_coverage_rectangles,
"Check the fidelity of the rasterisation.",
"coverage raster", /* keywords */
"raster", /* requirements */
SIZE, SIZE,
NULL, rectangles)
CAIRO_TEST (partial_coverage_triangles,
"Check the fidelity of the rasterisation.",
"coverage raster", /* keywords */
"raster", /* requirements */
SIZE, SIZE,
NULL, triangles)
NULL, full_triangles)
CAIRO_TEST (partial_coverage_reference,
"Check the fidelity of this test.",
"coverage raster", /* keywords */
"raster", /* requirements */
SIZE, SIZE,
NULL, reference)
CAIRO_TEST (partial_coverage_half_triangles,
"Check the fidelity of the rasterisation.",
"coverage raster", /* keywords */
"raster", /* requirements */
SIZE, SIZE,
NULL, half_triangles)
CAIRO_TEST (partial_coverage_half_reference,
"Check the fidelity of this test.",
"coverage raster", /* keywords */
"raster", /* requirements */
SIZE, SIZE,
NULL, half_reference)