1
/*
2
 * Copyright © 2009 Joonas Pihlaja
3
 *
4
 * Permission to use, copy, modify, distribute, and sell this software and its
5
 * documentation for any purpose is hereby granted without fee, provided that
6
 * the above copyright notice appear in all copies and that both that copyright
7
 * notice and this permission notice appear in supporting documentation, and
8
 * that the name of the copyright holders not be used in advertising or
9
 * publicity pertaining to distribution of the software without specific,
10
 * written prior permission.  The copyright holders make no representations
11
 * about the suitability of this software for any purpose.  It is provided "as
12
 * is" without express or implied warranty.
13
 *
14
 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16
 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20
 * OF THIS SOFTWARE.
21
 */
22

            
23
#include "cairo-test.h"
24

            
25
/* This test attempts to trigger failures in those clone_similar
26
 * backend methods that have size restrictions. */
27

            
28
static cairo_surface_t *
29
3
create_large_source (int width, int height)
30
{
31
    cairo_surface_t *surface;
32
    cairo_t *cr;
33

            
34
3
    surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
35
3
    cr = cairo_create (surface);
36
3
    cairo_surface_destroy (surface);
37

            
38
3
    cairo_set_source_rgb (cr, 1,0,0); /* red */
39
3
    cairo_paint (cr);
40
3
    surface = cairo_surface_reference (cairo_get_target (cr));
41
3
    cairo_destroy (cr);
42

            
43
3
    return surface;
44
}
45

            
46
static cairo_test_status_t
47
3
draw (cairo_t *cr, int width, int height)
48
{
49
    cairo_surface_t *source;
50
    /* Since 1cc750ed92a936d84b47cac696aaffd226e1c02e pixman will not
51
     * paint on the source surface if source_width > 30582. */
52
3
    double source_width = 30000.0;
53

            
54
3
    cairo_set_source_rgb (cr, 1,1,1);
55
3
    cairo_paint (cr);
56

            
57
    /* Create an excessively wide source image, all red. */
58
3
    source = create_large_source (source_width, height);
59

            
60
    /* Set a transform so that the source is scaled down to fit in the
61
     * destination horizontally and then paint the entire source to
62
     * the context. */
63
3
    cairo_scale (cr, width/source_width, 1.0);
64
3
    cairo_set_source_surface (cr, source, 0, 0);
65
3
    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
66
3
    cairo_paint (cr);
67

            
68
3
    cairo_surface_destroy (source);
69

            
70
3
    return CAIRO_TEST_SUCCESS;
71
}
72

            
73
1
CAIRO_TEST (large_source_roi,
74
	    "Uses a all of a large source image.",
75
	    "stress, source", /* keywords */
76
	    NULL, /* requirements */
77
	    7, 7,
78
	    NULL, draw)