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"
29 static cairo_test_draw_function_t draw
;
33 #define WIDTH (PAD + 3 * (PAD + SIZE) + PAD)
34 #define HEIGHT (PAD + SIZE + PAD)
36 /* We're demonstrating here a bug originally reported by Benjamin Otte
37 * on the cairo mailing list here, (after he ran into this problem
38 * with various flash animations):
40 * [cairo] Assertion `i < pen->num_vertices' failed in 1.4.10
41 * http://lists.cairographics.org/archives/cairo/2007-August/011282.html
43 * The problem shows up with an extreme transformation matrix that
44 * collapses the pen to a single line, (which means that
45 * _cairo_slope_compare cannot handle adjacent vertices in the pen
46 * since they have parallel slope).
48 * This test case tests degenerate pens in several directions and uses
49 * round caps to force the stroking code to attempt to walk around the
50 * pen doing slope comparisons.
53 static const cairo_test_t test
= {
55 "Test round joins with a pen that's transformed to a line",
60 static cairo_test_status_t
61 draw (cairo_t
*cr
, int width
, int height
)
63 cairo_set_source_rgb (cr
, 1, 1, 1);
66 cairo_set_source_rgb (cr
, 0, 0, 0);
67 cairo_set_line_join (cr
, CAIRO_LINE_JOIN_ROUND
);
69 cairo_translate (cr
, PAD
, PAD
);
71 /* First compress the pen to a vertical line. */
72 cairo_rectangle (cr
, 0, 0, SIZE
, SIZE
);
73 cairo_curve_to (cr
, SIZE
/ 2, 0, SIZE
, SIZE
/ 2, SIZE
, SIZE
);
76 cairo_scale (cr
, 0.000001, 1.0);
81 cairo_translate (cr
, PAD
+ SIZE
, 0);
83 /* Then compress the pen to a horizontal line. */
84 cairo_rectangle (cr
, 0, 0, SIZE
, SIZE
);
85 cairo_curve_to (cr
, SIZE
/ 2, 0, SIZE
, SIZE
/ 2, SIZE
, SIZE
);
88 cairo_scale (cr
, 1.0, 0.000001);
93 cairo_translate (cr
, PAD
+ SIZE
, 0);
95 /* Finally a line at an angle. */
96 cairo_rectangle (cr
, 0, 0, SIZE
, SIZE
);
97 cairo_curve_to (cr
, SIZE
/ 2, 0, SIZE
, SIZE
/ 2, SIZE
, SIZE
);
100 cairo_rotate (cr
, M_PI
/ 4.0);
101 cairo_scale (cr
, 0.000001, 1.0);
106 return CAIRO_TEST_SUCCESS
;
112 return cairo_test (&test
);