1
/*
2
 * Copyright © 2007 Keith Packard
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it either under the terms of the GNU Lesser General Public
6
 * License version 2.1 as published by the Free Software Foundation
7
 * (the "LGPL") or, at your option, under the terms of the Mozilla
8
 * Public License Version 1.1 (the "MPL"). If you do not alter this
9
 * notice, a recipient may use your version of this file under either
10
 * the MPL or the LGPL.
11
 *
12
 * You should have received a copy of the LGPL along with this library
13
 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
15
 * You should have received a copy of the MPL along with this library
16
 * in the file COPYING-MPL-1.1
17
 *
18
 * The contents of this file are subject to the Mozilla Public License
19
 * Version 1.1 (the "License"); you may not use this file except in
20
 * compliance with the License. You may obtain a copy of the License at
21
 * http://www.mozilla.org/MPL/
22
 *
23
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
24
 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
25
 * the specific language governing rights and limitations.
26
 *
27
 * The Original Code is the cairo graphics library.
28
 *
29
 * The Initial Developer of the Original Code is Keith Packard
30
 *
31
 * Contributor(s):
32
 *      Keith Packard <keithp@keithp.com>
33
 */
34
#include "cairo-test.h"
35

            
36
static cairo_test_status_t
37
3
draw (cairo_t *cr, int width, int height)
38
{
39
    double  xscale, yscale;
40
3
    cairo_set_source_rgb (cr, 1, 1, 1);
41
3
    cairo_paint (cr);
42

            
43
3
    cairo_set_source_rgb (cr, 0, 0, 0);
44
3
    cairo_set_miter_limit (cr, 100000);
45
9
    for (xscale = 1; xscale <= 1000; xscale += 999)
46
18
	for (yscale = 1; yscale <= 1000; yscale += 999)
47
	{
48
12
	    double  max_scale = xscale > yscale ? xscale : yscale;
49
12
	    cairo_save (cr);
50
12
	    if (xscale > 1)
51
6
		cairo_translate (cr, 50, 0);
52
12
	    if (yscale > 1)
53
6
		cairo_translate (cr, 0, 50);
54
12
	    cairo_scale (cr, xscale, yscale);
55
12
	    cairo_set_line_width (cr, 10.0 / max_scale);
56
12
	    cairo_move_to (cr, 10.0 / xscale, 10.0 / yscale);
57
12
	    cairo_line_to (cr, 40.0 / xscale, 10.0 / yscale);
58
12
	    cairo_line_to (cr, 10.0 / xscale, 30.0 / yscale);
59
12
	    cairo_stroke (cr);
60
12
	    cairo_restore (cr);
61
	}
62

            
63
3
    return CAIRO_TEST_SUCCESS;
64
}
65

            
66
1
CAIRO_TEST (miter_precision,
67
	    "test how cairo deals with small miters"
68
	    "\ncurrent code draws inappropriate bevels at times",
69
	    "stoke, stress", /* keywords */
70
	    NULL, /* requirements */
71
	    120, 100,
72
	    NULL, draw)