Add qemu 2.4.0
[kvmfornfv.git] / qemu / pixman / demos / tri-test.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "../test/utils.h"
5 #include "gtk-utils.h"
6
7 int
8 main (int argc, char **argv)
9 {
10 #define WIDTH 200
11 #define HEIGHT 200
12
13 #define POINT(x,y)                                                      \
14     { pixman_double_to_fixed ((x)), pixman_double_to_fixed ((y)) }
15     
16     pixman_image_t *src_img, *dest_img;
17     pixman_triangle_t tris[4] =
18     {
19         { POINT (100, 100), POINT (10, 50), POINT (110, 10) },
20         { POINT (100, 100), POINT (150, 10), POINT (200, 50) },
21         { POINT (100, 100), POINT (10, 170), POINT (90, 175) },
22         { POINT (100, 100), POINT (170, 150), POINT (120, 190) },
23     };
24     pixman_color_t color = { 0x4444, 0x4444, 0xffff, 0xffff };
25     uint32_t *bits = malloc (WIDTH * HEIGHT * 4);
26     int i;
27
28     for (i = 0; i < WIDTH * HEIGHT; ++i)
29         bits[i] = (i / HEIGHT) * 0x01010000;
30     
31     src_img = pixman_image_create_solid_fill (&color);
32     dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, bits, WIDTH * 4);
33     
34     pixman_composite_triangles (PIXMAN_OP_ATOP_REVERSE,
35                                 src_img,
36                                 dest_img,
37                                 PIXMAN_a8,
38                                 200, 200,
39                                 -5, 5,
40                                 ARRAY_LENGTH (tris), tris);
41     show_image (dest_img);
42     
43     pixman_image_unref (src_img);
44     pixman_image_unref (dest_img);
45     free (bits);
46     
47     return 0;
48 }