render: Always store client clip as a region

This does have one semantic change.  FixesCreateRegionFromPicture used to
throw BadImplementation if you tried to create a region from a picture
with no client clip.  I changed that to BadMatch here since that more
honestly describes what's going on.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Adam Jackson 2014-10-08 17:20:33 +02:00 committed by Keith Packard
parent 3f4edd2e3f
commit 462bf87c4d
6 changed files with 13 additions and 43 deletions

View File

@ -326,7 +326,7 @@ create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
* only set the clip region for pictures with drawables * only set the clip region for pictures with drawables
*/ */
if (has_clip) { if (has_clip) {
if (pict->clientClipType != CT_NONE) if (pict->clientClip)
pixman_image_set_has_client_clip(image, TRUE); pixman_image_set_has_client_clip(image, TRUE);
if (*xoff || *yoff) if (*xoff || *yoff)

View File

@ -49,23 +49,9 @@ miDestroyPicture(PicturePtr pPicture)
void void
miDestroyPictureClip(PicturePtr pPicture) miDestroyPictureClip(PicturePtr pPicture)
{ {
switch (pPicture->clientClipType) { if (pPicture->clientClip)
case CT_NONE:
return;
case CT_PIXMAP:
(*pPicture->pDrawable->pScreen->
DestroyPixmap) ((PixmapPtr) (pPicture->clientClip));
break;
default:
/*
* we know we'll never have a list of rectangles, since ChangeClip
* immediately turns them into a region
*/
RegionDestroy(pPicture->clientClip); RegionDestroy(pPicture->clientClip);
break;
}
pPicture->clientClip = NULL; pPicture->clientClip = NULL;
pPicture->clientClipType = CT_NONE;
} }
int int
@ -73,37 +59,31 @@ miChangePictureClip(PicturePtr pPicture, int type, void *value, int n)
{ {
ScreenPtr pScreen = pPicture->pDrawable->pScreen; ScreenPtr pScreen = pPicture->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen); PictureScreenPtr ps = GetPictureScreen(pScreen);
void *clientClip; RegionPtr clientClip;
int clientClipType;
switch (type) { switch (type) {
case CT_PIXMAP: case CT_PIXMAP:
/* convert the pixmap to a region */ /* convert the pixmap to a region */
clientClip = (void *) BitmapToRegion(pScreen, (PixmapPtr) value); clientClip = BitmapToRegion(pScreen, (PixmapPtr) value);
if (!clientClip) if (!clientClip)
return BadAlloc; return BadAlloc;
clientClipType = CT_REGION;
(*pScreen->DestroyPixmap) ((PixmapPtr) value); (*pScreen->DestroyPixmap) ((PixmapPtr) value);
break; break;
case CT_REGION: case CT_REGION:
clientClip = value; clientClip = value;
clientClipType = CT_REGION;
break; break;
case CT_NONE: case CT_NONE:
clientClip = 0; clientClip = 0;
clientClipType = CT_NONE;
break; break;
default: default:
clientClip = (void *) RegionFromRects(n, (xRectangle *) value, type); clientClip = RegionFromRects(n, (xRectangle *) value, type);
if (!clientClip) if (!clientClip)
return BadAlloc; return BadAlloc;
clientClipType = CT_REGION;
free(value); free(value);
break; break;
} }
(*ps->DestroyPictureClip) (pPicture); (*ps->DestroyPictureClip) (pPicture);
pPicture->clientClip = clientClip; pPicture->clientClip = clientClip;
pPicture->clientClipType = clientClipType;
pPicture->stateChanges |= CPClipMask; pPicture->stateChanges |= CPClipMask;
return Success; return Success;
} }
@ -144,7 +124,7 @@ miValidatePicture(PicturePtr pPicture, Mask mask)
* copying of regions. (this wins especially if many clients clip * copying of regions. (this wins especially if many clients clip
* by children and have no client clip.) * by children and have no client clip.)
*/ */
if (pPicture->clientClipType == CT_NONE) { if (!pPicture->clientClip) {
if (freeCompClip) if (freeCompClip)
RegionDestroy(pPicture->pCompositeClip); RegionDestroy(pPicture->pCompositeClip);
pPicture->pCompositeClip = pregWin; pPicture->pCompositeClip = pregWin;
@ -203,7 +183,7 @@ miValidatePicture(PicturePtr pPicture, Mask mask)
pPicture->pCompositeClip = RegionCreate(&pixbounds, 1); pPicture->pCompositeClip = RegionCreate(&pixbounds, 1);
} }
if (pPicture->clientClipType == CT_REGION) { if (pPicture->clientClip) {
if (pDrawable->x || pDrawable->y) { if (pDrawable->x || pDrawable->y) {
RegionTranslate(pPicture->clientClip, RegionTranslate(pPicture->clientClip,
pDrawable->x + pPicture->clipOrigin.x, pDrawable->x + pPicture->clipOrigin.x,
@ -284,7 +264,7 @@ miClipPictureReg(pixman_region16_t * pRegion,
static inline Bool static inline Bool
miClipPictureSrc(RegionPtr pRegion, PicturePtr pPicture, int dx, int dy) miClipPictureSrc(RegionPtr pRegion, PicturePtr pPicture, int dx, int dy)
{ {
if (pPicture->clientClipType != CT_NONE) { if (pPicture->clientClip) {
Bool result; Bool result;
pixman_region_translate(pPicture->clientClip, pixman_region_translate(pPicture->clientClip,

View File

@ -54,7 +54,7 @@ miColorRects(PicturePtr pDst,
tmpval[1].val = pixel; tmpval[1].val = pixel;
tmpval[2].val = pDst->subWindowMode; tmpval[2].val = pDst->subWindowMode;
mask = GCFunction | GCForeground | GCSubwindowMode; mask = GCFunction | GCForeground | GCSubwindowMode;
if (pClipPict->clientClipType == CT_REGION) { if (pClipPict->clientClip) {
tmpval[3].val = pDst->clipOrigin.x - xoff; tmpval[3].val = pDst->clipOrigin.x - xoff;
tmpval[4].val = pDst->clipOrigin.y - yoff; tmpval[4].val = pDst->clipOrigin.y - yoff;
mask |= GCClipXOrigin | GCClipYOrigin; mask |= GCClipXOrigin | GCClipYOrigin;

View File

@ -731,7 +731,6 @@ SetPictureToDefaults(PicturePtr pPicture)
pPicture->polyEdge = PolyEdgeSharp; pPicture->polyEdge = PolyEdgeSharp;
pPicture->polyMode = PolyModePrecise; pPicture->polyMode = PolyModePrecise;
pPicture->freeCompClip = FALSE; pPicture->freeCompClip = FALSE;
pPicture->clientClipType = CT_NONE;
pPicture->componentAlpha = FALSE; pPicture->componentAlpha = FALSE;
pPicture->repeatType = RepeatNone; pPicture->repeatType = RepeatNone;

View File

@ -132,7 +132,6 @@ typedef struct _Picture {
unsigned int polyEdge:1; unsigned int polyEdge:1;
unsigned int polyMode:1; unsigned int polyMode:1;
unsigned int freeCompClip:1; unsigned int freeCompClip:1;
unsigned int clientClipType:2;
unsigned int componentAlpha:1; unsigned int componentAlpha:1;
unsigned int repeatType:2; unsigned int repeatType:2;
unsigned int filter:3; unsigned int filter:3;
@ -145,7 +144,7 @@ typedef struct _Picture {
DDXPointRec alphaOrigin; DDXPointRec alphaOrigin;
DDXPointRec clipOrigin; DDXPointRec clipOrigin;
void *clientClip; RegionPtr clientClip;
unsigned long serialNumber; unsigned long serialNumber;

View File

@ -272,20 +272,12 @@ ProcXFixesCreateRegionFromPicture(ClientPtr client)
if (!pPicture->pDrawable) if (!pPicture->pDrawable)
return RenderErrBase + BadPicture; return RenderErrBase + BadPicture;
switch (pPicture->clientClipType) { if (pPicture->clientClip) {
case CT_PIXMAP:
pRegion = BitmapToRegion(pPicture->pDrawable->pScreen,
(PixmapPtr) pPicture->clientClip);
if (!pRegion)
return BadAlloc;
break;
case CT_REGION:
pRegion = XFixesRegionCopy((RegionPtr) pPicture->clientClip); pRegion = XFixesRegionCopy((RegionPtr) pPicture->clientClip);
if (!pRegion) if (!pRegion)
return BadAlloc; return BadAlloc;
break; } else {
default: return BadMatch;
return BadImplementation; /* assume sane server bits */
} }
if (!AddResource(stuff->region, RegionResType, (void *) pRegion)) if (!AddResource(stuff->region, RegionResType, (void *) pRegion))