2009-11-17 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / cairo / test / in-fill-trapezoid.c
blobc44ffb829e92e1b7860733e018ffef8715d388ac
1 /*
2 * Copyright © 2008 Chris Wilson
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
24 * Author: Chris Wilson <chris@chris-wilson.co.uk>
27 #include "cairo-test.h"
29 static cairo_test_draw_function_t draw;
31 static const cairo_test_t test = {
32 "in-fill-trapezoid",
33 "Test _cairo_trap_contains via cairo_in_fill",
34 0, 0,
35 draw
38 static cairo_test_status_t
39 draw (cairo_t *cr, int width, int height)
41 const cairo_test_context_t *ctx = cairo_test_get_context (cr);
42 cairo_test_status_t ret = CAIRO_TEST_SUCCESS;
44 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
46 /* simple rectangle */
47 cairo_new_path (cr);
48 cairo_rectangle (cr, -10, -10, 20, 20);
49 if (! cairo_in_fill (cr, 0, 0)) {
50 cairo_test_log (ctx, "Error: Failed to find point inside rectangle\n");
51 ret = CAIRO_TEST_FAILURE;
54 /* simple circle */
55 cairo_new_path (cr);
56 cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
57 if (! cairo_in_fill (cr, 0, 0)) {
58 cairo_test_log (ctx, "Error: Failed to find point inside circle\n");
59 ret = CAIRO_TEST_FAILURE;
62 /* holey rectangle */
63 cairo_new_path (cr);
64 cairo_rectangle (cr, -10, -10, 20, 20);
65 cairo_rectangle (cr, -5, -5, 10, 10);
66 if (cairo_in_fill (cr, 0, 0)) {
67 cairo_test_log (ctx, "Error: Found an unexpected point inside rectangular hole\n");
68 ret = CAIRO_TEST_FAILURE;
71 /* holey circle */
72 cairo_new_path (cr);
73 cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
74 cairo_arc (cr, 0, 0, 5, 0, 2 * M_PI);
75 if (cairo_in_fill (cr, 0, 0)) {
76 cairo_test_log (ctx, "Error: Found an unexpected point inside circular hole\n");
77 ret = CAIRO_TEST_FAILURE;
80 return ret;
83 int
84 main (void)
86 return cairo_test (&test);