pixman: Branch 'master' - 7 commits

Søren Sandmann Pedersen sandmann at kemper.freedesktop.org
Thu Sep 24 05:11:37 PDT 2009


 pixman/pixman-access.c |  166 +++++++++++++++++++++++++++----------------------
 test/blitters-test.c   |    5 +
 test/composite.c       |    9 +-
 3 files changed, 103 insertions(+), 77 deletions(-)

New commits:
commit 59e877cffe6497d865031d79e9a742414407d544
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Thu Sep 24 08:10:00 2009 -0400

    In the compositing test, Don't try to use component alpha with solid fills.
    
    It's not supported yet.

diff --git a/test/composite.c b/test/composite.c
index f281562..0d4191a 100644
--- a/test/composite.c
+++ b/test/composite.c
@@ -853,10 +853,13 @@ main (void)
 			switch (ca)
 			{
 			case -1:
-			    ok = composite_test (&dst, op, &src, NULL, ca);
+			    ok = composite_test (&dst, op, &src, NULL, FALSE);
 			    break;
-			default:
-			    ok = composite_test (&dst, op, &src, &mask, ca);
+			case 0:
+			    ok = composite_test (&dst, op, &src, &mask, FALSE);
+			case 1:
+			    ok = composite_test (&dst, op, &src, &mask,
+						 mask.size? TRUE : FALSE);
 			    break;
 			}
 			group_ok = group_ok && ok;
commit 16adb09c8a003936a1ef17042776a725c9aa6813
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Fri Sep 18 11:33:18 2009 -0400

    Update CRC value in blitters-test for the new bug fixes

diff --git a/test/blitters-test.c b/test/blitters-test.c
index 6e1c5de..b364845 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -640,7 +640,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 == 0xFE1244BF)
+	    if (crc == 0x481369DE)
 	    {
 		printf ("blitters test passed\n");
 	    }
commit e156964d3e005be3dbc9ff80580d98c6dd617afd
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Fri Sep 18 08:16:56 2009 -0400

    Fix bug in blitters-test with BGRA formats.
    
    When masking out the x bits, blitter-test would make the incorrect
    assumption that the they were always in the topmost position. This is
    not correct for formats of type PIXMAN_TYPE_BGRA.

diff --git a/test/blitters-test.c b/test/blitters-test.c
index 23de6c2..6e1c5de 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -314,6 +314,9 @@ free_random_image (uint32_t initcrc,
 	    uint32_t *data = pixman_image_get_data (img);
 	    uint32_t mask = (1 << PIXMAN_FORMAT_DEPTH (fmt)) - 1;
 
+	    if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_BGRA)
+		mask <<= (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt));
+
 	    for (i = 0; i < 32; i++)
 		mask |= mask << (i * PIXMAN_FORMAT_BPP (fmt));
 
commit eb72bfb97d10283964c070f0a0e26f0520a22ff3
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Fri Sep 18 09:43:14 2009 -0400

    Fix bugs in fetch_*_b2g3r3().
    
    The red channel should only be shifted five positions, not six.

diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c
index 0a48451..389cf2a 100644
--- a/pixman/pixman-access.c
+++ b/pixman/pixman-access.c
@@ -731,23 +731,27 @@ fetch_scanline_b2g3r3 (pixman_image_t *image,
     const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
     const uint8_t *pixel = (const uint8_t *)bits + x;
     const uint8_t *end = pixel + width;
-    
+
     while (pixel < end)
     {
 	uint32_t p = READ (image, pixel++);
 	uint32_t r, g, b;
-	
-	b = (((p & 0xc0)     ) |
-	     ((p & 0xc0) >> 2) |
-	     ((p & 0xc0) >> 4) |
-	     ((p & 0xc0) >> 6));
-	
-	g = ((p & 0x38) | ((p & 0x38) >> 3) | ((p & 0x30) << 2)) << 8;
-	
-	r = (((p & 0x07)     ) |
-	     ((p & 0x07) << 3) |
-	     ((p & 0x06) << 6)) << 16;
-	
+
+	b  = p & 0xc0;
+	b |= b >> 2;
+	b |= b >> 4;
+	b &= 0xff;
+
+	g  = (p & 0x38) << 10;
+	g |= g >> 3;
+	g |= g >> 6;
+	g &= 0xff00;
+
+	r  = (p & 0x7) << 21;
+	r |= r >> 3;
+	r |= r >> 6;
+	r &= 0xff0000;
+
 	*buffer++ = 0xff000000 | r | g | b;
     }
 }
@@ -967,12 +971,12 @@ fetch_scanline_a1b1g1r1 (pixman_image_t *image,
 {
     const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
     int i;
-    
+
     for (i = 0; i < width; ++i)
     {
 	uint32_t p = FETCH_4 (image, bits, i + x);
 	uint32_t a, r, g, b;
-	
+
 	a = ((p & 0x8) * 0xff) << 21;
 	b = ((p & 0x4) * 0xff) >> 2;
 	g = ((p & 0x2) * 0xff) << 7;
@@ -1548,23 +1552,25 @@ fetch_pixel_b2g3r3 (bits_image_t *image,
 		    int           line)
 {
     uint32_t *bits = image->bits + line * image->rowstride;
-    uint32_t pixel = READ (image, (uint8_t *) bits + offset);
+    uint32_t p = READ (image, (uint8_t *) bits + offset);
     uint32_t r, g, b;
-    
-    b = ((pixel & 0xc0)         |
-	 ((pixel & 0xc0) >> 2)  |
-	 ((pixel & 0xc0) >> 4)  |
-	 ((pixel & 0xc0) >> 6));
-    
-    g = ((pixel & 0x38)         |
-	 ((pixel & 0x38) >> 3)  |
-	 ((pixel & 0x30) << 2)) << 8;
-    
-    r = ((pixel & 0x07)         |
-	 ((pixel & 0x07) << 3)  |
-	 ((pixel & 0x06) << 6)) << 16;
-    
-    return (0xff000000 | r | g | b);
+
+    b  = p & 0xc0;
+    b |= b >> 2;
+    b |= b >> 4;
+    b &= 0xff;
+
+    g  = (p & 0x38) << 10;
+    g |= g >> 3;
+    g |= g >> 6;
+    g &= 0xff00;
+
+    r  = (p & 0x7) << 21;
+    r |= r >> 3;
+    r |= r >> 6;
+    r &= 0xff0000;
+
+    return 0xff000000 | r | g | b;
 }
 
 static uint32_t
@@ -1693,7 +1699,7 @@ fetch_pixel_a1b1g1r1 (bits_image_t *image,
     uint32_t *bits = image->bits + line * image->rowstride;
     uint32_t pixel = FETCH_4 (image, bits, offset);
     uint32_t a, r, g, b;
-    
+
     a = ((pixel & 0x8) * 0xff) << 21;
     b = ((pixel & 0x4) * 0xff) >> 2;
     g = ((pixel & 0x2) * 0xff) << 7;
@@ -1710,7 +1716,7 @@ fetch_pixel_c4 (bits_image_t *image,
     uint32_t *bits = image->bits + line * image->rowstride;
     uint32_t pixel = FETCH_4 (image, bits, offset);
     const pixman_indexed_t * indexed = image->indexed;
-    
+
     return indexed->rgba[pixel];
 }
 
commit b4f6113cb975110c33f607aa39d19290f58be398
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Thu Sep 24 07:48:46 2009 -0400

    Fix bugs in a1b2g1r1.
    
    The first bug is that it is treating the input as if it were a1r1g1b1;
    the second one is that the red channel should only be shifted two
    bits, not three.

diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c
index 06b8411..0a48451 100644
--- a/pixman/pixman-access.c
+++ b/pixman/pixman-access.c
@@ -942,16 +942,16 @@ fetch_scanline_a1r1g1b1 (pixman_image_t *image,
     uint32_t a, r, g, b;
     const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
     int i;
-    
+
     for (i = 0; i < width; ++i)
     {
 	uint32_t p = FETCH_4 (image, bits, i + x);
-	
+
 	a = ((p & 0x8) * 0xff) << 21;
 	r = ((p & 0x4) * 0xff) << 14;
 	g = ((p & 0x2) * 0xff) << 7;
 	b = ((p & 0x1) * 0xff);
-	
+
 	*buffer++ = a | r | g | b;
     }
 }
@@ -974,10 +974,10 @@ fetch_scanline_a1b1g1r1 (pixman_image_t *image,
 	uint32_t a, r, g, b;
 	
 	a = ((p & 0x8) * 0xff) << 21;
-	r = ((p & 0x4) * 0xff) >> 3;
+	b = ((p & 0x4) * 0xff) >> 2;
 	g = ((p & 0x2) * 0xff) << 7;
-	b = ((p & 0x1) * 0xff) << 16;
-	
+	r = ((p & 0x1) * 0xff) << 16;
+
 	*buffer++ = a | r | g | b;
     }
 }
@@ -1676,12 +1676,12 @@ fetch_pixel_a1r1g1b1 (bits_image_t *image,
     uint32_t *bits = image->bits + line * image->rowstride;
     uint32_t pixel = FETCH_4 (image, bits, offset);
     uint32_t a, r, g, b;
-    
+
     a = ((pixel & 0x8) * 0xff) << 21;
     r = ((pixel & 0x4) * 0xff) << 14;
     g = ((pixel & 0x2) * 0xff) << 7;
     b = ((pixel & 0x1) * 0xff);
-    
+
     return a | r | g | b;
 }
 
@@ -1695,10 +1695,10 @@ fetch_pixel_a1b1g1r1 (bits_image_t *image,
     uint32_t a, r, g, b;
     
     a = ((pixel & 0x8) * 0xff) << 21;
-    r = ((pixel & 0x4) * 0xff) >> 3;
+    b = ((pixel & 0x4) * 0xff) >> 2;
     g = ((pixel & 0x2) * 0xff) << 7;
-    b = ((pixel & 0x1) * 0xff) << 16;
-    
+    r = ((pixel & 0x1) * 0xff) << 16;
+
     return a | r | g | b;
 }
 
commit efdf15e677d506c2049a34e92eb2172712101afa
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Fri Sep 18 08:48:04 2009 -0400

    Fix shift bug in fetch_scanline/pixel_a2b2g2r2()
    
    0x30 * 0x55 is 0xff0, so the red channel should be shifted four bits,
    not six.

diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c
index 41cd1b6..06b8411 100644
--- a/pixman/pixman-access.c
+++ b/pixman/pixman-access.c
@@ -798,7 +798,7 @@ fetch_scanline_a2b2g2r2 (pixman_image_t *image,
 	uint32_t a, r, g, b;
 	
 	a = ((p & 0xc0) * 0x55) << 18;
-	b = ((p & 0x30) * 0x55) >> 6;
+	b = ((p & 0x30) * 0x55) >> 4;
 	g = ((p & 0x0c) * 0x55) << 6;
 	r = ((p & 0x03) * 0x55) << 16;
 	
@@ -1594,7 +1594,7 @@ fetch_pixel_a2b2g2r2 (bits_image_t *image,
     uint32_t a, r, g, b;
     
     a = ((pixel & 0xc0) * 0x55) << 18;
-    b = ((pixel & 0x30) * 0x55) >> 6;
+    b = ((pixel & 0x30) * 0x55) >> 4;
     g = ((pixel & 0x0c) * 0x55) << 6;
     r = ((pixel & 0x03) * 0x55) << 16;
     
commit 679c2dabda094491599ce770ddba11611d08efc8
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Fri Sep 18 08:13:46 2009 -0400

    Fix four bit formats.
    
    The original Render code used to index pixels with their position in
    bits in the image. When the scanline code was introduced pixels were
    indexed in bytes, but the FETCH/STORE_4/8 macros still assumed bits.
    
    This commit fixes that by making the FETCH/STORE_4 macros first
    convert the index to bit position.

diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c
index d9fd38c..41cd1b6 100644
--- a/pixman/pixman-access.c
+++ b/pixman/pixman-access.c
@@ -180,11 +180,11 @@ fetch_scanline_b8g8r8a8 (pixman_image_t *image,
     const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
     const uint32_t *pixel = (uint32_t *)bits + x;
     const uint32_t *end = pixel + width;
-    
+
     while (pixel < end)
     {
 	uint32_t p = READ (image, pixel++);
-	
+
 	*buffer++ = (((p & 0xff000000) >> 24)	|
 	             ((p & 0x00ff0000) >> 8)	|
 	             ((p & 0x0000ff00) << 8)	|
@@ -840,20 +840,22 @@ fetch_scanline_x4a4 (pixman_image_t *image,
     const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
     const uint8_t *pixel = (const uint8_t *)bits + x;
     const uint8_t *end = pixel + width;
-    
+   
     while (pixel < end)
     {
 	uint8_t p = READ (image, pixel++) & 0xf;
-	
+
 	*buffer++ = (p | (p << 4)) << 24;
     }
 }
 
-#define FETCH_8(img,l,o)    (READ (img, (uint8_t *)(l) + ((o) >> 2)))
+#define FETCH_8(img,l,o)    (READ (img, (((uint8_t *)(l)) + ((o) >> 3))))
 #ifdef WORDS_BIGENDIAN
-#define FETCH_4(img,l,o)    ((o) & 2 ? FETCH_8 (img,l,o) & 0xf : FETCH_8 (img,l,o) >> 4)
+#define FETCH_4(img,l,o)						\
+    (((4 * (o)) & 4) ? (FETCH_8 (img,l, 4 * (o)) & 0xf) : (FETCH_8 (img,l,(4 * (o))) >> 4))
 #else
-#define FETCH_4(img,l,o)    ((o) & 2 ? FETCH_8 (img,l,o) >> 4 : FETCH_8 (img,l,o) & 0xf)
+#define FETCH_4(img,l,o)						\
+    (((4 * (o)) & 4) ? (FETCH_8 (img, l, 4 * (o)) >> 4) : (FETCH_8 (img, l, (4 * (o))) & 0xf))
 #endif
 
 static void
@@ -867,13 +869,13 @@ fetch_scanline_a4 (pixman_image_t *image,
 {
     const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
     int i;
-    
+
     for (i = 0; i < width; ++i)
     {
 	uint32_t p = FETCH_4 (image, bits, i + x);
-	
+
 	p |= p << 4;
-	
+
 	*buffer++ = p << 24;
     }
 }
@@ -923,7 +925,7 @@ fetch_scanline_b1g2r1 (pixman_image_t *image,
 	b = ((p & 0x8) * 0xff) >> 3;
 	g = ((p & 0x6) * 0x55) << 7;
 	r = ((p & 0x1) * 0xff) << 16;
-	
+
 	*buffer++ = 0xff000000 | r | g | b;
     }
 }
@@ -2425,22 +2427,32 @@ store_scanline_x4a4 (bits_image_t *  image,
     uint32_t *bits = image->bits + image->rowstride * y;
     uint8_t   *pixel = ((uint8_t *) bits) + x;
     int i;
-    
+
     for (i = 0; i < width; ++i)
 	WRITE (image, pixel++, values[i] >> 28);
 }
 
 #define STORE_8(img,l,o,v)  (WRITE (img, (uint8_t *)(l) + ((o) >> 3), (v)))
 #ifdef WORDS_BIGENDIAN
-#define STORE_4(img,l,o,v)					    \
-    STORE_8 (img,l,o,((o) & 4 ?					    \
-                      (FETCH_8 (img,l,o) & 0xf0) | (v) :            \
-                      (FETCH_8 (img,l,o) & 0x0f) | ((v) << 4)))
+
+#define STORE_4(img,l,o,v)						\
+    do									\
+    {									\
+	int bo = 4 * (o);						\
+	STORE_8 (img, l, bo, (bo & 4 ?					\
+			      (FETCH_8 (img, l, bo) & 0xf0) | (v) :	\
+			      (FETCH_8 (img, l, bo) & 0x0f) | ((v) << 4))); \
+    } while (0)
 #else
-#define STORE_4(img,l,o,v)					\
-    STORE_8 (img,l,o,((o) & 4 ?					\
-                      (FETCH_8 (img,l,o) & 0x0f) | ((v) << 4) : \
-                      (FETCH_8 (img,l,o) & 0xf0) | (v)))
+
+#define STORE_4(img,l,o,v)						\
+    do									\
+    {									\
+	int bo = 4 * (o);						\
+	STORE_8 (img, l, bo, (bo & 4 ?					\
+			      (FETCH_8 (img, l, bo) & 0x0f) | ((v) << 4) : \
+			      (FETCH_8 (img, l, bo) & 0xf0) | (v)));	\
+    } while (0)
 #endif
 
 static void
@@ -2452,7 +2464,7 @@ store_scanline_a4 (bits_image_t *  image,
 {
     uint32_t *bits = image->bits + image->rowstride * y;
     int i;
-    
+
     for (i = 0; i < width; ++i)
 	STORE_4 (image, bits, i + x, values[i] >> 28);
 }
@@ -2488,11 +2500,11 @@ store_scanline_b1g2r1 (bits_image_t *  image,
 {
     uint32_t *bits = image->bits + image->rowstride * y;
     int i;
-    
+
     for (i = 0; i < width; ++i)
     {
 	uint32_t pixel;
-	
+
 	SPLIT (values[i]);
 	pixel = (((b >> 4) & 0x8) |
 	         ((g >> 5) & 0x6) |
@@ -2510,16 +2522,17 @@ store_scanline_a1r1g1b1 (bits_image_t *  image,
 {
     uint32_t *bits = image->bits + image->rowstride * y;
     int i;
-    
+
     for (i = 0; i < width; ++i)
     {
 	uint32_t pixel;
-	
+
 	SPLIT_A (values[i]);
 	pixel = (((a >> 4) & 0x8) |
 	         ((r >> 5) & 0x4) |
 	         ((g >> 6) & 0x2) |
 	         ((b >> 7)      ));
+
 	STORE_4 (image, bits, i + x, pixel);
     }
 }
@@ -2533,16 +2546,17 @@ store_scanline_a1b1g1r1 (bits_image_t *  image,
 {
     uint32_t *bits = image->bits + image->rowstride * y;
     int i;
-    
+
     for (i = 0; i < width; ++i)
     {
 	uint32_t pixel;
-	
+
 	SPLIT_A (values[i]);
 	pixel = (((a >> 4) & 0x8) |
 	         ((b >> 5) & 0x4) |
 	         ((g >> 6) & 0x2) |
 	         ((r >> 7)      ));
+
 	STORE_4 (image, bits, i + x, pixel);
     }
 }


More information about the xorg-commit mailing list