Changeset 30570 in vbox for trunk/src/VBox/Additions/WINNT/Graphics
- Timestamp:
- Jul 2, 2010 9:22:37 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
r30566 r30570 951 951 } 952 952 } 953 } 954 955 #if 0 956 static HRESULT vboxWddmRectBltPerform(uint8_t *pvDstSurf, const uint8_t *pvSrcSurf, 957 RECT *pDstRect, RECT *pSrcRect, 958 uint32_t DstPitch, uint32_t SrcPitch, uint32_t bpp, 959 RECT *pDstCopyRect, RECT *pSrcCopyRect) 960 { 961 uint32_t DstCopyWidth = pDstCopyRect->left - pDstCopyRect->right; 962 uint32_t DstCopyHeight = pDstCopyRect->bottom - pDstCopyRect->top; 963 uint32_t SrcCopyWidth = pSrcCopyRect->left - pSrcCopyRect->right; 964 uint32_t SrcCopyHeight = pSrcCopyRect->bottom - pSrcCopyRect->top; 965 uint32_t srcBpp = bpp; 966 uint32_t dstBpp = bpp; 967 /* we do not support stretching */ 968 Assert(DstCopyWidth == SrcCopyWidth); 969 Assert(DstCopyHeight == SrcCopyWidth); 970 if (DstCopyWidth != SrcCopyWidth) 971 return E_FAIL; 972 if (DstCopyHeight != SrcCopyWidth) 973 return E_FAIL; 974 975 uint32_t DstWidth = pDstRect->left - pDstRect->right; 976 uint32_t DstHeight = pDstRect->bottom - pDstRect->top; 977 uint32_t SrcWidth = pSrcRect->left - pSrcRect->right; 978 uint32_t SrcHeight = pSrcRect->bottom - pSrcRect->top; 979 980 if (DstWidth == DstCopyWidth 981 && SrcWidth == SrcCopyWidth 982 && SrcWidth == DstWidth) 983 { 984 Assert(!pDstCopyRect->left); 985 Assert(!pSrcCopyRect->left); 986 uint32_t cbOff = DstPitch * pDstCopyRect->top; 987 uint32_t cbSize = DstPitch * DstCopyHeight; 988 memcpy(pvDstSurf + cbOff, pvSrcSurf + cbOff, cbSize); 989 } 990 else 991 { 992 uint32_t offDstLineStart = pDstCopyRect->left * dstBpp >> 3; 993 uint32_t offDstLineEnd = ((pDstCopyRect->left * dstBpp + 7) >> 3) + ((dstBpp * DstCopyWidth + 7) >> 3); 994 uint32_t cbDstLine = offDstLineEnd - offDstLineStart; 995 uint32_t offDstStart = DstPitch * pDstCopyRect->top + offDstLineStart; 996 Assert(cbDstLine <= DstPitch); 997 uint32_t cbDstSkip = DstPitch; 998 uint8_t * pvDstStart = pvDstSurf + offDstStart; 999 1000 uint32_t offSrcLineStart = pSrcCopyRect->left * srcBpp >> 3; 1001 uint32_t offSrcLineEnd = ((pSrcCopyRect->left * srcBpp + 7) >> 3) + ((srcBpp * SrcCopyWidth + 7) >> 3); 1002 uint32_t cbSrcLine = offSrcLineEnd - offSrcLineStart; 1003 uint32_t offSrcStart = SrcPitch * pSrcCopyRect->top + offSrcLineStart; 1004 Assert(cbSrcLine <= SrcPitch); 1005 uint32_t cbSrcSkip = SrcPitch; 1006 const uint8_t * pvSrcStart = pvSrcSurf + offSrcStart; 1007 1008 Assert(cbDstLine == cbSrcLine); 1009 1010 for (uint32_t i = 0; ; ++i) 1011 { 1012 memcpy (pvDstStart, pvSrcStart, cbDstLine); 1013 if (i == DstCopyHeight) 1014 break; 1015 pvDstStart += cbDstSkip; 1016 pvSrcStart += cbSrcSkip; 1017 } 1018 } 1019 return S_OK; 1020 } 1021 #endif 1022 1023 static HRESULT vboxWddmRectBltPerform(uint8_t *pvDstSurf, const uint8_t *pvSrcSurf, 1024 const RECT *pDstRect, const RECT *pSrcRect, 1025 uint32_t DstPitch, uint32_t SrcPitch, uint32_t bpp) 1026 { 1027 uint32_t DstWidth = pDstRect->left - pDstRect->right; 1028 uint32_t DstHeight = pDstRect->bottom - pDstRect->top; 1029 uint32_t SrcWidth = pSrcRect->left - pSrcRect->right; 1030 uint32_t SrcHeight = pSrcRect->bottom - pSrcRect->top; 1031 uint32_t srcBpp = bpp; 1032 uint32_t dstBpp = bpp; 1033 /* we do not support stretching */ 1034 Assert(DstWidth == SrcWidth); 1035 Assert(DstHeight == SrcWidth); 1036 if (DstWidth != SrcWidth) 1037 return E_FAIL; 1038 if (DstHeight != SrcWidth) 1039 return E_FAIL; 1040 1041 if (DstPitch == SrcPitch 1042 && ((DstWidth * bpp)/8) == DstPitch) 1043 { 1044 Assert(!pDstRect->left); 1045 Assert(!pSrcRect->left); 1046 uint32_t cbOff = DstPitch * pDstRect->top; 1047 uint32_t cbSize = DstPitch * DstHeight; 1048 memcpy(pvDstSurf + cbOff, pvSrcSurf + cbOff, cbSize); 1049 } 1050 else 1051 { 1052 1053 uint32_t cbDstLine = (((DstWidth * dstBpp) + 7) >> 3); 1054 for (uint32_t i = 0; ; ++i) 1055 { 1056 memcpy (pvDstSurf, pvSrcSurf, cbDstLine); 1057 if (i == DstHeight) 1058 break; 1059 pvDstSurf += DstPitch; 1060 pvSrcSurf += SrcPitch; 1061 } 1062 } 1063 return S_OK; 953 1064 } 954 1065 … … 3639 3750 return E_FAIL; 3640 3751 } 3752 static HRESULT vboxWddmLockRect(PVBOXWDDMDISP_ALLOCATION pAlloc, UINT iAlloc, D3DDDI_RESOURCEFLAGS fAllocType, 3753 D3DLOCKED_RECT * pLockedRect, 3754 CONST RECT *pRect, 3755 DWORD fLockFlags) 3756 { 3757 HRESULT hr = E_FAIL; 3758 Assert(!pAlloc->LockInfo.cLocks); 3759 if (fAllocType.Texture || fAllocType.Value == 0) 3760 { 3761 IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pAlloc->pD3DIf; 3762 Assert(pD3DIfTex); 3763 hr = pD3DIfTex->LockRect(iAlloc, pLockedRect, pRect, fLockFlags); 3764 Assert(hr == S_OK); 3765 } 3766 else if (fAllocType.RenderTarget) 3767 { 3768 IDirect3DSurface9 *pD3DIfSurf = (IDirect3DSurface9*)pAlloc->pD3DIf; 3769 Assert(pD3DIfSurf); 3770 hr = pD3DIfSurf->LockRect(pLockedRect, pRect, fLockFlags); 3771 Assert(hr == S_OK); 3772 } 3773 else 3774 { 3775 AssertBreakpoint(); 3776 } 3777 return hr; 3778 } 3779 static HRESULT vboxWddmUnlockRect(PVBOXWDDMDISP_ALLOCATION pAlloc, UINT iAlloc, D3DDDI_RESOURCEFLAGS fAllocType) 3780 { 3781 HRESULT hr = E_FAIL; 3782 Assert(!pAlloc->LockInfo.cLocks); 3783 if (fAllocType.Texture || fAllocType.Value == 0) 3784 { 3785 IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pAlloc->pD3DIf; 3786 Assert(pD3DIfTex); 3787 hr = pD3DIfTex->UnlockRect(iAlloc); 3788 Assert(hr == S_OK); 3789 } 3790 else if (fAllocType.RenderTarget) 3791 { 3792 IDirect3DSurface9 *pD3DIfSurf = (IDirect3DSurface9*)pAlloc->pD3DIf; 3793 Assert(pD3DIfSurf); 3794 hr = pD3DIfSurf->UnlockRect(); 3795 Assert(hr == S_OK); 3796 } 3797 else 3798 { 3799 AssertBreakpoint(); 3800 } 3801 return hr; 3802 } 3641 3803 static HRESULT APIENTRY vboxWddmDDevBlt(HANDLE hDevice, CONST D3DDDIARG_BLT* pData) 3642 3804 { … … 3647 3809 PVBOXWDDMDISP_RESOURCE pDstRc = (PVBOXWDDMDISP_RESOURCE)pData->hDstResource; 3648 3810 PVBOXWDDMDISP_RESOURCE pSrcRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource; 3811 Assert(pDstRc->cAllocations > pData->DstSubResourceIndex); 3812 Assert(pSrcRc->cAllocations > pData->SrcSubResourceIndex); 3813 PVBOXWDDMDISP_ALLOCATION pSrcAlloc = &pSrcRc->aAllocations[pData->SrcSubResourceIndex]; 3814 PVBOXWDDMDISP_ALLOCATION pDstAlloc = &pDstRc->aAllocations[pData->DstSubResourceIndex]; 3649 3815 HRESULT hr = S_OK; 3650 3816 if ((pDstRc->RcDesc.fFlags.Texture || pDstRc->RcDesc.fFlags.Value == 0) 3651 3817 && (pSrcRc->RcDesc.fFlags.Texture || pSrcRc->RcDesc.fFlags.Value == 0)) 3652 3818 { 3653 IDirect3DTexture9 *pD3DIfSrcTex = (IDirect3DTexture9*)pSrc Rc->aAllocations[0].pD3DIf;3654 IDirect3DTexture9 *pD3DIfDstTex = (IDirect3DTexture9*)pDst Rc->aAllocations[0].pD3DIf;3819 IDirect3DTexture9 *pD3DIfSrcTex = (IDirect3DTexture9*)pSrcAlloc->pD3DIf; 3820 IDirect3DTexture9 *pD3DIfDstTex = (IDirect3DTexture9*)pDstAlloc->pD3DIf; 3655 3821 Assert(pD3DIfSrcTex); 3656 3822 Assert(pD3DIfDstTex); 3657 3823 3658 if (pSrcRc->aAllocations[0].SurfDesc.width == pDstRc->aAllocations[0].SurfDesc.width 3659 && pSrcRc->aAllocations[0].SurfDesc.height == pDstRc->aAllocations[0].SurfDesc.height 3660 && pSrcRc->RcDesc.enmFormat == pDstRc->RcDesc.enmFormat) 3661 { 3662 /* first check if we can do IDirect3DDevice9::UpdateTexture */ 3663 if (pData->DstRect.left == 0 && pData->DstRect.top == 0 3824 if (pSrcRc->RcDesc.enmFormat == pDstRc->RcDesc.enmFormat) 3825 { 3826 if (pSrcRc->aAllocations[0].SurfDesc.width == pDstRc->aAllocations[0].SurfDesc.width 3827 && pSrcRc->aAllocations[0].SurfDesc.height == pDstRc->aAllocations[0].SurfDesc.height 3828 && pData->DstRect.left == 0 && pData->DstRect.top == 0 3664 3829 && pData->SrcRect.left == 0 && pData->SrcRect.top == 0 3665 3830 && pData->SrcRect.right - pData->SrcRect.left == pSrcRc->aAllocations[0].SurfDesc.width … … 3672 3837 Assert(hr == S_OK); 3673 3838 } 3839 else if (pData->SrcRect.right - pData->SrcRect.left == pData->DstRect.right - pData->DstRect.left 3840 && pData->SrcRect.bottom - pData->SrcRect.top == pData->DstRect.bottom - pData->DstRect.top) 3841 { 3842 Assert(pDstAlloc->SurfDesc.bpp); 3843 Assert(pSrcAlloc->SurfDesc.bpp); 3844 Assert(pSrcAlloc->SurfDesc.bpp == pDstAlloc->SurfDesc.bpp); 3845 D3DLOCKED_RECT DstRect, SrcRect; 3846 Assert(!pSrcAlloc->LockInfo.cLocks); 3847 Assert(!pDstAlloc->LockInfo.cLocks); 3848 hr = pD3DIfDstTex->LockRect(pData->DstSubResourceIndex, &DstRect, &pData->DstRect, D3DLOCK_DISCARD); 3849 Assert(hr == S_OK); 3850 if (hr == S_OK) 3851 { 3852 hr = pD3DIfSrcTex->LockRect(pData->SrcSubResourceIndex, &SrcRect, &pData->SrcRect, D3DLOCK_READONLY); 3853 Assert(hr == S_OK); 3854 if (hr == S_OK) 3855 { 3856 hr = vboxWddmRectBltPerform((uint8_t *)DstRect.pBits, (uint8_t *)SrcRect.pBits, 3857 &pData->DstRect, &pData->SrcRect, 3858 DstRect.Pitch, SrcRect.Pitch, pDstAlloc->SurfDesc.bpp); 3859 Assert(hr == S_OK); 3860 3861 pD3DIfSrcTex->UnlockRect(pData->SrcSubResourceIndex); 3862 } 3863 pD3DIfDstTex->UnlockRect(pData->DstSubResourceIndex); 3864 } 3865 } 3674 3866 else 3675 3867 { 3868 3676 3869 AssertBreakpoint(); 3677 3870 /* @todo: impl */ … … 3686 3879 else 3687 3880 { 3688 AssertBreakpoint(); 3689 /* @todo: impl */ 3881 if (pData->SrcRect.right - pData->SrcRect.left == pData->DstRect.right - pData->DstRect.left 3882 && pData->SrcRect.bottom - pData->SrcRect.top == pData->DstRect.bottom - pData->DstRect.top) 3883 { 3884 Assert(pDstAlloc->SurfDesc.bpp); 3885 Assert(pSrcAlloc->SurfDesc.bpp); 3886 Assert(pSrcAlloc->SurfDesc.bpp == pDstAlloc->SurfDesc.bpp); 3887 3888 D3DLOCKED_RECT DstRect, SrcRect; 3889 hr = vboxWddmLockRect(pDstAlloc, pData->DstSubResourceIndex, pDstRc->RcDesc.fFlags, 3890 &DstRect, &pData->DstRect, D3DLOCK_DISCARD); 3891 Assert(hr == S_OK); 3892 if (hr == S_OK) 3893 { 3894 hr = vboxWddmLockRect(pSrcAlloc, pData->SrcSubResourceIndex, pSrcRc->RcDesc.fFlags, 3895 &SrcRect, &pData->SrcRect, D3DLOCK_READONLY); 3896 Assert(hr == S_OK); 3897 if (hr == S_OK) 3898 { 3899 hr = vboxWddmRectBltPerform((uint8_t *)DstRect.pBits, (uint8_t *)SrcRect.pBits, 3900 &pData->DstRect, &pData->SrcRect, 3901 DstRect.Pitch, SrcRect.Pitch, pDstAlloc->SurfDesc.bpp); 3902 Assert(hr == S_OK); 3903 3904 HRESULT tmpHr = vboxWddmUnlockRect(pSrcAlloc, pData->SrcSubResourceIndex, pSrcRc->RcDesc.fFlags); 3905 Assert(tmpHr == S_OK); 3906 } 3907 HRESULT tmpHr = vboxWddmUnlockRect(pDstAlloc, pData->DstSubResourceIndex, pDstRc->RcDesc.fFlags); 3908 Assert(tmpHr == S_OK); 3909 } 3910 } 3911 else 3912 { 3913 AssertBreakpoint(); 3914 /* @todo: impl */ 3915 } 3690 3916 } 3691 3917
Note:
See TracChangeset
for help on using the changeset viewer.