[Pixman] [PATCH] test: Add support for indexed formats to blitters-test

Søren Sandmann Pedersen sandmann at daimi.au.dk
Sun Mar 7 06:34:08 PST 2010


From: Søren Sandmann Pedersen <sandmann at redhat.com>

These formats work fine, they just need to have a palette set.
---
 test/blitters-test.c |   27 ++++++++++++++++++++++++---
 1 files 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 <config.h>
 #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");
 	    }
-- 
1.6.0.6



More information about the Pixman mailing list