pixman: Branch 'master' - 6 commits

Søren Sandmann Pedersen sandmann at kemper.freedesktop.org
Sun Jul 18 19:23:09 PDT 2010


 pixman/pixman-access.c     |   31 +++++++++++++++++-
 pixman/pixman-bits-image.c |    1 
 pixman/pixman-fast-path.c  |   73 ++++++++++++++++++++++++--------------------
 test/blitters-test.c       |   74 ++++++++++++++++++++++++++++++++++++++-------
 4 files changed, 134 insertions(+), 45 deletions(-)

New commits:
commit 9897bb4eeed165b76001dfefd3a89bcb96d38a72
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Mon Jul 12 15:13:49 2010 -0400

    Check for read accessors before taking the bilinear fast path
    
    The bilinear fast path accesses pixels directly, so if the image has a
    read accessor, then it can't be used.

diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index ff59a8f..95710b4 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -909,6 +909,7 @@ bits_image_property_changed (pixman_image_t *image)
 	     bits->common.transform->matrix[2][2] == pixman_fixed_1	&&
 	     bits->common.transform->matrix[0][0] > 0			&&
 	     bits->common.transform->matrix[1][0] == 0			&&
+	     !bits->read_func						&&
 	     (bits->common.filter == PIXMAN_FILTER_BILINEAR ||
 	      bits->common.filter == PIXMAN_FILTER_GOOD	    ||
 	      bits->common.filter == PIXMAN_FILTER_BEST)		&&
commit ce3d9fca73bb8abe4d5b1023cfdb06ca53b6161c
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Sun Jul 11 19:58:49 2010 -0400

    fast-path: Some formatting fixes
    
    Add spaces before parentheses; fix indentation in the macro.

diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c
index 2e9d39a..c65dfb1 100644
--- a/pixman/pixman-fast-path.c
+++ b/pixman/pixman-fast-path.c
@@ -1547,8 +1547,8 @@ fast_composite_scaled_nearest_ ## scale_func_name ## _ ## OP (pixman_implementat
 	    }											\
 	    else /* PIXMAN_OP_SRC */								\
 	    {											\
-		    *dst++ = CONVERT_ ## SRC_FORMAT ## _TO_ ## DST_FORMAT (s1);			\
-		    *dst++ = CONVERT_ ## SRC_FORMAT ## _TO_ ## DST_FORMAT (s2);			\
+		*dst++ = CONVERT_ ## SRC_FORMAT ## _TO_ ## DST_FORMAT (s1);			\
+		*dst++ = CONVERT_ ## SRC_FORMAT ## _TO_ ## DST_FORMAT (s2);			\
 	    }											\
 	}											\
 												\
@@ -1584,22 +1584,22 @@ fast_composite_scaled_nearest_ ## scale_func_name ## _ ## OP (pixman_implementat
 	    }											\
 	    else /* PIXMAN_OP_SRC */								\
 	    {											\
-		    *dst++ = CONVERT_ ## SRC_FORMAT ## _TO_ ## DST_FORMAT (s1);			\
+		*dst++ = CONVERT_ ## SRC_FORMAT ## _TO_ ## DST_FORMAT (s1);			\
 	    }											\
 	}											\
     }												\
 }
 
-FAST_NEAREST(8888_8888_none, 8888, 8888, uint32_t, uint32_t, SRC, NONE);
-FAST_NEAREST(8888_8888_normal, 8888, 8888, uint32_t, uint32_t, SRC, NORMAL);
-FAST_NEAREST(8888_8888_none, 8888, 8888, uint32_t, uint32_t, OVER, NONE);
-FAST_NEAREST(8888_8888_normal, 8888, 8888, uint32_t, uint32_t, OVER, NORMAL);
-FAST_NEAREST(8888_565_none, 8888, 0565, uint32_t, uint16_t, SRC, NONE);
-FAST_NEAREST(8888_565_normal, 8888, 0565, uint32_t, uint16_t, SRC, NORMAL);
-FAST_NEAREST(565_565_none, 0565, 0565, uint16_t, uint16_t, SRC, NONE);
-FAST_NEAREST(565_565_normal, 0565, 0565, uint16_t, uint16_t, SRC, NORMAL);
-FAST_NEAREST(8888_565_none, 8888, 0565, uint32_t, uint16_t, OVER, NONE);
-FAST_NEAREST(8888_565_normal, 8888, 0565, uint32_t, uint16_t, OVER, NORMAL);
+FAST_NEAREST (8888_8888_none, 8888, 8888, uint32_t, uint32_t, SRC, NONE);
+FAST_NEAREST (8888_8888_normal, 8888, 8888, uint32_t, uint32_t, SRC, NORMAL);
+FAST_NEAREST (8888_8888_none, 8888, 8888, uint32_t, uint32_t, OVER, NONE);
+FAST_NEAREST (8888_8888_normal, 8888, 8888, uint32_t, uint32_t, OVER, NORMAL);
+FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, SRC, NONE);
+FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, SRC, NORMAL);
+FAST_NEAREST (565_565_none, 0565, 0565, uint16_t, uint16_t, SRC, NONE);
+FAST_NEAREST (565_565_normal, 0565, 0565, uint16_t, uint16_t, SRC, NORMAL);
+FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, OVER, NONE);
+FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, OVER, NORMAL);
 
 static force_inline uint32_t
 fetch_nearest (pixman_repeat_t src_repeat,
commit 839326e471a8a6c96dea1693501550d79043bb81
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Sun Jul 11 19:57:29 2010 -0400

    In the FAST_NEAREST macro call the function 8888_8888 and not x888_x888
    
    The x888 suggests that they have something to do with the x8r8g8b8
    formats, but that's not the case; they are assuming a8r8g8b8
    formats. (Although in some cases they also work for x8r8g8b8 type
    formats).

diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c
index 7b8c9bc..2e9d39a 100644
--- a/pixman/pixman-fast-path.c
+++ b/pixman/pixman-fast-path.c
@@ -1590,12 +1590,12 @@ fast_composite_scaled_nearest_ ## scale_func_name ## _ ## OP (pixman_implementat
     }												\
 }
 
-FAST_NEAREST(x888_x888_none, 8888, 8888, uint32_t, uint32_t, SRC, NONE);
-FAST_NEAREST(x888_x888_normal, 8888, 8888, uint32_t, uint32_t, SRC, NORMAL);
-FAST_NEAREST(x888_x888_none, 8888, 8888, uint32_t, uint32_t, OVER, NONE);
-FAST_NEAREST(x888_x888_normal, 8888, 8888, uint32_t, uint32_t, OVER, NORMAL);
-FAST_NEAREST(x888_565_none, 8888, 0565, uint32_t, uint16_t, SRC, NONE);
-FAST_NEAREST(x888_565_normal, 8888, 0565, uint32_t, uint16_t, SRC, NORMAL);
+FAST_NEAREST(8888_8888_none, 8888, 8888, uint32_t, uint32_t, SRC, NONE);
+FAST_NEAREST(8888_8888_normal, 8888, 8888, uint32_t, uint32_t, SRC, NORMAL);
+FAST_NEAREST(8888_8888_none, 8888, 8888, uint32_t, uint32_t, OVER, NONE);
+FAST_NEAREST(8888_8888_normal, 8888, 8888, uint32_t, uint32_t, OVER, NORMAL);
+FAST_NEAREST(8888_565_none, 8888, 0565, uint32_t, uint16_t, SRC, NONE);
+FAST_NEAREST(8888_565_normal, 8888, 0565, uint32_t, uint16_t, SRC, NORMAL);
 FAST_NEAREST(565_565_none, 0565, 0565, uint16_t, uint16_t, SRC, NONE);
 FAST_NEAREST(565_565_normal, 0565, 0565, uint16_t, uint16_t, SRC, NORMAL);
 FAST_NEAREST(8888_565_none, 8888, 0565, uint32_t, uint16_t, OVER, NONE);
@@ -1855,23 +1855,23 @@ static const pixman_fast_path_t c_fast_paths[] =
 	PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS,				\
 	fast_composite_scaled_nearest_ ## func ## _none ## _ ## op,	\
     }
-    SIMPLE_NEAREST_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8, x888_x888),
-    SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8, x888_x888),
-    SIMPLE_NEAREST_FAST_PATH (SRC, x8b8g8r8, x8b8g8r8, x888_x888),
-    SIMPLE_NEAREST_FAST_PATH (SRC, a8b8g8r8, x8b8g8r8, x888_x888),
+    SIMPLE_NEAREST_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8, 8888_8888),
+    SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8, 8888_8888),
+    SIMPLE_NEAREST_FAST_PATH (SRC, x8b8g8r8, x8b8g8r8, 8888_8888),
+    SIMPLE_NEAREST_FAST_PATH (SRC, a8b8g8r8, x8b8g8r8, 8888_8888),
 
-    SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8, x888_x888),
-    SIMPLE_NEAREST_FAST_PATH (SRC, a8b8g8r8, a8b8g8r8, x888_x888),
+    SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8, 8888_8888),
+    SIMPLE_NEAREST_FAST_PATH (SRC, a8b8g8r8, a8b8g8r8, 8888_8888),
 
-    SIMPLE_NEAREST_FAST_PATH (SRC, x8r8g8b8, r5g6b5, x888_565),
-    SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, r5g6b5, x888_565),
+    SIMPLE_NEAREST_FAST_PATH (SRC, x8r8g8b8, r5g6b5, 8888_565),
+    SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, r5g6b5, 8888_565),
 
     SIMPLE_NEAREST_FAST_PATH (SRC, r5g6b5, r5g6b5, 565_565),
 
-    SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8, x888_x888),
-    SIMPLE_NEAREST_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8, x888_x888),
-    SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, x888_x888),
-    SIMPLE_NEAREST_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8, x888_x888),
+    SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8, 8888_8888),
+    SIMPLE_NEAREST_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8, 8888_8888),
+    SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, 8888_8888),
+    SIMPLE_NEAREST_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8, 8888_8888),
 
     SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, r5g6b5, 8888_565),
 
commit e13d9f9684a47a6e0be4f8ae1a39cce8b1334238
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Sun Jul 11 19:45:22 2010 -0400

    Make the repeat mode explicit in the FAST_NEAREST macro.
    
    Before, it was 0 or 1 meaning 'no repeat' and 'normal repeat'
    respectively. Now we explicitly pass in either NONE or NORMAL.

diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c
index c4dd3a6..7b8c9bc 100644
--- a/pixman/pixman-fast-path.c
+++ b/pixman/pixman-fast-path.c
@@ -1399,7 +1399,7 @@ repeat (pixman_repeat_t repeat, int *c, int size)
 #define GET_0565_ALPHA(s) 0xff
 
 #define FAST_NEAREST(scale_func_name, SRC_FORMAT, DST_FORMAT,					\
-		     src_type_t, dst_type_t, OP, do_repeat)					\
+		     src_type_t, dst_type_t, OP, repeat_mode)					\
 static void											\
 fast_composite_scaled_nearest_ ## scale_func_name ## _ ## OP (pixman_implementation_t *imp,	\
 							      pixman_op_t              op,      \
@@ -1435,6 +1435,12 @@ fast_composite_scaled_nearest_ ## scale_func_name ## _ ## OP (pixman_implementat
     if (PIXMAN_OP_ ## OP != PIXMAN_OP_SRC && PIXMAN_OP_ ## OP != PIXMAN_OP_OVER)		\
 	abort();										\
 												\
+    if (PIXMAN_REPEAT_ ## repeat_mode != PIXMAN_REPEAT_NORMAL		&&			\
+	PIXMAN_REPEAT_ ## repeat_mode != PIXMAN_REPEAT_NONE)					\
+    {												\
+	abort();										\
+    }												\
+												\
     PIXMAN_IMAGE_GET_LINE (dst_image, dst_x, dst_y, dst_type_t, dst_stride, dst_line, 1);	\
     /* pass in 0 instead of src_x and src_y because src_x and src_y need to be			\
      * transformed from destination space to source space */					\
@@ -1458,7 +1464,7 @@ fast_composite_scaled_nearest_ ## scale_func_name ## _ ## OP (pixman_implementat
     vx = v.vector[0];										\
     vy = v.vector[1];										\
 												\
-    if (do_repeat)										\
+    if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NORMAL)					\
     {												\
 	/* Clamp repeating positions inside the actual samples */				\
 	max_vx = src_image->bits.width << 16;							\
@@ -1477,7 +1483,7 @@ fast_composite_scaled_nearest_ ## scale_func_name ## _ ## OP (pixman_implementat
 												\
 	y = vy >> 16;										\
 	vy += unit_y;										\
-	if (do_repeat)										\
+	if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NORMAL)				\
 	    repeat (PIXMAN_REPEAT_NORMAL, &vy, max_vy);						\
 												\
 	src = src_first_line + src_stride * y;							\
@@ -1488,7 +1494,7 @@ fast_composite_scaled_nearest_ ## scale_func_name ## _ ## OP (pixman_implementat
 	{											\
 	    x1 = vx >> 16;									\
 	    vx += unit_x;									\
-	    if (do_repeat)									\
+	    if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NORMAL)				\
 	    {											\
 		/* This works because we know that unit_x is positive */			\
 		while (vx >= max_vx)								\
@@ -1498,7 +1504,7 @@ fast_composite_scaled_nearest_ ## scale_func_name ## _ ## OP (pixman_implementat
 												\
 	    x2 = vx >> 16;									\
 	    vx += unit_x;									\
-	    if (do_repeat)									\
+	    if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NORMAL)				\
 	    {											\
 		/* This works because we know that unit_x is positive */			\
 		while (vx >= max_vx)								\
@@ -1517,7 +1523,8 @@ fast_composite_scaled_nearest_ ## scale_func_name ## _ ## OP (pixman_implementat
 		}										\
 		else if (s1)									\
 		{										\
-		    d = CONVERT_## DST_FORMAT ## _TO_8888 (*dst);				\
+		    d = CONVERT_ ## DST_FORMAT ## _TO_8888 (*dst);				\
+		    s1 = CONVERT_ ## SRC_FORMAT ## _TO_8888 (s1);				\
 		    a1 ^= 0xff;									\
 		    UN8x4_MUL_UN8_ADD_UN8x4 (d, a1, s1);					\
 		    *dst = CONVERT_8888_TO_ ## DST_FORMAT (d);					\
@@ -1531,6 +1538,7 @@ fast_composite_scaled_nearest_ ## scale_func_name ## _ ## OP (pixman_implementat
 		else if (s2)									\
 		{										\
 		    d = CONVERT_## DST_FORMAT ## _TO_8888 (*dst);				\
+		    s2 = CONVERT_## SRC_FORMAT ## _TO_8888 (s2);				\
 		    a2 ^= 0xff;									\
 		    UN8x4_MUL_UN8_ADD_UN8x4 (d, a2, s2);					\
 		    *dst = CONVERT_8888_TO_ ## DST_FORMAT (d);					\
@@ -1548,7 +1556,7 @@ fast_composite_scaled_nearest_ ## scale_func_name ## _ ## OP (pixman_implementat
 	{											\
 	    x1 = vx >> 16;									\
 	    vx += unit_x;									\
-	    if (do_repeat)									\
+	    if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NORMAL)				\
 	    {											\
 		/* This works because we know that unit_x is positive */			\
 		while (vx >= max_vx)								\
@@ -1567,6 +1575,7 @@ fast_composite_scaled_nearest_ ## scale_func_name ## _ ## OP (pixman_implementat
 		else if (s1)									\
 		{										\
 		    d = CONVERT_## DST_FORMAT ## _TO_8888 (*dst);				\
+		    s1 = CONVERT_ ## SRC_FORMAT ## _TO_8888 (s1);				\
 		    a1 ^= 0xff;									\
 		    UN8x4_MUL_UN8_ADD_UN8x4 (d, a1, s1);					\
 		    *dst = CONVERT_8888_TO_ ## DST_FORMAT (d);					\
@@ -1581,16 +1590,16 @@ fast_composite_scaled_nearest_ ## scale_func_name ## _ ## OP (pixman_implementat
     }												\
 }
 
-FAST_NEAREST(x888_x888_none, 8888, 8888, uint32_t, uint32_t, SRC, /*repeat: */ 0);
-FAST_NEAREST(x888_x888_normal, 8888, 8888, uint32_t, uint32_t, SRC, /*repeat: */ 1);
-FAST_NEAREST(x888_x888_none, 8888, 8888, uint32_t, uint32_t, OVER, /*repeat: */ 0);
-FAST_NEAREST(x888_x888_normal, 8888, 8888, uint32_t, uint32_t, OVER, /*repeat: */ 1);
-FAST_NEAREST(x888_565_none, 8888, 0565, uint32_t, uint16_t, SRC, /*repeat: */ 0);
-FAST_NEAREST(x888_565_normal, 8888, 0565, uint32_t, uint16_t, SRC, /*repeat: */ 1);
-FAST_NEAREST(565_565_none, 0565, 0565, uint16_t, uint16_t, SRC, /*repeat: */ 0);
-FAST_NEAREST(565_565_normal, 0565, 0565, uint16_t, uint16_t, SRC, /*repeat: */ 1);
-FAST_NEAREST(8888_565_none, 8888, 0565, uint32_t, uint16_t, OVER, /*repeat: */ 0);
-FAST_NEAREST(8888_565_normal, 8888, 0565, uint32_t, uint16_t, OVER, /*repeat: */ 1);
+FAST_NEAREST(x888_x888_none, 8888, 8888, uint32_t, uint32_t, SRC, NONE);
+FAST_NEAREST(x888_x888_normal, 8888, 8888, uint32_t, uint32_t, SRC, NORMAL);
+FAST_NEAREST(x888_x888_none, 8888, 8888, uint32_t, uint32_t, OVER, NONE);
+FAST_NEAREST(x888_x888_normal, 8888, 8888, uint32_t, uint32_t, OVER, NORMAL);
+FAST_NEAREST(x888_565_none, 8888, 0565, uint32_t, uint16_t, SRC, NONE);
+FAST_NEAREST(x888_565_normal, 8888, 0565, uint32_t, uint16_t, SRC, NORMAL);
+FAST_NEAREST(565_565_none, 0565, 0565, uint16_t, uint16_t, SRC, NONE);
+FAST_NEAREST(565_565_normal, 0565, 0565, uint16_t, uint16_t, SRC, NORMAL);
+FAST_NEAREST(8888_565_none, 8888, 0565, uint32_t, uint16_t, OVER, NONE);
+FAST_NEAREST(8888_565_normal, 8888, 0565, uint32_t, uint16_t, OVER, NORMAL);
 
 static force_inline uint32_t
 fetch_nearest (pixman_repeat_t src_repeat,
commit 2e7fb6655334789f8a5e290245d47c8d6b221c24
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Sat Jul 10 20:47:01 2010 -0400

    When converting indexed formats to 64 bits, don't correct for channel widths
    
    Indexed formats are mapped to a8r8g8b8 with full precision, so when
    expanding we shouldn't correct for the width of the channels

diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c
index 9708b10..80fa9e8 100644
--- a/pixman/pixman-access.c
+++ b/pixman/pixman-access.c
@@ -2683,12 +2683,26 @@ fetch_scanline_generic_64 (pixman_image_t *image,
                            uint32_t *      buffer,
                            const uint32_t *mask)
 {
+    pixman_format_code_t format;
+    
     /* Fetch the pixels into the first half of buffer and then expand them in
      * place.
      */
     image->bits.fetch_scanline_raw_32 (image, x, y, width, buffer, NULL);
+
+    format = image->bits.format;
+    if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_COLOR	||
+	PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_GRAY)
+    {
+	/* Indexed formats are mapped to a8r8g8b8 with full
+	 * precision, so when expanding we shouldn't correct
+	 * for the width of the channels
+	 */
+	
+	format = PIXMAN_a8r8g8b8;
+    }
     
-    pixman_expand ((uint64_t *)buffer, buffer, image->bits.format, width);
+    pixman_expand ((uint64_t *)buffer, buffer, format, width);
 }
 
 /* Despite the type, this function expects a uint64_t *buffer */
@@ -2699,8 +2713,21 @@ fetch_pixel_generic_64 (bits_image_t *image,
 {
     uint32_t pixel32 = image->fetch_pixel_raw_32 (image, offset, line);
     uint64_t result;
+    pixman_format_code_t format;
+
+    format = image->format;
+    if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_COLOR	||
+	PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_GRAY)
+    {
+	/* Indexed formats are mapped to a8r8g8b8 with full
+	 * precision, so when expanding we shouldn't correct
+	 * for the width of the channels
+	 */
+	
+	format = PIXMAN_a8r8g8b8;
+    }
     
-    pixman_expand ((uint64_t *)&result, &pixel32, image->format, 1);
+    pixman_expand ((uint64_t *)&result, &pixel32, format, 1);
 
     return result;
 }
diff --git a/test/blitters-test.c b/test/blitters-test.c
index 5becada..2c6334a 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -478,6 +478,6 @@ main (int argc, const char *argv[])
     }
 
     return fuzzer_test_main("blitters", 2000000,
-			    0xD0B050B1,
+			    0xD5833506,
 			    test_composite, argc, argv);
 }
commit 2df6dac0be678e1683223faeddadb35b1d2dbe36
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Sat Jul 10 18:40:06 2010 -0400

    test: Make sure the palettes for indexed format roundtrip properly
    
    The palettes for indexed formats must satisfy the condition that if
    some index maps to a color C, then the 15 bit version of that color
    must map back to the index. This ensures that the destination operator
    is always a no-op, which seems like a reasonable assumption to make.

diff --git a/test/blitters-test.c b/test/blitters-test.c
index 2673968..5becada 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -11,7 +11,8 @@
 #include <config.h>
 #include "utils.h"
 
-static pixman_indexed_t palette;
+static pixman_indexed_t rgb_palette[9];
+static pixman_indexed_t y_palette[9];
 
 static void *
 aligned_malloc (size_t align, size_t size)
@@ -66,10 +67,13 @@ 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)
+    if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_COLOR)
     {
-	pixman_image_set_indexed (img, &palette);
+	pixman_image_set_indexed (img, &(rgb_palette[PIXMAN_FORMAT_BPP (fmt)]));
+    }
+    else if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_GRAY)
+    {
+	pixman_image_set_indexed (img, &(y_palette[PIXMAN_FORMAT_BPP (fmt)]));
     }
 
     image_endian_swap (img, PIXMAN_FORMAT_BPP (fmt));
@@ -409,23 +413,71 @@ test_composite (int testnum, int verbose)
     return crc32;
 }
 
+#define CONVERT_15(c, is_rgb)						\
+    (is_rgb?								\
+     ((((c) >> 3) & 0x001f) |						\
+      (((c) >> 6) & 0x03e0) |						\
+      (((c) >> 9) & 0x7c00)) :						\
+     (((((c) >> 16) & 0xff) * 153 +					\
+       (((c) >>  8) & 0xff) * 301 +					\
+       (((c)      ) & 0xff) * 58) >> 2))
+
 static void
-initialize_palette (void)
+initialize_palette (pixman_indexed_t *palette, uint32_t mask, int is_rgb)
 {
     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;
+	palette->ent[i] = lcg_rand() & mask;
+
+    for (i = 0; i < mask + 1; ++i)
+    {
+	uint32_t rgba24;
+ 	pixman_bool_t retry;
+	uint32_t i15;
+
+	/* We filled the rgb->index map with random numbers, but we
+	 * do need the ability to round trip, that is if some indexed
+	 * color expands to an argb24, then the 15 bit version of that
+	 * color must map back to the index. Anything else, we don't
+	 * care about too much.
+	 */
+	do
+	{
+	    uint32_t old_idx;
+	    
+	    rgba24 = lcg_rand();
+	    i15 = CONVERT_15 (rgba24, is_rgb);
+
+	    old_idx = palette->ent[i15];
+	    if (CONVERT_15 (palette->rgba[old_idx], is_rgb) == i15)
+		retry = 1;
+	    else
+		retry = 0;
+	} while (retry);
+	
+	palette->rgba[i] = rgba24;
+	palette->ent[i15] = i;
+    }
+
+    for (i = 0; i < mask + 1; ++i)
+    {
+	assert (palette->ent[CONVERT_15 (palette->rgba[i], is_rgb)] == i);
+    }
 }
 
 int
 main (int argc, const char *argv[])
 {
-    initialize_palette();
+    int i;
+
+    for (i = 1; i <= 8; i++)
+    {
+	initialize_palette (&(rgb_palette[i]), (1 << i) - 1, TRUE);
+	initialize_palette (&(y_palette[i]), (1 << i) - 1, FALSE);
+    }
 
-    return fuzzer_test_main("blitters", 2000000, 0xD09B1C03,
+    return fuzzer_test_main("blitters", 2000000,
+			    0xD0B050B1,
 			    test_composite, argc, argv);
 }


More information about the xorg-commit mailing list