[PATCH 09/16] xv: Move xf86 XV color key helper to core.

Eric Anholt eric at anholt.net
Fri Jul 18 10:32:26 PDT 2014


Color key overlay implementations want to reuse this code, and XF86's
had bugs.

Signed-off-by: Eric Anholt <eric at anholt.net>
---
 Xext/xvdix.h               |  2 ++
 Xext/xvmain.c              | 31 +++++++++++++++++++++++++++++++
 hw/xfree86/common/xf86xv.c | 25 +------------------------
 3 files changed, 34 insertions(+), 24 deletions(-)

diff --git a/Xext/xvdix.h b/Xext/xvdix.h
index 534e7d3..828f67c 100644
--- a/Xext/xvdix.h
+++ b/Xext/xvdix.h
@@ -233,6 +233,8 @@ extern _X_EXPORT int XvScreenInit(ScreenPtr);
 extern _X_EXPORT DevPrivateKey XvGetScreenKey(void);
 extern _X_EXPORT unsigned long XvGetRTPort(void);
 extern _X_EXPORT void XvFreeAdaptor(XvAdaptorPtr pAdaptor);
+extern void _X_EXPORT XvFillColorKey(DrawablePtr pDraw, CARD32 key,
+                                     RegionPtr region);
 extern _X_EXPORT int XvdiSendPortNotify(XvPortPtr, Atom, INT32);
 
 extern _X_EXPORT int XvdiPutVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
diff --git a/Xext/xvmain.c b/Xext/xvmain.c
index 9abded5..a3fb711 100644
--- a/Xext/xvmain.c
+++ b/Xext/xvmain.c
@@ -1084,3 +1084,34 @@ XvFreeAdaptor(XvAdaptorPtr pAdaptor)
     free(pAdaptor->devPriv.ptr);
     pAdaptor->devPriv.ptr = NULL;
 }
+
+void
+XvFillColorKey(DrawablePtr pDraw, CARD32 key, RegionPtr region)
+{
+    ScreenPtr pScreen = pDraw->pScreen;
+    ChangeGCVal pval[2];
+    BoxPtr pbox = RegionRects(region);
+    int i, nbox = RegionNumRects(region);
+    xRectangle *rects;
+    GCPtr gc;
+
+    gc = GetScratchGC(pDraw->depth, pScreen);
+    pval[0].val = key;
+    pval[1].val = IncludeInferiors;
+    (void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval);
+    ValidateGC(pDraw, gc);
+
+    rects = malloc(nbox * sizeof(xRectangle));
+
+    for (i = 0; i < nbox; i++, pbox++) {
+        rects[i].x = pbox->x1 - pDraw->x;
+        rects[i].y = pbox->y1 - pDraw->y;
+        rects[i].width = pbox->x2 - pbox->x1;
+        rects[i].height = pbox->y2 - pbox->y1;
+    }
+
+    (*gc->ops->PolyFillRect) (pDraw, gc, nbox, rects);
+
+    free(rects);
+    FreeScratchGC(gc);
+}
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 3e31046..1c250b3 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -1736,34 +1736,11 @@ void
 xf86XVFillKeyHelperDrawable(DrawablePtr pDraw, CARD32 key, RegionPtr fillboxes)
 {
     ScreenPtr pScreen = pDraw->pScreen;
-    ChangeGCVal pval[2];
-    BoxPtr pbox = RegionRects(fillboxes);
-    int i, nbox = RegionNumRects(fillboxes);
-    xRectangle *rects;
-    GCPtr gc;
 
     if (!xf86ScreenToScrn(pScreen)->vtSema)
         return;
 
-    gc = GetScratchGC(pDraw->depth, pScreen);
-    pval[0].val = key;
-    pval[1].val = IncludeInferiors;
-    (void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval);
-    ValidateGC(pDraw, gc);
-
-    rects = malloc(nbox * sizeof(xRectangle));
-
-    for (i = 0; i < nbox; i++, pbox++) {
-        rects[i].x = pbox->x1 - pDraw->x;
-        rects[i].y = pbox->y1 - pDraw->y;
-        rects[i].width = pbox->x2 - pbox->x1;
-        rects[i].height = pbox->y2 - pbox->y1;
-    }
-
-    (*gc->ops->PolyFillRect) (pDraw, gc, nbox, rects);
-
-    free(rects);
-    FreeScratchGC(gc);
+    XvFillColorKey(pDraw, key, fillboxes);
 }
 
 void
-- 
2.0.1



More information about the xorg-devel mailing list