1
/*
2
 * Permission is hereby granted, free of charge, to any person
3
 * obtaining a copy of this software and associated documentation
4
 * files (the "Software"), to deal in the Software without
5
 * restriction, including without limitation the rights to use, copy,
6
 * modify, merge, publish, distribute, sublicense, and/or sell copies
7
 * of the Software, and to permit persons to whom the Software is
8
 * furnished to do so, subject to the following conditions:
9
 *
10
 * The above copyright notice and this permission notice shall be
11
 * included in all copies or substantial portions of the Software.
12
 *
13
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
17
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
 * SOFTWARE.
21
 */
22

            
23
#include "cairo-test.h"
24

            
25
static cairo_pattern_t *
26
3
create_pattern (cairo_surface_t *target)
27
{
28
    cairo_surface_t *surface;
29
    cairo_pattern_t *pattern;
30
    cairo_t *cr;
31
    cairo_matrix_t m;
32

            
33
3
    surface = cairo_surface_create_similar(target,
34
					   cairo_surface_get_content (target),
35
					   1000, 600);
36
3
    cr = cairo_create (surface);
37
3
    cairo_surface_destroy (surface);
38

            
39
3
    cairo_set_source_rgb (cr, 0, 1, 0);
40
3
    cairo_paint(cr);
41

            
42
3
    pattern = cairo_pattern_create_for_surface (cairo_get_target (cr));
43
3
    cairo_destroy(cr);
44

            
45
3
    cairo_matrix_init_translate (&m, 0, 0.1); // y offset must be non-integer
46
3
    cairo_pattern_set_matrix (pattern, &m);
47
3
    return pattern;
48
}
49

            
50
static cairo_test_status_t
51
3
draw (cairo_t *cr, int width, int height)
52
{
53
    cairo_pattern_t *pattern;
54

            
55
3
    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
56

            
57
3
    cairo_set_source_rgb (cr, 1, 0, 0);
58
3
    cairo_paint (cr);
59

            
60
3
    cairo_new_path (cr);
61
3
    cairo_move_to (cr, 10, 400.1);
62
3
    cairo_line_to (cr, 990, 400.1);
63
3
    cairo_line_to (cr, 990, 600);
64
3
    cairo_line_to (cr, 10,  600);
65
3
    cairo_close_path (cr);
66

            
67
3
    pattern = create_pattern (cairo_get_target (cr));
68
3
    cairo_set_source (cr, pattern);
69
3
    cairo_pattern_destroy (pattern);
70

            
71
3
    cairo_fill(cr);
72

            
73
3
    return CAIRO_TEST_SUCCESS;
74
}
75

            
76
1
CAIRO_TEST (bug_source_cu,
77
	    "Exercises a bug discovered in the tracking of unbounded source extents",
78
	    "fill", /* keywords */
79
	    NULL, /* requirements */
80
	    1000, 600,
81
	    NULL, draw)