diff options
author | Keith Packard <keithp@keithp.com> | 2008-03-17 15:19:17 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2008-11-24 13:24:37 -0800 |
commit | 1df02d7ddd44f84bcaefd6583af1a9141cb3c78b (patch) | |
tree | 50a57ab9f6ed7c35c072042bd72f812364458f1d /render | |
parent | 40f3dff6b350fe0be55ebf7dbca88a0ef8f6380f (diff) |
Add kernel size to Render filters.
This width/height value lets filter users know how far the filter spreads
into the source image.
Diffstat (limited to 'render')
-rw-r--r-- | render/filter.c | 27 | ||||
-rw-r--r-- | render/picturestr.h | 8 |
2 files changed, 26 insertions, 9 deletions
diff --git a/render/filter.c b/render/filter.c index e499fc44e..b5bcf026c 100644 --- a/render/filter.c +++ b/render/filter.c @@ -126,7 +126,9 @@ PictureFreeFilterIds (void) _X_EXPORT int PictureAddFilter (ScreenPtr pScreen, char *filter, - PictFilterValidateParamsProcPtr ValidateParams) + PictFilterValidateParamsProcPtr ValidateParams, + int width, + int height) { PictureScreenPtr ps = GetPictureScreen(pScreen); int id = PictureGetFilterId (filter, -1, TRUE); @@ -152,6 +154,8 @@ PictureAddFilter (ScreenPtr pScreen, ps->filters[i].name = PictureGetFilterName (id); ps->filters[i].id = id; ps->filters[i].ValidateParams = ValidateParams; + ps->filters[i].width = width; + ps->filters[i].height = height; return id; } @@ -216,18 +220,26 @@ static Bool convolutionFilterValidateParams (ScreenPtr pScreen, int filter, xFixed *params, - int nparams) + int nparams, + int *width, + int *height) { + int w, h; if (nparams < 3) return FALSE; if (xFixedFrac (params[0]) || xFixedFrac (params[1])) return FALSE; + w = xFixedToInt (params[0]); + h = xFixedToInt (params[1]); + nparams -= 2; - if ((xFixedToInt (params[0]) * xFixedToInt (params[1])) > nparams) + if (w * h > nparams) return FALSE; + *width = w; + *height = h; return TRUE; } @@ -238,9 +250,9 @@ PictureSetDefaultFilters (ScreenPtr pScreen) if (!filterNames) if (!PictureSetDefaultIds ()) return FALSE; - if (PictureAddFilter (pScreen, FilterNearest, 0) < 0) + if (PictureAddFilter (pScreen, FilterNearest, 0, 1, 1) < 0) return FALSE; - if (PictureAddFilter (pScreen, FilterBilinear, 0) < 0) + if (PictureAddFilter (pScreen, FilterBilinear, 0, 4, 4) < 0) return FALSE; if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast)) @@ -250,7 +262,7 @@ PictureSetDefaultFilters (ScreenPtr pScreen) if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterBest)) return FALSE; - if (PictureAddFilter (pScreen, FilterConvolution, convolutionFilterValidateParams) < 0) + if (PictureAddFilter (pScreen, FilterConvolution, convolutionFilterValidateParams, 0, 0) < 0) return FALSE; return TRUE; @@ -314,7 +326,8 @@ SetPicturePictFilter (PicturePtr pPicture, PictFilterPtr pFilter, if (pFilter->ValidateParams) { - if (!(*pFilter->ValidateParams) (pScreen, pFilter->id, params, nparams)) + int width, height; + if (!(*pFilter->ValidateParams) (pScreen, pFilter->id, params, nparams, &width, &height)) return BadMatch; } else if (nparams) diff --git a/render/picturestr.h b/render/picturestr.h index 8a926ce90..60be68ab8 100644 --- a/render/picturestr.h +++ b/render/picturestr.h @@ -185,11 +185,13 @@ typedef struct _Picture { } PictureRec; typedef Bool (*PictFilterValidateParamsProcPtr) (ScreenPtr pScreen, int id, - xFixed *params, int nparams); + xFixed *params, int nparams, + int *width, int *height); typedef struct { char *name; int id; PictFilterValidateParamsProcPtr ValidateParams; + int width, height; } PictFilterRec, *PictFilterPtr; #define PictFilterNearest 0 @@ -458,7 +460,9 @@ PictureGetFilterName (int id); int PictureAddFilter (ScreenPtr pScreen, char *filter, - PictFilterValidateParamsProcPtr ValidateParams); + PictFilterValidateParamsProcPtr ValidateParams, + int width, + int height); Bool PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias); |