10 pixman_indexed_t mono_pallete = {
11 .rgba = { 0x00000000, 0x00ffffff },
16 pixman_format_code_t format;
21 pixman_indexed_t *indexed;
24 testcase_t testcases[] = {
26 .format = PIXMAN_a8r8g8b8,
27 .width = 2, .height = 2,
29 .src = { 0x00112233, 0x44556677,
30 0x8899aabb, 0xccddeeff },
31 .dst = { 0x00112233, 0x44556677,
32 0x8899aabb, 0xccddeeff },
37 .width = 8, .height = 2,
41 .dst = { 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000,
42 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff },
43 .indexed = &mono_pallete,
48 .width = 4, .height = 2,
52 .dst = { 0x00010101, 0x00232323, 0x00454545, 0x00676767,
53 0x00898989, 0x00ababab, 0x00cdcdcd, 0x00efefef, },
57 .format = PIXMAN_yv12,
58 .width = 8, .height = 2,
60 .src = { 0xff00ff00, 0xff00ff00,
61 0x00ff00ff, 0x00ff00ff,
65 0xff000000, 0xffffffff, 0xffb80000, 0xffffe113,
66 0xff000000, 0xffffffff, 0xff0023ee, 0xff4affff,
67 0xffffffff, 0xff000000, 0xffffe113, 0xffb80000,
68 0xffffffff, 0xff000000, 0xff4affff, 0xff0023ee,
73 const int ntestcases = sizeof(testcases)/sizeof(testcases[0]);
77 reader (const void *src, int size)
82 return *(uint8_t *)src;
84 return *(uint16_t *)src;
86 return *(uint32_t *)src;
94 writer (void *src, uint32_t value, int size)
99 *(uint8_t *)src = value;
102 *(uint16_t *)src = value;
105 *(uint32_t *)src = value;
114 main (int argc, char **argv)
117 pixman_image_t *src_img;
118 pixman_image_t *dst_img;
122 for (i = 0; i < ntestcases; ++i) {
123 for (j = 0; j < 2; ++j) {
124 src_img = pixman_image_create_bits (testcases[i].format,
128 testcases[i].stride);
129 pixman_image_set_indexed(src_img, testcases[i].indexed);
131 dst_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
135 testcases[i].width*4);
138 pixman_image_set_accessors (src_img, reader, writer);
139 pixman_image_set_accessors (dst_img, reader, writer);
142 pixman_image_composite (PIXMAN_OP_SRC, src_img, NULL, dst_img,
143 0, 0, 0, 0, 0, 0, testcases[i].width, testcases[i].height);
145 pixman_image_unref (src_img);
146 pixman_image_unref (dst_img);
148 for (y = 0; y < testcases[i].height; ++y)
149 for (x = 0; x < testcases[i].width; ++x) {
150 int offset = y*testcases[i].width + x;
151 if (dst[offset] != testcases[i].dst[offset]) {
152 printf ("test %i%c: pixel mismatch at (x=%d,y=%d): %08x expected, %08x obtained\n",
155 testcases[i].dst[offset], dst[offset]);