diff --git a/dlls/d3d8/buffer.c b/dlls/d3d8/buffer.c index cd68f6cc231..f10ec68413b 100644 --- a/dlls/d3d8/buffer.c +++ b/dlls/d3d8/buffer.c @@ -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); diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index e84b60acd7c..6ec67126005 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -287,10 +287,8 @@ HRESULT vertexbuffer_init(IDirect3DVertexBuffer8Impl *buffer, IDirect3DDevice8Im */ struct IDirect3DIndexBuffer8Impl { - /* IUnknown fields */ - const IDirect3DIndexBuffer8Vtbl *lpVtbl; - LONG ref; - + IDirect3DIndexBuffer8 IDirect3DIndexBuffer8_iface; + LONG ref; struct wined3d_buffer *wineD3DIndexBuffer; IDirect3DDevice8 *parentDevice; enum wined3d_format_id format; diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index adae05ed7c0..3537cb7fb26 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -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; }