Commit bfb63a86 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9: Add a separate function for query initialization.

parent cdb7a94a
......@@ -228,9 +228,6 @@ extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(IDirect3DDevi
UINT StartRegister, const BOOL *pConstantData, UINT BoolCount) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(IDirect3DDevice9Ex *iface,
UINT StartRegister, BOOL *pConstantData, UINT BoolCount) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(IDirect3DDevice9Ex *iface,
D3DQUERYTYPE Type, IDirect3DQuery9 **ppQuery) DECLSPEC_HIDDEN;
/* ---------------- */
/* IDirect3DVolume9 */
......@@ -564,4 +561,7 @@ typedef struct IDirect3DQuery9Impl {
LPDIRECT3DDEVICE9EX parentDevice;
} IDirect3DQuery9Impl;
HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device,
D3DQUERYTYPE type) DECLSPEC_HIDDEN;
#endif /* __WINE_D3D9_PRIVATE_H */
......@@ -2178,6 +2178,37 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9EX ifa
return hr;
}
static HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(IDirect3DDevice9Ex *iface,
D3DQUERYTYPE type, IDirect3DQuery9 **query)
{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DQuery9Impl *object;
HRESULT hr;
TRACE("iface %p, type %#x, query %p.\n", iface, type, query);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
ERR("Failed to allocate query memory.\n");
return E_OUTOFMEMORY;
}
hr = query_init(object, This, type);
if (FAILED(hr))
{
WARN("Failed to initialize query, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created query %p.\n", object);
if (query) *query = (IDirect3DQuery9 *)object;
else IDirect3DQuery9_Release((IDirect3DQuery9 *)object);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_SetConvolutionMonoKernel(IDirect3DDevice9Ex *iface,
UINT width, UINT height, float *rows, float *columns)
{
......
......@@ -150,49 +150,24 @@ static const IDirect3DQuery9Vtbl Direct3DQuery9_Vtbl =
IDirect3DQuery9Impl_GetData
};
HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, D3DQUERYTYPE type)
{
HRESULT hr;
/* IDirect3DDevice9 IDirect3DQuery9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9EX iface, D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DQuery9Impl *object = NULL;
HRESULT hr = D3D_OK;
TRACE("iface %p, type %#x, query %p.\n", iface, Type, ppQuery);
query->lpVtbl = &Direct3DQuery9_Vtbl;
query->ref = 1;
if (!ppQuery)
{
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, NULL, NULL);
hr = IWineD3DDevice_CreateQuery(device->WineD3DDevice, type, &query->wineD3DQuery, (IUnknown *)query);
wined3d_mutex_unlock();
if (FAILED(hr))
{
WARN("Failed to create wined3d query, hr %#x.\n", hr);
return hr;
}
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DQuery9Impl));
if (NULL == object) {
ERR("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DQuery9_Vtbl;
object->ref = 1;
query->parentDevice = (IDirect3DDevice9Ex *)device;
IDirect3DDevice9Ex_AddRef(query->parentDevice);
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, &object->wineD3DQuery, (IUnknown *)object);
wined3d_mutex_unlock();
if (FAILED(hr)) {
/* free up object */
WARN("(%p) call to IWineD3DDevice_CreateQuery failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
} else {
IDirect3DDevice9Ex_AddRef(iface);
object->parentDevice = iface;
*ppQuery = (LPDIRECT3DQUERY9) object;
TRACE("(%p) : Created query %p\n", This , object);
}
TRACE("(%p) : returning %x\n", This, hr);
return hr;
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