xserver/render filter.c,1.4,1.5 mipict.c,1.22,1.23

David Reveman xserver-commit@pdx.freedesktop.org
Wed Jan 26 02:20:18 PST 2005


Committed by: davidr

Update of /cvs/xserver/xserver/render
In directory gabe:/tmp/cvs-serv24446/render

Modified Files:
	filter.c mipict.c 
Log Message:
Add transform+repeat and convolution filter support

Index: filter.c
===================================================================
RCS file: /cvs/xserver/xserver/render/filter.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- filter.c	4 Nov 2004 22:56:40 -0000	1.4
+++ filter.c	26 Jan 2005 10:20:16 -0000	1.5
@@ -264,10 +264,16 @@
 
     if (nparams != pPicture->filter_nparams)
     {
-	new_params = xalloc (nparams * sizeof (xFixed));
-	if (!new_params)
-	    return BadAlloc;
-	xfree (pPicture->filter_params);
+	if (nparams)
+	{
+	    new_params = xalloc (nparams * sizeof (xFixed));
+	    if (!new_params)
+		return BadAlloc;
+	} else
+	    new_params = NULL;
+	
+	if (pPicture->filter_nparams)
+	    xfree (pPicture->filter_params);
 	pPicture->filter_params = new_params;
 	pPicture->filter_nparams = nparams;
     }

Index: mipict.c
===================================================================
RCS file: /cvs/xserver/xserver/render/mipict.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- mipict.c	26 Jan 2005 00:20:27 -0000	1.22
+++ mipict.c	26 Jan 2005 10:20:16 -0000	1.23
@@ -264,6 +264,36 @@
     return Success;
 }
 
+Bool
+miFilterValidateParams (PicturePtr pPicture,
+			int	   filter,
+			xFixed	   *params,
+			int	   nparams)
+{
+    switch (filter) {
+    case PictFilterNearest:
+    case PictFilterFast:
+    case PictFilterGood:
+    case PictFilterBest:
+    case PictFilterBilinear:
+	break;
+    case PictFilterConvolution:
+	if (nparams < 3)
+	    return FALSE;
+	
+	if (xFixedFrac (params[0]) || xFixedFrac (params[1]))
+	    return FALSE;
+
+	nparams -= 2;
+	if ((xFixedToInt (params[0]) * xFixedToInt (params[1])) > nparams)
+	    return FALSE;
+	
+	break;
+    } 
+    
+    return TRUE;
+}
+
 #define BOUND(v)	(INT16) ((v) < MINSHORT ? MINSHORT : (v) > MAXSHORT ? MAXSHORT : (v))
 
 static __inline Bool
@@ -316,6 +346,12 @@
     /* XXX what to do with clipping from transformed pictures? */
     if (pPicture->transform)
 	return TRUE;
+    
+    /* XXX what to do with clipping from pictures with filter that touch
+       pixels outside the drawable? */
+    if (pPicture->filter == PictFilterConvolution)
+	return TRUE;
+    
     if (pPicture->repeat)
     {
 	if (pPicture->clientClipType != CT_NONE)
@@ -389,6 +425,21 @@
 	    width = xmax - xmin;
 	    height = ymax - ymin;
 	}
+	if (pPicture->filter == PictFilterConvolution)
+	{
+	    if (pPicture->filter_nparams >= 2)
+	    {
+		int sx, sy;
+
+		sx = xFixedToInt (pPicture->filter_params[0]);
+		sy = xFixedToInt (pPicture->filter_params[1]);
+
+		x -= (sx - 1) / 2;
+		y -= (sy - 1) / 2;
+		width  += sx - 1;
+		height += sy - 1;
+	    }
+	}
 	(*pScreen->SourceValidate) (pDrawable, x, y, width, height);
     }
 }



More information about the xserver-commit mailing list