Commit 79d62ca1 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9: Get rid of IDirect3DStateBlock9Impl.

parent 176d27e8
...@@ -245,25 +245,15 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *dev ...@@ -245,25 +245,15 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *dev
UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN; UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN;
struct d3d9_texture *unsafe_impl_from_IDirect3DBaseTexture9(IDirect3DBaseTexture9 *iface) DECLSPEC_HIDDEN; struct d3d9_texture *unsafe_impl_from_IDirect3DBaseTexture9(IDirect3DBaseTexture9 *iface) DECLSPEC_HIDDEN;
/* ----------------------- */ struct d3d9_stateblock
/* IDirect3DStateBlock9 */ {
/* ----------------------- */ IDirect3DStateBlock9 IDirect3DStateBlock9_iface;
LONG refcount;
/*****************************************************************************
* IDirect3DStateBlock9 implementation structure
*/
typedef struct IDirect3DStateBlock9Impl {
IDirect3DStateBlock9 IDirect3DStateBlock9_iface;
LONG ref;
/* IDirect3DStateBlock9 fields */
struct wined3d_stateblock *wined3d_stateblock; struct wined3d_stateblock *wined3d_stateblock;
IDirect3DDevice9Ex *parent_device;
};
/* Parent reference */ HRESULT stateblock_init(struct d3d9_stateblock *stateblock, struct d3d9_device *device,
IDirect3DDevice9Ex *parentDevice;
} IDirect3DStateBlock9Impl;
HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, struct d3d9_device *device,
D3DSTATEBLOCKTYPE type, struct wined3d_stateblock *wined3d_stateblock) DECLSPEC_HIDDEN; D3DSTATEBLOCKTYPE type, struct wined3d_stateblock *wined3d_stateblock) DECLSPEC_HIDDEN;
/* --------------------------- */ /* --------------------------- */
......
...@@ -1525,7 +1525,7 @@ static HRESULT WINAPI d3d9_device_CreateStateBlock(IDirect3DDevice9Ex *iface, ...@@ -1525,7 +1525,7 @@ static HRESULT WINAPI d3d9_device_CreateStateBlock(IDirect3DDevice9Ex *iface,
D3DSTATEBLOCKTYPE type, IDirect3DStateBlock9 **stateblock) D3DSTATEBLOCKTYPE type, IDirect3DStateBlock9 **stateblock)
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DStateBlock9Impl *object; struct d3d9_stateblock *object;
HRESULT hr; HRESULT hr;
TRACE("iface %p, type %#x, stateblock %p.\n", iface, type, stateblock); TRACE("iface %p, type %#x, stateblock %p.\n", iface, type, stateblock);
...@@ -1575,7 +1575,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDire ...@@ -1575,7 +1575,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDire
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_stateblock *wined3d_stateblock; struct wined3d_stateblock *wined3d_stateblock;
IDirect3DStateBlock9Impl *object; struct d3d9_stateblock *object;
HRESULT hr; HRESULT hr;
TRACE("iface %p, stateblock %p.\n", iface, stateblock); TRACE("iface %p, stateblock %p.\n", iface, stateblock);
......
...@@ -25,67 +25,66 @@ ...@@ -25,67 +25,66 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d9); WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
static inline IDirect3DStateBlock9Impl *impl_from_IDirect3DStateBlock9(IDirect3DStateBlock9 *iface) static inline struct d3d9_stateblock *impl_from_IDirect3DStateBlock9(IDirect3DStateBlock9 *iface)
{ {
return CONTAINING_RECORD(iface, IDirect3DStateBlock9Impl, IDirect3DStateBlock9_iface); return CONTAINING_RECORD(iface, struct d3d9_stateblock, IDirect3DStateBlock9_iface);
} }
static HRESULT WINAPI IDirect3DStateBlock9Impl_QueryInterface(IDirect3DStateBlock9 *iface, static HRESULT WINAPI d3d9_stateblock_QueryInterface(IDirect3DStateBlock9 *iface, REFIID riid, void **out)
REFIID riid, void **ppobj)
{ {
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_IDirect3DStateBlock9) if (IsEqualGUID(riid, &IID_IDirect3DStateBlock9)
|| IsEqualGUID(riid, &IID_IUnknown)) || IsEqualGUID(riid, &IID_IUnknown))
{ {
IDirect3DStateBlock9_AddRef(iface); IDirect3DStateBlock9_AddRef(iface);
*ppobj = iface; *out = iface;
return S_OK; return S_OK;
} }
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*ppobj = NULL; *out = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI IDirect3DStateBlock9Impl_AddRef(IDirect3DStateBlock9 *iface) static ULONG WINAPI d3d9_stateblock_AddRef(IDirect3DStateBlock9 *iface)
{ {
IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface); struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface);
ULONG ref = InterlockedIncrement(&This->ref); ULONG refcount = InterlockedIncrement(&stateblock->refcount);
TRACE("%p increasing refcount to %u.\n", iface, ref); TRACE("%p increasing refcount to %u.\n", iface, refcount);
return ref; return refcount;
} }
static ULONG WINAPI IDirect3DStateBlock9Impl_Release(IDirect3DStateBlock9 *iface) static ULONG WINAPI d3d9_stateblock_Release(IDirect3DStateBlock9 *iface)
{ {
IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface); struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface);
ULONG ref = InterlockedDecrement(&This->ref); ULONG refcount = InterlockedDecrement(&stateblock->refcount);
TRACE("%p decreasing refcount to %u.\n", iface, ref); TRACE("%p decreasing refcount to %u.\n", iface, refcount);
if (ref == 0) { if (!refcount)
{
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_stateblock_decref(This->wined3d_stateblock); wined3d_stateblock_decref(stateblock->wined3d_stateblock);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(This->parentDevice); IDirect3DDevice9Ex_Release(stateblock->parent_device);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, stateblock);
} }
return ref;
return refcount;
} }
/* IDirect3DStateBlock9 Interface follow: */ static HRESULT WINAPI d3d9_stateblock_GetDevice(IDirect3DStateBlock9 *iface, IDirect3DDevice9 **device)
static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(IDirect3DStateBlock9 *iface,
IDirect3DDevice9 **device)
{ {
IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface); struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface);
TRACE("iface %p, device %p.\n", iface, device); TRACE("iface %p, device %p.\n", iface, device);
*device = (IDirect3DDevice9 *)This->parentDevice; *device = (IDirect3DDevice9 *)stateblock->parent_device;
IDirect3DDevice9_AddRef(*device); IDirect3DDevice9_AddRef(*device);
TRACE("Returning device %p.\n", *device); TRACE("Returning device %p.\n", *device);
...@@ -93,54 +92,54 @@ static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(IDirect3DStateBlock9 *i ...@@ -93,54 +92,54 @@ static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(IDirect3DStateBlock9 *i
return D3D_OK; return D3D_OK;
} }
static HRESULT WINAPI IDirect3DStateBlock9Impl_Capture(IDirect3DStateBlock9 *iface) static HRESULT WINAPI d3d9_stateblock_Capture(IDirect3DStateBlock9 *iface)
{ {
IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface); struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_stateblock_capture(This->wined3d_stateblock); hr = wined3d_stateblock_capture(stateblock->wined3d_stateblock);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
} }
static HRESULT WINAPI IDirect3DStateBlock9Impl_Apply(IDirect3DStateBlock9 *iface) static HRESULT WINAPI d3d9_stateblock_Apply(IDirect3DStateBlock9 *iface)
{ {
IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface); struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_stateblock_apply(This->wined3d_stateblock); hr = wined3d_stateblock_apply(stateblock->wined3d_stateblock);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
} }
static const IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl = static const struct IDirect3DStateBlock9Vtbl d3d9_stateblock_vtbl =
{ {
/* IUnknown */ /* IUnknown */
IDirect3DStateBlock9Impl_QueryInterface, d3d9_stateblock_QueryInterface,
IDirect3DStateBlock9Impl_AddRef, d3d9_stateblock_AddRef,
IDirect3DStateBlock9Impl_Release, d3d9_stateblock_Release,
/* IDirect3DStateBlock9 */ /* IDirect3DStateBlock9 */
IDirect3DStateBlock9Impl_GetDevice, d3d9_stateblock_GetDevice,
IDirect3DStateBlock9Impl_Capture, d3d9_stateblock_Capture,
IDirect3DStateBlock9Impl_Apply d3d9_stateblock_Apply,
}; };
HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, struct d3d9_device *device, HRESULT stateblock_init(struct d3d9_stateblock *stateblock, struct d3d9_device *device,
D3DSTATEBLOCKTYPE type, struct wined3d_stateblock *wined3d_stateblock) D3DSTATEBLOCKTYPE type, struct wined3d_stateblock *wined3d_stateblock)
{ {
HRESULT hr; HRESULT hr;
stateblock->IDirect3DStateBlock9_iface.lpVtbl = &Direct3DStateBlock9_Vtbl; stateblock->IDirect3DStateBlock9_iface.lpVtbl = &d3d9_stateblock_vtbl;
stateblock->ref = 1; stateblock->refcount = 1;
if (wined3d_stateblock) if (wined3d_stateblock)
{ {
...@@ -159,8 +158,8 @@ HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, struct d3d9_device ...@@ -159,8 +158,8 @@ HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, struct d3d9_device
} }
} }
stateblock->parentDevice = &device->IDirect3DDevice9Ex_iface; stateblock->parent_device = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(stateblock->parentDevice); IDirect3DDevice9Ex_AddRef(stateblock->parent_device);
return D3D_OK; return D3D_OK;
} }
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