int vboxVbvaReportDirtyRect (PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SOURCE pSrc, RECT *pRectOrig) { VBVACMDHDR hdr; RECT rect = *pRectOrig; // if (rect.left < 0) rect.left = 0; // if (rect.top < 0) rect.top = 0; // if (rect.right > (int)ppdev->cxScreen) rect.right = ppdev->cxScreen; // if (rect.bottom > (int)ppdev->cyScreen) rect.bottom = ppdev->cyScreen; hdr.x = (int16_t)rect.left; hdr.y = (int16_t)rect.top; hdr.w = (uint16_t)(rect.right - rect.left); hdr.h = (uint16_t)(rect.bottom - rect.top); hdr.x += (int16_t)pSrc->VScreenPos.x; hdr.y += (int16_t)pSrc->VScreenPos.y; if (VBoxVBVAWrite(&pSrc->Vbva.Vbva, &VBoxCommonFromDeviceExt(pDevExt)->guestCtx, &hdr, sizeof(hdr))) return VINF_SUCCESS; WARN(("VBoxVBVAWrite failed")); return VERR_GENERAL_FAILURE; }
/* * RDP orders reporting. */ static BOOL vrdpReportOrder(PVBOXDISPDEV pDev, const void *pOrder, unsigned cbOrder, unsigned code) { BOOL bRc = vrdpWriteHdr(pDev, VRDP_MAKE_OP(code)); if (bRc) { VBoxVBVAWrite(&pDev->vbvaCtx, &pDev->hgsmi.ctx, pOrder, cbOrder); } return bRc; }
/** * Callback function called by the X server to tell us about dirty * rectangles in the video buffer. * * @param pScreen pointer to the information structure for the current * screen * @param iRects Number of dirty rectangles to update * @param aRects Array of structures containing the coordinates of the * rectangles */ static void vboxHandleDirtyRect(ScrnInfoPtr pScrn, int iRects, BoxPtr aRects) { VBVACMDHDR cmdHdr; VBOXPtr pVBox; int i; unsigned j; pVBox = pScrn->driverPrivate; if (pVBox->fHaveHGSMI == FALSE || !pScrn->vtSema) return; for (j = 0; j < pVBox->cScreens; ++j) { /* Just continue quietly if VBVA is not currently active. */ struct VBVABUFFER *pVBVA = pVBox->aVbvaCtx[j].pVBVA; if ( !pVBVA || !(pVBVA->hostFlags.u32HostEvents & VBVA_F_MODE_ENABLED)) continue; for (i = 0; i < iRects; ++i) { if ( aRects[i].x1 > pVBox->aScreenLocation[j].x + pVBox->aScreenLocation[j].cx || aRects[i].y1 > pVBox->aScreenLocation[j].y + pVBox->aScreenLocation[j].cy || aRects[i].x2 < pVBox->aScreenLocation[j].x || aRects[i].y2 < pVBox->aScreenLocation[j].y) continue; cmdHdr.x = (int16_t)aRects[i].x1; cmdHdr.y = (int16_t)aRects[i].y1; cmdHdr.w = (uint16_t)(aRects[i].x2 - aRects[i].x1); cmdHdr.h = (uint16_t)(aRects[i].y2 - aRects[i].y1); #if 0 TRACE_LOG("display=%u, x=%d, y=%d, w=%d, h=%d\n", j, cmdHdr.x, cmdHdr.y, cmdHdr.w, cmdHdr.h); #endif if (VBoxVBVABufferBeginUpdate(&pVBox->aVbvaCtx[j], &pVBox->guestCtx)) { VBoxVBVAWrite(&pVBox->aVbvaCtx[j], &pVBox->guestCtx, &cmdHdr, sizeof(cmdHdr)); VBoxVBVABufferEndUpdate(&pVBox->aVbvaCtx[j]); } } } }
__inline BOOL vrdpWriteHdr (PVBOXDISPDEV pDev, uint32_t u32Op) { return VBoxVBVAWrite(&pDev->vbvaCtx, &pDev->hgsmi.ctx, &u32Op, sizeof (u32Op)); }