Add test cases to oob-test using PIXMAN_{a,x}2b10g10r10
[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     {
33         PIXMAN_OP_SRC,
34         {  3, 6, 16, PIXMAN_a8r8g8b8 },
35         {  5, 7, 20, PIXMAN_x8r8g8b8 },
36         1, 8,
37         1, -1,
38         1, 8
39     },
40     {
41         PIXMAN_OP_SRC,
42         { 7, 5, 36, PIXMAN_a8r8g8b8 },
43         { 6, 5, 28, PIXMAN_x8r8g8b8 },
44         8, 5,
45         5, 3,
46         1, 2
47     },
48     {
49         PIXMAN_OP_OVER,
50         { 10, 10, 40, PIXMAN_a2b10g10r10 },
51         { 10, 10, 40, PIXMAN_a2b10g10r10 },
52         0, 0,
53         0, 0,
54         10, 10
55     },
56     {
57         PIXMAN_OP_OVER,
58         { 10, 10, 40, PIXMAN_x2b10g10r10 },
59         { 10, 10, 40, PIXMAN_x2b10g10r10 },
60         0, 0,
61         0, 0,
62         10, 10
63     },
64 };
65
66 static pixman_image_t *
67 make_image (const image_info_t *info)
68 {
69     char *data = malloc (info->stride * info->height);
70     int i;
71
72     for (i = 0; i < info->height * info->stride; ++i)
73         data[i] = (i % 255) ^ (((i % 16) << 4) | (i & 0xf0));
74
75     return pixman_image_create_bits (info->format, info->width, info->height, (uint32_t *)data, info->stride);
76 }
77     
78 static void
79 test_composite (const composite_info_t *info)
80 {
81     pixman_image_t *src = make_image (&info->src);
82     pixman_image_t *dest = make_image (&info->dest);
83
84     pixman_image_composite (PIXMAN_OP_SRC, src, NULL, dest,
85                             info->src_x, info->src_y,
86                             0, 0,
87                             info->dest_x, info->dest_y,
88                             info->width, info->height);
89 }
90
91
92
93 int
94 main (int argc, char **argv)
95 {
96     int i;
97
98     for (i = 0; i < sizeof (info) / sizeof (info[0]); ++i)
99         test_composite (&info[i]);
100     
101     return 0;
102 }