[xorg-commit-diffs] xc/programs/Xserver/render filter.c, 1.1.4.1, 1.1.4.1.2.1

Stuart Kreitman xorg-commit at pdx.freedesktop.org
Tue Mar 30 09:34:47 PST 2004


Committed by: stukreit

Update of /cvs/xorg/xc/programs/Xserver/render
In directory pdx:/tmp/cvs-serv22401

Modified Files:
      Tag: DAMAGE-XFIXES
	filter.c 
Log Message:
integration from modular tree in support of damage ext.
Modified Files:
  Tag: DAMAGE-XFIXES
 	filter.c 


Index: filter.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/render/filter.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.1.2.1
diff -u -d -r1.1.4.1 -r1.1.4.1.2.1
--- a/filter.c	5 Mar 2004 13:41:11 -0000	1.1.4.1
+++ b/filter.c	30 Mar 2004 17:34:45 -0000	1.1.4.1.2.1
@@ -1,7 +1,7 @@
 /*
- * $XFree86$
+ * $Id: filter.c,v 1.3 2004/01/15 09:03:47 keithp Exp $
  *
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -22,6 +22,9 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 #include "misc.h"
 #include "scrnintstr.h"
 #include "os.h"
@@ -40,6 +43,12 @@
 static char **filterNames;
 static int  nfilterNames;
 
+/*
+ * standard but not required filters don't have constant indices
+ */
+
+int pictFilterConvolution;
+
 int
 PictureGetFilterId (char *filter, int len, Bool makeit)
 {
@@ -50,15 +59,14 @@
     if (len < 0)
 	len = strlen (filter);
     for (i = 0; i < nfilterNames; i++)
-	if (len == strlen (filterNames[i]) && 
-	    !strncmp (filterNames[i], filter, len))
+	if (!CompareISOLatin1Lowered (filterNames[i], -1, filter, len))
 	    return i;
     if (!makeit)
 	return -1;
-    name = xalloc (strlen (filter) + 1);
+    name = xalloc (len + 1);
     if (!name)
 	return -1;
-    strncpy (name, filter, len);
+    memcpy (name, filter, len);
     name[len] = '\0';
     if (filterNames)
 	names = xrealloc (filterNames, (nfilterNames + 1) * sizeof (char *));
@@ -116,7 +124,9 @@
 }
 
 int
-PictureAddFilter (ScreenPtr pScreen, char *filter, xFixed *params, int nparams)
+PictureAddFilter (ScreenPtr			    pScreen,
+		  char				    *filter,
+		  PictFilterValidateParamsProcPtr   ValidateParams)
 {
     PictureScreenPtr    ps = GetPictureScreen(pScreen);
     int			id = PictureGetFilterId (filter, -1,  TRUE);
@@ -140,9 +150,8 @@
     ps->filters = filters;
     i = ps->nfilters++;
     ps->filters[i].name = PictureGetFilterName (id);
-    ps->filters[i].params = params;
-    ps->filters[i].nparams = nparams;
     ps->filters[i].id = id;
+    ps->filters[i].ValidateParams = ValidateParams;
     return id;
 }
 
@@ -209,11 +218,12 @@
     if (!filterNames)
 	if (!PictureSetDefaultIds ())
 	    return FALSE;
-    if (PictureAddFilter (pScreen, FilterNearest, 0, 0) < 0)
+
+    if (PictureAddFilter (pScreen, FilterNearest, 0) < 0)
 	return FALSE;
-    if (PictureAddFilter (pScreen, FilterBilinear, 0, 0) < 0)
+    if (PictureAddFilter (pScreen, FilterBilinear, 0) < 0)
 	return FALSE;
-
+    
     if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast))
 	return FALSE;
     if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterGood))
@@ -243,21 +253,25 @@
 
     if (!pFilter)
 	return BadName;
-    if (nparams > pFilter->nparams)
+    if (pFilter->ValidateParams)
+    {
+	if (!(*pFilter->ValidateParams) (pPicture, pFilter->id, params, nparams))
+	    return BadMatch;
+    }
+    else if (nparams)
 	return BadMatch;
-    if (pFilter->nparams != pPicture->filter_nparams)
+
+    if (nparams != pPicture->filter_nparams)
     {
-	new_params = xalloc (pFilter->nparams * sizeof (xFixed));
+	new_params = xalloc (nparams * sizeof (xFixed));
 	if (!new_params)
 	    return BadAlloc;
 	xfree (pPicture->filter_params);
 	pPicture->filter_params = new_params;
-	pPicture->filter_nparams = pFilter->nparams;
+	pPicture->filter_nparams = nparams;
     }
     for (i = 0; i < nparams; i++)
 	pPicture->filter_params[i] = params[i];
-    for (; i < pFilter->nparams; i++)
-	pPicture->filter_params[i] = pFilter->params[i];
     pPicture->filter = pFilter->id;
     return Success;
 }




More information about the xorg-commit-diffs mailing list