1 /* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
3 * Copyright 2010 Andrea Canciani
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use, copy,
9 * modify, merge, publish, distribute, sublicense, and/or sell copies
10 * of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Author: Andrea Canciani <ranma42@gmail.com>
28 #include "cairo-test.h"
32 #define DISTANCE 10.25
35 This test checks that boxes not aligned to pixels are drawn
38 In particular the corners of the boxes are drawn incorrectly by
39 cairo-image in cairo 1.10.0, because overlapping boxes are passed to
40 a span converter which assumes disjoint boxes as input.
42 This results in corners to be drawn with the wrong shade.
45 static cairo_test_status_t
46 draw (cairo_t *cr, int width, int height)
50 cairo_set_source_rgb (cr, 1, 1, 1);
53 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
54 cairo_set_source_rgb (cr, 0, 0, 0);
55 cairo_set_line_width (cr, 4);
56 cairo_translate (cr, 2*OFFSET, 2*OFFSET);
58 for (i = 0; i < 4; i++) {
59 double x = i * DISTANCE;
61 cairo_move_to (cr, x, -OFFSET-0.75);
62 cairo_line_to (cr, x, SIZE-3*OFFSET-0.25);
64 cairo_move_to (cr, -OFFSET-0.75, x);
65 cairo_line_to (cr, SIZE-3*OFFSET-0.25, x);
70 return CAIRO_TEST_SUCCESS;
73 static cairo_test_status_t
74 aligned (cairo_t *cr, int width, int height)
76 cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
77 return draw (cr, width, height);
80 CAIRO_TEST (rectilinear_grid,
81 "Test rectilinear rasterizer (covering partial pixels)",
82 "rectilinear", /* keywords */
83 NULL, /* requirements */
87 CAIRO_TEST (a1_rectilinear_grid,
88 "Test rectilinear rasterizer (covering whole pixels)",
89 "rectilinear", /* keywords */
90 "target=raster", /* requirements */