ddraw: Use unsafe_impl_from_IDirect3DDevice3 for application provided interfaces.

This commit is contained in:
Ričardas Barkauskas 2011-10-17 16:57:53 +03:00 committed by Alexandre Julliard
parent d32df839ac
commit a90b2ad002
4 changed files with 23 additions and 15 deletions

View File

@ -342,6 +342,7 @@ static inline IDirect3DDeviceImpl *device_from_device3(IDirect3DDevice3 *iface)
IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice(IDirect3DDevice *iface) DECLSPEC_HIDDEN;
IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface) DECLSPEC_HIDDEN;
IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface) DECLSPEC_HIDDEN;
/*****************************************************************************
* IDirectDrawClipper implementation structure

View File

@ -6746,6 +6746,13 @@ static const struct IDirect3DDeviceVtbl d3d_device1_vtbl =
IDirect3DDeviceImpl_1_GetDirect3D
};
IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface)
{
if (!iface) return NULL;
assert(iface->lpVtbl == &d3d_device3_vtbl);
return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice3_vtbl);
}
IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface)
{
if (!iface) return NULL;

View File

@ -295,18 +295,18 @@ static HRESULT WINAPI IDirect3DMaterialImpl_GetMaterial(IDirect3DMaterial3 *ifac
*
*****************************************************************************/
static HRESULT WINAPI IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface,
IDirect3DDevice3 *lpDirect3DDevice3, D3DMATERIALHANDLE *lpHandle)
IDirect3DDevice3 *device, D3DMATERIALHANDLE *handle)
{
IDirect3DMaterialImpl *This = impl_from_IDirect3DMaterial3(iface);
IDirect3DDeviceImpl *device = device_from_device3(lpDirect3DDevice3);
IDirect3DDeviceImpl *device_impl = unsafe_impl_from_IDirect3DDevice3(device);
TRACE("iface %p, device %p, handle %p.\n", iface, lpDirect3DDevice3, lpHandle);
TRACE("iface %p, device %p, handle %p.\n", iface, device, handle);
EnterCriticalSection(&ddraw_cs);
This->active_device = device;
This->active_device = device_impl;
if(!This->Handle)
{
DWORD h = ddraw_allocate_handle(&device->handle_table, This, DDRAW_HANDLE_MATERIAL);
DWORD h = ddraw_allocate_handle(&device_impl->handle_table, This, DDRAW_HANDLE_MATERIAL);
if (h == DDRAW_INVALID_HANDLE)
{
ERR("Failed to allocate a material handle.\n");
@ -316,8 +316,8 @@ static HRESULT WINAPI IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface,
This->Handle = h + 1;
}
*lpHandle = This->Handle;
TRACE(" returning handle %08x.\n", *lpHandle);
*handle = This->Handle;
TRACE(" returning handle %08x.\n", *handle);
LeaveCriticalSection(&ddraw_cs);
return D3D_OK;

View File

@ -351,17 +351,17 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexB
static HRESULT WINAPI IDirect3DVertexBufferImpl_1_ProcessVertices(IDirect3DVertexBuffer *iface,
DWORD VertexOp, DWORD DestIndex, DWORD Count, IDirect3DVertexBuffer *SrcBuffer,
DWORD SrcIndex, IDirect3DDevice3 *D3DDevice, DWORD Flags)
DWORD SrcIndex, IDirect3DDevice3 *device, DWORD Flags)
{
IDirect3DVertexBufferImpl *This = impl_from_IDirect3DVertexBuffer(iface);
IDirect3DVertexBufferImpl *Src = unsafe_impl_from_IDirect3DVertexBuffer(SrcBuffer);
IDirect3DDeviceImpl *D3D = D3DDevice ? device_from_device3(D3DDevice) : NULL;
IDirect3DDeviceImpl *device_impl = unsafe_impl_from_IDirect3DDevice3(device);
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, device, Flags);
return IDirect3DVertexBuffer7_ProcessVertices(&This->IDirect3DVertexBuffer7_iface, VertexOp,
DestIndex, Count, &Src->IDirect3DVertexBuffer7_iface, SrcIndex, (IDirect3DDevice7 *)D3D,
DestIndex, Count, &Src->IDirect3DVertexBuffer7_iface, SrcIndex, (IDirect3DDevice7 *)device_impl,
Flags);
}
@ -451,15 +451,15 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_Optimize(IDirect3DVertexBuffer7
}
static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Optimize(IDirect3DVertexBuffer *iface,
IDirect3DDevice3 *D3DDevice, DWORD Flags)
IDirect3DDevice3 *device, DWORD Flags)
{
IDirect3DVertexBufferImpl *This = impl_from_IDirect3DVertexBuffer(iface);
IDirect3DDeviceImpl *D3D = D3DDevice ? device_from_device3(D3DDevice) : NULL;
IDirect3DDeviceImpl *device_impl = unsafe_impl_from_IDirect3DDevice3(device);
TRACE("iface %p, device %p, flags %#x.\n", iface, D3DDevice, Flags);
TRACE("iface %p, device %p, flags %#x.\n", iface, device, Flags);
return IDirect3DVertexBuffer7_Optimize(&This->IDirect3DVertexBuffer7_iface,
(IDirect3DDevice7 *)D3D, Flags);
(IDirect3DDevice7 *)device_impl, Flags);
}
/*****************************************************************************