mi: added MPX to miSpriteReportDamage

added id field to miCursorInfoPtr, required to pass through to miDC
        core pointer uses mpCursors array as well.
        added miDCBufferRec for future use with MPX

TAG: MPX_BEFORE_MIDC_API_BREAK
This commit is contained in:
Peter Hutterer 2006-11-21 11:26:21 +10:30 committed by Peter Hutterer
parent b1bbdf464d
commit 3bad452d12
4 changed files with 146 additions and 64 deletions

View File

@ -1,4 +1,17 @@
MPX Changelog file MPX Changelog file
== 21.11.06 ==
mi: added MPX to miSpriteReportDamage
added id field to miCursorInfoPtr, required to pass through to miDC
core pointer uses mpCursors array as well.
added miDCBufferRec for future use with MPX
Files:
mi/midispcur.c
mi/misprite.c
mi/mispritest.h
TAG: MPX_BEFORE_MIDC_API_BREAK
== 20.11.06 == == 20.11.06 ==
mi: moved core pointer information from miSpriteScreenRec into a mi: moved core pointer information from miSpriteScreenRec into a

View File

@ -52,6 +52,10 @@ in this Software without prior written authorization from The Open Group.
# include "picturestr.h" # include "picturestr.h"
#endif #endif
#ifdef MPX
# include "inputstr.h"
#endif
/* per-screen private data */ /* per-screen private data */
static int miDCScreenIndex; static int miDCScreenIndex;
@ -64,12 +68,19 @@ typedef struct {
GCPtr pSaveGC, pRestoreGC; GCPtr pSaveGC, pRestoreGC;
GCPtr pMoveGC; GCPtr pMoveGC;
GCPtr pPixSourceGC, pPixMaskGC; GCPtr pPixSourceGC, pPixMaskGC;
CloseScreenProcPtr CloseScreen;
PixmapPtr pSave, pTemp; PixmapPtr pSave, pTemp;
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
PicturePtr pRootPicture; PicturePtr pRootPicture;
PicturePtr pTempPicture; PicturePtr pTempPicture;
#endif #endif
} miDCBufferRec, *miDCBufferPtr;
typedef struct {
miDCBufferPtr pCoreBuffer; /* for core pointer */
#ifdef MPX
miDCBufferPtr pMPBuffers; /* for MPX pointers */
#endif
CloseScreenProcPtr CloseScreen;
} miDCScreenRec, *miDCScreenPtr; } miDCScreenRec, *miDCScreenPtr;
/* per-cursor per-screen private data */ /* per-cursor per-screen private data */
@ -131,20 +142,54 @@ miDCInitialize (pScreen, screenFuncs)
/* /*
* initialize the entire private structure to zeros * initialize the entire private structure to zeros
*/ */
pScreenPriv->pCoreBuffer = (miDCBufferPtr)xalloc(sizeof(miDCBufferRec));
pScreenPriv->pSourceGC = pScreenPriv->pCoreBuffer->pSourceGC =
pScreenPriv->pMaskGC = pScreenPriv->pCoreBuffer->pMaskGC =
pScreenPriv->pSaveGC = pScreenPriv->pCoreBuffer->pSaveGC =
pScreenPriv->pRestoreGC = pScreenPriv->pCoreBuffer->pRestoreGC =
pScreenPriv->pMoveGC = pScreenPriv->pCoreBuffer->pMoveGC =
pScreenPriv->pPixSourceGC = pScreenPriv->pCoreBuffer->pPixSourceGC =
pScreenPriv->pPixMaskGC = NULL; pScreenPriv->pCoreBuffer->pPixMaskGC = NULL;
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
pScreenPriv->pRootPicture = NULL; pScreenPriv->pCoreBuffer->pRootPicture = NULL;
pScreenPriv->pTempPicture = NULL; pScreenPriv->pCoreBuffer->pTempPicture = NULL;
#endif #endif
pScreenPriv->pSave = pScreenPriv->pTemp = NULL; pScreenPriv->pCoreBuffer->pSave = pScreenPriv->pCoreBuffer->pTemp = NULL;
#ifdef MPX
{
int mpBufferIdx = 0;
pScreenPriv->pMPBuffers = (miDCBufferPtr)xalloc(MAX_DEVICES *
sizeof(miDCBufferRec));
/* virtual core pointer ID is 1, we might as well use the array */
xfree(pScreenPriv->pCoreBuffer);
pScreenPriv->pCoreBuffer = &pScreenPriv->pMPBuffers[1];
while (mpBufferIdx < MAX_DEVICES)
{
miDCBufferPtr pBuffer = &pScreenPriv->pMPBuffers[mpBufferIdx];
pBuffer->pSourceGC =
pBuffer->pMaskGC =
pBuffer->pSaveGC =
pBuffer->pRestoreGC =
pBuffer->pMoveGC =
pBuffer->pPixSourceGC =
pBuffer->pPixMaskGC = NULL;
#ifdef ARGB_CURSOR
pBuffer->pRootPicture = NULL;
pBuffer->pTempPicture = NULL;
#endif
pBuffer->pSave = pBuffer->pTemp = NULL;
mpBufferIdx++;
}
}
#endif
pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = miDCCloseScreen; pScreen->CloseScreen = miDCCloseScreen;
@ -172,20 +217,20 @@ miDCCloseScreen (index, pScreen)
pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr; pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
pScreen->CloseScreen = pScreenPriv->CloseScreen; pScreen->CloseScreen = pScreenPriv->CloseScreen;
tossGC (pScreenPriv->pSourceGC); tossGC (pScreenPriv->pCoreBuffer->pSourceGC);
tossGC (pScreenPriv->pMaskGC); tossGC (pScreenPriv->pCoreBuffer->pMaskGC);
tossGC (pScreenPriv->pSaveGC); tossGC (pScreenPriv->pCoreBuffer->pSaveGC);
tossGC (pScreenPriv->pRestoreGC); tossGC (pScreenPriv->pCoreBuffer->pRestoreGC);
tossGC (pScreenPriv->pMoveGC); tossGC (pScreenPriv->pCoreBuffer->pMoveGC);
tossGC (pScreenPriv->pPixSourceGC); tossGC (pScreenPriv->pCoreBuffer->pPixSourceGC);
tossGC (pScreenPriv->pPixMaskGC); tossGC (pScreenPriv->pCoreBuffer->pPixMaskGC);
tossPix (pScreenPriv->pSave); tossPix (pScreenPriv->pCoreBuffer->pSave);
tossPix (pScreenPriv->pTemp); tossPix (pScreenPriv->pCoreBuffer->pTemp);
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
#if 0 /* This has been free()d before */ #if 0 /* This has been free()d before */
tossPict (pScreenPriv->pRootPicture); tossPict (pScreenPriv->pRootPicture);
#endif #endif
tossPict (pScreenPriv->pTempPicture); tossPict (pScreenPriv->pCoreBuffer->pTempPicture);
#endif #endif
xfree ((pointer) pScreenPriv); xfree ((pointer) pScreenPriv);
return (*pScreen->CloseScreen) (index, pScreen); return (*pScreen->CloseScreen) (index, pScreen);
@ -481,12 +526,12 @@ miDCPutUpCursor (pScreen, pCursor, x, y, source, mask)
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
if (pPriv->pPicture) if (pPriv->pPicture)
{ {
if (!EnsurePicture(pScreenPriv->pRootPicture, &pWin->drawable, pWin)) if (!EnsurePicture(pScreenPriv->pCoreBuffer->pRootPicture, &pWin->drawable, pWin))
return FALSE; return FALSE;
CompositePicture (PictOpOver, CompositePicture (PictOpOver,
pPriv->pPicture, pPriv->pPicture,
NULL, NULL,
pScreenPriv->pRootPicture, pScreenPriv->pCoreBuffer->pRootPicture,
0, 0, 0, 0, 0, 0, 0, 0,
x, y, x, y,
pCursor->bits->width, pCursor->bits->width,
@ -495,16 +540,16 @@ miDCPutUpCursor (pScreen, pCursor, x, y, source, mask)
else else
#endif #endif
{ {
if (!EnsureGC(pScreenPriv->pSourceGC, pWin)) if (!EnsureGC(pScreenPriv->pCoreBuffer->pSourceGC, pWin))
return FALSE; return FALSE;
if (!EnsureGC(pScreenPriv->pMaskGC, pWin)) if (!EnsureGC(pScreenPriv->pCoreBuffer->pMaskGC, pWin))
{ {
FreeGC (pScreenPriv->pSourceGC, (GContext) 0); FreeGC (pScreenPriv->pCoreBuffer->pSourceGC, (GContext) 0);
pScreenPriv->pSourceGC = 0; pScreenPriv->pCoreBuffer->pSourceGC = 0;
return FALSE; return FALSE;
} }
miDCPutBits ((DrawablePtr)pWin, pPriv, miDCPutBits ((DrawablePtr)pWin, pPriv,
pScreenPriv->pSourceGC, pScreenPriv->pMaskGC, pScreenPriv->pCoreBuffer->pSourceGC, pScreenPriv->pCoreBuffer->pMaskGC,
x, y, pCursor->bits->width, pCursor->bits->height, x, y, pCursor->bits->width, pCursor->bits->height,
source, mask); source, mask);
} }
@ -522,20 +567,20 @@ miDCSaveUnderCursor (pScreen, x, y, w, h)
GCPtr pGC; GCPtr pGC;
pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr; pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
pSave = pScreenPriv->pSave; pSave = pScreenPriv->pCoreBuffer->pSave;
pWin = WindowTable[pScreen->myNum]; pWin = WindowTable[pScreen->myNum];
if (!pSave || pSave->drawable.width < w || pSave->drawable.height < h) if (!pSave || pSave->drawable.width < w || pSave->drawable.height < h)
{ {
if (pSave) if (pSave)
(*pScreen->DestroyPixmap) (pSave); (*pScreen->DestroyPixmap) (pSave);
pScreenPriv->pSave = pSave = pScreenPriv->pCoreBuffer->pSave = pSave =
(*pScreen->CreatePixmap) (pScreen, w, h, pScreen->rootDepth); (*pScreen->CreatePixmap) (pScreen, w, h, pScreen->rootDepth);
if (!pSave) if (!pSave)
return FALSE; return FALSE;
} }
if (!EnsureGC(pScreenPriv->pSaveGC, pWin)) if (!EnsureGC(pScreenPriv->pCoreBuffer->pSaveGC, pWin))
return FALSE; return FALSE;
pGC = pScreenPriv->pSaveGC; pGC = pScreenPriv->pCoreBuffer->pSaveGC;
if (pSave->drawable.serialNumber != pGC->serialNumber) if (pSave->drawable.serialNumber != pGC->serialNumber)
ValidateGC ((DrawablePtr) pSave, pGC); ValidateGC ((DrawablePtr) pSave, pGC);
(*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC, (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
@ -554,13 +599,13 @@ miDCRestoreUnderCursor (pScreen, x, y, w, h)
GCPtr pGC; GCPtr pGC;
pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr; pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
pSave = pScreenPriv->pSave; pSave = pScreenPriv->pCoreBuffer->pSave;
pWin = WindowTable[pScreen->myNum]; pWin = WindowTable[pScreen->myNum];
if (!pSave) if (!pSave)
return FALSE; return FALSE;
if (!EnsureGC(pScreenPriv->pRestoreGC, pWin)) if (!EnsureGC(pScreenPriv->pCoreBuffer->pRestoreGC, pWin))
return FALSE; return FALSE;
pGC = pScreenPriv->pRestoreGC; pGC = pScreenPriv->pCoreBuffer->pRestoreGC;
if (pWin->drawable.serialNumber != pGC->serialNumber) if (pWin->drawable.serialNumber != pGC->serialNumber)
ValidateGC ((DrawablePtr) pWin, pGC); ValidateGC ((DrawablePtr) pWin, pGC);
(*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC, (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
@ -580,16 +625,16 @@ miDCChangeSave (pScreen, x, y, w, h, dx, dy)
int sourcex, sourcey, destx, desty, copyw, copyh; int sourcex, sourcey, destx, desty, copyw, copyh;
pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr; pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
pSave = pScreenPriv->pSave; pSave = pScreenPriv->pCoreBuffer->pSave;
pWin = WindowTable[pScreen->myNum]; pWin = WindowTable[pScreen->myNum];
/* /*
* restore the bits which are about to get trashed * restore the bits which are about to get trashed
*/ */
if (!pSave) if (!pSave)
return FALSE; return FALSE;
if (!EnsureGC(pScreenPriv->pRestoreGC, pWin)) if (!EnsureGC(pScreenPriv->pCoreBuffer->pRestoreGC, pWin))
return FALSE; return FALSE;
pGC = pScreenPriv->pRestoreGC; pGC = pScreenPriv->pCoreBuffer->pRestoreGC;
if (pWin->drawable.serialNumber != pGC->serialNumber) if (pWin->drawable.serialNumber != pGC->serialNumber)
ValidateGC ((DrawablePtr) pWin, pGC); ValidateGC ((DrawablePtr) pWin, pGC);
/* /*
@ -627,9 +672,9 @@ miDCChangeSave (pScreen, x, y, w, h, dx, dy)
(*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC, (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
0, sourcey, -dx, copyh, x + dx, desty); 0, sourcey, -dx, copyh, x + dx, desty);
} }
if (!EnsureGC(pScreenPriv->pSaveGC, pWin)) if (!EnsureGC(pScreenPriv->pCoreBuffer->pSaveGC, pWin))
return FALSE; return FALSE;
pGC = pScreenPriv->pSaveGC; pGC = pScreenPriv->pCoreBuffer->pSaveGC;
if (pSave->drawable.serialNumber != pGC->serialNumber) if (pSave->drawable.serialNumber != pGC->serialNumber)
ValidateGC ((DrawablePtr) pSave, pGC); ValidateGC ((DrawablePtr) pSave, pGC);
/* /*
@ -724,39 +769,39 @@ miDCMoveCursor (pScreen, pCursor, x, y, w, h, dx, dy, source, mask)
} }
pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr; pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
pWin = WindowTable[pScreen->myNum]; pWin = WindowTable[pScreen->myNum];
pTemp = pScreenPriv->pTemp; pTemp = pScreenPriv->pCoreBuffer->pTemp;
if (!pTemp || if (!pTemp ||
pTemp->drawable.width != pScreenPriv->pSave->drawable.width || pTemp->drawable.width != pScreenPriv->pCoreBuffer->pSave->drawable.width ||
pTemp->drawable.height != pScreenPriv->pSave->drawable.height) pTemp->drawable.height != pScreenPriv->pCoreBuffer->pSave->drawable.height)
{ {
if (pTemp) if (pTemp)
(*pScreen->DestroyPixmap) (pTemp); (*pScreen->DestroyPixmap) (pTemp);
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
if (pScreenPriv->pTempPicture) if (pScreenPriv->pCoreBuffer->pTempPicture)
{ {
FreePicture (pScreenPriv->pTempPicture, 0); FreePicture (pScreenPriv->pCoreBuffer->pTempPicture, 0);
pScreenPriv->pTempPicture = 0; pScreenPriv->pCoreBuffer->pTempPicture = 0;
} }
#endif #endif
pScreenPriv->pTemp = pTemp = (*pScreen->CreatePixmap) pScreenPriv->pCoreBuffer->pTemp = pTemp = (*pScreen->CreatePixmap)
(pScreen, w, h, pScreenPriv->pSave->drawable.depth); (pScreen, w, h, pScreenPriv->pCoreBuffer->pSave->drawable.depth);
if (!pTemp) if (!pTemp)
return FALSE; return FALSE;
} }
if (!pScreenPriv->pMoveGC) if (!pScreenPriv->pCoreBuffer->pMoveGC)
{ {
pScreenPriv->pMoveGC = CreateGC ((DrawablePtr)pTemp, pScreenPriv->pCoreBuffer->pMoveGC = CreateGC ((DrawablePtr)pTemp,
GCGraphicsExposures, &gcval, &status); GCGraphicsExposures, &gcval, &status);
if (!pScreenPriv->pMoveGC) if (!pScreenPriv->pCoreBuffer->pMoveGC)
return FALSE; return FALSE;
} }
/* /*
* copy the saved area to a temporary pixmap * copy the saved area to a temporary pixmap
*/ */
pGC = pScreenPriv->pMoveGC; pGC = pScreenPriv->pCoreBuffer->pMoveGC;
if (pGC->serialNumber != pTemp->drawable.serialNumber) if (pGC->serialNumber != pTemp->drawable.serialNumber)
ValidateGC ((DrawablePtr) pTemp, pGC); ValidateGC ((DrawablePtr) pTemp, pGC);
(*pGC->ops->CopyArea)((DrawablePtr)pScreenPriv->pSave, (*pGC->ops->CopyArea)((DrawablePtr)pScreenPriv->pCoreBuffer->pSave,
(DrawablePtr)pTemp, pGC, 0, 0, w, h, 0, 0); (DrawablePtr)pTemp, pGC, 0, 0, w, h, 0, 0);
/* /*
@ -765,12 +810,12 @@ miDCMoveCursor (pScreen, pCursor, x, y, w, h, dx, dy, source, mask)
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
if (pPriv->pPicture) if (pPriv->pPicture)
{ {
if (!EnsurePicture(pScreenPriv->pTempPicture, &pTemp->drawable, pWin)) if (!EnsurePicture(pScreenPriv->pCoreBuffer->pTempPicture, &pTemp->drawable, pWin))
return FALSE; return FALSE;
CompositePicture (PictOpOver, CompositePicture (PictOpOver,
pPriv->pPicture, pPriv->pPicture,
NULL, NULL,
pScreenPriv->pTempPicture, pScreenPriv->pCoreBuffer->pTempPicture,
0, 0, 0, 0, 0, 0, 0, 0,
dx, dy, dx, dy,
pCursor->bits->width, pCursor->bits->width,
@ -779,22 +824,22 @@ miDCMoveCursor (pScreen, pCursor, x, y, w, h, dx, dy, source, mask)
else else
#endif #endif
{ {
if (!pScreenPriv->pPixSourceGC) if (!pScreenPriv->pCoreBuffer->pPixSourceGC)
{ {
pScreenPriv->pPixSourceGC = CreateGC ((DrawablePtr)pTemp, pScreenPriv->pCoreBuffer->pPixSourceGC = CreateGC ((DrawablePtr)pTemp,
GCGraphicsExposures, &gcval, &status); GCGraphicsExposures, &gcval, &status);
if (!pScreenPriv->pPixSourceGC) if (!pScreenPriv->pCoreBuffer->pPixSourceGC)
return FALSE; return FALSE;
} }
if (!pScreenPriv->pPixMaskGC) if (!pScreenPriv->pCoreBuffer->pPixMaskGC)
{ {
pScreenPriv->pPixMaskGC = CreateGC ((DrawablePtr)pTemp, pScreenPriv->pCoreBuffer->pPixMaskGC = CreateGC ((DrawablePtr)pTemp,
GCGraphicsExposures, &gcval, &status); GCGraphicsExposures, &gcval, &status);
if (!pScreenPriv->pPixMaskGC) if (!pScreenPriv->pCoreBuffer->pPixMaskGC)
return FALSE; return FALSE;
} }
miDCPutBits ((DrawablePtr)pTemp, pPriv, miDCPutBits ((DrawablePtr)pTemp, pPriv,
pScreenPriv->pPixSourceGC, pScreenPriv->pPixMaskGC, pScreenPriv->pCoreBuffer->pPixSourceGC, pScreenPriv->pCoreBuffer->pPixMaskGC,
dx, dy, pCursor->bits->width, pCursor->bits->height, dx, dy, pCursor->bits->width, pCursor->bits->height,
source, mask); source, mask);
} }
@ -803,9 +848,9 @@ miDCMoveCursor (pScreen, pCursor, x, y, w, h, dx, dy, source, mask)
* copy the temporary pixmap onto the screen * copy the temporary pixmap onto the screen
*/ */
if (!EnsureGC(pScreenPriv->pRestoreGC, pWin)) if (!EnsureGC(pScreenPriv->pCoreBuffer->pRestoreGC, pWin))
return FALSE; return FALSE;
pGC = pScreenPriv->pRestoreGC; pGC = pScreenPriv->pCoreBuffer->pRestoreGC;
if (pWin->drawable.serialNumber != pGC->serialNumber) if (pWin->drawable.serialNumber != pGC->serialNumber)
ValidateGC ((DrawablePtr) pWin, pGC); ValidateGC ((DrawablePtr) pWin, pGC);

View File

@ -158,6 +158,24 @@ miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
SPRITE_DEBUG(("Damage remove\n")); SPRITE_DEBUG(("Damage remove\n"));
miSpriteRemoveCursor (pScreenPriv->cp, pScreen); miSpriteRemoveCursor (pScreenPriv->cp, pScreen);
} }
#ifdef MPX
{
int mpCursorIdx = 0;
while (mpCursorIdx < MAX_DEVICES)
{
miCursorInfoPtr pMPCursor = &pScreenPriv->mpCursors[mpCursorIdx];
if (pMPCursor->isUp &&
RECT_IN_REGION (pScreen, pRegion, &pMPCursor->saved) != rgnOUT)
{
SPRITE_DEBUG(("Damage remove MPX\n"));
miSpriteRemoveCursor(pMPCursor, pScreen);
}
mpCursorIdx++;
}
}
#endif
} }
/* /*
@ -266,6 +284,7 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs)
{ {
miCursorInfoPtr cursor = &(pScreenPriv->mpCursors[mpCursorIdx]); miCursorInfoPtr cursor = &(pScreenPriv->mpCursors[mpCursorIdx]);
cursor->id = mpCursorIdx;
cursor->pCursor = NULL; cursor->pCursor = NULL;
cursor->x = 0; cursor->x = 0;
cursor->y = 0; cursor->y = 0;
@ -285,6 +304,10 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs)
mpCursorIdx++; mpCursorIdx++;
} }
/* virtual core pointer has id 1, we might as well save the memory */
xfree(pScreenPriv->cp);
pScreenPriv->cp = &(pScreenPriv->mpCursors[1]);
#endif #endif
return TRUE; return TRUE;

View File

@ -44,6 +44,7 @@ in this Software without prior written authorization from The Open Group.
# include "damage.h" # include "damage.h"
typedef struct { typedef struct {
int id; /* id, corresponds with device id */
CursorPtr pCursor; CursorPtr pCursor;
int x; /* cursor hotspot */ int x; /* cursor hotspot */
int y; int y;