From aa8e4dd81bec802fb28b4d59f770773108ca449b Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Fri, 8 Jul 2011 12:22:14 +0200 Subject: [PATCH] d3d8: Use unsafe_impl_from_IDirect3DVertexBuffer8 for app provided ifaces. --- dlls/d3d8/buffer.c | 9 +++++++++ dlls/d3d8/d3d8_private.h | 1 + dlls/d3d8/device.c | 6 +++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dlls/d3d8/buffer.c b/dlls/d3d8/buffer.c index f10ec68413b..19ce7e44b3c 100644 --- a/dlls/d3d8/buffer.c +++ b/dlls/d3d8/buffer.c @@ -298,6 +298,15 @@ HRESULT vertexbuffer_init(IDirect3DVertexBuffer8Impl *buffer, IDirect3DDevice8Im return D3D_OK; } +IDirect3DVertexBuffer8Impl *unsafe_impl_from_IDirect3DVertexBuffer8(IDirect3DVertexBuffer8 *iface) +{ + if (!iface) + return NULL; + assert(iface->lpVtbl == &Direct3DVertexBuffer8_Vtbl); + + return impl_from_IDirect3DVertexBuffer8(iface); +} + static inline IDirect3DIndexBuffer8Impl *impl_from_IDirect3DIndexBuffer8(IDirect3DIndexBuffer8 *iface) { return CONTAINING_RECORD(iface, IDirect3DIndexBuffer8Impl, IDirect3DIndexBuffer8_iface); diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 6ec67126005..cbc01869a1e 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -277,6 +277,7 @@ struct IDirect3DVertexBuffer8Impl HRESULT vertexbuffer_init(IDirect3DVertexBuffer8Impl *buffer, IDirect3DDevice8Impl *device, UINT size, DWORD usage, DWORD fvf, D3DPOOL pool) DECLSPEC_HIDDEN; +IDirect3DVertexBuffer8Impl *unsafe_impl_from_IDirect3DVertexBuffer8(IDirect3DVertexBuffer8 *iface) DECLSPEC_HIDDEN; /* --------------------- */ /* IDirect3DIndexBuffer8 */ diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 3537cb7fb26..cd3c16ded46 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -2005,8 +2005,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(IDirect3DDevice8 *ifa DWORD Flags) { IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface); + IDirect3DVertexBuffer8Impl *dest = unsafe_impl_from_IDirect3DVertexBuffer8(pDestBuffer); HRESULT hr; - IDirect3DVertexBuffer8Impl *dest = (IDirect3DVertexBuffer8Impl *) pDestBuffer; TRACE("iface %p, src_start_idx %u, dst_idx %u, vertex_count %u, dst_buffer %p, flags %#x.\n", iface, SrcStartIndex, DestIndex, VertexCount, pDestBuffer, Flags); @@ -2683,6 +2683,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetStreamSource(IDirect3DDevice8 *ifa UINT StreamNumber, IDirect3DVertexBuffer8 *pStreamData, UINT Stride) { IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface); + IDirect3DVertexBuffer8Impl *streamdata = unsafe_impl_from_IDirect3DVertexBuffer8(pStreamData); HRESULT hr; TRACE("iface %p, stream_idx %u, buffer %p, stride %u.\n", @@ -2690,8 +2691,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetStreamSource(IDirect3DDevice8 *ifa wined3d_mutex_lock(); hr = wined3d_device_set_stream_source(This->wined3d_device, StreamNumber, - pStreamData ? ((IDirect3DVertexBuffer8Impl *)pStreamData)->wineD3DVertexBuffer : NULL, - 0/* Offset in bytes */, Stride); + streamdata ? streamdata->wineD3DVertexBuffer : NULL, 0/* Offset in bytes */, Stride); wined3d_mutex_unlock(); return hr;