diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index df74def5762..648c63d8f42 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -4266,7 +4266,7 @@ static HRESULT WINAPI ddraw3_DuplicateSurface(IDirectDraw3 *iface, IDirectDrawSu IDirectDrawSurface **dst) { IDirectDrawImpl *This = impl_from_IDirectDraw3(iface); - IDirectDrawSurfaceImpl *src_impl = unsafe_impl_from_IDirectDrawSurface3((IDirectDrawSurface3 *)src); + IDirectDrawSurfaceImpl *src_impl = unsafe_impl_from_IDirectDrawSurface(src); IDirectDrawSurface7 *dst7; IDirectDrawSurfaceImpl *dst_impl; HRESULT hr; @@ -4286,7 +4286,7 @@ static HRESULT WINAPI ddraw2_DuplicateSurface(IDirectDraw2 *iface, IDirectDrawSurface *src, IDirectDrawSurface **dst) { IDirectDrawImpl *This = impl_from_IDirectDraw2(iface); - IDirectDrawSurfaceImpl *src_impl = unsafe_impl_from_IDirectDrawSurface3((IDirectDrawSurface3 *)src); + IDirectDrawSurfaceImpl *src_impl = unsafe_impl_from_IDirectDrawSurface(src); IDirectDrawSurface7 *dst7; IDirectDrawSurfaceImpl *dst_impl; HRESULT hr; @@ -4306,7 +4306,7 @@ static HRESULT WINAPI ddraw1_DuplicateSurface(IDirectDraw *iface, IDirectDrawSur IDirectDrawSurface **dst) { IDirectDrawImpl *This = impl_from_IDirectDraw(iface); - IDirectDrawSurfaceImpl *src_impl = unsafe_impl_from_IDirectDrawSurface3((IDirectDrawSurface3 *)src); + IDirectDrawSurfaceImpl *src_impl = unsafe_impl_from_IDirectDrawSurface(src); IDirectDrawSurface7 *dst7; IDirectDrawSurfaceImpl *dst_impl; HRESULT hr; @@ -4906,7 +4906,7 @@ static HRESULT WINAPI d3d2_CreateDevice(IDirect3D2 *iface, REFCLSID riid, IDirectDrawSurface *surface, IDirect3DDevice2 **device) { IDirectDrawImpl *This = impl_from_IDirect3D2(iface); - IDirectDrawSurfaceImpl *surface_impl = unsafe_impl_from_IDirectDrawSurface3((IDirectDrawSurface3 *)surface); + IDirectDrawSurfaceImpl *surface_impl = unsafe_impl_from_IDirectDrawSurface(surface); HRESULT hr; TRACE("iface %p, riid %s, surface %p, device %p.\n", diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index bce6368cf87..160ae44bb4a 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -242,6 +242,7 @@ static inline IDirectDrawSurfaceImpl *impl_from_IDirectDrawSurface7(IDirectDrawS return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawSurface7_iface); } +IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface(IDirectDrawSurface *iface) DECLSPEC_HIDDEN; IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface2(IDirectDrawSurface2 *iface) DECLSPEC_HIDDEN; IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface3(IDirectDrawSurface3 *iface) DECLSPEC_HIDDEN; IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface4(IDirectDrawSurface4 *iface) DECLSPEC_HIDDEN; diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index f4e5664d826..c4ad855fe31 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -1901,7 +1901,7 @@ static HRESULT WINAPI IDirect3DDeviceImpl_2_SetRenderTarget(IDirect3DDevice2 *if IDirectDrawSurface *NewRenderTarget, DWORD Flags) { IDirect3DDeviceImpl *This = device_from_device2(iface); - IDirectDrawSurfaceImpl *Target = unsafe_impl_from_IDirectDrawSurface3((IDirectDrawSurface3 *)NewRenderTarget); + IDirectDrawSurfaceImpl *Target = unsafe_impl_from_IDirectDrawSurface(NewRenderTarget); TRACE("iface %p, target %p, flags %#x.\n", iface, NewRenderTarget, Flags); diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index e877b9f5df9..eb9dd29cbfa 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -4421,6 +4421,13 @@ IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface2(IDirectDrawSurface2 return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawSurface2_iface); } +IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface(IDirectDrawSurface *iface) +{ + if (!iface) return NULL; + assert(iface->lpVtbl == (struct IDirectDrawSurfaceVtbl *)&ddraw_surface3_vtbl); + return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawSurface3_iface); +} + static void STDMETHODCALLTYPE ddraw_surface_wined3d_object_destroyed(void *parent) { IDirectDrawSurfaceImpl *surface = parent;