Commit 56fffd06 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9: Get rid of IDirect3DQuery9Impl.

parent 2f2995de
...@@ -299,24 +299,14 @@ HRESULT pixelshader_init(struct d3d9_pixelshader *shader, ...@@ -299,24 +299,14 @@ HRESULT pixelshader_init(struct d3d9_pixelshader *shader,
struct d3d9_device *device, const DWORD *byte_code) DECLSPEC_HIDDEN; struct d3d9_device *device, const DWORD *byte_code) DECLSPEC_HIDDEN;
struct d3d9_pixelshader *unsafe_impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface) DECLSPEC_HIDDEN; struct d3d9_pixelshader *unsafe_impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface) DECLSPEC_HIDDEN;
/* --------------- */ struct d3d9_query
/* IDirect3DQuery9 */ {
/* --------------- */ IDirect3DQuery9 IDirect3DQuery9_iface;
LONG refcount;
/***************************************************************************** struct wined3d_query *wined3d_query;
* IDirect3DPixelShader implementation structure IDirect3DDevice9Ex *parent_device;
*/ };
typedef struct IDirect3DQuery9Impl {
IDirect3DQuery9 IDirect3DQuery9_iface;
LONG ref;
/* IDirect3DQuery9 fields */
struct wined3d_query *wineD3DQuery;
/* Parent reference */
IDirect3DDevice9Ex *parentDevice;
} IDirect3DQuery9Impl;
HRESULT query_init(IDirect3DQuery9Impl *query, struct d3d9_device *device, D3DQUERYTYPE type) DECLSPEC_HIDDEN; HRESULT query_init(struct d3d9_query *query, struct d3d9_device *device, D3DQUERYTYPE type) DECLSPEC_HIDDEN;
#endif /* __WINE_D3D9_PRIVATE_H */ #endif /* __WINE_D3D9_PRIVATE_H */
...@@ -2760,7 +2760,7 @@ static HRESULT WINAPI d3d9_device_DeletePatch(IDirect3DDevice9Ex *iface, UINT ha ...@@ -2760,7 +2760,7 @@ static HRESULT WINAPI d3d9_device_DeletePatch(IDirect3DDevice9Ex *iface, UINT ha
static HRESULT WINAPI d3d9_device_CreateQuery(IDirect3DDevice9Ex *iface, D3DQUERYTYPE type, IDirect3DQuery9 **query) static HRESULT WINAPI d3d9_device_CreateQuery(IDirect3DDevice9Ex *iface, D3DQUERYTYPE type, IDirect3DQuery9 **query)
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DQuery9Impl *object; struct d3d9_query *object;
HRESULT hr; HRESULT hr;
TRACE("iface %p, type %#x, query %p.\n", iface, type, query); TRACE("iface %p, type %#x, query %p.\n", iface, type, query);
......
...@@ -25,66 +25,65 @@ ...@@ -25,66 +25,65 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d9); WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
static inline IDirect3DQuery9Impl *impl_from_IDirect3DQuery9(IDirect3DQuery9 *iface) static inline struct d3d9_query *impl_from_IDirect3DQuery9(IDirect3DQuery9 *iface)
{ {
return CONTAINING_RECORD(iface, IDirect3DQuery9Impl, IDirect3DQuery9_iface); return CONTAINING_RECORD(iface, struct d3d9_query, IDirect3DQuery9_iface);
} }
static HRESULT WINAPI IDirect3DQuery9Impl_QueryInterface(IDirect3DQuery9 *iface, REFIID riid, static HRESULT WINAPI d3d9_query_QueryInterface(IDirect3DQuery9 *iface, REFIID riid, void **out)
void **ppobj)
{ {
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), out);
if (IsEqualGUID(riid, &IID_IDirect3DQuery9) if (IsEqualGUID(riid, &IID_IDirect3DQuery9)
|| IsEqualGUID(riid, &IID_IUnknown)) || IsEqualGUID(riid, &IID_IUnknown))
{ {
IDirect3DQuery9_AddRef(iface); IDirect3DQuery9_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 IDirect3DQuery9Impl_AddRef(IDirect3DQuery9 *iface) static ULONG WINAPI d3d9_query_AddRef(IDirect3DQuery9 *iface)
{ {
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); struct d3d9_query *query = impl_from_IDirect3DQuery9(iface);
ULONG ref = InterlockedIncrement(&This->ref); ULONG refcount = InterlockedIncrement(&query->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 IDirect3DQuery9Impl_Release(IDirect3DQuery9 *iface) static ULONG WINAPI d3d9_query_Release(IDirect3DQuery9 *iface)
{ {
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); struct d3d9_query *query = impl_from_IDirect3DQuery9(iface);
ULONG ref = InterlockedDecrement(&This->ref); ULONG refcount = InterlockedDecrement(&query->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_query_decref(This->wineD3DQuery); wined3d_query_decref(query->wined3d_query);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(This->parentDevice); IDirect3DDevice9Ex_Release(query->parent_device);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, query);
} }
return ref; return refcount;
} }
static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface, static HRESULT WINAPI d3d9_query_GetDevice(IDirect3DQuery9 *iface, IDirect3DDevice9 **device)
IDirect3DDevice9 **device)
{ {
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); struct d3d9_query *query = impl_from_IDirect3DQuery9(iface);
TRACE("iface %p, device %p.\n", iface, device); TRACE("iface %p, device %p.\n", iface, device);
*device = (IDirect3DDevice9 *)This->parentDevice; *device = (IDirect3DDevice9 *)query->parent_device;
IDirect3DDevice9_AddRef(*device); IDirect3DDevice9_AddRef(*device);
TRACE("Returning device %p.\n", *device); TRACE("Returning device %p.\n", *device);
...@@ -92,86 +91,85 @@ static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface, ...@@ -92,86 +91,85 @@ static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface,
return D3D_OK; return D3D_OK;
} }
static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(IDirect3DQuery9 *iface) static D3DQUERYTYPE WINAPI d3d9_query_GetType(IDirect3DQuery9 *iface)
{ {
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); struct d3d9_query *query = impl_from_IDirect3DQuery9(iface);
D3DQUERYTYPE type; D3DQUERYTYPE type;
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
type = wined3d_query_get_type(This->wineD3DQuery); type = wined3d_query_get_type(query->wined3d_query);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return type; return type;
} }
static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(IDirect3DQuery9 *iface) static DWORD WINAPI d3d9_query_GetDataSize(IDirect3DQuery9 *iface)
{ {
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); struct d3d9_query *query = impl_from_IDirect3DQuery9(iface);
DWORD ret; DWORD ret;
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
ret = wined3d_query_get_data_size(This->wineD3DQuery); ret = wined3d_query_get_data_size(query->wined3d_query);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return ret; return ret;
} }
static HRESULT WINAPI IDirect3DQuery9Impl_Issue(IDirect3DQuery9 *iface, DWORD dwIssueFlags) static HRESULT WINAPI d3d9_query_Issue(IDirect3DQuery9 *iface, DWORD flags)
{ {
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); struct d3d9_query *query = impl_from_IDirect3DQuery9(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p, flags %#x.\n", iface, dwIssueFlags); TRACE("iface %p, flags %#x.\n", iface, flags);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_query_issue(This->wineD3DQuery, dwIssueFlags); hr = wined3d_query_issue(query->wined3d_query, flags);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
} }
static HRESULT WINAPI IDirect3DQuery9Impl_GetData(IDirect3DQuery9 *iface, void *pData, static HRESULT WINAPI d3d9_query_GetData(IDirect3DQuery9 *iface, void *data, DWORD size, DWORD flags)
DWORD dwSize, DWORD dwGetDataFlags)
{ {
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); struct d3d9_query *query = 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",
iface, pData, dwSize, dwGetDataFlags); iface, data, size, flags);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_query_get_data(This->wineD3DQuery, pData, dwSize, dwGetDataFlags); hr = wined3d_query_get_data(query->wined3d_query, data, size, flags);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
} }
static const IDirect3DQuery9Vtbl Direct3DQuery9_Vtbl = static const struct IDirect3DQuery9Vtbl d3d9_query_vtbl =
{ {
IDirect3DQuery9Impl_QueryInterface, d3d9_query_QueryInterface,
IDirect3DQuery9Impl_AddRef, d3d9_query_AddRef,
IDirect3DQuery9Impl_Release, d3d9_query_Release,
IDirect3DQuery9Impl_GetDevice, d3d9_query_GetDevice,
IDirect3DQuery9Impl_GetType, d3d9_query_GetType,
IDirect3DQuery9Impl_GetDataSize, d3d9_query_GetDataSize,
IDirect3DQuery9Impl_Issue, d3d9_query_Issue,
IDirect3DQuery9Impl_GetData d3d9_query_GetData,
}; };
HRESULT query_init(IDirect3DQuery9Impl *query, struct d3d9_device *device, D3DQUERYTYPE type) HRESULT query_init(struct d3d9_query *query, struct d3d9_device *device, D3DQUERYTYPE type)
{ {
HRESULT hr; HRESULT hr;
query->IDirect3DQuery9_iface.lpVtbl = &Direct3DQuery9_Vtbl; query->IDirect3DQuery9_iface.lpVtbl = &d3d9_query_vtbl;
query->ref = 1; query->refcount = 1;
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_query_create(device->wined3d_device, type, &query->wineD3DQuery); hr = wined3d_query_create(device->wined3d_device, type, &query->wined3d_query);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
if (FAILED(hr)) if (FAILED(hr))
{ {
...@@ -179,8 +177,8 @@ HRESULT query_init(IDirect3DQuery9Impl *query, struct d3d9_device *device, D3DQU ...@@ -179,8 +177,8 @@ HRESULT query_init(IDirect3DQuery9Impl *query, struct d3d9_device *device, D3DQU
return hr; return hr;
} }
query->parentDevice = &device->IDirect3DDevice9Ex_iface; query->parent_device = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(query->parentDevice); IDirect3DDevice9Ex_AddRef(query->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