xserver/fb fbcompose.c,1.33,1.34

Billy Biggs xserver-commit at pdx.freedesktop.org
Tue Aug 2 05:40:36 EST 2005


Committed by: vektor

Update of /cvs/xserver/xserver/fb
In directory gabe:/tmp/cvs-serv15523/fb

Modified Files:
	fbcompose.c 
Log Message:
	reviewed by: keithp

	* fb/fbcompose.c: (fbFetchTransformed): Use a floored divide
	that handles negative numbers correctly when applying
	transforms (Bug #3945).



Index: fbcompose.c
===================================================================
RCS file: /cvs/xserver/xserver/fb/fbcompose.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- fbcompose.c	13 Jul 2005 07:23:55 -0000	1.33
+++ fbcompose.c	1 Aug 2005 19:40:34 -0000	1.34
@@ -2635,6 +2635,8 @@
 }
 
 #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)
@@ -2894,8 +2896,8 @@
                     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];
@@ -2907,8 +2909,8 @@
                     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
@@ -2926,8 +2928,8 @@
                     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);
                     }
@@ -2940,8 +2942,8 @@
                     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



More information about the xserver-commit mailing list