示例#1
0
_X_EXPORT Bool
PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias)
{
    PictureScreenPtr    ps = GetPictureScreen(pScreen);
    int			filter_id = PictureGetFilterId (filter, -1, FALSE);
    int			alias_id = PictureGetFilterId (alias, -1, TRUE);
    int			i;

    if (filter_id < 0 || alias_id < 0)
	return FALSE;
    for (i = 0; i < ps->nfilterAliases; i++)
	if (ps->filterAliases[i].alias_id == alias_id)
	    break;
    if (i == ps->nfilterAliases)
    {
	PictFilterAliasPtr  aliases;

	if (ps->filterAliases)
	    aliases = xrealloc (ps->filterAliases,
				(ps->nfilterAliases + 1) *
				sizeof (PictFilterAliasRec));
	else
	    aliases = xalloc (sizeof (PictFilterAliasRec));
	if (!aliases)
	    return FALSE;
	ps->filterAliases = aliases;
	ps->filterAliases[i].alias = PictureGetFilterName (alias_id);
	ps->filterAliases[i].alias_id = alias_id;
	ps->nfilterAliases++;
    }
    ps->filterAliases[i].filter_id = filter_id;
    return TRUE;
}
示例#2
0
_X_EXPORT int
PictureAddFilter (ScreenPtr			    pScreen,
		  char				    *filter,
		  PictFilterValidateParamsProcPtr   ValidateParams)
{
    PictureScreenPtr    ps = GetPictureScreen(pScreen);
    int			id = PictureGetFilterId (filter, -1,  TRUE);
    int			i;
    PictFilterPtr	filters;

    if (id < 0)
	return -1;
    /*
     * It's an error to attempt to reregister a filter
     */
    for (i = 0; i < ps->nfilters; i++)
	if (ps->filters[i].id == id)
	    return -1;
    if (ps->filters)
	filters = xrealloc (ps->filters, (ps->nfilters + 1) * sizeof (PictFilterRec));
    else
	filters = xalloc (sizeof (PictFilterRec));
    if (!filters)
	return -1;
    ps->filters = filters;
    i = ps->nfilters++;
    ps->filters[i].name = PictureGetFilterName (id);
    ps->filters[i].id = id;
    ps->filters[i].ValidateParams = ValidateParams;
    return id;
}
示例#3
0
PictFilterPtr
PictureFindFilter(ScreenPtr pScreen, char *name, int len)
{
    PictureScreenPtr ps = GetPictureScreen(pScreen);
    int id = PictureGetFilterId(name, len, FALSE);
    int i;

    if (id < 0)
        return 0;
    /* Check for an alias, allow them to recurse */
    for (i = 0; i < ps->nfilterAliases; i++)
        if (ps->filterAliases[i].alias_id == id) {
            id = ps->filterAliases[i].filter_id;
            i = 0;
        }
    /* find the filter */
    for (i = 0; i < ps->nfilters; i++)
        if (ps->filters[i].id == id)
            return &ps->filters[i];
    return 0;
}
示例#4
0
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;
}