Viewport clipping now works with both GL and Gallium.
[cairo/gpu.git] / test / big-trap.c
blob38f2adbff26c3da3778d7e4fd6041cf9cf7a69fa
1 /*
2 * Copyright © 2006 Mozilla Corporation
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Mozilla Corporation not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior
11 * permission. Mozilla Corporation makes no representations about the
12 * suitability of this software for any purpose. It is provided "as
13 * is" without express or implied warranty.
15 * MOZILLA CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
16 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS, IN NO EVENT SHALL MOZILLA CORPORATION BE LIABLE FOR ANY SPECIAL,
18 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
21 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: Vladimir Vukicevic <vladimir@pobox.com>
26 #include "cairo-test.h"
28 /* This test was originally written to exercise a bug in pixman in
29 * which it would scribble all over memory when given a particular
30 * (and bogus) trapezoid. However, a recent change to
31 * _cairo_fixed_from_double changed the details of the bogus trapezoid
32 * (it overflows in a different way now), so the bug is being masked.
34 * According to Vladimir, (http://lists.freedesktop.org/archives/cairo/2006-November/008482.html):
36 * Before the change, the two trapezoids that were generated were:
38 * Trap[0]: T: 0x80000000 B: 0x80000003
39 * L: [(0x000a0000, 0x80000000) (0x00080000, 0x00080000)]
40 * R: [(0x01360000, 0x80000000) (0x01380000, 0x00080000)]
41 * Trap[1]: T: 0x80000003 B: 0x00080000
42 * L: [(0x000a0000, 0x80000000) (0x00080000, 0x00080000)]
43 * R: [(0x01360000, 0x80000000) (0x01380000, 0x00080000)]
45 * After the change, the L/R coordinates are identical for both traps, but
46 * the top and bottom change:
48 * Trap[0]: t: 0x80000000 b: 0xfda80003
49 * l: [(0x000a0000, 0x80000000) (0x00080000, 0x00080000)]
50 * r: [(0x01360000, 0x80000000) (0x01380000, 0x00080000)]
51 * Trap[1]: t: 0xfda80003 b: 0x00080000
52 * l: [(0x000a0000, 0x80000000) (0x00080000, 0x00080000)]
53 * r: [(0x01360000, 0x80000000) (0x01380000, 0x00080000)]
55 * I think the fix we want here is to rewrite this test to call
56 * directly into pixman with the trapezoid of interest, (which will
57 * require adding a new way to configure cairo for "testing" which
58 * will prevent the hiding of internal library symbols.
61 static cairo_test_status_t
62 draw (cairo_t *cr, int width, int height)
64 /* Note that without the clip, this doesn't crash... */
65 cairo_new_path (cr);
66 cairo_rectangle (cr, 0, 0, width, height);
67 cairo_clip (cr);
69 cairo_new_path (cr);
70 cairo_line_to (cr, 8.0, 8.0);
71 cairo_line_to (cr, 312.0, 8.0);
72 cairo_line_to (cr, 310.0, 31378756.2666666666);
73 cairo_line_to (cr, 10.0, 31378756.2666666666);
74 cairo_line_to (cr, 8.0, 8.0);
75 cairo_fill (cr);
77 return CAIRO_TEST_SUCCESS;
80 CAIRO_TEST (big_trap,
81 "Test oversize trapezoid with a clip region"
82 "\nTest needs to be adjusted to trigger the original bug",
83 "XFAIL trap", /* keywords */
84 NULL, /* requirements */
85 100, 100,
86 NULL, draw)