From 78ea105b85c18b7e840a6a600898e5f256d99319 Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Tue, 12 Apr 2011 04:04:02 +0200 Subject: [PATCH] d3d9: COM cleanup for the IDirect3DQuery9 iface. --- dlls/d3d9/d3d9_private.h | 5 ++-- dlls/d3d9/device.c | 4 ++-- dlls/d3d9/query.c | 51 +++++++++++++++++++++++++--------------- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index f1c0a8ca21d..0947a54d2d4 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -465,15 +465,14 @@ HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, * IDirect3DPixelShader implementation structure */ typedef struct IDirect3DQuery9Impl { - /* IUnknown fields */ - const IDirect3DQuery9Vtbl *lpVtbl; + IDirect3DQuery9 IDirect3DQuery9_iface; LONG ref; /* IDirect3DQuery9 fields */ struct wined3d_query *wineD3DQuery; /* Parent reference */ - LPDIRECT3DDEVICE9EX parentDevice; + IDirect3DDevice9Ex *parentDevice; } IDirect3DQuery9Impl; HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 9565815228a..bd5b1676dac 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2706,8 +2706,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(IDirect3DDevice9Ex *iface } TRACE("Created query %p.\n", object); - if (query) *query = (IDirect3DQuery9 *)object; - else IDirect3DQuery9_Release((IDirect3DQuery9 *)object); + if (query) *query = &object->IDirect3DQuery9_iface; + else IDirect3DQuery9_Release(&object->IDirect3DQuery9_iface); return D3D_OK; } diff --git a/dlls/d3d9/query.c b/dlls/d3d9/query.c index 34debd90999..918c21fd1bf 100644 --- a/dlls/d3d9/query.c +++ b/dlls/d3d9/query.c @@ -25,9 +25,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d9); -/* IDirect3DQuery9 IUnknown parts follow: */ -static HRESULT WINAPI IDirect3DQuery9Impl_QueryInterface(LPDIRECT3DQUERY9 iface, REFIID riid, LPVOID* ppobj) { - IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; +static inline IDirect3DQuery9Impl *impl_from_IDirect3DQuery9(IDirect3DQuery9 *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); @@ -43,8 +49,9 @@ static HRESULT WINAPI IDirect3DQuery9Impl_QueryInterface(LPDIRECT3DQUERY9 iface, return E_NOINTERFACE; } -static ULONG WINAPI IDirect3DQuery9Impl_AddRef(LPDIRECT3DQUERY9 iface) { - IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; +static ULONG WINAPI IDirect3DQuery9Impl_AddRef(IDirect3DQuery9 *iface) +{ + IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); ULONG ref = InterlockedIncrement(&This->ref); TRACE("%p increasing refcount to %u.\n", iface, ref); @@ -52,8 +59,9 @@ static ULONG WINAPI IDirect3DQuery9Impl_AddRef(LPDIRECT3DQUERY9 iface) { return ref; } -static ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) { - IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; +static ULONG WINAPI IDirect3DQuery9Impl_Release(IDirect3DQuery9 *iface) +{ + IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("%p decreasing refcount to %u.\n", iface, ref); @@ -69,10 +77,10 @@ static ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) { return ref; } -/* IDirect3DQuery9 Interface follow: */ -static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface, IDirect3DDevice9 **device) +static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface, + IDirect3DDevice9 **device) { - IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; + IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); TRACE("iface %p, device %p.\n", iface, device); @@ -84,8 +92,9 @@ static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface, IDir return D3D_OK; } -static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(LPDIRECT3DQUERY9 iface) { - IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; +static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(IDirect3DQuery9 *iface) +{ + IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); HRESULT hr; TRACE("iface %p.\n", iface); @@ -97,8 +106,9 @@ static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(LPDIRECT3DQUERY9 iface) { return hr; } -static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(LPDIRECT3DQUERY9 iface) { - IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; +static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(IDirect3DQuery9 *iface) +{ + IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); DWORD ret; TRACE("iface %p.\n", iface); @@ -110,8 +120,9 @@ static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(LPDIRECT3DQUERY9 iface) { return ret; } -static HRESULT WINAPI IDirect3DQuery9Impl_Issue(LPDIRECT3DQUERY9 iface, DWORD dwIssueFlags) { - IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; +static HRESULT WINAPI IDirect3DQuery9Impl_Issue(IDirect3DQuery9 *iface, DWORD dwIssueFlags) +{ + IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); HRESULT hr; TRACE("iface %p, flags %#x.\n", iface, dwIssueFlags); @@ -123,8 +134,10 @@ static HRESULT WINAPI IDirect3DQuery9Impl_Issue(LPDIRECT3DQUERY9 iface, DWORD dw return hr; } -static HRESULT WINAPI IDirect3DQuery9Impl_GetData(LPDIRECT3DQUERY9 iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) { - IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface; +static HRESULT WINAPI IDirect3DQuery9Impl_GetData(IDirect3DQuery9 *iface, void *pData, + DWORD dwSize, DWORD dwGetDataFlags) +{ + IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); HRESULT hr; TRACE("iface %p, data %p, size %u, flags %#x.\n", @@ -154,7 +167,7 @@ HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, D3D { HRESULT hr; - query->lpVtbl = &Direct3DQuery9_Vtbl; + query->IDirect3DQuery9_iface.lpVtbl = &Direct3DQuery9_Vtbl; query->ref = 1; wined3d_mutex_lock();