xserver: Branch 'master' - 4 commits

Adam Jackson ajax at kemper.freedesktop.org
Mon Jan 8 19:43:38 UTC 2018


 include/inputstr.h |    1 
 render/animcur.c   |  105 ++++++++++++++++-------------------------------------
 2 files changed, 32 insertions(+), 74 deletions(-)

New commits:
commit ab54bc295cd05281e55bd4d9c37216c0a929fc83
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Oct 26 15:33:14 2017 -0400

    animcur: Stop tracking the last display time in the SpriteInfoRec
    
    Reviewed-by: Robert Morell <rmorell at nvidia.com>
    Tested-by: Robert Morell <rmorell at nvidia.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/include/inputstr.h b/include/inputstr.h
index 568f5f991..5f0026b9b 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -515,7 +515,6 @@ typedef struct _SpriteInfoRec {
         CursorPtr pCursor;
         ScreenPtr pScreen;
         int elt;
-        CARD32 time;
     } anim;
 } SpriteInfoRec, *SpriteInfoPtr;
 
diff --git a/render/animcur.c b/render/animcur.c
index 9393b4018..058bc1b32 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -147,7 +147,6 @@ AnimCurTimerNotify(OsTimerPtr timer, CARD32 now, void *arg)
     pScreen->DisplayCursor = DisplayCursor;
 
     dev->spriteInfo->anim.elt = elt;
-    dev->spriteInfo->anim.time = now + ac->elts[elt].delay;
 
     return ac->elts[elt].delay;
 }
@@ -170,8 +169,6 @@ AnimCurDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
                 (pDev, pScreen, ac->elts[0].pCursor);
             if (ret) {
                 pDev->spriteInfo->anim.elt = 0;
-                pDev->spriteInfo->anim.time =
-                    GetTimeInMillis() + ac->elts[0].delay;
                 pDev->spriteInfo->anim.pCursor = pCursor;
                 pDev->spriteInfo->anim.pScreen = pScreen;
 
commit 094a63d56fbfb9e23210cc9ac538fb198af37cee
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Oct 26 15:24:39 2017 -0400

    animcur: Run the timer from the device, not the screen
    
    This is very slightly more efficient since the callback now doesn't need
    to walk every input device, instead we know exactly which device's
    cursor is being updated. AnimCurTimerNotify() gets outdented nicely as a
    result. A more important side effect is that we can stop using the
    TimerAbsolute mode and just pass in the relative delay.
    
    In AnimCurSetCursorPosition, we no longer need to rearm the timer with
    the new screen; it is enough to update the device's state. In
    AnimCurDisplayCursor we need to notice when we're switching from
    animated cursor to regular and cancel the existing timer.
    
    Reviewed-by: Robert Morell <rmorell at nvidia.com>
    Tested-by: Robert Morell <rmorell at nvidia.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/render/animcur.c b/render/animcur.c
index 26a6026ae..9393b4018 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -55,6 +55,7 @@ typedef struct _AnimCurElt {
 typedef struct _AnimCur {
     int nelt;                   /* number of elements in the elts array */
     AnimCurElt *elts;           /* actually allocated right after the structure */
+    OsTimerPtr timer;
 } AnimCurRec, *AnimCurPtr;
 
 typedef struct _AnimScrPriv {
@@ -65,8 +66,6 @@ typedef struct _AnimScrPriv {
     RealizeCursorProcPtr RealizeCursor;
     UnrealizeCursorProcPtr UnrealizeCursor;
     RecolorCursorProcPtr RecolorCursor;
-    OsTimerPtr timer;
-    Bool timer_set;
 } AnimCurScreenRec, *AnimCurScreenPtr;
 
 static unsigned char empty[4];
@@ -130,49 +129,27 @@ AnimCurCursorLimits(DeviceIntPtr pDev,
 static CARD32
 AnimCurTimerNotify(OsTimerPtr timer, CARD32 now, void *arg)
 {
-    ScreenPtr pScreen = arg;
+    DeviceIntPtr dev = arg;
+    ScreenPtr pScreen = dev->spriteInfo->anim.pScreen;
     AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
-    DeviceIntPtr dev;
-    Bool activeDevice = FALSE;
-    CARD32 soonest = ~0;       /* earliest time to wakeup again */
-
-    for (dev = inputInfo.devices; dev; dev = dev->next) {
-        if (IsPointerDevice(dev) && pScreen == dev->spriteInfo->anim.pScreen) {
-            if (!activeDevice)
-                activeDevice = TRUE;
-
-            if ((INT32) (now - dev->spriteInfo->anim.time) >= 0) {
-                AnimCurPtr ac = GetAnimCur(dev->spriteInfo->anim.pCursor);
-                int elt = (dev->spriteInfo->anim.elt + 1) % ac->nelt;
-                DisplayCursorProcPtr DisplayCursor;
-
-                /*
-                 * Not a simple Unwrap/Wrap as this
-                 * isn't called along the DisplayCursor
-                 * wrapper chain.
-                 */
-                DisplayCursor = pScreen->DisplayCursor;
-                pScreen->DisplayCursor = as->DisplayCursor;
-                (void) (*pScreen->DisplayCursor) (dev,
-                                                  pScreen,
-                                                  ac->elts[elt].pCursor);
-                as->DisplayCursor = pScreen->DisplayCursor;
-                pScreen->DisplayCursor = DisplayCursor;
-
-                dev->spriteInfo->anim.elt = elt;
-                dev->spriteInfo->anim.time = now + ac->elts[elt].delay;
-            }
 
-            if (soonest > dev->spriteInfo->anim.time)
-                soonest = dev->spriteInfo->anim.time;
-        }
-    }
+    AnimCurPtr ac = GetAnimCur(dev->spriteInfo->anim.pCursor);
+    int elt = (dev->spriteInfo->anim.elt + 1) % ac->nelt;
+    DisplayCursorProcPtr DisplayCursor = pScreen->DisplayCursor;
 
-    if (activeDevice)
-        return soonest - now;
+    /*
+     * Not a simple Unwrap/Wrap as this isn't called along the DisplayCursor
+     * wrapper chain.
+     */
+    pScreen->DisplayCursor = as->DisplayCursor;
+    (void) (*pScreen->DisplayCursor) (dev, pScreen, ac->elts[elt].pCursor);
+    as->DisplayCursor = pScreen->DisplayCursor;
+    pScreen->DisplayCursor = DisplayCursor;
 
-    as->timer_set = FALSE;
-    return 0;
+    dev->spriteInfo->anim.elt = elt;
+    dev->spriteInfo->anim.time = now + ac->elts[elt].delay;
+
+    return ac->elts[elt].delay;
 }
 
 static Bool
@@ -198,17 +175,19 @@ AnimCurDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
                 pDev->spriteInfo->anim.pCursor = pCursor;
                 pDev->spriteInfo->anim.pScreen = pScreen;
 
-                if (!as->timer_set) {
-                    TimerSet(as->timer, TimerAbsolute, pDev->spriteInfo->anim.time,
-                             AnimCurTimerNotify, pScreen);
-                    as->timer_set = TRUE;
-                }
+                ac->timer = TimerSet(ac->timer, 0, ac->elts[0].delay,
+                                     AnimCurTimerNotify, pDev);
             }
         }
         else
             ret = TRUE;
     }
     else {
+        CursorPtr old = pDev->spriteInfo->anim.pCursor;
+
+        if (old && IsAnimCur(old))
+            TimerCancel(GetAnimCur(old)->timer);
+
         pDev->spriteInfo->anim.pCursor = 0;
         pDev->spriteInfo->anim.pScreen = 0;
         ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
@@ -227,12 +206,6 @@ AnimCurSetCursorPosition(DeviceIntPtr pDev,
     Unwrap(as, pScreen, SetCursorPosition);
     if (pDev->spriteInfo->anim.pCursor) {
         pDev->spriteInfo->anim.pScreen = pScreen;
-
-        if (!as->timer_set) {
-            TimerSet(as->timer, TimerAbsolute, pDev->spriteInfo->anim.time,
-                     AnimCurTimerNotify, pScreen);
-            as->timer_set = TRUE;
-        }
     }
     ret = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
     Wrap(as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
@@ -307,11 +280,6 @@ AnimCurInit(ScreenPtr pScreen)
         return FALSE;
 
     as = GetAnimCurScreen(pScreen);
-    as->timer = TimerSet(NULL, TimerAbsolute, 0, AnimCurTimerNotify, pScreen);
-    if (!as->timer) {
-        return FALSE;
-    }
-    as->timer_set = FALSE;
 
     Wrap(as, pScreen, CloseScreen, AnimCurCloseScreen);
 
@@ -359,10 +327,14 @@ AnimCursorCreate(CursorPtr *cursors, CARD32 *deltas, int ncursor,
 
     pCursor->id = cid;
 
+    ac = GetAnimCur(pCursor);
+    ac->timer = TimerSet(NULL, 0, 0, AnimCurTimerNotify, NULL);
+
     /* security creation/labeling check */
     rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR, pCursor,
                   RT_NONE, NULL, DixCreateAccess);
     if (rc != Success) {
+        TimerFree(ac->timer);
         dixFiniPrivates(pCursor, PRIVATE_CURSOR);
         free(pCursor);
         return rc;
@@ -372,7 +344,6 @@ AnimCursorCreate(CursorPtr *cursors, CARD32 *deltas, int ncursor,
      * Fill in the AnimCurRec
      */
     animCursorBits.refcnt++;
-    ac = GetAnimCur(pCursor);
     ac->nelt = ncursor;
     ac->elts = (AnimCurElt *) (ac + 1);
 
commit cc3241a712684f8c7147f5688e9ee3ecb5a93b87
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Oct 26 13:53:06 2017 -0400

    animcur: Return the next interval directly from the timer callback
    
    If the return value is non-zero here, DoTimer() will automatically rearm
    the timer for the new (relative) delay. 'soonest' is in absolute time,
    so subtract off 'now' and return that.
    
    Reviewed-by: Robert Morell <rmorell at nvidia.com>
    Tested-by: Robert Morell <rmorell at nvidia.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/render/animcur.c b/render/animcur.c
index 3f85f9a4f..26a6026ae 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -169,10 +169,9 @@ AnimCurTimerNotify(OsTimerPtr timer, CARD32 now, void *arg)
     }
 
     if (activeDevice)
-        TimerSet(as->timer, TimerAbsolute, soonest, AnimCurTimerNotify, pScreen);
-    else
-        as->timer_set = FALSE;
+        return soonest - now;
 
+    as->timer_set = FALSE;
     return 0;
 }
 
commit 3abbdb7318018584a27220737bd92081ce8ee67c
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Oct 26 13:40:57 2017 -0400

    animcur: Use fixed-size screen private
    
    Reviewed-by: Robert Morell <rmorell at nvidia.com>
    Tested-by: Robert Morell <rmorell at nvidia.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/render/animcur.c b/render/animcur.c
index 52e6b8b79..3f85f9a4f 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -77,12 +77,9 @@ static CursorBits animCursorBits = {
 
 static DevPrivateKeyRec AnimCurScreenPrivateKeyRec;
 
-#define AnimCurScreenPrivateKey (&AnimCurScreenPrivateKeyRec)
-
 #define IsAnimCur(c)	    ((c) && ((c)->bits == &animCursorBits))
 #define GetAnimCur(c)	    ((AnimCurPtr) ((((char *)(c) + CURSOR_REC_SIZE))))
-#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey))
-#define SetAnimCurScreen(s,p) dixSetPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey, p)
+#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, &AnimCurScreenPrivateKeyRec))
 
 #define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
 #define Unwrap(as,s,elt)    ((s)->elt = (as)->elt)
@@ -101,9 +98,7 @@ AnimCurCloseScreen(ScreenPtr pScreen)
     Unwrap(as, pScreen, RealizeCursor);
     Unwrap(as, pScreen, UnrealizeCursor);
     Unwrap(as, pScreen, RecolorCursor);
-    SetAnimCurScreen(pScreen, 0);
     ret = (*pScreen->CloseScreen) (pScreen);
-    free(as);
     return ret;
 }
 
@@ -308,15 +303,13 @@ AnimCurInit(ScreenPtr pScreen)
 {
     AnimCurScreenPtr as;
 
-    if (!dixRegisterPrivateKey(&AnimCurScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+    if (!dixRegisterPrivateKey(&AnimCurScreenPrivateKeyRec, PRIVATE_SCREEN,
+                               sizeof(AnimCurScreenRec)))
         return FALSE;
 
-    as = (AnimCurScreenPtr) malloc(sizeof(AnimCurScreenRec));
-    if (!as)
-        return FALSE;
+    as = GetAnimCurScreen(pScreen);
     as->timer = TimerSet(NULL, TimerAbsolute, 0, AnimCurTimerNotify, pScreen);
     if (!as->timer) {
-        free(as);
         return FALSE;
     }
     as->timer_set = FALSE;
@@ -329,7 +322,6 @@ AnimCurInit(ScreenPtr pScreen)
     Wrap(as, pScreen, RealizeCursor, AnimCurRealizeCursor);
     Wrap(as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
     Wrap(as, pScreen, RecolorCursor, AnimCurRecolorCursor);
-    SetAnimCurScreen(pScreen, as);
     return TRUE;
 }
 


More information about the xorg-commit mailing list