2 * Copyright 2010 Soeren Sandmann Pedersen
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
24 * Author: Soeren Sandmann <sandmann@daimi.au.dk>
27 /* Exercises a case of seam appearing between two polygons in the image
28 * backend but not in xlib [using pixman].
30 * The test case draws two abutting quads both individually on the
31 * leftm combining them with operator ADD, and in one go on the right.
32 * Both methods should show no signs of seaming at the common edge
33 * between the two quads, but the individually drawn ones have a
36 * The cause of the seam is that there are slight differences in the
37 * output of the analytical coverage rasterization and the
38 * supersampling rasterization methods, both employed by
39 * cairo-tor-scan-converter. When drawn individually, the scan
40 * converter gets a partial view of the geometry at a time, so it ends
41 * up making different decisions about which scanlines it rasterizes
42 * with which method, compared to when the geometry is draw all at
43 * once. Though both methods produce seamless results individually
44 * (where applicable), they don't produce bit-exact identical results,
45 * and hence we get seaming where they meet.
48 #include "cairo-test.h"
51 draw_quad (cairo_t *cr,
52 double x1, double y1, double x2, double y2,
53 double x3, double y3, double x4, double y4)
55 cairo_move_to (cr, x1, y1);
56 cairo_line_to (cr, x2, y2);
57 cairo_line_to (cr, x3, y3);
58 cairo_line_to (cr, x4, y4);
59 cairo_close_path (cr);
62 static cairo_test_status_t
63 draw (cairo_t *cr, int width, int height)
65 cairo_set_source_rgb (cr, 0, 0, 0);
68 cairo_scale (cr, 20, 20);
69 cairo_translate (cr, 5, 1);
71 /* On the left side, we have two quads drawn one at a time and
72 * combined with OPERATOR_ADD. This should be seamless, but
74 cairo_push_group (cr);
75 cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
77 cairo_set_source_rgb (cr, 0, 0.6, 0);
91 cairo_pop_group_to_source (cr);
92 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
95 /* On the right side, we have the same two quads drawn both at the
96 * same time. This is seamless. */
97 cairo_translate (cr, 10, 0);
99 cairo_set_source_rgb (cr, 0, 0.6, 0);
112 return CAIRO_TEST_SUCCESS;
115 CAIRO_TEST (bug_seams,
116 "Check the fidelity of the rasterisation.",
117 "raster", /* keywords */
118 "target=raster", /* requirements */