diff options
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86/drivers/vmware/vmwarecurs.c')
-rw-r--r-- | xc/programs/Xserver/hw/xfree86/drivers/vmware/vmwarecurs.c | 215 |
1 files changed, 148 insertions, 67 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/vmware/vmwarecurs.c b/xc/programs/Xserver/hw/xfree86/drivers/vmware/vmwarecurs.c index a9cb25652..1a7c6eb4d 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/vmware/vmwarecurs.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/vmware/vmwarecurs.c @@ -6,7 +6,7 @@ char rcsId_vmwarecurs[] = "Id: vmwarecurs.c,v 1.5 2001/01/30 23:33:02 bennett Exp $"; #endif -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vmware/vmwarecurs.c,v 1.5 2002/10/16 22:12:53 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vmware/vmwarecurs.c,v 1.11 2003/02/05 12:47:42 dawes Exp $ */ #include "vmware.h" #include "bits2pixels.h" @@ -30,7 +30,9 @@ RedefineCursor(VMWAREPtr pVMWARE) int i; VmwareLog(("RedefineCursor\n")); - + + pVMWARE->cursorDefined = FALSE; + /* Define cursor */ vmwareWriteWordToFIFO(pVMWARE, SVGA_CMD_DEFINE_CURSOR); vmwareWriteWordToFIFO(pVMWARE, MOUSE_ID); @@ -48,7 +50,7 @@ RedefineCursor(VMWAREPtr pVMWARE) * arange for 'image' & 1 ^ 'source' = 'image' below when we clip * 'source' below. */ - Raster_BitsToPixels((uint8 *) pVMWARE->hwcur.mask, + vmwareRaster_BitsToPixels((uint8 *) pVMWARE->hwcur.mask, SVGA_BITMAP_INCREMENT(pVMWARE->CursorInfoRec->MaxWidth), (uint8 *) pVMWARE->hwcur.maskPixmap, SVGA_PIXMAP_INCREMENT(pVMWARE->CursorInfoRec->MaxWidth, @@ -61,7 +63,7 @@ RedefineCursor(VMWAREPtr pVMWARE) vmwareWriteWordToFIFO(pVMWARE, ~pVMWARE->hwcur.mask[i]); } - Raster_BitsToPixels((uint8 *) pVMWARE->hwcur.source, + vmwareRaster_BitsToPixels((uint8 *) pVMWARE->hwcur.source, SVGA_BITMAP_INCREMENT(pVMWARE->CursorInfoRec->MaxWidth), (uint8 *) pVMWARE->hwcur.sourcePixmap, SVGA_PIXMAP_INCREMENT(pVMWARE->CursorInfoRec->MaxWidth, @@ -116,6 +118,46 @@ vmwareLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src ) RedefineCursor(pVMWARE); } +#ifdef ARGB_CURSOR +#include "cursorstr.h" + +static Bool +vmwareUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs) +{ + ScrnInfoPtr pScrn = infoFromScreen(pScreen); + return pCurs->bits->height <= MAX_CURS && + pCurs->bits->width <= MAX_CURS && + pScrn->bitsPerPixel > 8; +} + +static void +vmwareLoadCursorARGB(ScrnInfoPtr pScrn, CursorPtr pCurs) +{ + VMWAREPtr pVMWARE = VMWAREPTR(pScrn); + CARD32 width = pCurs->bits->width; + CARD32 height = pCurs->bits->height; + CARD32* image = pCurs->bits->argb; + CARD32* imageEnd = image + (width * height); + + pVMWARE->cursorDefined = FALSE; + + vmwareWriteWordToFIFO(pVMWARE, SVGA_CMD_DEFINE_ALPHA_CURSOR); + vmwareWriteWordToFIFO(pVMWARE, MOUSE_ID); + vmwareWriteWordToFIFO(pVMWARE, 0); + vmwareWriteWordToFIFO(pVMWARE, 0); + vmwareWriteWordToFIFO(pVMWARE, width); + vmwareWriteWordToFIFO(pVMWARE, height); + + while (image != imageEnd) { + vmwareWriteWordToFIFO(pVMWARE, *image++); + } + + vmwareWaitForFB(pVMWARE); + + pVMWARE->cursorDefined = TRUE; +} +#endif + void vmwareWriteCursorRegs(VMWAREPtr pVMWARE, Bool visible, Bool force) { @@ -209,9 +251,7 @@ vmwareCursorInit(ScreenPtr pScreen) { xf86CursorInfoPtr infoPtr; VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(pScreen)); -#ifdef RENDER - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); -#endif + Bool ret; TRACEPOINT @@ -236,20 +276,19 @@ vmwareCursorInit(ScreenPtr pScreen) infoPtr->HideCursor = vmwareHideCursor; infoPtr->ShowCursor = vmwareShowCursor; - - pVMWARE->ScrnFuncs.GetImage = pScreen->GetImage; - pVMWARE->ScrnFuncs.CopyWindow = pScreen->CopyWindow; - pScreen->GetImage = VMWAREGetImage; - pScreen->CopyWindow = VMWARECopyWindow; - -#ifdef RENDER - if(ps) { - pVMWARE->Composite = ps->Composite; - ps->Composite = VMWAREComposite; +#ifdef ARGB_CURSOR + if (pVMWARE->vmwareCapability & SVGA_CAP_ALPHA_CURSOR) { + infoPtr->UseHWCursorARGB = vmwareUseHWCursorARGB; + infoPtr->LoadCursorARGB = vmwareLoadCursorARGB; } -#endif /* RENDER */ +#endif - return(xf86InitCursor(pScreen, infoPtr)); + ret = xf86InitCursor(pScreen, infoPtr); + if (!ret) { + xf86DestroyCursorInfoRec(infoPtr); + pVMWARE->CursorInfoRec = NULL; + } + return ret; } void @@ -264,7 +303,9 @@ vmwareCursorCloseScreen(ScreenPtr pScreen) pScreen->GetImage = pVMWARE->ScrnFuncs.GetImage; pScreen->CopyWindow = pVMWARE->ScrnFuncs.CopyWindow; #ifdef RENDER - ps->Composite = pVMWARE->Composite; + if (ps) { + ps->Composite = pVMWARE->Composite; + } #endif /* RENDER */ vmwareHideCursor(pScrn); @@ -273,56 +314,91 @@ vmwareCursorCloseScreen(ScreenPtr pScreen) /*** Wrap functions that read from the framebuffer ***/ +void +vmwareCursorHookWrappers(ScreenPtr pScreen) +{ + VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(pScreen)); +#ifdef RENDER + PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); +#endif + + TRACEPOINT + + pVMWARE->ScrnFuncs.GetImage = pScreen->GetImage; + pVMWARE->ScrnFuncs.CopyWindow = pScreen->CopyWindow; + pScreen->GetImage = VMWAREGetImage; + pScreen->CopyWindow = VMWARECopyWindow; + +#ifdef RENDER + if (ps) { + pVMWARE->Composite = ps->Composite; + ps->Composite = VMWAREComposite; + } +#endif /* RENDER */ + +} + static void VMWAREGetImage(DrawablePtr src, int x, int y, int w, int h, unsigned int format, unsigned long planeMask, char *pBinImage) { - ScreenPtr pScreen = src->pScreen; - VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(src->pScreen)); - BoxRec box; - Bool hidden = FALSE; - - box.x1 = x; - box.y1 = y; - box.x2 = x + w; - box.y2 = y + h; - - if (BOX_INTERSECT(box, pVMWARE->hwcur.box)) { - PRE_OP_HIDE_CURSOR(); - hidden = TRUE; - } - pScreen->GetImage = pVMWARE->ScrnFuncs.GetImage; - (*pScreen->GetImage)(src, x, y, w, h, format, planeMask, pBinImage); - pScreen->GetImage = VMWAREGetImage; - if (hidden) { - POST_OP_SHOW_CURSOR(); - } + ScreenPtr pScreen = src->pScreen; + VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(src->pScreen)); + BoxRec box; + Bool hidden = FALSE; + + VmwareLog(("VMWAREGetImage(%p, %d, %d, %d, %d, %d, %d, %p)\n", + src, x, y, w, h, format, planeMask, pBinImage)); + + box.x1 = src->x + x; + box.y1 = src->y + y; + box.x2 = box.x1 + w; + box.y2 = box.y1 + h; + + if (BOX_INTERSECT(box, pVMWARE->hwcur.box)) { + PRE_OP_HIDE_CURSOR(); + hidden = TRUE; + } + + pScreen->GetImage = pVMWARE->ScrnFuncs.GetImage; + (*pScreen->GetImage)(src, x, y, w, h, format, planeMask, pBinImage); + pScreen->GetImage = VMWAREGetImage; + + if (hidden) { + POST_OP_SHOW_CURSOR(); + } } static void VMWARECopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) { - ScreenPtr pScreen = pWin->drawable.pScreen; - VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(pWin->drawable.pScreen)); - BoxPtr pBB; - Bool hidden = FALSE; - - /* - * We only worry about the source region here, since shadowfb or XAA will - * take care of the destination region. - */ - pBB = REGION_EXTENTS(pWin->drawable.pScreen, prgnSrc); - if (BOX_INTERSECT(*pBB, pVMWARE->hwcur.box)) { - PRE_OP_HIDE_CURSOR(); - hidden = TRUE; - } - pScreen->CopyWindow = pVMWARE->ScrnFuncs.CopyWindow; - (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc); - pScreen->CopyWindow = VMWARECopyWindow; - - if (hidden) { - POST_OP_SHOW_CURSOR(); - } + ScreenPtr pScreen = pWin->drawable.pScreen; + VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(pWin->drawable.pScreen)); + BoxPtr pBB; + Bool hidden = FALSE; + + /* + * We only worry about the source region here, since shadowfb will + * take care of the destination region. + */ + pBB = REGION_EXTENTS(pWin->drawable.pScreen, prgnSrc); + + VmwareLog(("VMWARECopyWindow(%p, (%d, %d), (%d, %d - %d, %d)\n", + pWin, ptOldOrg.x, ptOldOrg.y, + pBB->x1, pBB->y1, pBB->x2, pBB->y2)); + + if (BOX_INTERSECT(*pBB, pVMWARE->hwcur.box)) { + PRE_OP_HIDE_CURSOR(); + hidden = TRUE; + } + + pScreen->CopyWindow = pVMWARE->ScrnFuncs.CopyWindow; + (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc); + pScreen->CopyWindow = VMWARECopyWindow; + + if (hidden) { + POST_OP_SHOW_CURSOR(); + } } #ifdef RENDER @@ -337,13 +413,18 @@ VMWAREComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PictureScreenPtr ps = GetPictureScreen(pScreen); BoxRec box; Bool hidden = FALSE; + + VmwareLog(("VMWAREComposite op = %d, pSrc = %p, pMask = %p, pDst = %p," + " src = (%d, %d), mask = (%d, %d), dst = (%d, %d), w = %d," + " h = %d\n", op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, + xDst, yDst, width, height)); - /* - * We only worry about the source region here, since shadowfb or XAA will - * take care of the destination region. - */ - box.x1 = pDst->pDrawable->x + xDst; - box.y1 = pDst->pDrawable->y + yDst; + /* + * We only worry about the source region here, since shadowfb or XAA will + * take care of the destination region. + */ + box.x1 = pSrc->pDrawable->x + xSrc; + box.y1 = pSrc->pDrawable->y + ySrc; box.x2 = box.x1 + width; box.y2 = box.y1 + height; |