1
/*
2
 * Copyright © 2005 Red Hat, Inc.
3
 * Copyright © 2006 Red Hat, Inc.
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
 */
26

            
27
#include "cairo-test.h"
28

            
29
#define LINE_WIDTH	10.
30
#define SIZE		(5 * LINE_WIDTH)
31
#define PAD		(2 * LINE_WIDTH)
32

            
33
static void
34
9
make_path (cairo_t *cr)
35
{
36
9
    cairo_move_to (cr, 0., 0.);
37
9
    cairo_rel_line_to (cr, 0., SIZE);
38
9
    cairo_rel_line_to (cr, SIZE, 0.);
39
9
    cairo_close_path (cr);
40

            
41
9
    cairo_move_to (cr, 2 * LINE_WIDTH, 0.);
42
9
    cairo_rel_line_to (cr, 3 * LINE_WIDTH, 0.);
43
9
    cairo_rel_line_to (cr, 0., 3 * LINE_WIDTH);
44
9
}
45

            
46
static cairo_test_status_t
47
3
draw (cairo_t *cr, int width, int height)
48
{
49
    /* First draw a checkered background */
50
3
    cairo_test_paint_checkered (cr);
51

            
52
    /* Then draw the original caps-joins test but with a bit of alphs thrown in. */
53
3
    cairo_set_line_width (cr, LINE_WIDTH);
54

            
55
3
    cairo_set_source_rgba (cr, 1.0, 0.0, 0.0, 0.5); /* 50% red */
56
3
    cairo_translate (cr, PAD, PAD);
57

            
58
3
    make_path (cr);
59
3
    cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
60
3
    cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL);
61
3
    cairo_stroke (cr);
62

            
63
3
    cairo_set_source_rgba (cr, 0.0, 1.0, 0.0, 0.5); /* 50% green */
64
3
    cairo_translate (cr, SIZE + PAD, 0.);
65

            
66
3
    make_path (cr);
67
3
    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
68
3
    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
69
3
    cairo_stroke (cr);
70

            
71
3
    cairo_set_source_rgba (cr, 0.0, 0.0, 1.0, 0.5); /* 50% blue */
72

            
73
3
    cairo_translate (cr, SIZE + PAD, 0.);
74

            
75
3
    make_path (cr);
76
3
    cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
77
3
    cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
78
3
    cairo_stroke (cr);
79

            
80
3
    return CAIRO_TEST_SUCCESS;
81
}
82

            
83
1
CAIRO_TEST (caps_joins_alpha,
84
	    "Test caps and joins with some source alpha",
85
	    "stroke", /* keywords */
86
	    NULL, /* requirements */
87
	    3 * (PAD + SIZE) + PAD,
88
	    PAD + SIZE + PAD,
89
	    NULL, draw)