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:
parent
e1281790bb
commit
d4a101d4ef
|
@ -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
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
* documentation for any purpose is hereby granted without fee, provided that
|
* documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
@ -22,6 +22,9 @@
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "scrnintstr.h"
|
#include "scrnintstr.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
@ -40,6 +43,12 @@
|
||||||
static char **filterNames;
|
static char **filterNames;
|
||||||
static int nfilterNames;
|
static int nfilterNames;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* standard but not required filters don't have constant indices
|
||||||
|
*/
|
||||||
|
|
||||||
|
int pictFilterConvolution;
|
||||||
|
|
||||||
int
|
int
|
||||||
PictureGetFilterId (char *filter, int len, Bool makeit)
|
PictureGetFilterId (char *filter, int len, Bool makeit)
|
||||||
{
|
{
|
||||||
|
@ -50,15 +59,14 @@ PictureGetFilterId (char *filter, int len, Bool makeit)
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
len = strlen (filter);
|
len = strlen (filter);
|
||||||
for (i = 0; i < nfilterNames; i++)
|
for (i = 0; i < nfilterNames; i++)
|
||||||
if (len == strlen (filterNames[i]) &&
|
if (!CompareISOLatin1Lowered ((unsigned char *) filterNames[i], -1, (unsigned char *) filter, len))
|
||||||
!strncmp (filterNames[i], filter, len))
|
|
||||||
return i;
|
return i;
|
||||||
if (!makeit)
|
if (!makeit)
|
||||||
return -1;
|
return -1;
|
||||||
name = xalloc (strlen (filter) + 1);
|
name = xalloc (len + 1);
|
||||||
if (!name)
|
if (!name)
|
||||||
return -1;
|
return -1;
|
||||||
strncpy (name, filter, len);
|
memcpy (name, filter, len);
|
||||||
name[len] = '\0';
|
name[len] = '\0';
|
||||||
if (filterNames)
|
if (filterNames)
|
||||||
names = xrealloc (filterNames, (nfilterNames + 1) * sizeof (char *));
|
names = xrealloc (filterNames, (nfilterNames + 1) * sizeof (char *));
|
||||||
|
@ -116,7 +124,9 @@ PictureFreeFilterIds (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PictureAddFilter (ScreenPtr pScreen, char *filter, xFixed *params, int nparams)
|
PictureAddFilter (ScreenPtr pScreen,
|
||||||
|
char *filter,
|
||||||
|
PictFilterValidateParamsProcPtr ValidateParams)
|
||||||
{
|
{
|
||||||
PictureScreenPtr ps = GetPictureScreen(pScreen);
|
PictureScreenPtr ps = GetPictureScreen(pScreen);
|
||||||
int id = PictureGetFilterId (filter, -1, TRUE);
|
int id = PictureGetFilterId (filter, -1, TRUE);
|
||||||
|
@ -140,9 +150,8 @@ PictureAddFilter (ScreenPtr pScreen, char *filter, xFixed *params, int nparams)
|
||||||
ps->filters = filters;
|
ps->filters = filters;
|
||||||
i = ps->nfilters++;
|
i = ps->nfilters++;
|
||||||
ps->filters[i].name = PictureGetFilterName (id);
|
ps->filters[i].name = PictureGetFilterName (id);
|
||||||
ps->filters[i].params = params;
|
|
||||||
ps->filters[i].nparams = nparams;
|
|
||||||
ps->filters[i].id = id;
|
ps->filters[i].id = id;
|
||||||
|
ps->filters[i].ValidateParams = ValidateParams;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,9 +218,9 @@ PictureSetDefaultFilters (ScreenPtr pScreen)
|
||||||
if (!filterNames)
|
if (!filterNames)
|
||||||
if (!PictureSetDefaultIds ())
|
if (!PictureSetDefaultIds ())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (PictureAddFilter (pScreen, FilterNearest, 0, 0) < 0)
|
if (PictureAddFilter (pScreen, FilterNearest, 0) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (PictureAddFilter (pScreen, FilterBilinear, 0, 0) < 0)
|
if (PictureAddFilter (pScreen, FilterBilinear, 0) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast))
|
if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast))
|
||||||
|
@ -243,21 +252,25 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int
|
||||||
|
|
||||||
if (!pFilter)
|
if (!pFilter)
|
||||||
return BadName;
|
return BadName;
|
||||||
if (nparams > pFilter->nparams)
|
if (pFilter->ValidateParams)
|
||||||
return BadMatch;
|
|
||||||
if (pFilter->nparams != pPicture->filter_nparams)
|
|
||||||
{
|
{
|
||||||
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)
|
if (!new_params)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
xfree (pPicture->filter_params);
|
xfree (pPicture->filter_params);
|
||||||
pPicture->filter_params = new_params;
|
pPicture->filter_params = new_params;
|
||||||
pPicture->filter_nparams = pFilter->nparams;
|
pPicture->filter_nparams = nparams;
|
||||||
}
|
}
|
||||||
for (i = 0; i < nparams; i++)
|
for (i = 0; i < nparams; i++)
|
||||||
pPicture->filter_params[i] = params[i];
|
pPicture->filter_params[i] = params[i];
|
||||||
for (; i < pFilter->nparams; i++)
|
|
||||||
pPicture->filter_params[i] = pFilter->params[i];
|
|
||||||
pPicture->filter = pFilter->id;
|
pPicture->filter = pFilter->id;
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
* Author: Keith Packard, SuSE, Inc.
|
* Author: Keith Packard, SuSE, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "scrnintstr.h"
|
#include "scrnintstr.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
@ -420,7 +423,7 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
|
||||||
case PICT_TYPE_COLOR:
|
case PICT_TYPE_COLOR:
|
||||||
case PICT_TYPE_GRAY:
|
case PICT_TYPE_GRAY:
|
||||||
pFormats[f].type = PictTypeIndexed;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -428,6 +431,21 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
|
||||||
return pFormats;
|
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
|
Bool
|
||||||
PictureInitIndexedFormats (ScreenPtr pScreen)
|
PictureInitIndexedFormats (ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
|
@ -443,13 +461,16 @@ PictureInitIndexedFormats (ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
if (format->type == PictTypeIndexed && !format->index.pColormap)
|
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,
|
format->index.pColormap = (ColormapPtr) LookupIDByType(pScreen->defColormap,
|
||||||
RT_COLORMAP);
|
RT_COLORMAP);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
VisualPtr pVisual;
|
||||||
|
|
||||||
|
pVisual = PictureFindVisual (pScreen, format->index.vid);
|
||||||
if (CreateColormap (FakeClientID (0), pScreen,
|
if (CreateColormap (FakeClientID (0), pScreen,
|
||||||
format->index.pVisual,
|
pVisual,
|
||||||
&format->index.pColormap, AllocNone,
|
&format->index.pColormap, AllocNone,
|
||||||
0) != Success)
|
0) != Success)
|
||||||
{
|
{
|
||||||
|
@ -533,7 +554,7 @@ PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual)
|
||||||
{
|
{
|
||||||
if (type == PictTypeIndexed)
|
if (type == PictTypeIndexed)
|
||||||
{
|
{
|
||||||
if (format->index.pVisual == pVisual)
|
if (format->index.vid == pVisual->vid)
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -638,7 +659,8 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
|
||||||
}
|
}
|
||||||
if (formats[n].type == PictTypeIndexed)
|
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;
|
type = PICT_TYPE_COLOR;
|
||||||
else
|
else
|
||||||
type = PICT_TYPE_GRAY;
|
type = PICT_TYPE_GRAY;
|
||||||
|
@ -1079,6 +1101,51 @@ SetPictureClipRects (PicturePtr pPicture,
|
||||||
return result;
|
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
|
int
|
||||||
SetPictureTransform (PicturePtr pPicture,
|
SetPictureTransform (PicturePtr pPicture,
|
||||||
PictTransform *transform)
|
PictTransform *transform)
|
||||||
|
|
|
@ -160,6 +160,9 @@ extern int PictureCmapPolicy;
|
||||||
|
|
||||||
int PictureParseCmapPolicy (const char *name);
|
int PictureParseCmapPolicy (const char *name);
|
||||||
|
|
||||||
|
extern int RenderErrBase;
|
||||||
|
extern int RenderClientPrivateIndex;
|
||||||
|
|
||||||
/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
|
/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
|
@ -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.
|
* Copyright © 2000 SuSE, Inc.
|
||||||
*
|
*
|
||||||
|
@ -39,7 +38,7 @@ typedef struct _DirectFormat {
|
||||||
} DirectFormatRec;
|
} DirectFormatRec;
|
||||||
|
|
||||||
typedef struct _IndexFormat {
|
typedef struct _IndexFormat {
|
||||||
VisualPtr pVisual;
|
VisualID vid;
|
||||||
ColormapPtr pColormap;
|
ColormapPtr pColormap;
|
||||||
int nvalues;
|
int nvalues;
|
||||||
xIndexValue *pValues;
|
xIndexValue *pValues;
|
||||||
|
@ -103,11 +102,12 @@ typedef struct _Picture {
|
||||||
int filter_nparams;
|
int filter_nparams;
|
||||||
} PictureRec;
|
} PictureRec;
|
||||||
|
|
||||||
|
typedef Bool (*PictFilterValidateParamsProcPtr) (PicturePtr pPicture, int id,
|
||||||
|
xFixed *params, int nparams);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
xFixed *params;
|
|
||||||
int nparams;
|
|
||||||
int id;
|
int id;
|
||||||
|
PictFilterValidateParamsProcPtr ValidateParams;
|
||||||
} PictFilterRec, *PictFilterPtr;
|
} PictFilterRec, *PictFilterPtr;
|
||||||
|
|
||||||
#define PictFilterNearest 0
|
#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
|
Bool
|
||||||
PictureDestroyWindow (WindowPtr pWindow);
|
PictureDestroyWindow (WindowPtr pWindow);
|
||||||
|
|
||||||
|
@ -349,7 +340,9 @@ char *
|
||||||
PictureGetFilterName (int id);
|
PictureGetFilterName (int id);
|
||||||
|
|
||||||
int
|
int
|
||||||
PictureAddFilter (ScreenPtr pScreen, char *filter, xFixed *params, int nparams);
|
PictureAddFilter (ScreenPtr pScreen,
|
||||||
|
char *filter,
|
||||||
|
PictFilterValidateParamsProcPtr ValidateParams);
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias);
|
PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias);
|
||||||
|
@ -404,6 +397,12 @@ SetPictureClipRects (PicturePtr pPicture,
|
||||||
int nRect,
|
int nRect,
|
||||||
xRectangle *rects);
|
xRectangle *rects);
|
||||||
|
|
||||||
|
int
|
||||||
|
SetPictureClipRegion (PicturePtr pPicture,
|
||||||
|
int xOrigin,
|
||||||
|
int yOrigin,
|
||||||
|
RegionPtr pRegion);
|
||||||
|
|
||||||
int
|
int
|
||||||
SetPictureTransform (PicturePtr pPicture,
|
SetPictureTransform (PicturePtr pPicture,
|
||||||
PictTransform *transform);
|
PictTransform *transform);
|
||||||
|
|
Loading…
Reference in New Issue