[PATCH 2/6] exa: clean up some more code

Maarten Maathuis madman2003 at gmail.com
Sat Feb 28 16:36:31 PST 2009


---
 exa/exa.c |   56 +++++++++++++++++++++++++++++++-------------------------
 1 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/exa/exa.c b/exa/exa.c
index b0a26e9..17d75d2 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -48,17 +48,6 @@ DevPrivateKey exaGCPrivateKey = &exaGCPrivateKeyIndex;
 static ShmFuncs exaShmFuncs = { NULL, NULL };
 #endif
 
-static _X_INLINE void*
-ExaGetPixmapAddress(PixmapPtr p)
-{
-    ExaPixmapPriv(p);
-
-    if (pExaPixmap->offscreen && pExaPixmap->fb_ptr)
-	return pExaPixmap->fb_ptr;
-    else
-	return pExaPixmap->sys_ptr;
-}
-
 /**
  * exaGetPixmapOffset() returns the offset (in bytes) within the framebuffer of
  * the beginning of the given pixmap.
@@ -73,8 +62,9 @@ unsigned long
 exaGetPixmapOffset(PixmapPtr pPix)
 {
     ExaScreenPriv (pPix->drawable.pScreen);
+    ExaPixmapPriv (pPix);
 
-    return (CARD8 *)ExaGetPixmapAddress(pPix) - pExaScr->info->memoryBase;
+    return (CARD8 *)pExaPixmap->fb_ptr - pExaScr->info->memoryBase;
 }
 
 void *
@@ -449,15 +439,20 @@ exaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
 	}
     }
 
-
     if (pExaScr->info->ModifyPixmapHeader) {
 	ret = pExaScr->info->ModifyPixmapHeader(pPixmap, width, height, depth,
 						bitsPerPixel, devKind, pPixData);
 	if (ret == TRUE)
-	    return ret;
+	    goto out;
     }
-    return pExaScr->SavedModifyPixmapHeader(pPixmap, width, height, depth,
+    ret = pExaScr->SavedModifyPixmapHeader(pPixmap, width, height, depth,
 					    bitsPerPixel, devKind, pPixData);
+
+out:
+    /* Always NULL this, we don't want lingering pointers. */
+    pPixmap->devPrivate.ptr = NULL;
+
+    return ret;
 }
 
 /**
@@ -520,14 +515,26 @@ exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp)
 Bool
 ExaDoPrepareAccess(DrawablePtr pDrawable, int index)
 {
-    ScreenPtr	    pScreen = pDrawable->pScreen;
-    ExaScreenPriv  (pScreen);
-    PixmapPtr	    pPixmap = exaGetDrawablePixmap (pDrawable);
-    Bool	    offscreen = exaPixmapIsOffscreen(pPixmap);
+    ScreenPtr pScreen = pDrawable->pScreen;
+    ExaScreenPriv (pScreen);
+    PixmapPtr pPixmap = exaGetDrawablePixmap (pDrawable);
+    ExaPixmapPriv(pPixmap);
+    Bool offscreen;
+
+    if (!pExaPixmap)
+	FatalError("Calling PrepareAccess on a pixmap not known to exa.\n");
 
-    /* Unhide pixmap pointer */
-    if (pPixmap->devPrivate.ptr == NULL && !(pExaScr->info->flags & EXA_HANDLES_PIXMAPS)) {
-	pPixmap->devPrivate.ptr = ExaGetPixmapAddress(pPixmap);
+    if (pPixmap->devPrivate.ptr != NULL)
+	FatalError("Unbalanced Prepare/FinishAccess or data corruption."
+	    "pPixmap->devPrivate.ptr is %p.\n", pPixmap->devPrivate.ptr);
+
+    offscreen = exaPixmapIsOffscreen(pPixmap);
+
+    if (!(pExaScr->info->flags & EXA_HANDLES_PIXMAPS)) {
+	if (offscreen)
+	    pPixmap->devPrivate.ptr = pExaPixmap->fb_ptr;
+	else
+	    pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr;
     }
 
     if (!offscreen)
@@ -545,9 +552,8 @@ ExaDoPrepareAccess(DrawablePtr pDrawable, int index)
     }
 
     if (!(*pExaScr->info->PrepareAccess) (pPixmap, index)) {
-	ExaPixmapPriv (pPixmap);
 	if (pExaPixmap->score == EXA_PIXMAP_SCORE_PINNED)
-	    FatalError("Driver failed PrepareAccess on a pinned pixmap\n");
+	    FatalError("Driver failed PrepareAccess on a pinned pixmap.\n");
 	exaMoveOutPixmap (pPixmap);
 
 	return FALSE;
-- 
1.6.1.3



More information about the xorg-devel mailing list