1
/*
2
 * Copyright © 2005 Red Hat, Inc.
3
 * Copyright © 2009 Chris Wilson
4
 *
5
 * Permission to use, copy, modify, distribute, and sell this software
6
 * and its documentation for any purpose is hereby granted without
7
 * fee, provided that the above copyright notice appear in all copies
8
 * and that both that copyright notice and this permission notice
9
 * appear in supporting documentation, and that the name of
10
 * Red Hat, Inc. not be used in advertising or publicity pertaining to
11
 * distribution of the software without specific, written prior
12
 * permission. Red Hat, Inc. makes no representations about the
13
 * suitability of this software for any purpose.  It is provided "as
14
 * is" without express or implied warranty.
15
 *
16
 * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17
 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18
 * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
19
 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20
 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
22
 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23
 *
24
 * Author: Carl D. Worth <cworth@cworth.org>
25
 *         Chris Wilson <chris@chris-wilson.co.uk>
26
 */
27

            
28
#include "cairo-test.h"
29

            
30
#define SIZE 30
31

            
32
/* Another attempt at avoiding unnecessary splines was made, where
33
 * a curve-to that ended on the same point as it began were discarded.
34
 */
35
static cairo_test_status_t
36
3
draw (cairo_t *cr, int width, int height)
37
{
38
3
    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
39
3
    cairo_paint (cr);
40

            
41
3
    cairo_set_line_width (cr, 1.0);
42
3
    cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
43
3
    cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL);
44
3
    cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */
45

            
46
    /* entirely degenerate */
47
3
    cairo_move_to (cr,
48
		    2.5, 2.5);
49
3
    cairo_curve_to (cr,
50
		    2.5, 2.5,
51
		    2.5, 2.5,
52
		    2.5, 2.5);
53
3
    cairo_stroke (cr);
54

            
55
    /* horizontal */
56
3
    cairo_move_to (cr,
57
		     5.5, 2.5);
58
3
    cairo_curve_to (cr,
59
		    22.0, 2.5,
60
		    -0.5, 2.5,
61
		     5.5, 2.5);
62
3
    cairo_stroke (cr);
63

            
64
    /* vertical */
65
3
    cairo_move_to (cr,
66
		    7.5,  0.0);
67
3
    cairo_curve_to (cr,
68
		    7.5, 11.0,
69
		    7.5,  0.0,
70
		    7.5,  0.0);
71
3
    cairo_stroke (cr);
72

            
73
3
    cairo_translate (cr, 15, 0);
74

            
75
    /* horizontal/vertical */
76
3
    cairo_move_to (cr,
77
		     5.5,  0.5);
78
3
    cairo_curve_to (cr,
79
		    -0.5,  0.5,
80
		     5.5, 10.5,
81
		     5.5,  0.5);
82

            
83
3
    cairo_translate (cr, 10, 0);
84

            
85
    /* vertical/horizontal */
86
3
    cairo_move_to (cr,
87
		     5.5,  0.0);
88
3
    cairo_curve_to (cr,
89
		     5.5, 11.0,
90
		    10.5,  0.0,
91
		     5.5,  0.0);
92
3
    cairo_stroke (cr);
93

            
94
3
    return CAIRO_TEST_SUCCESS;
95
}
96

            
97
1
CAIRO_TEST (degenerate_curve_to,
98
	    "Test optimization treating degenerate curve_to as line_to",
99
	    "path", /* keywords */
100
	    NULL, /* requirements */
101
	    40,
102
	    5,
103
	    NULL, draw)