Add a table to oob-test so that it can test more than one setup.
[profile/ivi/pixman.git] / test / oob-test.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "pixman.h"
4 #include "utils.h"
5
6 typedef struct
7 {
8     int                         width;
9     int                         height;
10     int                         stride;
11     pixman_format_code_t        format;
12     
13 } image_info_t;
14
15 typedef struct
16 {
17     pixman_op_t         op;
18     
19     image_info_t        src;
20     image_info_t        dest;
21
22     int                 src_x;
23     int                 src_y;
24     int                 dest_x;
25     int                 dest_y;
26     int                 width;
27     int                 height;
28 } composite_info_t;
29
30 const composite_info_t info[] =
31 {
32     { PIXMAN_OP_SRC, { 3, 6, 16, PIXMAN_a8r8g8b8 }, { 5, 7, 20, PIXMAN_x8r8g8b8 }, 1, 8, 1, -1, 1, 8 },
33     { PIXMAN_OP_SRC, { 7, 5, 36, PIXMAN_a8r8g8b8 }, { 6, 5, 28, PIXMAN_x8r8g8b8 }, 8, 5, 5,  3, 1, 2 },
34 };
35
36 static pixman_image_t *
37 make_image (const image_info_t *info)
38 {
39     char *data = malloc (info->stride * info->height);
40     int i;
41
42     for (i = 0; i < info->height * info->stride; ++i)
43         data[i] = (i % 255) ^ (((i % 16) << 4) | (i & 0xf0));
44
45     return pixman_image_create_bits (info->format, info->width, info->height, (uint32_t *)data, info->stride);
46 }
47     
48 static void
49 test_composite (const composite_info_t *info)
50 {
51     pixman_image_t *src = make_image (&info->src);
52     pixman_image_t *dest = make_image (&info->dest);
53
54     pixman_image_composite (PIXMAN_OP_SRC, src, NULL, dest,
55                             info->src_x, info->src_y,
56                             0, 0,
57                             info->dest_x, info->dest_y,
58                             info->width, info->height);
59 }
60
61
62
63 int
64 main (int argc, char **argv)
65 {
66     int i;
67
68     for (i = 0; i < sizeof (info) / sizeof (info[0]); ++i)
69         test_composite (&info[i]);
70     
71     return 0;
72 }