From bbc2d604ce156da4947d00f4cc64b9bd5e917138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Wed, 3 Aug 2016 09:41:41 +0200 Subject: [PATCH] dxgi: Implement dxgi_swapchain_SetFullscreenState(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/dxgi/swapchain.c | 38 ++++++++++++++++++++++++++++++++++++-- dlls/dxgi/tests/device.c | 6 +++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index 6b80ead9688..cdb28e40c71 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -204,9 +204,43 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain *iface, static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH dxgi_swapchain_SetFullscreenState(IDXGISwapChain *iface, BOOL fullscreen, IDXGIOutput *target) { - FIXME("iface %p, fullscreen %#x, target %p stub!\n", iface, fullscreen, target); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain(iface); + struct wined3d_swapchain_desc swapchain_desc; + HRESULT hr; - return E_NOTIMPL; + TRACE("iface %p, fullscreen %#x, target %p.\n", iface, fullscreen, target); + + if (!fullscreen && target) + { + WARN("Invalid call.\n"); + return DXGI_ERROR_INVALID_CALL; + } + + if (fullscreen) + { + if (target) + { + IDXGIOutput_AddRef(target); + } + else if (FAILED(hr = IDXGISwapChain_GetContainingOutput(iface, &target))) + { + WARN("Failed to get default target output for swapchain, hr %#x.\n", hr); + return hr; + } + } + + swapchain->fullscreen = fullscreen; + if (swapchain->target) + IDXGIOutput_Release(swapchain->target); + swapchain->target = target; + + wined3d_mutex_lock(); + wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &swapchain_desc); + swapchain_desc.windowed = !fullscreen; + hr = wined3d_swapchain_set_fullscreen(swapchain->wined3d_swapchain, &swapchain_desc, NULL); + wined3d_mutex_unlock(); + + return hr; } static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFullscreenState(IDXGISwapChain *iface, diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c index 3c43895f292..9c0aa9dc6a8 100644 --- a/dlls/dxgi/tests/device.c +++ b/dlls/dxgi/tests/device.c @@ -545,7 +545,7 @@ static void test_create_swapchain(void) "Denominator %u is %u.\n", i ,result_desc.BufferDesc.RefreshRate.Denominator); hr = IDXGISwapChain_SetFullscreenState(swapchain, FALSE, NULL); - todo_wine ok(SUCCEEDED(hr), "SetFullscreenState failed, hr %#x.\n", hr); + ok(SUCCEEDED(hr), "SetFullscreenState failed, hr %#x.\n", hr); IDXGISwapChain_Release(swapchain); } @@ -1301,7 +1301,7 @@ static void test_swapchain_parameters(void) if (FAILED(hr)) { hr = IDXGISwapChain_SetFullscreenState(swapchain, FALSE, NULL); - todo_wine ok(SUCCEEDED(hr), "SetFullscreenState failed, hr %#x.\n", hr); + ok(SUCCEEDED(hr), "SetFullscreenState failed, hr %#x.\n", hr); IDXGISwapChain_Release(swapchain); continue; @@ -1357,7 +1357,7 @@ static void test_swapchain_parameters(void) ok(hr == DXGI_ERROR_INVALID_CALL, "GetBuffer(%u) returned unexpected hr %#x, test %u.\n", j, hr, i); hr = IDXGISwapChain_SetFullscreenState(swapchain, FALSE, NULL); - todo_wine ok(SUCCEEDED(hr), "SetFullscreenState failed, hr %#x.\n", hr); + ok(SUCCEEDED(hr), "SetFullscreenState failed, hr %#x.\n", hr); IDXGISwapChain_Release(swapchain); }