1
/*
2
 * Copyright © 2006 Mozilla Corporation
3
 *
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.
14
 *
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.
22
 *
23
 * Author: Vladimir Vukicevic <vladimir@pobox.com>
24
 */
25

            
26
#include "cairo-test.h"
27

            
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.
33
 *
34
 * According to Vladimir, (https://lists.freedesktop.org/archives/cairo/2006-November/008482.html):
35
 *
36
 *	Before the change, the two trapezoids that were generated were:
37
 *
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)]
44
 *
45
 *	After the change, the L/R coordinates are identical for both traps, but
46
 *	the top and bottom change:
47
 *
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)]
54
 *
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.
59
 */
60

            
61
static cairo_test_status_t
62
3
draw (cairo_t *cr, int width, int height)
63
{
64
3
    cairo_set_source_rgb (cr, 1,1,1);
65
3
    cairo_paint (cr);
66

            
67
3
    cairo_set_source_rgb (cr, 0,0,0);
68

            
69
    /* Note that without the clip, this doesn't crash... */
70
3
    cairo_new_path (cr);
71
3
    cairo_rectangle (cr, 0, 0, width, height);
72
3
    cairo_clip (cr);
73

            
74
3
    cairo_new_path (cr);
75
3
    cairo_line_to (cr, 8.0, 8.0);
76
3
    cairo_line_to (cr, 312.0, 8.0);
77
3
    cairo_line_to (cr, 310.0, 31378756.2666666666);
78
3
    cairo_line_to (cr, 10.0, 31378756.2666666666);
79
3
    cairo_line_to (cr, 8.0, 8.0);
80
3
    cairo_fill (cr);
81

            
82
3
    return CAIRO_TEST_SUCCESS;
83
}
84

            
85
/* XFAIL: range overflow of fixed-point */
86
1
CAIRO_TEST (big_trap,
87
	    "Test oversize trapezoid with a clip region"
88
	    "\nTest needs to be adjusted to trigger the original bug",
89
	    "trap", /* keywords */
90
	    NULL, /* requirements */
91
	    100, 100,
92
	    NULL, draw)