diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2016-06-21 04:12:07 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2016-06-21 04:12:07 +0200 |
commit | 17f3e3bc5157eeb6018ddaa6d862ca94f4b02b2b (patch) | |
tree | 38cc2874f114bc6a564c9aa518196da93b1f67dc /nx-X11/programs/Xserver/render/filter.c | |
parent | 9013a24da1830b445c03ba273e80774fd1d68fd7 (diff) | |
parent | 4c8fc6be8f530d3bc84d1097bd2cb6a4af6c77fc (diff) | |
download | nx-libs-17f3e3bc5157eeb6018ddaa6d862ca94f4b02b2b.tar.gz nx-libs-17f3e3bc5157eeb6018ddaa6d862ca94f4b02b2b.tar.bz2 nx-libs-17f3e3bc5157eeb6018ddaa6d862ca94f4b02b2b.zip |
Merge branch 'sunweaver-pr/xrandr-extension-upgrade-1.5' into 3.6.x
Attributes GH PR #137: https://github.com/ArcticaProject/nx-libs/pull/137
Reviewed by: Ulrich Sibiller <uli42@gmx.de> -- Mon, 20 Jun 2016 12:40:52 -0700
Diffstat (limited to 'nx-X11/programs/Xserver/render/filter.c')
-rw-r--r-- | nx-X11/programs/Xserver/render/filter.c | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/nx-X11/programs/Xserver/render/filter.c b/nx-X11/programs/Xserver/render/filter.c index 776bd4237..57a21a8c0 100644 --- a/nx-X11/programs/Xserver/render/filter.c +++ b/nx-X11/programs/Xserver/render/filter.c @@ -215,21 +215,30 @@ PictureFindFilter (ScreenPtr pScreen, char *name, int len) } static Bool -convolutionFilterValidateParams (PicturePtr pPicture, +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; } @@ -271,10 +280,8 @@ PictureResetFilters (ScreenPtr pScreen) int SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams) { - ScreenPtr pScreen; PictFilterPtr pFilter; - xFixed *new_params; - int i; + ScreenPtr pScreen; if (pPicture->pDrawable) { pScreen = pPicture->pDrawable->pScreen; @@ -288,7 +295,7 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int if (!pFilter) return BadName; - if (!pPicture->pDrawable) { + if (pPicture->pDrawable == NULL) { int s; /* For source pictures, the picture isn't tied to a screen. So, ensure @@ -303,8 +310,25 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int } } + return SetPicturePictFilter (pPicture, pFilter, params, nparams); +} + +int +SetPicturePictFilter (PicturePtr pPicture, PictFilterPtr pFilter, + xFixed *params, int nparams) +{ + ScreenPtr pScreen; + int i; + + if (pPicture->pDrawable) + pScreen = pPicture->pDrawable->pScreen; + else + pScreen = screenInfo.screens[0]; + if (pFilter->ValidateParams) { - if (!(*pFilter->ValidateParams) (pPicture, pFilter->id, params, nparams)) + int width, height; + + if (!(*pFilter->ValidateParams) (pScreen, pFilter->id, params, nparams, &width, &height)) return BadMatch; } else if (nparams) { @@ -312,7 +336,7 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int } if (nparams != pPicture->filter_nparams) { - new_params = xalloc (nparams * sizeof (xFixed)); + xFixed *new_params = xalloc (nparams * sizeof (xFixed)); if (!new_params && nparams) return BadAlloc; @@ -324,9 +348,10 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int pPicture->filter_params[i] = params[i]; pPicture->filter = pFilter->id; - if (pPicture->pDrawable) { - PictureScreenPtr ps = GetPictureScreen (pScreen); - int result; + if (pPicture->pDrawable) + { + PictureScreenPtr ps = GetPictureScreen(pScreen); + int result; result = (*ps->ChangePictureFilter) (pPicture, pPicture->filter, params, nparams); @@ -335,5 +360,5 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int } pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; - return Success; + return ; } |