diff options
author | Søren Sandmann Pedersen <sandmann@daimi.au.dk> | 2005-08-12 18:31:07 +0000 |
---|---|---|
committer | Søren Sandmann Pedersen <sandmann@daimi.au.dk> | 2005-08-12 18:31:07 +0000 |
commit | 8bfffb96b552a3facb77ff9e81658e80becbf2f4 (patch) | |
tree | 9ff1423605b31793537eeec7d983f8cd2aea79dd /fb | |
parent | 812ed2e17bfe8e232313cf9ab78000a564cb6b3c (diff) |
Fri Aug 12 14:29:09 2005 Søren Sandmann <sandmann@redhat.com>
Apply patch from Billy Biggs that fixes rounding problems with division.
Part of bug 3945.
Diffstat (limited to 'fb')
-rw-r--r-- | fb/fbcompose.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/fb/fbcompose.c b/fb/fbcompose.c index 0e455b437..73ae67357 100644 --- a/fb/fbcompose.c +++ b/fb/fbcompose.c @@ -2639,6 +2639,8 @@ static void fbFetch(PicturePtr pict, int x, int y, int width, CARD32 *buffer) } #define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b)) +#define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) :\ + ((a) - (b) + 1 - (((b) < 0) << 1)) / (b)) static CARD32 gradientPixel(const SourcePictPtr pGradient, xFixed_48_16 pos, unsigned int spread) @@ -2898,8 +2900,8 @@ static void fbFetchTransformed(PicturePtr pict, int x, int y, int width, CARD32 if (!v.vector[2]) { buffer[i] = 0; } else { - y = MOD((v.vector[1]/v.vector[2]), pict->pDrawable->height); - x = MOD((v.vector[0]/v.vector[2]), pict->pDrawable->width); + y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height); + x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width); buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed); } v.vector[0] += unit.vector[0]; @@ -2911,8 +2913,8 @@ static void fbFetchTransformed(PicturePtr pict, int x, int y, int width, CARD32 if (!v.vector[2]) { buffer[i] = 0; } else { - y = MOD((v.vector[1]/v.vector[2]), pict->pDrawable->height); - x = MOD((v.vector[0]/v.vector[2]), pict->pDrawable->width); + y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height); + x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width); if (POINT_IN_REGION (0, pict->pCompositeClip, x, y, &box)) buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed); else @@ -2930,8 +2932,8 @@ static void fbFetchTransformed(PicturePtr pict, int x, int y, int width, CARD32 if (!v.vector[2]) { buffer[i] = 0; } else { - y = (v.vector[1]/v.vector[2]); - x = (v.vector[0]/v.vector[2]); + y = DIV(v.vector[1],v.vector[2]); + x = DIV(v.vector[0],v.vector[2]); buffer[i] = ((x < box.x1) | (x >= box.x2) | (y < box.y1) | (y >= box.y2)) ? 0 : fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed); } @@ -2944,8 +2946,8 @@ static void fbFetchTransformed(PicturePtr pict, int x, int y, int width, CARD32 if (!v.vector[2]) { buffer[i] = 0; } else { - y = (v.vector[1]/v.vector[2]); - x = (v.vector[0]/v.vector[2]); + y = DIV(v.vector[1],v.vector[2]); + x = DIV(v.vector[0],v.vector[2]); if (POINT_IN_REGION (0, pict->pCompositeClip, x, y, &box)) buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed); else |