[PATCH 09/14] Kill DoChangeGC in favor of dixChangeGC.

Jamey Sharp jamey at minilop.net
Sat May 8 16:39:24 PDT 2010


Signed-off-by: Jamey Sharp <jamey at minilop.net>
Reviewed-by: Keith Packard <keithp at keithp.com>
---
 dbe/dbe.c                  |   22 +++++++-------------
 dix/gc.c                   |   46 ++-----------------------------------------
 fb/fbseg.c                 |    2 +-
 hw/xfree86/xaa/xaaPCache.c |    2 +-
 include/gc.h               |    6 -----
 mi/mibitblt.c              |    8 +++---
 mi/midispcur.c             |    4 +-
 mi/miexpose.c              |    4 +-
 mi/miglblt.c               |    8 +++---
 mi/mipolypnt.c             |    4 +-
 mi/miwideline.c            |   12 +++++-----
 mi/miwideline.h            |    4 +-
 mi/mizerarc.c              |    4 +-
 xfixes/region.c            |    2 +-
 14 files changed, 38 insertions(+), 90 deletions(-)

diff --git a/dbe/dbe.c b/dbe/dbe.c
index 825d2e0..9e72094 100644
--- a/dbe/dbe.c
+++ b/dbe/dbe.c
@@ -1239,7 +1239,7 @@ SProcDbeDispatch(ClientPtr client)
 static Bool
 DbeSetupBackgroundPainter(WindowPtr pWin, GCPtr pGC)
 {
-    pointer	gcvalues[4];
+    ChangeGCVal	gcvalues[4];
     int		ts_x_origin, ts_y_origin;
     PixUnion	background;
     int		backgroundState;
@@ -1265,16 +1265,16 @@ DbeSetupBackgroundPainter(WindowPtr pWin, GCPtr pGC)
     switch (backgroundState)
     {
         case BackgroundPixel:
-            gcvalues[0] = (pointer)background.pixel;
-            gcvalues[1] = (pointer)FillSolid;
+            gcvalues[0].val = background.pixel;
+            gcvalues[1].val = FillSolid;
             gcmask = GCForeground|GCFillStyle;
             break;
 
         case BackgroundPixmap:
-            gcvalues[0] = (pointer)FillTiled;
-            gcvalues[1] = (pointer)background.pixmap;
-            gcvalues[2] = (pointer)(long)ts_x_origin;
-            gcvalues[3] = (pointer)(long)ts_y_origin;
+            gcvalues[0].val = FillTiled;
+            gcvalues[1].ptr = background.pixmap;
+            gcvalues[2].val = ts_x_origin;
+            gcvalues[3].val = ts_y_origin;
             gcmask = GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin;
             break;
 
@@ -1283,13 +1283,7 @@ DbeSetupBackgroundPainter(WindowPtr pWin, GCPtr pGC)
             return(FALSE);
     }
 
-    if (DoChangeGC(pGC, gcmask, (XID *)gcvalues, TRUE) != 0)
-    {
-        return(FALSE);
-    }
-
-    return(TRUE);
-
+    return dixChangeGC(NullClient, pGC, gcmask, NULL, gcvalues) == 0;
 } /* DbeSetupBackgroundPainter() */
 
 
diff --git a/dix/gc.c b/dix/gc.c
index 6490165..88e6705 100644
--- a/dix/gc.c
+++ b/dix/gc.c
@@ -91,11 +91,9 @@ ValidateGC(DrawablePtr pDraw, GC *pGC)
  * pass NullClient for the client since any access checking should have
  * already been done at a higher level.
  * 
- * Since we had to create a new function anyway, we decided to change the
- * way the list of gc values is passed to eliminate the compiler warnings
- * caused by the DoChangeGC interface.  You can pass the values via pC32
- * or pUnion, but not both; one of them must be NULL.  If you don't need
- * to pass any pointers, you can use either one:
+ * You can pass the list of gc values via pC32 or pUnion, but not both;
+ * one of them must be NULL.  If you don't need to pass any pointers,
+ * you can use either one:
  * 
  *     example calling dixChangeGC using pC32 parameter
  *
@@ -126,13 +124,6 @@ ValidateGC(DrawablePtr pDraw, GC *pGC)
  * Note: we could have gotten by with just the pUnion parameter, but on
  * 64 bit machines that would have forced us to copy the value list that
  * comes in the ChangeGC request.
- * 
- * Ideally, we'd change all the DoChangeGC calls to dixChangeGC, but this
- * is far too many changes to consider at this time, so we've only
- * changed the ones that caused compiler warnings.  New code should use
- * dixChangeGC.
- * 
- * dpw
  */
 
 #define NEXTVAL(_type, _var) { \
@@ -533,37 +524,6 @@ ChangeGC(GC *pGC, BITS32 mask, XID *pval)
     return (dixChangeGC(NullClient, pGC, mask, pval, NULL));
 }
 
-/* DoChangeGC(pGC, mask, pval, fPointer)
-   mask is a set of bits indicating which values to change.
-   pval contains an appropriate value for each mask.
-   fPointer is true if the values for tiles, stipples, fonts or clipmasks
-   are pointers instead of IDs.  Note: if you are passing pointers you
-   MUST declare the array of values as type pointer!  Other data types
-   may not be large enough to hold pointers on some machines.  Yes,
-   this means you have to cast to (XID *) when you pass the array to
-   DoChangeGC.  Similarly, if you are not passing pointers (fPointer = 0) you
-   MUST declare the array as type XID (not unsigned long!), or again the wrong
-   size data type may be used.  To avoid this cruftiness, use dixChangeGC
-   above.
-
-   if there is an error, the value is marked as changed 
-   anyway, which is probably wrong, but infrequent.
-
-NOTE:
-	all values sent over the protocol for ChangeGC requests are
-32 bits long
-*/
-int
-DoChangeGC(GC *pGC, BITS32 mask, XID *pval, int fPointer)
-{
-    if (fPointer)
-    /* XXX might be a problem on 64 bit big-endian servers */
-	return dixChangeGC(NullClient, pGC, mask, NULL, (ChangeGCValPtr)pval);
-    else
-	return dixChangeGC(NullClient, pGC, mask, pval, NULL);
-}
-
-
 /* CreateGC(pDrawable, mask, pval, pStatus)
    creates a default GC for the given drawable, using mask to fill
    in any non-default values.
diff --git a/fb/fbseg.c b/fb/fbseg.c
index 80ce740..80dd480 100644
--- a/fb/fbseg.c
+++ b/fb/fbseg.c
@@ -250,7 +250,7 @@ fbSetFg (DrawablePtr	pDrawable,
 {
     if (fg != pGC->fgPixel)
     {
-	DoChangeGC (pGC, GCForeground, (XID *) &fg, FALSE);
+	dixChangeGC (NullClient, pGC, GCForeground, &fg, NULL);
 	ValidateGC (pDrawable, pGC);
     }
 }
diff --git a/hw/xfree86/xaa/xaaPCache.c b/hw/xfree86/xaa/xaaPCache.c
index 7e3011b..ef3ecd2 100644
--- a/hw/xfree86/xaa/xaaPCache.c
+++ b/hw/xfree86/xaa/xaaPCache.c
@@ -1881,7 +1881,7 @@ XAAWriteBitmapToCacheLinear(
    pGC = GetScratchGC(pScreenPix->drawable.depth, pScreen);
    gcvals[0] = fg;
    gcvals[1] = bg;
-   DoChangeGC(pGC, GCForeground | GCBackground, gcvals, 0);
+   dixChangeGC(NullClient, pGC, GCForeground | GCBackground, gcvals, NULL);
    ValidateGC((DrawablePtr)pDstPix, pGC);
 
    /* We've unwrapped already so these ops miss a sync */
diff --git a/include/gc.h b/include/gc.h
index e75cc5e..7f481c3 100644
--- a/include/gc.h
+++ b/include/gc.h
@@ -93,12 +93,6 @@ extern _X_EXPORT int ChangeGC(
     BITS32 /*mask*/,
     XID* /*pval*/);
 
-extern _X_EXPORT int DoChangeGC(
-    GCPtr/*pGC*/,
-    BITS32 /*mask*/,
-    XID* /*pval*/,
-    int /*fPointer*/);
-
 typedef union {
     CARD32 val;
     pointer ptr;
diff --git a/mi/mibitblt.c b/mi/mibitblt.c
index cc8b11d..246ff4b 100644
--- a/mi/mibitblt.c
+++ b/mi/mibitblt.c
@@ -679,7 +679,7 @@ miGetImage( DrawablePtr pDraw, int sx, int sy, int w, int h,
  
 	    /* alu is already GXCopy */
 	    gcv[0] = (XID)planeMask;
-	    DoChangeGC(pGC, GCPlaneMask, gcv, 0);
+	    dixChangeGC(NullClient, pGC, GCPlaneMask, gcv, NULL);
 	    ValidateGC((DrawablePtr)pPixmap, pGC);
 	}
 
@@ -776,7 +776,7 @@ miPutImage( DrawablePtr pDraw, GCPtr pGC, int depth,
 	oldBg = pGC->bgPixel;
 	gcv[0] = (XID)~0;
 	gcv[1] = (XID)0;
-	DoChangeGC(pGC, GCForeground | GCBackground, gcv, 0);
+	dixChangeGC(NullClient, pGC, GCForeground | GCBackground, gcv, NULL);
 	bytesPer = (long)h * BitmapBytePad(w + leftPad);
 
 	for (i = 1 << (depth-1); i != 0; i >>= 1, pImage += bytesPer)
@@ -784,7 +784,7 @@ miPutImage( DrawablePtr pDraw, GCPtr pGC, int depth,
 	    if (i & oldPlanemask)
 	    {
 	        gcv[0] = (XID)i;
-	        DoChangeGC(pGC, GCPlaneMask, gcv, 0);
+	        dixChangeGC(NullClient, pGC, GCPlaneMask, gcv, NULL);
 	        ValidateGC(pDraw, pGC);
 	        (*pGC->ops->PutImage)(pDraw, pGC, 1, x, y, w, h, leftPad,
 			         XYBitmap, (char *)pImage);
@@ -793,7 +793,7 @@ miPutImage( DrawablePtr pDraw, GCPtr pGC, int depth,
 	gcv[0] = (XID)oldPlanemask;
 	gcv[1] = (XID)oldFg;
 	gcv[2] = (XID)oldBg;
-	DoChangeGC(pGC, GCPlaneMask | GCForeground | GCBackground, gcv, 0);
+	dixChangeGC(NullClient, pGC, GCPlaneMask | GCForeground | GCBackground, gcv, NULL);
 	ValidateGC(pDraw, pGC);
 	break;
 
diff --git a/mi/midispcur.c b/mi/midispcur.c
index 9041630..dcdca39 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -371,7 +371,7 @@ miDCPutBits (
     if (sourceGC->fgPixel != source)
     {
 	gcvals[0] = source;
-	DoChangeGC (sourceGC, GCForeground, gcvals, 0);
+	dixChangeGC (NullClient, sourceGC, GCForeground, gcvals, NULL);
     }
     if (sourceGC->serialNumber != pDrawable->serialNumber)
 	ValidateGC (pDrawable, sourceGC);
@@ -391,7 +391,7 @@ miDCPutBits (
     if (maskGC->fgPixel != mask)
     {
 	gcvals[0] = mask;
-	DoChangeGC (maskGC, GCForeground, gcvals, 0);
+	dixChangeGC (NullClient, maskGC, GCForeground, gcvals, NULL);
     }
     if (maskGC->serialNumber != pDrawable->serialNumber)
 	ValidateGC (pDrawable, maskGC);
diff --git a/mi/miexpose.c b/mi/miexpose.c
index f52b492..4943685 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -691,9 +691,9 @@ miClearDrawable(DrawablePtr pDraw, GCPtr pGC)
     rect.y = 0;
     rect.width = pDraw->width;
     rect.height = pDraw->height;
-    DoChangeGC(pGC, GCForeground, &bg, 0);
+    dixChangeGC(NullClient, pGC, GCForeground, &bg, NULL);
     ValidateGC(pDraw, pGC);
     (*pGC->ops->PolyFillRect)(pDraw, pGC, 1, &rect);
-    DoChangeGC(pGC, GCForeground, &fg, 0);
+    dixChangeGC(NullClient, pGC, GCForeground, &fg, NULL);
     ValidateGC(pDraw, pGC);
 }
diff --git a/mi/miglblt.c b/mi/miglblt.c
index bc715ae..7e1e40d 100644
--- a/mi/miglblt.c
+++ b/mi/miglblt.c
@@ -138,7 +138,7 @@ miPolyGlyphBlt(
     gcvals[1] = 1;
     gcvals[2] = 0;
 
-    DoChangeGC(pGCtmp, GCFunction|GCForeground|GCBackground, gcvals, 0);
+    dixChangeGC(NullClient, pGCtmp, GCFunction|GCForeground|GCBackground, gcvals, NULL);
 
     nbyLine = BitmapBytePad(width);
     pbits = xalloc(height*nbyLine);
@@ -237,13 +237,13 @@ miImageGlyphBlt(
     gcvals[0] = GXcopy;
     gcvals[1] = pGC->bgPixel;
     gcvals[2] = FillSolid;
-    DoChangeGC(pGC, GCFunction|GCForeground|GCFillStyle, gcvals, 0);
+    dixChangeGC(NullClient, pGC, GCFunction|GCForeground|GCFillStyle, gcvals, NULL);
     ValidateGC(pDrawable, pGC);
     (*pGC->ops->PolyFillRect)(pDrawable, pGC, 1, &backrect);
 
     /* put down the glyphs */
     gcvals[0] = oldFG;
-    DoChangeGC(pGC, GCForeground, gcvals, 0);
+    dixChangeGC(NullClient, pGC, GCForeground, gcvals, NULL);
     ValidateGC(pDrawable, pGC);
     (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci,
 			      pglyphBase);
@@ -252,7 +252,7 @@ miImageGlyphBlt(
     gcvals[0] = oldAlu;
     gcvals[1] = oldFG;
     gcvals[2] = oldFS;
-    DoChangeGC(pGC, GCFunction|GCForeground|GCFillStyle, gcvals, 0);
+    dixChangeGC(NullClient, pGC, GCFunction|GCForeground|GCFillStyle, gcvals, NULL);
     ValidateGC(pDrawable, pGC);
 
 }
diff --git a/mi/mipolypnt.c b/mi/mipolypnt.c
index 12771ee..351de5f 100644
--- a/mi/mipolypnt.c
+++ b/mi/mipolypnt.c
@@ -107,7 +107,7 @@ miPolyPoint(
     fsNew = FillSolid;
     if(pGC->fillStyle != FillSolid)
     {
-	DoChangeGC(pGC, GCFillStyle, &fsNew, 0);
+	dixChangeGC(NullClient, pGC, GCFillStyle, &fsNew, NULL);
 	ValidateGC(pDrawable, pGC);
     }
     pwidth = pwidthInit;
@@ -117,7 +117,7 @@ miPolyPoint(
 
     if(fsOld != FillSolid)
     {
-	DoChangeGC(pGC, GCFillStyle, &fsOld, 0);
+	dixChangeGC(NullClient, pGC, GCFillStyle, &fsOld, NULL);
 	ValidateGC(pDrawable, pGC);
     }
     xfree(pwidthInit);
diff --git a/mi/miwideline.c b/mi/miwideline.c
index c5203fe..069594c 100644
--- a/mi/miwideline.c
+++ b/mi/miwideline.c
@@ -114,7 +114,7 @@ fillSpans(DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel, Spans *spans, S
 	if (pixel != oldPixel)
 	{
 	    XID tmpPixel = (XID)pixel;
-	    DoChangeGC (pGC, GCForeground, &tmpPixel, FALSE);
+	    dixChangeGC (NullClient, pGC, GCForeground, &tmpPixel, NULL);
 	    ValidateGC (pDrawable, pGC);
 	}
 	(*pGC->ops->FillSpans) (pDrawable, pGC, spans->count, spans->points, spans->widths, TRUE);
@@ -122,7 +122,7 @@ fillSpans(DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel, Spans *spans, S
 	xfree (spans->points);
 	if (pixel != oldPixel)
 	{
-	    DoChangeGC (pGC, GCForeground, &oldPixel, FALSE);
+	    dixChangeGC (NullClient, pGC, GCForeground, &oldPixel, NULL);
 	    ValidateGC (pDrawable, pGC);
 	}
     }
@@ -260,13 +260,13 @@ miFillRectPolyHelper (
     	if (pixel != oldPixel)
     	{
 	    XID tmpPixel = (XID)pixel;
-    	    DoChangeGC (pGC, GCForeground, &tmpPixel, FALSE);
+	    dixChangeGC (NullClient, pGC, GCForeground, &tmpPixel, NULL);
     	    ValidateGC (pDrawable, pGC);
     	}
 	(*pGC->ops->PolyFillRect) (pDrawable, pGC, 1, &rect);
     	if (pixel != oldPixel)
     	{
-	    DoChangeGC (pGC, GCForeground, &oldPixel, FALSE);
+	    dixChangeGC (NullClient, pGC, GCForeground, &oldPixel, NULL);
 	    ValidateGC (pDrawable, pGC);
     	}
     }
@@ -1504,14 +1504,14 @@ miCleanupSpanData (DrawablePtr pDrawable, GCPtr pGC, SpanDataPtr spanData)
 	oldPixel = pGC->fgPixel;
     	if (pixel != oldPixel)
     	{
-    	    DoChangeGC (pGC, GCForeground, &pixel, FALSE);
+	    dixChangeGC (NullClient, pGC, GCForeground, &pixel, NULL);
     	    ValidateGC (pDrawable, pGC);
     	}
 	miFillUniqueSpanGroup (pDrawable, pGC, &spanData->bgGroup);
 	miFreeSpanGroup (&spanData->bgGroup);
     	if (pixel != oldPixel)
     	{
-	    DoChangeGC (pGC, GCForeground, &oldPixel, FALSE);
+	    dixChangeGC (NullClient, pGC, GCForeground, &oldPixel, NULL);
 	    ValidateGC (pDrawable, pGC);
     	}
     }
diff --git a/mi/miwideline.h b/mi/miwideline.h
index 1665ebf..2ff36ed 100644
--- a/mi/miwideline.h
+++ b/mi/miwideline.h
@@ -78,13 +78,13 @@ typedef struct _LineFace {
 #define MILINESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \
     oldPixel = pGC->fgPixel; \
     if (pixel != oldPixel) { \
-	DoChangeGC (pGC, GCForeground, (XID *) &pixel, FALSE); \
+	dixChangeGC (NullClient, pGC, GCForeground, (XID *) &pixel, NULL); \
 	ValidateGC (pDrawable, pGC); \
     } \
 }
 #define MILINERESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \
     if (pixel != oldPixel) { \
-	DoChangeGC (pGC, GCForeground, (XID *) &oldPixel, FALSE); \
+	dixChangeGC (NullClient, pGC, GCForeground, (XID *) &oldPixel, NULL); \
 	ValidateGC (pDrawable, pGC); \
     } \
 }
diff --git a/mi/mizerarc.c b/mi/mizerarc.c
index ad84c01..46d1e5c 100644
--- a/mi/mizerarc.c
+++ b/mi/mizerarc.c
@@ -803,7 +803,7 @@ miZeroPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
 	    if ((pGC->fillStyle == FillSolid) ||
 		(pGC->fillStyle == FillStippled))
 	    {
-		DoChangeGC(pGC, GCForeground, (XID *)&pGC->bgPixel, 0);
+		dixChangeGC(NullClient, pGC, GCForeground, (XID *)&pGC->bgPixel, NULL);
 		ValidateGC(pDraw, pGC);
 	    }
 	    pts = &points[numPts >> 1];
@@ -831,7 +831,7 @@ miZeroPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
 	    if ((pGC->fillStyle == FillSolid) ||
 		(pGC->fillStyle == FillStippled))
 	    {
-		DoChangeGC(pGC, GCForeground, &fgPixel, 0);
+		dixChangeGC(NullClient, pGC, GCForeground, &fgPixel, NULL);
 		ValidateGC(pDraw, pGC);
 	    }
 	}
diff --git a/xfixes/region.c b/xfixes/region.c
index 795caf0..6ccc723 100644
--- a/xfixes/region.c
+++ b/xfixes/region.c
@@ -643,7 +643,7 @@ ProcXFixesSetGCClipRegion (ClientPtr client)
     
     vals[0] = stuff->xOrigin;
     vals[1] = stuff->yOrigin;
-    DoChangeGC (pGC, GCClipXOrigin|GCClipYOrigin, vals, 0);
+    dixChangeGC (NullClient, pGC, GCClipXOrigin|GCClipYOrigin, vals, NULL);
     (*pGC->funcs->ChangeClip)(pGC, pRegion ? CT_REGION : CT_NONE, (pointer)pRegion, 0);
 
     return (client->noClientException);
-- 
1.7.0



More information about the xorg-devel mailing list