- Timestamp:
- Feb 7, 2014 9:59:02 PM (11 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/include/cr_vreg.h
r50316 r50371 49 49 50 50 #ifndef IN_RING0 51 #define CR_FLOAT_RCAST(_t, _v) ((_t)((float)(_v) + 0.5)) 52 51 53 DECLINLINE(void) VBoxRectStretch(PRTRECT pRect, float xStretch, float yStretch) 52 54 { 53 pRect->xLeft = (int32_t)(pRect->xLeft * xStretch);54 pRect->yTop = (int32_t)(pRect->yTop * yStretch);55 pRect->xRight = (int32_t)(pRect->xRight * xStretch);56 pRect->yBottom = (int32_t)(pRect->yBottom * yStretch);55 pRect->xLeft = CR_FLOAT_RCAST(int32_t, pRect->xLeft * xStretch); 56 pRect->yTop = CR_FLOAT_RCAST(int32_t, pRect->yTop * yStretch); 57 pRect->xRight = CR_FLOAT_RCAST(int32_t, pRect->xRight * xStretch); 58 pRect->yBottom = CR_FLOAT_RCAST(int32_t, pRect->yBottom * yStretch); 57 59 } 58 60 -
trunk/src/VBox/GuestHost/OpenGL/util/bmpscale.cpp
r50365 r50371 61 61 } 62 62 63 DECLINLINE(void) gdImageSetPixel (gdImagePtr im, int x, int y, int color, int w)63 DECLINLINE(void) gdImageSetPixel (gdImagePtr im, int x, int y, int color, int cbLine) 64 64 { 65 *(int32_t *)(im + y * w * 4+ x * 4) = color;65 *(int32_t *)(im + y * cbLine + x * 4) = color; 66 66 } 67 67 … … 190 190 gdTrueColorAlpha ((int) red, 191 191 (int) green, 192 (int) blue, (int) alpha), dstW );192 (int) blue, (int) alpha), dstW * 4); 193 193 } 194 194 } -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp
r50364 r50371 241 241 } 242 242 243 static void crFbBltImg(void *pvSrc, const RTRECT *pSrcDataRect, bool fSrcInvert, const RTRECT *pCopyRect, const RTPOINT *pDstDataPoint, CR_BLITTER_IMG *pDst) 244 { 245 int32_t cbSrcPitch = (pSrcDataRect->xRight - pSrcDataRect->xLeft) * 4; 246 int32_t srcX = pCopyRect->xLeft - pSrcDataRect->xLeft; 247 int32_t srcY = pCopyRect->yTop - pSrcDataRect->yTop; 243 static void crFbBltImg(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcDataPoint, bool fSrcInvert, const RTRECT *pCopyRect, const RTPOINT *pDstDataPoint, CR_BLITTER_IMG *pDst) 244 { 245 int32_t srcX = pCopyRect->xLeft - pSrcDataPoint->x; 246 int32_t srcY = pCopyRect->yTop - pSrcDataPoint->y; 248 247 Assert(srcX >= 0); 249 248 Assert(srcY >= 0); 250 Assert(srcX < pSrcDataRect->xRight - pSrcDataRect->xLeft); 251 Assert(srcY < pSrcDataRect->yBottom - pSrcDataRect->yTop); 252 253 uint32_t cbDstPitch = pDst->pitch; 249 Assert(srcX < pSrc->width); 250 Assert(srcY < pSrc->height); 251 254 252 int32_t dstX = pCopyRect->xLeft - pDstDataPoint->x; 255 253 int32_t dstY = pCopyRect->yTop - pDstDataPoint->y; … … 257 255 Assert(dstY >= 0); 258 256 259 uint8_t *pu8Src = ((uint8_t*)pvSrc) + cbSrcPitch * (!fSrcInvert ? srcY : pSrcDataRect->yBottom - pSrcDataRect->yTop - srcY - 1) + srcX * 4; 260 uint8_t *pu8Dst = ((uint8_t*)pDst->pvData) + cbDstPitch * dstY + dstX * 4; 261 if (fSrcInvert) 262 cbSrcPitch = -cbSrcPitch; 263 264 crFbBltMem(pu8Src, cbSrcPitch, pu8Dst, cbDstPitch, pCopyRect->xRight - pCopyRect->xLeft, pCopyRect->yBottom - pCopyRect->yTop); 265 } 266 267 static void crFbBltImgStretched(void *pvSrc, const RTRECT *pSrcDataRect, bool fSrcInvert, const RTRECT *pCopyRect, const RTPOINT *pDstDataPoint, float strX, float strY, CR_BLITTER_IMG *pDst) 268 { 269 int32_t cbSrcPitch = (pSrcDataRect->xRight - pSrcDataRect->xLeft) * 4; 270 int32_t srcX = pCopyRect->xLeft - pSrcDataRect->xLeft; 271 int32_t srcY = pCopyRect->yTop - pSrcDataRect->yTop; 257 uint8_t *pu8Src = ((uint8_t*)pSrc->pvData) + pSrc->pitch * (!fSrcInvert ? srcY : pSrc->height - srcY - 1) + srcX * 4; 258 uint8_t *pu8Dst = ((uint8_t*)pDst->pvData) + pDst->pitch * dstY + dstX * 4; 259 260 crFbBltMem(pu8Src, fSrcInvert ? -pSrc->pitch : pSrc->pitch, pu8Dst, pDst->pitch, pCopyRect->xRight - pCopyRect->xLeft, pCopyRect->yBottom - pCopyRect->yTop); 261 } 262 263 static void crFbBltImgStretched(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcDataPoint, bool fSrcInvert, const RTRECT *pCopyRect, const RTPOINT *pDstDataPoint, float strX, float strY, CR_BLITTER_IMG *pDst) 264 { 265 int32_t srcX = pCopyRect->xLeft - pSrcDataPoint->x; 266 int32_t srcY = pCopyRect->yTop - pSrcDataPoint->y; 272 267 Assert(srcX >= 0); 273 268 Assert(srcY >= 0); 274 Assert(srcX < pSrcDataRect->xRight - pSrcDataRect->xLeft); 275 Assert(srcY < pSrcDataRect->yBottom - pSrcDataRect->yTop); 276 277 int32_t cbDstPitch = (int32_t)pDst->pitch; 278 int32_t dstX = static_cast<uint32_t>(strX * pCopyRect->xLeft - pDstDataPoint->x); 279 int32_t dstY = static_cast<uint32_t>(strY * pCopyRect->yTop - pDstDataPoint->y); 269 Assert(srcX < pSrc->width); 270 Assert(srcY < pSrc->height); 271 272 int32_t dstX = CR_FLOAT_RCAST(int32_t, strX * (pCopyRect->xLeft - pDstDataPoint->x)); 273 int32_t dstY = CR_FLOAT_RCAST(int32_t, strY * (pCopyRect->yTop - pDstDataPoint->y)); 280 274 Assert(dstX >= 0); 281 275 Assert(dstY >= 0); 282 276 283 uint8_t *pu8Src = ((uint8_t*)pvSrc) + cbSrcPitch * (!fSrcInvert ? srcY : pSrcDataRect->yBottom - pSrcDataRect->yTop - srcY - 1) + srcX * 4; 284 uint8_t *pu8Dst = ((uint8_t*)pDst->pvData) + cbDstPitch * dstY + dstX * 4; 285 if (fSrcInvert) 286 cbSrcPitch = -cbSrcPitch; 287 288 int srcW = pCopyRect->xRight - pCopyRect->xLeft; 289 int srcH = pCopyRect->yBottom - pCopyRect->yTop; 290 int dstW = static_cast<uint32_t>(strX * srcW); 291 int dstH = static_cast<uint32_t>(strY * srcH); 292 293 CrBmpScale32(pu8Dst, cbDstPitch, 294 dstW, dstH, 295 pu8Src, 296 cbSrcPitch, 297 srcW, srcH); 298 } 299 277 uint8_t *pu8Src = ((uint8_t*)pSrc->pvData) + pSrc->pitch * (!fSrcInvert ? srcY : pSrc->height - srcY - 1) + srcX * 4; 278 uint8_t *pu8Dst = ((uint8_t*)pDst->pvData) + pDst->pitch * dstY + dstX * 4; 279 280 CrBmpScale32(pu8Dst, pDst->pitch, 281 CR_FLOAT_RCAST(int32_t, strX * pCopyRect->xRight - pCopyRect->xLeft), 282 CR_FLOAT_RCAST(int32_t, strY * pCopyRect->yBottom - pCopyRect->yTop), 283 pu8Src, 284 fSrcInvert ? -pSrc->pitch : pSrc->pitch, 285 pCopyRect->xRight - pCopyRect->xLeft, pCopyRect->yBottom - pCopyRect->yTop); 286 } 287 288 static void crFbImgFromScreenVram(const VBVAINFOSCREEN *pScreen, void *pvVram, CR_BLITTER_IMG *pImg) 289 { 290 pImg->pvData = pvVram; 291 pImg->cbData = pScreen->u32LineSize * pScreen->u32Height; 292 pImg->enmFormat = GL_BGRA; 293 pImg->width = pScreen->u32Width; 294 pImg->height = pScreen->u32Height; 295 pImg->bpp = pScreen->u16BitsPerPixel; 296 pImg->pitch = pScreen->u32LineSize; 297 } 298 299 static void crFbImgFromFb(HCR_FRAMEBUFFER hFb, CR_BLITTER_IMG *pImg) 300 { 301 const VBVAINFOSCREEN *pScreen = CrFbGetScreenInfo(hFb); 302 void *pvVram = CrFbGetVRAM(hFb); 303 crFbImgFromScreenVram(pScreen, pvVram, pImg); 304 } 300 305 301 306 static int crFbBltGetContentsDirect(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg) … … 311 316 float strY = ((float)pImg->height) / (pSrcRect->yBottom - pSrcRect->yTop); 312 317 318 RTPOINT StretchedSrcPoint; 319 StretchedSrcPoint.x = CR_FLOAT_RCAST(int32_t, strX * SrcPoint.x); 320 StretchedSrcPoint.y = CR_FLOAT_RCAST(int32_t, strY * SrcPoint.y); 321 322 RTPOINT ZeroPoint = {0, 0}; 323 313 324 VBoxVrListInit(&List); 314 325 int rc = VBoxVrListRectsAdd(&List, 1, CrVrScrCompositorRectGet(&hFb->Compositor), NULL); … … 342 353 343 354 uint32_t width, height; 344 RT RECT SrcRect;355 RTPOINT StretchedEntryPoint; 345 356 346 357 for (uint32_t i = 0; i < cRects; ++i) … … 409 420 const VBOXVR_TEXTURE *pVrTex = CrTdTexGet(pTex); 410 421 411 width = static_cast<uint32_t>(strX * pVrTex->width); 412 height = static_cast<uint32_t>(strY * pVrTex->height); 413 VBoxRectStretched(CrVrScrCompositorEntryRectGet(pEntry), strX, strY, &SrcRect); 422 width = CR_FLOAT_RCAST(uint32_t, strX * pVrTex->width); 423 height = CR_FLOAT_RCAST(uint32_t, strY * pVrTex->height); 424 StretchedEntryPoint.x = CR_FLOAT_RCAST(int32_t, strX * CrVrScrCompositorEntryRectGet(pEntry)->xLeft); 425 StretchedEntryPoint.y = CR_FLOAT_RCAST(int32_t, strY * CrVrScrCompositorEntryRectGet(pEntry)->yTop); 414 426 } 415 427 … … 423 435 bool fInvert = !(CrVrScrCompositorEntryFlagsGet(pEntry) & CRBLT_F_INVERT_SRC_YCOORDS); 424 436 425 crFbBltImg(pSrcImg ->pvData, &SrcRect, fInvert, &Intersection, &SrcPoint, pImg);437 crFbBltImg(pSrcImg, &StretchedEntryPoint, fInvert, &Intersection, &StretchedSrcPoint, pImg); 426 438 427 439 CrTdBltDataReleaseStretched(pTex, pSrcImg); … … 460 472 RTPOINT Pos = {0}; 461 473 const RTRECT *pCompRect = CrVrScrCompositorRectGet(&hFb->Compositor); 462 uint32_t fbPitch = (pCompRect->xRight - pCompRect->xLeft) * 4; 474 475 uint32_t fbWidth = (pCompRect->xRight - pCompRect->xLeft); 463 476 uint32_t fbHeight = pCompRect->yBottom - pCompRect->yTop; 464 477 465 uint32_t dstPitch = static_cast<uint32_t>(strX * fbPitch); 466 uint32_t dstHeight = static_cast<uint32_t>(strY * fbHeight); 467 468 bool fStretch = fbPitch != dstPitch || fbHeight != dstHeight; 478 uint32_t stretchedWidth = CR_FLOAT_RCAST(uint32_t, strX * fbWidth); 479 uint32_t stretchedHeight = CR_FLOAT_RCAST(uint32_t, strY * fbHeight); 480 481 CR_BLITTER_IMG FbImg; 482 483 bool fStretch = fbWidth != stretchedWidth || fbHeight != stretchedHeight; 484 485 crFbImgFromFb(hFb, &FbImg); 469 486 470 487 for (uint32_t i = 0; i < cRects; ++i) … … 480 497 481 498 if (!fStretch) 482 crFbBltImg( hFb->pvVram, pCompRect, false, &Intersection, &SrcPoint, pImg);499 crFbBltImg(&FbImg, &ZeroPoint, false, &Intersection, &SrcPoint, pImg); 483 500 else 484 crFbBltImgStretched( hFb->pvVram, pCompRect, false, &Intersection, &SrcPoint, strX, strY, pImg);501 crFbBltImgStretched(&FbImg, &ZeroPoint, false, &Intersection, &SrcPoint, strX, strY, pImg); 485 502 } 486 503 } … … 4427 4444 Rect.yBottom = Rect.yTop + pScreen->u32Height; 4428 4445 CR_BLITTER_IMG Img; 4429 Img.pvData = pu8Buf; 4430 Img.cbData = pScreen->u32LineSize * pScreen->u32Height; 4431 Img.enmFormat = GL_BGRA; 4432 Img.width = pScreen->u32Width; 4433 Img.height = pScreen->u32Height; 4434 Img.bpp = pScreen->u16BitsPerPixel; 4435 Img.pitch = pScreen->u32LineSize; 4446 crFbImgFromScreenVram(pScreen, pu8Buf, &Img); 4436 4447 int rc = CrFbBltGetContents(hFb, &Rect, cRects, pRects, &Img); 4437 4448 if (!RT_SUCCESS(rc))
Note:
See TracChangeset
for help on using the changeset viewer.