From e1719889ff95234a20e93be67b8e4e1f7b0d1003 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 13 Aug 2010 14:40:59 -0400 Subject: [PATCH] fb: Fix clip computation sign bug Once you account for drawable offset you're dealing with uint16 instead of sint16, which means the clever math in isClipped() will do the wrong thing. Signed-off-by: Adam Jackson --- fb/fbbits.h | 11 ++++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fb/fbbits.h b/fb/fbbits.h index 8bf1a02..65a6ea5 100644 --- a/fb/fbbits.h +++ b/fb/fbbits.h @@ -25,7 +25,12 @@ * underlying datatypes instead of masks */ -#define isClipped(c,ul,lr) ((((c) - (ul)) | ((lr) - (c))) & 0x80008000) +#define isClipped(c, ul, lr) \ + ((c & 0x80008000) || \ + (intToX(c) < intToX(ul)) || \ + (intToX(c) > intToX(lr)) || \ + (intToY(c) < intToY(ul)) || \ + (intToY(c) > intToY(lr))) #ifdef HAVE_DIX_CONFIG_H #include @@ -705,7 +710,7 @@ POLYLINE (DrawablePtr pDrawable, npt--; for (;;) { - if (isClipped (pt1, ul, lr) | isClipped (pt2, ul, lr)) + if (isClipped (pt1, ul, lr) || isClipped (pt2, ul, lr)) { fbSegment (pDrawable, pGC, intToX(pt1) + xoff, intToY(pt1) + yoff, @@ -842,7 +847,7 @@ POLYSEGMENT (DrawablePtr pDrawable, { pt1 = *pts++; pt2 = *pts++; - if (isClipped (pt1, ul, lr) | isClipped (pt2, ul, lr)) + if (isClipped (pt1, ul, lr) || isClipped (pt2, ul, lr)) { fbSegment (pDrawable, pGC, intToX(pt1) + xoff, intToY(pt1) + yoff, -- 1.7.2.1