d3d9: Get rid of IDirect3DStateBlock9Impl.
This commit is contained in:
parent
176d27e889
commit
79d62ca1fb
|
@ -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;
|
||||
struct d3d9_texture *unsafe_impl_from_IDirect3DBaseTexture9(IDirect3DBaseTexture9 *iface) DECLSPEC_HIDDEN;
|
||||
|
||||
/* ----------------------- */
|
||||
/* IDirect3DStateBlock9 */
|
||||
/* ----------------------- */
|
||||
|
||||
/*****************************************************************************
|
||||
* IDirect3DStateBlock9 implementation structure
|
||||
*/
|
||||
typedef struct IDirect3DStateBlock9Impl {
|
||||
struct d3d9_stateblock
|
||||
{
|
||||
IDirect3DStateBlock9 IDirect3DStateBlock9_iface;
|
||||
LONG ref;
|
||||
|
||||
/* IDirect3DStateBlock9 fields */
|
||||
LONG refcount;
|
||||
struct wined3d_stateblock *wined3d_stateblock;
|
||||
IDirect3DDevice9Ex *parent_device;
|
||||
};
|
||||
|
||||
/* Parent reference */
|
||||
IDirect3DDevice9Ex *parentDevice;
|
||||
} IDirect3DStateBlock9Impl;
|
||||
|
||||
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) DECLSPEC_HIDDEN;
|
||||
|
||||
/* --------------------------- */
|
||||
|
|
|
@ -1525,7 +1525,7 @@ static HRESULT WINAPI d3d9_device_CreateStateBlock(IDirect3DDevice9Ex *iface,
|
|||
D3DSTATEBLOCKTYPE type, IDirect3DStateBlock9 **stateblock)
|
||||
{
|
||||
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
||||
IDirect3DStateBlock9Impl *object;
|
||||
struct d3d9_stateblock *object;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, type %#x, stateblock %p.\n", iface, type, stateblock);
|
||||
|
@ -1575,7 +1575,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDire
|
|||
{
|
||||
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
||||
struct wined3d_stateblock *wined3d_stateblock;
|
||||
IDirect3DStateBlock9Impl *object;
|
||||
struct d3d9_stateblock *object;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, stateblock %p.\n", iface, stateblock);
|
||||
|
|
|
@ -25,67 +25,66 @@
|
|||
|
||||
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,
|
||||
REFIID riid, void **ppobj)
|
||||
static HRESULT WINAPI d3d9_stateblock_QueryInterface(IDirect3DStateBlock9 *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_IDirect3DStateBlock9)
|
||||
|| IsEqualGUID(riid, &IID_IUnknown))
|
||||
{
|
||||
IDirect3DStateBlock9_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 IDirect3DStateBlock9Impl_AddRef(IDirect3DStateBlock9 *iface)
|
||||
static ULONG WINAPI d3d9_stateblock_AddRef(IDirect3DStateBlock9 *iface)
|
||||
{
|
||||
IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface);
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface);
|
||||
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);
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface);
|
||||
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_stateblock_decref(This->wined3d_stateblock);
|
||||
wined3d_stateblock_decref(stateblock->wined3d_stateblock);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
IDirect3DDevice9Ex_Release(This->parentDevice);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
IDirect3DDevice9Ex_Release(stateblock->parent_device);
|
||||
HeapFree(GetProcessHeap(), 0, stateblock);
|
||||
}
|
||||
return ref;
|
||||
|
||||
return refcount;
|
||||
}
|
||||
|
||||
/* IDirect3DStateBlock9 Interface follow: */
|
||||
static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(IDirect3DStateBlock9 *iface,
|
||||
IDirect3DDevice9 **device)
|
||||
static HRESULT WINAPI d3d9_stateblock_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);
|
||||
|
||||
*device = (IDirect3DDevice9 *)This->parentDevice;
|
||||
*device = (IDirect3DDevice9 *)stateblock->parent_device;
|
||||
IDirect3DDevice9_AddRef(*device);
|
||||
|
||||
TRACE("Returning device %p.\n", *device);
|
||||
|
@ -93,54 +92,54 @@ static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(IDirect3DStateBlock9 *i
|
|||
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;
|
||||
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
hr = wined3d_stateblock_capture(This->wined3d_stateblock);
|
||||
hr = wined3d_stateblock_capture(stateblock->wined3d_stateblock);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
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;
|
||||
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
hr = wined3d_stateblock_apply(This->wined3d_stateblock);
|
||||
hr = wined3d_stateblock_apply(stateblock->wined3d_stateblock);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
static const IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl =
|
||||
static const struct IDirect3DStateBlock9Vtbl d3d9_stateblock_vtbl =
|
||||
{
|
||||
/* IUnknown */
|
||||
IDirect3DStateBlock9Impl_QueryInterface,
|
||||
IDirect3DStateBlock9Impl_AddRef,
|
||||
IDirect3DStateBlock9Impl_Release,
|
||||
d3d9_stateblock_QueryInterface,
|
||||
d3d9_stateblock_AddRef,
|
||||
d3d9_stateblock_Release,
|
||||
/* IDirect3DStateBlock9 */
|
||||
IDirect3DStateBlock9Impl_GetDevice,
|
||||
IDirect3DStateBlock9Impl_Capture,
|
||||
IDirect3DStateBlock9Impl_Apply
|
||||
d3d9_stateblock_GetDevice,
|
||||
d3d9_stateblock_Capture,
|
||||
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)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
stateblock->IDirect3DStateBlock9_iface.lpVtbl = &Direct3DStateBlock9_Vtbl;
|
||||
stateblock->ref = 1;
|
||||
stateblock->IDirect3DStateBlock9_iface.lpVtbl = &d3d9_stateblock_vtbl;
|
||||
stateblock->refcount = 1;
|
||||
|
||||
if (wined3d_stateblock)
|
||||
{
|
||||
|
@ -159,8 +158,8 @@ HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, struct d3d9_device
|
|||
}
|
||||
}
|
||||
|
||||
stateblock->parentDevice = &device->IDirect3DDevice9Ex_iface;
|
||||
IDirect3DDevice9Ex_AddRef(stateblock->parentDevice);
|
||||
stateblock->parent_device = &device->IDirect3DDevice9Ex_iface;
|
||||
IDirect3DDevice9Ex_AddRef(stateblock->parent_device);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue