diff options
author | Pierre-Loup A. Griffais <pgriffais@nvidia.com> | 2010-04-21 16:46:17 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2010-04-26 19:40:12 -0700 |
commit | 518f3b189b6c8aa28b62837d14309fd06163ccbb (patch) | |
tree | 951a4e7afb6e8de82ce6d1804d5e661f75776d79 | |
parent | 25d1c6cd37cc4079adf7c4bad8d10678fb08b409 (diff) |
mi: don't thrash resources when displaying the software cursor across screens
This changes the DC layer to maintain a persistent set of GCs/pixmaps/pictures
for each pScreen instead of failing to thrash between them when changing
screens.
Signed-off-by: Pierre-Loup A. Griffais <pgriffais@nvidia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | mi/midispcur.c | 269 |
1 files changed, 108 insertions, 161 deletions
diff --git a/mi/midispcur.c b/mi/midispcur.c index 3fb7e02b5..904163091 100644 --- a/mi/midispcur.c +++ b/mi/midispcur.c | |||
@@ -59,9 +59,9 @@ static DevPrivateKey miDCScreenKey = &miDCScreenKeyIndex; | |||
59 | 59 | ||
60 | static Bool miDCCloseScreen(int index, ScreenPtr pScreen); | 60 | static Bool miDCCloseScreen(int index, ScreenPtr pScreen); |
61 | 61 | ||
62 | /* per device private data */ | 62 | /* per device per-screen private data */ |
63 | static int miDCSpriteKeyIndex; | 63 | static int miDCSpriteKeyIndex[MAXSCREENS]; |
64 | static DevPrivateKey miDCSpriteKey = &miDCSpriteKeyIndex; | 64 | static DevPrivateKey miDCSpriteKey = miDCSpriteKeyIndex; |
65 | 65 | ||
66 | typedef struct { | 66 | typedef struct { |
67 | GCPtr pSourceGC, pMaskGC; | 67 | GCPtr pSourceGC, pMaskGC; |
@@ -75,10 +75,10 @@ typedef struct { | |||
75 | #endif | 75 | #endif |
76 | } miDCBufferRec, *miDCBufferPtr; | 76 | } miDCBufferRec, *miDCBufferPtr; |
77 | 77 | ||
78 | #define MIDCBUFFER(dev) \ | 78 | #define MIDCBUFFER(dev, screen) \ |
79 | ((DevHasCursor(dev)) ? \ | 79 | ((DevHasCursor(dev)) ? \ |
80 | (miDCBufferPtr)dixLookupPrivate(&dev->devPrivates, miDCSpriteKey) : \ | 80 | (miDCBufferPtr)dixLookupPrivate(&dev->devPrivates, miDCSpriteKey + (screen)->myNum) : \ |
81 | (miDCBufferPtr)dixLookupPrivate(&dev->u.master->devPrivates, miDCSpriteKey)) | 81 | (miDCBufferPtr)dixLookupPrivate(&dev->u.master->devPrivates, miDCSpriteKey + (screen)->myNum)) |
82 | 82 | ||
83 | /* | 83 | /* |
84 | * The core pointer buffer will point to the index of the virtual core pointer | 84 | * The core pointer buffer will point to the index of the virtual core pointer |
@@ -158,10 +158,6 @@ miDCInitialize (ScreenPtr pScreen, miPointerScreenFuncPtr screenFuncs) | |||
158 | return TRUE; | 158 | return TRUE; |
159 | } | 159 | } |
160 | 160 | ||
161 | #define tossGC(gc) (gc ? FreeGC (gc, (GContext) 0) : 0) | ||
162 | #define tossPix(pix) (pix ? (*pScreen->DestroyPixmap) (pix) : TRUE) | ||
163 | #define tossPict(pict) (pict ? FreePicture (pict, 0) : 0) | ||
164 | |||
165 | static Bool | 161 | static Bool |
166 | miDCCloseScreen (int index, ScreenPtr pScreen) | 162 | miDCCloseScreen (int index, ScreenPtr pScreen) |
167 | { | 163 | { |
@@ -183,7 +179,6 @@ miDCRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) | |||
183 | } | 179 | } |
184 | 180 | ||
185 | #ifdef ARGB_CURSOR | 181 | #ifdef ARGB_CURSOR |
186 | #define EnsurePicture(picture,draw,win) (picture || miDCMakePicture(&picture,draw,win)) | ||
187 | 182 | ||
188 | static VisualPtr | 183 | static VisualPtr |
189 | miDCGetWindowVisual (WindowPtr pWin) | 184 | miDCGetWindowVisual (WindowPtr pWin) |
@@ -415,12 +410,8 @@ miDCPutBits ( | |||
415 | (*maskGC->ops->PushPixels) (maskGC, pPriv->maskBits, pDrawable, w, h, x, y); | 410 | (*maskGC->ops->PushPixels) (maskGC, pPriv->maskBits, pDrawable, w, h, x, y); |
416 | } | 411 | } |
417 | 412 | ||
418 | #define EnsureGC(gc,win) (gc || miDCMakeGC(&gc, win)) | ||
419 | |||
420 | static GCPtr | 413 | static GCPtr |
421 | miDCMakeGC( | 414 | miDCMakeGC(WindowPtr pWin) |
422 | GCPtr *ppGC, | ||
423 | WindowPtr pWin) | ||
424 | { | 415 | { |
425 | GCPtr pGC; | 416 | GCPtr pGC; |
426 | int status; | 417 | int status; |
@@ -431,7 +422,6 @@ miDCMakeGC( | |||
431 | pGC = CreateGC((DrawablePtr)pWin, | 422 | pGC = CreateGC((DrawablePtr)pWin, |
432 | GCSubwindowMode|GCGraphicsExposures, gcvals, &status, | 423 | GCSubwindowMode|GCGraphicsExposures, gcvals, &status, |
433 | (XID)0, serverClient); | 424 | (XID)0, serverClient); |
434 | *ppGC = pGC; | ||
435 | return pGC; | 425 | return pGC; |
436 | } | 426 | } |
437 | 427 | ||
@@ -456,22 +446,11 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, | |||
456 | pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates, | 446 | pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates, |
457 | miDCScreenKey); | 447 | miDCScreenKey); |
458 | pWin = WindowTable[pScreen->myNum]; | 448 | pWin = WindowTable[pScreen->myNum]; |
459 | pBuffer = MIDCBUFFER(pDev); | 449 | pBuffer = MIDCBUFFER(pDev, pScreen); |
460 | 450 | ||
461 | #ifdef ARGB_CURSOR | 451 | #ifdef ARGB_CURSOR |
462 | if (pPriv->pPicture) | 452 | if (pPriv->pPicture) |
463 | { | 453 | { |
464 | /* see comment in miDCPutUpCursor */ | ||
465 | if (pBuffer->pRootPicture && | ||
466 | pBuffer->pRootPicture->pDrawable && | ||
467 | pBuffer->pRootPicture->pDrawable->pScreen != pScreen) | ||
468 | { | ||
469 | tossPict(pBuffer->pRootPicture); | ||
470 | pBuffer->pRootPicture = NULL; | ||
471 | } | ||
472 | |||
473 | if (!EnsurePicture(pBuffer->pRootPicture, &pWin->drawable, pWin)) | ||
474 | return FALSE; | ||
475 | CompositePicture (PictOpOver, | 454 | CompositePicture (PictOpOver, |
476 | pPriv->pPicture, | 455 | pPriv->pPicture, |
477 | NULL, | 456 | NULL, |
@@ -484,33 +463,6 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, | |||
484 | else | 463 | else |
485 | #endif | 464 | #endif |
486 | { | 465 | { |
487 | /** | ||
488 | * XXX: Before MPX, the sourceGC and maskGC were attached to the | ||
489 | * screen, and would switch as the screen switches. With mpx we have | ||
490 | * the GC's attached to the device now, so each time we switch screen | ||
491 | * we need to make sure the GC's are allocated on the new screen. | ||
492 | * This is ... not optimal. (whot) | ||
493 | */ | ||
494 | if (pBuffer->pSourceGC && pScreen != pBuffer->pSourceGC->pScreen) | ||
495 | { | ||
496 | tossGC(pBuffer->pSourceGC); | ||
497 | pBuffer->pSourceGC = NULL; | ||
498 | } | ||
499 | |||
500 | if (pBuffer->pMaskGC && pScreen != pBuffer->pMaskGC->pScreen) | ||
501 | { | ||
502 | tossGC(pBuffer->pMaskGC); | ||
503 | pBuffer->pMaskGC = NULL; | ||
504 | } | ||
505 | |||
506 | if (!EnsureGC(pBuffer->pSourceGC, pWin)) | ||
507 | return FALSE; | ||
508 | if (!EnsureGC(pBuffer->pMaskGC, pWin)) | ||
509 | { | ||
510 | FreeGC (pBuffer->pSourceGC, (GContext) 0); | ||
511 | pBuffer->pSourceGC = 0; | ||
512 | return FALSE; | ||
513 | } | ||
514 | miDCPutBits ((DrawablePtr)pWin, pPriv, | 466 | miDCPutBits ((DrawablePtr)pWin, pPriv, |
515 | pBuffer->pSourceGC, pBuffer->pMaskGC, | 467 | pBuffer->pSourceGC, pBuffer->pMaskGC, |
516 | x, y, pCursor->bits->width, pCursor->bits->height, | 468 | x, y, pCursor->bits->width, pCursor->bits->height, |
@@ -531,7 +483,7 @@ miDCSaveUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen, | |||
531 | 483 | ||
532 | pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates, | 484 | pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates, |
533 | miDCScreenKey); | 485 | miDCScreenKey); |
534 | pBuffer = MIDCBUFFER(pDev); | 486 | pBuffer = MIDCBUFFER(pDev, pScreen); |
535 | 487 | ||
536 | pSave = pBuffer->pSave; | 488 | pSave = pBuffer->pSave; |
537 | pWin = WindowTable[pScreen->myNum]; | 489 | pWin = WindowTable[pScreen->myNum]; |
@@ -544,14 +496,7 @@ miDCSaveUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen, | |||
544 | if (!pSave) | 496 | if (!pSave) |
545 | return FALSE; | 497 | return FALSE; |
546 | } | 498 | } |
547 | /* see comment in miDCPutUpCursor */ | 499 | |
548 | if (pBuffer->pSaveGC && pBuffer->pSaveGC->pScreen != pScreen) | ||
549 | { | ||
550 | tossGC(pBuffer->pSaveGC); | ||
551 | pBuffer->pSaveGC = NULL; | ||
552 | } | ||
553 | if (!EnsureGC(pBuffer->pSaveGC, pWin)) | ||
554 | return FALSE; | ||
555 | pGC = pBuffer->pSaveGC; | 500 | pGC = pBuffer->pSaveGC; |
556 | if (pSave->drawable.serialNumber != pGC->serialNumber) | 501 | if (pSave->drawable.serialNumber != pGC->serialNumber) |
557 | ValidateGC ((DrawablePtr) pSave, pGC); | 502 | ValidateGC ((DrawablePtr) pSave, pGC); |
@@ -572,20 +517,13 @@ miDCRestoreUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen, | |||
572 | 517 | ||
573 | pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates, | 518 | pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates, |
574 | miDCScreenKey); | 519 | miDCScreenKey); |
575 | pBuffer = MIDCBUFFER(pDev); | 520 | pBuffer = MIDCBUFFER(pDev, pScreen); |
576 | pSave = pBuffer->pSave; | 521 | pSave = pBuffer->pSave; |
577 | 522 | ||
578 | pWin = WindowTable[pScreen->myNum]; | 523 | pWin = WindowTable[pScreen->myNum]; |
579 | if (!pSave) | 524 | if (!pSave) |
580 | return FALSE; | 525 | return FALSE; |
581 | /* see comment in miDCPutUpCursor */ | 526 | |
582 | if (pBuffer->pRestoreGC && pBuffer->pRestoreGC->pScreen != pScreen) | ||
583 | { | ||
584 | tossGC(pBuffer->pRestoreGC); | ||
585 | pBuffer->pRestoreGC = NULL; | ||
586 | } | ||
587 | if (!EnsureGC(pBuffer->pRestoreGC, pWin)) | ||
588 | return FALSE; | ||
589 | pGC = pBuffer->pRestoreGC; | 527 | pGC = pBuffer->pRestoreGC; |
590 | if (pWin->drawable.serialNumber != pGC->serialNumber) | 528 | if (pWin->drawable.serialNumber != pGC->serialNumber) |
591 | ValidateGC ((DrawablePtr) pWin, pGC); | 529 | ValidateGC ((DrawablePtr) pWin, pGC); |
@@ -607,7 +545,7 @@ miDCChangeSave (DeviceIntPtr pDev, ScreenPtr pScreen, | |||
607 | 545 | ||
608 | pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates, | 546 | pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates, |
609 | miDCScreenKey); | 547 | miDCScreenKey); |
610 | pBuffer = MIDCBUFFER(pDev); | 548 | pBuffer = MIDCBUFFER(pDev, pScreen); |
611 | 549 | ||
612 | pSave = pBuffer->pSave; | 550 | pSave = pBuffer->pSave; |
613 | pWin = WindowTable[pScreen->myNum]; | 551 | pWin = WindowTable[pScreen->myNum]; |
@@ -616,14 +554,7 @@ miDCChangeSave (DeviceIntPtr pDev, ScreenPtr pScreen, | |||
616 | */ | 554 | */ |
617 | if (!pSave) | 555 | if (!pSave) |
618 | return FALSE; | 556 | return FALSE; |
619 | /* see comment in miDCPutUpCursor */ | 557 | |
620 | if (pBuffer->pRestoreGC && pBuffer->pRestoreGC->pScreen != pScreen) | ||
621 | { | ||
622 | tossGC(pBuffer->pRestoreGC); | ||
623 | pBuffer->pRestoreGC = NULL; | ||
624 | } | ||
625 | if (!EnsureGC(pBuffer->pRestoreGC, pWin)) | ||
626 | return FALSE; | ||
627 | pGC = pBuffer->pRestoreGC; | 558 | pGC = pBuffer->pRestoreGC; |
628 | if (pWin->drawable.serialNumber != pGC->serialNumber) | 559 | if (pWin->drawable.serialNumber != pGC->serialNumber) |
629 | ValidateGC ((DrawablePtr) pWin, pGC); | 560 | ValidateGC ((DrawablePtr) pWin, pGC); |
@@ -662,14 +593,7 @@ miDCChangeSave (DeviceIntPtr pDev, ScreenPtr pScreen, | |||
662 | (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC, | 593 | (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC, |
663 | 0, sourcey, -dx, copyh, x + dx, desty); | 594 | 0, sourcey, -dx, copyh, x + dx, desty); |
664 | } | 595 | } |
665 | /* see comment in miDCPutUpCursor */ | 596 | |
666 | if (pBuffer->pSaveGC && pBuffer->pSaveGC->pScreen != pScreen) | ||
667 | { | ||
668 | tossGC(pBuffer->pSaveGC); | ||
669 | pBuffer->pSaveGC = NULL; | ||
670 | } | ||
671 | if (!EnsureGC(pBuffer->pSaveGC, pWin)) | ||
672 | return FALSE; | ||
673 | pGC = pBuffer->pSaveGC; | 597 | pGC = pBuffer->pSaveGC; |
674 | if (pSave->drawable.serialNumber != pGC->serialNumber) | 598 | if (pSave->drawable.serialNumber != pGC->serialNumber) |
675 | ValidateGC ((DrawablePtr) pSave, pGC); | 599 | ValidateGC ((DrawablePtr) pSave, pGC); |
@@ -766,7 +690,7 @@ miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, | |||
766 | pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates, | 690 | pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates, |
767 | miDCScreenKey); | 691 | miDCScreenKey); |
768 | pWin = WindowTable[pScreen->myNum]; | 692 | pWin = WindowTable[pScreen->myNum]; |
769 | pBuffer = MIDCBUFFER(pDev); | 693 | pBuffer = MIDCBUFFER(pDev, pScreen); |
770 | 694 | ||
771 | pTemp = pBuffer->pTemp; | 695 | pTemp = pBuffer->pTemp; |
772 | if (!pTemp || | 696 | if (!pTemp || |
@@ -809,17 +733,9 @@ miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, | |||
809 | #ifdef ARGB_CURSOR | 733 | #ifdef ARGB_CURSOR |
810 | if (pPriv->pPicture) | 734 | if (pPriv->pPicture) |
811 | { | 735 | { |
812 | /* see comment in miDCPutUpCursor */ | 736 | if (!pBuffer->pTempPicture) |
813 | if (pBuffer->pTempPicture && | 737 | miDCMakePicture(&pBuffer->pTempPicture, &pTemp->drawable, pWin); |
814 | pBuffer->pTempPicture->pDrawable && | ||
815 | pBuffer->pTempPicture->pDrawable->pScreen != pScreen) | ||
816 | { | ||
817 | tossPict(pBuffer->pTempPicture); | ||
818 | pBuffer->pTempPicture = NULL; | ||
819 | } | ||
820 | 738 | ||
821 | if (!EnsurePicture(pBuffer->pTempPicture, &pTemp->drawable, pWin)) | ||
822 | return FALSE; | ||
823 | CompositePicture (PictOpOver, | 739 | CompositePicture (PictOpOver, |
824 | pPriv->pPicture, | 740 | pPriv->pPicture, |
825 | NULL, | 741 | NULL, |
@@ -832,38 +748,12 @@ miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, | |||
832 | else | 748 | else |
833 | #endif | 749 | #endif |
834 | { | 750 | { |
835 | if (!pBuffer->pPixSourceGC) | ||
836 | { | ||
837 | pBuffer->pPixSourceGC = CreateGC ((DrawablePtr)pTemp, | ||
838 | GCGraphicsExposures, &gcval, &status, (XID)0, serverClient); | ||
839 | if (!pBuffer->pPixSourceGC) | ||
840 | return FALSE; | ||
841 | } | ||
842 | if (!pBuffer->pPixMaskGC) | ||
843 | { | ||
844 | pBuffer->pPixMaskGC = CreateGC ((DrawablePtr)pTemp, | ||
845 | GCGraphicsExposures, &gcval, &status, (XID)0, serverClient); | ||
846 | if (!pBuffer->pPixMaskGC) | ||
847 | return FALSE; | ||
848 | } | ||
849 | miDCPutBits ((DrawablePtr)pTemp, pPriv, | 751 | miDCPutBits ((DrawablePtr)pTemp, pPriv, |
850 | pBuffer->pPixSourceGC, pBuffer->pPixMaskGC, | 752 | pBuffer->pPixSourceGC, pBuffer->pPixMaskGC, |
851 | dx, dy, pCursor->bits->width, pCursor->bits->height, | 753 | dx, dy, pCursor->bits->width, pCursor->bits->height, |
852 | source, mask); | 754 | source, mask); |
853 | } | 755 | } |
854 | 756 | ||
855 | /* see comment in miDCPutUpCursor */ | ||
856 | if (pBuffer->pRestoreGC && pBuffer->pRestoreGC->pScreen != pScreen) | ||
857 | { | ||
858 | tossGC(pBuffer->pRestoreGC); | ||
859 | pBuffer->pRestoreGC = NULL; | ||
860 | } | ||
861 | /* | ||
862 | * copy the temporary pixmap onto the screen | ||
863 | */ | ||
864 | |||
865 | if (!EnsureGC(pBuffer->pRestoreGC, pWin)) | ||
866 | return FALSE; | ||
867 | pGC = pBuffer->pRestoreGC; | 757 | pGC = pBuffer->pRestoreGC; |
868 | if (pWin->drawable.serialNumber != pGC->serialNumber) | 758 | if (pWin->drawable.serialNumber != pGC->serialNumber) |
869 | ValidateGC ((DrawablePtr) pWin, pGC); | 759 | ValidateGC ((DrawablePtr) pWin, pGC); |
@@ -877,51 +767,108 @@ miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, | |||
877 | static Bool | 767 | static Bool |
878 | miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen) | 768 | miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen) |
879 | { | 769 | { |
880 | miDCBufferPtr pBuffer; | 770 | miDCBufferPtr pBuffer; |
881 | 771 | WindowPtr pWin; | |
882 | pBuffer = xalloc(sizeof(miDCBufferRec)); | 772 | XID gcval = FALSE; |
883 | dixSetPrivate(&pDev->devPrivates, miDCSpriteKey, pBuffer); | 773 | int status; |
884 | 774 | int i; | |
885 | pBuffer->pSourceGC = | 775 | |
886 | pBuffer->pMaskGC = | 776 | if (!DevHasCursor(pDev)) |
887 | pBuffer->pSaveGC = | 777 | return TRUE; |
888 | pBuffer->pRestoreGC = | 778 | |
889 | pBuffer->pMoveGC = | 779 | for (i = 0; i < screenInfo.numScreens; i++) |
890 | pBuffer->pPixSourceGC = | 780 | { |
891 | pBuffer->pPixMaskGC = NULL; | 781 | pScreen = screenInfo.screens[i]; |
782 | |||
783 | pBuffer = xalloc(sizeof(miDCBufferRec)); | ||
784 | if (!pBuffer) | ||
785 | goto failure; | ||
786 | |||
787 | dixSetPrivate(&pDev->devPrivates, miDCSpriteKey + pScreen->myNum, pBuffer); | ||
788 | pWin = WindowTable[pScreen->myNum]; | ||
789 | |||
790 | pBuffer->pSourceGC = miDCMakeGC(pWin); | ||
791 | if (!pBuffer->pSourceGC) | ||
792 | goto failure; | ||
793 | |||
794 | pBuffer->pMaskGC = miDCMakeGC(pWin); | ||
795 | if (!pBuffer->pMaskGC) | ||
796 | goto failure; | ||
797 | |||
798 | pBuffer->pSaveGC = miDCMakeGC(pWin); | ||
799 | if (!pBuffer->pSaveGC) | ||
800 | goto failure; | ||
801 | |||
802 | pBuffer->pRestoreGC = miDCMakeGC(pWin); | ||
803 | if (!pBuffer->pRestoreGC) | ||
804 | goto failure; | ||
805 | |||
806 | pBuffer->pMoveGC = CreateGC ((DrawablePtr)pWin, | ||
807 | GCGraphicsExposures, &gcval, &status, (XID)0, serverClient); | ||
808 | if (!pBuffer->pMoveGC) | ||
809 | goto failure; | ||
810 | |||
811 | pBuffer->pPixSourceGC = CreateGC ((DrawablePtr)pWin, | ||
812 | GCGraphicsExposures, &gcval, &status, (XID)0, serverClient); | ||
813 | if (!pBuffer->pPixSourceGC) | ||
814 | goto failure; | ||
815 | |||
816 | pBuffer->pPixMaskGC = CreateGC ((DrawablePtr)pWin, | ||
817 | GCGraphicsExposures, &gcval, &status, (XID)0, serverClient); | ||
818 | if (!pBuffer->pPixMaskGC) | ||
819 | goto failure; | ||
820 | |||
892 | #ifdef ARGB_CURSOR | 821 | #ifdef ARGB_CURSOR |
893 | pBuffer->pRootPicture = NULL; | 822 | miDCMakePicture(&pBuffer->pRootPicture, &pWin->drawable, pWin); |
894 | pBuffer->pTempPicture = NULL; | 823 | if (!pBuffer->pRootPicture) |
824 | goto failure; | ||
825 | |||
826 | pBuffer->pTempPicture = NULL; | ||
895 | #endif | 827 | #endif |
896 | pBuffer->pSave = pBuffer->pTemp = NULL; | 828 | |
829 | // these get (re)allocated lazily depending on the cursor size | ||
830 | pBuffer->pSave = pBuffer->pTemp = NULL; | ||
831 | } | ||
897 | 832 | ||
898 | return TRUE; | 833 | return TRUE; |
834 | |||
835 | failure: | ||
836 | |||
837 | miDCDeviceCleanup(pDev, pScreen); | ||
838 | |||
839 | return FALSE; | ||
899 | } | 840 | } |
900 | 841 | ||
901 | static void | 842 | static void |
902 | miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) | 843 | miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) |
903 | { | 844 | { |
904 | miDCBufferPtr pBuffer; | 845 | miDCBufferPtr pBuffer; |
846 | int i; | ||
905 | 847 | ||
906 | if (DevHasCursor(pDev)) | 848 | if (DevHasCursor(pDev)) |
907 | { | 849 | { |
908 | pBuffer = MIDCBUFFER(pDev); | 850 | for (i = 0; i < screenInfo.numScreens; i++) |
909 | tossGC (pBuffer->pSourceGC); | 851 | { |
910 | tossGC (pBuffer->pMaskGC); | 852 | pScreen = screenInfo.screens[i]; |
911 | tossGC (pBuffer->pSaveGC); | 853 | |
912 | tossGC (pBuffer->pRestoreGC); | 854 | pBuffer = MIDCBUFFER(pDev, pScreen); |
913 | tossGC (pBuffer->pMoveGC); | 855 | |
914 | tossGC (pBuffer->pPixSourceGC); | 856 | if (pBuffer) |
915 | tossGC (pBuffer->pPixMaskGC); | 857 | { |
916 | tossPix (pBuffer->pSave); | 858 | if (pBuffer->pSourceGC) FreeGC(pBuffer->pSourceGC, (GContext) 0); |
917 | tossPix (pBuffer->pTemp); | 859 | if (pBuffer->pMaskGC) FreeGC(pBuffer->pMaskGC, (GContext) 0); |
918 | #ifdef ARGB_CURSOR | 860 | if (pBuffer->pSaveGC) FreeGC(pBuffer->pSaveGC, (GContext) 0); |
919 | #if 0 /* This has been free()d before */ | 861 | if (pBuffer->pRestoreGC) FreeGC(pBuffer->pRestoreGC, (GContext) 0); |
920 | tossPict (pScreenPriv->pRootPicture); | 862 | if (pBuffer->pMoveGC) FreeGC(pBuffer->pMoveGC, (GContext) 0); |
921 | #endif | 863 | if (pBuffer->pPixSourceGC) FreeGC(pBuffer->pPixSourceGC, (GContext) 0); |
922 | tossPict (pBuffer->pTempPicture); | 864 | if (pBuffer->pPixMaskGC) FreeGC(pBuffer->pPixMaskGC, (GContext) 0); |
923 | #endif | 865 | |
924 | xfree(pBuffer); | 866 | if (pBuffer->pSave) (*pScreen->DestroyPixmap)(pBuffer->pSave); |
925 | dixSetPrivate(&pDev->devPrivates, miDCSpriteKey, NULL); | 867 | if (pBuffer->pTemp) (*pScreen->DestroyPixmap)(pBuffer->pTemp); |
868 | |||
869 | xfree(pBuffer); | ||
870 | dixSetPrivate(&pDev->devPrivates, miDCSpriteKey + pScreen->myNum, NULL); | ||
871 | } | ||
872 | } | ||
926 | } | 873 | } |
927 | } | 874 | } |