| 79 | } |
| 80 | |
| 81 | HRESULT WINAPI D3D9Present(IDirect3DDevice9 *pDev, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) { |
| 82 | D3D9FrameGrabber *d3d9FrameGrabber = D3D9FrameGrabber::getInstance(); |
| 83 | Logger *logger = d3d9FrameGrabber->m_logger; |
| 84 | DWORD errorcode; |
| 85 | if (WAIT_OBJECT_0 == (errorcode = WaitForSingleObject(d3d9FrameGrabber->m_syncRunMutex, 0))) { |
| 86 | IPCContext *ipcContext = d3d9FrameGrabber->m_ipcContext; |
| 87 | logger->reportLogDebug(L"D3D9Present"); |
| 88 | HRESULT hRes; |
| 89 | |
| 90 | RECT newRect = RECT(); |
| 91 | IDirect3DSurface9 *pBackBuffer = NULL; |
| 92 | IDirect3DSurface9 *pDemultisampledSurf = NULL; |
| 93 | IDirect3DSurface9 *pOffscreenSurf = NULL; |
| 94 | IDirect3DSwapChain9 *pSc = NULL; |
| 95 | D3DPRESENT_PARAMETERS params; |
| 96 | |
| 97 | if(FAILED( hRes = pDev->GetSwapChain(0, &pSc))) { |
| 98 | logger->reportLogError(L"d3d9present couldn't get swapchain. result 0x%x", hRes); |
| 99 | goto end; |
| 100 | } |
| 101 | |
| 102 | hRes = pSc->GetPresentParameters(¶ms); |
| 103 | if (FAILED(hRes) || params.Windowed) { |
| 104 | goto end; |
| 105 | } |
| 106 | |
| 107 | if(FAILED( hRes = pDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer))) { |
| 108 | goto end; |
| 109 | } |
| 110 | |
| 111 | D3DSURFACE_DESC surfDesc; |
| 112 | pBackBuffer->GetDesc(&surfDesc); |
| 113 | |
| 114 | hRes = pDev->CreateRenderTarget( |
| 115 | surfDesc.Width, surfDesc.Height, |
| 116 | surfDesc.Format, D3DMULTISAMPLE_NONE, 0, false, |
| 117 | &pDemultisampledSurf, NULL ); |
| 118 | if (FAILED(hRes)) |
| 119 | { |
| 120 | logger->reportLogError(L"GetFramePrep: FAILED to create demultisampled render target. 0x%x, width=%u, height=%u, format=%x", hRes, surfDesc.Width, surfDesc.Height, surfDesc.Format ); |
| 121 | goto end; |
| 122 | } |
| 123 | |
| 124 | hRes = pDev->StretchRect(pBackBuffer, NULL, pDemultisampledSurf, NULL, D3DTEXF_LINEAR ); |
| 125 | if (FAILED(hRes)) |
| 126 | { |
| 127 | logger->reportLogError(L"GetFramePrep: StretchRect FAILED for image surfacee. 0x%x, width=%u, height=%u, format=%x", hRes, surfDesc.Width, surfDesc.Height, surfDesc.Format ); |
| 128 | goto end; |
| 129 | } |
| 130 | |
| 131 | hRes = pDev->CreateOffscreenPlainSurface( |
| 132 | surfDesc.Width, surfDesc.Height, |
| 133 | surfDesc.Format, D3DPOOL_SYSTEMMEM, |
| 134 | &pOffscreenSurf, NULL ); |
| 135 | if (FAILED(hRes)) |
| 136 | { |
| 137 | logger->reportLogError(L"GetFramePrep: FAILED to create image surface. 0x%x, width=%u, height=%u, format=%x", hRes, surfDesc.Width, surfDesc.Height, surfDesc.Format ); |
| 138 | goto end; |
nothing calls this directly
no test coverage detected