Commit 638cf80c authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

d3d8: COM cleanup for the IDirect3DIndexBuffer8 iface.

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