Tizen 2.0 Release
[framework/graphics/cairo.git] / test / device-offset-fractional.c
1 /*
2  * Copyright © 2006 Red Hat, Inc.
3  * Copyright © 2008 Chris Wilson
4  *
5  * Permission to use, copy, modify, distribute, and sell this software
6  * and its documentation for any purpose is hereby granted without
7  * fee, provided that the above copyright notice appear in all copies
8  * and that both that copyright notice and this permission notice
9  * appear in supporting documentation, and that the name of
10  * Red Hat, Inc. not be used in advertising or publicity pertaining to
11  * distribution of the software without specific, written prior
12  * permission. Red Hat, Inc. makes no representations about the
13  * suitability of this software for any purpose.  It is provided "as
14  * is" without express or implied warranty.
15  *
16  * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18  * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
19  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
22  * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23  *
24  * Author: Carl D. Worth <cworth@cworth.org>
25  *         Chris Wilson <chris@chris-wilson.co.uk>
26  */
27
28 #include "cairo-test.h"
29
30 #define SIZE 10
31 #define PAD 4
32 #define COUNT 4
33
34 static cairo_test_status_t
35 draw (cairo_t *cr, int width, int height)
36 {
37     cairo_surface_t *surface;
38     cairo_t *cr2;
39     int i,j;
40
41     /* Fill the background */
42     cairo_set_source_rgb (cr, 1, 1, 1); /* white */
43     cairo_paint (cr);
44
45     surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, SIZE, SIZE);
46     cr2 = cairo_create (surface);
47     cairo_surface_destroy (surface);
48
49     cairo_set_source_rgb (cr2, 0, 0, 1); /* blue */
50     cairo_paint (cr2);
51
52     cairo_set_source_surface (cr, cairo_get_target (cr2), 0, 0);
53     cairo_destroy (cr2);
54
55     for (i = 0; i < COUNT; i++) {
56         for (j = 0; j < COUNT; j++) {
57             cairo_surface_set_device_offset (surface,
58                                              -i*(SIZE+PAD+.5)-PAD,
59                                              -j*(SIZE+PAD+.5)-PAD);
60             cairo_paint (cr);
61         }
62     }
63
64     return CAIRO_TEST_SUCCESS;
65 }
66
67 CAIRO_TEST (device_offset_fractional,
68             "Test using image surfaces with fractional device-offsets as sources.",
69             "device-offset", /* keywords */
70             NULL, /* requirements */
71             COUNT*(SIZE+PAD+.5)+PAD, COUNT*(SIZE+PAD+.5)+PAD,
72             NULL, draw)