summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2014-04-05 09:07:18 +0100
committerEric Anholt <eric@anholt.net>2014-08-06 20:12:20 -0700
commitea3f3b0786d58b2ba6a9bbf0a32e734670f54b73 (patch)
tree1d093302d634e618d6f3685989f0805cee8901a1
parentb01cfe5f23766b9c13ed6bd889263d5d7a8a351d (diff)
xv: Move xf86 XV color key helper to core.
Color key overlay implementations want to reuse this code, and XF86's had bugs (to be fixed in the next commit). Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com>
-rw-r--r--Xext/xvdix.h2
-rw-r--r--Xext/xvmain.c31
-rw-r--r--hw/xfree86/common/xf86xv.c25
3 files changed, 34 insertions, 24 deletions
diff --git a/Xext/xvdix.h b/Xext/xvdix.h
index 534e7d3f8..828f67cd1 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 4a439e32c..d932dfdfc 100644
--- a/Xext/xvmain.c
+++ b/Xext/xvmain.c
@@ -1082,3 +1082,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 3e31046b7..1c250b33c 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