Changeset 46343 in vbox for trunk/src/VBox/GuestHost/OpenGL/util/blitter.cpp
- Timestamp:
- May 31, 2013 1:27:10 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/util/blitter.cpp
r46085 r46343 88 88 if (pBlitter->Flags.CtxCreated) 89 89 pBlitter->pDispatch->DestroyContext(pBlitter->CtxInfo.Base.id); 90 memset(pBlitter, 0, sizeof (pBlitter)); 90 91 } 91 92 … … 515 516 void CrBltLeave(PCR_BLITTER pBlitter) 516 517 { 517 Assert(CrBltIsEntered(pBlitter)); 518 if (!CrBltIsEntered(pBlitter)) 519 { 520 crWarning("CrBltLeave: blitter not entered"); 521 return; 522 } 518 523 519 524 if (pBlitter->Flags.SupportsFBO) … … 610 615 } 611 616 612 void CrBltBlitTexMural(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags) 613 { 617 void CrBltBlitTexMural(PCR_BLITTER pBlitter, bool fBb, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags) 618 { 619 if (!CrBltIsEntered(pBlitter)) 620 { 621 crWarning("CrBltBlitTexMural: blitter not entered"); 622 return; 623 } 624 614 625 RTRECTSIZE DstSize = {pBlitter->CurrentMural.width, pBlitter->CurrentMural.height}; 615 626 616 627 pBlitter->pDispatch->BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0); 617 628 618 crBltBlitTexBuf(pBlitter, pSrc, paSrcRects, GL_BACK, &DstSize, paDstRects, cRects, fFlags);629 crBltBlitTexBuf(pBlitter, pSrc, paSrcRects, fBb ? GL_BACK : GL_FRONT, &DstSize, paDstRects, cRects, fFlags); 619 630 } 620 631 621 632 void CrBltBlitTexTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *pSrcRect, const VBOXVR_TEXTURE *pDst, const RTRECT *pDstRect, uint32_t cRects, uint32_t fFlags) 622 633 { 634 if (!CrBltIsEntered(pBlitter)) 635 { 636 crWarning("CrBltBlitTexTex: blitter not entered"); 637 return; 638 } 639 623 640 RTRECTSIZE DstSize = {(uint32_t)pDst->width, (uint32_t)pDst->height}; 624 641 … … 639 656 void CrBltPresent(PCR_BLITTER pBlitter) 640 657 { 658 if (!CrBltIsEntered(pBlitter)) 659 { 660 crWarning("CrBltPresent: blitter not entered"); 661 return; 662 } 663 641 664 if (pBlitter->CtxInfo.Base.visualBits & CR_DOUBLE_BIT) 642 665 pBlitter->pDispatch->SwapBuffers(pBlitter->CurrentMural.Base.id, 0); … … 644 667 pBlitter->pDispatch->Flush(); 645 668 } 669 670 static int crBltImgCreateForTex(const VBOXVR_TEXTURE *pSrc, CR_BLITTER_IMG *pDst, GLenum enmFormat) 671 { 672 memset(pDst, 0, sizeof (*pDst)); 673 if (enmFormat != GL_RGBA 674 && enmFormat != GL_BGRA) 675 { 676 crWarning("unsupported format 0x%x", enmFormat); 677 return VERR_NOT_IMPLEMENTED; 678 } 679 680 uint32_t bpp = 32; 681 682 uint32_t pitch = ((bpp * pSrc->width) + 7) >> 3; 683 uint32_t cbData = pitch * pSrc->height; 684 pDst->pvData = RTMemAllocZ(cbData); 685 if (!pDst->pvData) 686 { 687 crWarning("RTMemAlloc failed"); 688 return VERR_NO_MEMORY; 689 } 690 691 #ifdef DEBUG_misha 692 { 693 char *pTmp = (char*)pDst->pvData; 694 for (uint32_t i = 0; i < cbData; ++i) 695 { 696 pTmp[i] = (char)((1 << i) % 255); 697 } 698 } 699 #endif 700 701 pDst->cbData = cbData; 702 pDst->enmFormat = enmFormat; 703 pDst->width = pSrc->width; 704 pDst->height = pSrc->height; 705 pDst->bpp = bpp; 706 pDst->pitch = pitch; 707 return VINF_SUCCESS; 708 } 709 710 VBOXBLITTERDECL(int) CrBltImgGetTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, GLenum enmFormat, CR_BLITTER_IMG *pDst) 711 { 712 if (!CrBltIsEntered(pBlitter)) 713 { 714 crWarning("CrBltImgGetTex: blitter not entered"); 715 return VERR_INVALID_STATE; 716 } 717 718 int rc = crBltImgCreateForTex(pSrc, pDst, enmFormat); 719 if (!RT_SUCCESS(rc)) 720 { 721 crWarning("crBltImgCreateForTex failed, rc %d", rc); 722 return rc; 723 } 724 pBlitter->pDispatch->BindTexture(pSrc->target, pSrc->hwid); 725 726 #ifdef DEBUG_misha 727 { 728 GLint width = 0, height = 0, depth = 0; 729 pBlitter->pDispatch->GetTexLevelParameteriv(pSrc->target, 0, GL_TEXTURE_WIDTH, &width); 730 pBlitter->pDispatch->GetTexLevelParameteriv(pSrc->target, 0, GL_TEXTURE_HEIGHT, &height); 731 pBlitter->pDispatch->GetTexLevelParameteriv(pSrc->target, 0, GL_TEXTURE_DEPTH, &depth); 732 733 Assert(width == pSrc->width); 734 Assert(height == pSrc->height); 735 // Assert(depth == pSrc->depth); 736 } 737 #endif 738 739 pBlitter->pDispatch->GetTexImage(pSrc->target, 0, enmFormat, GL_UNSIGNED_BYTE, pDst->pvData); 740 741 pBlitter->pDispatch->BindTexture(pSrc->target, 0); 742 return VINF_SUCCESS; 743 } 744 745 VBOXBLITTERDECL(int) CrBltImgGetMural(PCR_BLITTER pBlitter, bool fBb, CR_BLITTER_IMG *pDst) 746 { 747 if (!CrBltIsEntered(pBlitter)) 748 { 749 crWarning("CrBltImgGetMural: blitter not entered"); 750 return VERR_INVALID_STATE; 751 } 752 753 crWarning("NOT IMPLEMENTED"); 754 return VERR_NOT_IMPLEMENTED; 755 } 756 757 VBOXBLITTERDECL(void) CrBltImgFree(PCR_BLITTER pBlitter, CR_BLITTER_IMG *pDst) 758 { 759 if (!CrBltIsEntered(pBlitter)) 760 { 761 crWarning("CrBltImgFree: blitter not entered"); 762 return; 763 } 764 765 if (pDst->pvData) 766 { 767 RTMemFree(pDst->pvData); 768 pDst->pvData = NULL; 769 } 770 } 771
Note:
See TracChangeset
for help on using the changeset viewer.