d3d8: Get rid of IDirect3DSwapChain8Impl.

This commit is contained in:
Henri Verbeet 2012-05-22 18:01:08 +02:00 committed by Alexandre Julliard
parent 1993727ee7
commit 584053d0ee
3 changed files with 52 additions and 62 deletions

View File

@ -101,7 +101,6 @@
void fixup_caps(WINED3DCAPS *pWineCaps) DECLSPEC_HIDDEN;
typedef struct IDirect3DSurface8Impl IDirect3DSurface8Impl;
typedef struct IDirect3DSwapChain8Impl IDirect3DSwapChain8Impl;
typedef struct IDirect3DVolume8Impl IDirect3DVolume8Impl;
struct d3d8
@ -189,23 +188,15 @@ struct IDirect3DVolume8Impl
HRESULT volume_init(IDirect3DVolume8Impl *volume, struct d3d8_device *device, UINT width, UINT height,
UINT depth, DWORD usage, enum wined3d_format_id format, enum wined3d_pool pool) DECLSPEC_HIDDEN;
/* ------------------- */
/* IDirect3DSwapChain8 */
/* ------------------- */
/*****************************************************************************
* IDirect3DSwapChain8 implementation structure
*/
struct IDirect3DSwapChain8Impl
struct d3d8_swapchain
{
/* IUnknown fields */
IDirect3DSwapChain8 IDirect3DSwapChain8_iface;
LONG ref;
LONG refcount;
struct wined3d_swapchain *wined3d_swapchain;
IDirect3DDevice8 *parentDevice;
IDirect3DDevice8 *parent_device;
};
HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, struct d3d8_device *device,
HRESULT swapchain_init(struct d3d8_swapchain *swapchain, struct d3d8_device *device,
D3DPRESENT_PARAMETERS *present_parameters) DECLSPEC_HIDDEN;
/* ----------------- */

View File

@ -498,7 +498,7 @@ static HRESULT WINAPI d3d8_device_CreateAdditionalSwapChain(IDirect3DDevice8 *if
D3DPRESENT_PARAMETERS *present_parameters, IDirect3DSwapChain8 **swapchain)
{
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
IDirect3DSwapChain8Impl *object;
struct d3d8_swapchain *object;
HRESULT hr;
TRACE("iface %p, present_parameters %p, swapchain %p.\n",
@ -2974,7 +2974,7 @@ static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent
return hr;
}
*swapchain = ((IDirect3DSwapChain8Impl *)d3d_swapchain)->wined3d_swapchain;
*swapchain = ((struct d3d8_swapchain *)d3d_swapchain)->wined3d_swapchain;
wined3d_swapchain_incref(*swapchain);
IDirect3DSwapChain8_Release(d3d_swapchain);

View File

@ -23,107 +23,106 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
static inline IDirect3DSwapChain8Impl *impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8 *iface)
static inline struct d3d8_swapchain *impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DSwapChain8Impl, IDirect3DSwapChain8_iface);
return CONTAINING_RECORD(iface, struct d3d8_swapchain, IDirect3DSwapChain8_iface);
}
static HRESULT WINAPI IDirect3DSwapChain8Impl_QueryInterface(IDirect3DSwapChain8 *iface,
REFIID riid, void **ppobj)
static HRESULT WINAPI d3d8_swapchain_QueryInterface(IDirect3DSwapChain8 *iface, REFIID riid, void **out)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
if (IsEqualGUID(riid, &IID_IDirect3DSwapChain8)
|| IsEqualGUID(riid, &IID_IUnknown))
{
IUnknown_AddRef(iface);
*ppobj = iface;
*out = iface;
return S_OK;
}
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*ppobj = NULL;
*out = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DSwapChain8Impl_AddRef(IDirect3DSwapChain8 *iface)
static ULONG WINAPI d3d8_swapchain_AddRef(IDirect3DSwapChain8 *iface)
{
IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface);
ULONG ref = InterlockedIncrement(&This->ref);
struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
ULONG ref = InterlockedIncrement(&swapchain->refcount);
TRACE("%p increasing refcount to %u.\n", iface, ref);
if (ref == 1)
{
if (This->parentDevice)
IDirect3DDevice8_AddRef(This->parentDevice);
if (swapchain->parent_device)
IDirect3DDevice8_AddRef(swapchain->parent_device);
wined3d_mutex_lock();
wined3d_swapchain_incref(This->wined3d_swapchain);
wined3d_swapchain_incref(swapchain->wined3d_swapchain);
wined3d_mutex_unlock();
}
return ref;
}
static ULONG WINAPI IDirect3DSwapChain8Impl_Release(IDirect3DSwapChain8 *iface)
static ULONG WINAPI d3d8_swapchain_Release(IDirect3DSwapChain8 *iface)
{
IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface);
ULONG ref = InterlockedDecrement(&This->ref);
struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
ULONG ref = InterlockedDecrement(&swapchain->refcount);
TRACE("%p decreasing refcount to %u.\n", iface, ref);
if (!ref)
{
IDirect3DDevice8 *parentDevice = This->parentDevice;
IDirect3DDevice8 *parent_device = swapchain->parent_device;
wined3d_mutex_lock();
wined3d_swapchain_decref(This->wined3d_swapchain);
wined3d_swapchain_decref(swapchain->wined3d_swapchain);
wined3d_mutex_unlock();
if (parentDevice)
IDirect3DDevice8_Release(parentDevice);
if (parent_device)
IDirect3DDevice8_Release(parent_device);
}
return ref;
}
static HRESULT WINAPI IDirect3DSwapChain8Impl_Present(IDirect3DSwapChain8 *iface,
const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride,
const RGNDATA *pDirtyRegion)
static HRESULT WINAPI d3d8_swapchain_Present(IDirect3DSwapChain8 *iface,
const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override,
const RGNDATA *dirty_region)
{
IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface);
struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
HRESULT hr;
TRACE("iface %p, src_rect %p, dst_rect %p, dst_window_override %p, dirty_region %p.\n",
iface, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
TRACE("iface %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p.\n",
iface, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect), dst_window_override, dirty_region);
wined3d_mutex_lock();
hr = wined3d_swapchain_present(This->wined3d_swapchain, pSourceRect,
pDestRect, hDestWindowOverride, pDirtyRegion, 0);
hr = wined3d_swapchain_present(swapchain->wined3d_swapchain, src_rect,
dst_rect, dst_window_override, dirty_region, 0);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(IDirect3DSwapChain8 *iface,
UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8 **ppBackBuffer)
static HRESULT WINAPI d3d8_swapchain_GetBackBuffer(IDirect3DSwapChain8 *iface,
UINT backbuffer_idx, D3DBACKBUFFER_TYPE backbuffer_type, IDirect3DSurface8 **backbuffer)
{
IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface);
struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
struct wined3d_surface *wined3d_surface = NULL;
IDirect3DSurface8Impl *surface_impl;
HRESULT hr;
TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
iface, iBackBuffer, Type, ppBackBuffer);
iface, backbuffer_idx, backbuffer_type, backbuffer);
wined3d_mutex_lock();
hr = wined3d_swapchain_get_back_buffer(This->wined3d_swapchain,
iBackBuffer, (enum wined3d_backbuffer_type)Type, &wined3d_surface);
hr = wined3d_swapchain_get_back_buffer(swapchain->wined3d_swapchain,
backbuffer_idx, (enum wined3d_backbuffer_type)backbuffer_type, &wined3d_surface);
if (SUCCEEDED(hr) && wined3d_surface)
{
surface_impl = wined3d_surface_get_parent(wined3d_surface);
*ppBackBuffer = &surface_impl->IDirect3DSurface8_iface;
IDirect3DSurface8_AddRef(*ppBackBuffer);
*backbuffer = &surface_impl->IDirect3DSurface8_iface;
IDirect3DSurface8_AddRef(*backbuffer);
wined3d_surface_decref(wined3d_surface);
}
wined3d_mutex_unlock();
@ -131,13 +130,13 @@ static HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(IDirect3DSwapChain8
return hr;
}
static const IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl =
static const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl =
{
IDirect3DSwapChain8Impl_QueryInterface,
IDirect3DSwapChain8Impl_AddRef,
IDirect3DSwapChain8Impl_Release,
IDirect3DSwapChain8Impl_Present,
IDirect3DSwapChain8Impl_GetBackBuffer
d3d8_swapchain_QueryInterface,
d3d8_swapchain_AddRef,
d3d8_swapchain_Release,
d3d8_swapchain_Present,
d3d8_swapchain_GetBackBuffer
};
static void STDMETHODCALLTYPE d3d8_swapchain_wined3d_object_released(void *parent)
@ -150,14 +149,14 @@ static const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops =
d3d8_swapchain_wined3d_object_released,
};
HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, struct d3d8_device *device,
HRESULT swapchain_init(struct d3d8_swapchain *swapchain, struct d3d8_device *device,
D3DPRESENT_PARAMETERS *present_parameters)
{
struct wined3d_swapchain_desc desc;
HRESULT hr;
swapchain->ref = 1;
swapchain->IDirect3DSwapChain8_iface.lpVtbl = &Direct3DSwapChain8_Vtbl;
swapchain->refcount = 1;
swapchain->IDirect3DSwapChain8_iface.lpVtbl = &d3d8_swapchain_vtbl;
desc.backbuffer_width = present_parameters->BackBufferWidth;
desc.backbuffer_height = present_parameters->BackBufferHeight;
@ -201,8 +200,8 @@ HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, struct d3d8_device *d
return hr;
}
swapchain->parentDevice = &device->IDirect3DDevice8_iface;
IDirect3DDevice8_AddRef(swapchain->parentDevice);
swapchain->parent_device = &device->IDirect3DDevice8_iface;
IDirect3DDevice8_AddRef(swapchain->parent_device);
return D3D_OK;
}