2
* Copyright © 2007 Adrian Johnson
4
* Permission is hereby granted, free of charge, to any person
5
* obtaining a copy of this software and associated documentation
6
* files (the "Software"), to deal in the Software without
7
* restriction, including without limitation the rights to use, copy,
8
* modify, merge, publish, distribute, sublicense, and/or sell copies
9
* of the Software, and to permit persons to whom the Software is
10
* furnished to do so, subject to the following conditions:
12
* The above copyright notice and this permission notice shall be
13
* included in all copies or substantial portions of the Software.
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
* Author: Adrian Johnson <ajohnson@redneon.com>
27
#include "cairo-test.h"
29
static cairo_test_draw_function_t draw;
32
#define PAT_HEIGHT 120
33
#define SIZE (PAT_WIDTH*2)
35
#define WIDTH (PAD + SIZE + PAD)
39
/* This test is designed to test painting a meta surface pattern with
40
* CAIRO_EXTEND_NONE and a non identity pattern matrix.
44
"meta-surface-pattern",
45
"Paint meta surface pattern with non identity pattern matrix",
51
static cairo_test_status_t
52
draw (cairo_t *cr, int width, int height)
54
cairo_surface_t *pat_surface;
55
cairo_pattern_t *pattern;
59
cairo_translate (cr, PAD, PAD);
61
pat_surface = cairo_surface_create_similar (cairo_get_group_target (cr),
62
CAIRO_CONTENT_COLOR_ALPHA,
63
PAT_WIDTH, PAT_HEIGHT);
65
cr2 = cairo_create (pat_surface);
67
cairo_set_source_rgba (cr2, 1, 0, 1, 0.5);
68
cairo_rectangle (cr2, PAT_WIDTH/6.0, PAT_HEIGHT/6.0, PAT_WIDTH/4.0, PAT_HEIGHT/4.0);
71
cairo_set_source_rgba (cr2, 0, 1, 1, 0.5);
72
cairo_rectangle (cr2, PAT_WIDTH/2.0, PAT_HEIGHT/2.0, PAT_WIDTH/4.0, PAT_HEIGHT/4.0);
75
cairo_set_line_width (cr2, 1);
76
cairo_move_to (cr2, PAT_WIDTH/6.0, 0);
77
cairo_line_to (cr2, 0, 0);
78
cairo_line_to (cr2, 0, PAT_HEIGHT/6.0);
79
cairo_set_source_rgb (cr2, 1, 0, 0);
81
cairo_move_to (cr2, PAT_WIDTH/6.0, PAT_HEIGHT);
82
cairo_line_to (cr2, 0, PAT_HEIGHT);
83
cairo_line_to (cr2, 0, 5*PAT_HEIGHT/6.0);
84
cairo_set_source_rgb (cr2, 0, 1, 0);
86
cairo_move_to (cr2, 5*PAT_WIDTH/6.0, 0);
87
cairo_line_to (cr2, PAT_WIDTH, 0);
88
cairo_line_to (cr2, PAT_WIDTH, PAT_HEIGHT/6.0);
89
cairo_set_source_rgb (cr2, 0, 0, 1);
91
cairo_move_to (cr2, 5*PAT_WIDTH/6.0, PAT_HEIGHT);
92
cairo_line_to (cr2, PAT_WIDTH, PAT_HEIGHT);
93
cairo_line_to (cr2, PAT_WIDTH, 5*PAT_HEIGHT/6.0);
94
cairo_set_source_rgb (cr2, 1, 1, 0);
97
cairo_set_source_rgb (cr2, 0.5, 0.5, 0.5);
98
cairo_set_line_width (cr2, PAT_WIDTH/10.0);
100
cairo_move_to (cr2, 0, PAT_HEIGHT/4.0);
101
cairo_line_to (cr2, PAT_WIDTH, PAT_HEIGHT/4.0);
104
cairo_move_to (cr2, PAT_WIDTH/4.0, 0);
105
cairo_line_to (cr2, PAT_WIDTH/4.0, PAT_WIDTH);
109
pattern = cairo_pattern_create_for_surface (pat_surface);
110
cairo_surface_destroy (pat_surface);
112
cairo_matrix_init_identity (&mat);
113
cairo_matrix_scale (&mat, 2, 1.5);
114
cairo_matrix_rotate (&mat, 1);
115
cairo_matrix_translate (&mat, -PAT_WIDTH/4.0, -PAT_WIDTH/2.0);
116
cairo_pattern_set_matrix (pattern, &mat);
117
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_NONE);
119
cairo_set_source (cr, pattern);
122
cairo_pattern_destroy (pattern);
124
return CAIRO_TEST_SUCCESS;
130
return cairo_test (&test);