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

            
24
#include "cairo-test.h"
25
#include <stdlib.h>
26

            
27
static cairo_test_status_t
28
3
draw (cairo_t *cr, int width, int height)
29
{
30
    cairo_matrix_t m;
31
3
    int xoffset = 50;
32
3
    int yoffset = 50;
33

            
34
    cairo_surface_t *shadow;
35
    cairo_t *shadow_cr;
36
    cairo_path_t *path;
37

            
38
3
    cairo_set_source_rgb (cr, 1, 1, 1);
39
3
    cairo_paint (cr);
40

            
41
3
    cairo_translate (cr, 130, 130);
42
3
    cairo_rotate (cr, .5);//2*M_PI*angle/360);
43
3
    cairo_rectangle (cr, 0, 0, 50, 100);
44
3
    cairo_get_matrix (cr, &m);
45

            
46
3
    shadow = cairo_surface_create_similar (cairo_get_target (cr),
47
					   CAIRO_CONTENT_COLOR_ALPHA,
48
					   600 - xoffset,
49
					   600 - yoffset);
50
3
    cairo_surface_set_device_offset (shadow, xoffset, yoffset);
51
3
    shadow_cr = cairo_create (shadow);
52
3
    cairo_surface_destroy (shadow);
53

            
54
3
    cairo_set_source_rgb (shadow_cr, 0, 1, 0);
55
3
    cairo_set_matrix (shadow_cr, &m);
56

            
57
3
    path = cairo_copy_path (cr);
58
3
    cairo_new_path (shadow_cr);
59
3
    cairo_append_path (shadow_cr, path);
60
3
    cairo_fill (shadow_cr);
61
3
    cairo_path_destroy (path);
62

            
63
3
    cairo_identity_matrix (cr);
64
3
    cairo_translate (cr, 10, 50);
65
3
    cairo_set_source_surface (cr, cairo_get_target (shadow_cr), 0, 0);
66
3
    cairo_paint (cr);
67
3
    cairo_set_matrix (cr, &m);
68
3
    cairo_set_source_rgb (cr, 1, 0, 0);
69
3
    cairo_fill (cr);
70

            
71
3
    cairo_destroy (shadow_cr);
72

            
73
3
    return CAIRO_TEST_SUCCESS;
74
}
75

            
76
1
CAIRO_TEST (path_append,
77
	    "Test appending path to a context, in particular to exercise a regression in 005436",
78
	    "path", /* keywords */
79
	    NULL, /* requirements */
80
	    600, 600,
81
	    NULL, draw)