wined3d: Use a backup device context for swapchains created on the desktop window.

This patch was written by "naur".

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=18490
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-06-20 18:56:28 -05:00 committed by Alexandre Julliard
parent 835d668dc3
commit 0922237c83
5 changed files with 11 additions and 15 deletions

View File

@ -18028,7 +18028,7 @@ static void test_desktop_window(void)
swapchain_desc.Flags = 0; swapchain_desc.Flags = 0;
hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)device, &swapchain_desc, &swapchain); hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)device, &swapchain_desc, &swapchain);
todo_wine ok(hr == S_OK || broken(hr == DXGI_ERROR_INVALID_CALL) /* Not available on all Windows versions. */, ok(hr == S_OK || broken(hr == DXGI_ERROR_INVALID_CALL) /* Not available on all Windows versions. */,
"Failed to create swapchain, hr %#x.\n", hr); "Failed to create swapchain, hr %#x.\n", hr);
IDXGIFactory_Release(factory); IDXGIFactory_Release(factory);
if (FAILED(hr)) if (FAILED(hr))

View File

@ -29338,7 +29338,7 @@ static void test_desktop_window(void)
swapchain_desc.Flags = 0; swapchain_desc.Flags = 0;
hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)device, &swapchain_desc, &swapchain); hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)device, &swapchain_desc, &swapchain);
todo_wine ok(hr == S_OK || broken(hr == DXGI_ERROR_INVALID_CALL) /* Not available on all Windows versions. */, ok(hr == S_OK || broken(hr == DXGI_ERROR_INVALID_CALL) /* Not available on all Windows versions. */,
"Failed to create swapchain, hr %#x.\n", hr); "Failed to create swapchain, hr %#x.\n", hr);
IDXGIFactory_Release(factory); IDXGIFactory_Release(factory);
if (FAILED(hr)) if (FAILED(hr))

View File

@ -11024,12 +11024,7 @@ static void test_desktop_window(void)
DestroyWindow(window); DestroyWindow(window);
device = create_device(d3d, GetDesktopWindow(), GetDesktopWindow(), TRUE); device = create_device(d3d, GetDesktopWindow(), GetDesktopWindow(), TRUE);
todo_wine ok(!!device, "Failed to create a D3D device.\n"); ok(!!device, "Failed to create a D3D device.\n");
if (!device)
{
IDirect3D8_Release(d3d);
return;
}
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0); hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);

View File

@ -25813,12 +25813,7 @@ static void test_desktop_window(void)
DestroyWindow(window); DestroyWindow(window);
device = create_device(d3d, GetDesktopWindow(), GetDesktopWindow(), TRUE); device = create_device(d3d, GetDesktopWindow(), GetDesktopWindow(), TRUE);
todo_wine ok(!!device, "Failed to create a D3D device.\n"); ok(!!device, "Failed to create a D3D device.\n");
if (!device)
{
IDirect3D9_Release(d3d);
return;
}
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0); hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);

View File

@ -1961,10 +1961,16 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
context_gl->tid = GetCurrentThreadId(); context_gl->tid = GetCurrentThreadId();
context_gl->window = context->swapchain->win_handle; context_gl->window = context->swapchain->win_handle;
if (!(context_gl->dc = GetDCEx(context_gl->window, 0, DCX_USESTYLE | DCX_CACHE))) if (context_gl->window == GetDesktopWindow())
{ {
TRACE("Swapchain is created on the desktop window, trying backup device context.\n");
context_gl->dc = NULL;
}
else if (!(context_gl->dc = GetDCEx(context_gl->window, 0, DCX_USESTYLE | DCX_CACHE)))
WARN("Failed to retrieve device context, trying swapchain backup.\n"); WARN("Failed to retrieve device context, trying swapchain backup.\n");
if (!context_gl->dc)
{
if (!(context_gl->dc = swapchain_get_backup_dc(context->swapchain))) if (!(context_gl->dc = swapchain_get_backup_dc(context->swapchain)))
{ {
ERR("Failed to retrieve a device context.\n"); ERR("Failed to retrieve a device context.\n");