Track number of visible DRI windows separately for transitions.
This allows e.g. doing page flipping with multiple DRI windows as long as only one of them is visible.
This commit is contained in:
		
							parent
							
								
									8a42af6a93
								
							
						
					
					
						commit
						eedf148e5a
					
				|  | @ -204,6 +204,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) | ||||||
|     pDRIPriv->directRenderingSupport = TRUE; |     pDRIPriv->directRenderingSupport = TRUE; | ||||||
|     pDRIPriv->pDriverInfo = pDRIInfo; |     pDRIPriv->pDriverInfo = pDRIInfo; | ||||||
|     pDRIPriv->nrWindows = 0; |     pDRIPriv->nrWindows = 0; | ||||||
|  |     pDRIPriv->nrWindowsVisible = 0; | ||||||
|     pDRIPriv->fullscreen = NULL; |     pDRIPriv->fullscreen = NULL; | ||||||
| 
 | 
 | ||||||
|     pDRIPriv->createDummyCtx     = pDRIInfo->createDummyCtx; |     pDRIPriv->createDummyCtx     = pDRIInfo->createDummyCtx; | ||||||
|  | @ -1006,6 +1007,40 @@ DRITransitionTo2d(ScreenPtr pScreen) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | static void | ||||||
|  | DRIIncreaseNumberVisible(ScreenPtr pScreen) | ||||||
|  | { | ||||||
|  |     DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); | ||||||
|  | 
 | ||||||
|  |     switch (++pDRIPriv->nrWindowsVisible) { | ||||||
|  |     case 1: | ||||||
|  | 	DRITransitionTo3d( pScreen ); | ||||||
|  | 	break; | ||||||
|  |     case 2: | ||||||
|  | 	DRITransitionToSharedBuffers( pScreen ); | ||||||
|  | 	break; | ||||||
|  |     default: | ||||||
|  | 	break; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void | ||||||
|  | DRIDecreaseNumberVisible(ScreenPtr pScreen) | ||||||
|  | { | ||||||
|  |     DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); | ||||||
|  | 
 | ||||||
|  |     switch (--pDRIPriv->nrWindowsVisible) { | ||||||
|  |     case 0: | ||||||
|  | 	DRITransitionTo2d( pScreen ); | ||||||
|  | 	break; | ||||||
|  |     case 1: | ||||||
|  | 	DRITransitionToPrivateBuffers( pScreen ); | ||||||
|  | 	break; | ||||||
|  |     default: | ||||||
|  | 	break; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| Bool | Bool | ||||||
| DRICreateDrawable(ScreenPtr pScreen, Drawable id, | DRICreateDrawable(ScreenPtr pScreen, Drawable id, | ||||||
|                   DrawablePtr pDrawable, drm_drawable_t * hHWDrawable) |                   DrawablePtr pDrawable, drm_drawable_t * hHWDrawable) | ||||||
|  | @ -1040,21 +1075,16 @@ DRICreateDrawable(ScreenPtr pScreen, Drawable id, | ||||||
| 	    pDRIDrawablePriv->pScreen = pScreen; | 	    pDRIDrawablePriv->pScreen = pScreen; | ||||||
| 	    pDRIDrawablePriv->refCount = 1; | 	    pDRIDrawablePriv->refCount = 1; | ||||||
| 	    pDRIDrawablePriv->drawableIndex = -1; | 	    pDRIDrawablePriv->drawableIndex = -1; | ||||||
|  | 	    pDRIDrawablePriv->nrects = REGION_NUM_RECTS(&pWin->clipList); | ||||||
| 
 | 
 | ||||||
| 	    /* save private off of preallocated index */ | 	    /* save private off of preallocated index */ | ||||||
| 	    pWin->devPrivates[DRIWindowPrivIndex].ptr = | 	    pWin->devPrivates[DRIWindowPrivIndex].ptr = | ||||||
| 						(pointer)pDRIDrawablePriv; | 						(pointer)pDRIDrawablePriv; | ||||||
| 
 | 
 | ||||||
| 	    switch (++pDRIPriv->nrWindows) { | 	    if (pDRIDrawablePriv->nrects) | ||||||
| 	    case 1: | 		DRIIncreaseNumberVisible(pScreen); | ||||||
| 	       DRITransitionTo3d( pScreen ); | 
 | ||||||
| 	       break; | 	    pDRIPriv->nrWindows++; | ||||||
| 	    case 2: |  | ||||||
| 	       DRITransitionToSharedBuffers( pScreen ); |  | ||||||
| 	       break; |  | ||||||
| 	    default: |  | ||||||
| 	       break; |  | ||||||
| 	    } |  | ||||||
| 
 | 
 | ||||||
| 	    /* track this in case this window is destroyed */ | 	    /* track this in case this window is destroyed */ | ||||||
| 	    AddResource(id, DRIDrawablePrivResType, (pointer)pWin); | 	    AddResource(id, DRIDrawablePrivResType, (pointer)pWin); | ||||||
|  | @ -1126,19 +1156,14 @@ DRIDrawablePrivDelete(pointer pResource, XID id) | ||||||
| 			       pDRIDrawablePriv->hwDrawable)) { | 			       pDRIDrawablePriv->hwDrawable)) { | ||||||
| 	    return FALSE; | 	    return FALSE; | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	if (pDRIDrawablePriv->nrects) | ||||||
|  | 	    DRIDecreaseNumberVisible(pDrawable->pScreen); | ||||||
|  | 
 | ||||||
| 	xfree(pDRIDrawablePriv); | 	xfree(pDRIDrawablePriv); | ||||||
| 	pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL; | 	pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL; | ||||||
| 
 | 
 | ||||||
| 	switch (--pDRIPriv->nrWindows) { | 	pDRIPriv->nrWindows--; | ||||||
| 	case 0: |  | ||||||
| 	   DRITransitionTo2d( pDrawable->pScreen ); |  | ||||||
| 	   break; |  | ||||||
| 	case 1: |  | ||||||
| 	   DRITransitionToPrivateBuffers( pDrawable->pScreen ); |  | ||||||
| 	   break; |  | ||||||
| 	default: |  | ||||||
| 	   break; |  | ||||||
| 	} |  | ||||||
|     } |     } | ||||||
|     else { /* pixmap (or for GLX 1.3, a PBuffer) */ |     else { /* pixmap (or for GLX 1.3, a PBuffer) */ | ||||||
| 	/* NOT_DONE */ | 	/* NOT_DONE */ | ||||||
|  | @ -1276,7 +1301,7 @@ DRIGetDrawableInfo(ScreenPtr pScreen, | ||||||
| 	    *backX = *X; | 	    *backX = *X; | ||||||
| 	    *backY = *Y; | 	    *backY = *Y; | ||||||
| 
 | 
 | ||||||
| 	    if (pDRIPriv->nrWindows == 1 && *numClipRects) { | 	    if (pDRIPriv->nrWindowsVisible == 1 && *numClipRects) { | ||||||
| 	       /* Use a single cliprect. */ | 	       /* Use a single cliprect. */ | ||||||
| 
 | 
 | ||||||
| 	       int x0 = *X; | 	       int x0 = *X; | ||||||
|  | @ -1652,7 +1677,7 @@ DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) | ||||||
| 
 | 
 | ||||||
|     if(!pDRIPriv) return; |     if(!pDRIPriv) return; | ||||||
| 
 | 
 | ||||||
|     if(pDRIPriv->nrWindows > 0) { |     if(pDRIPriv->nrWindowsVisible > 0) { | ||||||
|        RegionRec reg; |        RegionRec reg; | ||||||
| 
 | 
 | ||||||
|        REGION_NULL(pScreen, ®); |        REGION_NULL(pScreen, ®); | ||||||
|  | @ -1844,19 +1869,26 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy) | ||||||
|     if(!pDRIPriv) return; |     if(!pDRIPriv) return; | ||||||
| 
 | 
 | ||||||
|     if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) { |     if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) { | ||||||
|  |         int nrects = REGION_NUM_RECTS(&pWin->clipList); | ||||||
| 
 | 
 | ||||||
|         if(!pDRIPriv->windowsTouched) { |         if(!pDRIPriv->windowsTouched) { | ||||||
|             DRILockTree(pScreen); |             DRILockTree(pScreen); | ||||||
|             pDRIPriv->windowsTouched = TRUE; |             pDRIPriv->windowsTouched = TRUE; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | 	if (nrects && !pDRIDrawablePriv->nrects) | ||||||
|  | 	    DRIIncreaseNumberVisible(pScreen); | ||||||
|  | 	else if (!nrects && pDRIDrawablePriv->nrects) | ||||||
|  | 	    DRIDecreaseNumberVisible(pScreen); | ||||||
|  | 
 | ||||||
|  | 	pDRIDrawablePriv->nrects = nrects; | ||||||
|  | 
 | ||||||
| 	pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp | 	pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp | ||||||
| 	    = DRIDrawableValidationStamp++; | 	    = DRIDrawableValidationStamp++; | ||||||
| 
 | 
 | ||||||
| 	drmUpdateDrawableInfo(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable, | 	drmUpdateDrawableInfo(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable, | ||||||
| 			      DRM_DRAWABLE_CLIPRECTS, | 			      DRM_DRAWABLE_CLIPRECTS, | ||||||
| 			      REGION_NUM_RECTS(&pWin->clipList), | 			      nrects, REGION_RECTS(&pWin->clipList)); | ||||||
| 			      REGION_RECTS(&pWin->clipList)); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /* call lower wrapped functions */ |     /* call lower wrapped functions */ | ||||||
|  |  | ||||||
|  | @ -53,6 +53,7 @@ typedef struct _DRIDrawablePrivRec | ||||||
|     int			drawableIndex; |     int			drawableIndex; | ||||||
|     ScreenPtr		pScreen; |     ScreenPtr		pScreen; | ||||||
|     int 		refCount; |     int 		refCount; | ||||||
|  |     int 		nrects; | ||||||
| } DRIDrawablePrivRec, *DRIDrawablePrivPtr; | } DRIDrawablePrivRec, *DRIDrawablePrivPtr; | ||||||
| 
 | 
 | ||||||
| struct _DRIContextPrivRec | struct _DRIContextPrivRec | ||||||
|  | @ -87,6 +88,7 @@ typedef struct _DRIScreenPrivRec | ||||||
|     void**		partial3DContextStore; /* parital 3D context        */ |     void**		partial3DContextStore; /* parital 3D context        */ | ||||||
|     DRIInfoPtr		pDriverInfo; |     DRIInfoPtr		pDriverInfo; | ||||||
|     int                 nrWindows; |     int                 nrWindows; | ||||||
|  |     int                 nrWindowsVisible; | ||||||
|     drm_clip_rect_t  private_buffer_rect; /* management of private buffers */ |     drm_clip_rect_t  private_buffer_rect; /* management of private buffers */ | ||||||
|     DrawablePtr         fullscreen; /* pointer to fullscreen drawable */ |     DrawablePtr         fullscreen; /* pointer to fullscreen drawable */ | ||||||
|     drm_clip_rect_t  fullscreen_rect; /* fake rect for fullscreen mode */ |     drm_clip_rect_t  fullscreen_rect; /* fake rect for fullscreen mode */ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue