From 9059fee7c511cdd194349740018edc90b8b0cab1 Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Thu, 9 Jun 2011 11:57:45 +0200 Subject: [PATCH] ddraw: Use unsafe_impl_from_IDirect3DLight() for application provided ifaces. --- dlls/ddraw/ddraw_private.h | 1 + dlls/ddraw/light.c | 9 +++++++++ dlls/ddraw/viewport.c | 23 +++++++++-------------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index c749168867e..f1e0219f825 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -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 diff --git a/dlls/ddraw/light.c b/dlls/ddraw/light.c index f7b8347eba0..0325cd4ee81 100644 --- a/dlls/ddraw/light.c +++ b/dlls/ddraw/light.c @@ -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); +} diff --git a/dlls/ddraw/viewport.c b/dlls/ddraw/viewport.c index 08af7e2380f..7dc3dd4c6e5 100644 --- a/dlls/ddraw/viewport.c +++ b/dlls/ddraw/viewport.c @@ -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;