d3d10core: Allow ID3D10Device to be aggregated.

This commit is contained in:
Henri Verbeet 2008-11-12 15:43:46 +01:00 committed by Alexandre Julliard
parent ccf48fff33
commit ed418dc815
2 changed files with 49 additions and 8 deletions

View File

@ -34,9 +34,12 @@ const char *debug_dxgi_format(DXGI_FORMAT format);
/* IDirect3D10Device */
extern const struct ID3D10DeviceVtbl d3d10_device_vtbl;
extern const struct IUnknownVtbl d3d10_device_inner_unkown_vtbl;
struct d3d10_device
{
const struct ID3D10DeviceVtbl *vtbl;
const struct IUnknownVtbl *inner_unknown_vtbl;
IUnknown *outer_unknown;
LONG refcount;
};

View File

@ -24,17 +24,24 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
/* IUnknown methods */
/* Inner IUnknown methods */
static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device *iface, REFIID riid, void **object)
static inline struct d3d10_device *d3d10_device_from_inner_unknown(IUnknown *iface)
{
return (struct d3d10_device *)((char*)iface - FIELD_OFFSET(struct d3d10_device, inner_unknown_vtbl));
}
static HRESULT STDMETHODCALLTYPE d3d10_device_inner_QueryInterface(IUnknown *iface, REFIID riid, void **object)
{
struct d3d10_device *This = d3d10_device_from_inner_unknown(iface);
TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_ID3D10Device))
{
IUnknown_AddRef(iface);
*object = iface;
IUnknown_AddRef((IUnknown *)This);
*object = This;
return S_OK;
}
@ -44,9 +51,9 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device *iface
return E_NOINTERFACE;
}
static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device *iface)
static ULONG STDMETHODCALLTYPE d3d10_device_inner_AddRef(IUnknown *iface)
{
struct d3d10_device *This = (struct d3d10_device *)iface;
struct d3d10_device *This = d3d10_device_from_inner_unknown(iface);
ULONG refcount = InterlockedIncrement(&This->refcount);
TRACE("%p increasing refcount to %u\n", This, refcount);
@ -54,9 +61,9 @@ static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device *iface)
return refcount;
}
static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device *iface)
static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
{
struct d3d10_device *This = (struct d3d10_device *)iface;
struct d3d10_device *This = d3d10_device_from_inner_unknown(iface);
ULONG refcount = InterlockedDecrement(&This->refcount);
TRACE("%p decreasing refcount to %u\n", This, refcount);
@ -64,6 +71,29 @@ static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device *iface)
return refcount;
}
/* IUnknown methods */
static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device *iface, REFIID riid, void **object)
{
struct d3d10_device *This = (struct d3d10_device *)iface;
TRACE("Forwarding to outer IUnknown\n");
return IUnknown_QueryInterface(This->outer_unknown, riid, object);
}
static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device *iface)
{
struct d3d10_device *This = (struct d3d10_device *)iface;
TRACE("Forwarding to outer IUnknown\n");
return IUnknown_AddRef(This->outer_unknown);
}
static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device *iface)
{
struct d3d10_device *This = (struct d3d10_device *)iface;
TRACE("Forwarding to outer IUnknown\n");
return IUnknown_Release(This->outer_unknown);
}
/* ID3D10Device methods */
static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device *iface,
@ -845,3 +875,11 @@ const struct ID3D10DeviceVtbl d3d10_device_vtbl =
d3d10_device_SetTextFilterSize,
d3d10_device_GetTextFilterSize,
};
const struct IUnknownVtbl d3d10_device_inner_unkown_vtbl =
{
/* IUnknown methods */
d3d10_device_inner_QueryInterface,
d3d10_device_inner_AddRef,
d3d10_device_inner_Release,
};