Changeset 43932 in vbox for trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp
- Timestamp:
- Nov 21, 2012 7:28:05 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 82253
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp
r43891 r43932 32 32 #include <iprt/mem.h> 33 33 34 typedef DECLCALLBACK(int) FNCRDISPLAY_REGIONS_CHANGED(struct CR_PRESENTER *pPresenter);35 typedef FNCRDISPLAY_REGIONS_CHANGED *PFNCRDISPLAY_REGIONS_CHANGED;36 37 typedef DECLCALLBACK(int) FNCRDISPLAY_DRAW_ENTRY(struct CR_PRESENTER *pPresenter, struct CR_PRESENTER_ENTRY *pEntry, PCR_BLITTER pBlitter);38 typedef FNCRDISPLAY_DRAW_ENTRY *PFNCRDISPLAY_DRAW_ENTRY;39 40 typedef DECLCALLBACK(int) FNCRDISPLAY_DRAW_TEXTURE(struct CR_PRESENTER *pPresenter, PCR_BLITTER pBlitter,41 CR_BLITTER_TEXTURE *pTexture, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects);42 typedef FNCRDISPLAY_DRAW_TEXTURE *PFNCRDISPLAY_DRAW_TEXTURE;43 44 45 34 #define CR_DISPLAY_RECTS_UNDEFINED UINT32_MAX 46 35 … … 212 201 } 213 202 214 DECLCALLBACK(int) CrPtCbDrawEntrySingle(struct CR_PRESENTER *pPresenter, struct CR_PRESENTER_ENTRY *pEntry, PCR_BLITTER pBlitter) 215 { 203 DECLCALLBACK(int) CrPtCbDrawEntrySingle(struct CR_PRESENTER *pPresenter, struct CR_PRESENTER_ENTRY *pEntry, PCR_BLITTER pBlitter, bool *pfAllEntriesDrawn) 204 { 205 if (pfAllEntriesDrawn) 206 *pfAllEntriesDrawn = false; 207 216 208 int rc = crPtRectsCheckInit(pPresenter); 217 209 if (!RT_SUCCESS(rc)) … … 241 233 struct CR_PRESENTER_ENTRY *pEntry = CR_PRESENTER_ENTRY_FROM_ENTRY(pCEntry); 242 234 PCR_BLITTER pBlitter = (PCR_BLITTER)pvVisitor; 243 int rc = CrPtCbDrawEntrySingle(pPresenter, pEntry, pBlitter); 235 bool fAllEntriesDrawn; 236 int rc = CrPtCbDrawEntrySingle(pPresenter, pEntry, pBlitter, &fAllEntriesDrawn); 244 237 if (!RT_SUCCESS(rc)) 245 238 { 246 239 crWarning("CrPtCbDrawEntrySingle failed, rc %d", rc); 247 240 } 248 return true;249 } 250 251 DECLCALLBACK(int) CrPtCbDrawEntryAll(struct CR_PRESENTER *pPresenter, struct CR_PRESENTER_ENTRY *pEntry, PCR_BLITTER pBlitter )241 return !fAllEntriesDrawn; 242 } 243 244 DECLCALLBACK(int) CrPtCbDrawEntryAll(struct CR_PRESENTER *pPresenter, struct CR_PRESENTER_ENTRY *pEntry, PCR_BLITTER pBlitter, bool *pfAllEntriesDrawn) 252 245 { 253 246 int rc = crPtRectsCheckInit(pPresenter); … … 258 251 } 259 252 260 VBoxVrCompositorVisit(&pPresenter->Compositor, crPtDrawEntryAllCb, pPresenter); 253 VBoxVrCompositorVisit(&pPresenter->Compositor, crPtDrawEntryAllCb, pBlitter); 254 255 if (pfAllEntriesDrawn) 256 *pfAllEntriesDrawn = true; 261 257 262 258 return VINF_SUCCESS; … … 289 285 } 290 286 287 static int crPtEntryRegionsSet(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged) 288 { 289 bool fChanged; 290 int rc = VBoxVrCompositorEntryRegionsSet(&pPresenter->Compositor, &pEntry->Ce, cRegions, paRegions, &fChanged); 291 if (!RT_SUCCESS(rc)) 292 { 293 crWarning("VBoxVrCompositorEntryRegionsSet failed, rc %d", rc); 294 return rc; 295 } 296 297 if (fChanged) 298 { 299 crPtRectsInvalidate(pPresenter); 300 rc = pPresenter->pfnRegionsChanged(pPresenter); 301 if (!RT_SUCCESS(rc)) 302 { 303 crWarning("pfnRegionsChanged failed, rc %d", rc); 304 return rc; 305 } 306 } 307 308 if (pfChanged) 309 *pfChanged = fChanged; 310 return VINF_SUCCESS; 311 } 312 291 313 static void crPtEntryPositionSet(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, const RTPOINT *pPos) 292 314 { 293 if (pEntry && pEntry->Pos.x != pPos->x || pEntry->Pos.y != pPos->y) 294 { 295 VBoxVrCompositorEntryRemove(&pPresenter->Compositor, &pEntry->Ce); 296 crPtRectsInvalidate(pPresenter); 315 if (pEntry && (pEntry->Pos.x != pPos->x || pEntry->Pos.y != pPos->y)) 316 { 317 if (VBoxVrCompositorEntryIsInList(&pEntry->Ce)) 318 { 319 VBoxVrCompositorEntryRemove(&pPresenter->Compositor, &pEntry->Ce); 320 crPtRectsInvalidate(pPresenter); 321 } 297 322 pEntry->Pos = *pPos; 298 323 } 299 324 } 300 325 301 int CrPtEntryPresent(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions, PCR_BLITTER pBlitter) 326 int CrPtPresentEntry(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, PCR_BLITTER pBlitter) 327 { 328 int rc = CrBltEnter(pBlitter, cr_server.currentCtxInfo, cr_server.currentMural); 329 if (!RT_SUCCESS(rc)) 330 { 331 crWarning("CrBltEnter failed, rc %d", rc); 332 return rc; 333 } 334 335 rc = pPresenter->pfnDrawEntry(pPresenter, pEntry, pBlitter, NULL); 336 337 CrBltLeave(pBlitter); 338 339 if (!RT_SUCCESS(rc)) 340 { 341 crWarning("pfnDraw failed, rc %d", rc); 342 return rc; 343 } 344 345 return VINF_SUCCESS; 346 } 347 348 static DECLCALLBACK(bool) crPtPresentCb(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pCEntry, void *pvVisitor) 349 { 350 struct CR_PRESENTER *pPresenter = CR_PRESENTER_FROM_COMPOSITOR(pCompositor); 351 struct CR_PRESENTER_ENTRY *pEntry = CR_PRESENTER_ENTRY_FROM_ENTRY(pCEntry); 352 PCR_BLITTER pBlitter = (PCR_BLITTER)pvVisitor; 353 bool fAllDrawn = false; 354 int rc = pPresenter->pfnDrawEntry(pPresenter, pEntry, pBlitter, &fAllDrawn); 355 if (!RT_SUCCESS(rc)) 356 { 357 crWarning("pfnDrawEntry failed, rc %d", rc); 358 } 359 return !fAllDrawn; 360 } 361 362 int CrPtPresent(PCR_PRESENTER pPresenter, PCR_BLITTER pBlitter) 363 { 364 int rc = CrBltEnter(pBlitter, cr_server.currentCtxInfo, cr_server.currentMural); 365 if (!RT_SUCCESS(rc)) 366 { 367 crWarning("CrBltEnter failed, rc %d", rc); 368 return rc; 369 } 370 371 VBoxVrCompositorVisit(&pPresenter->Compositor, crPtPresentCb, pBlitter); 372 373 CrBltLeave(pBlitter); 374 375 if (!RT_SUCCESS(rc)) 376 { 377 crWarning("pfnDraw failed, rc %d", rc); 378 return rc; 379 } 380 381 return VINF_SUCCESS; 382 } 383 384 int CrPtEntryRegionsAdd(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions) 302 385 { 303 386 crPtEntryPositionSet(pPresenter, pEntry, pPos); … … 310 393 } 311 394 312 if (!pEntry) 313 return VINF_SUCCESS; 314 315 rc = CrBltEnter(pBlitter, cr_server.currentCtxInfo, cr_server.currentMural); 316 if (!RT_SUCCESS(rc)) 317 { 318 crWarning("CrBltEnter failed, rc %d", rc); 319 return rc; 320 } 321 322 rc = pPresenter->pfnDrawEntry(pPresenter, pEntry, pBlitter); 323 324 CrBltLeave(pBlitter); 325 326 if (!RT_SUCCESS(rc)) 327 { 328 crWarning("pfnDrawEntry failed, rc %d", rc); 329 return rc; 330 } 395 return VINF_SUCCESS; 396 } 397 398 int CrPtEntryRegionsSet(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions) 399 { 400 crPtEntryPositionSet(pPresenter, pEntry, pPos); 401 402 int rc = crPtEntryRegionsSet(pPresenter, pEntry, cRegions, paRegions, NULL); 403 if (!RT_SUCCESS(rc)) 404 { 405 crWarning("crPtEntryRegionsAdd failed, rc %d", rc); 406 return rc; 407 } 408 331 409 return VINF_SUCCESS; 332 410 } … … 429 507 int CrDpInit(PCR_DISPLAY pDisplay) 430 508 { 431 const GLint visBits = CR_RGB_BIT ;432 int rc = CrPtInit(&pDisplay->Presenter, crDpCbRegionsChanged, CrPtCbDrawEntry Single, crDpCbDrawTextureWindow);509 const GLint visBits = CR_RGB_BIT | CR_DOUBLE_BIT; 510 int rc = CrPtInit(&pDisplay->Presenter, crDpCbRegionsChanged, CrPtCbDrawEntryAll, crDpCbDrawTextureWindow); 433 511 if (RT_SUCCESS(rc)) 434 512 { … … 455 533 } 456 534 457 bool CrDpBlitterTest(PCR_DISPLAY pDisplay, PCR_BLITTER pBlitter)458 { 459 CrBltMuralSetCurrent(pBlitter, &pDisplay->Mural);535 int CrDpBlitterTestWithMural(PCR_BLITTER pBlitter, CRMuralInfo *pMural) 536 { 537 CrBltMuralSetCurrent(pBlitter, pMural); 460 538 /* try to enter to make sure the blitter is initialized completely and to make sure we actually can do that */ 461 539 int rc = CrBltEnter(pBlitter, cr_server.currentCtxInfo, cr_server.currentMural); … … 463 541 { 464 542 CrBltLeave(pBlitter); 465 return true;543 return VINF_SUCCESS; 466 544 } 467 545 else … … 469 547 crWarning("CrBltEnter failed, rc %d", rc); 470 548 } 471 return false; 549 return rc; 550 } 551 552 int CrDpBlitterTest(PCR_DISPLAY pDisplay, PCR_BLITTER pBlitter) 553 { 554 return CrDpBlitterTestWithMural(pBlitter, &pDisplay->Mural); 472 555 } 473 556 … … 482 565 } 483 566 484 int CrDpPresentTexture(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions) 485 { 486 return CrPtEntryPresent(&pDisplay->Presenter, &pEntry->Pe, pPos, cRegions, paRegions, pDisplay->pBlitter); 567 int CrDpEntryRegionsSet(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions) 568 { 569 return CrPtEntryRegionsSet(&pDisplay->Presenter, &pEntry->Pe, pPos, cRegions, paRegions); 570 } 571 572 int CrDpEntryRegionsAdd(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions) 573 { 574 return CrPtEntryRegionsAdd(&pDisplay->Presenter, &pEntry->Pe, pPos, cRegions, paRegions); 575 } 576 577 int CrDpPresentEntry(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry) 578 { 579 return CrPtPresentEntry(&pDisplay->Presenter, &pEntry->Pe, pDisplay->pBlitter); 487 580 } 488 581 … … 582 675 #define CR_PRESENT_GET_FLAGS(_cfg) ((_cfg) >> CR_PRESENT_FLAGS_OFFSET) 583 676 584 static uint8_t crServerCheckInitDisplayBlitter() 677 int crServerBlitterInit(PCR_BLITTER pBlitter, CRMuralInfo*pMural) 678 { 679 int rc = CrBltInit(pBlitter, pMural); 680 if (RT_SUCCESS(rc)) 681 { 682 rc = CrDpBlitterTestWithMural(pBlitter, pMural); 683 if (RT_SUCCESS(rc)) 684 return VINF_SUCCESS; 685 else 686 crWarning("CrDpBlitterTestWithMural failed, rc %d", rc); 687 CrBltTerm(pBlitter); 688 } 689 else 690 crWarning("CrBltInit failed, rc %d", rc); 691 return rc; 692 } 693 694 PCR_BLITTER crServerGetFBOPresentBlitter(CRMuralInfo*pMural) 695 { 696 if (cr_server.fFBOModeBlitterInited > 0) 697 return &cr_server.FBOModeBlitter; 698 if (!cr_server.fFBOModeBlitterInited) 699 { 700 int rc = crServerBlitterInit(&cr_server.FBOModeBlitter, pMural); 701 if (RT_SUCCESS(rc)) 702 { 703 cr_server.fFBOModeBlitterInited = 1; 704 return &cr_server.FBOModeBlitter; 705 } 706 crWarning("crServerBlitterInit failed rc %d", rc); 707 cr_server.fFBOModeBlitterInited = -1; 708 } 709 return NULL; 710 } 711 712 static int8_t crServerCheckInitDisplayBlitter() 585 713 { 586 714 if (cr_server.fPresentBlitterInited) … … 597 725 { 598 726 CRMuralInfo*pMural = CrDpGetMural(&cr_server.aDispplays[0]); 599 CRCreateInfo_t*pCreateInfo = CrDpGetMuralCreateInfo(&cr_server.aDispplays[0]); 600 rc = CrBltInit(&cr_server.PresentBlitter, pMural, pCreateInfo->visualBits); 727 rc = crServerBlitterInit(&cr_server.PresentBlitter, pMural); 601 728 if (RT_SUCCESS(rc)) 602 729 { 603 if (CrDpBlitterTest(&cr_server.aDispplays[0], &cr_server.PresentBlitter)) 604 { 605 CrDpBlitterSet(&cr_server.aDispplays[0], &cr_server.PresentBlitter); 606 ASMBitSet(cr_server.DisplaysInitMap, 0); 607 cr_server.fPresentBlitterInited = 1; 608 return 1; 609 } 610 else 611 { 612 crWarning("CrDpBlitterTest failed"); 613 } 614 CrBltTerm(&cr_server.PresentBlitter); 730 CrDpBlitterSet(&cr_server.aDispplays[0], &cr_server.PresentBlitter); 731 CrDpResize(&cr_server.aDispplays[0], 732 cr_server.screen[0].w, cr_server.screen[0].h, 733 cr_server.screen[0].w, cr_server.screen[0].h); 734 ASMBitSet(cr_server.DisplaysInitMap, 0); 735 cr_server.fPresentBlitterInited = 1; 736 return 1; 615 737 } 616 738 else 617 739 { 618 crWarning(" CrBltInit failed, rc %d", rc);740 crWarning("crServerBlitterInit failed, rc %d", rc); 619 741 } 620 742 CrDpTerm(&cr_server.aDispplays[0]); … … 638 760 { 639 761 return crServerCheckInitDisplayBlitter() > 0; 762 } 763 764 PCR_DISPLAY crServerDisplayGetInitialized(uint32_t idScreen) 765 { 766 if (ASMBitTest(cr_server.DisplaysInitMap, idScreen)) 767 return &cr_server.aDispplays[idScreen]; 768 return NULL; 640 769 } 641 770 … … 662 791 { 663 792 CrDpBlitterSet(&cr_server.aDispplays[idScreen], &cr_server.PresentBlitter); 793 CrDpResize(&cr_server.aDispplays[idScreen], 794 cr_server.screen[idScreen].w, cr_server.screen[idScreen].h, 795 cr_server.screen[idScreen].w, cr_server.screen[idScreen].h); 664 796 ASMBitSet(cr_server.DisplaysInitMap, idScreen); 665 797 return &cr_server.aDispplays[idScreen]; … … 697 829 698 830 RTPOINT Point = {xPos, yPos}; 699 int rc = CrDpPresentTexture(pDisplay, pEntry, &Point, (uint32_t)cRects, (const RTRECT*)pRects); 700 if (!RT_SUCCESS(rc)) 701 { 702 crWarning("CrDpPresentTexture Failed rc %d", rc); 703 } 704 } 831 int rc = CrDpEntryRegionsAdd(pDisplay, pEntry, &Point, (uint32_t)cRects, (const RTRECT*)pRects); 832 if (!RT_SUCCESS(rc)) 833 { 834 crWarning("CrDpEntrySetRegions Failed rc %d", rc); 835 return; 836 } 837 838 rc = CrDpPresentEntry(pDisplay, pEntry); 839 if (!RT_SUCCESS(rc)) 840 { 841 crWarning("CrDpEntrySetRegions Failed rc %d", rc); 842 return; 843 } 844 }
Note:
See TracChangeset
for help on using the changeset viewer.