From 15f16e8f5eaf71fa274f2e88eabf45569bd64ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ri=C4=8Dardas=20Barkauskas?= Date: Fri, 29 Jul 2011 16:30:32 +0300 Subject: [PATCH] ddraw: Use unsafe_impl_from_IDirect3DTexture2 for application provided interfaces. --- dlls/ddraw/ddraw_private.h | 1 + dlls/ddraw/device.c | 6 +++--- dlls/ddraw/surface.c | 9 ++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 0c9c41bf1d2..b7ab1988114 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -254,6 +254,7 @@ IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface4(IDirectDrawSurface4 IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface7(IDirectDrawSurface7 *iface) DECLSPEC_HIDDEN; IDirectDrawSurfaceImpl *unsafe_impl_from_IDirect3DTexture(IDirect3DTexture *iface) DECLSPEC_HIDDEN; +IDirectDrawSurfaceImpl *unsafe_impl_from_IDirect3DTexture2(IDirect3DTexture2 *iface) DECLSPEC_HIDDEN; /* Get the number of bytes per pixel for a given surface */ #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.dwRGBBitCount+7)/8)) diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index eb450990f93..3cd0a604256 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -544,8 +544,8 @@ IDirect3DDeviceImpl_2_SwapTextureHandles(IDirect3DDevice2 *iface, IDirect3DTexture2 *Tex2) { IDirect3DDeviceImpl *This = device_from_device2(iface); - IDirectDrawSurfaceImpl *surf1 = surface_from_texture2(Tex1); - IDirectDrawSurfaceImpl *surf2 = surface_from_texture2(Tex2); + IDirectDrawSurfaceImpl *surf1 = unsafe_impl_from_IDirect3DTexture2(Tex1); + IDirectDrawSurfaceImpl *surf2 = unsafe_impl_from_IDirect3DTexture2(Tex2); DWORD h1, h2; TRACE("iface %p, tex1 %p, tex2 %p.\n", iface, Tex1, Tex2); @@ -4564,7 +4564,7 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface, IDirect3DTexture2 *Texture2) { IDirect3DDeviceImpl *This = device_from_device3(iface); - IDirectDrawSurfaceImpl *tex = Texture2 ? surface_from_texture2(Texture2) : NULL; + IDirectDrawSurfaceImpl *tex = unsafe_impl_from_IDirect3DTexture2(Texture2); DWORD texmapblend; HRESULT hr; diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index e4c74366881..a7722d74fcf 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -4572,7 +4572,7 @@ static IDirectDrawSurfaceImpl *get_sub_mimaplevel(IDirectDrawSurfaceImpl *surfac static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTexture2 *src_texture) { IDirectDrawSurfaceImpl *dst_surface = surface_from_texture2(iface); - IDirectDrawSurfaceImpl *src_surface = surface_from_texture2(src_texture); + IDirectDrawSurfaceImpl *src_surface = unsafe_impl_from_IDirect3DTexture2(src_texture); HRESULT hr; TRACE("iface %p, src_texture %p.\n", iface, src_texture); @@ -5030,6 +5030,13 @@ IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface(IDirectDrawSurface * return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawSurface_iface); } +IDirectDrawSurfaceImpl *unsafe_impl_from_IDirect3DTexture2(IDirect3DTexture2 *iface) +{ + if (!iface) return NULL; + assert(iface->lpVtbl == &d3d_texture2_vtbl); + return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirect3DTexture2_vtbl); +} + IDirectDrawSurfaceImpl *unsafe_impl_from_IDirect3DTexture(IDirect3DTexture *iface) { if (!iface) return NULL;