rendercheck: tests.c

Eric Anholt anholt at kemper.freedesktop.org
Fri Jan 12 02:39:40 EET 2007


 tests.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

New commits:
diff-tree 2ae83b5c2783dbce9523ce030a50596eb6804c2b (from f5395a5866c4947dbfc30b8845f9400a422990ce)
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Jan 11 16:36:48 2007 -0800

    Bug #9485: Fix a sign-extension issue on 64-bit platforms in pixel fetching.
    
    The result was that 32bpp pictures with a field including the top bit would
    result in get_pixel returning a zero in that channel.
    
    While I'm here, also fix the fact that we weren't using XGetPixel to fetch the
    pixel, which would have likely caused problems on big-endian systems.

diff --git a/tests.c b/tests.c
index 4db1413..ced755a 100644
--- a/tests.c
+++ b/tests.c
@@ -118,15 +118,16 @@ get_pixel(Display *dpy, picture_info *pi
 	XImage *image;
 	unsigned long val;
 	unsigned long rm, gm, bm, am;
+	XRenderDirectFormat *layout = &pi->format->direct;
 
 	image = XGetImage(dpy, pi->d, x, y, 1, 1, 0xffffffff, ZPixmap);
 
-	val = *(unsigned long *)image->data;
+	val = XGetPixel(image, 0, 0);
 
-	rm = pi->format->direct.redMask << pi->format->direct.red;
-	gm = pi->format->direct.greenMask << pi->format->direct.green;
-	bm = pi->format->direct.blueMask << pi->format->direct.blue;
-	am = pi->format->direct.alphaMask << pi->format->direct.alpha;
+	rm = (unsigned long)layout->redMask << layout->red;
+	gm = (unsigned long)layout->greenMask << layout->green;
+	bm = (unsigned long)layout->blueMask << layout->blue;
+	am = (unsigned long)layout->alphaMask << layout->alpha;
 	if (am != 0)
 		color->a = (double)(val & am) / (double)am;
 	else



More information about the xorg-commit mailing list