Upload Tizen2.0 source
[framework/graphics/cairo.git] / test / tiger.c
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 draw (cairo_t *cr, int width, int height)
29 {
30         unsigned int i;
31
32         cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
33         cairo_set_source_rgba (cr, 0.1, 0.2, 0.3, 1.0);
34         cairo_paint (cr);
35         cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
36
37         cairo_translate (cr, width/2, height/2);
38         cairo_scale (cr, .85, .85);
39
40         for (i = 0; i < sizeof (tiger_commands)/sizeof(tiger_commands[0]);i++) {
41                 const struct command *cmd = &tiger_commands[i];
42                 switch (cmd->type) {
43                 case 'm':
44                         cairo_move_to (cr, cmd->x0, cmd->y0);
45                         break;
46                 case 'l':
47                         cairo_line_to (cr, cmd->x0, cmd->y0);
48                         break;
49                 case 'c':
50                         cairo_curve_to (cr,
51                                         cmd->x0, cmd->y0,
52                                         cmd->x1, cmd->y1,
53                                         cmd->x2, cmd->y2);
54                         break;
55                 case 'f':
56                         cairo_set_source_rgba (cr,
57                                                cmd->x0, cmd->y0, cmd->x1, cmd->y1);
58                         cairo_fill (cr);
59                         break;
60                 }
61         }
62
63         return CAIRO_TEST_SUCCESS;
64 }
65
66 static cairo_test_status_t
67 a1_draw (cairo_t *cr, int width, int height)
68 {
69     cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
70     return draw (cr, width, height);
71 }
72
73 CAIRO_TEST (tiger,
74             "Check the fidelity of the rasterisation.",
75             "raster", /* keywords */
76             NULL, /* requirements */
77             500, 500,
78             NULL, draw)
79
80 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)