2 * Copyright © 2007 Adrian Johnson
3 * Copyright © 2009 Chris Wilson
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use, copy,
9 * modify, merge, publish, distribute, sublicense, and/or sell copies
10 * of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Author: Adrian Johnson <ajohnson@redneon.com>
26 * Chris Wilson <chris@chris-wilson.co.uk>
29 #include "cairo-test.h"
32 #define PAT_HEIGHT 120
33 #define SIZE (PAT_WIDTH*2)
35 #define WIDTH (PAD + SIZE + PAD)
38 static cairo_test_status_t
39 draw (cairo_t *cr, int width, int height)
43 /* make the output opaque */
44 cairo_set_source_rgb (cr, 0, 0, 0);
47 cairo_translate (cr, PAD, PAD);
49 cairo_matrix_init_scale (&m, 2, 1.5);
50 cairo_matrix_rotate (&m, 1);
51 cairo_matrix_translate (&m, -PAT_WIDTH/4.0, -PAT_WIDTH/2.0);
52 cairo_matrix_invert (&m);
53 cairo_set_matrix (cr, &m);
55 cairo_rectangle (cr, 0, 0, PAT_WIDTH, PAT_HEIGHT);
58 cairo_set_source_rgba (cr, 1, 0, 1, 0.5);
59 cairo_rectangle (cr, PAT_WIDTH/6.0, PAT_HEIGHT/6.0, PAT_WIDTH/4.0, PAT_HEIGHT/4.0);
62 cairo_set_source_rgba (cr, 0, 1, 1, 0.5);
63 cairo_rectangle (cr, PAT_WIDTH/2.0, PAT_HEIGHT/2.0, PAT_WIDTH/4.0, PAT_HEIGHT/4.0);
66 cairo_set_line_width (cr, 1);
67 cairo_move_to (cr, PAT_WIDTH/6.0, 0);
68 cairo_line_to (cr, 0, 0);
69 cairo_line_to (cr, 0, PAT_HEIGHT/6.0);
70 cairo_set_source_rgb (cr, 1, 0, 0);
73 cairo_move_to (cr, PAT_WIDTH/6.0, PAT_HEIGHT);
74 cairo_line_to (cr, 0, PAT_HEIGHT);
75 cairo_line_to (cr, 0, 5*PAT_HEIGHT/6.0);
76 cairo_set_source_rgb (cr, 0, 1, 0);
79 cairo_move_to (cr, 5*PAT_WIDTH/6.0, 0);
80 cairo_line_to (cr, PAT_WIDTH, 0);
81 cairo_line_to (cr, PAT_WIDTH, PAT_HEIGHT/6.0);
82 cairo_set_source_rgb (cr, 0, 0, 1);
85 cairo_move_to (cr, 5*PAT_WIDTH/6.0, PAT_HEIGHT);
86 cairo_line_to (cr, PAT_WIDTH, PAT_HEIGHT);
87 cairo_line_to (cr, PAT_WIDTH, 5*PAT_HEIGHT/6.0);
88 cairo_set_source_rgb (cr, 1, 1, 0);
91 cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
92 cairo_set_line_width (cr, PAT_WIDTH/10.0);
94 cairo_move_to (cr, 0, PAT_HEIGHT/4.0);
95 cairo_line_to (cr, PAT_WIDTH, PAT_HEIGHT/4.0);
98 cairo_move_to (cr, PAT_WIDTH/4.0, 0);
99 cairo_line_to (cr, PAT_WIDTH/4.0, PAT_WIDTH);
102 return CAIRO_TEST_SUCCESS;
105 CAIRO_TEST (rotated_clip,
106 "Test clipping with non identity pattern matrix",
107 "clip", /* keywords */
108 NULL, /* requirements */