ddraw: Use unsafe_impl_from_IDirect3DLight() for application provided ifaces.

This commit is contained in:
Michael Stefaniuc 2011-06-09 11:57:45 +02:00 committed by Alexandre Julliard
parent 0519450708
commit 9059fee7c5
3 changed files with 19 additions and 14 deletions

View File

@ -408,6 +408,7 @@ struct IDirect3DLightImpl
void light_activate(IDirect3DLightImpl *light) DECLSPEC_HIDDEN;
void light_deactivate(IDirect3DLightImpl *light) DECLSPEC_HIDDEN;
void d3d_light_init(IDirect3DLightImpl *light, IDirectDrawImpl *ddraw) DECLSPEC_HIDDEN;
IDirect3DLightImpl *unsafe_impl_from_IDirect3DLight(IDirect3DLight *iface) DECLSPEC_HIDDEN;
/******************************************************************************
* IDirect3DMaterial implementation structure - Wraps to D3D7

View File

@ -281,3 +281,12 @@ void d3d_light_init(IDirect3DLightImpl *light, IDirectDrawImpl *ddraw)
light->ref = 1;
light->ddraw = ddraw;
}
IDirect3DLightImpl *unsafe_impl_from_IDirect3DLight(IDirect3DLight *iface)
{
if (!iface)
return NULL;
assert(iface->lpVtbl == &d3d_light_vtbl);
return impl_from_IDirect3DLight(iface);
}

View File

@ -715,12 +715,11 @@ static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface,
* DDERR_INVALIDPARAMS if there are 8 lights or more
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface,
IDirect3DLight *lpDirect3DLight)
static HRESULT WINAPI IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface,
IDirect3DLight *lpDirect3DLight)
{
IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface;
IDirect3DLightImpl *lpDirect3DLightImpl = (IDirect3DLightImpl *)lpDirect3DLight;
IDirect3DLightImpl *lpDirect3DLightImpl = unsafe_impl_from_IDirect3DLight(lpDirect3DLight);
DWORD i = 0;
DWORD map = This->map_lights;
@ -771,12 +770,11 @@ IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface,
* DDERR_INVALIDPARAMS if the light wasn't found
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *iface,
IDirect3DLight *lpDirect3DLight)
static HRESULT WINAPI IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *iface,
IDirect3DLight *lpDirect3DLight)
{
IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface;
IDirect3DLightImpl *l = (IDirect3DLightImpl *)lpDirect3DLight;
IDirect3DLightImpl *l = unsafe_impl_from_IDirect3DLight(lpDirect3DLight);
TRACE("iface %p, light %p.\n", iface, lpDirect3DLight);
@ -814,14 +812,11 @@ IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *iface,
* D3D_OK, because it's a stub
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_NextLight(IDirect3DViewport3 *iface,
IDirect3DLight *lpDirect3DLight,
IDirect3DLight **lplpDirect3DLight,
DWORD dwFlags)
static HRESULT WINAPI IDirect3DViewportImpl_NextLight(IDirect3DViewport3 *iface,
IDirect3DLight *lpDirect3DLight, IDirect3DLight **lplpDirect3DLight, DWORD dwFlags)
{
IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface;
IDirect3DLightImpl *l = (IDirect3DLightImpl *)lpDirect3DLight;
IDirect3DLightImpl *l = unsafe_impl_from_IDirect3DLight(lpDirect3DLight);
struct list *entry;
HRESULT hr;