diff options
author | Lars Knoll <lars@trolltech.com> | 2005-06-13 14:40:25 +0000 |
---|---|---|
committer | Lars Knoll <lars@trolltech.com> | 2005-06-13 14:40:25 +0000 |
commit | 49476ca73c86a599a1bc49cba1117d42f59996a8 (patch) | |
tree | a5618b6b33c73b7b40898c70059105f89ee2677b /render | |
parent | f0ab6d57df66da5de1a8182f8250cc2c8e1450ad (diff) |
add the convolution filter from xserver to xorg
Diffstat (limited to 'render')
-rw-r--r-- | render/filter.c | 35 | ||||
-rw-r--r-- | render/picturestr.h | 28 |
2 files changed, 45 insertions, 18 deletions
diff --git a/render/filter.c b/render/filter.c index d1dbded6b..935c91515 100644 --- a/render/filter.c +++ b/render/filter.c @@ -47,8 +47,6 @@ static int nfilterNames; * standard but not required filters don't have constant indices */ -int pictFilterConvolution; - int PictureGetFilterId (char *filter, int len, Bool makeit) { @@ -87,18 +85,21 @@ 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; } @@ -174,7 +175,7 @@ PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias) if (ps->filterAliases) aliases = xrealloc (ps->filterAliases, - (ps->nfilterAliases + 1) * + (ps->nfilterAliases + 1) * sizeof (PictFilterAliasRec)); else aliases = xalloc (sizeof (PictFilterAliasRec)); @@ -212,6 +213,26 @@ PictureFindFilter (ScreenPtr pScreen, char *name, int len) return 0; } +static Bool +convolutionFilterValidateParams (PicturePtr pPicture, + int filter, + xFixed *params, + int nparams) +{ + if (nparams < 3) + return FALSE; + + if (xFixedFrac (params[0]) || xFixedFrac (params[1])) + return FALSE; + + nparams -= 2; + if ((xFixedToInt (params[0]) * xFixedToInt (params[1])) > nparams) + return FALSE; + + return TRUE; +} + + Bool PictureSetDefaultFilters (ScreenPtr pScreen) { @@ -229,6 +250,10 @@ PictureSetDefaultFilters (ScreenPtr pScreen) return FALSE; if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterBest)) return FALSE; + + if (PictureAddFilter (pScreen, FilterConvolution, convolutionFilterValidateParams) < 0) + return FALSE; + return TRUE; } diff --git a/render/picturestr.h b/render/picturestr.h index 30630ce06..690e08f4d 100644 --- a/render/picturestr.h +++ b/render/picturestr.h @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Keith Packard, SuSE, Inc. @@ -69,7 +69,7 @@ typedef struct _Picture { int refcnt; CARD32 id; PicturePtr pNext; /* chain on same drawable */ - + unsigned int repeat : 1; unsigned int graphicsExposures : 1; unsigned int subWindowMode : 1; @@ -92,9 +92,9 @@ typedef struct _Picture { unsigned long serialNumber; RegionPtr pCompositeClip; - + DevUnion *devPrivates; - + PictTransform *transform; int filter; @@ -117,6 +117,8 @@ typedef struct { #define PictFilterGood 3 #define PictFilterBest 4 +#define PictFilterConvolution 5 + typedef struct { char *alias; int alias_id; @@ -130,7 +132,7 @@ typedef int (*ChangePictureClipProcPtr) (PicturePtr pPicture, pointer value, int n); typedef void (*DestroyPictureClipProcPtr)(PicturePtr pPicture); - + typedef int (*ChangePictureTransformProcPtr) (PicturePtr pPicture, PictTransform *transform); @@ -246,12 +248,12 @@ typedef struct _PictureScreen { PictFormatPtr formats; PictFormatPtr fallback; int nformats; - + CreatePictureProcPtr CreatePicture; DestroyPictureProcPtr DestroyPicture; ChangePictureClipProcPtr ChangePictureClip; DestroyPictureClipProcPtr DestroyPictureClip; - + ChangePictureProcPtr ChangePicture; ValidatePictureProcPtr ValidatePicture; @@ -269,7 +271,7 @@ typedef struct _PictureScreen { UpdateIndexedProcPtr UpdateIndexed; int subpixel; - + PictFilterPtr filters; int nfilters; PictFilterAliasPtr filterAliases; @@ -278,7 +280,7 @@ typedef struct _PictureScreen { ChangePictureTransformProcPtr ChangePictureTransform; ChangePictureFilterProcPtr ChangePictureFilter; DestroyPictureFilterProcPtr DestroyPictureFilter; - + TrapezoidsProcPtr Trapezoids; TrianglesProcPtr Triangles; TriStripProcPtr TriStrip; @@ -355,7 +357,7 @@ PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual); PictFormatPtr PictureMatchFormat (ScreenPtr pScreen, int depth, CARD32 format); - + Bool PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats); @@ -375,7 +377,7 @@ PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias); Bool PictureSetDefaultFilters (ScreenPtr pScreen); - + void PictureResetFilters (ScreenPtr pScreen); @@ -390,7 +392,7 @@ PictureFinishInit (void); void SetPictureToDefaults (PicturePtr pPicture); - + PicturePtr AllocatePicture (ScreenPtr pScreen); @@ -534,7 +536,7 @@ int AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor); void -AddTraps (PicturePtr pPicture, +AddTraps (PicturePtr pPicture, INT16 xOff, INT16 yOff, int ntraps, |