d3d9: COM cleanup for the IDirect3DVertexBuffer9 iface.

This commit is contained in:
Michael Stefaniuc 2011-07-06 13:29:02 +02:00 committed by Alexandre Julliard
parent 2b3a364e9a
commit 17eccaffbf
3 changed files with 29 additions and 21 deletions

View File

@ -26,7 +26,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
static inline IDirect3DVertexBuffer9Impl *impl_from_IDirect3DVertexBuffer9(IDirect3DVertexBuffer9 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DVertexBuffer9Impl, lpVtbl);
return CONTAINING_RECORD(iface, IDirect3DVertexBuffer9Impl, IDirect3DVertexBuffer9_iface);
}
static HRESULT WINAPI d3d9_vertexbuffer_QueryInterface(IDirect3DVertexBuffer9 *iface, REFIID riid, void **object)
@ -50,7 +50,7 @@ static HRESULT WINAPI d3d9_vertexbuffer_QueryInterface(IDirect3DVertexBuffer9 *i
static ULONG WINAPI d3d9_vertexbuffer_AddRef(IDirect3DVertexBuffer9 *iface)
{
IDirect3DVertexBuffer9Impl *buffer = (IDirect3DVertexBuffer9Impl *)iface;
IDirect3DVertexBuffer9Impl *buffer = impl_from_IDirect3DVertexBuffer9(iface);
ULONG refcount = InterlockedIncrement(&buffer->ref);
TRACE("%p increasing refcount to %u.\n", iface, refcount);
@ -68,7 +68,7 @@ static ULONG WINAPI d3d9_vertexbuffer_AddRef(IDirect3DVertexBuffer9 *iface)
static ULONG WINAPI d3d9_vertexbuffer_Release(IDirect3DVertexBuffer9 *iface)
{
IDirect3DVertexBuffer9Impl *buffer = (IDirect3DVertexBuffer9Impl *)iface;
IDirect3DVertexBuffer9Impl *buffer = impl_from_IDirect3DVertexBuffer9(iface);
ULONG refcount = InterlockedDecrement(&buffer->ref);
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
@ -88,11 +88,14 @@ static ULONG WINAPI d3d9_vertexbuffer_Release(IDirect3DVertexBuffer9 *iface)
return refcount;
}
static HRESULT WINAPI d3d9_vertexbuffer_GetDevice(IDirect3DVertexBuffer9 *iface, IDirect3DDevice9 **device)
static HRESULT WINAPI d3d9_vertexbuffer_GetDevice(IDirect3DVertexBuffer9 *iface,
IDirect3DDevice9 **device)
{
IDirect3DVertexBuffer9Impl *buffer = impl_from_IDirect3DVertexBuffer9(iface);
TRACE("iface %p, device %p.\n", iface, device);
*device = (IDirect3DDevice9 *)((IDirect3DVertexBuffer9Impl *)iface)->parentDevice;
*device = (IDirect3DDevice9 *)buffer->parentDevice;
IDirect3DDevice9_AddRef(*device);
TRACE("Returning device %p.\n", *device);
@ -154,12 +157,13 @@ static HRESULT WINAPI d3d9_vertexbuffer_FreePrivateData(IDirect3DVertexBuffer9 *
static DWORD WINAPI d3d9_vertexbuffer_SetPriority(IDirect3DVertexBuffer9 *iface, DWORD priority)
{
IDirect3DVertexBuffer9Impl *buffer = impl_from_IDirect3DVertexBuffer9(iface);
DWORD previous;
TRACE("iface %p, priority %u.\n", iface, priority);
wined3d_mutex_lock();
previous = wined3d_buffer_set_priority(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer, priority);
previous = wined3d_buffer_set_priority(buffer->wineD3DVertexBuffer, priority);
wined3d_mutex_unlock();
return previous;
@ -167,12 +171,13 @@ static DWORD WINAPI d3d9_vertexbuffer_SetPriority(IDirect3DVertexBuffer9 *iface,
static DWORD WINAPI d3d9_vertexbuffer_GetPriority(IDirect3DVertexBuffer9 *iface)
{
IDirect3DVertexBuffer9Impl *buffer = impl_from_IDirect3DVertexBuffer9(iface);
DWORD priority;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
priority = wined3d_buffer_get_priority(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer);
priority = wined3d_buffer_get_priority(buffer->wineD3DVertexBuffer);
wined3d_mutex_unlock();
return priority;
@ -180,10 +185,12 @@ static DWORD WINAPI d3d9_vertexbuffer_GetPriority(IDirect3DVertexBuffer9 *iface)
static void WINAPI d3d9_vertexbuffer_PreLoad(IDirect3DVertexBuffer9 *iface)
{
IDirect3DVertexBuffer9Impl *buffer = impl_from_IDirect3DVertexBuffer9(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
wined3d_buffer_preload(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer);
wined3d_buffer_preload(buffer->wineD3DVertexBuffer);
wined3d_mutex_unlock();
}
@ -194,17 +201,17 @@ static D3DRESOURCETYPE WINAPI d3d9_vertexbuffer_GetType(IDirect3DVertexBuffer9 *
return D3DRTYPE_VERTEXBUFFER;
}
static HRESULT WINAPI d3d9_vertexbuffer_Lock(IDirect3DVertexBuffer9 *iface,
UINT offset, UINT size, void **data, DWORD flags)
static HRESULT WINAPI d3d9_vertexbuffer_Lock(IDirect3DVertexBuffer9 *iface, UINT offset, UINT size,
void **data, DWORD flags)
{
IDirect3DVertexBuffer9Impl *buffer = impl_from_IDirect3DVertexBuffer9(iface);
HRESULT hr;
TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
iface, offset, size, data, flags);
wined3d_mutex_lock();
hr = wined3d_buffer_map(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer,
offset, size, (BYTE **)data, flags);
hr = wined3d_buffer_map(buffer->wineD3DVertexBuffer, offset, size, (BYTE **)data, flags);
wined3d_mutex_unlock();
return hr;
@ -212,18 +219,21 @@ static HRESULT WINAPI d3d9_vertexbuffer_Lock(IDirect3DVertexBuffer9 *iface,
static HRESULT WINAPI d3d9_vertexbuffer_Unlock(IDirect3DVertexBuffer9 *iface)
{
IDirect3DVertexBuffer9Impl *buffer = impl_from_IDirect3DVertexBuffer9(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
wined3d_buffer_unmap(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer);
wined3d_buffer_unmap(buffer->wineD3DVertexBuffer);
wined3d_mutex_unlock();
return D3D_OK;
}
static HRESULT WINAPI d3d9_vertexbuffer_GetDesc(IDirect3DVertexBuffer9 *iface, D3DVERTEXBUFFER_DESC *desc)
static HRESULT WINAPI d3d9_vertexbuffer_GetDesc(IDirect3DVertexBuffer9 *iface,
D3DVERTEXBUFFER_DESC *desc)
{
IDirect3DVertexBuffer9Impl *buffer = (IDirect3DVertexBuffer9Impl *)iface;
IDirect3DVertexBuffer9Impl *buffer = impl_from_IDirect3DVertexBuffer9(iface);
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
@ -280,7 +290,7 @@ HRESULT vertexbuffer_init(IDirect3DVertexBuffer9Impl *buffer, IDirect3DDevice9Im
{
HRESULT hr;
buffer->lpVtbl = &d3d9_vertexbuffer_vtbl;
buffer->IDirect3DVertexBuffer9_iface.lpVtbl = &d3d9_vertexbuffer_vtbl;
buffer->ref = 1;
buffer->fvf = fvf;

View File

@ -251,10 +251,8 @@ HRESULT surface_init(IDirect3DSurface9Impl *surface, IDirect3DDevice9Impl *devic
*/
typedef struct IDirect3DVertexBuffer9Impl
{
/* IUnknown fields */
const IDirect3DVertexBuffer9Vtbl *lpVtbl;
LONG ref;
IDirect3DVertexBuffer9 IDirect3DVertexBuffer9_iface;
LONG ref;
struct wined3d_buffer *wineD3DVertexBuffer;
IDirect3DDevice9Ex *parentDevice;
DWORD fvf;

View File

@ -853,7 +853,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(IDirect3DDevice9Ex
}
TRACE("Created vertex buffer %p.\n", object);
*buffer = (IDirect3DVertexBuffer9 *)object;
*buffer = &object->IDirect3DVertexBuffer9_iface;
return D3D_OK;
}