From 73e2383b7350723256894c5076d0c731aec5cd1f Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 20 Jun 2014 13:31:20 -0400 Subject: dix: Always store GC client clip as a region (v2) Again, this changes FixesCreateRegionFromGC to throw BadMatch when fed a GC with no client clip. v2: Fix Xnest and some variable names (Keith) Reviewed-by: Keith Packard Signed-off-by: Adam Jackson --- mi/micopy.c | 5 ++--- mi/miexpose.c | 2 +- mi/migc.c | 45 ++++++++++----------------------------------- mi/mioverlay.c | 2 +- 4 files changed, 14 insertions(+), 40 deletions(-) (limited to 'mi') diff --git a/mi/micopy.c b/mi/micopy.c index a52b0a786..2409c7880 100644 --- a/mi/micopy.c +++ b/mi/micopy.c @@ -167,7 +167,7 @@ miDoCopy(DrawablePtr pSrcDrawable, /* Compute source clip region */ if (pSrcDrawable->type == DRAWABLE_PIXMAP) { - if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE)) + if ((pSrcDrawable == pDstDrawable) && (!pGC->clientClip)) prgnSrcClip = miGetCompositeClip(pGC); else fastSrc = TRUE; @@ -186,8 +186,7 @@ miDoCopy(DrawablePtr pSrcDrawable, */ fastSrc = TRUE; } - else if ((pSrcDrawable == pDstDrawable) && - (pGC->clientClipType == CT_NONE)) { + else if ((pSrcDrawable == pDstDrawable) && (!pGC->clientClip)) { prgnSrcClip = miGetCompositeClip(pGC); } else { diff --git a/mi/miexpose.c b/mi/miexpose.c index de8ee6c2a..e74b9c37e 100644 --- a/mi/miexpose.c +++ b/mi/miexpose.c @@ -230,7 +230,7 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, RegionIntersect(&rgnExposed, &rgnExposed, prgnDstClip); /* intersect with client clip region. */ - if (pGC->clientClipType == CT_REGION) + if (pGC->clientClip) RegionIntersect(&rgnExposed, &rgnExposed, pGC->clientClip); /* diff --git a/mi/migc.c b/mi/migc.c index 9bbe8846e..8fdd4810c 100644 --- a/mi/migc.c +++ b/mi/migc.c @@ -55,20 +55,9 @@ miDestroyGC(GCPtr pGC) void miDestroyClip(GCPtr pGC) { - if (pGC->clientClipType == CT_NONE) - return; - else if (pGC->clientClipType == CT_PIXMAP) { - (*pGC->pScreen->DestroyPixmap) ((PixmapPtr) (pGC->clientClip)); - } - else { - /* - * we know we'll never have a list of rectangles, since ChangeClip - * immediately turns them into a region - */ + if (pGC->clientClip) RegionDestroy(pGC->clientClip); - } pGC->clientClip = NULL; - pGC->clientClipType = CT_NONE; } void @@ -77,8 +66,7 @@ miChangeClip(GCPtr pGC, int type, void *pvalue, int nrects) (*pGC->funcs->DestroyClip) (pGC); if (type == CT_PIXMAP) { /* convert the pixmap to a region */ - pGC->clientClip = (void *) BitmapToRegion(pGC->pScreen, - (PixmapPtr) pvalue); + pGC->clientClip = BitmapToRegion(pGC->pScreen, (PixmapPtr) pvalue); (*pGC->pScreen->DestroyPixmap) (pvalue); } else if (type == CT_REGION) { @@ -86,34 +74,21 @@ miChangeClip(GCPtr pGC, int type, void *pvalue, int nrects) pGC->clientClip = pvalue; } else if (type != CT_NONE) { - pGC->clientClip = (void *) RegionFromRects(nrects, - (xRectangle *) pvalue, - type); + pGC->clientClip = RegionFromRects(nrects, (xRectangle *) pvalue, type); free(pvalue); } - pGC->clientClipType = (type != CT_NONE && - pGC->clientClip) ? CT_REGION : CT_NONE; pGC->stateChanges |= GCClipMask; } void miCopyClip(GCPtr pgcDst, GCPtr pgcSrc) { - RegionPtr prgnNew; - - switch (pgcSrc->clientClipType) { - case CT_PIXMAP: - ((PixmapPtr) pgcSrc->clientClip)->refcnt++; - /* Fall through !! */ - case CT_NONE: - (*pgcDst->funcs->ChangeClip) (pgcDst, (int) pgcSrc->clientClipType, - pgcSrc->clientClip, 0); - break; - case CT_REGION: - prgnNew = RegionCreate(NULL, 1); + if (pgcSrc->clientClip) { + RegionPtr prgnNew = RegionCreate(NULL, 1); RegionCopy(prgnNew, (RegionPtr) (pgcSrc->clientClip)); - (*pgcDst->funcs->ChangeClip) (pgcDst, CT_REGION, (void *) prgnNew, 0); - break; + (*pgcDst->funcs->ChangeClip) (pgcDst, CT_REGION, prgnNew, 0); + } else { + (*pgcDst->funcs->ChangeClip) (pgcDst, CT_NONE, NULL, 0); } } @@ -149,7 +124,7 @@ miComputeCompositeClip(GCPtr pGC, DrawablePtr pDrawable) * regions. (this wins especially if many clients clip by children * and have no client clip.) */ - if (pGC->clientClipType == CT_NONE) { + if (!pGC->clientClip) { if (freeCompClip) RegionDestroy(pGC->pCompositeClip); pGC->pCompositeClip = pregWin; @@ -206,7 +181,7 @@ miComputeCompositeClip(GCPtr pGC, DrawablePtr pDrawable) pGC->pCompositeClip = RegionCreate(&pixbounds, 1); } - if (pGC->clientClipType == CT_REGION) { + if (pGC->clientClip) { if (pDrawable->x || pDrawable->y) { RegionTranslate(pGC->clientClip, pDrawable->x + pGC->clipOrg.x, diff --git a/mi/mioverlay.c b/mi/mioverlay.c index eb8dda133..2b20fd72f 100644 --- a/mi/mioverlay.c +++ b/mi/mioverlay.c @@ -1667,7 +1667,7 @@ miOverlayComputeCompositeClip(GCPtr pGC, WindowPtr pWin) freeTmpClip = FALSE; } freeCompClip = pGC->freeCompClip; - if (pGC->clientClipType == CT_NONE) { + if (!pGC->clientClip) { if (freeCompClip) RegionDestroy(pGC->pCompositeClip); pGC->pCompositeClip = pregWin; -- cgit v1.2.3