a573f56a5be28de499f5fc3ece28c63eb55bff31
[framework/graphics/cairo.git] / test / infinite-join.c
1 /*
2  * Copyright © 2006 Red Hat, Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software
5  * and its documentation for any purpose is hereby granted without
6  * fee, provided that the above copyright notice appear in all copies
7  * and that both that copyright notice and this permission notice
8  * appear in supporting documentation, and that the name of the
9  * copyright holders not be used in advertising or publicity
10  * pertaining to distribution of the software without specific,
11  * written prior permission. The copyright holders make no
12  * representations about the suitability of this software for any
13  * purpose.  It is provided "as is" without express or implied
14  * warranty.
15  *
16  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18  * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
21  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
22  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
23  * SOFTWARE.
24  *
25  * Author: Carl D. Worth <cworth@cworth.org>
26  */
27
28 /* Test case for bug #8379:
29  *
30  *      infinite loop when stroking
31  *      https://bugs.freedesktop.org/show_bug.cgi?id=8379
32  */
33
34 #include "cairo-test.h"
35
36 static cairo_test_status_t
37 draw (cairo_t *cr, int width, int height)
38 {
39     /* Paint white, then draw in black. */
40     cairo_set_source_rgb (cr, 1, 1, 1); /* white */
41     cairo_paint (cr);
42     cairo_set_source_rgb (cr, 0, 0, 0); /* black */
43
44     cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
45
46     /* scaling 2 times causes a slight rounding error in the ctm.
47      * Without that, the bug doesn't happen. */
48     cairo_scale (cr, 20 / 100., 20 / 100.);
49     cairo_scale (cr, 1. / 20, 1. / 20);
50
51     cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
52     cairo_set_line_width (cr, 20);
53
54     cairo_translate (cr, -18300, -13200);
55
56     cairo_new_path (cr);
57     cairo_move_to (cr, 18928, 13843);
58     cairo_line_to (cr, 18500, 13843);
59     cairo_line_to (cr, 18500, 13400);
60     cairo_line_to (cr, 18928, 13400);
61     cairo_line_to (cr, 18928, 13843);
62     cairo_stroke (cr);
63
64     return CAIRO_TEST_SUCCESS;
65 }
66
67 CAIRO_TEST (infinite_join,
68             "Test case for infinite loop when stroking with round joins",
69             "stroke", /* keywords */
70             NULL,
71             8, 8,
72             NULL, draw)