int SetPictureFilter(PicturePtr pPicture, char *name, int len, xFixed * params, int nparams) { PictFilterPtr pFilter; ScreenPtr pScreen; if (pPicture->pDrawable != NULL) pScreen = pPicture->pDrawable->pScreen; else pScreen = screenInfo.screens[0]; pFilter = PictureFindFilter(pScreen, name, len); if (!pFilter) return BadName; if (pPicture->pDrawable == NULL) { int s; /* For source pictures, the picture isn't tied to a screen. So, ensure * that all screens can handle a filter we set for the picture. */ for (s = 1; s < screenInfo.numScreens; s++) { PictFilterPtr pScreenFilter; pScreenFilter = PictureFindFilter(screenInfo.screens[s], name, len); if (!pScreenFilter || pScreenFilter->id != pFilter->id) return BadMatch; } } return SetPicturePictFilter(pPicture, pFilter, params, nparams); }
int SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams) { PictFilterPtr pFilter; xFixed *new_params; int i, s, result; pFilter = PictureFindFilter (screenInfo.screens[0], name, len); if (pPicture->pDrawable == NULL) { /* For source pictures, the picture isn't tied to a screen. So, ensure * that all screens can handle a filter we set for the picture. */ for (s = 0; s < screenInfo.numScreens; s++) { if (PictureFindFilter (screenInfo.screens[s], name, len)->id != pFilter->id) { return BadMatch; } } } if (!pFilter) return BadName; if (pFilter->ValidateParams) { if (!(*pFilter->ValidateParams) (pPicture, pFilter->id, params, nparams)) return BadMatch; } else if (nparams) return BadMatch; if (nparams != pPicture->filter_nparams) { new_params = xalloc (nparams * sizeof (xFixed)); if (!new_params) return BadAlloc; xfree (pPicture->filter_params); pPicture->filter_params = new_params; pPicture->filter_nparams = nparams; } for (i = 0; i < nparams; i++) pPicture->filter_params[i] = params[i]; pPicture->filter = pFilter->id; if (pPicture->pDrawable) { ScreenPtr pScreen = pPicture->pDrawable->pScreen; PictureScreenPtr ps = GetPictureScreen(pScreen); result = (*ps->ChangePictureFilter) (pPicture, pPicture->filter, params, nparams); return result; } return Success; }
int RRCrtcTransformSet (RRCrtcPtr crtc, PictTransformPtr transform, struct pixman_f_transform *f_transform, struct pixman_f_transform *f_inverse, char *filter_name, int filter_len, xFixed *params, int nparams) { PictFilterPtr filter = NULL; int width = 0, height = 0; if (!crtc->transforms) return BadValue; if (filter_len) { filter = PictureFindFilter (crtc->pScreen, filter_name, filter_len); if (!filter) return BadName; if (filter->ValidateParams) { if (!filter->ValidateParams (crtc->pScreen, filter->id, params, nparams, &width, &height)) return BadMatch; } else { width = filter->width; height = filter->height; } } else { if (nparams) return BadMatch; } if (!RRTransformSetFilter (&crtc->client_pending_transform, filter, params, nparams, width, height)) return BadAlloc; crtc->client_pending_transform.transform = *transform; crtc->client_pending_transform.f_transform = *f_transform; crtc->client_pending_transform.f_inverse = *f_inverse; return Success; }