[PATCH 06/22] mi: Fix wrapping for sprite screen

Pauli ext-pauli.nieminen at nokia.com
Wed Dec 29 11:27:18 PST 2010


From: Pauli Nieminen <ext-pauli.nieminen at nokia.com>

SCREEN_EPILOGUE should read the current function pointer from screen
after calling wrapped function in case the pointer changes.

Passing pPriv to macros instead of asking dix each time makes sense when
both macros need same pointer.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
---
 mi/misprite.c |   47 +++++++++++++++++++++++++----------------------
 1 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/mi/misprite.c b/mi/misprite.c
index c42760c..6f2a0eb 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -217,11 +217,10 @@ static Bool         miSpriteDeviceCursorInitialize(DeviceIntPtr pDev,
 static void         miSpriteDeviceCursorCleanup(DeviceIntPtr pDev,
                                                 ScreenPtr pScreen);
 
-#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
-   ((miSpriteScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
-					miSpriteScreenKey))->field)
-#define SCREEN_EPILOGUE(pScreen, field)\
-    ((pScreen)->field = miSprite##field)
+#define SCREEN_PROLOGUE(pPriv, pScreen, field) ((pScreen)->field = \
+   (pPriv)->field)
+#define SCREEN_EPILOGUE(pPriv, pScreen, field)\
+    ((pPriv)->field = (pScreen)->field, (pScreen)->field = miSprite##field)
 
 /*
  * pointer-sprite method table
@@ -398,11 +397,12 @@ miSpriteGetImage (DrawablePtr pDrawable, int sx, int sy, int w, int h,
                   unsigned int format, unsigned long planemask,
                   char *pdstLine)
 {
-    ScreenPtr	    pScreen = pDrawable->pScreen;
-    DeviceIntPtr    pDev;
-    miCursorInfoPtr pCursorInfo;
+    ScreenPtr	        pScreen = pDrawable->pScreen;
+    DeviceIntPtr        pDev;
+    miCursorInfoPtr     pCursorInfo;
+    miSpriteScreenPtr   pPriv = GetSpriteScreen(pScreen);
 
-    SCREEN_PROLOGUE (pScreen, GetImage);
+    SCREEN_PROLOGUE (pPriv, pScreen, GetImage);
 
     if (pDrawable->type == DRAWABLE_WINDOW)
     {
@@ -425,7 +425,7 @@ miSpriteGetImage (DrawablePtr pDrawable, int sx, int sy, int w, int h,
     (*pScreen->GetImage) (pDrawable, sx, sy, w, h,
 			  format, planemask, pdstLine);
 
-    SCREEN_EPILOGUE (pScreen, GetImage);
+    SCREEN_EPILOGUE (pPriv, pScreen, GetImage);
 }
 
 static void
@@ -435,8 +435,9 @@ miSpriteGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
     ScreenPtr		    pScreen = pDrawable->pScreen;
     DeviceIntPtr            pDev;
     miCursorInfoPtr         pCursorInfo;
+    miSpriteScreenPtr       pPriv = GetSpriteScreen(pScreen);
 
-    SCREEN_PROLOGUE (pScreen, GetSpans);
+    SCREEN_PROLOGUE (pPriv, pScreen, GetSpans);
 
     if (pDrawable->type == DRAWABLE_WINDOW)
     {
@@ -476,7 +477,7 @@ miSpriteGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
 
     (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
 
-    SCREEN_EPILOGUE (pScreen, GetSpans);
+    SCREEN_EPILOGUE (pPriv, pScreen, GetSpans);
 }
 
 static void
@@ -486,8 +487,9 @@ miSpriteSourceValidate (DrawablePtr pDrawable, int x, int y, int width,
     ScreenPtr		    pScreen = pDrawable->pScreen;
     DeviceIntPtr            pDev;
     miCursorInfoPtr         pCursorInfo;
+    miSpriteScreenPtr       pPriv = GetSpriteScreen(pScreen);
 
-    SCREEN_PROLOGUE (pScreen, SourceValidate);
+    SCREEN_PROLOGUE (pPriv, pScreen, SourceValidate);
 
     if (pDrawable->type == DRAWABLE_WINDOW)
     {
@@ -510,7 +512,7 @@ miSpriteSourceValidate (DrawablePtr pDrawable, int x, int y, int width,
     if (pScreen->SourceValidate)
 	(*pScreen->SourceValidate) (pDrawable, x, y, width, height);
 
-    SCREEN_EPILOGUE (pScreen, SourceValidate);
+    SCREEN_EPILOGUE (pPriv, pScreen, SourceValidate);
 }
 
 static void
@@ -519,8 +521,9 @@ miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
     ScreenPtr	pScreen = pWindow->drawable.pScreen;
     DeviceIntPtr            pDev;
     miCursorInfoPtr         pCursorInfo;
+    miSpriteScreenPtr       pPriv = GetSpriteScreen(pScreen);
 
-    SCREEN_PROLOGUE (pScreen, CopyWindow);
+    SCREEN_PROLOGUE (pPriv, pScreen, CopyWindow);
 
     for(pDev = inputInfo.devices; pDev; pDev = pDev->next)
     {
@@ -540,7 +543,7 @@ miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
     }
 
     (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc);
-    SCREEN_EPILOGUE (pScreen, CopyWindow);
+    SCREEN_EPILOGUE (pPriv, pScreen, CopyWindow);
 }
 
 static void
@@ -552,11 +555,11 @@ miSpriteBlockHandler (int i, pointer blockData, pointer pTimeout,
     DeviceIntPtr            pDev;
     miCursorInfoPtr         pCursorInfo;
 
-    SCREEN_PROLOGUE(pScreen, BlockHandler);
+    SCREEN_PROLOGUE(pPriv, pScreen, BlockHandler);
 
     (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
 
-    SCREEN_EPILOGUE(pScreen, BlockHandler);
+    SCREEN_EPILOGUE(pPriv, pScreen, BlockHandler);
 
     for(pDev = inputInfo.devices; pDev; pDev = pDev->next)
     {
@@ -594,11 +597,11 @@ miSpriteInstallColormap (ColormapPtr pMap)
     ScreenPtr		pScreen = pMap->pScreen;
     miSpriteScreenPtr   pPriv = GetSpriteScreen(pScreen);
 
-    SCREEN_PROLOGUE(pScreen, InstallColormap);
+    SCREEN_PROLOGUE(pPriv, pScreen, InstallColormap);
 
     (*pScreen->InstallColormap) (pMap);
 
-    SCREEN_EPILOGUE(pScreen, InstallColormap);
+    SCREEN_EPILOGUE(pPriv, pScreen, InstallColormap);
 
     /* InstallColormap can be called before devices are initialized. */
     pPriv->pInstalledMap = pMap;
@@ -631,11 +634,11 @@ miSpriteStoreColors (ColormapPtr pMap, int ndef, xColorItem *pdef)
     DeviceIntPtr        pDev;
     miCursorInfoPtr     pCursorInfo;
 
-    SCREEN_PROLOGUE(pScreen, StoreColors);
+    SCREEN_PROLOGUE(pPriv, pScreen, StoreColors);
 
     (*pScreen->StoreColors) (pMap, ndef, pdef);
 
-    SCREEN_EPILOGUE(pScreen, StoreColors);
+    SCREEN_EPILOGUE(pPriv, pScreen, StoreColors);
 
     if (pPriv->pColormap == pMap)
     {
-- 
1.7.0.4



More information about the xorg-devel mailing list