9 static const pixman_indexed_t mono_pallete =
11 .rgba = { 0x00000000, 0x00ffffff },
16 pixman_format_code_t format;
21 pixman_indexed_t *indexed;
24 static const testcase_t testcases[] =
27 .format = PIXMAN_a8r8g8b8,
28 .width = 2, .height = 2,
30 .src = { 0x00112233, 0x44556677,
31 0x8899aabb, 0xccddeeff },
32 .dst = { 0x00112233, 0x44556677,
33 0x8899aabb, 0xccddeeff },
38 .width = 8, .height = 2,
40 #ifdef WORDS_BIGENDIAN
55 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000,
56 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff
58 .indexed = &mono_pallete,
63 .width = 4, .height = 2,
67 .dst = { 0x00010101, 0x00232323, 0x00454545, 0x00676767,
68 0x00898989, 0x00ababab, 0x00cdcdcd, 0x00efefef, },
71 /* FIXME: make this work on big endian */
73 .format = PIXMAN_yv12,
74 .width = 8, .height = 2,
76 #ifdef WORDS_BIGENDIAN
79 0x00ff00ff, 0x00ff00ff,
80 0xff00ff00, 0xff00ff00,
87 0xff00ff00, 0xff00ff00,
88 0x00ff00ff, 0x00ff00ff,
95 0xff000000, 0xffffffff, 0xffb80000, 0xffffe113,
96 0xff000000, 0xffffffff, 0xff0023ee, 0xff4affff,
97 0xffffffff, 0xff000000, 0xffffe113, 0xffb80000,
98 0xffffffff, 0xff000000, 0xff4affff, 0xff0023ee,
103 const int n_test_cases = sizeof(testcases)/sizeof(testcases[0]);
107 reader (const void *src, int size)
112 return *(uint8_t *)src;
114 return *(uint16_t *)src;
116 return *(uint32_t *)src;
124 writer (void *src, uint32_t value, int size)
129 *(uint8_t *)src = value;
132 *(uint16_t *)src = value;
135 *(uint32_t *)src = value;
144 main (int argc, char **argv)
147 pixman_image_t *src_img;
148 pixman_image_t *dst_img;
152 for (i = 0; i < n_test_cases; ++i)
154 for (j = 0; j < 2; ++j)
156 src_img = pixman_image_create_bits (testcases[i].format,
160 testcases[i].stride);
161 pixman_image_set_indexed(src_img, testcases[i].indexed);
163 dst_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
167 testcases[i].width*4);
171 pixman_image_set_accessors (src_img, reader, writer);
172 pixman_image_set_accessors (dst_img, reader, writer);
175 pixman_image_composite (PIXMAN_OP_SRC, src_img, NULL, dst_img,
176 0, 0, 0, 0, 0, 0, testcases[i].width, testcases[i].height);
178 pixman_image_unref (src_img);
179 pixman_image_unref (dst_img);
181 for (y = 0; y < testcases[i].height; ++y)
183 for (x = 0; x < testcases[i].width; ++x)
185 int offset = y * testcases[i].width + x;
187 if (dst[offset] != testcases[i].dst[offset])
189 printf ("test %i%c: pixel mismatch at (x=%d,y=%d): %08x expected, %08x obtained\n",
192 testcases[i].dst[offset], dst[offset]);