Commit 47ab4d64 authored by Eamon Walsh's avatar Eamon Walsh Committed by Eamon Walsh

devPrivates rework: convert CursorRec and CursorBits over to new interface.

parent 4795df62
......@@ -99,6 +99,7 @@ FreeCursorBits(CursorBitsPtr bits)
CloseFont(this->font, (Font)0);
xfree(this);
}
dixFreePrivates(bits->devPrivates);
xfree(bits);
}
}
......@@ -124,6 +125,7 @@ FreeCursor(pointer value, XID cid)
pscr = screenInfo.screens[nscr];
(void)( *pscr->UnrealizeCursor)( pscr, pCurs);
}
dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(pCurs->bits);
xfree( pCurs);
return(Success);
......@@ -192,9 +194,9 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
bits->height = cm->height;
bits->xhot = cm->xhot;
bits->yhot = cm->yhot;
bits->devPrivates = NULL;
bits->refcnt = -1;
CheckForEmptyMask(bits);
pCurs->bits = bits;
pCurs->refcnt = 1;
#ifdef XFIXES
......@@ -210,10 +212,14 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
pCurs->backGreen = backGreen;
pCurs->backBlue = backBlue;
pCurs->devPrivates = NULL;
pCurs->id = cid;
/* security creation/labeling check */
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR,
DixCreateAccess, pCurs);
if (rc != Success) {
dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(bits);
xfree(pCurs);
return rc;
......@@ -232,6 +238,7 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
pscr = screenInfo.screens[nscr];
( *pscr->UnrealizeCursor)( pscr, pCurs);
}
dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(bits);
xfree(pCurs);
return BadAlloc;
......@@ -394,10 +401,14 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
pCurs->backGreen = backGreen;
pCurs->backBlue = backBlue;
pCurs->id = cid;
pCurs->devPrivates = NULL;
/* security creation/labeling check */
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR,
DixCreateAccess, pCurs);
if (rc != Success) {
dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(bits);
xfree(pCurs);
return rc;
......@@ -416,6 +427,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
pscr = screenInfo.screens[nscr];
( *pscr->UnrealizeCursor)( pscr, pCurs);
}
dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(pCurs->bits);
xfree(pCurs);
return BadAlloc;
......
......@@ -202,7 +202,7 @@ XFIOKitRealizeCursor8(
}
// save the result
pCursor->devPriv[pScreen->myNum] = (pointer) newCursor;
dixSetPrivate(&pCursor->devPrivates, pScreen, newCursor);
return TRUE;
}
......@@ -285,7 +285,7 @@ XFIOKitRealizeCursor15(
#endif
// save the result
pCursor->devPriv[pScreen->myNum] = (pointer) newCursor;
dixSetPrivate(&pCursor->devPrivates, pScreen, newCursor);
return TRUE;
}
......@@ -369,7 +369,7 @@ XFIOKitRealizeCursor24(
#endif
// save the result
pCursor->devPriv[pScreen->myNum] = (pointer) newCursor;
dixSetPrivate(&pCursor->devPrivates, pScreen, newCursor);
return TRUE;
}
......@@ -422,7 +422,7 @@ XFIOKitUnrealizeCursor(
!ScreenPriv->canHWCursor) {
result = (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pScreen, pCursor);
} else {
xfree( pCursor->devPriv[pScreen->myNum] );
xfree(dixLookupPrivate(&pCursor->devPrivates, pScreen));
result = TRUE;
}
......@@ -476,20 +476,20 @@ XFIOKitSetCursor(
// change the cursor image in shared memory
if (dfb->bitsPerPixel == 8) {
cursorPrivPtr newCursor =
(cursorPrivPtr) pCursor->devPriv[pScreen->myNum];
cursorPrivPtr newCursor = dixLookupPrivate(&pCursor->devPrivates,
pScreen);
memcpy(cshmem->cursor.bw8.image[0], newCursor->image,
CURSORWIDTH*CURSORHEIGHT);
memcpy(cshmem->cursor.bw8.mask[0], newCursor->mask,
CURSORWIDTH*CURSORHEIGHT);
} else if (dfb->bitsPerPixel == 16) {
unsigned short *newCursor =
(unsigned short *) pCursor->devPriv[pScreen->myNum];
unsigned short *newCursor = dixLookupPrivate(&pCursor->devPrivates,
pScreen);
memcpy(cshmem->cursor.rgb.image[0], newCursor,
2*CURSORWIDTH*CURSORHEIGHT);
} else {
unsigned int *newCursor =
(unsigned int *) pCursor->devPriv[pScreen->myNum];
unsigned int *newCursor = dixLookupPrivate(&pCursor->devPrivates,
pScreen);
memcpy(cshmem->cursor.rgb24.image[0], newCursor,
4*CURSORWIDTH*CURSORHEIGHT);
}
......
......@@ -318,7 +318,7 @@ QuartzRealizeCursor(
if (!qdCursor) return FALSE;
// save the result
pCursor->devPriv[pScreen->myNum] = (pointer) qdCursor;
dixSetPrivate(&pCursor->devPrivates, pScreen, qdCursor);
return TRUE;
}
......@@ -345,13 +345,13 @@ QuartzUnrealizeCursor(
(pScreen, pCursor);
}
} else {
CCrsrHandle oldCursor = (CCrsrHandle) pCursor->devPriv[pScreen->myNum];
CCrsrHandle oldCursor = dixLookupPrivate(&pCursor->devPrivates,
pScreen);
if (currentCursor != oldCursor) {
// This should only fail when quitting, in which case we just leak.
FreeQDCursor(oldCursor);
}
pCursor->devPriv[pScreen->myNum] = NULL;
dixSetPrivate(&pCursor->devPrivates, pScreen, NULL);
return TRUE;
}
}
......@@ -391,7 +391,7 @@ QuartzSetCursor(
(*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
ScreenPriv->qdCursorMode = TRUE;
CHANGE_QD_CURSOR(pCursor->devPriv[pScreen->myNum]);
CHANGE_QD_CURSOR(dixLookupPrivate(&pCursor->devPrivates, pScreen));
SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
}
else if (quartzRootless) {
......
......@@ -321,7 +321,7 @@ QuartzRealizeCursor(
if (!qdCursor) return FALSE;
// save the result
pCursor->devPriv[pScreen->myNum] = (pointer) qdCursor;
dixSetPrivate(&pCursor->devPrivates, pScreen, qdCursor);
return TRUE;
}
......@@ -348,13 +348,13 @@ QuartzUnrealizeCursor(
(pScreen, pCursor);
}
} else {
CCrsrHandle oldCursor = (CCrsrHandle) pCursor->devPriv[pScreen->myNum];
CCrsrHandle oldCursor = dixLookupPrivate(&pCursor->devPrivates,
pScreen);
if (currentCursor != oldCursor) {
// This should only fail when quitting, in which case we just leak.
FreeQDCursor(oldCursor);
}
pCursor->devPriv[pScreen->myNum] = NULL;
dixSetPrivate(&pCursor->devPrivates, pScreen, NULL);
return TRUE;
}
}
......@@ -394,7 +394,7 @@ QuartzSetCursor(
(*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
ScreenPriv->qdCursorMode = TRUE;
CHANGE_QD_CURSOR(pCursor->devPriv[pScreen->myNum]);
CHANGE_QD_CURSOR(dixLookupPrivate(&pCursor->devPrivates, pScreen));
SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
}
else if (quartzRootless) {
......
......@@ -662,8 +662,8 @@ static Bool _dmxRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
DMXDBG2("_dmxRealizeCursor(%d,%p)\n", pScreen->myNum, pCursor);
pCursor->devPriv[pScreen->myNum] = xalloc(sizeof(*pCursorPriv));
if (!pCursor->devPriv[pScreen->myNum])
DMX_SET_CURSOR_PRIV(pCursor, pScreen, xalloc(sizeof(*pCursorPriv)));
if (!DMX_GET_CURSOR_PRIV(pCursor, pScreen))
return FALSE;
pCursorPriv = DMX_GET_CURSOR_PRIV(pCursor, pScreen);
......@@ -700,9 +700,9 @@ static Bool _dmxUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
if (dmxScreen->beDisplay) {
if (dmxBEFreeCursor(pScreen, pCursor))
xfree(pCursor->devPriv[pScreen->myNum]);
xfree(DMX_GET_CURSOR_PRIV(pCursor, pScreen));
}
pCursor->devPriv[pScreen->myNum] = NULL;
DMX_SET_CURSOR_PRIV(pCursor, pScreen, NULL);
return TRUE;
}
......
......@@ -63,7 +63,10 @@ extern void dmxHideCursor(DMXScreenInfo *dmxScreen);
extern void dmxBECreateCursor(ScreenPtr pScreen, CursorPtr pCursor);
extern Bool dmxBEFreeCursor(ScreenPtr pScreen, CursorPtr pCursor);
#define DMX_GET_CURSOR_PRIV(_pCursor, _pScreen) \
(dmxCursorPrivPtr)(_pCursor)->devPriv[(_pScreen)->myNum]
#define DMX_GET_CURSOR_PRIV(_pCursor, _pScreen) \
((dmxCursorPrivPtr)dixLookupPrivate(&(_pCursor)->devPrivates, _pScreen))
#define DMX_SET_CURSOR_PRIV(_pCursor, _pScreen, v) \
dixSetPrivate(&(_pCursor)->devPrivates, _pScreen, v)
#endif /* DMXCURSOR_H */
......@@ -226,7 +226,8 @@ xf86_set_cursor_colors (ScrnInfoPtr scrn, int bg, int fg)
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
CursorPtr cursor = xf86_config->cursor;
int c;
CARD8 *bits = cursor ? cursor->devPriv[screen->myNum] : NULL;
CARD8 *bits = cursor ? dixLookupPrivate(&cursor->devPrivates,
screen) : NULL;
/* Save ARGB versions of these colors */
xf86_config->cursor_fg = (CARD32) fg | 0xff000000;
......@@ -612,7 +613,7 @@ xf86_reload_cursors (ScreenPtr screen)
else
#endif
(*cursor_info->LoadCursorImage)(cursor_info->pScrn,
cursor->devPriv[screen->myNum]);
dixLookupPrivate(&cursor->devPrivates, screen));
(*cursor_info->SetCursorPosition)(cursor_info->pScrn, x, y);
(*cursor_info->ShowCursor)(cursor_info->pScrn);
......
......@@ -251,7 +251,7 @@ xf86CursorRealizeCursor(ScreenPtr pScreen, CursorPtr pCurs)
&pScreen->devPrivates, xf86CursorScreenKey);
if (pCurs->refcnt <= 1)
pCurs->devPriv[pScreen->myNum] = NULL;
dixSetPrivate(&pCurs->devPrivates, pScreen, NULL);
return (*ScreenPriv->spriteFuncs->RealizeCursor)(pScreen, pCurs);
}
......@@ -263,8 +263,8 @@ xf86CursorUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCurs)
&pScreen->devPrivates, xf86CursorScreenKey);
if (pCurs->refcnt <= 1) {
xfree(pCurs->devPriv[pScreen->myNum]);
pCurs->devPriv[pScreen->myNum] = NULL;
xfree(dixLookupPrivate(&pCurs->devPrivates, pScreen));
dixSetPrivate(&pCurs->devPrivates, pScreen, NULL);
}
return (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pScreen, pCurs);
......
......@@ -123,7 +123,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
return;
}
bits = pCurs->devPriv[pScreen->myNum];
bits = (unsigned char *)dixLookupPrivate(&pCurs->devPrivates, pScreen);
x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX;
y -= infoPtr->pScrn->frameY0 + ScreenPriv->HotY;
......@@ -133,7 +133,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
#endif
if (!bits) {
bits = (*infoPtr->RealizeCursor)(infoPtr, pCurs);
pCurs->devPriv[pScreen->myNum] = bits;
dixSetPrivate(&pCurs->devPrivates, pScreen, bits);
}
if (!(infoPtr->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
......
......@@ -121,10 +121,10 @@ typedef struct _xglxCursor {
} xglxCursorRec, *xglxCursorPtr;
#define XGLX_GET_CURSOR_PRIV(pCursor, pScreen) \
((xglxCursorPtr) (pCursor)->devPriv[(pScreen)->myNum])
((xglxCursorPtr)dixLookupPrivate(&(pCursor)->devPrivates, pScreen))
#define XGLX_SET_CURSOR_PRIV(pCursor, pScreen, v) \
((pCursor)->devPriv[(pScreen)->myNum] = (pointer) v)
dixSetPrivate(&(pCursor)->devPrivates, pScreen, v)
#define XGLX_CURSOR_PRIV(pCursor, pScreen) \
xglxCursorPtr pCursorPriv = XGLX_GET_CURSOR_PRIV (pCursor, pScreen)
......
......@@ -104,8 +104,8 @@ xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
bg_color.green = pCursor->backGreen;
bg_color.blue = pCursor->backBlue;
pCursor->devPriv[pScreen->myNum] = (pointer)xalloc(sizeof(xnestPrivCursor));
xnestCursorPriv(pCursor, pScreen)->cursor =
xnestSetCursorPriv(pCursor, pScreen, xalloc(sizeof(xnestPrivCursor)));
xnestCursor(pCursor, pScreen) =
XCreatePixmapCursor(xnestDisplay, source, mask, &fg_color, &bg_color,
pCursor->bits->xhot, pCursor->bits->yhot);
......@@ -119,7 +119,7 @@ Bool
xnestUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
{
XFreeCursor(xnestDisplay, xnestCursor(pCursor, pScreen));
xfree(xnestCursorPriv(pCursor, pScreen));
xfree(xnestGetCursorPriv(pCursor, pScreen));
return True;
}
......
......@@ -19,11 +19,14 @@ typedef struct {
Cursor cursor;
} xnestPrivCursor;
#define xnestCursorPriv(pCursor, pScreen) \
((xnestPrivCursor *)((pCursor)->devPriv[pScreen->myNum]))
#define xnestGetCursorPriv(pCursor, pScreen) \
((xnestPrivCursor *)dixLookupPrivate(&(pCursor)->devPrivates, pScreen))
#define xnestSetCursorPriv(pCursor, pScreen, v) \
dixSetPrivate(&(pCursor)->devPrivates, pScreen, v)
#define xnestCursor(pCursor, pScreen) \
(xnestCursorPriv(pCursor, pScreen)->cursor)
(xnestGetCursorPriv(pCursor, pScreen)->cursor)
Bool xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
Bool xnestUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
......
......@@ -49,6 +49,7 @@ SOFTWARE.
#define CURSORSTRUCT_H
#include "cursor.h"
#include "privates.h"
/*
* device-independent cursor storage
*/
......@@ -63,7 +64,7 @@ typedef struct _CursorBits {
Bool emptyMask; /* all zeros mask */
unsigned short width, height, xhot, yhot; /* metrics */
int refcnt; /* can be shared */
pointer devPriv[MAXSCREENS]; /* set by pScr->RealizeCursor*/
PrivateRec *devPrivates; /* set by pScr->RealizeCursor*/
#ifdef ARGB_CURSOR
CARD32 *argb; /* full-color alpha blended */
#endif
......@@ -74,7 +75,8 @@ typedef struct _Cursor {
unsigned short foreRed, foreGreen, foreBlue; /* device-independent color */
unsigned short backRed, backGreen, backBlue; /* device-independent color */
int refcnt;
pointer devPriv[MAXSCREENS]; /* set by pScr->RealizeCursor*/
PrivateRec *devPrivates; /* set by pScr->RealizeCursor*/
XID id;
#ifdef XFIXES
CARD32 serialNumber;
Atom name;
......
......@@ -190,7 +190,7 @@ miDCRealizeCursor (pScreen, pCursor)
CursorPtr pCursor;
{
if (pCursor->bits->refcnt <= 1)
pCursor->bits->devPriv[pScreen->myNum] = (pointer)NULL;
dixSetPrivate(&pCursor->bits->devPrivates, pScreen, NULL);
return TRUE;
}
......@@ -290,7 +290,7 @@ miDCRealize (
xfree ((pointer) pPriv);
return (miDCCursorPtr)NULL;
}
pCursor->bits->devPriv[pScreen->myNum] = (pointer) pPriv;
dixSetPrivate(&pCursor->bits->devPrivates, pScreen, pPriv);
return pPriv;
}
pPriv->pPicture = 0;
......@@ -308,7 +308,7 @@ miDCRealize (
xfree ((pointer) pPriv);
return (miDCCursorPtr)NULL;
}
pCursor->bits->devPriv[pScreen->myNum] = (pointer) pPriv;
dixSetPrivate(&pCursor->bits->devPrivates, pScreen, pPriv);
/* create the two sets of bits, clipping as appropriate */
......@@ -354,7 +354,8 @@ miDCUnrealizeCursor (pScreen, pCursor)
{
miDCCursorPtr pPriv;
pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum];
pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates,
pScreen);
if (pPriv && (pCursor->bits->refcnt <= 1))
{
if (pPriv->sourceBits)
......@@ -366,7 +367,7 @@ miDCUnrealizeCursor (pScreen, pCursor)
FreePicture (pPriv->pPicture, 0);
#endif
xfree ((pointer) pPriv);
pCursor->bits->devPriv[pScreen->myNum] = (pointer)NULL;
dixSetPrivate(&pCursor->bits->devPrivates, pScreen, NULL);
}
return TRUE;
}
......@@ -461,7 +462,8 @@ miDCPutUpCursor (pScreen, pCursor, x, y, source, mask)
miDCCursorPtr pPriv;
WindowPtr pWin;
pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum];
pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates,
pScreen);
if (!pPriv)
{
pPriv = miDCRealize(pScreen, pCursor);
......@@ -711,7 +713,8 @@ miDCMoveCursor (pScreen, pCursor, x, y, w, h, dx, dy, source, mask)
XID gcval = FALSE;
PixmapPtr pTemp;
pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum];
pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates,
pScreen);
if (!pPriv)
{
pPriv = miDCRealize(pScreen, pCursor);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment