1
/*
2
 * Permission is hereby granted, free of charge, to any person
3
 * obtaining a copy of this software and associated documentation
4
 * files (the "Software"), to deal in the Software without
5
 * restriction, including without limitation the rights to use, copy,
6
 * modify, merge, publish, distribute, sublicense, and/or sell copies
7
 * of the Software, and to permit persons to whom the Software is
8
 * furnished to do so, subject to the following conditions:
9
 *
10
 * The above copyright notice and this permission notice shall be
11
 * included in all copies or substantial portions of the Software.
12
 *
13
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
17
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
 * SOFTWARE.
21
 */
22

            
23
#include "cairo-test.h"
24

            
25
#include "tiger.inc"
26

            
27
static cairo_test_status_t
28
6
draw (cairo_t *cr, int width, int height)
29
{
30
	unsigned int i;
31

            
32
6
	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
33
6
	cairo_set_source_rgba (cr, 0.1, 0.2, 0.3, 1.0);
34
6
	cairo_paint (cr);
35
6
	cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
36

            
37
6
	cairo_translate (cr, width/2, height/2);
38
6
	cairo_scale (cr, .85, .85);
39

            
40
13866
	for (i = 0; i < ARRAY_LENGTH(tiger_commands); i++) {
41
13860
		const struct command *cmd = &tiger_commands[i];
42
13860
		switch (cmd->type) {
43
1494
		case 'm':
44
1494
			cairo_move_to (cr, cmd->x0, cmd->y0);
45
1494
			break;
46
606
		case 'l':
47
606
			cairo_line_to (cr, cmd->x0, cmd->y0);
48
606
			break;
49
10260
		case 'c':
50
10260
			cairo_curve_to (cr,
51
10260
					cmd->x0, cmd->y0,
52
10260
					cmd->x1, cmd->y1,
53
10260
					cmd->x2, cmd->y2);
54
10260
			break;
55
1500
		case 'f':
56
1500
			cairo_set_source_rgba (cr,
57
1500
					       cmd->x0, cmd->y0, cmd->x1, cmd->y1);
58
1500
			cairo_fill (cr);
59
1500
			break;
60
		}
61
	}
62

            
63
6
	return CAIRO_TEST_SUCCESS;
64
}
65

            
66
static cairo_test_status_t
67
3
a1_draw (cairo_t *cr, int width, int height)
68
{
69
3
    cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
70
3
    return draw (cr, width, height);
71
}
72

            
73
1
CAIRO_TEST (tiger,
74
	    "Check the fidelity of the rasterisation.",
75
	    "raster", /* keywords */
76
	    NULL, /* requirements */
77
	    500, 500,
78
	    NULL, draw)
79

            
80
1
CAIRO_TEST (a1_tiger,
81
	    "Check the fidelity of the rasterisation.",
82
	    "fill", /* keywords */
83
	    "target=raster", /* requirements */
84
	    500, 500,
85
	    NULL, a1_draw)