summaryrefslogtreecommitdiff
path: root/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp
diff options
context:
space:
mode:
authorFelix Geyer <fgeyer@debian.org>2014-04-05 22:17:15 +0200
committerFelix Geyer <fgeyer@debian.org>2014-04-05 22:17:15 +0200
commit1700c7d32f7d9d101cbba9f1fcb8bb57ed16a727 (patch)
tree727251ad65172262944f82bb0f28601c3fb6f6b3 /src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp
parent1e85aed889b772c2f2daa7a6d9e8bd967aa213d8 (diff)
downloadvirtualbox-1700c7d32f7d9d101cbba9f1fcb8bb57ed16a727.tar.gz
Imported Upstream version 4.3.10-dfsgupstream/4.3.10-dfsgupstream
Diffstat (limited to 'src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp')
-rw-r--r--src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp397
1 files changed, 322 insertions, 75 deletions
diff --git a/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp b/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp
index 49fa537cd..e1dca8288 100644
--- a/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp
+++ b/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp
@@ -247,8 +247,8 @@ static void crFbBltImg(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcDataPoint,
int32_t srcY = pCopyRect->yTop - pSrcDataPoint->y;
Assert(srcX >= 0);
Assert(srcY >= 0);
- Assert(srcX < pSrc->width);
- Assert(srcY < pSrc->height);
+ Assert(srcX < (int32_t)pSrc->width);
+ Assert(srcY < (int32_t)pSrc->height);
int32_t dstX = pCopyRect->xLeft - pDstDataPoint->x;
int32_t dstY = pCopyRect->yTop - pDstDataPoint->y;
@@ -258,7 +258,7 @@ static void crFbBltImg(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcDataPoint,
uint8_t *pu8Src = ((uint8_t*)pSrc->pvData) + pSrc->pitch * (!fSrcInvert ? srcY : pSrc->height - srcY - 1) + srcX * 4;
uint8_t *pu8Dst = ((uint8_t*)pDst->pvData) + pDst->pitch * dstY + dstX * 4;
- crFbBltMem(pu8Src, fSrcInvert ? -pSrc->pitch : pSrc->pitch, pu8Dst, pDst->pitch, pCopyRect->xRight - pCopyRect->xLeft, pCopyRect->yBottom - pCopyRect->yTop);
+ crFbBltMem(pu8Src, fSrcInvert ? -((int32_t)pSrc->pitch) : (int32_t)pSrc->pitch, pu8Dst, pDst->pitch, pCopyRect->xRight - pCopyRect->xLeft, pCopyRect->yBottom - pCopyRect->yTop);
}
static void crFbBltImgScaled(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcDataPoint, bool fSrcInvert, const RTRECT *pCopyRect, const RTPOINT *pDstDataPoint, float strX, float strY, CR_BLITTER_IMG *pDst)
@@ -267,8 +267,8 @@ static void crFbBltImgScaled(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcData
int32_t srcY = pCopyRect->yTop - pSrcDataPoint->y;
Assert(srcX >= 0);
Assert(srcY >= 0);
- Assert(srcX < pSrc->width);
- Assert(srcY < pSrc->height);
+ Assert(srcX < (int32_t)pSrc->width);
+ Assert(srcY < (int32_t)pSrc->height);
RTPOINT ScaledDtsDataPoint;
RTRECT ScaledCopyRect;
@@ -315,10 +315,68 @@ static void crFbBltImgScaled(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcData
ScaledDstWidth,
ScaledDstHeight,
pu8Src,
- fSrcInvert ? -pSrc->pitch : pSrc->pitch,
+ fSrcInvert ? -((int32_t)pSrc->pitch) : (int32_t)pSrc->pitch,
pCopyRect->xRight - pCopyRect->xLeft, pCopyRect->yBottom - pCopyRect->yTop);
}
+static void crFbBltImgScaledRects(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcDataPoint, bool fSrcInvert, const RTRECT *pCopyRect, const RTPOINT *pDstDataPoint, float strX, float strY, CR_BLITTER_IMG *pDst)
+{
+ int32_t srcX = pCopyRect->xLeft - pSrcDataPoint->x;
+ int32_t srcY = pCopyRect->yTop - pSrcDataPoint->y;
+ Assert(srcX >= 0);
+ Assert(srcY >= 0);
+
+ RTRECT UnscaledCopyRect;
+ VBoxRectUnscaled(pCopyRect, strX, strY, &UnscaledCopyRect);
+
+ srcX = CR_FLOAT_RCAST(int32_t, srcX / strX);
+ srcY = CR_FLOAT_RCAST(int32_t, srcY / strY);
+
+ int32_t UnscaledSrcWidth = UnscaledCopyRect.xRight - UnscaledCopyRect.xLeft;
+ int32_t delta = (int32_t)pSrc->width - srcX - UnscaledSrcWidth;
+ if (delta < 0)
+ UnscaledSrcWidth += delta;
+
+ if (UnscaledSrcWidth <= 0)
+ {
+ LOG(("UnscaledSrcWidth <= 0"));
+ if (UnscaledSrcWidth < 0)
+ WARN(("src width (%d) < 0", UnscaledSrcWidth));
+ return;
+ }
+
+ int32_t UnscaledSrcHeight = UnscaledCopyRect.yBottom - UnscaledCopyRect.yTop;
+ delta = (int32_t)pSrc->height - srcY - UnscaledSrcHeight;
+ if (delta < 0)
+ UnscaledSrcHeight += delta;
+
+ if (UnscaledSrcHeight <= 0)
+ {
+ LOG(("UnscaledSrcHeight <= 0"));
+ if (UnscaledSrcHeight < 0)
+ WARN(("src height (%d) < 0", UnscaledSrcHeight));
+ return;
+ }
+
+ int32_t dstX = pCopyRect->xLeft - pDstDataPoint->x;
+ int32_t dstY = pCopyRect->yTop - pDstDataPoint->y;
+ Assert(dstX >= 0);
+ Assert(dstY >= 0);
+
+
+ uint8_t *pu8Src = ((uint8_t*)pSrc->pvData) + pSrc->pitch * (!fSrcInvert ? srcY : pSrc->height - srcY - 1) + srcX * 4;
+ uint8_t *pu8Dst = ((uint8_t*)pDst->pvData) + pDst->pitch * dstY + dstX * 4;
+
+ CrBmpScale32(pu8Dst, pDst->pitch,
+ pCopyRect->xRight - pCopyRect->xLeft,
+ pCopyRect->yBottom - pCopyRect->yTop,
+ pu8Src,
+ fSrcInvert ? -pSrc->pitch : pSrc->pitch,
+ UnscaledSrcWidth,
+ UnscaledSrcHeight
+ );
+}
+
static void crFbImgFromScreenVram(const VBVAINFOSCREEN *pScreen, void *pvVram, CR_BLITTER_IMG *pImg)
{
pImg->pvData = pvVram;
@@ -337,7 +395,7 @@ static void crFbImgFromFb(HCR_FRAMEBUFFER hFb, CR_BLITTER_IMG *pImg)
crFbImgFromScreenVram(pScreen, pvVram, pImg);
}
-static int crFbBltGetContentsDirect(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
+static int crFbBltGetContentsDirect(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect, const RTRECT *pDstRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
{
VBOXVR_LIST List;
uint32_t c2DRects = 0;
@@ -347,15 +405,17 @@ static int crFbBltGetContentsDirect(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect,
RTPOINT ScaledEntryPoint = {0};
VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR Iter;
- RTPOINT SrcPoint = {pSrcRect->xLeft, pSrcRect->yTop};
- float strX = ((float)pImg->width) / (pSrcRect->xRight - pSrcRect->xLeft);
- float strY = ((float)pImg->height) / (pSrcRect->yBottom - pSrcRect->yTop);
+ int32_t srcWidth = pSrcRect->xRight - pSrcRect->xLeft;
+ int32_t srcHeight = pSrcRect->yBottom - pSrcRect->yTop;
+ int32_t dstWidth = pDstRect->xRight - pDstRect->xLeft;
+ int32_t dstHeight = pDstRect->yBottom - pDstRect->yTop;
- RTPOINT ScaledSrcPoint;
- ScaledSrcPoint.x = CR_FLOAT_RCAST(int32_t, strX * SrcPoint.x);
- ScaledSrcPoint.y = CR_FLOAT_RCAST(int32_t, strY * SrcPoint.y);
+ RTPOINT DstPoint = {pDstRect->xLeft, pDstRect->yTop};
+ float strX = ((float)dstWidth) / srcWidth;
+ float strY = ((float)dstHeight) / srcHeight;
+ bool fScale = (dstWidth != srcWidth || dstHeight != srcHeight);
- RTPOINT ZeroPoint = {0, 0};
+ const RTPOINT ZeroPoint = {0, 0};
VBoxVrListInit(&List);
int rc = VBoxVrListRectsAdd(&List, 1, CrVrScrCompositorRectGet(&hFb->Compositor), NULL);
@@ -387,18 +447,24 @@ static int crFbBltGetContentsDirect(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect,
goto end;
}
- for (uint32_t i = 0; i < cRects; ++i)
+ for (uint32_t j = 0; j < cRegions; ++j)
{
- const RTRECT * pRect = &pRects[i];
- for (uint32_t j = 0; j < cRegions; ++j)
+ /* rects are in dst coordinates,
+ * while the pReg is in source coords
+ * convert */
+ const RTRECT * pReg = &pRegions[j];
+ RTRECT ScaledReg;
+ /* scale */
+ VBoxRectScaled(pReg, strX, strY, &ScaledReg);
+ /* translate */
+ VBoxRectTranslate(&ScaledReg, pDstRect->xLeft, pDstRect->yTop);
+
+ for (uint32_t i = 0; i < cRects; ++i)
{
- const RTRECT * pReg = &pRegions[j];
- RTRECT Intersection;
- VBoxRectIntersected(pRect, pReg, &Intersection);
- if (VBoxRectIsZero(&Intersection))
- continue;
+ const RTRECT * pRect = &pRects[i];
- VBoxRectScale(&Intersection, strX, strY);
+ RTRECT Intersection;
+ VBoxRectIntersected(pRect, &ScaledReg, &Intersection);
if (VBoxRectIsZero(&Intersection))
continue;
@@ -454,8 +520,8 @@ static int crFbBltGetContentsDirect(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect,
width = CR_FLOAT_RCAST(uint32_t, strX * pVrTex->width);
height = CR_FLOAT_RCAST(uint32_t, strY * pVrTex->height);
- ScaledEntryPoint.x = CR_FLOAT_RCAST(int32_t, strX * CrVrScrCompositorEntryRectGet(pEntry)->xLeft);
- ScaledEntryPoint.y = CR_FLOAT_RCAST(int32_t, strY * CrVrScrCompositorEntryRectGet(pEntry)->yTop);
+ ScaledEntryPoint.x = CR_FLOAT_RCAST(int32_t, strX * CrVrScrCompositorEntryRectGet(pEntry)->xLeft) + pDstRect->xLeft;
+ ScaledEntryPoint.y = CR_FLOAT_RCAST(int32_t, strY * CrVrScrCompositorEntryRectGet(pEntry)->yTop) + pDstRect->yTop;
}
rc = CrTdBltDataAcquireScaled(pTex, GL_BGRA, false, width, height, &pSrcImg);
@@ -467,7 +533,7 @@ static int crFbBltGetContentsDirect(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect,
bool fInvert = !(CrVrScrCompositorEntryFlagsGet(pEntry) & CRBLT_F_INVERT_SRC_YCOORDS);
- crFbBltImg(pSrcImg, &ScaledEntryPoint, fInvert, &Intersection, &ScaledSrcPoint, pImg);
+ crFbBltImg(pSrcImg, &ScaledEntryPoint, fInvert, &Intersection, &ZeroPoint, pImg);
CrTdBltDataReleaseScaled(pTex, pSrcImg);
}
@@ -502,36 +568,34 @@ static int crFbBltGetContentsDirect(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect,
goto end;
}
- RTPOINT Pos = {0};
const RTRECT *pCompRect = CrVrScrCompositorRectGet(&hFb->Compositor);
- uint32_t fbWidth = (pCompRect->xRight - pCompRect->xLeft);
- uint32_t fbHeight = pCompRect->yBottom - pCompRect->yTop;
-
- uint32_t stretchedWidth = CR_FLOAT_RCAST(uint32_t, strX * fbWidth);
- uint32_t stretchedHeight = CR_FLOAT_RCAST(uint32_t, strY * fbHeight);
-
CR_BLITTER_IMG FbImg;
- bool fScale = fbWidth != stretchedWidth || fbHeight != stretchedHeight;
-
crFbImgFromFb(hFb, &FbImg);
- for (uint32_t i = 0; i < cRects; ++i)
+ for (uint32_t j = 0; j < c2DRects; ++j)
{
- const RTRECT * pRect = &pRects[i];
- for (uint32_t j = 0; j < c2DRects; ++j)
+ const RTRECT * p2DRect = &p2DRects[j];
+ RTRECT ScaledReg;
+ /* scale */
+ VBoxRectScaled(p2DRect, strX, strY, &ScaledReg);
+ /* translate */
+ VBoxRectTranslate(&ScaledReg, pDstRect->xLeft, pDstRect->yTop);
+
+ for (uint32_t i = 0; i < cRects; ++i)
{
- const RTRECT * p2DRect = &p2DRects[j];
+ const RTRECT * pRect = &pRects[i];
RTRECT Intersection;
- VBoxRectIntersected(pRect, p2DRect, &Intersection);
+
+ VBoxRectIntersected(pRect, &ScaledReg, &Intersection);
if (VBoxRectIsZero(&Intersection))
continue;
if (!fScale)
- crFbBltImg(&FbImg, &ZeroPoint, false, &Intersection, &SrcPoint, pImg);
+ crFbBltImg(&FbImg, &DstPoint, false, &Intersection, &ZeroPoint, pImg);
else
- crFbBltImgScaled(&FbImg, &ZeroPoint, false, &Intersection, &SrcPoint, strX, strY, pImg);
+ crFbBltImgScaledRects(&FbImg, &DstPoint, false, &Intersection, &ZeroPoint, strX, strY, pImg);
}
}
}
@@ -549,10 +613,21 @@ end:
return rc;
}
-static int crFbBltGetContentsScaleCPU(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
+static int crFbBltGetContentsScaleCPU(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect, const RTRECT *pDstRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
{
- uint32_t srcWidth = pSrcRect->xRight - pSrcRect->xLeft;
- uint32_t srcHeight = pSrcRect->yBottom - pSrcRect->yTop;
+ int32_t srcWidth = pSrcRect->xRight - pSrcRect->xLeft;
+ int32_t srcHeight = pSrcRect->yBottom - pSrcRect->yTop;
+ int32_t dstWidth = pDstRect->xRight - pDstRect->xLeft;
+ int32_t dstHeight = pDstRect->yBottom - pDstRect->yTop;
+
+ RTPOINT DstPoint = {pDstRect->xLeft, pDstRect->yTop};
+ float strX = ((float)dstWidth) / srcWidth;
+ float strY = ((float)dstHeight) / srcHeight;
+
+ RTRECT DstRect;
+ VBoxRectUnscaled(pDstRect, strX, strY, &DstRect);
+ DstRect.xRight = DstRect.xLeft + srcWidth;
+ DstRect.yBottom = DstRect.yTop + srcHeight;
/* destination is bigger than the source, do 3D data stretching with CPU */
CR_BLITTER_IMG Img;
@@ -569,7 +644,7 @@ static int crFbBltGetContentsScaleCPU(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRec
Img.bpp = pImg->bpp;
Img.pitch = Img.width * 4;
- int rc = CrFbBltGetContents(hFb, pSrcRect, cRects, pRects, &Img);
+ int rc = CrFbBltGetContents(hFb, pSrcRect, &DstRect, cRects, pRects, &Img);
if (RT_SUCCESS(rc))
{
CrBmpScale32((uint8_t *)pImg->pvData,
@@ -588,21 +663,187 @@ static int crFbBltGetContentsScaleCPU(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRec
}
-int CrFbBltGetContents(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
+int CrFbBltGetContents(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect, const RTRECT *pDstRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
{
uint32_t srcWidth = pSrcRect->xRight - pSrcRect->xLeft;
uint32_t srcHeight = pSrcRect->yBottom - pSrcRect->yTop;
- if ((srcWidth == pImg->width
- && srcHeight == pImg->height)
+ uint32_t dstWidth = pDstRect->xRight - pDstRect->xLeft;
+ uint32_t dstHeight = pDstRect->yBottom - pDstRect->yTop;
+ if ((srcWidth == dstWidth
+ && srcHeight == dstHeight)
|| !CrFbHas3DData(hFb)
- || (srcWidth * srcHeight > pImg->width * pImg->height))
+ || (srcWidth * srcHeight > dstWidth * dstHeight))
{
- return crFbBltGetContentsDirect(hFb, pSrcRect, cRects, pRects, pImg);
+ return crFbBltGetContentsDirect(hFb, pSrcRect, pDstRect, cRects, pRects, pImg);
}
- return crFbBltGetContentsScaleCPU(hFb, pSrcRect, cRects, pRects, pImg);
+ return crFbBltGetContentsScaleCPU(hFb, pSrcRect, pDstRect, cRects, pRects, pImg);
}
+#if 0
+static int crFbBltPutContentsVram(HCR_FRAMEBUFFER hFb, const RTPOINT *pDstPoint, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg, float strX, float strY)
+{
+ const RTRECT *pCompRect = CrVrScrCompositorRectGet(&hFb->Compositor);
+ const RTPOINT ZeroPoint = {0};
+
+ uint32_t fbWidth = (pCompRect->xRight - pCompRect->xLeft);
+ uint32_t fbHeight = pCompRect->yBottom - pCompRect->yTop;
+
+ uint32_t stretchedWidth = CR_FLOAT_RCAST(uint32_t, strX * fbWidth);
+ uint32_t stretchedHeight = CR_FLOAT_RCAST(uint32_t, strY * fbHeight);
+
+ CR_BLITTER_IMG FbImg;
+
+ bool fScale = fbWidth != stretchedWidth || fbHeight != stretchedHeight;
+
+ crFbImgFromFb(hFb, &FbImg);
+
+ RTRECT Intersection;
+
+ for (uint32_t i = 0; i < cRects; ++i)
+ {
+ const RTRECT * pRect = &pRects[i];
+ VBoxRectIntersected(pRect, pCompRect, &Intersection);
+
+ if (VBoxRectIsZero(&Intersection))
+ continue;
+
+ if (!fScale)
+ crFbBltImg(pImg, pDstPoint, false, &Intersection, &ZeroPoint, &FbImg);
+ else
+ crFbBltImgScaled(pImg, pDstPoint, false, &Intersection, &ZeroPoint, strX, strY, &FbImg);
+ }
+
+ return VINF_SUCCESS;
+}
+
+int CrFbBltPutContents(HCR_FRAMEBUFFER hFb, const RTRECT *pDstRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
+{
+ RTPOINT DstPoint = {pDstRect->xLeft, pDstRect->yTop};
+ float strX = ((float)pImg->width) / (pDstRect->xRight - pDstRect->xLeft);
+ float strY = ((float)pImg->height) / (pDstRect->yBottom - pDstRect->yTop);
+
+ int rc = CrFbEntryRegionsAdd(hFb, NULL, const RTPOINT *pPos, cRects, pRects, true)
+ if (!hFb->cUpdating)
+ {
+ WARN(("not updating\n"));
+ return VERR_INVALID_STATE;
+ }
+}
+
+int CrFbBltPutContentsNe(HCR_FRAMEBUFFER hFb, const RTRECT *pDstRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
+{
+ uint32_t cCompRects;
+ const RTRECT *pCompRects;
+ int rc = CrVrScrCompositorRegionsGet(&hFb->Compositor, &cCompRects, NULL, NULL, &pCompRects);
+ if (!RT_SUCCESS(rc))
+ {
+ WARN(("CrVrScrCompositorRegionsGet failed rc %d", rc));
+ return rc;
+ }
+
+ bool fRegChanged = false;
+ for (uint32_t i = 0; i < cCompRects; ++i)
+ {
+ const RTRECT *pCompRect = pCompRects[i];
+ for (uint32_t j = 0; j < cRects; ++j)
+ {
+ const RTRECT *pRect = pRects[j];
+ if (VBoxRectIsIntersect(pCompRect, pRect))
+ {
+ fRegChanged = true;
+ break;
+ }
+ }
+ }
+
+ if (fRegChanged)
+ {
+ rc = CrFbUpdateBegin(hFb);
+ if (RT_SUCCESS(rc))
+ {
+ rc = CrFbBltPutContents(hFb, pDstRect, cRects, pRects, pImg);
+ if (!RT_SUCCESS(rc))
+ WARN(("CrFbBltPutContents failed rc %d", rc));
+ CrFbUpdateEnd(hFb);
+ }
+ else
+ WARN(("CrFbUpdateBegin failed rc %d", rc));
+
+ return rc;
+ }
+
+ return crFbBltPutContentsVram(HCR_FRAMEBUFFER hFb, const RTPOINT *pDstPoint, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg, float strX, float strY);
+
+ const RTPOINT ZeroPoint = {0, 0};
+
+ c2DRects = VBoxVrListRectsCount(&List);
+ if (c2DRects)
+ {
+ if (g_CrPresenter.cbTmpBuf2 < c2DRects * sizeof (RTRECT))
+ {
+ if (g_CrPresenter.pvTmpBuf2)
+ RTMemFree(g_CrPresenter.pvTmpBuf2);
+
+ g_CrPresenter.cbTmpBuf2 = (c2DRects + 10) * sizeof (RTRECT);
+ g_CrPresenter.pvTmpBuf2 = RTMemAlloc(g_CrPresenter.cbTmpBuf2);
+ if (!g_CrPresenter.pvTmpBuf2)
+ {
+ WARN(("RTMemAlloc failed!"));
+ g_CrPresenter.cbTmpBuf2 = 0;
+ rc = VERR_NO_MEMORY;
+ goto end;
+ }
+ }
+
+ RTRECT *p2DRects = (RTRECT *)g_CrPresenter.pvTmpBuf2;
+
+ rc = VBoxVrListRectsGet(&List, c2DRects, p2DRects);
+ if (!RT_SUCCESS(rc))
+ {
+ WARN(("VBoxVrListRectsGet failed, rc %d", rc));
+ goto end;
+ }
+
+ RTPOINT Pos = {0};
+ const RTRECT *pCompRect = CrVrScrCompositorRectGet(&hFb->Compositor);
+
+ CR_BLITTER_IMG FbImg;
+
+ crFbImgFromFb(hFb, &FbImg);
+
+ for (uint32_t i = 0; i < cRects; ++i)
+ {
+ const RTRECT * pRect = &pRects[i];
+ for (uint32_t j = 0; j < c2DRects; ++j)
+ {
+ const RTRECT * p2DRect = &p2DRects[j];
+ RTRECT Intersection;
+ VBoxRectIntersected(pRect, p2DRect, &Intersection);
+ if (VBoxRectIsZero(&Intersection))
+ continue;
+
+ if (!fScale)
+ crFbBltImg(&FbImg, &ZeroPoint, false, &Intersection, &SrcPoint, pImg);
+ else
+ crFbBltImgScaled(&FbImg, &ZeroPoint, false, &Intersection, &SrcPoint, strX, strY, pImg);
+ }
+ }
+ }
+
+end:
+
+ if (pEnteredTex)
+ CrTdBltLeave(pEnteredTex);
+
+ if (pEnteredBlitter)
+ CrBltLeave(pEnteredBlitter);
+
+ VBoxVrListClear(&List);
+
+ return rc;
+}
+#endif
int CrFbResize(CR_FRAMEBUFFER *pFb, const struct VBVAINFOSCREEN * pScreen, void *pvVRAM)
{
@@ -3583,7 +3824,7 @@ HCR_FRAMEBUFFER CrPMgrFbGetEnabled(uint32_t idScreen)
static HCR_FRAMEBUFFER crPMgrFbGetNextEnabled(uint32_t i)
{
- for (;i < cr_server.screenCount; ++i)
+ for (;i < (uint32_t)cr_server.screenCount; ++i)
{
HCR_FRAMEBUFFER hFb = CrPMgrFbGetEnabled(i);
if (hFb)
@@ -3595,7 +3836,7 @@ static HCR_FRAMEBUFFER crPMgrFbGetNextEnabled(uint32_t i)
static HCR_FRAMEBUFFER crPMgrFbGetNextInitialized(uint32_t i)
{
- for (;i < cr_server.screenCount; ++i)
+ for (;i < (uint32_t)cr_server.screenCount; ++i)
{
HCR_FRAMEBUFFER hFb = CrPMgrFbGetInitialized(i);
if (hFb)
@@ -3943,7 +4184,7 @@ int CrPMgrHlpGlblUpdateBegin(CR_FBMAP *pMap)
/*helper function that calls CrFbUpdateEnd for all framebuffers being updated */
void CrPMgrHlpGlblUpdateEnd(CR_FBMAP *pMap)
{
- for (uint32_t i = 0; i < cr_server.screenCount; ++i)
+ for (uint32_t i = 0; i < (uint32_t)cr_server.screenCount; ++i)
{
if (!CrFBmIsSet(pMap, i))
continue;
@@ -4412,12 +4653,12 @@ int32_t crVBoxServerCrCmdBltProcess(PVBOXCMDVBVA_HDR pCmd, uint32_t cbCmd)
if (u8Flags & (VBOXCMDVBVA_OPF_ALLOC_DSTPRIMARY | VBOXCMDVBVA_OPF_ALLOC_SRCPRIMARY))
{
VBOXCMDVBVA_BLT_PRIMARY *pBlt = (VBOXCMDVBVA_BLT_PRIMARY*)pCmd;
- uint8_t u8PrimaryID = pBlt->Hdr.u8PrimaryID;
+ uint8_t u8PrimaryID = pBlt->Hdr.u.u8PrimaryID;
HCR_FRAMEBUFFER hFb = CrPMgrFbGetEnabled(u8PrimaryID);
if (!hFb)
{
WARN(("request to present on disabled framebuffer, ignore"));
- pCmd->i8Result = -1;
+ pCmd->u.i8Result = -1;
return VINF_SUCCESS;
}
@@ -4435,7 +4676,7 @@ int32_t crVBoxServerCrCmdBltProcess(PVBOXCMDVBVA_HDR pCmd, uint32_t cbCmd)
{
WARN(("RTMemAlloc failed!"));
g_CrPresenter.cbTmpBuf = 0;
- pCmd->i8Result = -1;
+ pCmd->u.i8Result = -1;
return VINF_SUCCESS;
}
}
@@ -4455,23 +4696,24 @@ int32_t crVBoxServerCrCmdBltProcess(PVBOXCMDVBVA_HDR pCmd, uint32_t cbCmd)
if (u8Flags & VBOXCMDVBVA_OPF_ALLOC_DSTID)
{
/* TexPresent */
- texId = pBlt->alloc.id;
+ texId = pBlt->alloc.u.id;
}
else
{
- VBOXCMDVBVAOFFSET offVRAM = pBlt->alloc.offVRAM;
+ VBOXCMDVBVAOFFSET offVRAM = pBlt->alloc.u.offVRAM;
const VBVAINFOSCREEN *pScreen = CrFbGetScreenInfo(hFb);
uint32_t cbScreen = pScreen->u32LineSize * pScreen->u32Height;
if (offVRAM >= g_cbVRam
|| offVRAM + cbScreen >= g_cbVRam)
{
WARN(("invalid param"));
- pCmd->i8Result = -1;
+ pCmd->u.i8Result = -1;
return VINF_SUCCESS;
}
uint8_t *pu8Buf = g_pvVRamBase + offVRAM;
texId = 0;
+// cr_server.CrCmdClientInfo.pfnCltScrUpdateBegin(cr_server.CrCmdClientInfo.hCltScr);
/*todo: notify VGA device to perform updates */
}
@@ -4481,7 +4723,7 @@ int32_t crVBoxServerCrCmdBltProcess(PVBOXCMDVBVA_HDR pCmd, uint32_t cbCmd)
{
/* blit from one primary to another primary, wow */
WARN(("not implemented"));
- pCmd->i8Result = -1;
+ pCmd->u.i8Result = -1;
return VINF_SUCCESS;
}
}
@@ -4491,38 +4733,43 @@ int32_t crVBoxServerCrCmdBltProcess(PVBOXCMDVBVA_HDR pCmd, uint32_t cbCmd)
/* blit from primary to non-primary */
if (u8Flags & VBOXCMDVBVA_OPF_ALLOC_DSTID)
{
- uint32_t texId = pBlt->alloc.id;
+ uint32_t texId = pBlt->alloc.u.id;
WARN(("not implemented"));
- pCmd->i8Result = -1;
+ pCmd->u.i8Result = -1;
return VINF_SUCCESS;
}
else
{
- VBOXCMDVBVAOFFSET offVRAM = pBlt->alloc.offVRAM;
+ VBOXCMDVBVAOFFSET offVRAM = pBlt->alloc.u.offVRAM;
const VBVAINFOSCREEN *pScreen = CrFbGetScreenInfo(hFb);
uint32_t cbScreen = pScreen->u32LineSize * pScreen->u32Height;
if (offVRAM >= g_cbVRam
|| offVRAM + cbScreen >= g_cbVRam)
{
WARN(("invalid param"));
- pCmd->i8Result = -1;
+ pCmd->u.i8Result = -1;
return VINF_SUCCESS;
}
uint8_t *pu8Buf = g_pvVRamBase + offVRAM;
- RTRECT Rect;
- Rect.xLeft = pBlt->Pos.x;
- Rect.yTop = pBlt->Pos.y;
- Rect.xRight = Rect.xLeft + pScreen->u32Width;
- Rect.yBottom = Rect.yTop + pScreen->u32Height;
+ RTRECT SrcRect;
+ SrcRect.xLeft = 0;
+ SrcRect.yTop = 0;
+ SrcRect.xRight = pScreen->u32Width;
+ SrcRect.yBottom = pScreen->u32Height;
+ RTRECT DstRect;
+ DstRect.xLeft = pBlt->Pos.x;
+ DstRect.yTop = pBlt->Pos.y;
+ DstRect.xRight = DstRect.xLeft + pScreen->u32Width;
+ DstRect.yBottom = DstRect.yTop + pScreen->u32Height;
CR_BLITTER_IMG Img;
crFbImgFromScreenVram(pScreen, pu8Buf, &Img);
- int rc = CrFbBltGetContents(hFb, &Rect, cRects, pRects, &Img);
+ int rc = CrFbBltGetContents(hFb, &SrcRect, &DstRect, cRects, pRects, &Img);
if (!RT_SUCCESS(rc))
{
WARN(("CrFbBltGetContents failed %d", rc));
- pCmd->i8Result = -1;
+ pCmd->u.i8Result = -1;
return VINF_SUCCESS;
}
}
@@ -4531,10 +4778,10 @@ int32_t crVBoxServerCrCmdBltProcess(PVBOXCMDVBVA_HDR pCmd, uint32_t cbCmd)
else
{
WARN(("not implemented"));
- pCmd->i8Result = -1;
+ pCmd->u.i8Result = -1;
return VINF_SUCCESS;
}
- pCmd->i8Result = 0;
+ pCmd->u.i8Result = 0;
return VINF_SUCCESS;
}