d3d9: COM cleanup for the IDirect3DQuery9 iface.

This commit is contained in:
Michael Stefaniuc 2011-04-12 04:04:02 +02:00 committed by Alexandre Julliard
parent 0f10e1b344
commit 78ea105b85
3 changed files with 36 additions and 24 deletions

View File

@ -465,15 +465,14 @@ HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader,
* IDirect3DPixelShader implementation structure * IDirect3DPixelShader implementation structure
*/ */
typedef struct IDirect3DQuery9Impl { typedef struct IDirect3DQuery9Impl {
/* IUnknown fields */ IDirect3DQuery9 IDirect3DQuery9_iface;
const IDirect3DQuery9Vtbl *lpVtbl;
LONG ref; LONG ref;
/* IDirect3DQuery9 fields */ /* IDirect3DQuery9 fields */
struct wined3d_query *wineD3DQuery; struct wined3d_query *wineD3DQuery;
/* Parent reference */ /* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice; IDirect3DDevice9Ex *parentDevice;
} IDirect3DQuery9Impl; } IDirect3DQuery9Impl;
HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device,

View File

@ -2706,8 +2706,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(IDirect3DDevice9Ex *iface
} }
TRACE("Created query %p.\n", object); TRACE("Created query %p.\n", object);
if (query) *query = (IDirect3DQuery9 *)object; if (query) *query = &object->IDirect3DQuery9_iface;
else IDirect3DQuery9_Release((IDirect3DQuery9 *)object); else IDirect3DQuery9_Release(&object->IDirect3DQuery9_iface);
return D3D_OK; return D3D_OK;
} }

View File

@ -25,9 +25,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d9); WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DQuery9 IUnknown parts follow: */ static inline IDirect3DQuery9Impl *impl_from_IDirect3DQuery9(IDirect3DQuery9 *iface)
static HRESULT WINAPI IDirect3DQuery9Impl_QueryInterface(LPDIRECT3DQUERY9 iface, REFIID riid, LPVOID* ppobj) { {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; return CONTAINING_RECORD(iface, IDirect3DQuery9Impl, IDirect3DQuery9_iface);
}
static HRESULT WINAPI IDirect3DQuery9Impl_QueryInterface(IDirect3DQuery9 *iface, REFIID riid,
void **ppobj)
{
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj); TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -43,8 +49,9 @@ static HRESULT WINAPI IDirect3DQuery9Impl_QueryInterface(LPDIRECT3DQUERY9 iface,
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI IDirect3DQuery9Impl_AddRef(LPDIRECT3DQUERY9 iface) { static ULONG WINAPI IDirect3DQuery9Impl_AddRef(IDirect3DQuery9 *iface)
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; {
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
ULONG ref = InterlockedIncrement(&This->ref); ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref); TRACE("%p increasing refcount to %u.\n", iface, ref);
@ -52,8 +59,9 @@ static ULONG WINAPI IDirect3DQuery9Impl_AddRef(LPDIRECT3DQUERY9 iface) {
return ref; return ref;
} }
static ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) { static ULONG WINAPI IDirect3DQuery9Impl_Release(IDirect3DQuery9 *iface)
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; {
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", iface, ref); TRACE("%p decreasing refcount to %u.\n", iface, ref);
@ -69,10 +77,10 @@ static ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) {
return ref; return ref;
} }
/* IDirect3DQuery9 Interface follow: */ static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface,
static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface, IDirect3DDevice9 **device) IDirect3DDevice9 **device)
{ {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
TRACE("iface %p, device %p.\n", iface, device); TRACE("iface %p, device %p.\n", iface, device);
@ -84,8 +92,9 @@ static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface, IDir
return D3D_OK; return D3D_OK;
} }
static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(LPDIRECT3DQUERY9 iface) { static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(IDirect3DQuery9 *iface)
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; {
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
@ -97,8 +106,9 @@ static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(LPDIRECT3DQUERY9 iface) {
return hr; return hr;
} }
static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(LPDIRECT3DQUERY9 iface) { static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(IDirect3DQuery9 *iface)
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; {
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
DWORD ret; DWORD ret;
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
@ -110,8 +120,9 @@ static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(LPDIRECT3DQUERY9 iface) {
return ret; return ret;
} }
static HRESULT WINAPI IDirect3DQuery9Impl_Issue(LPDIRECT3DQUERY9 iface, DWORD dwIssueFlags) { static HRESULT WINAPI IDirect3DQuery9Impl_Issue(IDirect3DQuery9 *iface, DWORD dwIssueFlags)
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; {
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p, flags %#x.\n", iface, dwIssueFlags); TRACE("iface %p, flags %#x.\n", iface, dwIssueFlags);
@ -123,8 +134,10 @@ static HRESULT WINAPI IDirect3DQuery9Impl_Issue(LPDIRECT3DQUERY9 iface, DWORD dw
return hr; return hr;
} }
static HRESULT WINAPI IDirect3DQuery9Impl_GetData(LPDIRECT3DQUERY9 iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) { static HRESULT WINAPI IDirect3DQuery9Impl_GetData(IDirect3DQuery9 *iface, void *pData,
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; DWORD dwSize, DWORD dwGetDataFlags)
{
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p, data %p, size %u, flags %#x.\n", TRACE("iface %p, data %p, size %u, flags %#x.\n",
@ -154,7 +167,7 @@ HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, D3D
{ {
HRESULT hr; HRESULT hr;
query->lpVtbl = &Direct3DQuery9_Vtbl; query->IDirect3DQuery9_iface.lpVtbl = &Direct3DQuery9_Vtbl;
query->ref = 1; query->ref = 1;
wined3d_mutex_lock(); wined3d_mutex_lock();