2 * Copyright © 2009 Joonas Pihlaja
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.
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
23 #include "cairo-test.h"
25 /* This test attempts to trigger failures in those clone_similar
26 * backend methods that have size restrictions. */
28 static cairo_surface_t *
29 create_large_source (int width, int height)
31 cairo_surface_t *surface;
34 surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
35 cr = cairo_create (surface);
36 cairo_surface_destroy (surface);
38 cairo_set_source_rgb (cr, 1,0,0); /* red */
40 surface = cairo_surface_reference (cairo_get_target (cr));
46 static cairo_test_status_t
47 draw (cairo_t *cr, int width, int height)
49 cairo_surface_t *source;
50 /* Since 1cc750ed92a936d84b47cac696aaffd226e1c02e pixman will not
51 * paint on the source surface if source_width > 30582. */
52 double source_width = 30000.0;
54 cairo_set_source_rgb (cr, 1,1,1);
57 /* Create an excessively wide source image, all red. */
58 source = create_large_source (source_width, height);
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
63 cairo_scale (cr, width/source_width, 1.0);
64 cairo_set_source_surface (cr, source, 0, 0);
65 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
68 cairo_surface_destroy (source);
70 return CAIRO_TEST_SUCCESS;
73 CAIRO_TEST (large_source_roi,
74 "Uses a all of a large source image.",
75 "stress, source", /* keywords */
76 NULL, /* requirements */