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);
......
......@@ -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