d3d8: COM cleanup for the IDirect3DIndexBuffer8 iface.

This commit is contained in:
Michael Stefaniuc 2011-07-05 00:46:30 +02:00 committed by Alexandre Julliard
parent c1eeeec2d2
commit 638cf80c4f
3 changed files with 29 additions and 21 deletions

View File

@ -300,7 +300,7 @@ HRESULT vertexbuffer_init(IDirect3DVertexBuffer8Impl *buffer, IDirect3DDevice8Im
static inline IDirect3DIndexBuffer8Impl *impl_from_IDirect3DIndexBuffer8(IDirect3DIndexBuffer8 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DIndexBuffer8Impl, lpVtbl);
return CONTAINING_RECORD(iface, IDirect3DIndexBuffer8Impl, IDirect3DIndexBuffer8_iface);
}
static HRESULT WINAPI d3d8_indexbuffer_QueryInterface(IDirect3DIndexBuffer8 *iface, REFIID riid, void **object)
@ -324,7 +324,7 @@ static HRESULT WINAPI d3d8_indexbuffer_QueryInterface(IDirect3DIndexBuffer8 *ifa
static ULONG WINAPI d3d8_indexbuffer_AddRef(IDirect3DIndexBuffer8 *iface)
{
IDirect3DIndexBuffer8Impl *buffer = (IDirect3DIndexBuffer8Impl *)iface;
IDirect3DIndexBuffer8Impl *buffer = impl_from_IDirect3DIndexBuffer8(iface);
ULONG refcount = InterlockedIncrement(&buffer->ref);
TRACE("%p increasing refcount to %u.\n", iface, refcount);
@ -342,7 +342,7 @@ static ULONG WINAPI d3d8_indexbuffer_AddRef(IDirect3DIndexBuffer8 *iface)
static ULONG WINAPI d3d8_indexbuffer_Release(IDirect3DIndexBuffer8 *iface)
{
IDirect3DIndexBuffer8Impl *buffer = (IDirect3DIndexBuffer8Impl *)iface;
IDirect3DIndexBuffer8Impl *buffer = impl_from_IDirect3DIndexBuffer8(iface);
ULONG refcount = InterlockedDecrement(&buffer->ref);
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
@ -362,11 +362,14 @@ static ULONG WINAPI d3d8_indexbuffer_Release(IDirect3DIndexBuffer8 *iface)
return refcount;
}
static HRESULT WINAPI d3d8_indexbuffer_GetDevice(IDirect3DIndexBuffer8 *iface, IDirect3DDevice8 **device)
static HRESULT WINAPI d3d8_indexbuffer_GetDevice(IDirect3DIndexBuffer8 *iface,
IDirect3DDevice8 **device)
{
IDirect3DIndexBuffer8Impl *buffer = impl_from_IDirect3DIndexBuffer8(iface);
TRACE("iface %p, device %p.\n", iface, device);
*device = (IDirect3DDevice8 *)((IDirect3DIndexBuffer8Impl *)iface)->parentDevice;
*device = buffer->parentDevice;
IDirect3DDevice8_AddRef(*device);
TRACE("Returning device %p.\n", *device);
@ -428,12 +431,13 @@ static HRESULT WINAPI d3d8_indexbuffer_FreePrivateData(IDirect3DIndexBuffer8 *if
static DWORD WINAPI d3d8_indexbuffer_SetPriority(IDirect3DIndexBuffer8 *iface, DWORD priority)
{
IDirect3DIndexBuffer8Impl *buffer = impl_from_IDirect3DIndexBuffer8(iface);
DWORD previous;
TRACE("iface %p, priority %u.\n", iface, priority);
wined3d_mutex_lock();
previous = wined3d_buffer_set_priority(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer, priority);
previous = wined3d_buffer_set_priority(buffer->wineD3DIndexBuffer, priority);
wined3d_mutex_unlock();
return previous;
@ -441,12 +445,13 @@ static DWORD WINAPI d3d8_indexbuffer_SetPriority(IDirect3DIndexBuffer8 *iface, D
static DWORD WINAPI d3d8_indexbuffer_GetPriority(IDirect3DIndexBuffer8 *iface)
{
IDirect3DIndexBuffer8Impl *buffer = impl_from_IDirect3DIndexBuffer8(iface);
DWORD priority;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
priority = wined3d_buffer_get_priority(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer);
priority = wined3d_buffer_get_priority(buffer->wineD3DIndexBuffer);
wined3d_mutex_unlock();
return priority;
@ -454,10 +459,12 @@ static DWORD WINAPI d3d8_indexbuffer_GetPriority(IDirect3DIndexBuffer8 *iface)
static void WINAPI d3d8_indexbuffer_PreLoad(IDirect3DIndexBuffer8 *iface)
{
IDirect3DIndexBuffer8Impl *buffer = impl_from_IDirect3DIndexBuffer8(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
wined3d_buffer_preload(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer);
wined3d_buffer_preload(buffer->wineD3DIndexBuffer);
wined3d_mutex_unlock();
}
@ -468,17 +475,17 @@ static D3DRESOURCETYPE WINAPI d3d8_indexbuffer_GetType(IDirect3DIndexBuffer8 *if
return D3DRTYPE_INDEXBUFFER;
}
static HRESULT WINAPI d3d8_indexbuffer_Lock(IDirect3DIndexBuffer8 *iface,
UINT offset, UINT size, BYTE **data, DWORD flags)
static HRESULT WINAPI d3d8_indexbuffer_Lock(IDirect3DIndexBuffer8 *iface, UINT offset, UINT size,
BYTE **data, DWORD flags)
{
IDirect3DIndexBuffer8Impl *buffer = impl_from_IDirect3DIndexBuffer8(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(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer,
offset, size, data, flags);
hr = wined3d_buffer_map(buffer->wineD3DIndexBuffer, offset, size, data, flags);
wined3d_mutex_unlock();
return hr;
@ -486,18 +493,21 @@ static HRESULT WINAPI d3d8_indexbuffer_Lock(IDirect3DIndexBuffer8 *iface,
static HRESULT WINAPI d3d8_indexbuffer_Unlock(IDirect3DIndexBuffer8 *iface)
{
IDirect3DIndexBuffer8Impl *buffer = impl_from_IDirect3DIndexBuffer8(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
wined3d_buffer_unmap(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer);
wined3d_buffer_unmap(buffer->wineD3DIndexBuffer);
wined3d_mutex_unlock();
return D3D_OK;
}
static HRESULT WINAPI d3d8_indexbuffer_GetDesc(IDirect3DIndexBuffer8 *iface, D3DINDEXBUFFER_DESC *desc)
static HRESULT WINAPI d3d8_indexbuffer_GetDesc(IDirect3DIndexBuffer8 *iface,
D3DINDEXBUFFER_DESC *desc)
{
IDirect3DIndexBuffer8Impl *buffer = (IDirect3DIndexBuffer8Impl *)iface;
IDirect3DIndexBuffer8Impl *buffer = impl_from_IDirect3DIndexBuffer8(iface);
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
@ -553,7 +563,7 @@ HRESULT indexbuffer_init(IDirect3DIndexBuffer8Impl *buffer, IDirect3DDevice8Impl
{
HRESULT hr;
buffer->lpVtbl = &d3d8_indexbuffer_vtbl;
buffer->IDirect3DIndexBuffer8_iface.lpVtbl = &d3d8_indexbuffer_vtbl;
buffer->ref = 1;
buffer->format = wined3dformat_from_d3dformat(format);

View File

@ -287,10 +287,8 @@ HRESULT vertexbuffer_init(IDirect3DVertexBuffer8Impl *buffer, IDirect3DDevice8Im
*/
struct IDirect3DIndexBuffer8Impl
{
/* IUnknown fields */
const IDirect3DIndexBuffer8Vtbl *lpVtbl;
IDirect3DIndexBuffer8 IDirect3DIndexBuffer8_iface;
LONG ref;
struct wined3d_buffer *wineD3DIndexBuffer;
IDirect3DDevice8 *parentDevice;
enum wined3d_format_id format;

View File

@ -870,7 +870,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(IDirect3DDevice8 *i
}
TRACE("Created index buffer %p.\n", object);
*buffer = (IDirect3DIndexBuffer8 *)object;
*buffer = &object->IDirect3DIndexBuffer8_iface;
return D3D_OK;
}