Commit 60223057 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

ddraw: COM cleanup for the IDirect3DVertexBuffer iface.

parent 8e272741
...@@ -4983,7 +4983,7 @@ static HRESULT WINAPI d3d3_CreateVertexBuffer(IDirect3D3 *iface, D3DVERTEXBUFFER ...@@ -4983,7 +4983,7 @@ static HRESULT WINAPI d3d3_CreateVertexBuffer(IDirect3D3 *iface, D3DVERTEXBUFFER
if (hr == D3D_OK) if (hr == D3D_OK)
{ {
TRACE("Created vertex buffer %p.\n", object); TRACE("Created vertex buffer %p.\n", object);
*vertex_buffer = (IDirect3DVertexBuffer *)object; *vertex_buffer = &object->IDirect3DVertexBuffer_iface;
} }
else else
WARN("Failed to create vertex buffer, hr %#x.\n", hr); WARN("Failed to create vertex buffer, hr %#x.\n", hr);
......
...@@ -521,8 +521,8 @@ struct IDirect3DVertexBufferImpl ...@@ -521,8 +521,8 @@ struct IDirect3DVertexBufferImpl
{ {
/*** IUnknown Methods ***/ /*** IUnknown Methods ***/
const IDirect3DVertexBuffer7Vtbl *lpVtbl; const IDirect3DVertexBuffer7Vtbl *lpVtbl;
const IDirect3DVertexBufferVtbl *IDirect3DVertexBuffer_vtbl; IDirect3DVertexBuffer IDirect3DVertexBuffer_iface;
LONG ref; LONG ref;
/*** WineD3D and ddraw links ***/ /*** WineD3D and ddraw links ***/
struct wined3d_buffer *wineD3DVertexBuffer; struct wined3d_buffer *wineD3DVertexBuffer;
...@@ -539,12 +539,6 @@ HRESULT d3d_vertex_buffer_create(IDirect3DVertexBufferImpl **vertex_buf, IDirect ...@@ -539,12 +539,6 @@ HRESULT d3d_vertex_buffer_create(IDirect3DVertexBufferImpl **vertex_buf, IDirect
IDirect3DVertexBufferImpl *unsafe_impl_from_IDirect3DVertexBuffer(IDirect3DVertexBuffer *iface) DECLSPEC_HIDDEN; IDirect3DVertexBufferImpl *unsafe_impl_from_IDirect3DVertexBuffer(IDirect3DVertexBuffer *iface) DECLSPEC_HIDDEN;
IDirect3DVertexBufferImpl *unsafe_impl_from_IDirect3DVertexBuffer7(IDirect3DVertexBuffer7 *iface) DECLSPEC_HIDDEN; IDirect3DVertexBufferImpl *unsafe_impl_from_IDirect3DVertexBuffer7(IDirect3DVertexBuffer7 *iface) DECLSPEC_HIDDEN;
static inline IDirect3DVertexBufferImpl *vb_from_vb1(IDirect3DVertexBuffer *iface)
{
return (IDirect3DVertexBufferImpl *)((char*)iface
- FIELD_OFFSET(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer_vtbl));
}
/***************************************************************************** /*****************************************************************************
* Helper functions from utils.c * Helper functions from utils.c
*****************************************************************************/ *****************************************************************************/
......
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(ddraw); WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
static inline IDirect3DVertexBufferImpl *impl_from_IDirect3DVertexBuffer(IDirect3DVertexBuffer *iface)
{
return CONTAINING_RECORD(iface, IDirect3DVertexBufferImpl, IDirect3DVertexBuffer_iface);
}
/***************************************************************************** /*****************************************************************************
* IUnknown Methods * IUnknown Methods
*****************************************************************************/ *****************************************************************************/
...@@ -67,7 +72,7 @@ IDirect3DVertexBufferImpl_QueryInterface(IDirect3DVertexBuffer7 *iface, ...@@ -67,7 +72,7 @@ IDirect3DVertexBufferImpl_QueryInterface(IDirect3DVertexBuffer7 *iface,
if ( IsEqualGUID( &IID_IDirect3DVertexBuffer, riid ) ) if ( IsEqualGUID( &IID_IDirect3DVertexBuffer, riid ) )
{ {
IUnknown_AddRef(iface); IUnknown_AddRef(iface);
*obj = &This->IDirect3DVertexBuffer_vtbl; *obj = &This->IDirect3DVertexBuffer_iface;
TRACE(" Creating IDirect3DVertexBuffer interface %p\n", *obj); TRACE(" Creating IDirect3DVertexBuffer interface %p\n", *obj);
return S_OK; return S_OK;
} }
...@@ -85,9 +90,11 @@ IDirect3DVertexBufferImpl_QueryInterface(IDirect3DVertexBuffer7 *iface, ...@@ -85,9 +90,11 @@ IDirect3DVertexBufferImpl_QueryInterface(IDirect3DVertexBuffer7 *iface,
static HRESULT WINAPI IDirect3DVertexBufferImpl_1_QueryInterface(IDirect3DVertexBuffer *iface, static HRESULT WINAPI IDirect3DVertexBufferImpl_1_QueryInterface(IDirect3DVertexBuffer *iface,
REFIID riid, void **obj) REFIID riid, void **obj)
{ {
IDirect3DVertexBufferImpl *This = impl_from_IDirect3DVertexBuffer(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obj); TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obj);
return IDirect3DVertexBuffer7_QueryInterface((IDirect3DVertexBuffer7 *)vb_from_vb1(iface), riid, obj); return IDirect3DVertexBuffer7_QueryInterface((IDirect3DVertexBuffer7 *)This, riid, obj);
} }
/***************************************************************************** /*****************************************************************************
...@@ -112,9 +119,11 @@ IDirect3DVertexBufferImpl_AddRef(IDirect3DVertexBuffer7 *iface) ...@@ -112,9 +119,11 @@ IDirect3DVertexBufferImpl_AddRef(IDirect3DVertexBuffer7 *iface)
static ULONG WINAPI IDirect3DVertexBufferImpl_1_AddRef(IDirect3DVertexBuffer *iface) static ULONG WINAPI IDirect3DVertexBufferImpl_1_AddRef(IDirect3DVertexBuffer *iface)
{ {
IDirect3DVertexBufferImpl *This = impl_from_IDirect3DVertexBuffer(iface);
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
return IDirect3DVertexBuffer7_AddRef((IDirect3DVertexBuffer7 *)vb_from_vb1(iface)); return IDirect3DVertexBuffer7_AddRef((IDirect3DVertexBuffer7 *)This);
} }
...@@ -164,9 +173,11 @@ IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface) ...@@ -164,9 +173,11 @@ IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface)
static ULONG WINAPI IDirect3DVertexBufferImpl_1_Release(IDirect3DVertexBuffer *iface) static ULONG WINAPI IDirect3DVertexBufferImpl_1_Release(IDirect3DVertexBuffer *iface)
{ {
IDirect3DVertexBufferImpl *This = impl_from_IDirect3DVertexBuffer(iface);
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
return IDirect3DVertexBuffer7_Release((IDirect3DVertexBuffer7 *)vb_from_vb1(iface)); return IDirect3DVertexBuffer7_Release((IDirect3DVertexBuffer7 *)This);
} }
/***************************************************************************** /*****************************************************************************
...@@ -231,9 +242,11 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface, ...@@ -231,9 +242,11 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface,
static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Lock(IDirect3DVertexBuffer *iface, DWORD Flags, static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Lock(IDirect3DVertexBuffer *iface, DWORD Flags,
void **Data, DWORD *Size) void **Data, DWORD *Size)
{ {
IDirect3DVertexBufferImpl *This = impl_from_IDirect3DVertexBuffer(iface);
TRACE("iface %p, flags %#x, data %p, data_size %p.\n", iface, Flags, Data, Size); TRACE("iface %p, flags %#x, data %p, data_size %p.\n", iface, Flags, Data, Size);
return IDirect3DVertexBuffer7_Lock((IDirect3DVertexBuffer7 *)vb_from_vb1(iface), Flags, Data, Size); return IDirect3DVertexBuffer7_Lock((IDirect3DVertexBuffer7 *)This, Flags, Data, Size);
} }
/***************************************************************************** /*****************************************************************************
...@@ -261,9 +274,11 @@ IDirect3DVertexBufferImpl_Unlock(IDirect3DVertexBuffer7 *iface) ...@@ -261,9 +274,11 @@ IDirect3DVertexBufferImpl_Unlock(IDirect3DVertexBuffer7 *iface)
static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Unlock(IDirect3DVertexBuffer *iface) static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Unlock(IDirect3DVertexBuffer *iface)
{ {
IDirect3DVertexBufferImpl *This = impl_from_IDirect3DVertexBuffer(iface);
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
return IDirect3DVertexBuffer7_Unlock((IDirect3DVertexBuffer7 *)vb_from_vb1(iface)); return IDirect3DVertexBuffer7_Unlock((IDirect3DVertexBuffer7 *)This);
} }
...@@ -341,13 +356,14 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_1_ProcessVertices(IDirect3DVerte ...@@ -341,13 +356,14 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_1_ProcessVertices(IDirect3DVerte
DWORD VertexOp, DWORD DestIndex, DWORD Count, IDirect3DVertexBuffer *SrcBuffer, DWORD VertexOp, DWORD DestIndex, DWORD Count, IDirect3DVertexBuffer *SrcBuffer,
DWORD SrcIndex, IDirect3DDevice3 *D3DDevice, DWORD Flags) DWORD SrcIndex, IDirect3DDevice3 *D3DDevice, DWORD Flags)
{ {
IDirect3DVertexBufferImpl *This = impl_from_IDirect3DVertexBuffer(iface);
IDirect3DVertexBufferImpl *Src = unsafe_impl_from_IDirect3DVertexBuffer(SrcBuffer); IDirect3DVertexBufferImpl *Src = unsafe_impl_from_IDirect3DVertexBuffer(SrcBuffer);
IDirect3DDeviceImpl *D3D = D3DDevice ? device_from_device3(D3DDevice) : NULL; IDirect3DDeviceImpl *D3D = D3DDevice ? device_from_device3(D3DDevice) : NULL;
TRACE("iface %p, vertex_op %#x, dst_idx %u, count %u, src_buffer %p, src_idx %u, device %p, flags %#x.\n", TRACE("iface %p, vertex_op %#x, dst_idx %u, count %u, src_buffer %p, src_idx %u, device %p, flags %#x.\n",
iface, VertexOp, DestIndex, Count, SrcBuffer, SrcIndex, D3DDevice, Flags); iface, VertexOp, DestIndex, Count, SrcBuffer, SrcIndex, D3DDevice, Flags);
return IDirect3DVertexBuffer7_ProcessVertices((IDirect3DVertexBuffer7 *)vb_from_vb1(iface), VertexOp, return IDirect3DVertexBuffer7_ProcessVertices((IDirect3DVertexBuffer7 *)This, VertexOp,
DestIndex, Count, (IDirect3DVertexBuffer7 *)Src, SrcIndex, (IDirect3DDevice7 *)D3D, Flags); DestIndex, Count, (IDirect3DVertexBuffer7 *)Src, SrcIndex, (IDirect3DDevice7 *)D3D, Flags);
} }
...@@ -392,9 +408,11 @@ IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface, ...@@ -392,9 +408,11 @@ IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface,
static HRESULT WINAPI IDirect3DVertexBufferImpl_1_GetVertexBufferDesc(IDirect3DVertexBuffer *iface, static HRESULT WINAPI IDirect3DVertexBufferImpl_1_GetVertexBufferDesc(IDirect3DVertexBuffer *iface,
D3DVERTEXBUFFERDESC *Desc) D3DVERTEXBUFFERDESC *Desc)
{ {
IDirect3DVertexBufferImpl *This = impl_from_IDirect3DVertexBuffer(iface);
TRACE("iface %p, desc %p.\n", iface, Desc); TRACE("iface %p, desc %p.\n", iface, Desc);
return IDirect3DVertexBuffer7_GetVertexBufferDesc((IDirect3DVertexBuffer7 *)vb_from_vb1(iface), Desc); return IDirect3DVertexBuffer7_GetVertexBufferDesc((IDirect3DVertexBuffer7 *)This, Desc);
} }
...@@ -440,11 +458,12 @@ IDirect3DVertexBufferImpl_Optimize(IDirect3DVertexBuffer7 *iface, ...@@ -440,11 +458,12 @@ IDirect3DVertexBufferImpl_Optimize(IDirect3DVertexBuffer7 *iface,
static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Optimize(IDirect3DVertexBuffer *iface, static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Optimize(IDirect3DVertexBuffer *iface,
IDirect3DDevice3 *D3DDevice, DWORD Flags) IDirect3DDevice3 *D3DDevice, DWORD Flags)
{ {
IDirect3DVertexBufferImpl *This = impl_from_IDirect3DVertexBuffer(iface);
IDirect3DDeviceImpl *D3D = D3DDevice ? device_from_device3(D3DDevice) : NULL; IDirect3DDeviceImpl *D3D = D3DDevice ? device_from_device3(D3DDevice) : NULL;
TRACE("iface %p, device %p, flags %#x.\n", iface, D3DDevice, Flags); TRACE("iface %p, device %p, flags %#x.\n", iface, D3DDevice, Flags);
return IDirect3DVertexBuffer7_Optimize((IDirect3DVertexBuffer7 *)vb_from_vb1(iface), return IDirect3DVertexBuffer7_Optimize((IDirect3DVertexBuffer7 *)This,
(IDirect3DDevice7 *)D3D, Flags); (IDirect3DDevice7 *)D3D, Flags);
} }
...@@ -538,7 +557,7 @@ HRESULT d3d_vertex_buffer_create(IDirect3DVertexBufferImpl **vertex_buf, IDirect ...@@ -538,7 +557,7 @@ HRESULT d3d_vertex_buffer_create(IDirect3DVertexBufferImpl **vertex_buf, IDirect
return DDERR_OUTOFMEMORY; return DDERR_OUTOFMEMORY;
buffer->lpVtbl = &d3d_vertex_buffer7_vtbl; buffer->lpVtbl = &d3d_vertex_buffer7_vtbl;
buffer->IDirect3DVertexBuffer_vtbl = &d3d_vertex_buffer1_vtbl; buffer->IDirect3DVertexBuffer_iface.lpVtbl = &d3d_vertex_buffer1_vtbl;
buffer->ref = 1; buffer->ref = 1;
buffer->ddraw = ddraw; buffer->ddraw = ddraw;
...@@ -588,7 +607,7 @@ IDirect3DVertexBufferImpl *unsafe_impl_from_IDirect3DVertexBuffer(IDirect3DVerte ...@@ -588,7 +607,7 @@ IDirect3DVertexBufferImpl *unsafe_impl_from_IDirect3DVertexBuffer(IDirect3DVerte
return NULL; return NULL;
assert(iface->lpVtbl == &d3d_vertex_buffer1_vtbl); assert(iface->lpVtbl == &d3d_vertex_buffer1_vtbl);
return vb_from_vb1(iface); return impl_from_IDirect3DVertexBuffer(iface);
} }
IDirect3DVertexBufferImpl *unsafe_impl_from_IDirect3DVertexBuffer7(IDirect3DVertexBuffer7 *iface) IDirect3DVertexBufferImpl *unsafe_impl_from_IDirect3DVertexBuffer7(IDirect3DVertexBuffer7 *iface)
......
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