mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 21:38:03 +02:00
[test] Exercise degenerate dashes.
Add a test case to capture the current behaviour when a segment ends on an off/on dash transition. Originally filed as bug: Miter artifacts for dashed strokes https://bugs.freedesktop.org/show_bug.cgi?id=17973
This commit is contained in:
parent
6487a147a2
commit
96b083d3f0
4 changed files with 100 additions and 0 deletions
1
test/.gitignore
vendored
1
test/.gitignore
vendored
|
|
@ -52,6 +52,7 @@ dash-scale
|
|||
dash-state
|
||||
dash-zero-length
|
||||
degenerate-arc
|
||||
degenerate-dash
|
||||
degenerate-path
|
||||
degenerate-pen
|
||||
device-offset
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ dash-scale$(EXEEXT) \
|
|||
dash-state$(EXEEXT) \
|
||||
dash-zero-length$(EXEEXT) \
|
||||
degenerate-arc$(EXEEXT) \
|
||||
degenerate-dash$(EXEEXT) \
|
||||
degenerate-path$(EXEEXT) \
|
||||
degenerate-pen$(EXEEXT) \
|
||||
device-offset$(EXEEXT) \
|
||||
|
|
@ -395,6 +396,7 @@ REFERENCE_IMAGES = \
|
|||
degenerate-arc-ref.png \
|
||||
degenerate-arc-ps2-ref.png \
|
||||
degenerate-arc-ps3-ref.png \
|
||||
degenerate-dash-ref.png \
|
||||
degenerate-pen-ref.png \
|
||||
degenerate-pen-ps2-ref.png \
|
||||
degenerate-pen-ps3-ref.png \
|
||||
|
|
|
|||
BIN
test/degenerate-dash-ref.png
Normal file
BIN
test/degenerate-dash-ref.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2 KiB |
97
test/degenerate-dash.c
Normal file
97
test/degenerate-dash.c
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* Copyright © 2008 Chris Wilson
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the name of
|
||||
* Chris Wilson not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior
|
||||
* permission. Chris Wilson makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*
|
||||
* Based on an original test case by M Joonas Pihlaja.
|
||||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
#ifndef ARRAY_LENGTH
|
||||
#define ARRAY_LENGTH(A) (int) (sizeof (A) / sizeof ((A)[0]))
|
||||
#endif
|
||||
|
||||
#define PAD 5
|
||||
|
||||
static cairo_test_draw_function_t draw;
|
||||
|
||||
static const cairo_test_t test = {
|
||||
"degenerate-dash",
|
||||
"Tests the behaviour of dashed segments that end on a off-on transition",
|
||||
210 + 2*PAD, 210 + 2*PAD,
|
||||
draw
|
||||
};
|
||||
|
||||
static cairo_test_status_t
|
||||
draw (cairo_t *cr, int width, int height)
|
||||
{
|
||||
const double dashes[] = { 25, 25 };
|
||||
cairo_line_join_t joins[] = {
|
||||
CAIRO_LINE_JOIN_ROUND,
|
||||
CAIRO_LINE_JOIN_MITER,
|
||||
CAIRO_LINE_JOIN_BEVEL
|
||||
};
|
||||
cairo_line_cap_t caps[] = {
|
||||
CAIRO_LINE_CAP_ROUND,
|
||||
CAIRO_LINE_CAP_SQUARE,
|
||||
CAIRO_LINE_CAP_BUTT,
|
||||
};
|
||||
int i, j;
|
||||
|
||||
cairo_set_source_rgb (cr, 1,1,1);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_set_source_rgb (cr, 1, 0, 0);
|
||||
|
||||
cairo_set_dash (cr, dashes, 2, 0.);
|
||||
cairo_set_line_width (cr, 10);
|
||||
|
||||
cairo_translate (cr, 5 + PAD, 5 + PAD);
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH (joins); i++) {
|
||||
cairo_set_line_join (cr, joins[i]);
|
||||
cairo_save (cr);
|
||||
|
||||
for (j = 0; j < ARRAY_LENGTH (caps); j++) {
|
||||
cairo_set_line_cap (cr, caps[j]);
|
||||
|
||||
cairo_move_to (cr, 0, 0);
|
||||
cairo_line_to (cr, 50, 0);
|
||||
cairo_line_to (cr, 50,50);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_translate (cr, 75, 0);
|
||||
}
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_translate (cr, 0, 75);
|
||||
}
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
return cairo_test (&test);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue