xserver/fb fbcompose.c,1.35,1.36

Billy Biggs xserver-commit at pdx.freedesktop.org
Thu Aug 18 18:43:31 PDT 2005


Committed by: vektor

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

Modified Files:
	fbcompose.c 
Log Message:
	* fb/fbcompose.c: (fbFetchTransformed): Special case projective
	transforms so we can avoid doing the expensive 64-bit math.
	Unroll the bilinear interpolation loops for an extra boost.



Index: fbcompose.c
===================================================================
RCS file: /cvs/xserver/xserver/fb/fbcompose.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- fbcompose.c	11 Aug 2005 01:51:25 -0000	1.35
+++ fbcompose.c	19 Aug 2005 01:43:29 -0000	1.36
@@ -2863,6 +2863,7 @@
     int         i;
     BoxRec	box;
     miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
+    Bool projective = FALSE;
 
     fetch = fetchPixelProcForPicture(pict);
 
@@ -2886,6 +2887,7 @@
         unit.vector[1] = 0;
         unit.vector[2] = 0;
     }
+    projective = (unit.vector[2] != 0);
 
     if (pict->filter == PictFilterNearest)
     {
@@ -2896,8 +2898,13 @@
                     if (!v.vector[2]) {
                         buffer[i] = 0;
                     } else {
-                        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 (projective) {
+                            y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height);
+                            x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width);
+                        } else {
+                            y = MOD(v.vector[1]>>16, pict->pDrawable->height);
+                            x = MOD(v.vector[0]>>16, pict->pDrawable->width);
+                        }
                         buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
                     }
                     v.vector[0] += unit.vector[0];
@@ -2909,8 +2916,13 @@
                     if (!v.vector[2]) {
                         buffer[i] = 0;
                     } else {
-                        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 (projective) {
+                            y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height);
+                            x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width);
+                        } else {
+                            y = MOD(v.vector[1]>>16, pict->pDrawable->height);
+                            x = MOD(v.vector[0]>>16, 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
@@ -2928,8 +2940,13 @@
                     if (!v.vector[2]) {
                         buffer[i] = 0;
                     } else {
-                        y = DIV(v.vector[1],v.vector[2]);
-                        x = DIV(v.vector[0],v.vector[2]);
+                        if (projective) {
+                            y = DIV(v.vector[1],v.vector[2]);
+                            x = DIV(v.vector[0],v.vector[2]);
+                        } else {
+                            y = v.vector[1]>>16;
+                            x = v.vector[0]>>16;
+                        }
                         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);
                     }
@@ -2942,8 +2959,13 @@
                     if (!v.vector[2]) {
                         buffer[i] = 0;
                     } else {
-                        y = DIV(v.vector[1],v.vector[2]);
-                        x = DIV(v.vector[0],v.vector[2]);
+                        if (projective) {
+                            y = DIV(v.vector[1],v.vector[2]);
+                            x = DIV(v.vector[0],v.vector[2]);
+                        } else {
+                            y = v.vector[1]>>16;
+                            x = v.vector[0]>>16;
+                        }
                         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
@@ -2963,19 +2985,27 @@
                     if (!v.vector[2]) {
                         buffer[i] = 0;
                     } else {
-                        int x1, x2, y1, y2, distx, idistx, disty, idisty, k;
+                        int x1, x2, y1, y2, distx, idistx, disty, idisty;
                         FbBits *b;
                         CARD32 tl, tr, bl, br, r;
-                        xFixed_48_16 div;
+                        CARD32 ft, fb;
 
-                        div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
-                        x1 = div >> 16;
-                        distx = ((xFixed)div >> 8) & 0xff;
+                        if (projective) {
+                            xFixed_48_16 div;
+                            div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
+                            x1 = div >> 16;
+                            distx = ((xFixed)div >> 8) & 0xff;
+                            div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
+                            y1 = div >> 16;
+                            disty = ((xFixed)div >> 8) & 0xff;
+                        } else {
+                            x1 = v.vector[0] >> 16;
+                            distx = (v.vector[0] >> 8) & 0xff;
+                            y1 = v.vector[1] >> 16;
+                            disty = (v.vector[1] >> 8) & 0xff;
+                        }
                         x2 = x1 + 1;
-                        div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
-                        y1 = div >> 16;
                         y2 = y1 + 1;
-                        disty = ((xFixed)div >> 8) & 0xff;
 
                         idistx = 256 - distx;
                         idisty = 256 - disty;
@@ -2993,13 +3023,18 @@
                         bl = fetch(b, x1 + pict->pDrawable->x, indexed);
                         br = fetch(b, x2 + pict->pDrawable->x, indexed);
 
-                        r = 0;
-                        for (k = 0; k < 32; k += 8) {
-                            CARD32 t, b;
-                            t = FbGet8(tl,k) * idistx + FbGet8(tr,k) * distx;
-                            b = FbGet8(bl,k) * idistx + FbGet8(br,k) * distx;
-                            r |= ((((t * idisty) + (b * disty)) >> 16) & 0xff) << k;
-                        }
+                        ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+                        fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+                        r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+                        ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+                        fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+                        r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+                        ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+                        fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+                        r |= (((ft * idisty + fb * disty)) & 0xff0000);
+                        ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+                        fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+                        r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
                         buffer[i] = r;
                     }
                     v.vector[0] += unit.vector[0];
@@ -3011,19 +3046,27 @@
                     if (!v.vector[2]) {
                         buffer[i] = 0;
                     } else {
-                        int x1, x2, y1, y2, distx, idistx, disty, idisty, k;
+                        int x1, x2, y1, y2, distx, idistx, disty, idisty;
                         FbBits *b;
                         CARD32 tl, tr, bl, br, r;
-                        xFixed_48_16 div;
+                        CARD32 ft, fb;
 
-                        div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
-                        x1 = div >> 16;
-                        distx = ((xFixed)div >> 8) & 0xff;
+                        if (projective) {
+                            xFixed_48_16 div;
+                            div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
+                            x1 = div >> 16;
+                            distx = ((xFixed)div >> 8) & 0xff;
+                            div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
+                            y1 = div >> 16;
+                            disty = ((xFixed)div >> 8) & 0xff;
+                        } else {
+                            x1 = v.vector[0] >> 16;
+                            distx = (v.vector[0] >> 8) & 0xff;
+                            y1 = v.vector[1] >> 16;
+                            disty = (v.vector[1] >> 8) & 0xff;
+                        }
                         x2 = x1 + 1;
-                        div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
-                        y1 = div >> 16;
                         y2 = y1 + 1;
-                        disty = ((xFixed)div >> 8) & 0xff;
 
                         idistx = 256 - distx;
                         idisty = 256 - disty;
@@ -3045,13 +3088,18 @@
                         br = POINT_IN_REGION(0, pict->pCompositeClip, x2, y2, &box)
                              ? fetch(b, x2 + pict->pDrawable->x, indexed) : 0;
 
-                        r = 0;
-                        for (k = 0; k < 32; k += 8) {
-                            CARD32 t, b;
-                            t = FbGet8(tl,k) * idistx + FbGet8(tr,k) * distx;
-                            b = FbGet8(bl,k) * idistx + FbGet8(br,k) * distx;
-                            r |= ((((t * idisty) + (b * disty)) >> 16) & 0xff) << k;
-                        }
+                        ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+                        fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+                        r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+                        ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+                        fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+                        r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+                        ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+                        fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+                        r |= (((ft * idisty + fb * disty)) & 0xff0000);
+                        ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+                        fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+                        r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
                         buffer[i] = r;
                     }
                     v.vector[0] += unit.vector[0];
@@ -3066,20 +3114,28 @@
                     if (!v.vector[2]) {
                         buffer[i] = 0;
                     } else {
-                        int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off, k;
+                        int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
                         FbBits *b;
                         CARD32 tl, tr, bl, br, r;
                         Bool x1_out, x2_out, y1_out, y2_out;
-                        xFixed_48_16 div;
+                        CARD32 ft, fb;
 
-                        div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
-                        x1 = div >> 16;
-                        distx = ((xFixed)div >> 8) & 0xff;
+                        if (projective) {
+                            xFixed_48_16 div;
+                            div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
+                            x1 = div >> 16;
+                            distx = ((xFixed)div >> 8) & 0xff;
+                            div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
+                            y1 = div >> 16;
+                            disty = ((xFixed)div >> 8) & 0xff;
+                        } else {
+                            x1 = v.vector[0] >> 16;
+                            distx = (v.vector[0] >> 8) & 0xff;
+                            y1 = v.vector[1] >> 16;
+                            disty = (v.vector[1] >> 8) & 0xff;
+                        }
                         x2 = x1 + 1;
-                        div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
-                        y1 = div >> 16;
                         y2 = y1 + 1;
-                        disty = ((xFixed)div >> 8) & 0xff;
 
                         idistx = 256 - distx;
                         idisty = 256 - disty;
@@ -3098,13 +3154,18 @@
                         bl = x1_out|y2_out ? 0 : fetch(b, x_off, indexed);
                         br = x2_out|y2_out ? 0 : fetch(b, x_off + 1, indexed);
 
-                        r = 0;
-                        for (k = 0; k < 32; k += 8) {
-                            CARD32 t, b;
-                            t = FbGet8(tl,k) * idistx + FbGet8(tr,k) * distx;
-                            b = FbGet8(bl,k) * idistx + FbGet8(br,k) * distx;
-                            r |= ((((t * idisty) + (b * disty)) >> 16) & 0xff) << k;
-                        }
+                        ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+                        fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+                        r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+                        ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+                        fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+                        r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+                        ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+                        fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+                        r |= (((ft * idisty + fb * disty)) & 0xff0000);
+                        ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+                        fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+                        r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
                         buffer[i] = r;
                     }
                     v.vector[0] += unit.vector[0];
@@ -3116,19 +3177,27 @@
                     if (!v.vector[2]) {
                         buffer[i] = 0;
                     } else {
-                        int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off, k;
+                        int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
                         FbBits *b;
                         CARD32 tl, tr, bl, br, r;
-                        xFixed_48_16 div;
+                        CARD32 ft, fb;
 
-                        div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
-                        x1 = div >> 16;
-                        distx = ((xFixed)div >> 8) & 0xff;
+                        if (projective) {
+                            xFixed_48_16 div;
+                            div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
+                            x1 = div >> 16;
+                            distx = ((xFixed)div >> 8) & 0xff;
+                            div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
+                            y1 = div >> 16;
+                            disty = ((xFixed)div >> 8) & 0xff;
+                        } else {
+                            x1 = v.vector[0] >> 16;
+                            distx = (v.vector[0] >> 8) & 0xff;
+                            y1 = v.vector[1] >> 16;
+                            disty = (v.vector[1] >> 8) & 0xff;
+                        }
                         x2 = x1 + 1;
-                        div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
-                        y1 = div >> 16;
                         y2 = y1 + 1;
-                        disty = ((xFixed)div >> 8) & 0xff;
 
                         idistx = 256 - distx;
                         idisty = 256 - disty;
@@ -3146,13 +3215,18 @@
                         br = POINT_IN_REGION(0, pict->pCompositeClip, x2, y2, &box)
                              ? fetch(b, x_off + 1, indexed) : 0;
 
-                        r = 0;
-                        for (k = 0; k < 32; k += 8) {
-                            CARD32 t, b;
-                            t = FbGet8(tl,k) * idistx + FbGet8(tr,k) * distx;
-                            b = FbGet8(bl,k) * idistx + FbGet8(br,k) * distx;
-                            r |= ((((t * idisty) + (b * disty)) >> 16) & 0xff) << k;
-                        }
+                        ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+                        fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+                        r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+                        ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+                        fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+                        r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+                        ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+                        fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+                        r |= (((ft * idisty + fb * disty)) & 0xff0000);
+                        ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+                        fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+                        r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
                         buffer[i] = r;
                     }
                     v.vector[0] += unit.vector[0];
@@ -3175,12 +3249,18 @@
                 int x1, x2, y1, y2, x, y;
                 INT32 srtot, sgtot, sbtot, satot;
                 xFixed *p = params;
-                xFixed_48_16 tmp;
-                tmp = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2] - xoff;
-                x1 = xFixedToInt(tmp);
+
+                if (projective) {
+                    xFixed_48_16 tmp;
+                    tmp = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2] - xoff;
+                    x1 = xFixedToInt(tmp);
+                    tmp = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2] - yoff;
+                    y1 = xFixedToInt(tmp);
+                } else {
+                    x1 = xFixedToInt(v.vector[0] - xoff);
+                    y1 = xFixedToInt(v.vector[1] - yoff);
+                }
                 x2 = x1 + cwidth;
-                tmp = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2] - yoff;
-                y1 = xFixedToInt(tmp);
                 y2 = y1 + cheight;
 
                 srtot = sgtot = sbtot = satot = 0;



More information about the xserver-commit mailing list