diff --git a/test/Makefile.refs b/test/Makefile.refs index 5a733864c..c435bf6ac 100644 --- a/test/Makefile.refs +++ b/test/Makefile.refs @@ -690,6 +690,10 @@ REFERENCE_IMAGES = \ leaky-polygon.image16.ref.png \ leaky-polygon.ps.ref.png \ leaky-polygon.ref.png \ + line-width-overlap-flipped.ref.png \ + line-width-overlap-flopped.ref.png \ + line-width-overlap-offset.ref.png \ + line-width-overlap-rotated.ref.png \ line-width-overlap.ref.png \ line-width-scale.image16.ref.png \ line-width-scale.ps2.ref.png \ diff --git a/test/line-width-overlap-flipped.ref.png b/test/line-width-overlap-flipped.ref.png new file mode 100644 index 000000000..09911bc51 Binary files /dev/null and b/test/line-width-overlap-flipped.ref.png differ diff --git a/test/line-width-overlap-flopped.ref.png b/test/line-width-overlap-flopped.ref.png new file mode 100644 index 000000000..09911bc51 Binary files /dev/null and b/test/line-width-overlap-flopped.ref.png differ diff --git a/test/line-width-overlap-offset.ref.png b/test/line-width-overlap-offset.ref.png new file mode 100644 index 000000000..eafa50b1f Binary files /dev/null and b/test/line-width-overlap-offset.ref.png differ diff --git a/test/line-width-overlap-rotated.ref.png b/test/line-width-overlap-rotated.ref.png new file mode 100644 index 000000000..cd89a854b Binary files /dev/null and b/test/line-width-overlap-rotated.ref.png differ diff --git a/test/line-width-overlap.c b/test/line-width-overlap.c index cd23d32db..ac8c23479 100644 --- a/test/line-width-overlap.c +++ b/test/line-width-overlap.c @@ -54,9 +54,9 @@ draw (cairo_t *cr, int width, int height) /* rectangle that is smaller than the line width in center of image */ cairo_rectangle (cr, - (SIZE - RECT_SIZE) / 2, (SIZE - RECT_SIZE) / 2, - RECT_SIZE, + (SIZE - RECT_SIZE) / 2, + RECT_SIZE, RECT_SIZE); cairo_stroke (cr); @@ -64,9 +64,86 @@ draw (cairo_t *cr, int width, int height) return CAIRO_TEST_SUCCESS; } +/* and again slightly offset to trigger another path */ +static cairo_test_status_t +draw_offset (cairo_t *cr, int width, int height) +{ + cairo_translate (cr, .5, .5); + return draw (cr, width, height); +} + +static cairo_test_status_t +draw_rotated (cairo_t *cr, int width, int height) +{ + cairo_translate (cr, SIZE/2, SIZE/2); + cairo_rotate (cr, M_PI/4); + cairo_translate (cr, -SIZE/2, -SIZE/2); + + return draw (cr, width, height); +} + +static cairo_test_status_t +draw_flipped (cairo_t *cr, int width, int height) +{ + cairo_translate (cr, SIZE/2, SIZE/2); + cairo_scale (cr, -1, 1); + cairo_translate (cr, -SIZE/2, -SIZE/2); + + return draw (cr, width, height); +} + +static cairo_test_status_t +draw_flopped (cairo_t *cr, int width, int height) +{ + cairo_translate (cr, SIZE/2, SIZE/2); + cairo_scale (cr, 1, -1); + cairo_translate (cr, -SIZE/2, -SIZE/2); + + return draw (cr, width, height); +} + +static cairo_test_status_t +draw_dashed (cairo_t *cr, int width, int height) +{ + const double dashes[] = { 4 }; + cairo_set_dash (cr, dashes, 1, 0); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT); + return draw (cr, width, height); +} + CAIRO_TEST (line_width_overlap, "Test overlapping lines due to large line width", "stroke", /* keywords */ NULL, /* requirements */ SIZE, SIZE, NULL, draw) +CAIRO_TEST (line_width_overlap_offset, + "Test overlapping lines due to large line width", + "stroke", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw_offset) +CAIRO_TEST (line_width_overlap_rotated, + "Test overlapping lines due to large line width", + "stroke", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw_rotated) +CAIRO_TEST (line_width_overlap_flipped, + "Test overlapping lines due to large line width", + "stroke", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw_flipped) +CAIRO_TEST (line_width_overlap_flopped, + "Test overlapping lines due to large line width", + "stroke", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw_flopped) +CAIRO_TEST (line_width_overlap_dashed, + "Test overlapping lines due to large line width", + "stroke", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw_dashed)