1 #include "../test/utils.h"
5 #define GRADIENTS_PER_ROW 7
6 #define NUM_ROWS ((NUM_GRADIENTS + GRADIENTS_PER_ROW - 1) / GRADIENTS_PER_ROW)
7 #define WIDTH (SIZE * GRADIENTS_PER_ROW)
8 #define HEIGHT (SIZE * NUM_ROWS)
9 #define NUM_GRADIENTS 35
11 #define double_to_color(x) \
12 (((uint32_t) ((x)*65536)) - (((uint32_t) ((x)*65536)) >> 16))
14 #define PIXMAN_STOP(offset,r,g,b,a) \
15 { pixman_double_to_fixed (offset), \
17 double_to_color (r), \
18 double_to_color (g), \
19 double_to_color (b), \
25 static const pixman_gradient_stop_t stops[] = {
26 PIXMAN_STOP (0.25, 1, 0, 0, 0.7),
27 PIXMAN_STOP (0.5, 1, 1, 0, 0.7),
28 PIXMAN_STOP (0.75, 0, 1, 0, 0.7),
29 PIXMAN_STOP (1.0, 0, 0, 1, 0.7)
32 #define NUM_STOPS (sizeof (stops) / sizeof (stops[0]))
34 static pixman_image_t *
35 create_conical (int index)
37 pixman_point_fixed_t c;
40 c.x = pixman_double_to_fixed (0);
41 c.y = pixman_double_to_fixed (0);
43 angle = (0.5 / NUM_GRADIENTS + index / (double)NUM_GRADIENTS) * 720 - 180;
45 return pixman_image_create_conical_gradient (
46 &c, pixman_double_to_fixed (angle), stops, NUM_STOPS);
50 main (int argc, char **argv)
52 pixman_transform_t transform;
53 pixman_image_t *src_img, *dest_img;
56 enable_divbyzero_exceptions ();
58 dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
62 draw_checkerboard (dest_img, 25, 0xffaaaaaa, 0xff888888);
64 pixman_transform_init_identity (&transform);
66 pixman_transform_translate (NULL, &transform,
67 pixman_double_to_fixed (0.5),
68 pixman_double_to_fixed (0.5));
70 pixman_transform_scale (NULL, &transform,
71 pixman_double_to_fixed (SIZE),
72 pixman_double_to_fixed (SIZE));
73 pixman_transform_translate (NULL, &transform,
74 pixman_double_to_fixed (0.5),
75 pixman_double_to_fixed (0.5));
77 for (i = 0; i < NUM_GRADIENTS; i++)
79 int column = i % GRADIENTS_PER_ROW;
80 int row = i / GRADIENTS_PER_ROW;
82 src_img = create_conical (i);
83 pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NORMAL);
85 pixman_image_set_transform (src_img, &transform);
87 pixman_image_composite32 (
88 PIXMAN_OP_OVER, src_img, NULL,dest_img,
89 0, 0, 0, 0, column * SIZE, row * SIZE,
92 pixman_image_unref (src_img);
95 show_image (dest_img);
97 pixman_image_unref (dest_img);