mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 14:38:13 +02:00
test/coverage: Exercise invariance under mirror symmetry
Massimo noticed that the record/record-flip were not being rasterised as identical mirror images due to a half-subpixel offset in the tor scan converter. This test attempts to reproduce this error by rendering a rhombus around the origin of each cell (that is it generates 4 mirror images of a triangle in the 4 different orientations0. The expectation is that each pixel in the group is lit identically as the coverage is identical. References: https://bugs.freedesktop.org/show_bug.cgi?id=84396 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
fbb0a260b7
commit
5c03b20732
2 changed files with 55 additions and 0 deletions
|
|
@ -98,6 +98,54 @@ rectangles (cairo_t *cr, int width, int height)
|
|||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_test_status_t
|
||||
rhombus (cairo_t *cr, int width, int height)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
|
||||
cairo_paint (cr);
|
||||
|
||||
#if GENERATE_REFERENCE
|
||||
for (y = 0; y < WIDTH; y++) {
|
||||
for (x = 0; x < WIDTH; x++) {
|
||||
cairo_set_source_rgba (cr, 1, 1, 1,
|
||||
x * y / (2. * WIDTH * WIDTH));
|
||||
cairo_rectangle (cr, 2*x, 2*y, 2, 2);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
}
|
||||
#else
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
||||
cairo_set_source_rgb (cr, 1, 1, 1);
|
||||
|
||||
for (y = 0; y < WIDTH; y++) {
|
||||
double yf = y / (double) WIDTH;
|
||||
for (x = 0; x < WIDTH; x++) {
|
||||
double xf = x / (double) WIDTH;
|
||||
|
||||
cairo_move_to (cr,
|
||||
2*x + 1 - xf,
|
||||
2*y + 1);
|
||||
cairo_line_to (cr,
|
||||
2*x + 1,
|
||||
2*y + 1 - yf);
|
||||
cairo_line_to (cr,
|
||||
2*x + 1 + xf,
|
||||
2*y + 1);
|
||||
cairo_line_to (cr,
|
||||
2*x + 1,
|
||||
2*y + 1 + yf);
|
||||
cairo_close_path (cr);
|
||||
}
|
||||
}
|
||||
|
||||
cairo_fill (cr);
|
||||
#endif
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_test_status_t
|
||||
intersecting_quads (cairo_t *cr, int width, int height)
|
||||
{
|
||||
|
|
@ -365,6 +413,13 @@ CAIRO_TEST (coverage_rectangles,
|
|||
WIDTH, HEIGHT,
|
||||
NULL, rectangles)
|
||||
|
||||
CAIRO_TEST (coverage_rhombus,
|
||||
"Check the fidelity of the rasterisation.",
|
||||
NULL, /* keywords */
|
||||
"target=raster slow", /* requirements */
|
||||
2*WIDTH, 2*WIDTH,
|
||||
NULL, rhombus)
|
||||
|
||||
CAIRO_TEST (coverage_intersecting_quads,
|
||||
"Check the fidelity of the rasterisation.",
|
||||
NULL, /* keywords */
|
||||
|
|
|
|||
BIN
test/reference/coverage-rhombus.ref.png
Normal file
BIN
test/reference/coverage-rhombus.ref.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
Loading…
Add table
Reference in a new issue