dxgi: Factor out d3d11_swapchain_get_hwnd().

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2019-03-12 16:30:21 +01:00 committed by Alexandre Julliard
parent f42b983356
commit e3ad02bd3e
1 changed files with 14 additions and 12 deletions

View File

@ -150,6 +150,17 @@ static HRESULT dxgi_get_output_from_window(IDXGIAdapter *adapter, HWND window, I
return DXGI_ERROR_NOT_FOUND; return DXGI_ERROR_NOT_FOUND;
} }
static HWND d3d11_swapchain_get_hwnd(struct d3d11_swapchain *swapchain)
{
struct wined3d_swapchain_desc wined3d_desc;
wined3d_mutex_lock();
wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &wined3d_desc);
wined3d_mutex_unlock();
return wined3d_desc.device_window;
}
static inline struct d3d11_swapchain *d3d11_swapchain_from_IDXGISwapChain1(IDXGISwapChain1 *iface) static inline struct d3d11_swapchain *d3d11_swapchain_from_IDXGISwapChain1(IDXGISwapChain1 *iface)
{ {
return CONTAINING_RECORD(iface, struct d3d11_swapchain, IDXGISwapChain1_iface); return CONTAINING_RECORD(iface, struct d3d11_swapchain, IDXGISwapChain1_iface);
@ -490,7 +501,6 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_ResizeTarget(IDXGISwapChain1 *i
static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetContainingOutput(IDXGISwapChain1 *iface, IDXGIOutput **output) static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetContainingOutput(IDXGISwapChain1 *iface, IDXGIOutput **output)
{ {
struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface);
struct wined3d_swapchain_desc swapchain_desc;
IDXGIAdapter *adapter; IDXGIAdapter *adapter;
IDXGIDevice *device; IDXGIDevice *device;
HRESULT hr; HRESULT hr;
@ -511,11 +521,8 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetContainingOutput(IDXGISwapCh
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
wined3d_mutex_lock(); HWND hwnd = d3d11_swapchain_get_hwnd(swapchain);
wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &swapchain_desc); hr = dxgi_get_output_from_window(adapter, hwnd, output);
wined3d_mutex_unlock();
hr = dxgi_get_output_from_window(adapter, swapchain_desc.device_window, output);
IDXGIAdapter_Release(adapter); IDXGIAdapter_Release(adapter);
} }
else else
@ -611,7 +618,6 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetFullscreenDesc(IDXGISwapChai
static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetHwnd(IDXGISwapChain1 *iface, HWND *hwnd) static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetHwnd(IDXGISwapChain1 *iface, HWND *hwnd)
{ {
struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface);
struct wined3d_swapchain_desc wined3d_desc;
TRACE("iface %p, hwnd %p.\n", iface, hwnd); TRACE("iface %p, hwnd %p.\n", iface, hwnd);
@ -621,11 +627,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetHwnd(IDXGISwapChain1 *iface,
return DXGI_ERROR_INVALID_CALL; return DXGI_ERROR_INVALID_CALL;
} }
wined3d_mutex_lock(); *hwnd = d3d11_swapchain_get_hwnd(swapchain);
wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &wined3d_desc);
wined3d_mutex_unlock();
*hwnd = wined3d_desc.device_window;
return S_OK; return S_OK;
} }