From ff30a5cbb941a9559082c6a6052ef761c7de949c Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Wed, 3 Mar 2010 13:24:13 -0500 Subject: [PATCH] test: Add support for indexed formats to blitters-test These formats work fine, they just need to have a palette set. --- test/blitters-test.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/test/blitters-test.c b/test/blitters-test.c index 0b4b6c9..c11917d 100644 --- a/test/blitters-test.c +++ b/test/blitters-test.c @@ -27,6 +27,8 @@ #include #include "utils.h" +static pixman_indexed_t palette; + static void * aligned_malloc (size_t align, size_t size) { @@ -58,6 +60,7 @@ create_random_image (pixman_format_code_t *allowed_formats, while (allowed_formats[n] != -1) n++; fmt = allowed_formats[lcg_rand_n (n)]; + width = lcg_rand_n (max_width) + 1; height = lcg_rand_n (max_height) + 1; stride = (width * PIXMAN_FORMAT_BPP (fmt) + 7) / 8 + @@ -79,6 +82,12 @@ create_random_image (pixman_format_code_t *allowed_formats, img = pixman_image_create_bits (fmt, width, height, buf, stride); + if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_COLOR || + PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_GRAY) + { + pixman_image_set_indexed (img, &palette); + } + image_endian_swap (img, PIXMAN_FORMAT_BPP (fmt)); if (used_fmt) *used_fmt = fmt; @@ -221,7 +230,6 @@ static pixman_format_code_t img_fmt_list[] = { PIXMAN_b2g3r3, PIXMAN_a2r2g2b2, PIXMAN_a2b2g2r2, -#if 0 /* using these crashes the test */ PIXMAN_c8, PIXMAN_g8, PIXMAN_x4c4, @@ -229,7 +237,6 @@ static pixman_format_code_t img_fmt_list[] = { PIXMAN_c4, PIXMAN_g4, PIXMAN_g1, -#endif PIXMAN_x4a4, PIXMAN_a4, PIXMAN_r1g2b1, @@ -418,6 +425,18 @@ test_composite (uint32_t initcrc, int testnum, int verbose) return crc32; } +static void +initialize_palette (void) +{ + int i; + + for (i = 0; i < PIXMAN_MAX_INDEXED; ++i) + palette.rgba[i] = lcg_rand (); + + for (i = 0; i < 32768; ++i) + palette.ent[i] = lcg_rand() & 0xff; +} + int main (int argc, char *argv[]) { @@ -425,6 +444,8 @@ main (int argc, char *argv[]) uint32_t crc = 0; int verbose = getenv ("VERBOSE") != NULL; + initialize_palette(); + if (argc >= 3) { n1 = atoi (argv[1]); @@ -461,7 +482,7 @@ main (int argc, char *argv[]) /* Predefined value for running with all the fastpath functions disabled. It needs to be updated every time when changes are introduced to this program or behavior of pixman changes! */ - if (crc == 0x20CBE02C) + if (crc == 0xEF7A1179) { printf ("blitters test passed\n"); } -- 2.7.4