From 38982ddf114aceff064afff88a3d73250be61c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ri=C4=8Dardas=20Barkauskas?= Date: Mon, 3 Oct 2011 17:14:59 -0500 Subject: [PATCH] ddraw: Use unsafe_impl_from_IDirect3DViewport2 for application provided interfaces. --- dlls/ddraw/ddraw_private.h | 1 + dlls/ddraw/device.c | 8 ++++---- dlls/ddraw/viewport.c | 8 ++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index b50c0bc76a3..e75acc0d6e5 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -470,6 +470,7 @@ struct IDirect3DViewportImpl }; IDirect3DViewportImpl *unsafe_impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface) DECLSPEC_HIDDEN; +IDirect3DViewportImpl *unsafe_impl_from_IDirect3DViewport2(IDirect3DViewport2 *iface) DECLSPEC_HIDDEN; IDirect3DViewportImpl *unsafe_impl_from_IDirect3DViewport(IDirect3DViewport *iface) DECLSPEC_HIDDEN; /* Helper functions */ diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index a2e27acd770..8cfeac16252 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -771,7 +771,7 @@ static HRESULT WINAPI IDirect3DDeviceImpl_2_AddViewport(IDirect3DDevice2 *iface, IDirect3DViewport2 *Direct3DViewport2) { IDirect3DDeviceImpl *This = device_from_device2(iface); - IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport2; + IDirect3DViewportImpl *vp = unsafe_impl_from_IDirect3DViewport2(Direct3DViewport2); TRACE("iface %p, viewport %p.\n", iface, Direct3DViewport2); @@ -832,7 +832,7 @@ static HRESULT WINAPI IDirect3DDeviceImpl_2_DeleteViewport(IDirect3DDevice2 *ifa IDirect3DViewport2 *Direct3DViewport2) { IDirect3DDeviceImpl *This = device_from_device2(iface); - IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport2; + IDirect3DViewportImpl *vp = unsafe_impl_from_IDirect3DViewport2(Direct3DViewport2); TRACE("iface %p, viewport %p.\n", iface, Direct3DViewport2); @@ -927,7 +927,7 @@ static HRESULT WINAPI IDirect3DDeviceImpl_2_NextViewport(IDirect3DDevice2 *iface IDirect3DViewport2 *Viewport2, IDirect3DViewport2 **lplpDirect3DViewport2, DWORD Flags) { IDirect3DDeviceImpl *This = device_from_device2(iface); - IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport2; + IDirect3DViewportImpl *vp = unsafe_impl_from_IDirect3DViewport2(Viewport2); IDirect3DViewport3 *res; HRESULT hr; @@ -1749,7 +1749,7 @@ static HRESULT WINAPI IDirect3DDeviceImpl_2_SetCurrentViewport(IDirect3DDevice2 IDirect3DViewport2 *Direct3DViewport2) { IDirect3DDeviceImpl *This = device_from_device2(iface); - IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport2; + IDirect3DViewportImpl *vp = unsafe_impl_from_IDirect3DViewport2(Direct3DViewport2); TRACE("iface %p, viewport %p.\n", iface, Direct3DViewport2); diff --git a/dlls/ddraw/viewport.c b/dlls/ddraw/viewport.c index bbff45b5225..1becbc7a41c 100644 --- a/dlls/ddraw/viewport.c +++ b/dlls/ddraw/viewport.c @@ -1127,6 +1127,14 @@ IDirect3DViewportImpl *unsafe_impl_from_IDirect3DViewport3(IDirect3DViewport3 *i return CONTAINING_RECORD(iface, IDirect3DViewportImpl, IDirect3DViewport3_iface); } +IDirect3DViewportImpl *unsafe_impl_from_IDirect3DViewport2(IDirect3DViewport2 *iface) +{ + /* IDirect3DViewport and IDirect3DViewport3 use the same iface. */ + if (!iface) return NULL; + assert(iface->lpVtbl == (IDirect3DViewport2Vtbl *)&d3d_viewport_vtbl); + return CONTAINING_RECORD(iface, IDirect3DViewportImpl, IDirect3DViewport3_iface); +} + IDirect3DViewportImpl *unsafe_impl_from_IDirect3DViewport(IDirect3DViewport *iface) { /* IDirect3DViewport and IDirect3DViewport3 use the same iface. */