2 * Copyright © 2005 Mozilla Corporation
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Mozilla Corporation not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior
11 * permission. Mozilla Corporation makes no representations about the
12 * suitability of this software for any purpose. It is provided "as
13 * is" without express or implied warranty.
15 * MOZILLA CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
16 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS, IN NO EVENT SHALL MOZILLA CORPORATION BE LIABLE FOR ANY SPECIAL,
18 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
21 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: Vladimir Vukicevic <vladimir@pobox.com>
26 #include "cairo-test.h"
32 #define WIDTH (UNIT_SIZE + PAD) + PAD
33 #define HEIGHT (UNIT_SIZE + PAD) + PAD
35 static cairo_test_status_t
36 draw (cairo_t *cr, int width, int height)
38 cairo_pattern_t *gradient;
41 gradient = cairo_pattern_create_linear (UNIT_SIZE - (INNER_PAD*2), 0,
42 UNIT_SIZE - (INNER_PAD*2), UNIT_SIZE - (INNER_PAD*2));
43 cairo_pattern_add_color_stop_rgba (gradient, 0.0, 0.3, 0.3, 0.3, 1.0);
44 cairo_pattern_add_color_stop_rgba (gradient, 1.0, 1.0, 1.0, 1.0, 1.0);
46 for (j = 0; j < 1; j++) {
47 for (i = 0; i < 1; i++) {
48 double x = (i * UNIT_SIZE) + (i + 1) * PAD;
49 double y = (j * UNIT_SIZE) + (j + 1) * PAD;
53 cairo_translate (cr, x, y);
55 /* draw a gradient background */
57 cairo_translate (cr, INNER_PAD, INNER_PAD);
59 cairo_rectangle (cr, 0, 0,
60 UNIT_SIZE - (INNER_PAD*2), UNIT_SIZE - (INNER_PAD*2));
61 cairo_set_source (cr, gradient);
65 /* clip to the unit size */
66 cairo_rectangle (cr, 0, 0,
67 UNIT_SIZE, UNIT_SIZE);
70 cairo_rectangle (cr, 0, 0,
71 UNIT_SIZE, UNIT_SIZE);
72 cairo_set_source_rgba (cr, 0, 0, 0, 1);
73 cairo_set_line_width (cr, 2);
77 cairo_push_group (cr);
80 cairo_move_to (cr, UNIT_SIZE / 2, 0);
81 cairo_line_to (cr, UNIT_SIZE , UNIT_SIZE / 2);
82 cairo_line_to (cr, UNIT_SIZE / 2, UNIT_SIZE);
83 cairo_line_to (cr, 0 , UNIT_SIZE / 2);
84 cairo_close_path (cr);
85 cairo_set_source_rgba (cr, 0, 0, 1, 1);
90 UNIT_SIZE / 2, UNIT_SIZE / 2,
93 cairo_set_source_rgba (cr, 1, 0, 0, 1);
96 cairo_pop_group_to_source (cr);
97 cairo_paint_with_alpha (cr, 0.5);
103 cairo_pattern_destroy (gradient);
105 return CAIRO_TEST_SUCCESS;
108 CAIRO_TEST (push_group,
109 "Verify that cairo_push_group works.",
110 "group", /* keywords */
111 NULL, /* requirements */