Integration of DAMAGE-XFIXES branch to trunk

https://freedesktop.org/bugzilla/show_bug.cgi?id=859
These RENDER changes come from the experimental freedesktop tree formerly
    known as "Xserver". Partly motivated by compatibility with DAMAGE as
    pulled from that tree, also some of the code just is better
    implemented.
Modified Files: filter.c picture.c picture.h picturestr.h
This commit is contained in:
Stuart Kreitman 2004-07-29 18:37:54 +00:00
parent e1281790bb
commit d4a101d4ef
4 changed files with 122 additions and 40 deletions

View File

@ -1,7 +1,7 @@
/*
* $XFree86$
* $Id$
*
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
* Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@ -22,6 +22,9 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "misc.h"
#include "scrnintstr.h"
#include "os.h"
@ -40,6 +43,12 @@
static char **filterNames;
static int nfilterNames;
/*
* standard but not required filters don't have constant indices
*/
int pictFilterConvolution;
int
PictureGetFilterId (char *filter, int len, Bool makeit)
{
@ -50,15 +59,14 @@ PictureGetFilterId (char *filter, int len, Bool makeit)
if (len < 0)
len = strlen (filter);
for (i = 0; i < nfilterNames; i++)
if (len == strlen (filterNames[i]) &&
!strncmp (filterNames[i], filter, len))
if (!CompareISOLatin1Lowered ((unsigned char *) filterNames[i], -1, (unsigned char *) filter, len))
return i;
if (!makeit)
return -1;
name = xalloc (strlen (filter) + 1);
name = xalloc (len + 1);
if (!name)
return -1;
strncpy (name, filter, len);
memcpy (name, filter, len);
name[len] = '\0';
if (filterNames)
names = xrealloc (filterNames, (nfilterNames + 1) * sizeof (char *));
@ -116,7 +124,9 @@ PictureFreeFilterIds (void)
}
int
PictureAddFilter (ScreenPtr pScreen, char *filter, xFixed *params, int nparams)
PictureAddFilter (ScreenPtr pScreen,
char *filter,
PictFilterValidateParamsProcPtr ValidateParams)
{
PictureScreenPtr ps = GetPictureScreen(pScreen);
int id = PictureGetFilterId (filter, -1, TRUE);
@ -140,9 +150,8 @@ PictureAddFilter (ScreenPtr pScreen, char *filter, xFixed *params, int nparams)
ps->filters = filters;
i = ps->nfilters++;
ps->filters[i].name = PictureGetFilterName (id);
ps->filters[i].params = params;
ps->filters[i].nparams = nparams;
ps->filters[i].id = id;
ps->filters[i].ValidateParams = ValidateParams;
return id;
}
@ -209,9 +218,9 @@ PictureSetDefaultFilters (ScreenPtr pScreen)
if (!filterNames)
if (!PictureSetDefaultIds ())
return FALSE;
if (PictureAddFilter (pScreen, FilterNearest, 0, 0) < 0)
if (PictureAddFilter (pScreen, FilterNearest, 0) < 0)
return FALSE;
if (PictureAddFilter (pScreen, FilterBilinear, 0, 0) < 0)
if (PictureAddFilter (pScreen, FilterBilinear, 0) < 0)
return FALSE;
if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast))
@ -243,21 +252,25 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int
if (!pFilter)
return BadName;
if (nparams > pFilter->nparams)
return BadMatch;
if (pFilter->nparams != pPicture->filter_nparams)
if (pFilter->ValidateParams)
{
new_params = xalloc (pFilter->nparams * sizeof (xFixed));
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 = pFilter->nparams;
pPicture->filter_nparams = nparams;
}
for (i = 0; i < nparams; i++)
pPicture->filter_params[i] = params[i];
for (; i < pFilter->nparams; i++)
pPicture->filter_params[i] = pFilter->params[i];
pPicture->filter = pFilter->id;
return Success;
}

View File

@ -23,6 +23,9 @@
* Author: Keith Packard, SuSE, Inc.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "misc.h"
#include "scrnintstr.h"
#include "os.h"
@ -420,7 +423,7 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
case PICT_TYPE_COLOR:
case PICT_TYPE_GRAY:
pFormats[f].type = PictTypeIndexed;
pFormats[f].index.pVisual = &pScreen->visuals[PICT_FORMAT_VIS(format)];
pFormats[f].index.vid = pScreen->visuals[PICT_FORMAT_VIS(format)].vid;
break;
}
}
@ -428,6 +431,21 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
return pFormats;
}
static VisualPtr
PictureFindVisual (ScreenPtr pScreen, VisualID visual)
{
int i;
VisualPtr pVisual;
for (i = 0, pVisual = pScreen->visuals;
i < pScreen->numVisuals;
i++, pVisual++)
{
if (pVisual->vid == visual)
return pVisual;
}
return 0;
}
Bool
PictureInitIndexedFormats (ScreenPtr pScreen)
{
@ -443,13 +461,16 @@ PictureInitIndexedFormats (ScreenPtr pScreen)
{
if (format->type == PictTypeIndexed && !format->index.pColormap)
{
if (format->index.pVisual->vid == pScreen->rootVisual)
if (format->index.vid == pScreen->rootVisual)
format->index.pColormap = (ColormapPtr) LookupIDByType(pScreen->defColormap,
RT_COLORMAP);
else
{
VisualPtr pVisual;
pVisual = PictureFindVisual (pScreen, format->index.vid);
if (CreateColormap (FakeClientID (0), pScreen,
format->index.pVisual,
pVisual,
&format->index.pColormap, AllocNone,
0) != Success)
{
@ -533,7 +554,7 @@ PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual)
{
if (type == PictTypeIndexed)
{
if (format->index.pVisual == pVisual)
if (format->index.vid == pVisual->vid)
return format;
}
else
@ -638,7 +659,8 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
}
if (formats[n].type == PictTypeIndexed)
{
if ((formats[n].index.pVisual->class | DynamicClass) == PseudoColor)
VisualPtr pVisual = PictureFindVisual (pScreen, formats[n].index.vid);
if ((pVisual->class | DynamicClass) == PseudoColor)
type = PICT_TYPE_COLOR;
else
type = PICT_TYPE_GRAY;
@ -1079,6 +1101,51 @@ SetPictureClipRects (PicturePtr pPicture,
return result;
}
int
SetPictureClipRegion (PicturePtr pPicture,
int xOrigin,
int yOrigin,
RegionPtr pRegion)
{
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
RegionPtr clientClip;
int result;
int type;
if (pRegion)
{
type = CT_REGION;
clientClip = REGION_CREATE (pScreen,
REGION_EXTENTS(pScreen, pRegion),
REGION_NUM_RECTS(pRegion));
if (!clientClip)
return BadAlloc;
if (!REGION_COPY (pSCreen, clientClip, pRegion))
{
REGION_DESTROY (pScreen, clientClip);
return BadAlloc;
}
}
else
{
type = CT_NONE;
clientClip = 0;
}
result =(*ps->ChangePictureClip) (pPicture, type,
(pointer) clientClip, 0);
if (result == Success)
{
pPicture->clipOrigin.x = xOrigin;
pPicture->clipOrigin.y = yOrigin;
pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask;
pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
}
return result;
}
int
SetPictureTransform (PicturePtr pPicture,
PictTransform *transform)

View File

@ -160,6 +160,9 @@ extern int PictureCmapPolicy;
int PictureParseCmapPolicy (const char *name);
extern int RenderErrBase;
extern int RenderClientPrivateIndex;
/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
#ifdef WIN32

View File

@ -1,6 +1,5 @@
/* $XdotOrg: xc/programs/Xserver/render/picturestr.h,v 1.2 2004/04/23 19:54:29 eich Exp $ */
/*
* $XFree86: xc/programs/Xserver/render/picturestr.h,v 1.21 2002/11/06 22:45:36 keithp Exp $
* $Id$
*
* Copyright © 2000 SuSE, Inc.
*
@ -39,7 +38,7 @@ typedef struct _DirectFormat {
} DirectFormatRec;
typedef struct _IndexFormat {
VisualPtr pVisual;
VisualID vid;
ColormapPtr pColormap;
int nvalues;
xIndexValue *pValues;
@ -103,11 +102,12 @@ typedef struct _Picture {
int filter_nparams;
} PictureRec;
typedef Bool (*PictFilterValidateParamsProcPtr) (PicturePtr pPicture, int id,
xFixed *params, int nparams);
typedef struct {
char *name;
xFixed *params;
int nparams;
int id;
char *name;
int id;
PictFilterValidateParamsProcPtr ValidateParams;
} PictFilterRec, *PictFilterPtr;
#define PictFilterNearest 0
@ -303,15 +303,6 @@ extern RESTYPE GlyphSetType;
} \
} \
void
ResetPicturePrivateIndex (void);
int
AllocatePicturePrivateIndex (void);
Bool
AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount);
Bool
PictureDestroyWindow (WindowPtr pWindow);
@ -349,7 +340,9 @@ char *
PictureGetFilterName (int id);
int
PictureAddFilter (ScreenPtr pScreen, char *filter, xFixed *params, int nparams);
PictureAddFilter (ScreenPtr pScreen,
char *filter,
PictFilterValidateParamsProcPtr ValidateParams);
Bool
PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias);
@ -404,6 +397,12 @@ SetPictureClipRects (PicturePtr pPicture,
int nRect,
xRectangle *rects);
int
SetPictureClipRegion (PicturePtr pPicture,
int xOrigin,
int yOrigin,
RegionPtr pRegion);
int
SetPictureTransform (PicturePtr pPicture,
PictTransform *transform);