From b02858b5af47d524001ec571737cc92f6a6f06d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Fri, 29 Oct 2010 16:54:42 +0300 Subject: [PATCH 01/15] xfree86/xv: Remove useless NULL check from ClipNotify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WinPriv->PortRec should never be NULL as WinPriv itself would be removed from the list when the port is removed from the window. Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86xv.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 46761303d..532f0b2bc 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -1120,8 +1120,6 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy) while(WinPriv) { pPriv = WinPriv->PortRec; - if(!pPriv) goto next; - if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) RegionDestroy(pPriv->pCompositeClip); @@ -1156,7 +1154,6 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy) } } -next: pPrev = WinPriv; WinPriv = WinPriv->next; } From 0178173f0579c4b9dd0cf60b9cd3e5d264f86ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Fri, 29 Oct 2010 16:39:13 +0300 Subject: [PATCH 02/15] xfree86/xv: Eliminate two open coded copies of xf86XVRemovePortFromWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No functional change. Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86xv.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 532f0b2bc..f9b3d93ed 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -1048,7 +1048,6 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2) ScreenPtr pScreen = pWin->drawable.pScreen; XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen); XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin); - XF86XVWindowPtr pPrev; XvPortRecPrivatePtr pPriv; Bool AreasExposed; @@ -1061,8 +1060,6 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2) /* filter out XClearWindow/Area */ if (!pWin->valdata) return; - pPrev = NULL; - while(WinPriv) { pPriv = WinPriv->PortRec; @@ -1079,28 +1076,18 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2) if (pPriv->AdaptorRec->ReputImage) xf86XVReputImage(pPriv); else if(AreasExposed) { - XF86XVWindowPtr tmp; - if (pPriv->isOn == XV_ON) { (*pPriv->AdaptorRec->StopVideo)( pPriv->pScrn, pPriv->DevPriv.ptr, FALSE); pPriv->isOn = XV_PENDING; } - pPriv->pDraw = NULL; - if(!pPrev) - dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, - WinPriv->next); - else - pPrev->next = WinPriv->next; - tmp = WinPriv; WinPriv = WinPriv->next; - free(tmp); + xf86XVRemovePortFromWindow(pWin, pPriv); continue; } break; } - pPrev = WinPriv; WinPriv = WinPriv->next; } } @@ -1112,7 +1099,6 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy) ScreenPtr pScreen = pWin->drawable.pScreen; XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen); XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin); - XF86XVWindowPtr tmp, pPrev = NULL; XvPortRecPrivatePtr pPriv; Bool visible = (pWin->visibility == VisibilityUnobscured) || (pWin->visibility == VisibilityPartiallyObscured); @@ -1140,21 +1126,12 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy) } if(!pPriv->type) { /* overlaid still/image */ - pPriv->pDraw = NULL; - - if(!pPrev) - dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, - WinPriv->next); - else - pPrev->next = WinPriv->next; - tmp = WinPriv; WinPriv = WinPriv->next; - free(tmp); + xf86XVRemovePortFromWindow(pWin, pPriv); continue; } } - pPrev = WinPriv; WinPriv = WinPriv->next; } From 38987aae199982f17eae664f3a28ff5941d3ee73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Fri, 29 Oct 2010 16:51:24 +0300 Subject: [PATCH 03/15] xfree86/xv: Factor out the meat of xf86XVWindowExposures for later reuse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No fucntional change. Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86xv.c | 53 ++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index f9b3d93ed..581e8a7a3 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -1004,6 +1004,33 @@ xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) portPriv->pDraw = NULL; } +static void +xf86XVReputOrStopPort(XvPortRecPrivatePtr pPriv, + WindowPtr pWin, + Bool AreasExposed) +{ + switch (pPriv->type) { + case XvInputMask: + xf86XVReputVideo(pPriv); + break; + case XvOutputMask: + xf86XVRegetVideo(pPriv); + break; + default: /* overlaid still/image*/ + if (pPriv->AdaptorRec->ReputImage) + xf86XVReputImage(pPriv); + else if (AreasExposed) { + if (pPriv->isOn == XV_ON) { + (*pPriv->AdaptorRec->StopVideo)(pPriv->pScrn, pPriv->DevPriv.ptr, FALSE); + pPriv->isOn = XV_PENDING; + } + + xf86XVRemovePortFromWindow(pWin, pPriv); + } + break; + } +} + /**** ScreenRec fields ****/ static Bool @@ -1063,32 +1090,8 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2) while(WinPriv) { pPriv = WinPriv->PortRec; - /* Reput anyone with a reput function */ - - switch(pPriv->type) { - case XvInputMask: - xf86XVReputVideo(pPriv); - break; - case XvOutputMask: - xf86XVRegetVideo(pPriv); - break; - default: /* overlaid still/image*/ - if (pPriv->AdaptorRec->ReputImage) - xf86XVReputImage(pPriv); - else if(AreasExposed) { - if (pPriv->isOn == XV_ON) { - (*pPriv->AdaptorRec->StopVideo)( - pPriv->pScrn, pPriv->DevPriv.ptr, FALSE); - pPriv->isOn = XV_PENDING; - } - - WinPriv = WinPriv->next; - xf86XVRemovePortFromWindow(pWin, pPriv); - continue; - } - break; - } WinPriv = WinPriv->next; + xf86XVReputOrStopPort(pPriv, pWin, AreasExposed); } } From 27707ac5bdf6831630944f02f2128951a529faab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Fri, 29 Oct 2010 17:00:24 +0300 Subject: [PATCH 04/15] xfree86/xv: Allow xf86XVReputOrStopPort() to stop PutVideo/GetVideo ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modify xf86XVReputOrStopPort() to allow stopping of all types of ports. Will be useful later. No functional change. Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86xv.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 581e8a7a3..4ed117709 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -1007,8 +1007,20 @@ xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) static void xf86XVReputOrStopPort(XvPortRecPrivatePtr pPriv, WindowPtr pWin, - Bool AreasExposed) + Bool visible) { + if (!visible) { + if (pPriv->isOn == XV_ON) { + (*pPriv->AdaptorRec->StopVideo)(pPriv->pScrn, pPriv->DevPriv.ptr, FALSE); + pPriv->isOn = XV_PENDING; + } + + if (!pPriv->type) /* overlaid still/image*/ + xf86XVRemovePortFromWindow(pWin, pPriv); + + return; + } + switch (pPriv->type) { case XvInputMask: xf86XVReputVideo(pPriv); @@ -1019,14 +1031,6 @@ xf86XVReputOrStopPort(XvPortRecPrivatePtr pPriv, default: /* overlaid still/image*/ if (pPriv->AdaptorRec->ReputImage) xf86XVReputImage(pPriv); - else if (AreasExposed) { - if (pPriv->isOn == XV_ON) { - (*pPriv->AdaptorRec->StopVideo)(pPriv->pScrn, pPriv->DevPriv.ptr, FALSE); - pPriv->isOn = XV_PENDING; - } - - xf86XVRemovePortFromWindow(pWin, pPriv); - } break; } } @@ -1088,10 +1092,19 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2) if (!pWin->valdata) return; while(WinPriv) { + Bool visible = TRUE; + pPriv = WinPriv->PortRec; + /* + * Stop and remove still/images if areas were exposed and + * ReputImage isn't supported. + */ + if (!pPriv->type && !pPriv->AdaptorRec->ReputImage) + visible = !AreasExposed; + WinPriv = WinPriv->next; - xf86XVReputOrStopPort(pPriv, pWin, AreasExposed); + xf86XVReputOrStopPort(pPriv, pWin, visible); } } From 6051c7e940767b7120ad9c7e9188aee6a6f62b94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Fri, 29 Oct 2010 17:05:02 +0300 Subject: [PATCH 05/15] xfree86/xv: Change the behaviour of ClipNotify to reput instead of stop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When ClipNotify gets called for a visible window, reput instead of stopping the port. This eliminates nasty overlay flickering that happens during clip changes. If the window is invisible or if ReputImage isn't supported stop and remove the port from the window as was done before. Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86xv.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 4ed117709..cbbff40ba 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -1116,10 +1116,11 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy) XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen); XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin); XvPortRecPrivatePtr pPriv; - Bool visible = (pWin->visibility == VisibilityUnobscured) || - (pWin->visibility == VisibilityPartiallyObscured); while(WinPriv) { + Bool visible = pWin->visibility == VisibilityUnobscured || + pWin->visibility == VisibilityPartiallyObscured; + pPriv = WinPriv->PortRec; if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) @@ -1131,24 +1132,15 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy) (*pPriv->AdaptorRec->ClipNotify)(pPriv->pScrn, pPriv->DevPriv.ptr, pWin, dx, dy); - /* Stop everything except images, but stop them too if the - window isn't visible. But we only remove the images. */ - - if(pPriv->type || !visible) { - if(pPriv->isOn == XV_ON) { - (*pPriv->AdaptorRec->StopVideo)( - pPriv->pScrn, pPriv->DevPriv.ptr, FALSE); - pPriv->isOn = XV_PENDING; - } - - if(!pPriv->type) { /* overlaid still/image */ - WinPriv = WinPriv->next; - xf86XVRemovePortFromWindow(pWin, pPriv); - continue; - } - } + /* + * Stop and remove still/images if + * ReputImage isn't supported. + */ + if (!pPriv->type && !pPriv->AdaptorRec->ReputImage) + visible = FALSE; WinPriv = WinPriv->next; + xf86XVReputOrStopPort(pPriv, pWin, visible); } if(ScreenPriv->ClipNotify) { From d794be81218934ad4580211c7a0a27cb71eb5d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Fri, 29 Oct 2010 18:07:32 +0300 Subject: [PATCH 06/15] xfree86/xv: No need to free composite clip in AdjustFrame MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nothing should change in AdjustFrame that would need the composite clip to be recomputed. Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86xv.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index cbbff40ba..59232a85d 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -1289,12 +1289,6 @@ xf86XVAdjustFrame(int index, int x, int y, int flags) pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr; if(!pPriv->type && (pPriv->isOn != XV_OFF)) { /* overlaid still/image */ - - if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) - RegionDestroy(pPriv->pCompositeClip); - - pPriv->pCompositeClip = NULL; - pWin = (WindowPtr)pPriv->pDraw; if ((pPriv->AdaptorRec->ReputImage) && From 3d4d0237a3981820a9b7290f69c7172a48659a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Fri, 29 Oct 2010 17:14:34 +0300 Subject: [PATCH 07/15] xfree86/xv: Change the behaviour of AdjustFrame to reput everything MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also reput PutVideo/GetVideo ports in AdjustFrame. This makes the overlay track the screen panning instead of staying stationary in the wrong place. Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86xv.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 59232a85d..f70a2ef04 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -1286,24 +1286,26 @@ xf86XVAdjustFrame(int index, int x, int y, int flags) XvPortRecPrivatePtr pPriv; for(i = pa->nPorts; i > 0; i--, pPort++) { + Bool visible; + pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr; - if(!pPriv->type && (pPriv->isOn != XV_OFF)) { /* overlaid still/image */ - pWin = (WindowPtr)pPriv->pDraw; + pWin = (WindowPtr)pPriv->pDraw; - if ((pPriv->AdaptorRec->ReputImage) && - ((pWin->visibility == VisibilityUnobscured) || - (pWin->visibility == VisibilityPartiallyObscured))) - { - xf86XVReputImage(pPriv); - } else if (pPriv->isOn == XV_ON) { - (*pPriv->AdaptorRec->StopVideo)( - pPriv->pScrn, pPriv->DevPriv.ptr, FALSE); - xf86XVRemovePortFromWindow(pWin, pPriv); - pPriv->isOn = XV_PENDING; - continue; - } - } + if (pPriv->isOn == XV_OFF || !pWin) + continue; + + visible = pWin->visibility == VisibilityUnobscured || + pWin->visibility == VisibilityPartiallyObscured; + + /* + * Stop and remove still/images if + * ReputImage isn't supported. + */ + if (!pPriv->type && !pPriv->AdaptorRec->ReputImage) + visible = FALSE; + + xf86XVReputOrStopPort(pPriv, pWin, visible); } } } From 47d8bd0a999693f47fd244dc876ef7f8fcd52854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Fri, 29 Oct 2010 17:31:14 +0300 Subject: [PATCH 08/15] xfree86/xv: Factor out the meat of xf86XVAdjustFrame for later reuse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No functional change. Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86xv.c | 66 ++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index f70a2ef04..e4c50825d 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -1035,6 +1035,40 @@ xf86XVReputOrStopPort(XvPortRecPrivatePtr pPriv, } } +static void +xf86XVReputOrStopAllPorts(ScrnInfoPtr pScrn) +{ + ScreenPtr pScreen = pScrn->pScreen; + XvScreenPtr pxvs = GET_XV_SCREEN(pScreen); + XvAdaptorPtr pa; + int c, i; + + for (c = pxvs->nAdaptors, pa = pxvs->pAdaptors; c > 0; c--, pa++) { + XvPortPtr pPort = pa->pPorts; + + for (i = pa->nPorts; i > 0; i--, pPort++) { + XvPortRecPrivatePtr pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr; + WindowPtr pWin = (WindowPtr)pPriv->pDraw; + Bool visible; + + if (pPriv->isOn == XV_OFF || !pWin) + continue; + + visible = pWin->visibility == VisibilityUnobscured || + pWin->visibility == VisibilityPartiallyObscured; + + /* + * Stop and remove still/images if + * ReputImage isn't supported. + */ + if (!pPriv->type && !pPriv->AdaptorRec->ReputImage) + visible = FALSE; + + xf86XVReputOrStopPort(pPriv, pWin, visible); + } + } +} + /**** ScreenRec fields ****/ static Bool @@ -1269,11 +1303,7 @@ xf86XVAdjustFrame(int index, int x, int y, int flags) { ScrnInfoPtr pScrn = xf86Screens[index]; ScreenPtr pScreen = pScrn->pScreen; - XvScreenPtr pxvs = GET_XV_SCREEN(pScreen); XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen); - WindowPtr pWin; - XvAdaptorPtr pa; - int c, i; if(ScreenPriv->AdjustFrame) { pScrn->AdjustFrame = ScreenPriv->AdjustFrame; @@ -1281,33 +1311,7 @@ xf86XVAdjustFrame(int index, int x, int y, int flags) pScrn->AdjustFrame = xf86XVAdjustFrame; } - for(c = pxvs->nAdaptors, pa = pxvs->pAdaptors; c > 0; c--, pa++) { - XvPortPtr pPort = pa->pPorts; - XvPortRecPrivatePtr pPriv; - - for(i = pa->nPorts; i > 0; i--, pPort++) { - Bool visible; - - pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr; - - pWin = (WindowPtr)pPriv->pDraw; - - if (pPriv->isOn == XV_OFF || !pWin) - continue; - - visible = pWin->visibility == VisibilityUnobscured || - pWin->visibility == VisibilityPartiallyObscured; - - /* - * Stop and remove still/images if - * ReputImage isn't supported. - */ - if (!pPriv->type && !pPriv->AdaptorRec->ReputImage) - visible = FALSE; - - xf86XVReputOrStopPort(pPriv, pWin, visible); - } - } + xf86XVReputOrStopAllPorts(pScrn); } From 7294236bdb29b4fa7a7bc27aff9c786c5a33c544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Mon, 1 Nov 2010 20:02:40 +0200 Subject: [PATCH 09/15] xfree86/xv: Remove clipOrg from XvPortRecPrivate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clipOrg never changes except when clientClip changes, so instead of keeping copies of both originals translate clientClip by clipOrg immediately and just keep the translated clientClip. Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86xv.c | 6 +++--- hw/xfree86/common/xf86xvpriv.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index e4c50825d..8ccdf065a 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -661,8 +661,7 @@ xf86XVUpdateCompositeClip(XvPortRecPrivatePtr portPriv) pCompositeClip = RegionCreate(NullBox, 1); RegionCopy(pCompositeClip, portPriv->clientClip); RegionTranslate(pCompositeClip, - portPriv->pDraw->x + portPriv->clipOrg.x, - portPriv->pDraw->y + portPriv->clipOrg.y); + portPriv->pDraw->x, portPriv->pDraw->y); RegionIntersect(pCompositeClip, pregWin, pCompositeClip); portPriv->pCompositeClip = pCompositeClip; @@ -687,6 +686,8 @@ xf86XVCopyClip( portPriv->clientClip = RegionCreate(NullBox, 1); /* Note: this is in window coordinates */ RegionCopy(portPriv->clientClip, pGC->clientClip); + RegionTranslate(portPriv->clientClip, + pGC->clipOrg.x, pGC->clipOrg.y); } else if(portPriv->clientClip) { /* free the old clientClip */ RegionDestroy(portPriv->clientClip); portPriv->clientClip = NULL; @@ -697,7 +698,6 @@ xf86XVCopyClip( RegionDestroy(portPriv->pCompositeClip); } - portPriv->clipOrg = pGC->clipOrg; portPriv->pCompositeClip = pGC->pCompositeClip; portPriv->FreeCompositeClip = FALSE; portPriv->subWindowMode = pGC->subWindowMode; diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h index 7623d297d..3191c4c7a 100644 --- a/hw/xfree86/common/xf86xvpriv.h +++ b/hw/xfree86/common/xf86xvpriv.h @@ -67,7 +67,6 @@ typedef struct { DrawablePtr pDraw; unsigned char type; unsigned int subWindowMode; - DDXPointRec clipOrg; RegionPtr clientClip; RegionPtr pCompositeClip; Bool FreeCompositeClip; From b4ebde23d25bef1b891902d75b2db3aad92685b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Mon, 1 Nov 2010 20:27:25 +0200 Subject: [PATCH 10/15] xfree86/xv: Fix ReputImage clipping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PutImage/PutStill respect the GC clip, however ReputImage does not. PutImage/PutStill are supposed to be oneshot operations so ReputImage should never expand the area covered by the clip, instead it should only shrink if the window clip shrinks. So commandeer clientClip into use by ReputImage and initially make it a copy of the original GC composite clip. Whenever ReputImage needs reclipping update clientClip with the newly calculated composite clip. Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86xv.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 8ccdf065a..f1cdfe6f8 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -703,6 +703,27 @@ xf86XVCopyClip( portPriv->subWindowMode = pGC->subWindowMode; } +static void +xf86XVCopyCompositeClip(XvPortRecPrivatePtr portPriv, + GCPtr pGC, + DrawablePtr pDraw) +{ + if (!portPriv->clientClip) + portPriv->clientClip = RegionCreate(NullBox, 1); + /* Keep the original GC composite clip around for ReputImage */ + RegionCopy(portPriv->clientClip, pGC->pCompositeClip); + RegionTranslate(portPriv->clientClip, + -pDraw->x, -pDraw->y); + + /* get rid of the old clip list */ + if (portPriv->pCompositeClip && portPriv->FreeCompositeClip) + RegionDestroy(portPriv->pCompositeClip); + + portPriv->pCompositeClip = pGC->pCompositeClip; + portPriv->FreeCompositeClip = FALSE; + portPriv->subWindowMode = pGC->subWindowMode; +} + static int xf86XVRegetVideo(XvPortRecPrivatePtr portPriv) { @@ -863,6 +884,11 @@ xf86XVReputImage(XvPortRecPrivatePtr portPriv) xf86XVUpdateCompositeClip(portPriv); + /* the clip can get smaller over time */ + RegionCopy(portPriv->clientClip, portPriv->pCompositeClip); + RegionTranslate(portPriv->clientClip, + -portPriv->pDraw->x, -portPriv->pDraw->y); + /* translate the video region to the screen */ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x; WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y; @@ -1411,6 +1437,8 @@ xf86XVPutStill( WinBox.x2 = WinBox.x1 + drw_w; WinBox.y2 = WinBox.y1 + drw_h; + xf86XVCopyCompositeClip(portPriv, pGC, pDraw); + RegionInit(&WinRegion, &WinBox, 1); RegionNull(&ClipRegion); RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip); @@ -1479,6 +1507,10 @@ PUT_STILL_BAILOUT: portPriv->isOn = XV_PENDING; } + /* This clip was copied and only good for one shot */ + if(!portPriv->FreeCompositeClip) + portPriv->pCompositeClip = NULL; + RegionUninit(&WinRegion); RegionUninit(&ClipRegion); @@ -1700,6 +1732,8 @@ xf86XVPutImage( if(!portPriv->pScrn->vtSema) return Success; /* Success ? */ + xf86XVCopyCompositeClip(portPriv, pGC, pDraw); + WinBox.x1 = pDraw->x + drw_x; WinBox.y1 = pDraw->y + drw_y; WinBox.x2 = WinBox.x1 + drw_w; @@ -1776,6 +1810,10 @@ PUT_IMAGE_BAILOUT: portPriv->isOn = XV_PENDING; } + /* This clip was copied and only good for one shot */ + if(!portPriv->FreeCompositeClip) + portPriv->pCompositeClip = NULL; + RegionUninit(&WinRegion); RegionUninit(&ClipRegion); From 5f8ec1ade8b485f48de8c72011409219afad9dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Tue, 2 Nov 2010 16:04:36 +0200 Subject: [PATCH 11/15] xfree86/xv: Add some helpful comments about ReputImage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Document the fact that ReputImage is used for stills as well as images. Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86xv.c | 3 ++- hw/xfree86/common/xf86xv.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index f1cdfe6f8..66cf6858d 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -556,7 +556,7 @@ xf86XVInitAdaptors( adaptorPriv->QueryBestSize = adaptorPtr->QueryBestSize; adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes; adaptorPriv->PutImage = adaptorPtr->PutImage; - adaptorPriv->ReputImage = adaptorPtr->ReputImage; + adaptorPriv->ReputImage = adaptorPtr->ReputImage; /* image/still */ pa->devPriv.ptr = (pointer)adaptorPriv; @@ -873,6 +873,7 @@ CLIP_VIDEO_BAILOUT: return ret; } +/* Reput image/still */ static int xf86XVReputImage(XvPortRecPrivatePtr portPriv) { diff --git a/hw/xfree86/common/xf86xv.h b/hw/xfree86/common/xf86xv.h index c3db6cc73..1b43fcb41 100644 --- a/hw/xfree86/common/xf86xv.h +++ b/hw/xfree86/common/xf86xv.h @@ -165,7 +165,7 @@ typedef struct { GetPortAttributeFuncPtr GetPortAttribute; QueryBestSizeFuncPtr QueryBestSize; PutImageFuncPtr PutImage; - ReputImageFuncPtr ReputImage; + ReputImageFuncPtr ReputImage; /* image/still */ QueryImageAttributesFuncPtr QueryImageAttributes; ClipNotifyFuncPtr ClipNotify; } XF86VideoAdaptorRec, *XF86VideoAdaptorPtr; From 0fef4e94480f2bf1157ce5f92fcb0c7dd1585371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Tue, 2 Nov 2010 16:23:02 +0200 Subject: [PATCH 12/15] xfree86/xv: Document VIDEO_CLIP_TO_VIEWPORT incompatibility with reput MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86xv.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/xfree86/common/xf86xv.h b/hw/xfree86/common/xf86xv.h index 1b43fcb41..973b1d0f4 100644 --- a/hw/xfree86/common/xf86xv.h +++ b/hw/xfree86/common/xf86xv.h @@ -36,6 +36,10 @@ #define VIDEO_INVERT_CLIPLIST 0x00000002 #define VIDEO_OVERLAID_IMAGES 0x00000004 #define VIDEO_OVERLAID_STILLS 0x00000008 +/* + * Usage of VIDEO_CLIP_TO_VIEWPORT is not recommended. + * It can make reput behaviour inconsistent. + */ #define VIDEO_CLIP_TO_VIEWPORT 0x00000010 typedef struct { From a942534ca3908418c407115c6393263c2fe05931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Tue, 2 Nov 2010 16:05:13 +0200 Subject: [PATCH 13/15] xfree86/xv: Pass all coordinate arguments to ReputImage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass all of the src/dst coordinates to ReputImage so that drivers don't necessarily have to do double bookkeeping. Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86xv.c | 7 +++++++ hw/xfree86/common/xf86xv.h | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 66cf6858d..d3230069e 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -939,7 +939,10 @@ xf86XVReputImage(XvPortRecPrivatePtr portPriv) } ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->pScrn, + portPriv->vid_x, portPriv->vid_y, WinBox.x1, WinBox.y1, + portPriv->vid_w, portPriv->vid_h, + portPriv->drw_w, portPriv->drw_h, &ClipRegion, portPriv->DevPriv.ptr, portPriv->pDraw); @@ -1493,6 +1496,8 @@ xf86XVPutStill( xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv); portPriv->isOn = XV_ON; + portPriv->vid_x = vid_x; portPriv->vid_y = vid_y; + portPriv->vid_w = vid_w; portPriv->vid_h = vid_h; portPriv->drw_x = drw_x; portPriv->drw_y = drw_y; portPriv->drw_w = drw_w; portPriv->drw_h = drw_h; portPriv->type = 0; /* no mask means it's transient and should @@ -1796,6 +1801,8 @@ xf86XVPutImage( (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) { portPriv->isOn = XV_ON; + portPriv->vid_x = src_x; portPriv->vid_y = src_y; + portPriv->vid_w = src_w; portPriv->vid_h = src_h; portPriv->drw_x = drw_x; portPriv->drw_y = drw_y; portPriv->drw_w = drw_w; portPriv->drw_h = drw_h; portPriv->type = 0; /* no mask means it's transient and should diff --git a/hw/xfree86/common/xf86xv.h b/hw/xfree86/common/xf86xv.h index 973b1d0f4..47061fed2 100644 --- a/hw/xfree86/common/xf86xv.h +++ b/hw/xfree86/common/xf86xv.h @@ -111,7 +111,9 @@ typedef int (* PutImageFuncPtr)( ScrnInfoPtr pScrn, short src_w, short src_h, short drw_w, short drw_h, int image, unsigned char* buf, short width, short height, Bool Sync, RegionPtr clipBoxes, pointer data, DrawablePtr pDraw ); -typedef int (* ReputImageFuncPtr)( ScrnInfoPtr pScrn, short drw_x, short drw_y, +typedef int (* ReputImageFuncPtr)( ScrnInfoPtr pScrn, + short src_x, short src_y, short drw_x, short drw_y, + short src_w, short src_h, short drw_w, short drw_h, RegionPtr clipBoxes, pointer data, DrawablePtr pDraw ); typedef int (*QueryImageAttributesFuncPtr)(ScrnInfoPtr pScrn, int image, unsigned short *width, unsigned short *height, From 640c8716e0400e35afd7e91efc826fc447ea6745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Thu, 28 Oct 2010 18:13:02 +0300 Subject: [PATCH 14/15] xfree86/modes: Provide a ModeSet hook in ScrnInfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new hook ModeSet that will be called after display mode is changed, or after the display has been panned. Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86str.h | 4 +++- hw/xfree86/modes/xf86Crtc.c | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h index ce6b07f08..a65237a5b 100644 --- a/hw/xfree86/common/xf86str.h +++ b/hw/xfree86/common/xf86str.h @@ -498,7 +498,7 @@ typedef struct _confdrirec { /* These values should be adjusted when new fields are added to ScrnInfoRec */ #define NUM_RESERVED_INTS 16 #define NUM_RESERVED_POINTERS 14 -#define NUM_RESERVED_FUNCS 11 +#define NUM_RESERVED_FUNCS 10 typedef pointer (*funcPointer)(void); @@ -652,6 +652,7 @@ typedef Bool xf86PMEventProc (int, pmEvent, Bool); typedef void xf86DPMSSetProc (ScrnInfoPtr, int, int); typedef void xf86LoadPaletteProc (ScrnInfoPtr, int, int *, LOCO *, VisualPtr); typedef void xf86SetOverscanProc (ScrnInfoPtr, int); +typedef void xf86ModeSetProc (ScrnInfoPtr); /* @@ -802,6 +803,7 @@ typedef struct _ScrnInfoRec { xf86LoadPaletteProc *LoadPalette; xf86SetOverscanProc *SetOverscan; xorgDriverFuncProc *DriverFunc; + xf86ModeSetProc *ModeSet; /* * This can be used when the minor ABI version is incremented. diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 7fc2a60f7..74d91ed60 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -371,6 +371,8 @@ done: crtc->active = TRUE; if (scrn->pScreen) xf86CrtcSetScreenSubpixelOrder (scrn->pScreen); + if (scrn->ModeSet) + scrn->ModeSet(scrn); } else { crtc->x = saved_x; crtc->y = saved_y; @@ -407,12 +409,16 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, void xf86CrtcSetOrigin (xf86CrtcPtr crtc, int x, int y) { + ScrnInfoPtr scrn = crtc->scrn; + crtc->x = x; crtc->y = y; if (crtc->funcs->set_origin) { if (!xf86CrtcRotate (crtc)) return; crtc->funcs->set_origin (crtc, x, y); + if (scrn->ModeSet) + scrn->ModeSet(scrn); } else xf86CrtcSetMode (crtc, &crtc->mode, crtc->rotation, x, y); @@ -2894,6 +2900,8 @@ xf86DisableUnusedFunctions(ScrnInfoPtr pScrn) } if (pScrn->pScreen) xf86_crtc_notify(pScrn->pScreen); + if (pScrn->ModeSet) + pScrn->ModeSet(pScrn); } #ifdef RANDR_12_INTERFACE From f4f41c812d2ba5edba7e0e0dbaab4bbf0af834b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Fri, 29 Oct 2010 17:34:56 +0300 Subject: [PATCH 15/15] xfree86/xv: Provide a ModeSet hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reput all ports when the display mode or panning has been changed by RandR code. This makes the overlays appear in the correct position on the screen. Signed-off-by: Ville Syrjälä Reviewed-by: Luc Verhaegen --- hw/xfree86/common/xf86xv.c | 24 ++++++++++++++++++++++++ hw/xfree86/common/xf86xvpriv.h | 1 + 2 files changed, 25 insertions(+) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index d3230069e..016db1f04 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -104,6 +104,7 @@ static void xf86XVClipNotify(WindowPtr pWin, int dx, int dy); static Bool xf86XVEnterVT(int, int); static void xf86XVLeaveVT(int, int); static void xf86XVAdjustFrame(int index, int x, int y, int flags); +static void xf86XVModeSet(ScrnInfoPtr pScrn); /* misc */ @@ -287,6 +288,7 @@ xf86XVScreenInit( ScreenPriv->EnterVT = pScrn->EnterVT; ScreenPriv->LeaveVT = pScrn->LeaveVT; ScreenPriv->AdjustFrame = pScrn->AdjustFrame; + ScreenPriv->ModeSet = pScrn->ModeSet; pScreen->DestroyWindow = xf86XVDestroyWindow; pScreen->WindowExposures = xf86XVWindowExposures; @@ -295,6 +297,7 @@ xf86XVScreenInit( pScrn->LeaveVT = xf86XVLeaveVT; if(pScrn->AdjustFrame) pScrn->AdjustFrame = xf86XVAdjustFrame; + pScrn->ModeSet = xf86XVModeSet; if(!xf86XVInitAdaptors(pScreen, adaptors, num)) return FALSE; @@ -1241,6 +1244,7 @@ xf86XVCloseScreen(int i, ScreenPtr pScreen) pScrn->EnterVT = ScreenPriv->EnterVT; pScrn->LeaveVT = ScreenPriv->LeaveVT; pScrn->AdjustFrame = ScreenPriv->AdjustFrame; + pScrn->ModeSet = ScreenPriv->ModeSet; for(c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) { xf86XVFreeAdaptor(pa); @@ -1344,6 +1348,26 @@ xf86XVAdjustFrame(int index, int x, int y, int flags) xf86XVReputOrStopAllPorts(pScrn); } +static void +xf86XVModeSet(ScrnInfoPtr pScrn) +{ + ScreenPtr pScreen = pScrn->pScreen; + XF86XVScreenPtr ScreenPriv; + + /* Can be called before pScrn->pScreen is set */ + if (!pScreen) + return; + + ScreenPriv = GET_XF86XV_SCREEN(pScreen); + + if (ScreenPriv->ModeSet) { + pScrn->ModeSet = ScreenPriv->ModeSet; + (*pScrn->ModeSet)(pScrn); + pScrn->ModeSet = xf86XVModeSet; + } + + xf86XVReputOrStopAllPorts(pScrn); +} /**** XvAdaptorRec fields ****/ diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h index 3191c4c7a..88e7a0e59 100644 --- a/hw/xfree86/common/xf86xvpriv.h +++ b/hw/xfree86/common/xf86xvpriv.h @@ -44,6 +44,7 @@ typedef struct { Bool (*EnterVT)(int, int); void (*LeaveVT)(int, int); GCPtr videoGC; + xf86ModeSetProc *ModeSet; } XF86XVScreenRec, *XF86XVScreenPtr; typedef struct {