Changeset 55747 in vbox for trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/server_presenter.cpp
- Timestamp:
- May 8, 2015 9:11:45 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/server_presenter.cpp
r53908 r55747 195 195 CR_TEXDATA *pEnteredTex = NULL; 196 196 PCR_BLITTER pEnteredBlitter = NULL; 197 uint32_t width = 0, height = 0;198 RTPOINT ScaledEntryPoint = {0};199 RTRECT ScaledSrcRect = {0};200 197 201 198 VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR Iter; … … 211 208 Assert(fScale); 212 209 210 /* 'List' contains the destination rectangles to be updated (in pDst coords). */ 213 211 VBoxVrListInit(&List); 214 int rc = VBoxVrListRectsAdd(&List, 1, CrVrScrCompositorRectGet(&hFb->Compositor), NULL);212 int rc = VBoxVrListRectsAdd(&List, cRects, pRects, NULL); 215 213 if (!RT_SUCCESS(rc)) 216 214 { … … 225 223 pEntry = CrVrScrCompositorConstIterNext(&Iter)) 226 224 { 225 /* Where the entry would be located in pDst coords, i.e. convert pEntry hFb coord to pDst coord. */ 226 RTPOINT ScaledEntryPoint; 227 ScaledEntryPoint.x = CR_FLOAT_RCAST(int32_t, strX * CrVrScrCompositorEntryRectGet(pEntry)->xLeft) + pDstRect->xLeft; 228 ScaledEntryPoint.y = CR_FLOAT_RCAST(int32_t, strY * CrVrScrCompositorEntryRectGet(pEntry)->yTop) + pDstRect->yTop; 229 230 /* Scaled texture size and rect. */ 231 uint32_t width = 0, height = 0; 232 RTRECT ScaledSrcRect = {0}; 233 234 CR_TEXDATA *pTex = CrVrScrCompositorEntryTexGet(pEntry); 235 236 /* Optimization to avoid entering/leaving the same texture and its blitter. */ 237 if (pEnteredTex != pTex) 238 { 239 if (!pEnteredBlitter) 240 { 241 pEnteredBlitter = CrTdBlitterGet(pTex); 242 rc = CrBltEnter(pEnteredBlitter); 243 if (!RT_SUCCESS(rc)) 244 { 245 WARN(("CrBltEnter failed %d", rc)); 246 pEnteredBlitter = NULL; 247 goto end; 248 } 249 } 250 251 if (pEnteredTex) 252 { 253 CrTdBltLeave(pEnteredTex); 254 255 pEnteredTex = NULL; 256 257 if (pEnteredBlitter != CrTdBlitterGet(pTex)) 258 { 259 WARN(("blitters not equal!")); 260 CrBltLeave(pEnteredBlitter); 261 262 pEnteredBlitter = CrTdBlitterGet(pTex); 263 rc = CrBltEnter(pEnteredBlitter); 264 if (!RT_SUCCESS(rc)) 265 { 266 WARN(("CrBltEnter failed %d", rc)); 267 pEnteredBlitter = NULL; 268 goto end; 269 } 270 } 271 } 272 273 rc = CrTdBltEnter(pTex); 274 if (!RT_SUCCESS(rc)) 275 { 276 WARN(("CrTdBltEnter failed %d", rc)); 277 goto end; 278 } 279 280 pEnteredTex = pTex; 281 282 const VBOXVR_TEXTURE *pVrTex = CrTdTexGet(pTex); 283 284 width = CR_FLOAT_RCAST(uint32_t, strX * pVrTex->width); 285 height = CR_FLOAT_RCAST(uint32_t, strY * pVrTex->height); 286 ScaledSrcRect.xLeft = ScaledEntryPoint.x; 287 ScaledSrcRect.yTop = ScaledEntryPoint.y; 288 ScaledSrcRect.xRight = width + ScaledEntryPoint.x; 289 ScaledSrcRect.yBottom = height + ScaledEntryPoint.y; 290 } 291 292 bool fInvert = !(CrVrScrCompositorEntryFlagsGet(pEntry) & CRBLT_F_INVERT_SRC_YCOORDS); 293 294 /* pRegions is where the pEntry was drawn in hFb coords. */ 227 295 uint32_t cRegions; 228 296 const RTRECT *pRegions; … … 234 302 } 235 303 236 rc = VBoxVrListRectsSubst(&List, cRegions, pRegions, NULL); 304 /* CrTdBltDataAcquireScaled/CrTdBltDataReleaseScaled can use cached data, 305 * so it is not necessary to optimize and Aquire only when Tex changes. 306 */ 307 const CR_BLITTER_IMG *pSrcImg; 308 rc = CrTdBltDataAcquireScaled(pTex, GL_BGRA, false, width, height, &pSrcImg); 237 309 if (!RT_SUCCESS(rc)) 238 310 { 239 WARN((" VBoxVrListRectsSubstfailed rc %d", rc));311 WARN(("CrTdBltDataAcquire failed rc %d", rc)); 240 312 goto end; 241 313 } … … 253 325 VBoxRectTranslate(&ScaledReg, pDstRect->xLeft, pDstRect->yTop); 254 326 327 /* Exclude the pEntry rectangle, because it will be updated now in pDst. 328 * List uses dst coords and pRegions use hFb coords, therefore use 329 * ScaledReg which is already translated to dst. 330 */ 331 rc = VBoxVrListRectsSubst(&List, 1, &ScaledReg, NULL); 332 if (!RT_SUCCESS(rc)) 333 { 334 WARN(("VBoxVrListRectsSubst failed rc %d", rc)); 335 goto end; 336 } 337 255 338 for (uint32_t i = 0; i < cRects; ++i) 256 339 { … … 262 345 continue; 263 346 264 CR_TEXDATA *pTex = CrVrScrCompositorEntryTexGet(pEntry);265 const CR_BLITTER_IMG *pSrcImg;266 267 if (pEnteredTex != pTex)268 {269 if (!pEnteredBlitter)270 {271 pEnteredBlitter = CrTdBlitterGet(pTex);272 rc = CrBltEnter(pEnteredBlitter);273 if (!RT_SUCCESS(rc))274 {275 WARN(("CrBltEnter failed %d", rc));276 pEnteredBlitter = NULL;277 goto end;278 }279 }280 281 if (pEnteredTex)282 {283 CrTdBltLeave(pEnteredTex);284 285 pEnteredTex = NULL;286 287 if (pEnteredBlitter != CrTdBlitterGet(pTex))288 {289 WARN(("blitters not equal!"));290 CrBltLeave(pEnteredBlitter);291 292 pEnteredBlitter = CrTdBlitterGet(pTex);293 rc = CrBltEnter(pEnteredBlitter);294 if (!RT_SUCCESS(rc))295 {296 WARN(("CrBltEnter failed %d", rc));297 pEnteredBlitter = NULL;298 goto end;299 }300 }301 }302 303 rc = CrTdBltEnter(pTex);304 if (!RT_SUCCESS(rc))305 {306 WARN(("CrTdBltEnter failed %d", rc));307 goto end;308 }309 310 pEnteredTex = pTex;311 312 const VBOXVR_TEXTURE *pVrTex = CrTdTexGet(pTex);313 314 width = CR_FLOAT_RCAST(uint32_t, strX * pVrTex->width);315 height = CR_FLOAT_RCAST(uint32_t, strY * pVrTex->height);316 ScaledEntryPoint.x = CR_FLOAT_RCAST(int32_t, strX * CrVrScrCompositorEntryRectGet(pEntry)->xLeft) + pDstRect->xLeft;317 ScaledEntryPoint.y = CR_FLOAT_RCAST(int32_t, strY * CrVrScrCompositorEntryRectGet(pEntry)->yTop) + pDstRect->yTop;318 ScaledSrcRect.xLeft = ScaledEntryPoint.x;319 ScaledSrcRect.yTop = ScaledEntryPoint.y;320 ScaledSrcRect.xRight = width + ScaledEntryPoint.x;321 ScaledSrcRect.yBottom = height + ScaledEntryPoint.y;322 }323 324 347 VBoxRectIntersect(&Intersection, &ScaledSrcRect); 325 348 if (VBoxRectIsZero(&Intersection)) 326 349 continue; 327 350 328 rc = CrTdBltDataAcquireScaled(pTex, GL_BGRA, false, width, height, &pSrcImg);329 if (!RT_SUCCESS(rc))330 {331 WARN(("CrTdBltDataAcquire failed rc %d", rc));332 goto end;333 }334 335 bool fInvert = !(CrVrScrCompositorEntryFlagsGet(pEntry) & CRBLT_F_INVERT_SRC_YCOORDS);336 337 351 CrMBltImgRect(pSrcImg, &ScaledEntryPoint, fInvert, &Intersection, pDst); 338 339 CrTdBltDataReleaseScaled(pTex, pSrcImg); 340 } 341 } 342 } 343 352 } 353 } 354 355 CrTdBltDataReleaseScaled(pTex, pSrcImg); 356 } 357 358 /* Blit still not updated dst rects, i.e. not covered by 3D entries. */ 344 359 c2DRects = VBoxVrListRectsCount(&List); 345 360 if (c2DRects) … … 370 385 } 371 386 372 const RTRECT *pCompRect = CrVrScrCompositorRectGet(&hFb->Compositor);387 /* p2DRects are in pDst coords and already scaled. */ 373 388 374 389 CR_BLITTER_IMG FbImg; 375 390 376 391 crFbImgFromFb(hFb, &FbImg); 377 378 for (uint32_t i = 0; i < c2DRects; ++i)379 {380 VBoxRectScale(&p2DRects[i], strX, strY);381 }382 392 383 393 CrMBltImgScaled(&FbImg, pSrcRectSize, pDstRect, c2DRects, p2DRects, pDst); … … 449 459 } 450 460 451 int CrFbBltGetContents(HCR_FRAMEBUFFER hFb, const RTPOINT *pPos, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pDst)461 static int CrFbBltGetContents(HCR_FRAMEBUFFER hFb, const RTPOINT *pPos, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pDst) 452 462 { 453 463 VBOXVR_LIST List; … … 455 465 CR_TEXDATA *pEnteredTex = NULL; 456 466 PCR_BLITTER pEnteredBlitter = NULL; 457 RTPOINT EntryPoint = {0}; 458 467 468 /* 'List' contains the destination rectangles to be updated (in pDst coords). */ 459 469 VBoxVrListInit(&List); 460 int rc = VBoxVrListRectsAdd(&List, 1, CrVrScrCompositorRectGet(&hFb->Compositor), NULL);470 int rc = VBoxVrListRectsAdd(&List, cRects, pRects, NULL); 461 471 if (!RT_SUCCESS(rc)) 462 472 { … … 472 482 pEntry = CrVrScrCompositorConstIterNext(&Iter)) 473 483 { 484 /* Where the entry would be located in pDst coords (pPos = pDst_coord - hFb_coord). */ 485 RTPOINT EntryPoint; 486 EntryPoint.x = CrVrScrCompositorEntryRectGet(pEntry)->xLeft + pPos->x; 487 EntryPoint.y = CrVrScrCompositorEntryRectGet(pEntry)->yTop + pPos->y; 488 489 CR_TEXDATA *pTex = CrVrScrCompositorEntryTexGet(pEntry); 490 491 /* Optimization to avoid entering/leaving the same texture and its blitter. */ 492 if (pEnteredTex != pTex) 493 { 494 if (!pEnteredBlitter) 495 { 496 pEnteredBlitter = CrTdBlitterGet(pTex); 497 rc = CrBltEnter(pEnteredBlitter); 498 if (!RT_SUCCESS(rc)) 499 { 500 WARN(("CrBltEnter failed %d", rc)); 501 pEnteredBlitter = NULL; 502 goto end; 503 } 504 } 505 506 if (pEnteredTex) 507 { 508 CrTdBltLeave(pEnteredTex); 509 510 pEnteredTex = NULL; 511 512 if (pEnteredBlitter != CrTdBlitterGet(pTex)) 513 { 514 WARN(("blitters not equal!")); 515 CrBltLeave(pEnteredBlitter); 516 517 pEnteredBlitter = CrTdBlitterGet(pTex); 518 rc = CrBltEnter(pEnteredBlitter); 519 if (!RT_SUCCESS(rc)) 520 { 521 WARN(("CrBltEnter failed %d", rc)); 522 pEnteredBlitter = NULL; 523 goto end; 524 } 525 } 526 } 527 528 rc = CrTdBltEnter(pTex); 529 if (!RT_SUCCESS(rc)) 530 { 531 WARN(("CrTdBltEnter failed %d", rc)); 532 goto end; 533 } 534 535 pEnteredTex = pTex; 536 } 537 538 bool fInvert = !(CrVrScrCompositorEntryFlagsGet(pEntry) & CRBLT_F_INVERT_SRC_YCOORDS); 539 540 /* pRegions is where the pEntry was drawn in hFb coords. */ 474 541 uint32_t cRegions; 475 542 const RTRECT *pRegions; … … 481 548 } 482 549 483 rc = VBoxVrListRectsSubst(&List, cRegions, pRegions, NULL); 550 /* CrTdBltDataAcquire/CrTdBltDataRelease can use cached data, 551 * so it is not necessary to optimize and Aquire only when Tex changes. 552 */ 553 const CR_BLITTER_IMG *pSrcImg; 554 rc = CrTdBltDataAcquire(pTex, GL_BGRA, false, &pSrcImg); 484 555 if (!RT_SUCCESS(rc)) 485 556 { 486 WARN((" VBoxVrListRectsSubstfailed rc %d", rc));557 WARN(("CrTdBltDataAcquire failed rc %d", rc)); 487 558 goto end; 488 559 } … … 498 569 VBoxRectTranslated(pReg, pPos->x, pPos->y, &SrcReg); 499 570 571 /* Exclude the pEntry rectangle, because it will be updated now in pDst. 572 * List uses dst coords and pRegions use hFb coords, therefore use 573 * SrcReg which is already translated to dst. 574 */ 575 rc = VBoxVrListRectsSubst(&List, 1, &SrcReg, NULL); 576 if (!RT_SUCCESS(rc)) 577 { 578 WARN(("VBoxVrListRectsSubst failed rc %d", rc)); 579 goto end; 580 } 581 500 582 for (uint32_t i = 0; i < cRects; ++i) 501 583 { … … 507 589 continue; 508 590 509 CR_TEXDATA *pTex = CrVrScrCompositorEntryTexGet(pEntry);510 const CR_BLITTER_IMG *pSrcImg;511 512 if (pEnteredTex != pTex)513 {514 if (!pEnteredBlitter)515 {516 pEnteredBlitter = CrTdBlitterGet(pTex);517 rc = CrBltEnter(pEnteredBlitter);518 if (!RT_SUCCESS(rc))519 {520 WARN(("CrBltEnter failed %d", rc));521 pEnteredBlitter = NULL;522 goto end;523 }524 }525 526 if (pEnteredTex)527 {528 CrTdBltLeave(pEnteredTex);529 530 pEnteredTex = NULL;531 532 if (pEnteredBlitter != CrTdBlitterGet(pTex))533 {534 WARN(("blitters not equal!"));535 CrBltLeave(pEnteredBlitter);536 537 pEnteredBlitter = CrTdBlitterGet(pTex);538 rc = CrBltEnter(pEnteredBlitter);539 if (!RT_SUCCESS(rc))540 {541 WARN(("CrBltEnter failed %d", rc));542 pEnteredBlitter = NULL;543 goto end;544 }545 }546 }547 548 rc = CrTdBltEnter(pTex);549 if (!RT_SUCCESS(rc))550 {551 WARN(("CrTdBltEnter failed %d", rc));552 goto end;553 }554 555 pEnteredTex = pTex;556 EntryPoint.x = CrVrScrCompositorEntryRectGet(pEntry)->xLeft + pPos->x;557 EntryPoint.y = CrVrScrCompositorEntryRectGet(pEntry)->yTop + pPos->y;558 }559 560 rc = CrTdBltDataAcquire(pTex, GL_BGRA, false, &pSrcImg);561 if (!RT_SUCCESS(rc))562 {563 WARN(("CrTdBltDataAcquire failed rc %d", rc));564 goto end;565 }566 567 bool fInvert = !(CrVrScrCompositorEntryFlagsGet(pEntry) & CRBLT_F_INVERT_SRC_YCOORDS);568 569 591 CrMBltImgRect(pSrcImg, &EntryPoint, fInvert, &Intersection, pDst); 570 571 CrTdBltDataRelease(pTex); 572 } 573 } 574 } 575 592 } 593 } 594 595 CrTdBltDataRelease(pTex); 596 } 597 598 /* Blit still not updated dst rects, i.e. not covered by 3D entries. */ 576 599 c2DRects = VBoxVrListRectsCount(&List); 577 600 if (c2DRects) … … 601 624 goto end; 602 625 } 603 604 const RTRECT *pCompRect = CrVrScrCompositorRectGet(&hFb->Compositor);605 626 606 627 CR_BLITTER_IMG FbImg;
Note:
See TracChangeset
for help on using the changeset viewer.