Add kernel size to Render filters.
This width/height value lets filter users know how far the filter spreads into the source image.
This commit is contained in:
parent
40f3dff6b3
commit
1df02d7ddd
|
@ -126,7 +126,9 @@ PictureFreeFilterIds (void)
|
||||||
_X_EXPORT int
|
_X_EXPORT int
|
||||||
PictureAddFilter (ScreenPtr pScreen,
|
PictureAddFilter (ScreenPtr pScreen,
|
||||||
char *filter,
|
char *filter,
|
||||||
PictFilterValidateParamsProcPtr ValidateParams)
|
PictFilterValidateParamsProcPtr ValidateParams,
|
||||||
|
int width,
|
||||||
|
int height)
|
||||||
{
|
{
|
||||||
PictureScreenPtr ps = GetPictureScreen(pScreen);
|
PictureScreenPtr ps = GetPictureScreen(pScreen);
|
||||||
int id = PictureGetFilterId (filter, -1, TRUE);
|
int id = PictureGetFilterId (filter, -1, TRUE);
|
||||||
|
@ -152,6 +154,8 @@ PictureAddFilter (ScreenPtr pScreen,
|
||||||
ps->filters[i].name = PictureGetFilterName (id);
|
ps->filters[i].name = PictureGetFilterName (id);
|
||||||
ps->filters[i].id = id;
|
ps->filters[i].id = id;
|
||||||
ps->filters[i].ValidateParams = ValidateParams;
|
ps->filters[i].ValidateParams = ValidateParams;
|
||||||
|
ps->filters[i].width = width;
|
||||||
|
ps->filters[i].height = height;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,18 +220,26 @@ static Bool
|
||||||
convolutionFilterValidateParams (ScreenPtr pScreen,
|
convolutionFilterValidateParams (ScreenPtr pScreen,
|
||||||
int filter,
|
int filter,
|
||||||
xFixed *params,
|
xFixed *params,
|
||||||
int nparams)
|
int nparams,
|
||||||
|
int *width,
|
||||||
|
int *height)
|
||||||
{
|
{
|
||||||
|
int w, h;
|
||||||
if (nparams < 3)
|
if (nparams < 3)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (xFixedFrac (params[0]) || xFixedFrac (params[1]))
|
if (xFixedFrac (params[0]) || xFixedFrac (params[1]))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
w = xFixedToInt (params[0]);
|
||||||
|
h = xFixedToInt (params[1]);
|
||||||
|
|
||||||
nparams -= 2;
|
nparams -= 2;
|
||||||
if ((xFixedToInt (params[0]) * xFixedToInt (params[1])) > nparams)
|
if (w * h > nparams)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
*width = w;
|
||||||
|
*height = h;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,9 +250,9 @@ PictureSetDefaultFilters (ScreenPtr pScreen)
|
||||||
if (!filterNames)
|
if (!filterNames)
|
||||||
if (!PictureSetDefaultIds ())
|
if (!PictureSetDefaultIds ())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (PictureAddFilter (pScreen, FilterNearest, 0) < 0)
|
if (PictureAddFilter (pScreen, FilterNearest, 0, 1, 1) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (PictureAddFilter (pScreen, FilterBilinear, 0) < 0)
|
if (PictureAddFilter (pScreen, FilterBilinear, 0, 4, 4) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast))
|
if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast))
|
||||||
|
@ -250,7 +262,7 @@ PictureSetDefaultFilters (ScreenPtr pScreen)
|
||||||
if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterBest))
|
if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterBest))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (PictureAddFilter (pScreen, FilterConvolution, convolutionFilterValidateParams) < 0)
|
if (PictureAddFilter (pScreen, FilterConvolution, convolutionFilterValidateParams, 0, 0) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -314,7 +326,8 @@ SetPicturePictFilter (PicturePtr pPicture, PictFilterPtr pFilter,
|
||||||
|
|
||||||
if (pFilter->ValidateParams)
|
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;
|
return BadMatch;
|
||||||
}
|
}
|
||||||
else if (nparams)
|
else if (nparams)
|
||||||
|
|
|
@ -185,11 +185,13 @@ typedef struct _Picture {
|
||||||
} PictureRec;
|
} PictureRec;
|
||||||
|
|
||||||
typedef Bool (*PictFilterValidateParamsProcPtr) (ScreenPtr pScreen, int id,
|
typedef Bool (*PictFilterValidateParamsProcPtr) (ScreenPtr pScreen, int id,
|
||||||
xFixed *params, int nparams);
|
xFixed *params, int nparams,
|
||||||
|
int *width, int *height);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
int id;
|
int id;
|
||||||
PictFilterValidateParamsProcPtr ValidateParams;
|
PictFilterValidateParamsProcPtr ValidateParams;
|
||||||
|
int width, height;
|
||||||
} PictFilterRec, *PictFilterPtr;
|
} PictFilterRec, *PictFilterPtr;
|
||||||
|
|
||||||
#define PictFilterNearest 0
|
#define PictFilterNearest 0
|
||||||
|
@ -458,7 +460,9 @@ PictureGetFilterName (int id);
|
||||||
int
|
int
|
||||||
PictureAddFilter (ScreenPtr pScreen,
|
PictureAddFilter (ScreenPtr pScreen,
|
||||||
char *filter,
|
char *filter,
|
||||||
PictFilterValidateParamsProcPtr ValidateParams);
|
PictFilterValidateParamsProcPtr ValidateParams,
|
||||||
|
int width,
|
||||||
|
int height);
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias);
|
PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias);
|
||||||
|
|
Loading…
Reference in New Issue