summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Reveman <davidr@novell.com>2008-06-23 23:27:01 -0400
committerDavid Reveman <davidr@novell.com>2008-10-30 03:36:57 -0400
commit1d401db26613ccd24d6f218f459bf824710e7b44 (patch)
treebfb51df4060613b2f3def4d9fb696e4f5b388c0d
parente4e5db738039d3ab5d5fe2132beee4c45851f07e (diff)
Expose animated cursors to DDX for possible acceleration.
Each animated cursor is now realized as regular cursors and IsAnimCur macro can be used to check if a cursor is an animated cursor.
-rw-r--r--render/animcur.c98
-rw-r--r--render/picturestr.h25
2 files changed, 72 insertions, 51 deletions
diff --git a/render/animcur.c b/render/animcur.c
index 335feaa56..d4e2ca58e 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -49,12 +49,2 @@
-typedef struct _AnimCurElt {
- CursorPtr pCursor; /* cursor to show */
- CARD32 delay; /* in ms */
-} AnimCurElt;
-
-typedef struct _AnimCur {
- int nelt; /* number of elements in the elts array */
- AnimCurElt *elts; /* actually allocated right after the structure */
-} AnimCurRec, *AnimCurPtr;
-
typedef struct _AnimScrPriv {
@@ -88,3 +78,3 @@ static unsigned char empty[4];
-static CursorBits animCursorBits = {
+CursorBits animCursorBits = {
empty, empty, 2, 1, 1, 0, 0, 1
@@ -97,4 +87,2 @@ static DevPrivateKey AnimCurScreenPrivateKey = &AnimCurScreenPrivateKeyIndex;
-#define IsAnimCur(c) ((c) && ((c)->bits == &animCursorBits))
-#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1))
#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey))
@@ -290,6 +278,3 @@ AnimCurRealizeCursor (DeviceIntPtr pDev,
Unwrap (as, pScreen, RealizeCursor);
- if (IsAnimCur(pCursor))
- ret = TRUE;
- else
- ret = (*pScreen->RealizeCursor) (pDev, pScreen, pCursor);
+ ret = (*pScreen->RealizeCursor) (pDev, pScreen, pCursor);
Wrap (as, pScreen, RealizeCursor, AnimCurRealizeCursor);
@@ -307,2 +292,3 @@ AnimCurUnrealizeCursor (DeviceIntPtr pDev,
Unwrap (as, pScreen, UnrealizeCursor);
+ ret = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor);
if (IsAnimCur(pCursor))
@@ -315,6 +301,3 @@ AnimCurUnrealizeCursor (DeviceIntPtr pDev,
FreeCursor (ac->elts[i].pCursor, 0);
- ret = TRUE;
}
- else
- ret = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor);
Wrap (as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
@@ -383,5 +366,7 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp
{
- CursorPtr pCursor;
- int rc, i;
- AnimCurPtr ac;
+ CursorPtr pCursor;
+ int rc, nscr, i;
+ AnimCurPtr ac;
+ ScreenPtr pscr;
+ DeviceIntPtr pDev;
@@ -437,25 +422,52 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp
}
-
- *ppCursor = pCursor;
- return Success;
-}
-void
-AnimForEachCursorElt (ScreenPtr pScreen,
- CursorPtr pCursor,
- CursorProcPtr callBack)
-{
- if (IsAnimCur (pCursor))
- {
- AnimCurPtr ac = GetAnimCur (pCursor);
- int i;
-
- for (i = 0; i < ac->nelt; i++)
- (*callBack) (pScreen, ac->elts[i].pCursor);
-
- }
- else
+ /*
+ * realize the cursor for every screen
+ * Do not change the refcnt, this will be changed when ChangeToCursor
+ * actually changes the sprite.
+ */
+ for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
{
- (*callBack) (pScreen, pCursor);
+ pscr = screenInfo.screens[nscr];
+ for (pDev = inputInfo.devices; pDev; pDev = pDev->next)
+ {
+ if (DevHasCursor(pDev))
+ {
+ if (!( *pscr->RealizeCursor)(pDev, pscr, pCursor))
+ {
+ /* Realize failed for device pDev on screen pscr.
+ * We have to assume that for all devices before, realize
+ * worked. We need to rollback all devices so far on the
+ * current screen and then all devices on previous
+ * screens.
+ */
+ DeviceIntPtr pDevIt = inputInfo.devices; /*dev iterator*/
+ while(pDevIt && pDevIt != pDev)
+ {
+ if (DevHasCursor(pDevIt))
+ ( *pscr->UnrealizeCursor)(pDevIt, pscr, pCursor);
+ pDevIt = pDevIt->next;
+ }
+ while (--nscr >= 0)
+ {
+ pscr = screenInfo.screens[nscr];
+ /* now unrealize all devices on previous screens */
+ pDevIt = inputInfo.devices;
+ while (pDevIt)
+ {
+ if (DevHasCursor(pDevIt))
+ ( *pscr->UnrealizeCursor)(pDevIt, pscr, pCursor);
+ pDevIt = pDevIt->next;
+ }
+ ( *pscr->UnrealizeCursor)(pDev, pscr, pCursor);
+ }
+ dixFreePrivates(pCursor->devPrivates);
+ xfree(pCursor);
+ return BadAlloc;
+ }
+ }
+ }
}
+ *ppCursor = pCursor;
+ return Success;
}
diff --git a/render/picturestr.h b/render/picturestr.h
index 71647e67f..e91a70a25 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -28,2 +28,3 @@
#include "glyphstr.h"
+#include "cursorstr.h"
#include "resource.h"
@@ -619,2 +620,18 @@ void RenderExtensionInit (void);
+
+typedef struct _AnimCurElt {
+ CursorPtr pCursor; /* cursor to show */
+ CARD32 delay; /* in ms */
+} AnimCurElt;
+
+typedef struct _AnimCur {
+ int nelt; /* number of elements in the elts array */
+ AnimCurElt *elts; /* actually allocated right after the structure */
+} AnimCurRec, *AnimCurPtr;
+
+extern CursorBits animCursorBits;
+
+#define IsAnimCur(c) ((c) && ((c)->bits == &animCursorBits))
+#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1))
+
Bool
@@ -675,10 +692,2 @@ void PanoramiXRenderReset (void);
-typedef void (*CursorProcPtr) (ScreenPtr pScreen,
- CursorPtr pCursor);
-
-void
-AnimForEachCursorElt (ScreenPtr pScreen,
- CursorPtr pCursor,
- CursorProcPtr callBack);
-
#endif /* _PICTURESTR_H_ */