[PATCH 2/3] EXA: fix exaGetRGBAFromPixel to not loop forever on PICT_a8 pictures

Michel Dänzer michel at daenzer.net
Fri Oct 9 02:31:45 PDT 2009


From: Ben Skeggs <bskeggs at redhat.com>

Easily reproducible by running "rendercheck -t fill".

It should be safe to just test against rbits for all colour components
as we should always have values for r/g/bbits for PICT_FORMAT_COLOR
formats.

Signed-off-by: Ben Skeggs <bskeggs at redhat.com>
Signed-off-by: Michel Dänzer <daenzer at vmware.com>
---
 exa/exa_render.c |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/exa/exa_render.c b/exa/exa_render.c
index 8967d35..db355d6 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -213,22 +213,28 @@ exaGetRGBAFromPixel(CARD32	pixel,
 	FatalError("EXA bug: exaGetRGBAFromPixel() doesn't match "
 		   "createSourcePicture()\n");
 
-    *red = ((pixel >> rshift ) & ((1 << rbits) - 1)) << (16 - rbits);
-    while (rbits < 16) {
-	*red |= *red >> rbits;
-	rbits <<= 1;
-    }
+    if (rbits) {
+	*red = ((pixel >> rshift ) & ((1 << rbits) - 1)) << (16 - rbits);
+	while (rbits < 16) {
+	    *red |= *red >> rbits;
+	    rbits <<= 1;
+	}
 
-    *green = ((pixel >> gshift ) & ((1 << gbits) - 1)) << (16 - gbits);
-    while (gbits < 16) {
-	*green |= *green >> gbits;
-	gbits <<= 1;
-    }
+	*green = ((pixel >> gshift ) & ((1 << gbits) - 1)) << (16 - gbits);
+	while (gbits < 16) {
+	    *green |= *green >> gbits;
+	    gbits <<= 1;
+	}
 
-    *blue = ((pixel >> bshift ) & ((1 << bbits) - 1)) << (16 - bbits);
-    while (bbits < 16) {
-	*blue |= *blue >> bbits;
-	bbits <<= 1;
+	*blue = ((pixel >> bshift ) & ((1 << bbits) - 1)) << (16 - bbits);
+	while (bbits < 16) {
+	    *blue |= *blue >> bbits;
+	    bbits <<= 1;
+	}
+    } else {
+	*red = 0x0000;
+	*green = 0x0000;
+	*blue = 0x0000;
     }
 
     if (abits) {
-- 
1.6.4.3



More information about the xorg-devel mailing list