[PATCH 1/2] render: Always store client clip as a region

Adam Jackson ajax at redhat.com
Wed Oct 8 08:20:33 PDT 2014


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 at redhat.com>
---
 fb/fbpict.c         |  2 +-
 render/mipict.c     | 34 +++++++---------------------------
 render/mirect.c     |  2 +-
 render/picture.c    |  1 -
 render/picturestr.h |  3 +--
 xfixes/region.c     | 14 +++-----------
 6 files changed, 13 insertions(+), 43 deletions(-)

diff --git a/fb/fbpict.c b/fb/fbpict.c
index d610e7d..e726691 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -318,7 +318,7 @@ create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
      * only set the clip region for pictures with drawables
      */
     if (has_clip) {
-        if (pict->clientClipType != CT_NONE)
+        if (pict->clientClip)
             pixman_image_set_has_client_clip(image, TRUE);
 
         if (*xoff || *yoff)
diff --git a/render/mipict.c b/render/mipict.c
index 3959fc4..a725104 100644
--- a/render/mipict.c
+++ b/render/mipict.c
@@ -49,23 +49,9 @@ miDestroyPicture(PicturePtr pPicture)
 void
 miDestroyPictureClip(PicturePtr pPicture)
 {
-    switch (pPicture->clientClipType) {
-    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
-         */
+    if (pPicture->clientClip)
         RegionDestroy(pPicture->clientClip);
-        break;
-    }
     pPicture->clientClip = NULL;
-    pPicture->clientClipType = CT_NONE;
 }
 
 int
@@ -73,37 +59,31 @@ miChangePictureClip(PicturePtr pPicture, int type, void *value, int n)
 {
     ScreenPtr pScreen = pPicture->pDrawable->pScreen;
     PictureScreenPtr ps = GetPictureScreen(pScreen);
-    void *clientClip;
-    int clientClipType;
+    RegionPtr clientClip;
 
     switch (type) {
     case CT_PIXMAP:
         /* convert the pixmap to a region */
-        clientClip = (void *) BitmapToRegion(pScreen, (PixmapPtr) value);
+        clientClip = BitmapToRegion(pScreen, (PixmapPtr) value);
         if (!clientClip)
             return BadAlloc;
-        clientClipType = CT_REGION;
         (*pScreen->DestroyPixmap) ((PixmapPtr) value);
         break;
     case CT_REGION:
         clientClip = value;
-        clientClipType = CT_REGION;
         break;
     case CT_NONE:
         clientClip = 0;
-        clientClipType = CT_NONE;
         break;
     default:
-        clientClip = (void *) RegionFromRects(n, (xRectangle *) value, type);
+        clientClip = RegionFromRects(n, (xRectangle *) value, type);
         if (!clientClip)
             return BadAlloc;
-        clientClipType = CT_REGION;
         free(value);
         break;
     }
     (*ps->DestroyPictureClip) (pPicture);
     pPicture->clientClip = clientClip;
-    pPicture->clientClipType = clientClipType;
     pPicture->stateChanges |= CPClipMask;
     return Success;
 }
@@ -144,7 +124,7 @@ miValidatePicture(PicturePtr pPicture, Mask mask)
              * copying of regions.  (this wins especially if many clients clip
              * by children and have no client clip.)
              */
-            if (pPicture->clientClipType == CT_NONE) {
+            if (!pPicture->clientClip) {
                 if (freeCompClip)
                     RegionDestroy(pPicture->pCompositeClip);
                 pPicture->pCompositeClip = pregWin;
@@ -203,7 +183,7 @@ miValidatePicture(PicturePtr pPicture, Mask mask)
                 pPicture->pCompositeClip = RegionCreate(&pixbounds, 1);
             }
 
-            if (pPicture->clientClipType == CT_REGION) {
+            if (pPicture->clientClip) {
                 if (pDrawable->x || pDrawable->y) {
                     RegionTranslate(pPicture->clientClip,
                                     pDrawable->x + pPicture->clipOrigin.x,
@@ -284,7 +264,7 @@ miClipPictureReg(pixman_region16_t * pRegion,
 static inline Bool
 miClipPictureSrc(RegionPtr pRegion, PicturePtr pPicture, int dx, int dy)
 {
-    if (pPicture->clientClipType != CT_NONE) {
+    if (pPicture->clientClip) {
         Bool result;
 
         pixman_region_translate(pPicture->clientClip,
diff --git a/render/mirect.c b/render/mirect.c
index 4e76972..a36d1d6 100644
--- a/render/mirect.c
+++ b/render/mirect.c
@@ -54,7 +54,7 @@ miColorRects(PicturePtr pDst,
     tmpval[1].val = pixel;
     tmpval[2].val = pDst->subWindowMode;
     mask = GCFunction | GCForeground | GCSubwindowMode;
-    if (pClipPict->clientClipType == CT_REGION) {
+    if (pClipPict->clientClip) {
         tmpval[3].val = pDst->clipOrigin.x - xoff;
         tmpval[4].val = pDst->clipOrigin.y - yoff;
         mask |= GCClipXOrigin | GCClipYOrigin;
diff --git a/render/picture.c b/render/picture.c
index 0978d3f..1d9972c 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -729,7 +729,6 @@ SetPictureToDefaults(PicturePtr pPicture)
     pPicture->polyEdge = PolyEdgeSharp;
     pPicture->polyMode = PolyModePrecise;
     pPicture->freeCompClip = FALSE;
-    pPicture->clientClipType = CT_NONE;
     pPicture->componentAlpha = FALSE;
     pPicture->repeatType = RepeatNone;
 
diff --git a/render/picturestr.h b/render/picturestr.h
index ff88c10..a6cbed8 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -131,7 +131,6 @@ typedef struct _Picture {
     unsigned int polyEdge:1;
     unsigned int polyMode:1;
     unsigned int freeCompClip:1;
-    unsigned int clientClipType:2;
     unsigned int componentAlpha:1;
     unsigned int repeatType:2;
     unsigned int filter:3;
@@ -144,7 +143,7 @@ typedef struct _Picture {
     DDXPointRec alphaOrigin;
 
     DDXPointRec clipOrigin;
-    void *clientClip;
+    RegionPtr clientClip;
 
     unsigned long serialNumber;
 
diff --git a/xfixes/region.c b/xfixes/region.c
index 23320ce..5a8cdae 100644
--- a/xfixes/region.c
+++ b/xfixes/region.c
@@ -272,20 +272,12 @@ ProcXFixesCreateRegionFromPicture(ClientPtr client)
     if (!pPicture->pDrawable)
         return RenderErrBase + BadPicture;
 
-    switch (pPicture->clientClipType) {
-    case CT_PIXMAP:
-        pRegion = BitmapToRegion(pPicture->pDrawable->pScreen,
-                                 (PixmapPtr) pPicture->clientClip);
-        if (!pRegion)
-            return BadAlloc;
-        break;
-    case CT_REGION:
+    if (pPicture->clientClip) {
         pRegion = XFixesRegionCopy((RegionPtr) pPicture->clientClip);
         if (!pRegion)
             return BadAlloc;
-        break;
-    default:
-        return BadImplementation;       /* assume sane server bits */
+    } else {
+        return BadMatch;
     }
 
     if (!AddResource(stuff->region, RegionResType, (void *) pRegion))
-- 
1.9.3



More information about the xorg-devel mailing list