wined3d: Remove wined3d_device_get_back_buffer.

This commit is contained in:
Stefan Dösinger 2015-09-03 12:52:53 +02:00 committed by Alexandre Julliard
parent f010e5d88a
commit feb35006f5
5 changed files with 50 additions and 45 deletions

View file

@ -724,25 +724,38 @@ static HRESULT WINAPI d3d8_device_GetBackBuffer(IDirect3DDevice8 *iface,
UINT backbuffer_idx, D3DBACKBUFFER_TYPE backbuffer_type, IDirect3DSurface8 **backbuffer) UINT backbuffer_idx, D3DBACKBUFFER_TYPE backbuffer_type, IDirect3DSurface8 **backbuffer)
{ {
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
struct wined3d_surface *wined3d_surface = NULL; struct wined3d_swapchain *swapchain;
struct wined3d_resource *wined3d_resource;
struct wined3d_texture *wined3d_texture;
struct d3d8_surface *surface_impl; struct d3d8_surface *surface_impl;
HRESULT hr;
TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n", TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
iface, backbuffer_idx, backbuffer_type, backbuffer); iface, backbuffer_idx, backbuffer_type, backbuffer);
/* No need to check for backbuffer == NULL, Windows crashes in that case. */
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_device_get_back_buffer(device->wined3d_device, 0, backbuffer_idx, if (!(swapchain = wined3d_device_get_swapchain(device->wined3d_device, 0)))
(enum wined3d_backbuffer_type)backbuffer_type, &wined3d_surface);
if (SUCCEEDED(hr) && wined3d_surface && backbuffer)
{ {
surface_impl = wined3d_surface_get_parent(wined3d_surface); wined3d_mutex_unlock();
*backbuffer = &surface_impl->IDirect3DSurface8_iface; *backbuffer = NULL;
IDirect3DSurface8_AddRef(*backbuffer); return D3DERR_INVALIDCALL;
} }
wined3d_mutex_unlock();
return hr; if (!(wined3d_texture = wined3d_swapchain_get_back_buffer(swapchain,
backbuffer_idx, (enum wined3d_backbuffer_type)backbuffer_type)))
{
wined3d_mutex_unlock();
*backbuffer = NULL;
return D3DERR_INVALIDCALL;
}
wined3d_resource = wined3d_texture_get_sub_resource(wined3d_texture, 0);
surface_impl = wined3d_resource_get_parent(wined3d_resource);
*backbuffer = &surface_impl->IDirect3DSurface8_iface;
IDirect3DSurface8_AddRef(*backbuffer);
wined3d_mutex_unlock();
return D3D_OK;
} }
static HRESULT WINAPI d3d8_device_GetRasterStatus(IDirect3DDevice8 *iface, D3DRASTER_STATUS *raster_status) static HRESULT WINAPI d3d8_device_GetRasterStatus(IDirect3DDevice8 *iface, D3DRASTER_STATUS *raster_status)

View file

@ -746,26 +746,41 @@ static HRESULT WINAPI d3d9_device_GetBackBuffer(IDirect3DDevice9Ex *iface, UINT
UINT backbuffer_idx, D3DBACKBUFFER_TYPE backbuffer_type, IDirect3DSurface9 **backbuffer) UINT backbuffer_idx, D3DBACKBUFFER_TYPE backbuffer_type, IDirect3DSurface9 **backbuffer)
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_surface *wined3d_surface = NULL; struct wined3d_swapchain *wined3d_swapchain;
struct wined3d_resource *wined3d_resource;
struct wined3d_texture *wined3d_texture;
struct d3d9_surface *surface_impl; struct d3d9_surface *surface_impl;
HRESULT hr;
TRACE("iface %p, swapchain %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n", TRACE("iface %p, swapchain %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
iface, swapchain, backbuffer_idx, backbuffer_type, backbuffer); iface, swapchain, backbuffer_idx, backbuffer_type, backbuffer);
/* No need to check for backbuffer == NULL, Windows crashes in that case. */
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_device_get_back_buffer(device->wined3d_device, swapchain,
backbuffer_idx, (enum wined3d_backbuffer_type)backbuffer_type, &wined3d_surface);
if (SUCCEEDED(hr) && wined3d_surface && backbuffer)
{
surface_impl = wined3d_surface_get_parent(wined3d_surface);
*backbuffer = &surface_impl->IDirect3DSurface9_iface;
IDirect3DSurface9_AddRef(*backbuffer);
}
wined3d_mutex_unlock();
return hr; if (!(wined3d_swapchain = wined3d_device_get_swapchain(device->wined3d_device, swapchain)))
{
wined3d_mutex_unlock();
*backbuffer = NULL;
return D3DERR_INVALIDCALL;
}
if (!(wined3d_texture = wined3d_swapchain_get_back_buffer(wined3d_swapchain,
backbuffer_idx, (enum wined3d_backbuffer_type)backbuffer_type)))
{
wined3d_mutex_unlock();
*backbuffer = NULL;
return D3DERR_INVALIDCALL;
}
wined3d_resource = wined3d_texture_get_sub_resource(wined3d_texture, 0);
surface_impl = wined3d_resource_get_parent(wined3d_resource);
*backbuffer = &surface_impl->IDirect3DSurface9_iface;
IDirect3DSurface9_AddRef(*backbuffer);
wined3d_mutex_unlock();
return D3D_OK;
} }
static HRESULT WINAPI d3d9_device_GetRasterStatus(IDirect3DDevice9Ex *iface, static HRESULT WINAPI d3d9_device_GetRasterStatus(IDirect3DDevice9Ex *iface,
UINT swapchain, D3DRASTER_STATUS *raster_status) UINT swapchain, D3DRASTER_STATUS *raster_status)
{ {

View file

@ -3183,26 +3183,6 @@ struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_d
return device->state.textures[stage]; return device->state.textures[stage];
} }
HRESULT CDECL wined3d_device_get_back_buffer(const struct wined3d_device *device, UINT swapchain_idx,
UINT backbuffer_idx, enum wined3d_backbuffer_type backbuffer_type, struct wined3d_surface **backbuffer)
{
struct wined3d_texture *texture;
struct wined3d_resource *resource;
struct wined3d_swapchain *swapchain;
TRACE("device %p, swapchain_idx %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
device, swapchain_idx, backbuffer_idx, backbuffer_type, backbuffer);
if (!(swapchain = wined3d_device_get_swapchain(device, swapchain_idx)))
return WINED3DERR_INVALIDCALL;
if (!(texture = wined3d_swapchain_get_back_buffer(swapchain, backbuffer_idx, backbuffer_type)))
return WINED3DERR_INVALIDCALL;
resource = wined3d_texture_get_sub_resource(texture, 0);
*backbuffer = wined3d_surface_from_resource(resource);
return WINED3D_OK;
}
HRESULT CDECL wined3d_device_get_device_caps(const struct wined3d_device *device, WINED3DCAPS *caps) HRESULT CDECL wined3d_device_get_device_caps(const struct wined3d_device *device, WINED3DCAPS *caps)
{ {
TRACE("device %p, caps %p.\n", device, caps); TRACE("device %p, caps %p.\n", device, caps);

View file

@ -49,7 +49,6 @@
@ cdecl wined3d_device_end_stateblock(ptr ptr) @ cdecl wined3d_device_end_stateblock(ptr ptr)
@ cdecl wined3d_device_evict_managed_resources(ptr) @ cdecl wined3d_device_evict_managed_resources(ptr)
@ cdecl wined3d_device_get_available_texture_mem(ptr) @ cdecl wined3d_device_get_available_texture_mem(ptr)
@ cdecl wined3d_device_get_back_buffer(ptr long long long ptr)
@ cdecl wined3d_device_get_base_vertex_index(ptr) @ cdecl wined3d_device_get_base_vertex_index(ptr)
@ cdecl wined3d_device_get_clip_plane(ptr long ptr) @ cdecl wined3d_device_get_clip_plane(ptr long ptr)
@ cdecl wined3d_device_get_clip_status(ptr ptr) @ cdecl wined3d_device_get_clip_status(ptr ptr)

View file

@ -2154,8 +2154,6 @@ HRESULT __cdecl wined3d_device_end_scene(struct wined3d_device *device);
HRESULT __cdecl wined3d_device_end_stateblock(struct wined3d_device *device, struct wined3d_stateblock **stateblock); HRESULT __cdecl wined3d_device_end_stateblock(struct wined3d_device *device, struct wined3d_stateblock **stateblock);
void __cdecl wined3d_device_evict_managed_resources(struct wined3d_device *device); void __cdecl wined3d_device_evict_managed_resources(struct wined3d_device *device);
UINT __cdecl wined3d_device_get_available_texture_mem(const struct wined3d_device *device); UINT __cdecl wined3d_device_get_available_texture_mem(const struct wined3d_device *device);
HRESULT __cdecl wined3d_device_get_back_buffer(const struct wined3d_device *device, UINT swapchain_idx,
UINT backbuffer_idx, enum wined3d_backbuffer_type backbuffer_type, struct wined3d_surface **backbuffer);
INT __cdecl wined3d_device_get_base_vertex_index(const struct wined3d_device *device); INT __cdecl wined3d_device_get_base_vertex_index(const struct wined3d_device *device);
HRESULT __cdecl wined3d_device_get_clip_plane(const struct wined3d_device *device, HRESULT __cdecl wined3d_device_get_clip_plane(const struct wined3d_device *device,
UINT plane_idx, struct wined3d_vec4 *plane); UINT plane_idx, struct wined3d_vec4 *plane);