wined3d: Remove COM from the query implementation.

This commit is contained in:
Henri Verbeet 2011-02-03 20:14:06 +01:00 committed by Alexandre Julliard
parent 831a29d250
commit a5fe3610ad
6 changed files with 64 additions and 109 deletions

View File

@ -506,7 +506,7 @@ typedef struct IDirect3DQuery9Impl {
LONG ref;
/* IDirect3DQuery9 fields */
IWineD3DQuery *wineD3DQuery;
struct wined3d_query *wineD3DQuery;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;

View File

@ -60,7 +60,7 @@ static ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) {
if (ref == 0) {
wined3d_mutex_lock();
IWineD3DQuery_Release(This->wineD3DQuery);
wined3d_query_decref(This->wineD3DQuery);
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(This->parentDevice);
@ -91,7 +91,7 @@ static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(LPDIRECT3DQUERY9 iface) {
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DQuery_GetType(This->wineD3DQuery);
hr = wined3d_query_get_type(This->wineD3DQuery);
wined3d_mutex_unlock();
return hr;
@ -104,7 +104,7 @@ static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(LPDIRECT3DQUERY9 iface) {
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DQuery_GetDataSize(This->wineD3DQuery);
ret = wined3d_query_get_data_size(This->wineD3DQuery);
wined3d_mutex_unlock();
return ret;
@ -117,7 +117,7 @@ static HRESULT WINAPI IDirect3DQuery9Impl_Issue(LPDIRECT3DQUERY9 iface, DWORD dw
TRACE("iface %p, flags %#x.\n", iface, dwIssueFlags);
wined3d_mutex_lock();
hr = IWineD3DQuery_Issue(This->wineD3DQuery, dwIssueFlags);
hr = wined3d_query_issue(This->wineD3DQuery, dwIssueFlags);
wined3d_mutex_unlock();
return hr;
@ -131,7 +131,7 @@ static HRESULT WINAPI IDirect3DQuery9Impl_GetData(LPDIRECT3DQUERY9 iface, void*
iface, pData, dwSize, dwGetDataFlags);
wined3d_mutex_lock();
hr = IWineD3DQuery_GetData(This->wineD3DQuery, pData, dwSize, dwGetDataFlags);
hr = wined3d_query_get_data(This->wineD3DQuery, pData, dwSize, dwGetDataFlags);
wined3d_mutex_unlock();
return hr;

View File

@ -230,90 +230,70 @@ void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDevice
context_release(context);
}
static HRESULT WINAPI IWineD3DQueryImpl_QueryInterface(IWineD3DQuery *iface, REFIID riid, void **object)
ULONG CDECL wined3d_query_incref(struct wined3d_query *query)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
ULONG refcount = InterlockedIncrement(&query->ref);
if (IsEqualGUID(riid, &IID_IWineD3DQuery)
|| IsEqualGUID(riid, &IID_IUnknown))
{
IUnknown_AddRef(iface);
*object = iface;
return S_OK;
}
TRACE("%p increasing refcount to %u.\n", query, refcount);
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*object = NULL;
return E_NOINTERFACE;
return refcount;
}
static ULONG WINAPI IWineD3DQueryImpl_AddRef(IWineD3DQuery *iface) {
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
TRACE("(%p) : AddRef increasing from %d\n", This, This->ref);
return InterlockedIncrement(&This->ref);
}
ULONG CDECL wined3d_query_decref(struct wined3d_query *query)
{
ULONG refcount = InterlockedIncrement(&query->ref);
static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) {
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", query, refcount);
if (!ref)
if (!refcount)
{
/* Queries are specific to the GL context that created them. Not
* deleting the query will obviously leak it, but that's still better
* than potentially deleting a different query with the same id in this
* context, and (still) leaking the actual query. */
if (This->type == WINED3DQUERYTYPE_EVENT)
if (query->type == WINED3DQUERYTYPE_EVENT)
{
struct wined3d_event_query *query = This->extendedData;
if (query) wined3d_event_query_destroy(query);
struct wined3d_event_query *event_query = query->extendedData;
if (event_query) wined3d_event_query_destroy(event_query);
}
else if (This->type == WINED3DQUERYTYPE_OCCLUSION)
else if (query->type == WINED3DQUERYTYPE_OCCLUSION)
{
struct wined3d_occlusion_query *query = This->extendedData;
struct wined3d_occlusion_query *oq = query->extendedData;
if (query->context) context_free_occlusion_query(query);
HeapFree(GetProcessHeap(), 0, This->extendedData);
if (oq->context) context_free_occlusion_query(oq);
HeapFree(GetProcessHeap(), 0, query->extendedData);
}
HeapFree(GetProcessHeap(), 0, This);
HeapFree(GetProcessHeap(), 0, query);
}
return ref;
return refcount;
}
static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery *iface,
void *data, DWORD data_size, DWORD flags)
HRESULT CDECL wined3d_query_get_data(struct wined3d_query *query,
void *data, UINT data_size, DWORD flags)
{
struct IWineD3DQueryImpl *query = (struct IWineD3DQueryImpl *)iface;
TRACE("iface %p, data %p, data_size %u, flags %#x.\n",
iface, data, data_size, flags);
TRACE("query %p, data %p, data_size %u, flags %#x.\n",
query, data, data_size, flags);
return query->query_ops->query_get_data(query, data, data_size, flags);
}
static DWORD WINAPI IWineD3DQueryImpl_GetDataSize(IWineD3DQuery *iface)
UINT CDECL wined3d_query_get_data_size(const struct wined3d_query *query)
{
struct IWineD3DQueryImpl *query = (struct IWineD3DQueryImpl *)iface;
TRACE("iface %p.\n", iface);
TRACE("query %p.\n", query);
return query->data_size;
}
static HRESULT WINAPI IWineD3DQueryImpl_Issue(IWineD3DQuery *iface, DWORD flags)
HRESULT CDECL wined3d_query_issue(struct wined3d_query *query, DWORD flags)
{
struct IWineD3DQueryImpl *query = (struct IWineD3DQueryImpl *)iface;
TRACE("iface %p, flags %#x.\n", iface, flags);
TRACE("query %p, flags %#x.\n", query, flags);
return query->query_ops->query_issue(query, flags);
}
static HRESULT wined3d_occlusion_query_ops_get_data(struct IWineD3DQueryImpl *query,
static HRESULT wined3d_occlusion_query_ops_get_data(struct wined3d_query *query,
void *pData, DWORD dwSize, DWORD flags)
{
struct wined3d_occlusion_query *oq = query->extendedData;
@ -432,12 +412,14 @@ static HRESULT wined3d_event_query_ops_get_data(IWineD3DQueryImpl *query,
return S_OK;
}
static WINED3DQUERYTYPE WINAPI IWineD3DQueryImpl_GetType(IWineD3DQuery* iface){
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
return This->type;
WINED3DQUERYTYPE CDECL wined3d_query_get_type(const struct wined3d_query *query)
{
TRACE("query %p.\n", query);
return query->type;
}
static HRESULT wined3d_event_query_ops_issue(struct IWineD3DQueryImpl *query, DWORD flags)
static HRESULT wined3d_event_query_ops_issue(struct wined3d_query *query, DWORD flags)
{
TRACE("query %p, flags %#x.\n", query, flags);
@ -465,7 +447,7 @@ static HRESULT wined3d_event_query_ops_issue(struct IWineD3DQueryImpl *query, DW
return WINED3D_OK;
}
static HRESULT wined3d_occlusion_query_ops_issue(struct IWineD3DQueryImpl *query, DWORD flags)
static HRESULT wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD flags)
{
IWineD3DDeviceImpl *device = query->device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
@ -565,19 +547,6 @@ static const struct wined3d_query_ops occlusion_query_ops =
wined3d_occlusion_query_ops_issue,
};
static const struct IWineD3DQueryVtbl IWineD3DQuery_Vtbl =
{
/*** IUnknown methods ***/
IWineD3DQueryImpl_QueryInterface,
IWineD3DQueryImpl_AddRef,
IWineD3DQueryImpl_Release,
/*** IWineD3Dquery methods ***/
IWineD3DQueryImpl_GetData,
IWineD3DQueryImpl_GetDataSize,
IWineD3DQueryImpl_GetType,
IWineD3DQueryImpl_Issue,
};
HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device, WINED3DQUERYTYPE type)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
@ -639,7 +608,6 @@ HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device, WINED3D
return WINED3DERR_NOTAVAILABLE;
}
query->lpVtbl = &IWineD3DQuery_Vtbl;
query->type = type;
query->state = QUERY_CREATED;
query->device = device;

View File

@ -37,6 +37,13 @@
@ cdecl wined3d_palette_incref(ptr)
@ cdecl wined3d_palette_set_entries(ptr long long long ptr)
@ cdecl wined3d_query_decref(ptr)
@ cdecl wined3d_query_get_data(ptr ptr long long)
@ cdecl wined3d_query_get_data_size(ptr)
@ cdecl wined3d_query_get_type(ptr)
@ cdecl wined3d_query_incref(ptr)
@ cdecl wined3d_query_issue(ptr long)
@ cdecl wined3d_stateblock_apply(ptr)
@ cdecl wined3d_stateblock_capture(ptr)
@ cdecl wined3d_stateblock_decref(ptr)

View File

@ -58,6 +58,8 @@ typedef struct IWineD3DSwapChainImpl IWineD3DSwapChainImpl;
struct IWineD3DBaseShaderImpl;
struct IWineD3DBaseTextureImpl;
struct IWineD3DResourceImpl;
typedef struct wined3d_query IWineD3DQueryImpl;
typedef struct wined3d_query IWineD3DQuery;
/* Texture format fixups */
@ -2468,31 +2470,22 @@ enum query_state {
QUERY_BUILDING
};
struct IWineD3DQueryImpl;
struct wined3d_query_ops
{
HRESULT (*query_get_data)(struct IWineD3DQueryImpl *query, void *data, DWORD data_size, DWORD flags);
HRESULT (*query_issue)(struct IWineD3DQueryImpl *query, DWORD flags);
HRESULT (*query_get_data)(struct wined3d_query *query, void *data, DWORD data_size, DWORD flags);
HRESULT (*query_issue)(struct wined3d_query *query, DWORD flags);
};
/*****************************************************************************
* IWineD3DQueryImpl implementation structure (extends IUnknown)
*/
typedef struct IWineD3DQueryImpl
struct wined3d_query
{
const IWineD3DQueryVtbl *lpVtbl;
LONG ref; /* Note: Ref counting not required */
LONG ref;
const struct wined3d_query_ops *query_ops;
IWineD3DDeviceImpl *device;
/* IWineD3DQuery fields */
enum query_state state;
WINED3DQUERYTYPE type;
DWORD data_size;
void *extendedData;
} IWineD3DQueryImpl;
};
HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device, WINED3DQUERYTYPE type) DECLSPEC_HIDDEN;

View File

@ -2113,6 +2113,7 @@ interface IWineD3DDevice;
struct wined3d;
struct wined3d_clipper;
struct wined3d_palette;
struct wined3d_query;
struct wined3d_stateblock;
struct wined3d_vertex_declaration;
@ -2469,27 +2470,6 @@ interface IWineD3DVolumeTexture : IWineD3DBaseTexture
);
}
[
object,
local,
uuid(905ddbac-6f30-11d9-c687-00046142c14f)
]
interface IWineD3DQuery : IUnknown
{
HRESULT GetData(
[out] void *data,
[in] DWORD data_size,
[in] DWORD flags
);
DWORD GetDataSize(
);
WINED3DQUERYTYPE GetType(
);
HRESULT Issue(
DWORD flags
);
}
[
object,
local,
@ -2704,7 +2684,7 @@ interface IWineD3DDevice : IUnknown
);
HRESULT CreateQuery(
[in] WINED3DQUERYTYPE type,
[out] IWineD3DQuery **query
[out] struct wined3d_query **query
);
HRESULT CreateSwapChain(
[in] WINED3DPRESENT_PARAMETERS *present_parameters,
@ -3266,6 +3246,13 @@ ULONG __cdecl wined3d_palette_incref(struct wined3d_palette *palette);
HRESULT __cdecl wined3d_palette_set_entries(struct wined3d_palette *palette,
DWORD flags, DWORD start, DWORD count, const PALETTEENTRY *entries);
ULONG __cdecl wined3d_query_decref(struct wined3d_query *query);
HRESULT __cdecl wined3d_query_get_data(struct wined3d_query *query, void *data, UINT data_size, DWORD flags);
UINT __cdecl wined3d_query_get_data_size(const struct wined3d_query *query);
WINED3DQUERYTYPE __cdecl wined3d_query_get_type(const struct wined3d_query *query);
ULONG __cdecl wined3d_query_incref(struct wined3d_query *query);
HRESULT __cdecl wined3d_query_issue(struct wined3d_query *query, DWORD flags);
HRESULT __cdecl wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock);
HRESULT __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);