[PATCH 3/3] dix: more lookup function consolidation, macro removal

Eamon Walsh ewalsh at tycho.nsa.gov
Mon Jan 29 17:06:23 PST 2007


Replaces LOOKUP_DRAWABLE_AND_GC macro with dixLookupDrawableGCPair() 
function.

Signed-off-by: Eamon Walsh <ewalsh at tycho.nsa.gov>

---
 dix/dispatch.c             |    6 ---
 dix/dixutils.c             |   26 +++++++++++++
 hw/xfree86/loader/dixsym.c |    1 
 include/dix.h              |   90 ++++-----------------------------------------
 4 files changed, 35 insertions(+), 88 deletions(-)

---
diff --git a/dix/dispatch.c b/dix/dispatch.c
index d44687e..a3bd14f 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -1804,8 +1804,6 @@ ProcCopyArea(register ClientPtr client)
     else
         pSrc = pDst;
 
-    SET_DBE_SRCBUF(pSrc, stuff->srcDrawable);
-
     pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, stuff->srcX, stuff->srcY,
 				 stuff->width, stuff->height, 
 				 stuff->dstX, stuff->dstY);
@@ -1848,8 +1846,6 @@ ProcCopyPlane(register ClientPtr client)
     else
         psrcDraw = pdstDraw;
 
-    SET_DBE_SRCBUF(psrcDraw, stuff->srcDrawable);
-
     /* Check to see if stuff->bitPlane has exactly ONE good bit set */
     if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) ||
        (stuff->bitPlane > (1L << (psrcDraw->depth - 1))))
@@ -2210,8 +2206,6 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable,
 	xgi.visual = None;
     }
 
-    SET_DBE_SRCBUF(pDraw, drawable);
-
     xgi.type = X_Reply;
     xgi.sequenceNumber = client->sequence;
     xgi.depth = pDraw->depth;
diff --git a/dix/dixutils.c b/dix/dixutils.c
index 226cc6b..dbc8331 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -262,6 +262,32 @@ dixLookupGC(GCPtr *pGC, XID id, ClientPtr client, Mask access)
 }
 
 _X_EXPORT int
+dixLookupDrawableGCPair(DrawablePtr *pDraw, GCPtr *pGC, XID drawID, XID gcID,
+			ClientPtr client, Mask access)
+{
+    if (gcID == INVALID ||
+	client->lastGCID != gcID || client->lastDrawableID != drawID) {
+	int rc = dixLookupDrawable(pDraw, drawID, client, M_ANY, access);
+	if (rc != Success)
+	    return rc;
+	rc = dixLookupGC(pGC, gcID, client, DixReadAccess);
+	if (rc != Success)
+	    return rc;
+	if (*pGC->depth != *pDraw->depth || *pGC->pScreen != *pDraw->pScreen)
+	    return BadMatch;
+	client->lastDrawable = *pDraw;
+	client->lastDrawableID = drawID;
+	client->lastGC = *pGC;
+	client->lastGCID = gcID;
+    } else {
+        *pGC = client->lastGC;
+        *pDraw = client->lastDrawable;
+    }
+    if (*pGC->serialNumber != *pDraw->serialNumber)
+	ValidateGC(*pDraw, *pGC);
+}
+
+_X_EXPORT int
 dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access)
 {
     pointer pRes = (pointer)SecurityLookupIDByClass(client, rid, RC_ANY,
diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c
index bc22d75..056c902 100644
--- a/hw/xfree86/loader/dixsym.c
+++ b/hw/xfree86/loader/dixsym.c
@@ -169,6 +169,7 @@ _X_HIDDEN void *dixLookupTab[] = {
     SYMFUNC(dixLookupWindow)
     SYMFUNC(dixLookupClient)
     SYMFUNC(dixLookupGC)
+    SYMFUNC(dixLookupDrawableGCPair)
     SYMFUNC(NoopDDA)
     SYMFUNC(QueueWorkProc)
     SYMFUNC(RegisterBlockAndWakeupHandlers)
diff --git a/include/dix.h b/include/dix.h
index 9351b76..c21fce6 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -81,88 +81,6 @@ SOFTWARE.
         return(BadIDChoice);\
     }
 
-/*
- * We think that most hardware implementations of DBE will want
- * LookupID*(dbe_back_buffer_id) to return the window structure that the
- * id is a back buffer for.  Since both front and back buffers will
- * return the same structure, you need to be able to distinguish
- * somewhere what kind of buffer (front/back) was being asked for, so
- * that ddx can render to the right place.  That's the problem that the
- * following code solves.  Note: we couldn't embed this in the LookupID*
- * functions because the VALIDATE_DRAWABLE_AND_GC macro often circumvents
- * those functions by checking a one-element cache.  That's why we're
- * mucking with VALIDATE_DRAWABLE_AND_GC.
- * 
- * If you put -DNEED_DBE_BUF_BITS into PervasiveDBEDefines, the window
- * structure will have two additional bits defined, srcBuffer and
- * dstBuffer, and their values will be maintained via the macros
- * SET_DBE_DSTBUF and SET_DBE_SRCBUF (below).  If you also
- * put -DNEED_DBE_BUF_VALIDATE into PervasiveDBEDefines, the function
- * DbeValidateBuffer will be called any time the bits change to give you
- * a chance to do some setup.  See the DBE code for more details on this
- * function.  We put in these levels of conditionality so that you can do
- * just what you need to do, and no more.  If neither of these defines
- * are used, the bits won't be there, and VALIDATE_DRAWABLE_AND_GC will
- * be unchanged.	dpw
- */
-
-#if defined(NEED_DBE_BUF_BITS)
-#define SET_DBE_DSTBUF(_pDraw, _drawID) \
-        SET_DBE_BUF(_pDraw, _drawID, dstBuffer, TRUE)
-#define SET_DBE_SRCBUF(_pDraw, _drawID) \
-        SET_DBE_BUF(_pDraw, _drawID, srcBuffer, FALSE)
-#if defined (NEED_DBE_BUF_VALIDATE)
-#define SET_DBE_BUF(_pDraw, _drawID, _whichBuffer, _dstbuf) \
-    if (_pDraw->type == DRAWABLE_WINDOW)\
-    {\
-	int thisbuf = (_pDraw->id == _drawID);\
-	if (thisbuf != ((WindowPtr)_pDraw)->_whichBuffer)\
-	{\
-	     ((WindowPtr)_pDraw)->_whichBuffer = thisbuf;\
-	     DbeValidateBuffer((WindowPtr)_pDraw, _drawID, _dstbuf);\
-	}\
-     }
-#else /* want buffer bits, but don't need to call DbeValidateBuffer */
-#define SET_DBE_BUF(_pDraw, _drawID, _whichBuffer, _dstbuf) \
-    if (_pDraw->type == DRAWABLE_WINDOW)\
-    {\
-	((WindowPtr)_pDraw)->_whichBuffer = (_pDraw->id == _drawID);\
-    }
-#endif /* NEED_DBE_BUF_VALIDATE */
-#else /* don't want buffer bits in window */
-#define SET_DBE_DSTBUF(_pDraw, _drawID) /**/
-#define SET_DBE_SRCBUF(_pDraw, _drawID) /**/
-#endif /* NEED_DBE_BUF_BITS */
-
-#define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, pGC, client)\
-    if ((stuff->gc == INVALID) || (client->lastGCID != stuff->gc) ||\
-	(client->lastDrawableID != drawID))\
-    {\
-	int rc;\
-	rc = dixLookupDrawable(&(pDraw), drawID, client, M_ANY,\
-			       DixWriteAccess);\
-	if (rc != Success)\
-	    return rc;\
-	rc = dixLookupGC(&(pGC), stuff->gc, client, DixReadAccess);\
-	if (rc != Success)\
-	    return rc;\
-	if ((pGC->depth != pDraw->depth) || (pGC->pScreen != pDraw->pScreen))\
-	    return (BadMatch);\
-	client->lastDrawable = pDraw;\
-	client->lastDrawableID = drawID;\
-	client->lastGC = pGC;\
-	client->lastGCID = stuff->gc;\
-    }\
-    else\
-    {\
-        pGC = client->lastGC;\
-        pDraw = client->lastDrawable;\
-    }\
-    SET_DBE_DSTBUF(pDraw, drawID);\
-    if (pGC->serialNumber != pDraw->serialNumber)\
-	ValidateGC(pDraw, pGC);
-
-
 #define WriteReplyToClient(pClient, size, pReply) { \
    if ((pClient)->swapped) \
       (*ReplySwapVector[((xReq *)(pClient)->requestBuffer)->reqType]) \
@@ -298,6 +216,14 @@ extern int dixLookupGC(
     ClientPtr client,
     Mask access_mode);
 
+extern int dixLookupDrawableGCPair(
+    DrawablePtr *dResult,
+    GCPtr *gResult,
+    XID did,
+    XID gid,
+    ClientPtr client,
+    Mask access_mode);
+
 extern int dixLookupClient(
     ClientPtr *result,
     XID id,




-- 
Eamon Walsh <ewalsh at tycho.nsa.gov>
National Security Agency




More information about the xorg mailing list