| 210 | } |
| 211 | |
| 212 | HRESULT WINAPI D3D9SCPresent(IDirect3DSwapChain9 *pSc, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion, DWORD dwFlags) { |
| 213 | |
| 214 | D3D9FrameGrabber *d3d9FrameGrabber = D3D9FrameGrabber::getInstance(); |
| 215 | Logger *logger = d3d9FrameGrabber->m_logger; |
| 216 | DWORD errorcode; |
| 217 | if (WAIT_OBJECT_0 == (errorcode = WaitForSingleObject(d3d9FrameGrabber->m_syncRunMutex, 0))) { |
| 218 | IPCContext *ipcContext = d3d9FrameGrabber->m_ipcContext; |
| 219 | logger->reportLogDebug(L"D3D9SCPresent"); |
| 220 | IDirect3DSurface9 *pBackBuffer = NULL; |
| 221 | D3DPRESENT_PARAMETERS params; |
| 222 | RECT newRect = RECT(); |
| 223 | IDirect3DSurface9 *pDemultisampledSurf = NULL; |
| 224 | IDirect3DSurface9 *pOffscreenSurf = NULL; |
| 225 | IDirect3DDevice9 *pDev = NULL; |
| 226 | |
| 227 | HRESULT hRes = pSc->GetPresentParameters(¶ms); |
| 228 | |
| 229 | if (FAILED(hRes) || params.Windowed) { |
| 230 | goto end; |
| 231 | } |
| 232 | |
| 233 | if (FAILED(hRes = pSc->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer))) { |
| 234 | logger->reportLogError(L"d3d9sc couldn't get backbuffer. errorcode = 0x%x", hRes); |
| 235 | goto end; |
| 236 | } |
| 237 | D3DSURFACE_DESC surfDesc; |
| 238 | pBackBuffer->GetDesc(&surfDesc); |
| 239 | |
| 240 | hRes = pSc->GetDevice(&pDev); |
| 241 | if (FAILED(hRes)) |
| 242 | { |
| 243 | logger->reportLogError(L"GetFramePrep: FAILED to get pDev. 0x%x, width=%u, height=%u, format=%x", hRes, surfDesc.Width, surfDesc.Height, surfDesc.Format ); |
| 244 | goto end; |
| 245 | } |
| 246 | hRes = pDev->CreateRenderTarget( |
| 247 | surfDesc.Width, surfDesc.Height, |
| 248 | surfDesc.Format, D3DMULTISAMPLE_NONE, 0, false, |
| 249 | &pDemultisampledSurf, NULL ); |
| 250 | if (FAILED(hRes)) |
| 251 | { |
| 252 | 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 ); |
| 253 | goto end; |
| 254 | } |
| 255 | |
| 256 | hRes = pDev->StretchRect(pBackBuffer, NULL, pDemultisampledSurf, NULL, D3DTEXF_LINEAR ); |
| 257 | if (FAILED(hRes)) |
| 258 | { |
| 259 | logger->reportLogError(L"GetFramePrep: StretchRect FAILED for image surfacee. 0x%x, width=%u, height=%u, format=%x", hRes, surfDesc.Width, surfDesc.Height, surfDesc.Format ); |
| 260 | goto end; |
| 261 | } |
| 262 | |
| 263 | hRes = pDev->CreateOffscreenPlainSurface( |
| 264 | surfDesc.Width, surfDesc.Height, |
| 265 | surfDesc.Format, D3DPOOL_SYSTEMMEM, |
| 266 | &pOffscreenSurf, NULL ); |
| 267 | if (FAILED(hRes)) |
| 268 | { |
| 269 | logger->reportLogError(L"GetFramePrep: FAILED to create image surface. 0x%x, width=%u, height=%u, format=%x", hRes, surfDesc.Width, surfDesc.Height, surfDesc.Format ); |
nothing calls this directly
no test coverage detected