Commit 8fd7d3a2 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Just return the swapchain from wined3d_device_get_swapchain().

parent ac5c420c
......@@ -506,24 +506,24 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_GetSwapChain(IDirect3DDevice
UINT swapchain_idx, IDirect3DSwapChain9 **swapchain)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_swapchain *wined3d_swapchain = NULL;
struct wined3d_swapchain *wined3d_swapchain;
struct d3d9_swapchain *swapchain_impl;
HRESULT hr;
TRACE("iface %p, swapchain_idx %u, swapchain %p.\n", iface, swapchain_idx, swapchain);
wined3d_mutex_lock();
hr = wined3d_device_get_swapchain(device->wined3d_device, swapchain_idx, &wined3d_swapchain);
if (SUCCEEDED(hr) && wined3d_swapchain)
if ((wined3d_swapchain = wined3d_device_get_swapchain(device->wined3d_device, swapchain_idx)))
{
swapchain_impl = wined3d_swapchain_get_parent(wined3d_swapchain);
*swapchain = &swapchain_impl->IDirect3DSwapChain9_iface;
IDirect3DSwapChain9_AddRef(*swapchain);
wined3d_swapchain_decref(wined3d_swapchain);
hr = D3D_OK;
}
else
{
*swapchain = NULL;
hr = D3DERR_INVALIDCALL;
}
wined3d_mutex_unlock();
......
......@@ -695,13 +695,13 @@ static HRESULT ddraw_create_swapchain(struct ddraw *ddraw, HWND window, BOOL win
return hr;
}
if (FAILED(hr = wined3d_device_get_swapchain(ddraw->wined3d_device, 0, &ddraw->wined3d_swapchain)))
if (!(ddraw->wined3d_swapchain = wined3d_device_get_swapchain(ddraw->wined3d_device, 0)))
{
ERR("Failed to get swapchain, hr %#x.\n", hr);
ddraw->wined3d_swapchain = NULL;
return hr;
ERR("Failed to get swapchain.\n");
return DDERR_INVALIDPARAMS;
}
wined3d_swapchain_incref(ddraw->wined3d_swapchain);
ddraw_set_swapchain_window(ddraw, window);
return DD_OK;
......
......@@ -229,16 +229,15 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IWineDXGIFactory *
return hr;
}
hr = wined3d_device_get_swapchain(wined3d_device, 0, &wined3d_swapchain);
wined3d_swapchain = wined3d_device_get_swapchain(wined3d_device, 0);
wined3d_device_decref(wined3d_device);
if (FAILED(hr))
if (!wined3d_swapchain)
{
WARN("Failed to get swapchain, returning %#x\n", hr);
return hr;
WARN("Failed to get swapchain.\n");
return E_FAIL;
}
*swapchain = wined3d_swapchain_get_parent(wined3d_swapchain);
wined3d_swapchain_decref(wined3d_swapchain);
/* FIXME? The swapchain is created with refcount 1 by the wined3d device,
* but the wined3d device can't hold a real reference. */
......
......@@ -1296,8 +1296,7 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock)
}
/* check the return values, because the GetBackBuffer call isn't valid for ddraw */
hr = wined3d_device_get_swapchain(device, 0, &swapchain);
if (SUCCEEDED(hr) && swapchain)
if ((swapchain = wined3d_device_get_swapchain(device, 0)))
{
hr = wined3d_swapchain_get_back_buffer(swapchain, 0, WINED3D_BACKBUFFER_TYPE_MONO, &backbuffer);
if (SUCCEEDED(hr) && backbuffer)
......@@ -1321,8 +1320,6 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock)
state->viewport.height = swapchain->desc.backbuffer_height;
state->viewport.min_z = 0.0f;
state->viewport.max_z = 1.0f;
wined3d_swapchain_decref(swapchain);
}
TRACE("Done.\n");
......
......@@ -83,7 +83,7 @@
@ cdecl wined3d_device_get_stream_source(ptr long ptr ptr ptr)
@ cdecl wined3d_device_get_stream_source_freq(ptr long ptr)
@ cdecl wined3d_device_get_surface_from_dc(ptr ptr ptr)
@ cdecl wined3d_device_get_swapchain(ptr long ptr)
@ cdecl wined3d_device_get_swapchain(ptr long)
@ cdecl wined3d_device_get_swapchain_count(ptr)
@ cdecl wined3d_device_get_texture(ptr long ptr)
@ cdecl wined3d_device_get_texture_stage_state(ptr long long ptr)
......
......@@ -2157,8 +2157,8 @@ HRESULT __cdecl wined3d_device_get_stream_source_freq(const struct wined3d_devic
UINT stream_idx, UINT *divider);
HRESULT __cdecl wined3d_device_get_surface_from_dc(const struct wined3d_device *device,
HDC dc, struct wined3d_surface **surface);
HRESULT __cdecl wined3d_device_get_swapchain(const struct wined3d_device *device,
UINT swapchain_idx, struct wined3d_swapchain **swapchain);
struct wined3d_swapchain * __cdecl wined3d_device_get_swapchain(const struct wined3d_device *device,
UINT swapchain_idx);
UINT __cdecl wined3d_device_get_swapchain_count(const struct wined3d_device *device);
HRESULT __cdecl wined3d_device_get_texture(const struct wined3d_device *device,
UINT stage, struct wined3d_texture **texture);
......
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