2 * Copyright © 2010 Mozilla Corporation
\r
3 * Copyright © 2010 Intel Corporation
\r
5 * Permission is hereby granted, free of charge, to any person
\r
6 * obtaining a copy of this software and associated documentation
\r
7 * files (the "Software"), to deal in the Software without
\r
8 * restriction, including without limitation the rights to use, copy,
\r
9 * modify, merge, publish, distribute, sublicense, and/or sell copies
\r
10 * of the Software, and to permit persons to whom the Software is
\r
11 * furnished to do so, subject to the following conditions:
\r
13 * The above copyright notice and this permission notice shall be
\r
14 * included in all copies or substantial portions of the Software.
\r
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
25 * Author: Chris Wilson <chris@chris-wilson.co.uk>
\r
28 #include "cairo-test.h"
\r
30 static cairo_test_status_t
\r
31 draw (cairo_t *cr, int width, int height)
\r
33 cairo_surface_t *mask;
\r
36 cairo_set_source_rgb (cr, 0, 1, 0);
\r
39 /* clip twice, note that the intersection is smaller then the extents */
\r
40 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
\r
41 cairo_rectangle (cr, 10, 10, 80, 80);
\r
42 cairo_rectangle (cr, 20, 20, 60, 60);
\r
45 cairo_rectangle (cr, 0, 40, 40, 30);
\r
48 /* and exercise the bug found by Jeff Muizelaar */
\r
49 mask = cairo_surface_create_similar (cairo_get_target (cr),
\r
50 CAIRO_CONTENT_ALPHA,
\r
51 width-20, height-20);
\r
52 cr2 = cairo_create (mask);
\r
53 cairo_surface_destroy (mask);
\r
55 cairo_set_source_rgba (cr2, 1, 1, 1, 1);
\r
58 cairo_set_source_rgb (cr, 1, 0, 0);
\r
59 cairo_mask_surface (cr, cairo_get_target (cr2), 0, 0);
\r
60 cairo_destroy (cr2);
\r
62 return CAIRO_TEST_SUCCESS;
\r
65 CAIRO_TEST (clip_twice_rectangle,
\r
66 "Tests clipping twice using rectangles",
\r
67 "clip", /* keywords */
\r
68 NULL, /* requirements */
\r