summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorPauli Nieminen <ext-pauli.nieminen@nokia.com>2011-01-17 16:58:00 +0200
committerPauli Nieminen <ext-pauli.nieminen@nokia.com>2011-02-03 14:38:10 +0200
commit5678a41f6bc0ef8965bd50a88c5ef01ba7eb8b24 (patch)
treeea1141ef0b2608b978cf777dc4e9caca8d8dfb6b /hw
parent9b048ca420864e19862f63f4a491a4da0ff9b54f (diff)
xf86/xv: Fill color key on expose
If window gets exposed but clipboxes doesn't change drivers would avoid color key fill. This makes XResizeWindo&co to lose colorkey if background is painted. To help drivers to avoid filling colorkey for each put server can provide helper function if there is exposed areas. Server can subtract exposed areas from filled region. As a side effect we can avoid useless color key fills if window only moves in screen without background fills. v3: * Change tracking to filled area to account for client initiated clip changes * Make overlaid XvPutImage behavior like textured XvPutImage or PutImage * Make region dynamically allocated only when required. v4: * Simplify new driver interface to reduce duplicate code Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> Reviewed-by: Ville Syrjälä <ville.syrjala@nokia.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/xfree86/common/xf86xv.c78
-rw-r--r--hw/xfree86/common/xf86xv.h3
-rw-r--r--hw/xfree86/common/xf86xvpriv.h1
3 files changed, 76 insertions, 6 deletions
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 6dcd497a9..21e00355c 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -331,6 +331,8 @@ xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor)
RegionDestroy(pPriv->clientClip);
if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
RegionDestroy(pPriv->pCompositeClip);
+ if (pPriv->ckeyFilled)
+ RegionDestroy(pPriv->ckeyFilled);
free(pPriv);
}
}
@@ -1016,7 +1018,6 @@ static void
xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
{
XF86XVWindowPtr winPriv, prevPriv = NULL;
-
winPriv = GET_XF86XV_WINDOW(pWin);
while(winPriv) {
@@ -1033,6 +1034,10 @@ xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
winPriv = winPriv->next;
}
portPriv->pDraw = NULL;
+ if (portPriv->ckeyFilled) {
+ RegionDestroy(portPriv->ckeyFilled);
+ portPriv->ckeyFilled = NULL;
+ }
}
static void
@@ -1165,6 +1170,21 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
if (!pPriv->type && !pPriv->AdaptorRec->ReputImage)
visible = !AreasExposed;
+ /*
+ * Subtract exposed areas from overlaid image to match textured video
+ * behavior.
+ */
+ if (!pPriv->type && pPriv->clientClip)
+ RegionSubtract(pPriv->clientClip, pPriv->clientClip, reg1);
+
+ if (visible && pPriv->ckeyFilled) {
+ RegionRec tmp;
+ RegionNull(&tmp);
+ RegionCopy(&tmp, reg1);
+ RegionTranslate(&tmp, pWin->drawable.x, pWin->drawable.y);
+ RegionSubtract(pPriv->ckeyFilled, pPriv->ckeyFilled, &tmp);
+ }
+
WinPriv = WinPriv->next;
xf86XVReputOrStopPort(pPriv, pWin, visible);
}
@@ -1860,12 +1880,12 @@ xf86XVQueryImageAttributes(
}
void
-xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes)
+xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr fillboxes)
{
ScreenPtr pScreen = pDraw->pScreen;
ChangeGCVal pval[2];
- BoxPtr pbox = RegionRects(clipboxes);
- int i, nbox = RegionNumRects(clipboxes);
+ BoxPtr pbox = RegionRects(fillboxes);
+ int i, nbox = RegionNumRects(fillboxes);
xRectangle *rects;
GCPtr gc;
@@ -1894,11 +1914,57 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes)
}
void
-xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
+xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr fillboxes)
{
- xf86XVFillKeyHelperDrawable (&pScreen->root->drawable, key, clipboxes);
+ xf86XVFillKeyHelperDrawable (&pScreen->root->drawable, key, fillboxes);
}
+void
+xf86XVFillKeyHelperPort (DrawablePtr pDraw, pointer data, CARD32 key, RegionPtr clipboxes, Bool fillEverything)
+{
+ WindowPtr pWin = (WindowPtr)pDraw;
+ XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
+ XvPortRecPrivatePtr portPriv = NULL;
+ RegionRec reg;
+ RegionPtr fillboxes;
+
+ while (WinPriv) {
+ XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
+
+ if (data == pPriv->DevPriv.ptr) {
+ portPriv = pPriv;
+ break;
+ }
+
+ WinPriv = WinPriv->next;
+ }
+
+ if (!portPriv)
+ return;
+
+ if (!portPriv->ckeyFilled)
+ portPriv->ckeyFilled = RegionCreate(NULL, 0);
+
+ if (!fillEverything) {
+ RegionNull(&reg);
+ fillboxes = &reg;
+ RegionSubtract(fillboxes, clipboxes, portPriv->ckeyFilled);
+
+ if (!RegionNotEmpty(fillboxes))
+ goto out;
+ } else
+ fillboxes = clipboxes;
+
+
+ RegionCopy(portPriv->ckeyFilled, clipboxes);
+
+ xf86XVFillKeyHelperDrawable(pDraw, key, fillboxes);
+out:
+ if (!fillEverything)
+ RegionUninit(&reg);
+}
+
+
/* xf86XVClipVideoHelper -
Takes the dst box in standard X BoxRec form (top and left
diff --git a/hw/xfree86/common/xf86xv.h b/hw/xfree86/common/xf86xv.h
index 47061fed2..f0d8495c6 100644
--- a/hw/xfree86/common/xf86xv.h
+++ b/hw/xfree86/common/xf86xv.h
@@ -244,6 +244,9 @@ xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes);
extern _X_EXPORT void
xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes);
+extern _X_EXPORT void
+xf86XVFillKeyHelperPort (DrawablePtr pDraw, pointer data, CARD32 key, RegionPtr clipboxes, Bool fillEverything);
+
extern _X_EXPORT Bool
xf86XVClipVideoHelper(
BoxPtr dst,
diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h
index 4572218cb..3f1106de7 100644
--- a/hw/xfree86/common/xf86xvpriv.h
+++ b/hw/xfree86/common/xf86xvpriv.h
@@ -68,6 +68,7 @@ typedef struct {
unsigned char type;
unsigned int subWindowMode;
RegionPtr clientClip;
+ RegionPtr ckeyFilled;
RegionPtr pCompositeClip;
Bool FreeCompositeClip;
XvAdaptorRecPrivatePtr AdaptorRec;