Commit 8e272741 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

ddraw: Use unsafe_impl_from_IDirect3DVertexBuffer() for app provided ifaces.

parent ca1ee4a7
...@@ -536,6 +536,8 @@ struct IDirect3DVertexBufferImpl ...@@ -536,6 +536,8 @@ struct IDirect3DVertexBufferImpl
HRESULT d3d_vertex_buffer_create(IDirect3DVertexBufferImpl **vertex_buf, IDirectDrawImpl *ddraw, HRESULT d3d_vertex_buffer_create(IDirect3DVertexBufferImpl **vertex_buf, IDirectDrawImpl *ddraw,
D3DVERTEXBUFFERDESC *desc) DECLSPEC_HIDDEN; D3DVERTEXBUFFERDESC *desc) DECLSPEC_HIDDEN;
IDirect3DVertexBufferImpl *unsafe_impl_from_IDirect3DVertexBuffer(IDirect3DVertexBuffer *iface) DECLSPEC_HIDDEN;
IDirect3DVertexBufferImpl *unsafe_impl_from_IDirect3DVertexBuffer7(IDirect3DVertexBuffer7 *iface) DECLSPEC_HIDDEN;
static inline IDirect3DVertexBufferImpl *vb_from_vb1(IDirect3DVertexBuffer *iface) static inline IDirect3DVertexBufferImpl *vb_from_vb1(IDirect3DVertexBuffer *iface)
{ {
......
...@@ -4053,7 +4053,7 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface, ...@@ -4053,7 +4053,7 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
DWORD Flags) DWORD Flags)
{ {
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface; IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirect3DVertexBufferImpl *vb = (IDirect3DVertexBufferImpl *)D3DVertexBuf; IDirect3DVertexBufferImpl *vb = unsafe_impl_from_IDirect3DVertexBuffer7(D3DVertexBuf);
HRESULT hr; HRESULT hr;
DWORD stride; DWORD stride;
...@@ -4126,7 +4126,7 @@ static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawPrimitiveVB(IDirect3DDevice3 *if ...@@ -4126,7 +4126,7 @@ static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawPrimitiveVB(IDirect3DDevice3 *if
D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer *D3DVertexBuf, DWORD StartVertex, D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer *D3DVertexBuf, DWORD StartVertex,
DWORD NumVertices, DWORD Flags) DWORD NumVertices, DWORD Flags)
{ {
IDirect3DVertexBufferImpl *vb = D3DVertexBuf ? vb_from_vb1(D3DVertexBuf) : NULL; IDirect3DVertexBufferImpl *vb = unsafe_impl_from_IDirect3DVertexBuffer(D3DVertexBuf);
TRACE("iface %p, primitive_type %#x, vb %p, start_vertex %u, vertex_count %u, flags %#x.\n", TRACE("iface %p, primitive_type %#x, vb %p, start_vertex %u, vertex_count %u, flags %#x.\n",
iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Flags); iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Flags);
...@@ -4164,7 +4164,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface, ...@@ -4164,7 +4164,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
DWORD Flags) DWORD Flags)
{ {
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface; IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirect3DVertexBufferImpl *vb = (IDirect3DVertexBufferImpl *)D3DVertexBuf; IDirect3DVertexBufferImpl *vb = unsafe_impl_from_IDirect3DVertexBuffer7(D3DVertexBuf);
DWORD stride = get_flexible_vertex_size(vb->fvf); DWORD stride = get_flexible_vertex_size(vb->fvf);
struct wined3d_resource *wined3d_resource; struct wined3d_resource *wined3d_resource;
struct wined3d_resource_desc desc; struct wined3d_resource_desc desc;
...@@ -4288,13 +4288,13 @@ static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(IDirect3DDevi ...@@ -4288,13 +4288,13 @@ static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(IDirect3DDevi
D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer *D3DVertexBuf, WORD *Indices, D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer *D3DVertexBuf, WORD *Indices,
DWORD IndexCount, DWORD Flags) DWORD IndexCount, DWORD Flags)
{ {
IDirect3DVertexBufferImpl *VB = vb_from_vb1(D3DVertexBuf); IDirect3DVertexBufferImpl *vb = unsafe_impl_from_IDirect3DVertexBuffer(D3DVertexBuf);
TRACE("iface %p, primitive_type %#x, vb %p, indices %p, index_count %u, flags %#x.\n", TRACE("iface %p, primitive_type %#x, vb %p, indices %p, index_count %u, flags %#x.\n",
iface, PrimitiveType, D3DVertexBuf, Indices, IndexCount, Flags); iface, PrimitiveType, D3DVertexBuf, Indices, IndexCount, Flags);
return IDirect3DDevice7_DrawIndexedPrimitiveVB((IDirect3DDevice7 *)device_from_device3(iface), return IDirect3DDevice7_DrawIndexedPrimitiveVB((IDirect3DDevice7 *)device_from_device3(iface),
PrimitiveType, (IDirect3DVertexBuffer7 *)VB, 0, IndexCount, Indices, IndexCount, Flags); PrimitiveType, (IDirect3DVertexBuffer7 *)vb, 0, IndexCount, Indices, IndexCount, Flags);
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -289,18 +289,12 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Unlock(IDirect3DVertexBuffer * ...@@ -289,18 +289,12 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Unlock(IDirect3DVertexBuffer *
* DDERR_INVALIDPARAMS If D3DVOP_TRANSFORM wasn't passed * DDERR_INVALIDPARAMS If D3DVOP_TRANSFORM wasn't passed
* *
*****************************************************************************/ *****************************************************************************/
static HRESULT WINAPI static HRESULT WINAPI IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface,
IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface, DWORD VertexOp, DWORD DestIndex, DWORD Count, IDirect3DVertexBuffer7 *SrcBuffer,
DWORD VertexOp, DWORD SrcIndex, IDirect3DDevice7 *D3DDevice, DWORD Flags)
DWORD DestIndex,
DWORD Count,
IDirect3DVertexBuffer7 *SrcBuffer,
DWORD SrcIndex,
IDirect3DDevice7 *D3DDevice,
DWORD Flags)
{ {
IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface; IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
IDirect3DVertexBufferImpl *Src = (IDirect3DVertexBufferImpl *)SrcBuffer; IDirect3DVertexBufferImpl *Src = unsafe_impl_from_IDirect3DVertexBuffer7(SrcBuffer);
IDirect3DDeviceImpl *D3D = (IDirect3DDeviceImpl *)D3DDevice; IDirect3DDeviceImpl *D3D = (IDirect3DDeviceImpl *)D3DDevice;
BOOL oldClip, doClip; BOOL oldClip, doClip;
HRESULT hr; HRESULT hr;
...@@ -347,7 +341,7 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_1_ProcessVertices(IDirect3DVerte ...@@ -347,7 +341,7 @@ 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 *Src = SrcBuffer ? vb_from_vb1(SrcBuffer) : NULL; 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",
...@@ -587,3 +581,21 @@ end: ...@@ -587,3 +581,21 @@ end:
return hr; return hr;
} }
IDirect3DVertexBufferImpl *unsafe_impl_from_IDirect3DVertexBuffer(IDirect3DVertexBuffer *iface)
{
if (!iface)
return NULL;
assert(iface->lpVtbl == &d3d_vertex_buffer1_vtbl);
return vb_from_vb1(iface);
}
IDirect3DVertexBufferImpl *unsafe_impl_from_IDirect3DVertexBuffer7(IDirect3DVertexBuffer7 *iface)
{
if (!iface)
return NULL;
assert(iface->lpVtbl == &d3d_vertex_buffer7_vtbl);
return (IDirect3DVertexBufferImpl *)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