| 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include "pixman.h" |
| 4 | #include "gtk-utils.h" |
| 5 | |
| 6 | int |
| 7 | main (int argc, char **argv) |
| 8 | { |
| 9 | #define WIDTH400 400 |
| 10 | #define HEIGHT200 200 |
| 11 | |
| 12 | uint32_t *dest = malloc (WIDTH400 * HEIGHT200 * 4); |
| 13 | pixman_image_t *src_img; |
| 14 | pixman_image_t *dest_img; |
| 15 | int i; |
| 16 | pixman_gradient_stop_t stops[2] = |
| 17 | { |
| 18 | { pixman_int_to_fixed (0)((pixman_fixed_t) ((0) << 16)), { 0xffff, 0xeeee, 0xeeee, 0xeeee } }, |
| 19 | { pixman_int_to_fixed (1)((pixman_fixed_t) ((1) << 16)), { 0xffff, 0x1111, 0x1111, 0x1111 } } |
| 20 | }; |
| 21 | pixman_point_fixed_t p1 = { pixman_double_to_fixed (0)((pixman_fixed_t) ((0) * 65536.0)), 0 }; |
| 22 | pixman_point_fixed_t p2 = { pixman_double_to_fixed (WIDTH / 8.)((pixman_fixed_t) ((400 / 8.) * 65536.0)), |
| 23 | pixman_int_to_fixed (0)((pixman_fixed_t) ((0) << 16)) }; |
| 24 | #if 0 |
| 25 | pixman_transform_t trans = { |
| 26 | { { pixman_double_to_fixed (2)((pixman_fixed_t) ((2) * 65536.0)), pixman_double_to_fixed (0.5)((pixman_fixed_t) ((0.5) * 65536.0)), pixman_double_to_fixed (-100)((pixman_fixed_t) ((-100) * 65536.0)), }, |
| 27 | { pixman_double_to_fixed (0)((pixman_fixed_t) ((0) * 65536.0)), pixman_double_to_fixed (3)((pixman_fixed_t) ((3) * 65536.0)), pixman_double_to_fixed (0)((pixman_fixed_t) ((0) * 65536.0)), }, |
| 28 | { pixman_double_to_fixed (0)((pixman_fixed_t) ((0) * 65536.0)), pixman_double_to_fixed (0.000)((pixman_fixed_t) ((0.000) * 65536.0)), pixman_double_to_fixed (1.0)((pixman_fixed_t) ((1.0) * 65536.0)) } |
| 29 | } |
| 30 | }; |
| 31 | #else |
| 32 | pixman_transform_t trans = { |
| 33 | { { pixman_fixed_1(((pixman_fixed_t) ((1) << 16))), 0, 0 }, |
| 34 | { 0, pixman_fixed_1(((pixman_fixed_t) ((1) << 16))), 0 }, |
| 35 | { 0, 0, pixman_fixed_1(((pixman_fixed_t) ((1) << 16))) } } |
| 36 | }; |
| 37 | #endif |
| 38 | |
| 39 | pixman_point_fixed_t c_inner; |
| 40 | pixman_point_fixed_t c_outer; |
| 41 | pixman_fixed_t r_inner; |
| 42 | pixman_fixed_t r_outer; |
| 43 | |
| 44 | for (i = 0; i < WIDTH400 * HEIGHT200; ++i) |
| 45 | dest[i] = 0x4f00004f; |
| 46 | |
| 47 | dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8, |
| 48 | WIDTH400, HEIGHT200, |
| 49 | dest, |
| 50 | WIDTH400 * 4); |
| 51 | |
| 52 | c_inner.x = pixman_double_to_fixed (50.0)((pixman_fixed_t) ((50.0) * 65536.0)); |
| 53 | c_inner.y = pixman_double_to_fixed (50.0)((pixman_fixed_t) ((50.0) * 65536.0)); |
| 54 | c_outer.x = pixman_double_to_fixed (50.0)((pixman_fixed_t) ((50.0) * 65536.0)); |
| 55 | c_outer.y = pixman_double_to_fixed (50.0)((pixman_fixed_t) ((50.0) * 65536.0)); |
| 56 | r_inner = 0; |
| 57 | r_outer = pixman_double_to_fixed (50.0)((pixman_fixed_t) ((50.0) * 65536.0)); |
| 58 | |
| 59 | src_img = pixman_image_create_conical_gradient (&c_inner, r_inner, |
| Value stored to 'src_img' is never read |
| 60 | stops, 2); |
| 61 | #if 0 |
| 62 | src_img = pixman_image_create_conical_gradient (&c_inner, r_inner, |
| 63 | stops, 2); |
| 64 | src_img = pixman_image_create_linear_gradient (&c_inner, &c_outer, |
| 65 | r_inner, r_outer, |
| 66 | stops, 2); |
| 67 | #endif |
| 68 | |
| 69 | src_img = pixman_image_create_linear_gradient (&p1, &p2, |
| 70 | stops, 2); |
| 71 | |
| 72 | pixman_image_set_transform (src_img, &trans); |
| 73 | pixman_image_set_repeat (src_img, PIXMAN_REPEAT_PAD); |
| 74 | |
| 75 | pixman_image_composite (PIXMAN_OP_OVER, src_img, NULL((void*)0), dest_img, |
| 76 | 0, 0, 0, 0, 0, 0, 10 * WIDTH400, HEIGHT200); |
| 77 | |
| 78 | printf ("0, 0: %x\n", dest[0]); |
| 79 | printf ("10, 10: %x\n", dest[10 * 10 + 10]); |
| 80 | printf ("w, h: %x\n", dest[(HEIGHT200 - 1) * 100 + (WIDTH400 - 1)]); |
| 81 | |
| 82 | show_image (dest_img); |
| 83 | |
| 84 | pixman_image_unref (src_img); |
| 85 | pixman_image_unref (dest_img); |
| 86 | free (dest); |
| 87 | |
| 88 | return 0; |
| 89 | } |