Tizen 2.0 Release
[framework/graphics/cairo.git] / test / bug-source-cu.c
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 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     surface = cairo_surface_create_similar(target,
34                                            cairo_surface_get_content (target),
35                                            1000, 600);
36     cr = cairo_create (surface);
37     cairo_surface_destroy (surface);
38
39     cairo_set_source_rgb (cr, 0, 1, 0);
40     cairo_paint(cr);
41
42     pattern = cairo_pattern_create_for_surface (cairo_get_target (cr));
43     cairo_destroy(cr);
44
45     cairo_matrix_init_translate (&m, 0, 0.1); // y offset must be non-integer
46     cairo_pattern_set_matrix (pattern, &m);
47     return pattern;
48 }
49
50 static cairo_test_status_t
51 draw (cairo_t *cr, int width, int height)
52 {
53     cairo_pattern_t *pattern;
54
55     cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
56
57     cairo_set_source_rgb (cr, 1, 0, 0);
58     cairo_paint (cr);
59
60     cairo_new_path (cr);
61     cairo_move_to (cr, 10, 400.1);
62     cairo_line_to (cr, 990, 400.1);
63     cairo_line_to (cr, 990, 600);
64     cairo_line_to (cr, 10,  600);
65     cairo_close_path (cr);
66
67     pattern = create_pattern (cairo_get_target (cr));
68     cairo_set_source (cr, pattern);
69     cairo_pattern_destroy (pattern);
70
71     cairo_fill(cr);
72
73     return CAIRO_TEST_SUCCESS;
74 }
75
76 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)