2 * Copyright © 2007 Red Hat, Inc.
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * Author: Carl D. Worth <cworth@cworth.org>
27 #include "cairo-test.h"
31 #define WIDTH (PAD + 3 * (PAD + SIZE) + PAD)
32 #define HEIGHT (PAD + SIZE + PAD)
34 /* We're demonstrating here a bug originally reported by Benjamin Otte
35 * on the cairo mailing list here, (after he ran into this problem
36 * with various flash animations):
38 * [cairo] Assertion `i < pen->num_vertices' failed in 1.4.10
39 * http://lists.cairographics.org/archives/cairo/2007-August/011282.html
41 * The problem shows up with an extreme transformation matrix that
42 * collapses the pen to a single line, (which means that
43 * _cairo_slope_compare cannot handle adjacent vertices in the pen
44 * since they have parallel slope).
46 * This test case tests degenerate pens in several directions and uses
47 * round caps to force the stroking code to attempt to walk around the
48 * pen doing slope comparisons.
51 static cairo_test_status_t
52 draw (cairo_t *cr, int width, int height)
54 cairo_set_source_rgb (cr, 1, 1, 1);
57 cairo_set_source_rgb (cr, 0, 0, 0);
58 cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
60 cairo_translate (cr, PAD, PAD);
62 /* First compress the pen to a vertical line. */
63 cairo_rectangle (cr, 0, 0, SIZE, SIZE);
64 cairo_curve_to (cr, SIZE / 2, 0, SIZE, SIZE / 2, SIZE, SIZE);
67 cairo_scale (cr, 0.000001, 1.0);
72 cairo_translate (cr, PAD + SIZE, 0);
74 /* Then compress the pen to a horizontal line. */
75 cairo_rectangle (cr, 0, 0, SIZE, SIZE);
76 cairo_curve_to (cr, SIZE / 2, 0, SIZE, SIZE / 2, SIZE, SIZE);
79 cairo_scale (cr, 1.0, 0.000001);
84 cairo_translate (cr, PAD + SIZE, 0);
86 /* Finally a line at an angle. */
87 cairo_rectangle (cr, 0, 0, SIZE, SIZE);
88 cairo_curve_to (cr, SIZE / 2, 0, SIZE, SIZE / 2, SIZE, SIZE);
91 cairo_rotate (cr, M_PI / 4.0);
92 cairo_scale (cr, 0.000001, 1.0);
97 return CAIRO_TEST_SUCCESS;
100 CAIRO_TEST (degenerate_pen,
101 "Test round joins with a pen that's transformed to a line",
102 "degenerate", /* keywords */
103 NULL, /* requirements */