xserver/fb fbcompose.c,1.24,1.25 fbpict.c,1.36,1.37

Lars Knoll <xserver-commit-u7BhqnqprCWvj1b/[email protected]> Mon, 13 Jun 2005 01:01:01 -0700 (PDT)
Newsgroups gmane.comp.freedesktop.xserver.cvs
Message-ID <[email protected]>
Committed by: lars

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

Modified Files:
	fbcompose.c fbpict.c 
Log Message:
readd the convolution filter that got lost during our move to
the new implementation in fbcompose.


Index: fbcompose.c
===================================================================
RCS file: /cvs/xserver/xserver/fb/fbcompose.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- fbcompose.c	27 May 2005 14:15:13 -0000	1.24
+++ fbcompose.c	13 Jun 2005 08:00:58 -0000	1.25
@@ -49,7 +49,7 @@
 {
     memcpy(buffer, (const CARD32 *)bits + x, width*sizeof(CARD32));
 }
-    
+
 static FASTCALL void
 fbFetch_x8r8g8b8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
 {
@@ -59,7 +59,7 @@
         *buffer++ = *pixel++ | 0xff000000;
     }
 }
-    
+
 static FASTCALL void
 fbFetch_a8b8g8r8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
 {
@@ -72,7 +72,7 @@
         ++pixel;
     }
 }
-    
+
 static FASTCALL void
 fbFetch_x8b8g8r8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
 {
@@ -388,7 +388,7 @@
     int i;
     for (i = 0; i < width; ++i) {
         CARD32  p = Fetch4(bits, i + x);
-    
+
         p |= p << 4;
         *buffer++ = p << 24;
     }
@@ -401,7 +401,7 @@
     for (i = 0; i < width; ++i) {
         CARD32  p = Fetch4(bits, i + x);
         CARD32  r,g,b;
-    
+
         r = ((p & 0x8) * 0xff) << 13;
         g = ((p & 0x6) * 0x55) << 7;
         b = ((p & 0x1) * 0xff);
@@ -416,7 +416,7 @@
     for (i = 0; i < width; ++i) {
         CARD32  p = Fetch4(bits, i + x);
         CARD32  r,g,b;
-    
+
         b = ((p & 0x8) * 0xff) >> 3;
         g = ((p & 0x6) * 0x55) << 7;
         r = ((p & 0x1) * 0xff) << 16;
@@ -431,7 +431,7 @@
     for (i = 0; i < width; ++i) {
         CARD32  p = Fetch4(bits, i + x);
         CARD32  a,r,g,b;
-    
+
         a = ((p & 0x8) * 0xff) << 21;
         r = ((p & 0x4) * 0xff) << 14;
         g = ((p & 0x2) * 0xff) << 7;
@@ -447,7 +447,7 @@
     for (i = 0; i < width; ++i) {
         CARD32  p = Fetch4(bits, i + x);
         CARD32  a,r,g,b;
-    
+
         a = ((p & 0x8) * 0xff) << 21;
         r = ((p & 0x4) * 0xff) >> 3;
         g = ((p & 0x2) * 0xff) << 7;
@@ -462,7 +462,7 @@
     int i;
     for (i = 0; i < width; ++i) {
         CARD32  p = Fetch4(bits, i + x);
-    
+
         *buffer++ = indexed->rgba[p];
     }
 }
@@ -567,7 +567,7 @@
 {
     return ((CARD32 *)bits)[offset];
 }
-    
+
 static FASTCALL CARD32
 fbFetchPixel_x8r8g8b8 (const FbBits *bits, int offset, miIndexedPtr indexed)
 {
@@ -578,24 +578,24 @@
 fbFetchPixel_a8b8g8r8 (const FbBits *bits, int offset, miIndexedPtr indexed)
 {
     CARD32  pixel = ((CARD32 *)bits)[offset];
-    
+
     return ((pixel & 0xff000000) |
 	    ((pixel >> 16) & 0xff) |
 	    (pixel & 0x0000ff00) |
 	    ((pixel & 0xff) << 16));
 }
-    
+
 static FASTCALL CARD32
 fbFetchPixel_x8b8g8r8 (const FbBits *bits, int offset, miIndexedPtr indexed)
 {
     CARD32  pixel = ((CARD32 *)bits)[offset];
-    
+
     return ((0xff000000) |
 	    ((pixel >> 16) & 0xff) |
 	    (pixel & 0x0000ff00) |
 	    ((pixel & 0xff) << 16));
 }
-    
+
 static FASTCALL CARD32
 fbFetchPixel_r8g8b8 (const FbBits *bits, int offset, miIndexedPtr indexed)
 {
@@ -629,7 +629,7 @@
 	    (pixel[2]));
 #endif
 }
-    
+
 static FASTCALL CARD32
 fbFetchPixel_r5g6b5 (const FbBits *bits, int offset, miIndexedPtr indexed)
 {
@@ -653,7 +653,7 @@
     r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
     return (0xff000000 | r | g | b);
 }
- 
+
 static FASTCALL CARD32
 fbFetchPixel_a1r5g5b5 (const FbBits *bits, int offset, miIndexedPtr indexed)
 {
@@ -684,7 +684,7 @@
 {
     CARD32  pixel = ((CARD16 *) bits)[offset];
     CARD32  a,r,g,b;
-    
+
     a = (CARD32) ((CARD8) (0 - ((pixel & 0x8000) >> 15))) << 24;
     b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7;
     g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
@@ -716,19 +716,19 @@
     b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
     return (a | r | g | b);
 }
-    
+
 static FASTCALL CARD32
 fbFetchPixel_x4r4g4b4 (const FbBits *bits, int offset, miIndexedPtr indexed)
 {
     CARD32  pixel = ((CARD16 *) bits)[offset];
     CARD32  r,g,b;
-    
+
     r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12;
     g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
     b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
     return (0xff000000 | r | g | b);
 }
-    
+
 static FASTCALL CARD32
 fbFetchPixel_a4b4g4r4 (const FbBits *bits, int offset, miIndexedPtr indexed)
 {
@@ -753,15 +753,15 @@
     r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
     return (0xff000000 | r | g | b);
 }
-    
+
 static FASTCALL CARD32
 fbFetchPixel_a8 (const FbBits *bits, int offset, miIndexedPtr indexed)
 {
     CARD32   pixel = ((CARD8 *) bits)[offset];
-    
+
     return pixel << 24;
 }
-    
+
 static FASTCALL CARD32
 fbFetchPixel_r3g3b2 (const FbBits *bits, int offset, miIndexedPtr indexed)
 {
@@ -1069,7 +1069,7 @@
                    ((s >> 8) & 0xf800);
     }
 }
-    
+
 static FASTCALL void
 fbStore_b5g6r5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
 {
@@ -1082,7 +1082,7 @@
                     ((r >> 3)         ));
     }
 }
-    
+
 static FASTCALL void
 fbStore_a1r5g5b5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
 {
@@ -1096,7 +1096,7 @@
                     ((b >> 3)         ));
     }
 }
-    
+
 static FASTCALL void
 fbStore_x1r5g5b5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
 {
@@ -1136,7 +1136,7 @@
                     ((r >> 3)         ));
     }
 }
-    
+
 static FASTCALL void
 fbStore_a4r4g4b4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
 {
@@ -1150,7 +1150,7 @@
                     ((b >> 4)         ));
     }
 }
-    
+
 static FASTCALL void
 fbStore_x4r4g4b4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
 {
@@ -1163,7 +1163,7 @@
                     ((b >> 4)         ));
     }
 }
-    
+
 static FASTCALL void
 fbStore_a4b4g4r4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
 {
@@ -1869,28 +1869,28 @@
 {
     fbCombineConjointGeneralU (dest, src, width, CombineAOver);
 }
-    
+
 
 static FASTCALL void
 fbCombineConjointOverReverseU (CARD32 *dest, const CARD32 *src, int width)
 {
     fbCombineConjointGeneralU (dest, src, width, CombineBOver);
 }
-    
+
 
 static FASTCALL void
 fbCombineConjointInU (CARD32 *dest, const CARD32 *src, int width)
 {
     fbCombineConjointGeneralU (dest, src, width, CombineAIn);
 }
-    
+
 
 static FASTCALL void
 fbCombineConjointInReverseU (CARD32 *dest, const CARD32 *src, int width)
 {
     fbCombineConjointGeneralU (dest, src, width, CombineBIn);
 }
-    
+
 static FASTCALL void
 fbCombineConjointOutU (CARD32 *dest, const CARD32 *src, int width)
 {
@@ -1995,7 +1995,7 @@
             mask[i] = x;
             continue;
         }
-    
+
         xa = x >> 24;
         FbByteMulC(x, a);
         src[i] = x;
@@ -2011,7 +2011,7 @@
     for (i = 0; i < width; ++i) {
         CARD32 a = mask[i];
         CARD32	x;
-    
+
         if (!a)
         {
             src[i] = 0;
@@ -2433,7 +2433,7 @@
         CARD16  t, u, v;
         CARD32  sa;
         CARD8   da;
-    
+
         s = src[i];
         sa = mask[i];
         d = dest[i];
@@ -2461,7 +2461,7 @@
             Fa = 0xffffffff;
             break;
         }
-    
+
         switch (combine & CombineB) {
         default:
             Fb = 0;
@@ -2607,14 +2607,14 @@
 
     fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
     bits += yoff*stride + (xoff*bpp >> FB_SHIFT);
-	
+
     color = fetch(bits, 0, indexed);
-	
+
     end = buffer + width;
     while (buffer < end)
         *buffer++ = color;
 }
-  	 
+
 static void fbFetch(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
 {
     FbBits *bits;
@@ -2623,16 +2623,16 @@
     int xoff, yoff;
     fetchProc fetch = fetchProcForPicture(pict);
     miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
-	    
+
     fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
     x += xoff;
     y += yoff;
-		 
+
     bits += y*stride;
 
     fetch(bits, x, width, buffer, indexed);
 }
-	
+
 static void fbFetchTransformed(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
 {
     FbBits     *bits;
@@ -2643,38 +2643,34 @@
     PictVector	v;
     PictVector  unit;
     int         i;
-    int         trans_x, trans_y;
     BoxRec	box;
     miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
-    if (!pict->transform) {
-        fbFetch(pict, x, y, width, buffer);
-        return;
-    }
+
     fetch = fetchPixelProcForPicture(pict);
-	
+
     fbGetDrawable(pict->pDrawable, bits, stride, bpp, xoff, yoff);
     x += xoff;
     y += yoff;
-    trans_x = x - pict->pDrawable->x;
-    trans_y = y - pict->pDrawable->y;
 
     v.vector[0] = IntToxFixed(x - pict->pDrawable->x);
     v.vector[1] = IntToxFixed(y - pict->pDrawable->y);
     v.vector[2] = xFixed1;
-	    
+
     unit.vector[0] = xFixed1;
     unit.vector[1] = 0;
     unit.vector[2] = xFixed1;
 
-    if (!PictureTransformPoint (pict->transform, &v)) {
-        return;
-    }
-    if (!PictureTransformPoint (pict->transform, &unit)) {
-        return;
+    if (pict->transform) {
+        /* when using convolution filters one might get here without a transform */
+        if (!PictureTransformPoint (pict->transform, &v))
+            return;
+
+        if (!PictureTransformPoint (pict->transform, &unit))
+            return;
     }
-		 
+
     if (pict->filter == PictFilterNearest)
-		    {
+    {
         if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
             box = pict->pCompositeClip->extents;
             for (i = 0; i < width; ++i) {
@@ -2683,13 +2679,13 @@
                 y = xFixedToInt (v.vector[1]) + pict->pDrawable->y;
                 x = xFixedToInt (v.vector[0]) + pict->pDrawable->x;
                 if (pict->repeat)
-			{
+                {
                     y = mod (y, pict->pDrawable->height);
                     x = mod (x, pict->pDrawable->width);
-			}
+                }
                 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);
-		    }
+            }
         } else {
             for (i = 0; i < width; ++i) {
                 v.vector[0] += unit.vector[0];
@@ -2707,8 +2703,7 @@
                     buffer[i] = 0;
 	    }
 	}
-    } else if (pict->filter == PictFilterBilinear)
-	{
+    } else if (pict->filter == PictFilterBilinear) {
         if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
             box = pict->pCompositeClip->extents;
             for (i = 0; i < width; ++i) {
@@ -2724,33 +2719,32 @@
                 x2 = x1 + 1;
                 y1 = xFixedToInt(v.vector[1]);
                 y2 = y1 + 1;
-                if (pict->repeat)
-	{
+                if (pict->repeat) {
                     x1 = mod (x1, pict->pDrawable->width);
                     y1 = mod (y1, pict->pDrawable->height);
                     x2 = mod (x2, pict->pDrawable->width);
                     y2 = mod (y2, pict->pDrawable->height);
-	}
-	
+                }
+
                 distx = ((v.vector[0] - (x1 << 16)) >> 8);
                 disty = ((v.vector[1] - (y1 << 16)) >> 8);
                 idistx = 256 - distx;
                 idisty = 256 - disty;
-	
+
                 b = bits + (y1 - pict->pDrawable->y)*stride;
                 x_off = x1 - pict->pDrawable->x;
-  	 
+
                 x1_out = (x1 < box.x1) | (x1 > box.x2);
                 x2_out = (x2 < box.x1) | (x2 > box.x2);
                 y1_out = (y1 < box.y1) | (y1 > box.y2);
                 y2_out = (y2 < box.y1) | (y2 > box.y2);
-	    
+
                 tl = x1_out|y1_out ? 0 : fetch(b, x_off, indexed);
                 tr = x2_out|y1_out ? 0 : fetch(b, x_off + 1, indexed);
                 b += stride;
                 bl = x1_out|y2_out ? 0 : fetch(b, x_off, indexed);
                 br = x2_out|y2_out ? 0 : fetch(b, x_off + 1, indexed);
-		 
+
                 FbByteAddMul_256(tl, idistx, tr, distx);
                 FbByteAddMul_256(bl, idistx, br, distx);
                 FbByteAddMul_256(tl, idisty, bl, disty);
@@ -2764,13 +2758,13 @@
 
                 v.vector[0] += unit.vector[0];
                 v.vector[1] += unit.vector[1];
-	
+
                 x1 = xFixedToInt(v.vector[0]);
                 x2 = x1 + 1;
                 y1 = xFixedToInt(v.vector[1]);
                 y2 = y1 + 1;
                 if (pict->repeat)
-	{
+                {
                     x1 = mod (x1, pict->pDrawable->width);
                     y1 = mod (y1, pict->pDrawable->height);
                     x2 = mod (x2, pict->pDrawable->width);
@@ -2781,10 +2775,10 @@
                 disty = ((v.vector[1] - (y1 << 16)) >> 8);
                 idistx = 256 - distx;
                 idisty = 256 - disty;
-	    
+
                 b = bits + (y1 - pict->pDrawable->y)*stride;
                 x_off = x1 - pict->pDrawable->x;
-		 
+
                 tl = POINT_IN_REGION(0, pict->pCompositeClip, x1, y1, &box)
                      ? fetch(b, x_off, indexed) : 0;
                 tr = POINT_IN_REGION(0, pict->pCompositeClip, x2, y1, &box)
@@ -2794,17 +2788,75 @@
                      ? fetch(b, x_off, indexed) : 0;
                 br = POINT_IN_REGION(0, pict->pCompositeClip, x2, y2, &box)
                      ? fetch(b, x_off + 1, indexed) : 0;
-			    
+
                 FbByteAddMul_256(tl, idistx, tr, distx);
                 FbByteAddMul_256(bl, idistx, br, distx);
                 FbByteAddMul_256(tl, idisty, bl, disty);
                 buffer[i] = tl;
-		}
-	    }
-	}
+            }
+        }
+    } else if (pict->filter == PictFilterConvolution) {
+        xFixed *params = pict->filter_params;
+        INT32 cwidth = xFixedToInt(params[0]);
+        INT32 cheight = xFixedToInt(params[1]);
+        v.vector[0] -= params[0] >> 2;
+        v.vector[1] -= params[1] >> 2;
+        params += 2;
+        for (i = 0; i < width; ++i) {
+            int x1, x2, y1, y2, x, y;
+            INT32 srtot, sgtot, sbtot, satot, sum;
+            xFixed *p = params;
+
+            v.vector[0] += unit.vector[0];
+            v.vector[1] += unit.vector[1];
+
+            x1 = xFixedToInt(v.vector[0]);
+            x2 = x1 + cwidth;
+            y1 = xFixedToInt(v.vector[1]);
+            y2 = y1 + cheight;
+
+            srtot = sgtot = sbtot = satot = sum = 0;
+
+            for (y = y1; y < y2; y++) {
+                int ty = (pict->repeat) ? mod (y, pict->pDrawable->height) : y;
+                for (x = x1; x < x2; x++) {
+                    if (*params) {
+                        int tx = (pict->repeat) ? mod (x, pict->pDrawable->width) : x;
+                        if (POINT_IN_REGION (0, pict->pCompositeClip, tx, ty, &box)) {
+                            FbBits *b = bits + (ty - pict->pDrawable->y)*stride;
+                            CARD32 c = fetch(b, tx - pict->pDrawable->x, indexed);
+
+                            srtot += Red(c) * *p;
+                            sgtot += Green(c) * *p;
+                            sbtot += Blue(c) * *p;
+                            satot += Alpha(c) * *p;
+                        }
+                        sum += *p;
+                    }
+                    p++;
+                }
+            }
+
+            if (sum) {
+                satot /= sum;
+                srtot /= sum;
+                sgtot /= sum;
+                sbtot /= sum;
+            }
+            if (satot < 0) satot = 0; else if (satot > 0xff) satot = 0xff;
+            if (srtot < 0) srtot = 0; else if (srtot > 0xff) srtot = 0xff;
+            if (sgtot < 0) sgtot = 0; else if (sgtot > 0xff) sgtot = 0xff;
+            if (sbtot < 0) sbtot = 0; else if (sbtot > 0xff) sbtot = 0xff;
+
+            buffer[i] = ((satot << 24) |
+                         (srtot << 16) |
+                         (sgtot <<  8) |
+                         (sbtot       ));
+        }
+    }
 }
 
-	
+
 static void fbFetchExternalAlpha(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
 {
     int i;
@@ -2899,6 +2951,8 @@
         fetchSrc = fbFetchExternalAlpha;
     else if (data->src->repeat && data->src->pDrawable->width == 1 && data->src->pDrawable->height == 1)
         fetchSrc = fbFetchSolid;
+    else if (!data->src->transform && data->src->filter != PictFilterConvolution)
+        fetchSrc = fbFetch;
     else
         fetchSrc = fbFetchTransformed;
 
@@ -2907,6 +2961,8 @@
             fetchMask = fbFetchExternalAlpha;
         else if (data->mask->repeat && data->mask->pDrawable->width == 1 && data->mask->pDrawable->height == 1)
             fetchMask = fbFetchSolid;
+        else if (!data->mask->transform && data->src->filter != PictFilterConvolution)
+            fetchMask = fbFetch;
         else
             fetchMask = fbFetchTransformed;
     } else {
@@ -2950,7 +3006,7 @@
         CombineFuncU compose = combineFuncU[data->op];
         if (!compose)
             return;
-	
+
         if (fetchSrc == fbFetchSolid && (!fetchMask || fetchMask == fbFetchSolid)) {
             fetchSrc(data->src, data->xSrc, data->ySrc, data->width, src_buffer);
             if (fetchMask) {
@@ -3095,7 +3151,7 @@
 	pbox++;
     }
     REGION_UNINIT (pDst->pDrawable->pScreen, &region);
-	
+
     if (scanline_buffer != _scanline_buffer)
         free(scanline_buffer);
 }

Index: fbpict.c
===================================================================
RCS file: /cvs/xserver/xserver/fb/fbpict.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- fbpict.c	27 May 2005 14:15:13 -0000	1.36
+++ fbpict.c	13 Jun 2005 08:00:58 -0000	1.37
@@ -17,7 +17,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Author:  Keith Packard, SuSE, Inc.
@@ -144,7 +144,7 @@
 	#define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y=*z++; } where=(y)&0xff; (y)>>=8; (x)--;}
 	#define readPackedSource(where) readPacked(where,ws,workingSource,wsrc)
 	#define readPackedDest(where) readPacked(where,wd,workingiDest,widst)
-	#define writePacked(what) workingoDest>>=8; workingoDest|=(what<<24); ww--; if(!ww) { ww=4; *wodst++=workingoDest; } 
+	#define writePacked(what) workingoDest>>=8; workingoDest|=(what<<24); ww--; if(!ww) { ww=4; *wodst++=workingoDest; }
 #else
 	#warning "I havn't tested fbCompositeTrans_0888xnx0888() on big endian yet!"
 	#define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(long)where; \
@@ -157,7 +157,7 @@
 	#define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y=*z++; } where=(y)>>24; (y)<<=8; (x)--;}
 	#define readPackedSource(where) readPacked(where,ws,workingSource,wsrc)
 	#define readPackedDest(where) readPacked(where,wd,workingiDest,widst)
-	#define writePacked(what) workingoDest<<=8; workingoDest|=what; ww--; if(!ww) { ww=4; *wodst++=workingoDest; } 
+	#define writePacked(what) workingoDest<<=8; workingoDest|=what; ww--; if(!ww) { ww=4; *wodst++=workingoDest; }
 #endif
 /*
  * Naming convention:
@@ -186,15 +186,15 @@
     CARD16	w;
 
     fbComposeGetSolid(pSrc, src);
-    
+
     dstMask = FbFullMask (pDst->pDrawable->depth);
     srca = src >> 24;
     if (src == 0)
 	return;
-    
+
     fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
     fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
-	
+
     while (height--)
     {
 	dst = dstLine;
@@ -245,15 +245,15 @@
     CARD32	m, n, o, p;
 
     fbComposeGetSolid(pSrc, src);
-    
+
     dstMask = FbFullMask (pDst->pDrawable->depth);
     srca = src >> 24;
     if (src == 0)
 	return;
-    
+
     fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
     fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
-    
+
     while (height--)
     {
 	dst = dstLine;
@@ -319,7 +319,7 @@
 	CARD32 rs,gs,bs,rd,gd,bd;
 
     fbComposeGetSolid(pSrc, src);
-    
+
     srca = src >> 24;
     srcia = 255-srca;
     if (src == 0)
@@ -328,7 +328,7 @@
 	rs=src&0xff;
 	gs=(src>>8)&0xff;
 	bs=(src>>16)&0xff;
-    
+
     fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
     fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
 
@@ -338,17 +338,17 @@
 		unsigned long wt,wd;
 		CARD32 workingiDest;
 		CARD32 *widst;
-		
+
 		edst=dst = dstLine;
 		dstLine += dstStride;
 		mask = maskLine;
 		maskLine += maskStride;
 		w = width;
-		
+
 #ifndef NO_MASKED_PACKED_READ
 		setupPackedReader(wd,wt,edst,widst,workingiDest);
 #endif
-				
+
 		while (w--)
 		{
 #ifndef NO_MASKED_PACKED_READ
@@ -418,12 +418,12 @@
 
     if (src == 0)
 	return;
-    
+
     srca8 = (src >> 24);
     srca5 = (srca8 >> 3);
 
     src16 = cvt8888to0565(src);
-    
+
     fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
     fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
 
@@ -444,7 +444,7 @@
 	    {
 		if (m == 0xff)
 		    *dst++ = src16;
-		else 
+		else
 		{
 		    d = *dst;
 		    m >>= 3;
@@ -454,7 +454,7 @@
 	    else
 	    {
 		d = *dst;
-		if (m == 0xff) 
+		if (m == 0xff)
 		{
 		    t = fbOver24 (src, cvt0565to0888 (d));
 		}
@@ -530,7 +530,7 @@
 	    }
 	    else
 	    {
-		if (m == 0xff) 
+		if (m == 0xff)
 		{
 		    d = *dst;
 		    t = fbOver24 (src, cvt0565to0888 (d));
@@ -572,16 +572,16 @@
     CARD32	m, n, o;
 
     fbComposeGetSolid(pSrc, src);
-    
+
     srca = src >> 24;
     if (src == 0)
 	return;
-    
+
     src16 = cvt8888to0565(src);
-    
+
     fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
     fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
-    
+
     while (height--)
     {
 	dst = dstLine;
@@ -640,10 +640,10 @@
     FbStride	dstStride, srcStride;
     CARD8	a;
     CARD16	w;
-    
+
     fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
     fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
-    
+
     dstMask = FbFullMask (pDst->pDrawable->depth);
 
     while (height--)
@@ -687,10 +687,10 @@
     CARD8	a;
     FbStride	dstStride, srcStride;
     CARD16	w;
-    
+
     fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
     fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
-    
+
     while (height--)
     {
 	dst = dstLine;
@@ -736,7 +736,7 @@
     CARD8	a;
     FbStride	dstStride, srcStride;
     CARD16	w;
-    
+
     fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
     fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
 
@@ -788,7 +788,7 @@
     CARD16	w;
     CARD8	s, d;
     CARD16	t;
-    
+
     fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 1);
     fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1);
 
@@ -839,7 +839,7 @@
     CARD32	s, d;
     CARD16	t;
     CARD32	m,n,o,p;
-    
+
     fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
     fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
 
@@ -894,7 +894,7 @@
     int		dstBpp, srcBpp;
     int		dstXoff, dstYoff;
     int		srcXoff, srcYoff;
-    
+
     fbGetDrawable(pSrc->pDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff);
 
     fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff);
@@ -945,7 +945,7 @@
     if ((src & 0xff000000) != 0xff000000)
     {
 	fbCompositeGeneral  (op, pSrc, pMask, pDst,
-			     xSrc, ySrc, xMask, yMask, xDst, yDst, 
+			     xSrc, ySrc, xMask, yMask, xDst, yDst,
 			     width, height);
 	return;
     }
@@ -1008,16 +1008,16 @@
     CARD8	maskAlpha;
     CARD16	s_16, d_16;
     CARD32	s_32, d_32;
-    
+
     fbComposeGetSolid (pMask, mask);
     maskAlpha = mask >> 27;
-    
+
     if (!maskAlpha)
 	return;
     if (maskAlpha == 0xff)
     {
 	fbCompositeSrcSrc_nxn (PictOpSrc, pSrc, pMask, pDst,
-			       xSrc, ySrc, xMask, yMask, xDst, yDst, 
+			       xSrc, ySrc, xMask, yMask, xDst, yDst,
 			       width, height);
 	return;
     }
@@ -1033,7 +1033,7 @@
 		src = srcLine;
 		srcLine += srcStride;
 		w = width;
-		
+
 		if(((long)src&1)==1)
 		{
 			s_16 = *src++;
@@ -1110,23 +1110,23 @@
     CARD16	w;
     FbBits	mask;
     CARD16	maskAlpha,maskiAlpha;
-    
+
     fbComposeGetSolid (pMask, mask);
     maskAlpha = mask >> 24;
 	maskiAlpha= 255-maskAlpha;
-    
+
     if (!maskAlpha)
 	return;
     /*
     if (maskAlpha == 0xff)
     {
 	fbCompositeSrc_0888x0888 (op, pSrc, pMask, pDst,
-				  xSrc, ySrc, xMask, yMask, xDst, yDst, 
+				  xSrc, ySrc, xMask, yMask, xDst, yDst,
 				  width, height);
 	return;
     }
     */
-	
+
     fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 3);
     fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
 
@@ -1148,7 +1148,7 @@
 				isrc = src = srcLine;
 				srcLine += srcStride;
 				w = width*3;
-				
+
 				setupPackedReader(ws,wt,isrc,wsrc,workingSource);
 
 				/* get to word aligned */
@@ -1162,19 +1162,19 @@
 						w--; if(w==0) break;
 					case 2:
 						readPackedSource(rs);
-						rd=*dst;  
+						rd=*dst;
 						*dst++=alphamaskCombine24(rs, rd)>>8;
 						w--; if(w==0) break;
 					case 3:
 						readPackedSource(rs);
-						rd=*dst;  
+						rd=*dst;
 						*dst++=alphamaskCombine24(rs, rd)>>8;
 						w--; if(w==0) break;
 				}
 				wdst=(CARD32 *)dst;
 				while (w>3)
 				{
-					/* FIXME: write a special readPackedWord macro, which knows how to 
+					/* FIXME: write a special readPackedWord macro, which knows how to
 					 * halfword combine
 					 */
 
@@ -1205,15 +1205,15 @@
 				{
 					case 3:
 						readPackedSource(rs);
-						rd=*dst;  
+						rd=*dst;
 						*dst++=alphamaskCombine24(rs, rd)>>8;
 					case 2:
 						readPackedSource(rs);
-						rd=*dst;  
+						rd=*dst;
 						*dst++=alphamaskCombine24(rs, rd)>>8;
 					case 1:
 						readPackedSource(rs);
-						rd=*dst;  
+						rd=*dst;
 						*dst++=alphamaskCombine24(rs, rd)>>8;
 				}
 			}
@@ -1299,7 +1299,7 @@
     int		dstBpp;
     Bool	reverse = FALSE;
     Bool	upsidedown = FALSE;
-    
+
     fbGetDrawable(pSrc->pDrawable,src,srcStride,srcBpp,srcXoff,srcYoff);
     fbGetDrawable(pDst->pDrawable,dst,dstStride,dstBpp,dstXoff,dstYoff);
 
@@ -1338,7 +1338,7 @@
 			  CARD16     width,
 			  CARD16     height)
 {
-    
+
 }
  */
 
@@ -1381,7 +1381,7 @@
 	pSrc->pDrawable->width == 1 &&
 	pSrc->pDrawable->height == 1)
 	srcTransform = FALSE;
-    
+
     if (pMask)
     {
 	xMask += pMask->pDrawable->x;
@@ -1390,7 +1390,7 @@
 	maskTransform = pMask->transform != 0;
 	if (pMask->filter == PictFilterConvolution)
 	    maskTransform = TRUE;
-	
+
 	maskAlphaMap = pMask->alphaMap != 0;
 
 	if (maskRepeat && maskTransform &&
@@ -1398,14 +1398,16 @@
 	    pMask->pDrawable->height == 1)
 	    maskTransform = FALSE;
     }
-    
-    if (!srcTransform && !maskTransform)
-    if (!maskAlphaMap && !srcAlphaMap && !dstAlphaMap)
+
+    if (!srcTransform && !maskTransform
+        && !maskAlphaMap && !srcAlphaMap && !dstAlphaMap
+        && (pSrc->filter != PictFilterConvolution)
+        && (!pMask || pMask->filter != PictFilterConvolution))
     switch (op) {
     case PictOpOver:
 	if (pMask)
 	{
-	    if (srcRepeat && 
+	    if (srcRepeat &&
 		pSrc->pDrawable->width == 1 &&
 		pSrc->pDrawable->height == 1)
 	    {
@@ -1574,7 +1576,7 @@
 		    }
 		    break;
 		}
-		else 
+		else
 		{
 		    /* non-repeating source, repeating mask => translucent window */
 		    if (maskRepeat &&
@@ -1613,7 +1615,7 @@
 			    break;
 #endif
 			}
-				    
+
                         if (func != 0)
 			    maskRepeat = FALSE;
 		    }
@@ -1622,7 +1624,7 @@
 	}
 	else /* no mask */
 	{
-	    if (srcRepeat && 
+	    if (srcRepeat &&
 		pSrc->pDrawable->width == 1 &&
 		pSrc->pDrawable->height == 1)
 	    {
@@ -1755,7 +1757,7 @@
 	if (pMask)
 	  {
 #ifdef USE_MMX
-	    if (srcRepeat && 
+	    if (srcRepeat &&
 		pSrc->pDrawable->width == 1 &&
 		pSrc->pDrawable->height == 1)
 	    {
@@ -1782,7 +1784,7 @@
 		if (pSrc->pDrawable != pDst->pDrawable)
 		    func = fbCompositeCopyAreammx;
 		else
-#endif		    
+#endif
 		    func = fbCompositeSrcSrc_nxn;
 	    }
 	}
@@ -1800,7 +1802,7 @@
 	srcRepeat = 0;
     if (maskTransform)
 	maskRepeat = 0;
-    
+
 
     if (!miComputeCompositeRegion (&region,
 				   pSrc,
@@ -1858,7 +1860,7 @@
 			w_this = pSrc->pDrawable->width - x_src;
 		}
 		(*func) (op, pSrc, pMask, pDst,
-			 x_src, y_src, x_msk, y_msk, x_dst, y_dst, 
+			 x_src, y_src, x_msk, y_msk, x_dst, y_dst,
 			 w_this, h_this);
 		w -= w_this;
 		x_src += w_this;