[PATCH 09/22] mi: Only register sprite block handler when needed

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


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

miSpriteBlockHandler takes about 10us in arm each time BlockHandlers are
called. To eliminate that overhead from xserver side only register the
BlockHandler when there actually is any cursor down.

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

diff --git a/mi/misprite.c b/mi/misprite.c
index 3106c99..620fcc8 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -257,6 +257,15 @@ static void miSpriteRestoreCursor(DeviceIntPtr pDev,
                                  ScreenPtr pScreen);
 
 static void
+miSpriteRegisterBlockHandler(ScreenPtr pScreen, miSpriteScreenPtr pScreenPriv)
+{
+    if (!pScreenPriv->BlockHandler) {
+        pScreenPriv->BlockHandler = pScreen->BlockHandler;
+        pScreen->BlockHandler = miSpriteBlockHandler;
+    }
+}
+
+static void
 miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
 {
     ScreenPtr		    pScreen = closure;
@@ -333,7 +342,7 @@ miSpriteInitialize (ScreenPtr               pScreen,
     pScreenPriv->InstallColormap = pScreen->InstallColormap;
     pScreenPriv->StoreColors = pScreen->StoreColors;
 
-    pScreenPriv->BlockHandler = pScreen->BlockHandler;
+    pScreenPriv->BlockHandler = NULL;
 
     pScreenPriv->DeviceCursorInitialize = pScreen->DeviceCursorInitialize;
     pScreenPriv->DeviceCursorCleanup = pScreen->DeviceCursorCleanup;
@@ -360,8 +369,6 @@ miSpriteInitialize (ScreenPtr               pScreen,
     pScreen->InstallColormap = miSpriteInstallColormap;
     pScreen->StoreColors = miSpriteStoreColors;
 
-    pScreen->BlockHandler = miSpriteBlockHandler;
-
     return TRUE;
 }
 
@@ -383,7 +390,6 @@ miSpriteCloseScreen (int i, ScreenPtr pScreen)
     pScreen->GetImage = pScreenPriv->GetImage;
     pScreen->GetSpans = pScreenPriv->GetSpans;
     pScreen->SourceValidate = pScreenPriv->SourceValidate;
-    pScreen->BlockHandler = pScreenPriv->BlockHandler;
     pScreen->InstallColormap = pScreenPriv->InstallColormap;
     pScreen->StoreColors = pScreenPriv->StoreColors;
 
@@ -556,12 +562,7 @@ miSpriteBlockHandler (int i, pointer blockData, pointer pTimeout,
     miSpriteScreenPtr   pPriv = GetSpriteScreen(pScreen);
     DeviceIntPtr            pDev;
     miCursorInfoPtr         pCursorInfo;
-
-    SCREEN_PROLOGUE(pPriv, pScreen, BlockHandler);
-
-    (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
-
-    SCREEN_EPILOGUE(pPriv, pScreen, BlockHandler);
+    Bool                WorkToDo = FALSE;
 
     for(pDev = inputInfo.devices; pDev; pDev = pDev->next)
     {
@@ -588,9 +589,20 @@ miSpriteBlockHandler (int i, pointer blockData, pointer pTimeout,
             {
                 SPRITE_DEBUG (("BlockHandler restore\n"));
                 miSpriteRestoreCursor (pDev, pScreen);
+                if (!pCursorInfo->isUp)
+                    WorkToDo = TRUE;
             }
         }
     }
+
+    SCREEN_PROLOGUE(pPriv, pScreen, BlockHandler);
+
+    (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
+
+    if (WorkToDo)
+        SCREEN_EPILOGUE(pPriv, pScreen, BlockHandler);
+    else
+        pPriv->BlockHandler = NULL;
 }
 
 static void
@@ -799,6 +811,8 @@ miSpriteSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
     if (!pPointer->shouldBeUp)
 	pScreenPriv->numberOfCursors++;
     pPointer->shouldBeUp = TRUE;
+    if (!pPointer->isUp)
+	miSpriteRegisterBlockHandler(pScreen, pScreenPriv);
     if (pPointer->x == x &&
 	pPointer->y == y &&
 	pPointer->pCursor == pCursor &&
@@ -899,6 +913,7 @@ miSpriteRemoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen)
     pCursorInfo = MISPRITE(pDev);
 
     miSpriteIsDown(pCursorInfo);
+    miSpriteRegisterBlockHandler(pScreen, pScreenPriv);
     pCursorInfo->pCacheWin = NullWindow;
     miSpriteDisableDamage(pScreen, pScreenPriv);
     if (!miDCRestoreUnderCursor(pDev,
-- 
1.7.0.4



More information about the xorg-devel mailing list