From ae25b1eca5a2253148828af6b87717c6e680d531 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 30 Jun 2014 11:17:00 +0200 Subject: [PATCH] d3d9: Improve d3d9_device_CheckDeviceState() a little. --- dlls/d3d9/device.c | 22 +++++++++++++++++----- dlls/d3d9/tests/d3d9ex.c | 10 +++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 2d9a192c509..d9aba207c28 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3147,14 +3147,26 @@ static HRESULT WINAPI d3d9_device_GetMaximumFrameLatency(IDirect3DDevice9Ex *ifa static HRESULT WINAPI d3d9_device_CheckDeviceState(IDirect3DDevice9Ex *iface, HWND dst_window) { - static int i; + struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); + struct wined3d_swapchain_desc swapchain_desc; + struct wined3d_swapchain *swapchain; - TRACE("iface %p, dst_window %p stub!\n", iface, dst_window); + TRACE("iface %p, dst_window %p.\n", iface, dst_window); - if (!i++) - FIXME("iface %p, dst_window %p stub!\n", iface, dst_window); + wined3d_mutex_lock(); + swapchain = wined3d_device_get_swapchain(device->wined3d_device, 0); + wined3d_swapchain_get_desc(swapchain, &swapchain_desc); + wined3d_mutex_unlock(); - return D3D_OK; + if (swapchain_desc.windowed) + return D3D_OK; + + /* FIXME: This is actually supposed to check if any other device is in + * fullscreen mode. */ + if (dst_window != swapchain_desc.device_window) + return device->device_state == D3D9_DEVICE_STATE_OK ? S_PRESENT_OCCLUDED : D3D_OK; + + return device->device_state == D3D9_DEVICE_STATE_OK ? D3D_OK : S_PRESENT_OCCLUDED; } static HRESULT WINAPI d3d9_device_CreateRenderTargetEx(IDirect3DDevice9Ex *iface, diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c index 89238c8be94..03090133afa 100644 --- a/dlls/d3d9/tests/d3d9ex.c +++ b/dlls/d3d9/tests/d3d9ex.c @@ -1219,7 +1219,7 @@ static void test_lost_device(void) hr = IDirect3DDevice9Ex_CheckDeviceState(device, window); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL); - todo_wine ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); + ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -1230,7 +1230,7 @@ static void test_lost_device(void) hr = IDirect3DDevice9Ex_PresentEx(device, NULL, NULL, NULL, NULL, 0); ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_CheckDeviceState(device, window); - todo_wine ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); + ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); @@ -1245,7 +1245,7 @@ static void test_lost_device(void) hr = IDirect3DDevice9Ex_CheckDeviceState(device, window); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL); - todo_wine ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); + ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); hr = reset_device(device, window, FALSE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); @@ -1258,7 +1258,7 @@ static void test_lost_device(void) hr = IDirect3DDevice9Ex_CheckDeviceState(device, window); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL); - todo_wine ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); + ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); hr = reset_device(device, window, TRUE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); @@ -1323,7 +1323,7 @@ static void test_lost_device(void) hr = IDirect3DDevice9Ex_CheckDeviceState(device, window); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL); - todo_wine ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); + ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); refcount = IDirect3DDevice9Ex_Release(device); ok(!refcount, "Device has %u references left.\n", refcount);