#define VMWARE_VID_NUM_PORTS 1
/*
- * Using green as the default colorKey
+ * Using a dark shade as the default colorKey
*/
-#define VMWARE_VIDEO_COLORKEY 0x00ff00
+#define VMWARE_VIDEO_COLORKEY 0x100701
/*
* Maximum dimensions
{ 24, TrueColor}
};
-#define VMWARE_VID_NUM_IMAGES 2
+#define VMWARE_VID_NUM_IMAGES 3
static XF86ImageRec vmwareVideoImages[] =
{
XVIMAGE_YV12,
- XVIMAGE_YUY2
+ XVIMAGE_YUY2,
+ XVIMAGE_UYVY
};
-#define VMWARE_VID_NUM_ATTRIBUTES 1
+#define VMWARE_VID_NUM_ATTRIBUTES 2
static XF86AttributeRec vmwareVideoAttributes[] =
{
{
0x000000,
0xffffff,
"XV_COLORKEY"
+ },
+ {
+ XvGettable | XvSettable,
+ 0,
+ 1,
+ "XV_AUTOPAINT_COLORKEY"
}
};
int (*play)(ScrnInfoPtr, struct VMWAREVideoRec *,
short, short, short, short, short,
short, short, short, int, unsigned char*,
- short, short);
+ short, short, RegionPtr);
/*
* Offscreen memory region used to pass video data to the host.
*/
uint8 currBuf;
uint32 size;
uint32 colorKey;
+ Bool isAutoPaintColorkey;
uint32 flags;
+ BoxRec position;
VMWAREVideoFmtData *fmt_priv;
};
short src_x, short src_y, short drw_x,
short drw_y, short src_w, short src_h,
short drw_w, short drw_h, int format,
- unsigned char *buf, short width, short height);
+ unsigned char *buf, short width,
+ short height, RegionPtr clipBoxes);
static int vmwareVideoInitAttributes(ScrnInfoPtr pScrn, VMWAREVideoPtr pVid,
int format, unsigned short width,
unsigned short height);
short drw_y, short src_w, short src_h,
short drw_w, short drw_h, int format,
unsigned char *buf, short width,
- short height);
+ short height, RegionPtr clipBoxes);
static void vmwareVideoFlush(VMWAREPtr pVMWARE, uint32 streamId);
static void vmwareVideoSetOneReg(VMWAREPtr pVMWARE, uint32 streamId,
uint32 regId, uint32 value);
static void vmwareVideoEndStream(ScrnInfoPtr pScrn, VMWAREVideoPtr pVid);
+static Bool vmwareVideoMoved(VMWAREVideoPtr pVid, short drw_x,
+ short drw_y, short drw_w, short drw_h);
/*
* Offscreen memory manager functions
pPriv[i].play = vmwareVideoInitStream;
pPriv[i].flags = SVGA_VIDEO_FLAG_COLORKEY;
pPriv[i].colorKey = VMWARE_VIDEO_COLORKEY;
+ pPriv[i].isAutoPaintColorkey = TRUE;
adaptor->pPortPrivates[i].ptr = &pPriv[i];
}
pVMWARE->videoStreams = du;
short src_x, short src_y, short drw_x,
short drw_y, short src_w, short src_h,
short drw_w, short drw_h, int format,
- unsigned char *buf, short width, short height)
+ unsigned char *buf, short width,
+ short height, RegionPtr clipBoxes)
{
VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
int i;
}
pVid->currBuf = 0;
+ pVid->position.x1 = drw_x;
+ pVid->position.y1 = drw_y;
+ pVid->position.x2 = drw_w;
+ pVid->position.y2 = drw_h;
+
+ if (pVid->isAutoPaintColorkey) {
+ xf86XVFillKeyHelper(pScrn->pScreen, pVid->colorKey, clipBoxes);
+ }
+
VmwareLog(("Got offscreen region, offset %d, size %d "
"(yuv size in bytes: %d)\n",
pVid->fbarea->offset, pVid->fbarea->size, pVid->size));
return pVid->play(pScrn, pVid, src_x, src_y, drw_x, drw_y, src_w, src_h,
- drw_w, drw_h, format, buf, width, height);
+ drw_w, drw_h, format, buf, width, height, clipBoxes);
}
short drw_y, short src_w, short src_h,
short drw_w, short drw_h, int format,
unsigned char *buf, short width,
- short height)
+ short height, RegionPtr clipBoxes)
{
VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
uint32 *fifoItem;
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Increase in size of Xv video "
"frame streamId:%d.\n", pVid->streamId);
vmwareStopVideo(pScrn, pVid, TRUE);
- return pVid->play(pScrn, pVid, src_x, src_y, drw_x, drw_y, src_w,
- src_h, drw_w, drw_h, format, buf, width, height);
+ return pVid->play(pScrn, pVid, src_x, src_y, drw_x, drw_y, src_w,
+ src_h, drw_w, drw_h, format, buf, width, height,
+ clipBoxes);
}
-
+
pVid->size = size;
memcpy(pVid->bufs[pVid->currBuf].data, buf, pVid->size);
vmwareWriteWordToFIFO(pVMWARE, fifoItem[i]);
}
+ if (pVid->isAutoPaintColorkey &&
+ vmwareVideoMoved(pVid, drw_x, drw_y, drw_w, drw_h)) {
+ xf86XVFillKeyHelper(pScrn->pScreen, pVid->colorKey, clipBoxes);
+ }
+
vmwareVideoFlush(pVMWARE, pVid->streamId);
+ /*
+ * Update the position of the video frame.
+ */
+ pVid->position.x1 = drw_x;
+ pVid->position.y1 = drw_y;
+ pVid->position.x2 = drw_w;
+ pVid->position.y2 = drw_h;
+
pVid->currBuf = ++pVid->currBuf & (VMWARE_VID_NUM_BUFFERS - 1);
+
return Success;
}
static void vmwareVideoEndStream(ScrnInfoPtr pScrn, VMWAREVideoPtr pVid)
{
uint32 id, colorKey, flags;
+ Bool isAutoPaintColorkey;
if (pVid->fmt_priv) {
free(pVid->fmt_priv);
id = pVid->streamId;
colorKey = pVid->colorKey;
flags = pVid->flags;
+ isAutoPaintColorkey = pVid->isAutoPaintColorkey;
+
memset(pVid, 0, sizeof(*pVid));
+
pVid->streamId = id;
pVid->play = vmwareVideoInitStream;
pVid->colorKey = colorKey;
pVid->flags = flags;
+ pVid->isAutoPaintColorkey = isAutoPaintColorkey;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmwareVideoMoved --
+ *
+ * Detects whether the video frame has changed its position.
+ *
+ * Results:
+ * TRUE if the position has changed, FALSE otherwise.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static Bool vmwareVideoMoved(VMWAREVideoPtr pVid, short drw_x,
+ short drw_y, short drw_w, short drw_h)
+{
+ return !(pVid->position.x1 == drw_x &&
+ pVid->position.y1 == drw_y &&
+ pVid->position.x2 == drw_w &&
+ pVid->position.y2 == drw_h);
}
}
return pVid->play(pScrn, pVid, src_x, src_y, drw_x, drw_y, src_w, src_h,
- drw_w, drw_h, format, buf, width, height);
+ drw_w, drw_h, format, buf, width, height, clipBoxes);
}
}
size += tmp;
break;
+ case FOURCC_UYVY:
case FOURCC_YUY2:
size = *width * 2;
if (pitches) {
{
VMWAREVideoPtr pVid = (VMWAREVideoPtr) data;
Atom xvColorKey = MAKE_ATOM("XV_COLORKEY");
+ Atom xvAutoPaint = MAKE_ATOM("XV_AUTOPAINT_COLORKEY");
if (attribute == xvColorKey) {
+ VmwareLog(("Set colorkey:0x%x\n", value));
pVid->colorKey = value;
+ } else if (attribute == xvAutoPaint) {
+ VmwareLog(("Set autoPaint: %s\n", value? "TRUE": "FALSE"));
+ pVid->isAutoPaintColorkey = value;
} else {
return XvBadAlloc;
}
+
return Success;
}
{
VMWAREVideoPtr pVid = (VMWAREVideoPtr) data;
Atom xvColorKey = MAKE_ATOM("XV_COLORKEY");
+ Atom xvAutoPaint = MAKE_ATOM("XV_AUTOPAINT_COLORKEY");
if (attribute == xvColorKey) {
*value = pVid->colorKey;
+ } else if (attribute == xvAutoPaint) {
+ *value = pVid->isAutoPaintColorkey;
} else {
return XvBadAlloc;
}
+
return Success;
}