Commit 74e0985e authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

evr/presenter: Make GetCurrentImage() work without output window.

parent 2bf3a585
...@@ -492,28 +492,29 @@ static void video_presenter_sample_present(struct video_presenter *presenter, IM ...@@ -492,28 +492,29 @@ static void video_presenter_sample_present(struct video_presenter *presenter, IM
IDirect3DDevice9 *device; IDirect3DDevice9 *device;
HRESULT hr; HRESULT hr;
if (!presenter->swapchain)
return;
if (FAILED(hr = video_presenter_get_sample_surface(sample, &surface))) if (FAILED(hr = video_presenter_get_sample_surface(sample, &surface)))
{ {
WARN("Failed to get sample surface, hr %#lx.\n", hr); WARN("Failed to get sample surface, hr %#lx.\n", hr);
return; return;
} }
if (FAILED(hr = IDirect3DSwapChain9_GetBackBuffer(presenter->swapchain, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer))) if (presenter->swapchain)
{
if (SUCCEEDED(hr = IDirect3DSwapChain9_GetBackBuffer(presenter->swapchain, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer)))
{ {
WARN("Failed to get a backbuffer, hr %#lx.\n", hr);
IDirect3DSurface9_Release(surface);
return;
}
IDirect3DSwapChain9_GetDevice(presenter->swapchain, &device); IDirect3DSwapChain9_GetDevice(presenter->swapchain, &device);
IDirect3DDevice9_StretchRect(device, surface, NULL, backbuffer, NULL, D3DTEXF_POINT); IDirect3DDevice9_StretchRect(device, surface, NULL, backbuffer, NULL, D3DTEXF_POINT);
IDirect3DSwapChain9_Present(presenter->swapchain, NULL, NULL, NULL, NULL, 0); IDirect3DSwapChain9_Present(presenter->swapchain, NULL, NULL, NULL, NULL, 0);
presenter->frame_stats.presented++; presenter->frame_stats.presented++;
IDirect3DDevice9_Release(device);
IDirect3DSurface9_Release(backbuffer);
}
else
WARN("Failed to get a backbuffer, hr %#lx.\n", hr);
}
EnterCriticalSection(&presenter->cs); EnterCriticalSection(&presenter->cs);
if (presenter->thread.queue.last_presented) if (presenter->thread.queue.last_presented)
IMFSample_Release(presenter->thread.queue.last_presented); IMFSample_Release(presenter->thread.queue.last_presented);
...@@ -521,8 +522,6 @@ static void video_presenter_sample_present(struct video_presenter *presenter, IM ...@@ -521,8 +522,6 @@ static void video_presenter_sample_present(struct video_presenter *presenter, IM
IMFSample_AddRef(presenter->thread.queue.last_presented); IMFSample_AddRef(presenter->thread.queue.last_presented);
LeaveCriticalSection(&presenter->cs); LeaveCriticalSection(&presenter->cs);
IDirect3DDevice9_Release(device);
IDirect3DSurface9_Release(backbuffer);
IDirect3DSurface9_Release(surface); IDirect3DSurface9_Release(surface);
} }
...@@ -1493,13 +1492,13 @@ static HRESULT WINAPI video_presenter_control_GetCurrentImage(IMFVideoDisplayCon ...@@ -1493,13 +1492,13 @@ static HRESULT WINAPI video_presenter_control_GetCurrentImage(IMFVideoDisplayCon
sample = presenter->thread.queue.last_presented; sample = presenter->thread.queue.last_presented;
presenter->thread.queue.last_presented = NULL; presenter->thread.queue.last_presented = NULL;
if (!presenter->swapchain || !sample) if (!sample)
{ {
hr = MF_E_INVALIDREQUEST; hr = MF_E_INVALIDREQUEST;
} }
else if (SUCCEEDED(hr = video_presenter_get_sample_surface(sample, &surface))) else if (SUCCEEDED(hr = video_presenter_get_sample_surface(sample, &surface)))
{ {
IDirect3DSwapChain9_GetDevice(presenter->swapchain, &device); IDirect3DSurface9_GetDevice(surface, &device);
IDirect3DSurface9_GetDesc(surface, &surface_desc); IDirect3DSurface9_GetDesc(surface, &surface_desc);
if (surface_desc.Format != D3DFMT_X8R8G8B8) if (surface_desc.Format != D3DFMT_X8R8G8B8)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment