diff options
author | Lars Knoll <lars@trolltech.com> | 2005-06-13 14:40:25 +0000 |
---|---|---|
committer | Lars Knoll <lars@trolltech.com> | 2005-06-13 14:40:25 +0000 |
commit | 49476ca73c86a599a1bc49cba1117d42f59996a8 (patch) | |
tree | a5618b6b33c73b7b40898c70059105f89ee2677b /render/filter.c | |
parent | f0ab6d57df66da5de1a8182f8250cc2c8e1450ad (diff) |
add the convolution filter from xserver to xorg
Diffstat (limited to 'render/filter.c')
-rw-r--r-- | render/filter.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/render/filter.c b/render/filter.c index d1dbded6b..935c91515 100644 --- a/render/filter.c +++ b/render/filter.c @@ -47,8 +47,6 @@ static int nfilterNames; * standard but not required filters don't have constant indices */ -int pictFilterConvolution; - int PictureGetFilterId (char *filter, int len, Bool makeit) { @@ -87,18 +85,21 @@ static Bool PictureSetDefaultIds (void) { /* careful here -- this list must match the #define values */ - + if (PictureGetFilterId (FilterNearest, -1, TRUE) != PictFilterNearest) return FALSE; if (PictureGetFilterId (FilterBilinear, -1, TRUE) != PictFilterBilinear) return FALSE; - + if (PictureGetFilterId (FilterFast, -1, TRUE) != PictFilterFast) return FALSE; if (PictureGetFilterId (FilterGood, -1, TRUE) != PictFilterGood) return FALSE; if (PictureGetFilterId (FilterBest, -1, TRUE) != PictFilterBest) return FALSE; + + if (PictureGetFilterId (FilterConvolution, -1, TRUE) != PictFilterConvolution) + return FALSE; return TRUE; } @@ -174,7 +175,7 @@ PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias) if (ps->filterAliases) aliases = xrealloc (ps->filterAliases, - (ps->nfilterAliases + 1) * + (ps->nfilterAliases + 1) * sizeof (PictFilterAliasRec)); else aliases = xalloc (sizeof (PictFilterAliasRec)); @@ -212,6 +213,26 @@ PictureFindFilter (ScreenPtr pScreen, char *name, int len) return 0; } +static Bool +convolutionFilterValidateParams (PicturePtr pPicture, + int filter, + xFixed *params, + int nparams) +{ + 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; + + return TRUE; +} + + Bool PictureSetDefaultFilters (ScreenPtr pScreen) { @@ -229,6 +250,10 @@ PictureSetDefaultFilters (ScreenPtr pScreen) return FALSE; if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterBest)) return FALSE; + + if (PictureAddFilter (pScreen, FilterConvolution, convolutionFilterValidateParams) < 0) + return FALSE; + return TRUE; } |