1
#include "cairo-test.h"
2

            
3
static const char *png_filename = "romedalen.png";
4

            
5
static cairo_surface_t *
6
3
clone_similar_surface (cairo_surface_t * target, cairo_surface_t *surface)
7
{
8
    cairo_t *cr;
9
    cairo_surface_t *similar;
10

            
11
3
    similar = cairo_surface_create_similar (target,
12
	                              cairo_surface_get_content (surface),
13
				      cairo_image_surface_get_width (surface),
14
				      cairo_image_surface_get_height (surface));
15
3
    cr = cairo_create (similar);
16
3
    cairo_surface_destroy (similar);
17
3
    cairo_set_source_surface (cr, surface, 0, 0);
18
3
    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
19
3
    cairo_paint (cr);
20
3
    similar = cairo_surface_reference (cairo_get_target (cr));
21
3
    cairo_destroy (cr);
22

            
23
3
    return similar;
24
}
25

            
26
static cairo_test_status_t
27
3
draw (cairo_t *cr, int width, int height)
28
{
29
3
    const cairo_test_context_t *ctx = cairo_test_get_context (cr);
30
    cairo_surface_t *surface;
31
    cairo_surface_t *similar;
32

            
33
3
    surface = cairo_test_create_surface_from_png (ctx, png_filename);
34
3
    similar = clone_similar_surface (cairo_get_group_target (cr), surface);
35
3
    cairo_set_source_surface (cr, similar, 32, 32);
36
3
    cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REFLECT);
37

            
38
3
    cairo_paint (cr);
39

            
40
3
    cairo_surface_destroy (similar);
41
3
    cairo_surface_destroy (surface);
42

            
43
3
    return CAIRO_TEST_SUCCESS;
44
}
45

            
46
1
CAIRO_TEST (extend_reflect_similar,
47
	    "Test CAIRO_EXTEND_REFLECT for surface patterns",
48
	    "extend", /* keywords */
49
	    NULL, /* requirements */
50
	    256 + 32*2, 192 + 32*2,
51
	    NULL, draw)