Commit 802f9c7e authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Get rid of ICOM_OBJECT.

parent 8c4cc2af
......@@ -265,7 +265,7 @@ static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(
return DDERR_ALREADYINITIALIZED;
}
pOwner = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, lpDD);
pOwner = lpDD ? ddraw_from_ddraw1(lpDD) : NULL;
This->ddraw_owner = pOwner;
LeaveCriticalSection(&ddraw_cs);
......
......@@ -22,11 +22,6 @@
#include <stddef.h>
/* Given an interface pointer, returns the implementation pointer. */
#define ICOM_OBJECT(impltype, ifacename, ifaceptr) \
(impltype*)((ifaceptr) == NULL ? NULL \
: (char*)(ifaceptr) - offsetof(impltype, ifacename##_vtbl))
#define COM_INTERFACE_CAST(impltype, ifnamefrom, ifnameto, ifaceptr) \
((ifaceptr) ? (ifnameto *)&(((impltype *)((char *)(ifaceptr) \
- offsetof(impltype, ifnamefrom##_vtbl)))->ifnameto##_vtbl) : NULL)
......
......@@ -1652,9 +1652,7 @@ IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf,
DDSURFACEDESC2 *desc,
void *Context)
{
IDirectDrawSurfaceImpl *surfImpl = ICOM_OBJECT(IDirectDrawSurfaceImpl,
IDirectDrawSurface7,
surf);
IDirectDrawSurfaceImpl *surfImpl = (IDirectDrawSurfaceImpl *)surf;
IDirectDrawImpl *This = surfImpl->ddraw;
IUnknown *Parent;
IParentImpl *parImpl = NULL;
......@@ -1695,7 +1693,7 @@ IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf,
{
/* It is a IParent interface! */
IUnknown_Release(Parent); /* For the QueryInterface */
parImpl = ICOM_OBJECT(IParentImpl, IParent, Parent);
parImpl = (IParentImpl *)Parent;
/* Release the reference the parent interface is holding */
IWineD3DSurface_Release(wineD3DSurface);
}
......@@ -2932,7 +2930,7 @@ findRenderTarget(IDirectDrawSurface7 *surface,
DDSURFACEDESC2 *desc,
void *ctx)
{
IDirectDrawSurfaceImpl *surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, surface);
IDirectDrawSurfaceImpl *surf = (IDirectDrawSurfaceImpl *)surface;
IDirectDrawSurfaceImpl **target = ctx;
if(!surf->isRenderTarget) {
......@@ -3258,7 +3256,7 @@ IDirectDrawImpl_DuplicateSurface(IDirectDraw7 *iface,
IDirectDrawSurface7 **Dest)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
IDirectDrawSurfaceImpl *Surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Src);
IDirectDrawSurfaceImpl *Surf = (IDirectDrawSurfaceImpl *)Src;
FIXME("(%p)->(%p,%p)\n", This, Surf, Dest);
......@@ -3456,7 +3454,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParen
{
IDirectDrawSurface7 *attached;
IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)This->tex_root, &searchcaps, &attached);
surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, attached);
surf = (IDirectDrawSurfaceImpl *)attached;
IDirectDrawSurface7_Release(attached);
}
if (!surf) ERR("root search surface not found\n");
......@@ -3467,7 +3465,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParen
IDirectDrawSurface7 *attached;
IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)surf, &searchcaps, &attached);
if(!attached) ERR("Surface not found\n");
surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, attached);
surf = (IDirectDrawSurfaceImpl *)attached;
IDirectDrawSurface7_Release(attached);
++i;
}
......
......@@ -209,6 +209,46 @@ IWineD3DVertexDeclaration *
IDirectDrawImpl_FindDecl(IDirectDrawImpl *This,
DWORD fvf);
static inline IDirectDrawImpl *ddraw_from_d3d1(IDirect3D *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_d3d2(IDirect3D2 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D2_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_d3d3(IDirect3D3 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D3_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_d3d7(IDirect3D7 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D7_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_ddraw1(IDirectDraw *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_ddraw2(IDirectDraw2 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw2_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_ddraw3(IDirectDraw3 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw3_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_ddraw4(IDirectDraw4 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw4_vtbl));
}
/* The default surface type */
extern WINED3DSURFTYPE DefaultSurfaceType;
......@@ -282,6 +322,16 @@ extern const IDirect3DTextureVtbl IDirect3DTexture1_Vtbl;
HRESULT WINAPI IDirectDrawSurfaceImpl_AddAttachedSurface(IDirectDrawSurfaceImpl *This, IDirectDrawSurfaceImpl *Surf);
void IDirectDrawSurfaceImpl_Destroy(IDirectDrawSurfaceImpl *This);
static inline IDirectDrawSurfaceImpl *surface_from_texture1(IDirect3DTexture *iface)
{
return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirect3DTexture_vtbl));
}
static inline IDirectDrawSurfaceImpl *surface_from_texture2(IDirect3DTexture2 *iface)
{
return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirect3DTexture2_vtbl));
}
/* Get the number of bytes per pixel for a given surface */
#define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.dwRGBBitCount+7)/8))
#define GET_BPP(desc) PFGET_BPP(desc.ddpfPixelFormat)
......@@ -377,6 +427,21 @@ HRESULT IDirect3DImpl_GetCaps(IWineD3D *WineD3D, D3DDEVICEDESC *Desc123, D3DDEVI
DWORD IDirect3DDeviceImpl_CreateHandle(IDirect3DDeviceImpl *This);
WINED3DZBUFFERTYPE IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *This);
static inline IDirect3DDeviceImpl *device_from_device1(IDirect3DDevice *iface)
{
return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice_vtbl));
}
static inline IDirect3DDeviceImpl *device_from_device2(IDirect3DDevice2 *iface)
{
return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice2_vtbl));
}
static inline IDirect3DDeviceImpl *device_from_device3(IDirect3DDevice3 *iface)
{
return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice3_vtbl));
}
/* Structures */
struct EnumTextureFormatsCBS
{
......@@ -625,6 +690,12 @@ struct IDirect3DVertexBufferImpl
extern const IDirect3DVertexBuffer7Vtbl IDirect3DVertexBuffer7_Vtbl;
extern const IDirect3DVertexBufferVtbl IDirect3DVertexBuffer1_Vtbl;
static inline IDirect3DVertexBufferImpl *vb_from_vb1(IDirect3DVertexBuffer *iface)
{
return (IDirect3DVertexBufferImpl *)((char*)iface
- FIELD_OFFSET(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer_vtbl));
}
/*****************************************************************************
* Helper functions from utils.c
*****************************************************************************/
......
......@@ -42,26 +42,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(ddraw_thunk);
WINE_DECLARE_DEBUG_CHANNEL(ddraw);
static inline IDirectDrawImpl *ddraw_from_ddraw1(IDirectDraw *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_ddraw2(IDirectDraw2 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw2_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_ddraw3(IDirectDraw3 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw3_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_ddraw4(IDirectDraw4 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw4_vtbl));
}
static HRESULT WINAPI
IDirectDrawImpl_QueryInterface(LPDIRECTDRAW This, REFIID iid, LPVOID *ppObj)
{
......@@ -312,7 +292,7 @@ IDirectDrawImpl_CreatePalette(LPDIRECTDRAW This, DWORD dwFlags,
dwFlags, pEntries, ppPalette, pUnkOuter);
if(SUCCEEDED(hr) && *ppPalette)
{
IDirectDrawPaletteImpl *impl = ICOM_OBJECT(IDirectDrawPaletteImpl, IDirectDrawPalette, *ppPalette);
IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*ppPalette;
IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
......@@ -337,7 +317,7 @@ IDirectDraw2Impl_CreatePalette(LPDIRECTDRAW2 This, DWORD dwFlags,
dwFlags, pEntries, ppPalette, pUnkOuter);
if(SUCCEEDED(hr) && *ppPalette)
{
IDirectDrawPaletteImpl *impl = ICOM_OBJECT(IDirectDrawPaletteImpl, IDirectDrawPalette, *ppPalette);
IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*ppPalette;
IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
......@@ -361,7 +341,7 @@ IDirectDraw3Impl_CreatePalette(LPDIRECTDRAW3 This, DWORD dwFlags,
dwFlags, pEntries, ppPalette, pUnkOuter);
if(SUCCEEDED(hr) && *ppPalette)
{
IDirectDrawPaletteImpl *impl = ICOM_OBJECT(IDirectDrawPaletteImpl, IDirectDrawPalette, *ppPalette);
IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*ppPalette;
IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
......@@ -386,7 +366,7 @@ IDirectDraw4Impl_CreatePalette(LPDIRECTDRAW4 This, DWORD dwFlags,
dwFlags, pEntries, ppPalette, pUnkOuter);
if(SUCCEEDED(hr) && *ppPalette)
{
IDirectDrawPaletteImpl *impl = ICOM_OBJECT(IDirectDrawPaletteImpl, IDirectDrawPalette, *ppPalette);
IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*ppPalette;
IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
......@@ -441,7 +421,7 @@ IDirectDrawImpl_CreateSurface(LPDIRECTDRAW This, LPDDSURFACEDESC pSDesc,
IDirectDrawSurface7, IDirectDrawSurface3,
pSurface7);
impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, pSurface7);
impl = (IDirectDrawSurfaceImpl *)pSurface7;
if(SUCCEEDED(hr) && impl)
{
set_surf_version(impl, 1);
......@@ -476,7 +456,7 @@ IDirectDraw2Impl_CreateSurface(LPDIRECTDRAW2 This, LPDDSURFACEDESC pSDesc,
IDirectDrawSurface7, IDirectDrawSurface3,
pSurface7);
impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, pSurface7);
impl = (IDirectDrawSurfaceImpl *)pSurface7;
if(SUCCEEDED(hr) && impl)
{
set_surf_version(impl, 2);
......@@ -511,7 +491,7 @@ IDirectDraw3Impl_CreateSurface(LPDIRECTDRAW3 This, LPDDSURFACEDESC pSDesc,
IDirectDrawSurface7, IDirectDrawSurface3,
pSurface7);
impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, pSurface7);
impl = (IDirectDrawSurfaceImpl *)pSurface7;
if(SUCCEEDED(hr) && impl)
{
set_surf_version(impl, 3);
......@@ -541,7 +521,7 @@ IDirectDraw4Impl_CreateSurface(LPDIRECTDRAW4 This, LPDDSURFACEDESC2 pSDesc,
pSDesc,
(LPDIRECTDRAWSURFACE7 *)ppSurface,
pUnkOuter);
impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurface);
impl = (IDirectDrawSurfaceImpl *)*ppSurface;
if(SUCCEEDED(hr) && impl)
{
set_surf_version(impl, 4);
......
......@@ -93,21 +93,6 @@ static inline WORD d3d_fpu_setup(void)
return oldcw;
}
static inline IDirect3DDeviceImpl *device_from_device1(IDirect3DDevice *iface)
{
return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice_vtbl));
}
static inline IDirect3DDeviceImpl *device_from_device2(IDirect3DDevice2 *iface)
{
return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice2_vtbl));
}
static inline IDirect3DDeviceImpl *device_from_device3(IDirect3DDevice3 *iface)
{
return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice3_vtbl));
}
/*****************************************************************************
* IUnknown Methods. Common for Version 1, 2, 3 and 7
*****************************************************************************/
......@@ -625,8 +610,8 @@ IDirect3DDeviceImpl_2_SwapTextureHandles(IDirect3DDevice2 *iface,
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
DWORD swap;
IDirectDrawSurfaceImpl *surf1 = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture2, Tex1);
IDirectDrawSurfaceImpl *surf2 = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture2, Tex2);
IDirectDrawSurfaceImpl *surf1 = surface_from_texture2(Tex1);
IDirectDrawSurfaceImpl *surf2 = surface_from_texture2(Tex2);
TRACE("(%p)->(%p,%p)\n", This, surf1, surf2);
EnterCriticalSection(&ddraw_cs);
......@@ -647,8 +632,8 @@ Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles(IDirect3DDevice *iface,
IDirect3DTexture *D3DTex2)
{
IDirect3DDeviceImpl *This = device_from_device1(iface);
IDirectDrawSurfaceImpl *surf1 = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture, D3DTex1);
IDirectDrawSurfaceImpl *surf2 = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture, D3DTex2);
IDirectDrawSurfaceImpl *surf1 = surface_from_texture1(D3DTex1);
IDirectDrawSurfaceImpl *surf2 = surface_from_texture1(D3DTex2);
IDirect3DTexture2 *t1 = surf1 ? (IDirect3DTexture2 *)&surf1->IDirect3DTexture2_vtbl : NULL;
IDirect3DTexture2 *t2 = surf2 ? (IDirect3DTexture2 *)&surf2->IDirect3DTexture2_vtbl : NULL;
TRACE_(ddraw_thunk)("(%p)->(%p,%p) thunking to IDirect3DDevice2 interface.\n", This, surf1, surf2);
......@@ -821,8 +806,8 @@ IDirect3DDeviceImpl_1_Execute(IDirect3DDevice *iface,
DWORD Flags)
{
IDirect3DDeviceImpl *This = device_from_device1(iface);
IDirect3DExecuteBufferImpl *Direct3DExecuteBufferImpl = ICOM_OBJECT(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, ExecuteBuffer);
IDirect3DViewportImpl *Direct3DViewportImpl = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Viewport);
IDirect3DExecuteBufferImpl *Direct3DExecuteBufferImpl = (IDirect3DExecuteBufferImpl *)ExecuteBuffer;
IDirect3DViewportImpl *Direct3DViewportImpl = (IDirect3DViewportImpl *)Viewport;
TRACE("(%p)->(%p,%p,%08x)\n", This, Direct3DExecuteBufferImpl, Direct3DViewportImpl, Flags);
......@@ -859,7 +844,7 @@ IDirect3DDeviceImpl_3_AddViewport(IDirect3DDevice3 *iface,
IDirect3DViewport3 *Viewport)
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Viewport);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport;
TRACE("(%p)->(%p)\n", This, vp);
......@@ -882,7 +867,7 @@ Thunk_IDirect3DDeviceImpl_2_AddViewport(IDirect3DDevice2 *iface,
IDirect3DViewport2 *Direct3DViewport2)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Direct3DViewport2);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport2;
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This, vp);
return IDirect3DDevice3_AddViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, (IDirect3DViewport3 *)vp);
}
......@@ -892,7 +877,7 @@ Thunk_IDirect3DDeviceImpl_1_AddViewport(IDirect3DDevice *iface,
IDirect3DViewport *Direct3DViewport)
{
IDirect3DDeviceImpl *This = device_from_device1(iface);
IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Direct3DViewport);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport;
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This, vp);
return IDirect3DDevice3_AddViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, (IDirect3DViewport3 *)vp);
}
......@@ -948,7 +933,7 @@ Thunk_IDirect3DDeviceImpl_2_DeleteViewport(IDirect3DDevice2 *iface,
IDirect3DViewport2 *Direct3DViewport2)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Direct3DViewport2);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport2;
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This, vp);
return IDirect3DDevice3_DeleteViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, (IDirect3DViewport3 *)vp);
}
......@@ -958,7 +943,7 @@ Thunk_IDirect3DDeviceImpl_1_DeleteViewport(IDirect3DDevice *iface,
IDirect3DViewport *Direct3DViewport)
{
IDirect3DDeviceImpl *This = device_from_device1(iface);
IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Direct3DViewport);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport;
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This, vp);
return IDirect3DDevice3_DeleteViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, (IDirect3DViewport3 *)vp);
}
......@@ -988,7 +973,7 @@ IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3 *iface,
DWORD Flags)
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Viewport3);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport3;
IDirect3DViewportImpl *res = NULL;
TRACE("(%p)->(%p,%p,%08x)\n", This, vp, lplpDirect3DViewport3, Flags);
......@@ -1041,7 +1026,7 @@ Thunk_IDirect3DDeviceImpl_2_NextViewport(IDirect3DDevice2 *iface,
DWORD Flags)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Viewport2);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport2;
IDirect3DViewport3 *res;
HRESULT hr;
TRACE_(ddraw_thunk)("(%p)->(%p,%p,%08x) thunking to IDirect3DDevice3 interface.\n", This, vp, lplpDirect3DViewport2, Flags);
......@@ -1058,7 +1043,7 @@ Thunk_IDirect3DDeviceImpl_1_NextViewport(IDirect3DDevice *iface,
DWORD Flags)
{
IDirect3DDeviceImpl *This = device_from_device1(iface);
IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Viewport);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport;
IDirect3DViewport3 *res;
HRESULT hr;
TRACE_(ddraw_thunk)("(%p)->(%p,%p,%08x) thunking to IDirect3DDevice3 interface.\n", This, vp, lplpDirect3DViewport, Flags);
......@@ -1097,8 +1082,8 @@ IDirect3DDeviceImpl_1_Pick(IDirect3DDevice *iface,
D3DRECT *Rect)
{
IDirect3DDeviceImpl *This = device_from_device1(iface);
IDirect3DExecuteBufferImpl *execbuf = ICOM_OBJECT(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, ExecuteBuffer);
IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Viewport);
IDirect3DExecuteBufferImpl *execbuf = (IDirect3DExecuteBufferImpl *)ExecuteBuffer;
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport;
FIXME("(%p)->(%p,%p,%08x,%p): stub!\n", This, execbuf, vp, Flags, Rect);
return D3D_OK;
......@@ -1865,7 +1850,7 @@ IDirect3DDeviceImpl_3_SetCurrentViewport(IDirect3DDevice3 *iface,
IDirect3DViewport3 *Direct3DViewport3)
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Direct3DViewport3);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport3;
TRACE("(%p)->(%p)\n", This, Direct3DViewport3);
EnterCriticalSection(&ddraw_cs);
......@@ -1903,7 +1888,7 @@ Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport(IDirect3DDevice2 *iface,
IDirect3DViewport2 *Direct3DViewport2)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Direct3DViewport2);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport2;
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This, vp);
return IDirect3DDevice3_SetCurrentViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl,
(IDirect3DViewport3 *)vp);
......@@ -1984,7 +1969,7 @@ IDirect3DDeviceImpl_7_SetRenderTarget(IDirect3DDevice7 *iface,
DWORD Flags)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirectDrawSurfaceImpl *Target = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, NewTarget);
IDirectDrawSurfaceImpl *Target = (IDirectDrawSurfaceImpl *)NewTarget;
HRESULT hr;
TRACE("(%p)->(%p,%08x): Relay\n", This, NewTarget, Flags);
......@@ -2043,7 +2028,7 @@ Thunk_IDirect3DDeviceImpl_3_SetRenderTarget(IDirect3DDevice3 *iface,
DWORD Flags)
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
IDirectDrawSurfaceImpl *Target = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, NewRenderTarget);
IDirectDrawSurfaceImpl *Target = (IDirectDrawSurfaceImpl *)NewRenderTarget;
TRACE_(ddraw_thunk)("(%p)->(%p,%08x) thunking to IDirect3DDevice7 interface.\n", This, Target, Flags);
return IDirect3DDevice7_SetRenderTarget((IDirect3DDevice7 *)This, (IDirectDrawSurface7 *)Target, Flags);
}
......@@ -2054,7 +2039,7 @@ Thunk_IDirect3DDeviceImpl_2_SetRenderTarget(IDirect3DDevice2 *iface,
DWORD Flags)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
IDirectDrawSurfaceImpl *Target = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface3, NewRenderTarget);
IDirectDrawSurfaceImpl *Target = (IDirectDrawSurfaceImpl *)NewRenderTarget;
TRACE_(ddraw_thunk)("(%p)->(%p,%08x) thunking to IDirect3DDevice7 interface.\n", This, Target, Flags);
return IDirect3DDevice7_SetRenderTarget((IDirect3DDevice7 *)This, (IDirectDrawSurface7 *)Target, Flags);
}
......@@ -2523,9 +2508,7 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
/* The parent of the texture is the IDirectDrawSurface7 interface
* of the ddraw surface
*/
IDirectDrawSurfaceImpl *texImpl = ICOM_OBJECT(IDirectDrawSurfaceImpl,
IDirectDrawSurface7,
parent);
IDirectDrawSurfaceImpl *texImpl = (IDirectDrawSurfaceImpl *)parent;
*lpdwRenderState = texImpl->Handle;
IDirectDrawSurface7_Release(parent);
}
......@@ -4258,7 +4241,7 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
DWORD Flags)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirect3DVertexBufferImpl *vb = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, D3DVertexBuf);
IDirect3DVertexBufferImpl *vb = (IDirect3DVertexBufferImpl *)D3DVertexBuf;
UINT PrimitiveCount;
HRESULT hr;
DWORD stride;
......@@ -4385,7 +4368,7 @@ Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB(IDirect3DDevice3 *iface,
DWORD Flags)
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
IDirect3DVertexBufferImpl *vb = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, D3DVertexBuf);
IDirect3DVertexBufferImpl *vb = D3DVertexBuf ? vb_from_vb1(D3DVertexBuf) : NULL;
TRACE_(ddraw_thunk)("(%p)->(%08x,%p,%08x,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This, PrimitiveType, vb, StartVertex, NumVertices, Flags);
return IDirect3DDevice7_DrawPrimitiveVB((IDirect3DDevice7 *)This, PrimitiveType,
(IDirect3DVertexBuffer7 *)vb, StartVertex, NumVertices, Flags);
......@@ -4420,7 +4403,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
DWORD Flags)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirect3DVertexBufferImpl *vb = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, D3DVertexBuf);
IDirect3DVertexBufferImpl *vb = (IDirect3DVertexBufferImpl *)D3DVertexBuf;
DWORD stride;
UINT PrimitiveCount;
WORD *LockedIndices;
......@@ -4587,7 +4570,7 @@ Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(IDirect3DDevice3 *iface,
DWORD Flags)
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
IDirect3DVertexBufferImpl *VB = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, D3DVertexBuf);
IDirect3DVertexBufferImpl *VB = vb_from_vb1(D3DVertexBuf);
TRACE_(ddraw_thunk)("(%p)->(%08x,%p,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This, PrimitiveType, VB, Indices, IndexCount, Flags);
return IDirect3DDevice7_DrawIndexedPrimitiveVB((IDirect3DDevice7 *)This, PrimitiveType,
......@@ -4789,7 +4772,7 @@ IDirect3DDeviceImpl_7_SetTexture(IDirect3DDevice7 *iface,
IDirectDrawSurface7 *Texture)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirectDrawSurfaceImpl *surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Texture);
IDirectDrawSurfaceImpl *surf = (IDirectDrawSurfaceImpl *)Texture;
HRESULT hr;
TRACE("(%p)->(%08x,%p): Relay!\n", This, Stage, surf);
......@@ -4831,7 +4814,7 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface,
IDirect3DTexture2 *Texture2)
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
IDirectDrawSurfaceImpl *tex = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture2, Texture2);
IDirectDrawSurfaceImpl *tex = Texture2 ? surface_from_texture2(Texture2) : NULL;
DWORD texmapblend;
HRESULT hr;
TRACE("(%p)->(%d,%p)\n", This, Stage, tex);
......@@ -5773,7 +5756,7 @@ IDirect3DDeviceImpl_7_PreLoad(IDirect3DDevice7 *iface,
IDirectDrawSurface7 *Texture)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirectDrawSurfaceImpl *surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Texture);
IDirectDrawSurfaceImpl *surf = (IDirectDrawSurfaceImpl *)Texture;
TRACE("(%p)->(%p): Relay!\n", This, surf);
......@@ -6111,7 +6094,7 @@ static BOOL is_mip_level_subset(IDirectDrawSurfaceImpl *dest,
if (dest_level != dest) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)dest_level);
dest_level = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, temp);
dest_level = (IDirectDrawSurfaceImpl *)temp;
}
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
......@@ -6120,7 +6103,7 @@ static BOOL is_mip_level_subset(IDirectDrawSurfaceImpl *dest,
if (src_level != src) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)src_level);
src_level = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, temp);
src_level = (IDirectDrawSurfaceImpl *)temp;
}
if (src_level && src_level != src) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)src_level);
......@@ -6211,7 +6194,7 @@ static void copy_mipmap_chain(IDirect3DDeviceImpl *device,
if (dest_level != dest) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)dest_level);
dest_level = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, temp);
dest_level = (IDirectDrawSurfaceImpl *)temp;
}
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
......@@ -6220,7 +6203,7 @@ static void copy_mipmap_chain(IDirect3DDeviceImpl *device,
if (src_level != src) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)src_level);
src_level = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, temp);
src_level = (IDirectDrawSurfaceImpl *)temp;
point.x /= 2;
point.y /= 2;
......@@ -6269,8 +6252,8 @@ IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
DWORD Flags)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirectDrawSurfaceImpl *dest = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DestTex);
IDirectDrawSurfaceImpl *src = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, SrcTex);
IDirectDrawSurfaceImpl *dest = (IDirectDrawSurfaceImpl *)DestTex;
IDirectDrawSurfaceImpl *src = (IDirectDrawSurfaceImpl *)SrcTex;
POINT destpoint;
RECT srcrect;
TRACE("(%p)->(%p,%p,%p,%p,%08x)\n", This, dest, DestPoint, src, SrcRect, Flags);
......@@ -6368,7 +6351,7 @@ IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
if (src_face != src) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)src_face);
src_face = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, temp);
src_face = (IDirectDrawSurfaceImpl *)temp;
}
else
{
......@@ -6386,7 +6369,7 @@ IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
if (dest_face != dest) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)dest_face);
dest_face = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, temp);
dest_face = (IDirectDrawSurfaceImpl *)temp;
}
else
{
......@@ -7052,7 +7035,7 @@ IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *This)
return WINED3DZB_FALSE;
}
dsi = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, depthStencil);
dsi = (IDirectDrawSurfaceImpl *)depthStencil;
TRACE("Setting wined3d depth stencil to %p (wined3d %p)\n", dsi, dsi->WineD3DSurface);
IWineD3DDevice_SetDepthStencilSurface(This->wineD3DDevice,
dsi->WineD3DSurface);
......
......@@ -40,26 +40,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
static inline IDirectDrawImpl *ddraw_from_d3d1(IDirect3D *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_d3d2(IDirect3D2 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D2_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_d3d3(IDirect3D3 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D3_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_d3d7(IDirect3D7 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D7_vtbl));
}
/*****************************************************************************
* IDirect3D7::QueryInterface
*
......@@ -767,7 +747,7 @@ IDirect3DImpl_7_CreateDevice(IDirect3D7 *iface,
IDirect3DDeviceImpl *object;
IParentImpl *IndexBufferParent;
HRESULT hr;
IDirectDrawSurfaceImpl *target = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Surface);
IDirectDrawSurfaceImpl *target = (IDirectDrawSurfaceImpl *)Surface;
TRACE("(%p)->(%s,%p,%p)\n", iface, debugstr_guid(refiid), Surface, Device);
EnterCriticalSection(&ddraw_cs);
......
......@@ -138,7 +138,7 @@ IDirect3DLightImpl_Initialize(IDirect3DLight *iface,
IDirect3D *lpDirect3D)
{
IDirect3DLightImpl *This = (IDirect3DLightImpl *)iface;
IDirectDrawImpl *d3d = ICOM_OBJECT(IDirectDrawImpl, IDirect3D, lpDirect3D);
IDirectDrawImpl *d3d = lpDirect3D ? ddraw_from_d3d1(lpDirect3D) : NULL;
TRACE("(%p)->(%p) no-op...\n", This, d3d);
return D3D_OK;
}
......
......@@ -747,7 +747,7 @@ DestroyCallback(IDirectDrawSurface7 *surf,
DDSURFACEDESC2 *desc,
void *context)
{
IDirectDrawSurfaceImpl *Impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, surf);
IDirectDrawSurfaceImpl *Impl = (IDirectDrawSurfaceImpl *)surf;
IDirectDrawImpl *ddraw = context;
ULONG ref;
......
......@@ -317,7 +317,7 @@ IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface,
D3DMATERIALHANDLE *lpHandle)
{
IDirect3DMaterialImpl *This = (IDirect3DMaterialImpl *)iface;
IDirect3DDeviceImpl *device = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice3, lpDirect3DDevice3);
IDirect3DDeviceImpl *device = device_from_device3(lpDirect3DDevice3);
TRACE("(%p/%p)->(%p,%p)\n", This, iface, device, lpHandle);
EnterCriticalSection(&ddraw_cs);
......
......@@ -707,7 +707,7 @@ IDirectDrawSurfaceImpl_Flip(IDirectDrawSurface7 *iface,
DWORD Flags)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawSurfaceImpl *Override = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DestOverride);
IDirectDrawSurfaceImpl *Override = (IDirectDrawSurfaceImpl *)DestOverride;
IDirectDrawSurface7 *Override7;
HRESULT hr;
TRACE("(%p)->(%p,%x)\n", This, DestOverride, Flags);
......@@ -734,7 +734,7 @@ IDirectDrawSurfaceImpl_Flip(IDirectDrawSurface7 *iface,
LeaveCriticalSection(&ddraw_cs);
return DDERR_NOTFLIPPABLE; /* Unchecked */
}
Override = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Override7);
Override = (IDirectDrawSurfaceImpl *)Override7;
/* For the GetAttachedSurface */
IDirectDrawSurface7_Release(Override7);
......@@ -773,8 +773,8 @@ IDirectDrawSurfaceImpl_Blt(IDirectDrawSurface7 *iface,
DDBLTFX *DDBltFx)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawSurfaceImpl *Src = (IDirectDrawSurfaceImpl *)SrcSurface;
HRESULT hr;
IDirectDrawSurfaceImpl *Src = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, SrcSurface);
TRACE("(%p)->(%p,%p,%p,%x,%p)\n", This, DestRect, Src, SrcRect, Flags, DDBltFx);
/* Check for validity of the flags here. WineD3D Has the software-opengl selection path and would have
......@@ -933,7 +933,7 @@ IDirectDrawSurface7Impl_AddAttachedSurface(IDirectDrawSurface7 *iface,
IDirectDrawSurface7 *Attach)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawSurfaceImpl *Surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Attach);
IDirectDrawSurfaceImpl *Surf = (IDirectDrawSurfaceImpl *)Attach;
/* Version 7 of this interface seems to refuse everything except z buffers, as per msdn */
if(!(Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
......@@ -968,7 +968,7 @@ IDirectDrawSurfaceImpl_DeleteAttachedSurface(IDirectDrawSurface7 *iface,
IDirectDrawSurface7 *Attach)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawSurfaceImpl *Surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Attach);
IDirectDrawSurfaceImpl *Surf = (IDirectDrawSurfaceImpl *)Attach;
IDirectDrawSurfaceImpl *Prev = This;
TRACE("(%p)->(%08x,%p)\n", This, Flags, Surf);
......@@ -1700,7 +1700,7 @@ IDirectDrawSurfaceImpl_Initialize(IDirectDrawSurface7 *iface,
DDSURFACEDESC2 *DDSD)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawImpl *ddimpl = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, DD);
IDirectDrawImpl *ddimpl = DD ? ddraw_from_ddraw1(DD) : NULL;
TRACE("(%p)->(%p,%p)\n",This,ddimpl,DDSD);
return DDERR_ALREADYINITIALIZED;
......@@ -1834,7 +1834,7 @@ IDirectDrawSurfaceImpl_UpdateOverlay(IDirectDrawSurface7 *iface,
LPDDOVERLAYFX FX)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawSurfaceImpl *Dst = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DstSurface);
IDirectDrawSurfaceImpl *Dst = (IDirectDrawSurfaceImpl *)DstSurface;
HRESULT hr;
TRACE("(%p)->(%p,%p,%p,%x,%p): Relay\n", This, SrcRect, Dst, DstRect, Flags, FX);
......@@ -1894,8 +1894,8 @@ IDirectDrawSurfaceImpl_UpdateOverlayZOrder(IDirectDrawSurface7 *iface,
IDirectDrawSurface7 *DDSRef)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawSurfaceImpl *Ref = (IDirectDrawSurfaceImpl *)DDSRef;
HRESULT hr;
IDirectDrawSurfaceImpl *Ref = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DDSRef);
TRACE("(%p)->(%x,%p): Relay\n", This, Flags, Ref);
EnterCriticalSection(&ddraw_cs);
......@@ -2099,8 +2099,8 @@ IDirectDrawSurfaceImpl_BltFast(IDirectDrawSurface7 *iface,
DWORD trans)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawSurfaceImpl *src = (IDirectDrawSurfaceImpl *)Source;
HRESULT hr;
IDirectDrawSurfaceImpl *src = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Source);
TRACE("(%p)->(%d,%d,%p,%p,%d): Relay\n", This, dstx, dsty, Source, rsrc, trans);
/* Source must be != NULL, This is not checked by windows. Windows happily throws a 0xc0000005
......@@ -2211,13 +2211,13 @@ IDirectDrawSurfaceImpl_SetClipper(IDirectDrawSurface7 *iface,
TRACE("(%p)->(%p)\n",This,Clipper);
EnterCriticalSection(&ddraw_cs);
if (ICOM_OBJECT(IDirectDrawClipperImpl, IDirectDrawClipper, Clipper) == This->clipper)
if ((IDirectDrawClipperImpl *)Clipper == This->clipper)
{
LeaveCriticalSection(&ddraw_cs);
return DD_OK;
}
This->clipper = ICOM_OBJECT(IDirectDrawClipperImpl, IDirectDrawClipper, Clipper);
This->clipper = (IDirectDrawClipperImpl *)Clipper;
if (Clipper != NULL)
IDirectDrawClipper_AddRef(Clipper);
......@@ -2543,7 +2543,7 @@ IDirectDrawSurfaceImpl_SetPalette(IDirectDrawSurface7 *iface,
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawPalette *oldPal;
IDirectDrawSurfaceImpl *surf;
IDirectDrawPaletteImpl *PalImpl = ICOM_OBJECT(IDirectDrawPaletteImpl, IDirectDrawPalette, Pal);
IDirectDrawPaletteImpl *PalImpl = (IDirectDrawPaletteImpl *)Pal;
HRESULT hr;
TRACE("(%p)->(%p)\n", This, Pal);
......@@ -2593,7 +2593,7 @@ IDirectDrawSurfaceImpl_SetPalette(IDirectDrawSurface7 *iface,
TRACE("Setting palette on %p\n", attach);
IDirectDrawSurface7_SetPalette(attach,
Pal);
surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, attach);
surf = (IDirectDrawSurfaceImpl *)attach;
IDirectDrawSurface7_Release(attach);
}
}
......
......@@ -75,7 +75,7 @@ IDirectDrawSurface3Impl_AddAttachedSurface(LPDIRECTDRAWSURFACE3 iface,
LPDIRECTDRAWSURFACE3 pAttach)
{
IDirectDrawSurfaceImpl *This = surface_from_surface3(iface);
IDirectDrawSurfaceImpl *Surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface3, pAttach);
IDirectDrawSurfaceImpl *Surf = surface_from_surface3(pAttach);
TRACE("(%p)->(%p)\n", This, Surf);
/* Tests suggest that
......
......@@ -45,16 +45,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
WINE_DECLARE_DEBUG_CHANNEL(ddraw_thunk);
static inline IDirectDrawSurfaceImpl *surface_from_texture1(IDirect3DTexture *iface)
{
return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirect3DTexture_vtbl));
}
static inline IDirectDrawSurfaceImpl *surface_from_texture2(IDirect3DTexture2 *iface)
{
return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirect3DTexture2_vtbl));
}
/*****************************************************************************
* IUnknown interfaces. They are thunks to IDirectDrawSurface7
*****************************************************************************/
......@@ -137,10 +127,7 @@ IDirect3DTextureImpl_1_Initialize(IDirect3DTexture *iface,
IDirect3DDevice *Direct3DDevice,
IDirectDrawSurface *DDSurface)
{
IDirectDrawSurfaceImpl *This = surface_from_texture1(iface);
IDirect3DDeviceImpl *d3d = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice, Direct3DDevice);
IDirectDrawSurfaceImpl *surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface3, DDSurface);
TRACE("(%p)->(%p,%p) Not implemented\n", This, d3d, surf);
TRACE("(%p)->(%p,%p) Not implemented\n", iface, Direct3DDevice, DDSurface);
return DDERR_UNSUPPORTED; /* Unchecked */
}
......@@ -219,7 +206,7 @@ IDirect3DTextureImpl_GetHandle(IDirect3DTexture2 *iface,
D3DTEXTUREHANDLE *lpHandle)
{
IDirectDrawSurfaceImpl *This = surface_from_texture2(iface);
IDirect3DDeviceImpl *d3d = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice2, Direct3DDevice2);
IDirect3DDeviceImpl *d3d = device_from_device2(Direct3DDevice2);
TRACE("(%p)->(%p,%p)\n", This, d3d, lpHandle);
......@@ -247,7 +234,7 @@ Thunk_IDirect3DTextureImpl_1_GetHandle(IDirect3DTexture *iface,
LPD3DTEXTUREHANDLE lpHandle)
{
IDirectDrawSurfaceImpl *This = surface_from_texture1(iface);
IDirect3DDeviceImpl *d3d = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice, lpDirect3DDevice);
IDirect3DDeviceImpl *d3d = device_from_device1(lpDirect3DDevice);
IDirect3DTexture2 *d3d_texture2 = (IDirect3DTexture2 *)&This->IDirect3DTexture2_vtbl;
IDirect3DDevice2 *d3d_device2 = (IDirect3DDevice2 *)&d3d->IDirect3DDevice2_vtbl;
......@@ -277,7 +264,7 @@ get_sub_mimaplevel(IDirectDrawSurfaceImpl *tex_ptr)
hr = IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)tex_ptr, &mipmap_caps, &next_level);
if (FAILED(hr)) return NULL;
surf_ptr = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, next_level);
surf_ptr = (IDirectDrawSurfaceImpl *)next_level;
IDirectDrawSurface7_Release(next_level);
return surf_ptr;
......@@ -305,7 +292,7 @@ IDirect3DTextureImpl_Load(IDirect3DTexture2 *iface,
IDirect3DTexture2 *D3DTexture2)
{
IDirectDrawSurfaceImpl *This = surface_from_texture2(iface);
IDirectDrawSurfaceImpl *src_ptr = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture2, D3DTexture2);
IDirectDrawSurfaceImpl *src_ptr = surface_from_texture2(D3DTexture2);
HRESULT ret_value = D3D_OK;
if(src_ptr == This)
{
......@@ -479,7 +466,7 @@ Thunk_IDirect3DTextureImpl_1_Load(IDirect3DTexture *iface,
IDirect3DTexture *D3DTexture)
{
IDirectDrawSurfaceImpl *This = surface_from_texture1(iface);
IDirectDrawSurfaceImpl *Texture = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture, D3DTexture);
IDirectDrawSurfaceImpl *Texture = surface_from_texture1(D3DTexture);
TRACE("(%p)->(%p) thunking to IDirect3DTexture2 interface.\n", This, Texture);
return IDirect3DTexture2_Load(COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirect3DTexture, IDirect3DTexture2, iface),
......
......@@ -44,12 +44,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
WINE_DECLARE_DEBUG_CHANNEL(ddraw_thunk);
static inline IDirect3DVertexBufferImpl *vb_from_vb1(IDirect3DVertexBuffer *iface)
{
return (IDirect3DVertexBufferImpl *)((char*)iface
- FIELD_OFFSET(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer_vtbl));
}
/*****************************************************************************
* IUnknown Methods
*****************************************************************************/
......@@ -346,8 +340,8 @@ IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface,
DWORD Flags)
{
IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
IDirect3DVertexBufferImpl *Src = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, SrcBuffer);
IDirect3DDeviceImpl *D3D = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice7, D3DDevice);
IDirect3DVertexBufferImpl *Src = (IDirect3DVertexBufferImpl *)SrcBuffer;
IDirect3DDeviceImpl *D3D = (IDirect3DDeviceImpl *)D3DDevice;
BOOL oldClip, doClip;
HRESULT hr;
WINED3DVERTEXBUFFER_DESC Desc;
......@@ -419,8 +413,8 @@ Thunk_IDirect3DVertexBufferImpl_1_ProcessVertices(IDirect3DVertexBuffer *iface,
DWORD Flags)
{
IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
IDirect3DVertexBufferImpl *Src = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, SrcBuffer);
IDirect3DDeviceImpl *D3D = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice3, D3DDevice);
IDirect3DVertexBufferImpl *Src = SrcBuffer ? vb_from_vb1(SrcBuffer) : NULL;
IDirect3DDeviceImpl *D3D = D3DDevice ? device_from_device3(D3DDevice) : NULL;
TRACE_(ddraw_thunk)("(%p)->(%08x,%08x,%08x,%p,%08x,%p,%08x) thunking to IDirect3DVertexBuffer7 interface.\n", This, VertexOp, DestIndex, Count, Src, SrcIndex, D3D, Flags);
......@@ -501,7 +495,7 @@ IDirect3DVertexBufferImpl_Optimize(IDirect3DVertexBuffer7 *iface,
DWORD Flags)
{
IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
IDirect3DDeviceImpl *D3D = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice7, D3DDevice);
IDirect3DDeviceImpl *D3D = (IDirect3DDeviceImpl *)D3DDevice;
static BOOL hide = FALSE;
if (!hide)
......@@ -526,7 +520,7 @@ Thunk_IDirect3DVertexBufferImpl_1_Optimize(IDirect3DVertexBuffer *iface,
DWORD Flags)
{
IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
IDirect3DDeviceImpl *D3D = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice3, D3DDevice);
IDirect3DDeviceImpl *D3D = D3DDevice ? device_from_device3(D3DDevice) : NULL;
TRACE_(ddraw_thunk)("(%p)->(%p,%08x) thunking to IDirect3DVertexBuffer7 interface.\n", This, D3D, Flags);
return IDirect3DVertexBuffer7_Optimize((IDirect3DVertexBuffer7 *)This, (IDirect3DDevice7 *)D3D, Flags);
......@@ -565,7 +559,7 @@ IDirect3DVertexBufferImpl_ProcessVerticesStrided(IDirect3DVertexBuffer7 *iface,
DWORD Flags)
{
IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
IDirect3DDeviceImpl *D3D = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice7, D3DDevice);
IDirect3DDeviceImpl *D3D = (IDirect3DDeviceImpl *)D3DDevice;
FIXME("(%p)->(%08x,%08x,%08x,%p,%08x,%p,%08x): stub!\n", This, VertexOp, DestIndex, Count, StrideData, VertexTypeDesc, D3D, Flags);
return DD_OK;
}
......
......@@ -314,8 +314,7 @@ IDirect3DViewportImpl_SetViewport(IDirect3DViewport3 *iface,
IDirect3DDevice3 *d3d_device3 = (IDirect3DDevice3 *)&This->active_device->IDirect3DDevice3_vtbl;
IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport);
if (current_viewport) {
if (ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, current_viewport) == This)
This->activate(This, FALSE);
if ((IDirect3DViewportImpl *)current_viewport == This) This->activate(This, FALSE);
IDirect3DViewport3_Release(current_viewport);
}
}
......@@ -699,7 +698,7 @@ IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface,
IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport);
if(current_viewport) {
IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, current_viewport);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)current_viewport;
vp->activate(vp, TRUE);
IDirect3DViewport3_Release(current_viewport);
}
......@@ -727,7 +726,7 @@ IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface,
IDirect3DLight *lpDirect3DLight)
{
IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface;
IDirect3DLightImpl *lpDirect3DLightImpl = ICOM_OBJECT(IDirect3DLightImpl, IDirect3DLight, lpDirect3DLight);
IDirect3DLightImpl *lpDirect3DLightImpl = (IDirect3DLightImpl *)lpDirect3DLight;
DWORD i = 0;
DWORD map = This->map_lights;
......@@ -783,7 +782,7 @@ IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *iface,
IDirect3DLight *lpDirect3DLight)
{
IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface;
IDirect3DLightImpl *lpDirect3DLightImpl = ICOM_OBJECT(IDirect3DLightImpl, IDirect3DLight, lpDirect3DLight);
IDirect3DLightImpl *lpDirect3DLightImpl = (IDirect3DLightImpl *)lpDirect3DLight;
IDirect3DLightImpl *cur_light, *prev_light = NULL;
TRACE("(%p)->(%p)\n", This, lpDirect3DLight);
......@@ -915,8 +914,7 @@ IDirect3DViewportImpl_SetViewport2(IDirect3DViewport3 *iface,
IDirect3DDevice3 *d3d_device3 = (IDirect3DDevice3 *)&This->active_device->IDirect3DDevice3_vtbl;
IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport);
if (current_viewport) {
if (ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, current_viewport) == This)
This->activate(This, FALSE);
if ((IDirect3DViewportImpl *)current_viewport == This) This->activate(This, FALSE);
IDirect3DViewport3_Release(current_viewport);
}
}
......@@ -1019,7 +1017,7 @@ IDirect3DViewportImpl_Clear2(IDirect3DViewport3 *iface,
dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil);
IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport);
if(current_viewport) {
IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, current_viewport);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)current_viewport;
vp->activate(vp, TRUE);
IDirect3DViewport3_Release(current_viewport);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment