[PATCH 08/22] mi: Register sprite damage handler only when required

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


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

There is no need to have damage handler registered when there isn't any
pointer in the screen. This avoids some overhead from damage handling
which takes tens of microseconds on arm.

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

diff --git a/mi/misprite.c b/mi/misprite.c
index a8e4d4e..3106c99 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -96,6 +96,7 @@ typedef struct {
     VisualPtr	    pVisual;
     DamagePtr	    pDamage;		/* damage tracking structure */
     Bool            damageRegistered;
+    int             numberOfCursors;
 } miSpriteScreenRec, *miSpriteScreenPtr;
 
 #define SOURCE_COLOR	0
@@ -346,6 +347,7 @@ miSpriteInitialize (ScreenPtr               pScreen,
     pScreenPriv->colors[MASK_COLOR].green = 0;
     pScreenPriv->colors[MASK_COLOR].blue = 0;
     pScreenPriv->damageRegistered = 0;
+    pScreenPriv->numberOfCursors = 0;
 
     dixSetPrivate(&pScreen->devPrivates, miSpriteScreenKey, pScreenPriv);
 
@@ -773,21 +775,29 @@ static void
 miSpriteSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
                    CursorPtr pCursor, int x, int y)
 {
-    miCursorInfoPtr pPointer;
+    miCursorInfoPtr     pPointer;
+    miSpriteScreenPtr   pScreenPriv;
 
     if (!IsMaster(pDev) && !pDev->u.master)
         return;
 
     pPointer = MISPRITE(pDev);
+    pScreenPriv = GetSpriteScreen(pScreen);
 
     if (!pCursor)
     {
+	if (pPointer->shouldBeUp)
+	    --pScreenPriv->numberOfCursors;
     	pPointer->shouldBeUp = FALSE;
     	if (pPointer->isUp)
 	    miSpriteRemoveCursor (pDev, pScreen);
+	if (pScreenPriv->numberOfCursors == 0)
+	    miSpriteDisableDamage(pScreen, pScreenPriv);
 	pPointer->pCursor = 0;
 	return;
     }
+    if (!pPointer->shouldBeUp)
+	pScreenPriv->numberOfCursors++;
     pPointer->shouldBeUp = TRUE;
     if (pPointer->x == x &&
 	pPointer->y == y &&
-- 
1.7.0.4



More information about the xorg-devel mailing list