midispcur: Construct Picture objects lazily in case Render is disabled.

Reverts part of the effects of 518f3b189b,
"mi: don't thrash resources when displaying the software cursor across
screens". The per-screen cache is preserved, and the GCs are still
allocated eagerly, but now it doesn't construct pRootPicture until
somebody attempts to draw an ARGB cursor.

I noticed crashes in Xnest, which doesn't support the RENDER extension,
but I suspect other DDXes that support disabling that extension would
have had issues as well.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Pierre-Loup A. Griffais <pgriffais@nvidia.com>
This commit is contained in:
Jamey Sharp 2010-05-24 09:15:32 -07:00
parent bf9b64eefb
commit bf78e11839

View File

@ -141,6 +141,7 @@ miDCRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
} }
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
#define EnsurePicture(picture,draw,win) (picture || miDCMakePicture(&picture,draw,win))
static VisualPtr static VisualPtr
miDCGetWindowVisual (WindowPtr pWin) miDCGetWindowVisual (WindowPtr pWin)
@ -413,6 +414,8 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
if (pPriv->pPicture) if (pPriv->pPicture)
{ {
if (!EnsurePicture(pBuffer->pRootPicture, &pWin->drawable, pWin))
return FALSE;
CompositePicture (PictOpOver, CompositePicture (PictOpOver,
pPriv->pPicture, pPriv->pPicture,
NULL, NULL,
@ -695,9 +698,8 @@ miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
if (pPriv->pPicture) if (pPriv->pPicture)
{ {
if (!pBuffer->pTempPicture) if (!EnsurePicture(pBuffer->pTempPicture, &pTemp->drawable, pWin))
miDCMakePicture(&pBuffer->pTempPicture, &pTemp->drawable, pWin); return FALSE;
CompositePicture (PictOpOver, CompositePicture (PictOpOver,
pPriv->pPicture, pPriv->pPicture,
NULL, NULL,
@ -781,10 +783,7 @@ miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
goto failure; goto failure;
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
miDCMakePicture(&pBuffer->pRootPicture, &pWin->drawable, pWin); pBuffer->pRootPicture = NULL;
if (!pBuffer->pRootPicture)
goto failure;
pBuffer->pTempPicture = NULL; pBuffer->pTempPicture = NULL;
#endif #endif