Commit b09b0fbf authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Get rid of ddcomimpl.h.

parent 802f9c7e
/* A few helpful macros for implementing COM objects.
*
* Copyright 2000 TransGaming Technologies Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _DDCOMIMPL_H_
#define _DDCOMIMPL_H_
#include <stddef.h>
#define COM_INTERFACE_CAST(impltype, ifnamefrom, ifnameto, ifaceptr) \
((ifaceptr) ? (ifnameto *)&(((impltype *)((char *)(ifaceptr) \
- offsetof(impltype, ifnamefrom##_vtbl)))->ifnameto##_vtbl) : NULL)
#endif /* _DDCOMIMPL_H_ */
......@@ -33,8 +33,6 @@
#include "ddrawi.h"
#include "d3d.h"
#include "ddcomimpl.h"
#include "wine/list.h"
#ifdef DDRAW_INIT_GUID
#include "initguid.h"
......@@ -332,6 +330,11 @@ static inline IDirectDrawSurfaceImpl *surface_from_texture2(IDirect3DTexture2 *i
return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirect3DTexture2_vtbl));
}
static inline IDirectDrawSurfaceImpl *surface_from_surface3(IDirectDrawSurface3 *iface)
{
return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirectDrawSurface3_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)
......
......@@ -45,37 +45,25 @@ WINE_DECLARE_DEBUG_CHANNEL(ddraw);
static HRESULT WINAPI
IDirectDrawImpl_QueryInterface(LPDIRECTDRAW This, REFIID iid, LPVOID *ppObj)
{
return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7, This),
iid, ppObj);
return IDirectDraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw1(This), iid, ppObj);
}
static HRESULT WINAPI
IDirectDraw2Impl_QueryInterface(LPDIRECTDRAW2 This, REFIID iid, LPVOID *ppObj)
{
return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7, This),
iid, ppObj);
return IDirectDraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw2(This), iid, ppObj);
}
static HRESULT WINAPI
IDirectDraw3Impl_QueryInterface(LPDIRECTDRAW3 This, REFIID iid, LPVOID *ppObj)
{
return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7, This),
iid, ppObj);
return IDirectDraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw3(This), iid, ppObj);
}
static HRESULT WINAPI
IDirectDraw4Impl_QueryInterface(LPDIRECTDRAW4 This, REFIID iid, LPVOID *ppObj)
{
return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7, This),
iid, ppObj);
return IDirectDraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw4(This), iid, ppObj);
}
static ULONG WINAPI
......@@ -201,33 +189,25 @@ IDirectDraw4Impl_Release(LPDIRECTDRAW4 iface)
static HRESULT WINAPI
IDirectDrawImpl_Compact(LPDIRECTDRAW This)
{
return IDirectDraw7_Compact(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw, IDirectDraw7,
This));
return IDirectDraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw1(This));
}
static HRESULT WINAPI
IDirectDraw2Impl_Compact(LPDIRECTDRAW2 This)
{
return IDirectDraw7_Compact(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2, IDirectDraw7,
This));
return IDirectDraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw2(This));
}
static HRESULT WINAPI
IDirectDraw3Impl_Compact(LPDIRECTDRAW3 This)
{
return IDirectDraw7_Compact(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3, IDirectDraw7,
This));
return IDirectDraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw3(This));
}
static HRESULT WINAPI
IDirectDraw4Impl_Compact(LPDIRECTDRAW4 This)
{
return IDirectDraw7_Compact(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4, IDirectDraw7,
This));
return IDirectDraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw4(This));
}
static HRESULT WINAPI
......@@ -235,11 +215,7 @@ IDirectDrawImpl_CreateClipper(LPDIRECTDRAW This, DWORD dwFlags,
LPDIRECTDRAWCLIPPER *ppClipper,
IUnknown *pUnkOuter)
{
return IDirectDraw7_CreateClipper(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This),
dwFlags, ppClipper, pUnkOuter);
return IDirectDraw7_CreateClipper((IDirectDraw7 *)ddraw_from_ddraw1(This), dwFlags, ppClipper, pUnkOuter);
}
static HRESULT WINAPI
......@@ -247,11 +223,7 @@ IDirectDraw2Impl_CreateClipper(LPDIRECTDRAW2 This, DWORD dwFlags,
LPDIRECTDRAWCLIPPER *ppClipper,
IUnknown *pUnkOuter)
{
return IDirectDraw7_CreateClipper(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This),
dwFlags, ppClipper, pUnkOuter);
return IDirectDraw7_CreateClipper((IDirectDraw7 *)ddraw_from_ddraw2(This), dwFlags, ppClipper, pUnkOuter);
}
static HRESULT WINAPI
......@@ -259,11 +231,7 @@ IDirectDraw3Impl_CreateClipper(LPDIRECTDRAW3 This, DWORD dwFlags,
LPDIRECTDRAWCLIPPER *ppClipper,
IUnknown *pUnkOuter)
{
return IDirectDraw7_CreateClipper(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This),
dwFlags, ppClipper, pUnkOuter);
return IDirectDraw7_CreateClipper((IDirectDraw7 *)ddraw_from_ddraw3(This), dwFlags, ppClipper, pUnkOuter);
}
static HRESULT WINAPI
......@@ -271,11 +239,7 @@ IDirectDraw4Impl_CreateClipper(LPDIRECTDRAW4 This, DWORD dwFlags,
LPDIRECTDRAWCLIPPER *ppClipper,
IUnknown *pUnkOuter)
{
return IDirectDraw7_CreateClipper(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
dwFlags, ppClipper, pUnkOuter);
return IDirectDraw7_CreateClipper((IDirectDraw7 *)ddraw_from_ddraw4(This), dwFlags, ppClipper, pUnkOuter);
}
static HRESULT WINAPI
......@@ -285,18 +249,11 @@ IDirectDrawImpl_CreatePalette(LPDIRECTDRAW This, DWORD dwFlags,
IUnknown *pUnkOuter)
{
HRESULT hr;
hr = IDirectDraw7_CreatePalette(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This),
dwFlags, pEntries, ppPalette, pUnkOuter);
hr = IDirectDraw7_CreatePalette((IDirectDraw7 *)ddraw_from_ddraw1(This), dwFlags, pEntries, ppPalette, pUnkOuter);
if(SUCCEEDED(hr) && *ppPalette)
{
IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*ppPalette;
IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This));
IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw1(This));
impl->ifaceToRelease = NULL;
}
......@@ -310,18 +267,11 @@ IDirectDraw2Impl_CreatePalette(LPDIRECTDRAW2 This, DWORD dwFlags,
IUnknown *pUnkOuter)
{
HRESULT hr;
hr = IDirectDraw7_CreatePalette(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This),
dwFlags, pEntries, ppPalette, pUnkOuter);
hr = IDirectDraw7_CreatePalette((IDirectDraw7 *)ddraw_from_ddraw2(This), dwFlags, pEntries, ppPalette, pUnkOuter);
if(SUCCEEDED(hr) && *ppPalette)
{
IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*ppPalette;
IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This));
IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw2(This));
impl->ifaceToRelease = NULL;
}
return hr;
......@@ -334,18 +284,11 @@ IDirectDraw3Impl_CreatePalette(LPDIRECTDRAW3 This, DWORD dwFlags,
IUnknown *pUnkOuter)
{
HRESULT hr;
hr = IDirectDraw7_CreatePalette(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This),
dwFlags, pEntries, ppPalette, pUnkOuter);
hr = IDirectDraw7_CreatePalette((IDirectDraw7 *)ddraw_from_ddraw3(This), dwFlags, pEntries, ppPalette, pUnkOuter);
if(SUCCEEDED(hr) && *ppPalette)
{
IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*ppPalette;
IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This));
IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw3(This));
IDirectDraw4_AddRef(This);
impl->ifaceToRelease = (IUnknown *) This;
}
......@@ -359,18 +302,11 @@ IDirectDraw4Impl_CreatePalette(LPDIRECTDRAW4 This, DWORD dwFlags,
IUnknown *pUnkOuter)
{
HRESULT hr;
hr = IDirectDraw7_CreatePalette(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
dwFlags, pEntries, ppPalette, pUnkOuter);
hr = IDirectDraw7_CreatePalette((IDirectDraw7 *)ddraw_from_ddraw4(This), dwFlags, pEntries, ppPalette, pUnkOuter);
if(SUCCEEDED(hr) && *ppPalette)
{
IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*ppPalette;
IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This));
IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw4(This));
IDirectDraw4_AddRef(This);
impl->ifaceToRelease = (IUnknown *) This;
}
......@@ -409,26 +345,19 @@ IDirectDrawImpl_CreateSurface(LPDIRECTDRAW This, LPDDSURFACEDESC pSDesc,
pSDesc->ddsCaps.dwCaps &= ~DDSCAPS_FRONTBUFFER;
/* the LPDDSURFACEDESC -> LPDDSURFACEDESC2 conversion should be ok,
* since the data layout is the same */
hr = IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This),
(LPDDSURFACEDESC2)pSDesc, &pSurface7, pUnkOuter);
hr = IDirectDraw7_CreateSurface((IDirectDraw7 *)ddraw_from_ddraw1(This),
(LPDDSURFACEDESC2)pSDesc, &pSurface7, pUnkOuter);
/* This coercion is safe, since the IDirectDrawSurface3 vtable has the
* IDirectDrawSurface vtable layout at the beginning */
*ppSurface = (LPDIRECTDRAWSURFACE) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
IDirectDrawSurface7, IDirectDrawSurface3,
pSurface7);
*ppSurface = pSurface7 ?
(IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pSurface7)->IDirectDrawSurface3_vtbl : NULL;
impl = (IDirectDrawSurfaceImpl *)pSurface7;
if(SUCCEEDED(hr) && impl)
{
set_surf_version(impl, 1);
IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This));
IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw1(This));
impl->ifaceToRelease = NULL;
}
......@@ -444,26 +373,19 @@ IDirectDraw2Impl_CreateSurface(LPDIRECTDRAW2 This, LPDDSURFACEDESC pSDesc,
IDirectDrawSurfaceImpl *impl;
HRESULT hr;
hr = IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This),
(LPDDSURFACEDESC2)pSDesc, &pSurface7, pUnkOuter);
hr = IDirectDraw7_CreateSurface((IDirectDraw7 *)ddraw_from_ddraw2(This),
(LPDDSURFACEDESC2)pSDesc, &pSurface7, pUnkOuter);
/* This coercion is safe, since the IDirectDrawSurface3 vtable has the
* IDirectDrawSurface vtable layout at the beginning */
*ppSurface = (LPDIRECTDRAWSURFACE)COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
IDirectDrawSurface7, IDirectDrawSurface3,
pSurface7);
*ppSurface = pSurface7 ?
(IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pSurface7)->IDirectDrawSurface3_vtbl : NULL;
impl = (IDirectDrawSurfaceImpl *)pSurface7;
if(SUCCEEDED(hr) && impl)
{
set_surf_version(impl, 2);
IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This));
IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw2(This));
impl->ifaceToRelease = NULL;
}
......@@ -479,26 +401,19 @@ IDirectDraw3Impl_CreateSurface(LPDIRECTDRAW3 This, LPDDSURFACEDESC pSDesc,
IDirectDrawSurfaceImpl *impl;
HRESULT hr;
hr = IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This),
(LPDDSURFACEDESC2)pSDesc, &pSurface7, pUnkOuter);
hr = IDirectDraw7_CreateSurface((IDirectDraw7 *)ddraw_from_ddraw3(This),
(LPDDSURFACEDESC2)pSDesc, &pSurface7, pUnkOuter);
/* This coercion is safe, since the IDirectDrawSurface3 vtable has the
* IDirectDrawSurface vtable layout at the beginning */
*ppSurface = (LPDIRECTDRAWSURFACE)COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
IDirectDrawSurface7, IDirectDrawSurface3,
pSurface7);
*ppSurface = pSurface7 ?
(IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pSurface7)->IDirectDrawSurface3_vtbl : NULL;
impl = (IDirectDrawSurfaceImpl *)pSurface7;
if(SUCCEEDED(hr) && impl)
{
set_surf_version(impl, 3);
IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This));
IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw3(This));
IDirectDraw3_AddRef(This);
impl->ifaceToRelease = (IUnknown *) This;
}
......@@ -514,21 +429,13 @@ IDirectDraw4Impl_CreateSurface(LPDIRECTDRAW4 This, LPDDSURFACEDESC2 pSDesc,
HRESULT hr;
IDirectDrawSurfaceImpl *impl;
hr = IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
pSDesc,
(LPDIRECTDRAWSURFACE7 *)ppSurface,
pUnkOuter);
hr = IDirectDraw7_CreateSurface((IDirectDraw7 *)ddraw_from_ddraw4(This),
pSDesc, (LPDIRECTDRAWSURFACE7 *)ppSurface, pUnkOuter);
impl = (IDirectDrawSurfaceImpl *)*ppSurface;
if(SUCCEEDED(hr) && impl)
{
set_surf_version(impl, 4);
IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This));
IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw4(This));
IDirectDraw4_AddRef(This);
impl->ifaceToRelease = (IUnknown *) This;
}
......@@ -542,19 +449,12 @@ IDirectDrawImpl_DuplicateSurface(LPDIRECTDRAW This, LPDIRECTDRAWSURFACE pSrc,
LPDIRECTDRAWSURFACE7 pDst7;
HRESULT hr;
hr = IDirectDraw7_DuplicateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7, This),
COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
IDirectDrawSurface3,
IDirectDrawSurface7,
pSrc),
&pDst7);
hr = IDirectDraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw1(This),
pSrc ? (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)pSrc) : NULL, &pDst7);
/* This coercion is safe, since the IDirectDrawSurface3 vtable has the
* IDirectDrawSurface vtable layout at the beginning */
*ppDst = (LPDIRECTDRAWSURFACE)COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
IDirectDrawSurface3, pDst7);
*ppDst = pDst7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pDst7)->IDirectDrawSurface3_vtbl : NULL;
return hr;
}
......@@ -566,19 +466,12 @@ IDirectDraw2Impl_DuplicateSurface(LPDIRECTDRAW2 This, LPDIRECTDRAWSURFACE pSrc,
LPDIRECTDRAWSURFACE7 pDst7;
HRESULT hr;
hr = IDirectDraw7_DuplicateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7, This),
COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
IDirectDrawSurface3,
IDirectDrawSurface7,
pSrc),
&pDst7);
hr = IDirectDraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw2(This),
pSrc ? (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)pSrc) : NULL, &pDst7);
/* This coercion is safe, since the IDirectDrawSurface3 vtable has the
* IDirectDrawSurface vtable layout at the beginning */
*ppDst = (LPDIRECTDRAWSURFACE)COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
IDirectDrawSurface3, pDst7);
*ppDst = pDst7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pDst7)->IDirectDrawSurface3_vtbl : NULL;
return hr;
}
......@@ -590,19 +483,12 @@ IDirectDraw3Impl_DuplicateSurface(LPDIRECTDRAW3 This, LPDIRECTDRAWSURFACE pSrc,
LPDIRECTDRAWSURFACE7 pDst7;
HRESULT hr;
hr = IDirectDraw7_DuplicateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7, This),
COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
IDirectDrawSurface3,
IDirectDrawSurface7,
pSrc),
&pDst7);
hr = IDirectDraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw3(This),
pSrc ? (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)pSrc) : NULL, &pDst7);
/* This coercion is safe, since the IDirectDrawSurface3 vtable has the
* IDirectDrawSurface vtable layout at the beginning */
*ppDst = (LPDIRECTDRAWSURFACE)COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
IDirectDrawSurface3, pDst7);
*ppDst = pDst7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pDst7)->IDirectDrawSurface3_vtbl : NULL;
return hr;
}
......@@ -612,12 +498,8 @@ IDirectDraw4Impl_DuplicateSurface(LPDIRECTDRAW4 This,
LPDIRECTDRAWSURFACE4 pSrc,
LPDIRECTDRAWSURFACE4 *ppDst)
{
return IDirectDraw7_DuplicateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
(LPDIRECTDRAWSURFACE7)pSrc,
(LPDIRECTDRAWSURFACE7 *)ppDst);
return IDirectDraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw4(This),
(LPDIRECTDRAWSURFACE7)pSrc, (LPDIRECTDRAWSURFACE7 *)ppDst);
}
struct displaymodescallback_context
......@@ -648,12 +530,8 @@ IDirectDrawImpl_EnumDisplayModes(LPDIRECTDRAW This, DWORD dwFlags,
cbcontext.func = cb;
cbcontext.context = context;
return IDirectDraw7_EnumDisplayModes(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This),
dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext,
EnumDisplayModesCallbackThunk);
return IDirectDraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw1(This),
dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext, EnumDisplayModesCallbackThunk);
}
static HRESULT WINAPI
......@@ -666,12 +544,8 @@ IDirectDraw2Impl_EnumDisplayModes(LPDIRECTDRAW2 This, DWORD dwFlags,
cbcontext.func = cb;
cbcontext.context = context;
return IDirectDraw7_EnumDisplayModes(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This),
dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext,
EnumDisplayModesCallbackThunk);
return IDirectDraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw2(This),
dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext, EnumDisplayModesCallbackThunk);
}
static HRESULT WINAPI
......@@ -684,12 +558,8 @@ IDirectDraw3Impl_EnumDisplayModes(LPDIRECTDRAW3 This, DWORD dwFlags,
cbcontext.func = cb;
cbcontext.context = context;
return IDirectDraw7_EnumDisplayModes(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This),
dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext,
EnumDisplayModesCallbackThunk);
return IDirectDraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw3(This),
dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext, EnumDisplayModesCallbackThunk);
}
static HRESULT WINAPI
......@@ -697,11 +567,7 @@ IDirectDraw4Impl_EnumDisplayModes(LPDIRECTDRAW4 This, DWORD dwFlags,
LPDDSURFACEDESC2 pDDSD, LPVOID context,
LPDDENUMMODESCALLBACK2 cb)
{
return IDirectDraw7_EnumDisplayModes(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
dwFlags, pDDSD, context, cb);
return IDirectDraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw4(This), dwFlags, pDDSD, context, cb);
}
struct surfacescallback_context
......@@ -718,11 +584,9 @@ EnumSurfacesCallbackThunk(LPDIRECTDRAWSURFACE7 pSurf, LPDDSURFACEDESC2 pDDSD,
/* This coercion is safe, since the IDirectDrawSurface3 vtable has the
* IDirectDrawSurface vtable layout at the beginning */
return cbcontext->func((LPDIRECTDRAWSURFACE)
COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
IDirectDrawSurface7,
IDirectDrawSurface3, pSurf),
(LPDDSURFACEDESC)pDDSD, cbcontext->context);
return cbcontext->func(
pSurf ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pSurf)->IDirectDrawSurface3_vtbl : NULL,
(LPDDSURFACEDESC)pDDSD, cbcontext->context);
}
static HRESULT WINAPI
......@@ -735,11 +599,8 @@ IDirectDrawImpl_EnumSurfaces(LPDIRECTDRAW This, DWORD dwFlags,
cbcontext.func = cb;
cbcontext.context = context;
return IDirectDraw7_EnumSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7, This),
dwFlags, (LPDDSURFACEDESC2)pDDSD,
&cbcontext, EnumSurfacesCallbackThunk);
return IDirectDraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw1(This),
dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext, EnumSurfacesCallbackThunk);
}
static HRESULT WINAPI
......@@ -752,11 +613,8 @@ IDirectDraw2Impl_EnumSurfaces(LPDIRECTDRAW2 This, DWORD dwFlags,
cbcontext.func = cb;
cbcontext.context = context;
return IDirectDraw7_EnumSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7, This),
dwFlags, (LPDDSURFACEDESC2)pDDSD,
&cbcontext, EnumSurfacesCallbackThunk);
return IDirectDraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw2(This),
dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext, EnumSurfacesCallbackThunk);
}
static HRESULT WINAPI
......@@ -769,11 +627,8 @@ IDirectDraw3Impl_EnumSurfaces(LPDIRECTDRAW3 This, DWORD dwFlags,
cbcontext.func = cb;
cbcontext.context = context;
return IDirectDraw7_EnumSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7, This),
dwFlags, (LPDDSURFACEDESC2)pDDSD,
&cbcontext, EnumSurfacesCallbackThunk);
return IDirectDraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw3(This),
dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext, EnumSurfacesCallbackThunk);
}
static HRESULT WINAPI
......@@ -781,159 +636,108 @@ IDirectDraw4Impl_EnumSurfaces(LPDIRECTDRAW4 This, DWORD dwFlags,
LPDDSURFACEDESC2 pDDSD, LPVOID context,
LPDDENUMSURFACESCALLBACK2 cb)
{
return IDirectDraw7_EnumSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7, This),
dwFlags, pDDSD, context,
(LPDDENUMSURFACESCALLBACK7)cb);
return IDirectDraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw4(This),
dwFlags, pDDSD, context, (LPDDENUMSURFACESCALLBACK7)cb);
}
static HRESULT WINAPI
IDirectDrawImpl_FlipToGDISurface(LPDIRECTDRAW This)
{
return IDirectDraw7_FlipToGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This));
return IDirectDraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw1(This));
}
static HRESULT WINAPI
IDirectDraw2Impl_FlipToGDISurface(LPDIRECTDRAW2 This)
{
return IDirectDraw7_FlipToGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This));
return IDirectDraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw2(This));
}
static HRESULT WINAPI
IDirectDraw3Impl_FlipToGDISurface(LPDIRECTDRAW3 This)
{
return IDirectDraw7_FlipToGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This));
return IDirectDraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw3(This));
}
static HRESULT WINAPI
IDirectDraw4Impl_FlipToGDISurface(LPDIRECTDRAW4 This)
{
return IDirectDraw7_FlipToGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This));
return IDirectDraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw4(This));
}
static HRESULT WINAPI
IDirectDrawImpl_GetCaps(LPDIRECTDRAW This, LPDDCAPS pDDC1, LPDDCAPS pDDC2)
{
return IDirectDraw7_GetCaps(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw, IDirectDraw7,
This), pDDC1, pDDC2);
return IDirectDraw7_GetCaps((IDirectDraw7 *)ddraw_from_ddraw1(This), pDDC1, pDDC2);
}
static HRESULT WINAPI
IDirectDraw2Impl_GetCaps(LPDIRECTDRAW2 This, LPDDCAPS pDDC1, LPDDCAPS pDDC2)
{
return IDirectDraw7_GetCaps(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2, IDirectDraw7,
This), pDDC1, pDDC2);
return IDirectDraw7_GetCaps((IDirectDraw7 *)ddraw_from_ddraw2(This), pDDC1, pDDC2);
}
static HRESULT WINAPI
IDirectDraw3Impl_GetCaps(LPDIRECTDRAW3 This, LPDDCAPS pDDC1, LPDDCAPS pDDC2)
{
return IDirectDraw7_GetCaps(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3, IDirectDraw7,
This), pDDC1, pDDC2);
return IDirectDraw7_GetCaps((IDirectDraw7 *)ddraw_from_ddraw3(This), pDDC1, pDDC2);
}
static HRESULT WINAPI
IDirectDraw4Impl_GetCaps(LPDIRECTDRAW4 This, LPDDCAPS pDDC1, LPDDCAPS pDDC2)
{
return IDirectDraw7_GetCaps(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4, IDirectDraw7,
This), pDDC1, pDDC2);
return IDirectDraw7_GetCaps((IDirectDraw7 *)ddraw_from_ddraw4(This), pDDC1, pDDC2);
}
static HRESULT WINAPI
IDirectDrawImpl_GetDisplayMode(LPDIRECTDRAW This, LPDDSURFACEDESC pDDSD)
{
return IDirectDraw7_GetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7, This),
(LPDDSURFACEDESC2)pDDSD);
return IDirectDraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw1(This), (LPDDSURFACEDESC2)pDDSD);
}
static HRESULT WINAPI
IDirectDraw2Impl_GetDisplayMode(LPDIRECTDRAW2 This, LPDDSURFACEDESC pDDSD)
{
return IDirectDraw7_GetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7, This),
(LPDDSURFACEDESC2)pDDSD);
return IDirectDraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw2(This), (LPDDSURFACEDESC2)pDDSD);
}
static HRESULT WINAPI
IDirectDraw3Impl_GetDisplayMode(LPDIRECTDRAW3 This, LPDDSURFACEDESC pDDSD)
{
return IDirectDraw7_GetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7, This),
(LPDDSURFACEDESC2)pDDSD);
return IDirectDraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw3(This), (LPDDSURFACEDESC2)pDDSD);
}
static HRESULT WINAPI
IDirectDraw4Impl_GetDisplayMode(LPDIRECTDRAW4 This, LPDDSURFACEDESC2 pDDSD)
{
return IDirectDraw7_GetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7, This),
pDDSD);
return IDirectDraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw4(This), (LPDDSURFACEDESC2)pDDSD);
}
static HRESULT WINAPI
IDirectDrawImpl_GetFourCCCodes(LPDIRECTDRAW This, LPDWORD lpNumCodes,
LPDWORD lpCodes)
{
return IDirectDraw7_GetFourCCCodes(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This),
lpNumCodes, lpCodes);
return IDirectDraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw1(This), lpNumCodes, lpCodes);
}
static HRESULT WINAPI
IDirectDraw2Impl_GetFourCCCodes(LPDIRECTDRAW2 This, LPDWORD lpNumCodes,
LPDWORD lpCodes)
{
return IDirectDraw7_GetFourCCCodes(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This),
lpNumCodes, lpCodes);
return IDirectDraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw2(This), lpNumCodes, lpCodes);
}
static HRESULT WINAPI
IDirectDraw3Impl_GetFourCCCodes(LPDIRECTDRAW3 This, LPDWORD lpNumCodes,
LPDWORD lpCodes)
{
return IDirectDraw7_GetFourCCCodes(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This),
lpNumCodes, lpCodes);
return IDirectDraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw3(This), lpNumCodes, lpCodes);
}
static HRESULT WINAPI
IDirectDraw4Impl_GetFourCCCodes(LPDIRECTDRAW4 This, LPDWORD lpNumCodes,
LPDWORD lpCodes)
{
return IDirectDraw7_GetFourCCCodes(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
lpNumCodes, lpCodes);
return IDirectDraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw4(This), lpNumCodes, lpCodes);
}
static HRESULT WINAPI
......@@ -942,15 +746,11 @@ IDirectDrawImpl_GetGDISurface(LPDIRECTDRAW This, LPDIRECTDRAWSURFACE *ppSurf)
LPDIRECTDRAWSURFACE7 pSurf7;
HRESULT hr;
hr = IDirectDraw7_GetGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This), &pSurf7);
hr = IDirectDraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw1(This), &pSurf7);
/* This coercion is safe, since the IDirectDrawSurface3 vtable has the
* IDirectDrawSurface vtable layout at the beginning */
*ppSurf = (LPDIRECTDRAWSURFACE)COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
IDirectDrawSurface3, pSurf7);
*ppSurf = pSurf7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pSurf7)->IDirectDrawSurface3_vtbl : NULL;
return hr;
}
......@@ -961,15 +761,11 @@ IDirectDraw2Impl_GetGDISurface(LPDIRECTDRAW2 This, LPDIRECTDRAWSURFACE *ppSurf)
LPDIRECTDRAWSURFACE7 pSurf7;
HRESULT hr;
hr = IDirectDraw7_GetGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This), &pSurf7);
hr = IDirectDraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw2(This), &pSurf7);
/* This coercion is safe, since the IDirectDrawSurface3 vtable has the
* IDirectDrawSurface vtable layout at the beginning */
*ppSurf = (LPDIRECTDRAWSURFACE)COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
IDirectDrawSurface3, pSurf7);
*ppSurf = pSurf7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pSurf7)->IDirectDrawSurface3_vtbl : NULL;
return hr;
}
......@@ -980,15 +776,11 @@ IDirectDraw3Impl_GetGDISurface(LPDIRECTDRAW3 This, LPDIRECTDRAWSURFACE *ppSurf)
LPDIRECTDRAWSURFACE7 pSurf7;
HRESULT hr;
hr = IDirectDraw7_GetGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This), &pSurf7);
hr = IDirectDraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw3(This), &pSurf7);
/* This coercion is safe, since the IDirectDrawSurface3 vtable has the
* IDirectDrawSurface vtable layout at the beginning */
*ppSurf = (LPDIRECTDRAWSURFACE)COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
IDirectDrawSurface3, pSurf7);
*ppSurf = pSurf7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pSurf7)->IDirectDrawSurface3_vtbl : NULL;
return hr;
}
......@@ -997,127 +789,79 @@ static HRESULT WINAPI
IDirectDraw4Impl_GetGDISurface(LPDIRECTDRAW4 This,
LPDIRECTDRAWSURFACE4 *ppSurf)
{
return IDirectDraw7_GetGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
(LPDIRECTDRAWSURFACE7 *)ppSurf);
return IDirectDraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw4(This), (LPDIRECTDRAWSURFACE7 *)ppSurf);
}
static HRESULT WINAPI
IDirectDrawImpl_GetMonitorFrequency(LPDIRECTDRAW This, LPDWORD pdwFreq)
{
return IDirectDraw7_GetMonitorFrequency(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This),
pdwFreq);
return IDirectDraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw1(This), pdwFreq);
}
static HRESULT WINAPI
IDirectDraw2Impl_GetMonitorFrequency(LPDIRECTDRAW2 This, LPDWORD pdwFreq)
{
return IDirectDraw7_GetMonitorFrequency(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This),
pdwFreq);
return IDirectDraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw2(This), pdwFreq);
}
static HRESULT WINAPI
IDirectDraw3Impl_GetMonitorFrequency(LPDIRECTDRAW3 This, LPDWORD pdwFreq)
{
return IDirectDraw7_GetMonitorFrequency(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This),
pdwFreq);
return IDirectDraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw3(This), pdwFreq);
}
static HRESULT WINAPI
IDirectDraw4Impl_GetMonitorFrequency(LPDIRECTDRAW4 This, LPDWORD pdwFreq)
{
return IDirectDraw7_GetMonitorFrequency(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
pdwFreq);
return IDirectDraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw4(This), pdwFreq);
}
static HRESULT WINAPI
IDirectDrawImpl_GetScanLine(LPDIRECTDRAW This, LPDWORD pdwLine)
{
return IDirectDraw7_GetScanLine(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This), pdwLine);
return IDirectDraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw1(This), pdwLine);
}
static HRESULT WINAPI
IDirectDraw2Impl_GetScanLine(LPDIRECTDRAW2 This, LPDWORD pdwLine)
{
return IDirectDraw7_GetScanLine(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This), pdwLine);
return IDirectDraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw2(This), pdwLine);
}
static HRESULT WINAPI
IDirectDraw3Impl_GetScanLine(LPDIRECTDRAW3 This, LPDWORD pdwLine)
{
return IDirectDraw7_GetScanLine(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This), pdwLine);
return IDirectDraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw3(This), pdwLine);
}
static HRESULT WINAPI
IDirectDraw4Impl_GetScanLine(LPDIRECTDRAW4 This, LPDWORD pdwLine)
{
return IDirectDraw7_GetScanLine(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This), pdwLine);
return IDirectDraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw4(This), pdwLine);
}
static HRESULT WINAPI
IDirectDrawImpl_GetVerticalBlankStatus(LPDIRECTDRAW This, LPBOOL lpbIsInVB)
{
return IDirectDraw7_GetVerticalBlankStatus(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This),
lpbIsInVB);
return IDirectDraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw1(This), lpbIsInVB);
}
static HRESULT WINAPI
IDirectDraw2Impl_GetVerticalBlankStatus(LPDIRECTDRAW2 This, LPBOOL lpbIsInVB)
{
return IDirectDraw7_GetVerticalBlankStatus(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This),
lpbIsInVB);
return IDirectDraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw2(This), lpbIsInVB);
}
static HRESULT WINAPI
IDirectDraw3Impl_GetVerticalBlankStatus(LPDIRECTDRAW3 This, LPBOOL lpbIsInVB)
{
return IDirectDraw7_GetVerticalBlankStatus(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This),
lpbIsInVB);
return IDirectDraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw3(This), lpbIsInVB);
}
static HRESULT WINAPI
IDirectDraw4Impl_GetVerticalBlankStatus(LPDIRECTDRAW4 This, LPBOOL lpbIsInVB)
{
return IDirectDraw7_GetVerticalBlankStatus(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
lpbIsInVB);
return IDirectDraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw4(This), lpbIsInVB);
}
static HRESULT WINAPI
......@@ -1168,168 +912,108 @@ IDirectDraw4Impl_Initialize(LPDIRECTDRAW4 iface, LPGUID pGUID)
static HRESULT WINAPI
IDirectDrawImpl_RestoreDisplayMode(LPDIRECTDRAW This)
{
return IDirectDraw7_RestoreDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This));
return IDirectDraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw1(This));
}
static HRESULT WINAPI
IDirectDraw2Impl_RestoreDisplayMode(LPDIRECTDRAW2 This)
{
return IDirectDraw7_RestoreDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This));
return IDirectDraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw2(This));
}
static HRESULT WINAPI
IDirectDraw3Impl_RestoreDisplayMode(LPDIRECTDRAW3 This)
{
return IDirectDraw7_RestoreDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This));
return IDirectDraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw3(This));
}
static HRESULT WINAPI
IDirectDraw4Impl_RestoreDisplayMode(LPDIRECTDRAW4 This)
{
return IDirectDraw7_RestoreDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This));
return IDirectDraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw4(This));
}
static HRESULT WINAPI
IDirectDrawImpl_SetCooperativeLevel(LPDIRECTDRAW This, HWND hWnd,
DWORD dwFlags)
{
return IDirectDraw7_SetCooperativeLevel(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This),
hWnd, dwFlags);
return IDirectDraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw1(This), hWnd, dwFlags);
}
static HRESULT WINAPI
IDirectDraw2Impl_SetCooperativeLevel(LPDIRECTDRAW2 This, HWND hWnd,
DWORD dwFlags)
{
return IDirectDraw7_SetCooperativeLevel(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This),
hWnd, dwFlags);
return IDirectDraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw2(This), hWnd, dwFlags);
}
static HRESULT WINAPI
IDirectDraw3Impl_SetCooperativeLevel(LPDIRECTDRAW3 This, HWND hWnd,
DWORD dwFlags)
{
return IDirectDraw7_SetCooperativeLevel(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This),
hWnd, dwFlags);
return IDirectDraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw3(This), hWnd, dwFlags);
}
static HRESULT WINAPI
IDirectDraw4Impl_SetCooperativeLevel(LPDIRECTDRAW4 This, HWND hWnd,
DWORD dwFlags)
{
return IDirectDraw7_SetCooperativeLevel(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
hWnd, dwFlags);
return IDirectDraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw4(This), hWnd, dwFlags);
}
static HRESULT WINAPI
IDirectDrawImpl_SetDisplayMode(LPDIRECTDRAW This, DWORD a, DWORD b, DWORD c)
{
return IDirectDraw7_SetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This),
a, b, c, 0, 0);
return IDirectDraw7_SetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw1(This), a, b, c, 0, 0);
}
static HRESULT WINAPI
IDirectDraw2Impl_SetDisplayMode(LPDIRECTDRAW2 This, DWORD a, DWORD b, DWORD c,
DWORD d, DWORD e)
{
return IDirectDraw7_SetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This),
a, b, c, d, e);
return IDirectDraw7_SetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw2(This), a, b, c, d, e);
}
static HRESULT WINAPI
IDirectDraw3Impl_SetDisplayMode(LPDIRECTDRAW3 This, DWORD a, DWORD b, DWORD c,
DWORD d, DWORD e)
{
return IDirectDraw7_SetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This),
a, b, c, d, e);
return IDirectDraw7_SetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw3(This), a, b, c, d, e);
}
static HRESULT WINAPI
IDirectDraw4Impl_SetDisplayMode(LPDIRECTDRAW4 This, DWORD a, DWORD b, DWORD c,
DWORD d, DWORD e)
{
return IDirectDraw7_SetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
a, b, c, d, e);
return IDirectDraw7_SetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw4(This), a, b, c, d, e);
}
static HRESULT WINAPI
IDirectDrawImpl_WaitForVerticalBlank(LPDIRECTDRAW This, DWORD dwFlags,
HANDLE hEvent)
{
return IDirectDraw7_WaitForVerticalBlank(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw,
IDirectDraw7,
This),
dwFlags, hEvent);
return IDirectDraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw1(This), dwFlags, hEvent);
}
static HRESULT WINAPI
IDirectDraw2Impl_WaitForVerticalBlank(LPDIRECTDRAW2 This, DWORD dwFlags,
HANDLE hEvent)
{
return IDirectDraw7_WaitForVerticalBlank(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This),
dwFlags, hEvent);
return IDirectDraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw2(This), dwFlags, hEvent);
}
static HRESULT WINAPI
IDirectDraw3Impl_WaitForVerticalBlank(LPDIRECTDRAW3 This, DWORD dwFlags,
HANDLE hEvent)
{
return IDirectDraw7_WaitForVerticalBlank(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This),
dwFlags, hEvent);
return IDirectDraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw3(This), dwFlags, hEvent);
}
static HRESULT WINAPI
IDirectDraw4Impl_WaitForVerticalBlank(LPDIRECTDRAW4 This, DWORD dwFlags,
HANDLE hEvent)
{
return IDirectDraw7_WaitForVerticalBlank(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
dwFlags, hEvent);
return IDirectDraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw4(This), dwFlags, hEvent);
}
static HRESULT WINAPI
......@@ -1339,11 +1023,7 @@ IDirectDraw2Impl_GetAvailableVidMem(LPDIRECTDRAW2 This, LPDDSCAPS pCaps,
DDSCAPS2 Caps2;
DDRAW_Convert_DDSCAPS_1_To_2(pCaps, &Caps2);
return IDirectDraw7_GetAvailableVidMem(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw2,
IDirectDraw7,
This),
&Caps2, pdwTotal, pdwFree);
return IDirectDraw7_GetAvailableVidMem((IDirectDraw7 *)ddraw_from_ddraw2(This), &Caps2, pdwTotal, pdwFree);
}
static HRESULT WINAPI
......@@ -1353,62 +1033,40 @@ IDirectDraw3Impl_GetAvailableVidMem(LPDIRECTDRAW3 This, LPDDSCAPS pCaps,
DDSCAPS2 Caps2;
DDRAW_Convert_DDSCAPS_1_To_2(pCaps, &Caps2);
return IDirectDraw7_GetAvailableVidMem(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This),
&Caps2, pdwTotal, pdwFree);
return IDirectDraw7_GetAvailableVidMem((IDirectDraw7 *)ddraw_from_ddraw3(This), &Caps2, pdwTotal, pdwFree);
}
static HRESULT WINAPI
IDirectDraw4Impl_GetAvailableVidMem(LPDIRECTDRAW4 This, LPDDSCAPS2 pCaps,
LPDWORD pdwTotal, LPDWORD pdwFree)
{
return IDirectDraw7_GetAvailableVidMem(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
pCaps, pdwTotal, pdwFree);
return IDirectDraw7_GetAvailableVidMem((IDirectDraw7 *)ddraw_from_ddraw4(This), pCaps, pdwTotal, pdwFree);
}
static HRESULT WINAPI
IDirectDraw3Impl_GetSurfaceFromDC(LPDIRECTDRAW3 This, HDC hDC,
LPDIRECTDRAWSURFACE *pSurf)
{
return IDirectDraw7_GetSurfaceFromDC(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw3,
IDirectDraw7,
This),
hDC, (LPDIRECTDRAWSURFACE7 *)pSurf);
return IDirectDraw7_GetSurfaceFromDC((IDirectDraw7 *)ddraw_from_ddraw3(This), hDC, (LPDIRECTDRAWSURFACE7 *)pSurf);
}
static HRESULT WINAPI
IDirectDraw4Impl_GetSurfaceFromDC(LPDIRECTDRAW4 This, HDC hDC,
LPDIRECTDRAWSURFACE4 *pSurf)
{
return IDirectDraw7_GetSurfaceFromDC(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
hDC, (LPDIRECTDRAWSURFACE7 *)pSurf);
return IDirectDraw7_GetSurfaceFromDC((IDirectDraw7 *)ddraw_from_ddraw4(This), hDC, (LPDIRECTDRAWSURFACE7 *)pSurf);
}
static HRESULT WINAPI
IDirectDraw4Impl_RestoreAllSurfaces(LPDIRECTDRAW4 This)
{
return IDirectDraw7_RestoreAllSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This));
return IDirectDraw7_RestoreAllSurfaces((IDirectDraw7 *)ddraw_from_ddraw4(This));
}
static HRESULT WINAPI
IDirectDraw4Impl_TestCooperativeLevel(LPDIRECTDRAW4 This)
{
return IDirectDraw7_TestCooperativeLevel(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This));
return IDirectDraw7_TestCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw4(This));
}
static HRESULT WINAPI
......@@ -1418,11 +1076,7 @@ IDirectDraw4Impl_GetDeviceIdentifier(LPDIRECTDRAW4 This,
DDDEVICEIDENTIFIER2 DDDI2;
HRESULT hr;
hr = IDirectDraw7_GetDeviceIdentifier(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
&DDDI2, dwFlags);
hr = IDirectDraw7_GetDeviceIdentifier((IDirectDraw7 *)ddraw_from_ddraw4(This), &DDDI2, dwFlags);
DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(&DDDI2, pDDDI);
......
......@@ -282,7 +282,7 @@ static ULONG WINAPI
Thunk_IDirect3DDeviceImpl_1_AddRef(IDirect3DDevice *iface)
{
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface);
return IDirect3DDevice7_AddRef(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice7, iface));
return IDirect3DDevice7_AddRef((IDirect3DDevice7 *)device_from_device1(iface));
}
/*****************************************************************************
......@@ -1032,7 +1032,7 @@ Thunk_IDirect3DDeviceImpl_2_NextViewport(IDirect3DDevice2 *iface,
TRACE_(ddraw_thunk)("(%p)->(%p,%p,%08x) thunking to IDirect3DDevice3 interface.\n", This, vp, lplpDirect3DViewport2, Flags);
hr = IDirect3DDevice3_NextViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl,
(IDirect3DViewport3 *)vp, &res, Flags);
*lplpDirect3DViewport2 = (IDirect3DViewport2 *) COM_INTERFACE_CAST(IDirect3DViewportImpl, IDirect3DViewport3, IDirect3DViewport3, res);
*lplpDirect3DViewport2 = (IDirect3DViewport2 *)res;
return hr;
}
......@@ -1049,7 +1049,7 @@ Thunk_IDirect3DDeviceImpl_1_NextViewport(IDirect3DDevice *iface,
TRACE_(ddraw_thunk)("(%p)->(%p,%p,%08x) thunking to IDirect3DDevice3 interface.\n", This, vp, lplpDirect3DViewport, Flags);
hr = IDirect3DDevice3_NextViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl,
(IDirect3DViewport3 *)vp, &res, Flags);
*lplpDirect3DViewport = (IDirect3DViewport *) COM_INTERFACE_CAST(IDirect3DViewportImpl, IDirect3DViewport3, IDirect3DViewport3, res);
*lplpDirect3DViewport = (IDirect3DViewport *)res;
return hr;
}
......@@ -1790,7 +1790,7 @@ Thunk_IDirect3DDeviceImpl_3_GetDirect3D(IDirect3DDevice3 *iface,
ret = IDirect3DDevice7_GetDirect3D((IDirect3DDevice7 *)This, &ret_ptr);
if(ret != D3D_OK)
return ret;
*Direct3D3 = COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirect3D3, ret_ptr);
*Direct3D3 = ret_ptr ? (IDirect3D3 *)&((IDirectDrawImpl *)ret_ptr)->IDirect3D3_vtbl : NULL;
TRACE(" returning interface %p\n", *Direct3D3);
return D3D_OK;
}
......@@ -1807,7 +1807,7 @@ Thunk_IDirect3DDeviceImpl_2_GetDirect3D(IDirect3DDevice2 *iface,
ret = IDirect3DDevice7_GetDirect3D((IDirect3DDevice7 *)This, &ret_ptr);
if(ret != D3D_OK)
return ret;
*Direct3D2 = COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirect3D2, ret_ptr);
*Direct3D2 = ret_ptr ? (IDirect3D2 *)&((IDirectDrawImpl *)ret_ptr)->IDirect3D2_vtbl : NULL;
TRACE(" returning interface %p\n", *Direct3D2);
return D3D_OK;
}
......@@ -1824,7 +1824,7 @@ Thunk_IDirect3DDeviceImpl_1_GetDirect3D(IDirect3DDevice *iface,
ret = IDirect3DDevice7_GetDirect3D((IDirect3DDevice7 *)This, &ret_ptr);
if(ret != D3D_OK)
return ret;
*Direct3D = COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirect3D, ret_ptr);
*Direct3D = ret_ptr ? (IDirect3D *)&((IDirectDrawImpl *)ret_ptr)->IDirect3D_vtbl : NULL;
TRACE(" returning interface %p\n", *Direct3D);
return D3D_OK;
}
......@@ -1941,7 +1941,6 @@ Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport(IDirect3DDevice2 *iface,
hr = IDirect3DDevice3_GetCurrentViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl,
(IDirect3DViewport3 **)Direct3DViewport2);
if(hr != D3D_OK) return hr;
*Direct3DViewport2 = (IDirect3DViewport2 *) COM_INTERFACE_CAST(IDirect3DViewportImpl, IDirect3DViewport3, IDirect3DViewport3, *Direct3DViewport2);
return D3D_OK;
}
......@@ -2088,7 +2087,6 @@ Thunk_IDirect3DDeviceImpl_3_GetRenderTarget(IDirect3DDevice3 *iface,
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This, RenderTarget);
hr = IDirect3DDevice7_GetRenderTarget((IDirect3DDevice7 *)This, (IDirectDrawSurface7 **)RenderTarget);
if(hr != D3D_OK) return hr;
*RenderTarget = (IDirectDrawSurface4 *) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7, IDirectDrawSurface7, *RenderTarget);
return D3D_OK;
}
......@@ -2101,7 +2099,8 @@ Thunk_IDirect3DDeviceImpl_2_GetRenderTarget(IDirect3DDevice2 *iface,
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This, RenderTarget);
hr = IDirect3DDevice7_GetRenderTarget((IDirect3DDevice7 *)This, (IDirectDrawSurface7 **)RenderTarget);
if(hr != D3D_OK) return hr;
*RenderTarget = (IDirectDrawSurface *) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7, IDirectDrawSurface3, *RenderTarget);
*RenderTarget = *RenderTarget ?
(IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)*RenderTarget)->IDirectDrawSurface3_vtbl : NULL;
return D3D_OK;
}
......@@ -4743,7 +4742,7 @@ Thunk_IDirect3DDeviceImpl_3_GetTexture(IDirect3DDevice3 *iface,
TRACE_(ddraw_thunk)("(%p)->(%d,%p) thunking to IDirect3DDevice7 interface.\n", This, Stage, Texture2);
ret = IDirect3DDevice7_GetTexture((IDirect3DDevice7 *)This, Stage, &ret_val);
*Texture2 = COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7, IDirect3DTexture2, ret_val);
*Texture2 = ret_val ? (IDirect3DTexture2 *)&((IDirectDrawSurfaceImpl *)ret_val)->IDirect3DTexture2_vtbl : NULL;
TRACE_(ddraw_thunk)(" returning interface %p.\n", *Texture2);
......
......@@ -532,7 +532,8 @@ Thunk_IDirect3DImpl_2_CreateMaterial(IDirect3D2 *iface,
TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", This, Direct3DMaterial, UnkOuter);
ret = IDirect3D3_CreateMaterial((IDirect3D3 *)&This->IDirect3D3_vtbl, &ret_val, UnkOuter);
*Direct3DMaterial = COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial3, IDirect3DMaterial2, ret_val);
*Direct3DMaterial = ret_val ?
(IDirect3DMaterial2 *)&((IDirect3DMaterialImpl *)ret_val)->IDirect3DMaterial2_vtbl : NULL;
TRACE(" returning interface %p.\n", *Direct3DMaterial);
......@@ -551,7 +552,8 @@ Thunk_IDirect3DImpl_1_CreateMaterial(IDirect3D *iface,
TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", This, Direct3DMaterial, UnkOuter);
ret = IDirect3D3_CreateMaterial((IDirect3D3 *)&This->IDirect3D3_vtbl, &ret_val, UnkOuter);
*Direct3DMaterial = COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial3, IDirect3DMaterial, ret_val);
*Direct3DMaterial = ret_val ?
(IDirect3DMaterial *)&((IDirect3DMaterialImpl *)ret_val)->IDirect3DMaterial_vtbl : NULL;
TRACE(" returning interface %p.\n", *Direct3DMaterial);
......@@ -932,7 +934,7 @@ Thunk_IDirect3DImpl_3_CreateDevice(IDirect3D3 *iface,
hr = IDirect3D7_CreateDevice((IDirect3D7 *)&This->IDirect3D7_vtbl, refiid,
(IDirectDrawSurface7 *)Surface /* Same VTables */, (IDirect3DDevice7 **)Device);
*Device = COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice7, IDirect3DDevice3, *Device);
*Device = *Device ? (IDirect3DDevice3 *)&((IDirect3DDeviceImpl *)*Device)->IDirect3DDevice3_vtbl : NULL;
return hr;
}
......@@ -947,10 +949,10 @@ Thunk_IDirect3DImpl_2_CreateDevice(IDirect3D2 *iface,
TRACE("(%p)->(%s,%p,%p): Thunking to IDirect3D7\n", This, debugstr_guid(refiid), Surface, Device);
hr = IDirect3D7_CreateDevice((IDirect3D7 *)&This->IDirect3D7_vtbl, refiid,
COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface3, IDirectDrawSurface7, Surface),
Surface ? (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)Surface) : NULL,
(IDirect3DDevice7 **)Device);
*Device = COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice7, IDirect3DDevice2, *Device);
*Device = *Device ? (IDirect3DDevice2 *)&((IDirect3DDeviceImpl *)*Device)->IDirect3DDevice2_vtbl : NULL;
return hr;
}
......@@ -1077,7 +1079,9 @@ Thunk_IDirect3DImpl_3_CreateVertexBuffer(IDirect3D3 *iface,
hr = IDirect3D7_CreateVertexBuffer((IDirect3D7 *)&This->IDirect3D7_vtbl,
Desc, (IDirect3DVertexBuffer7 **)VertexBuffer, Flags);
*VertexBuffer = COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, IDirect3DVertexBuffer, *VertexBuffer);
*VertexBuffer = *VertexBuffer ?
(IDirect3DVertexBuffer *)&((IDirect3DVertexBufferImpl *)*VertexBuffer)->IDirect3DVertexBuffer_vtbl : NULL;
return hr;
}
......
......@@ -55,6 +55,11 @@ static inline IDirect3DMaterialImpl *material_from_material1(IDirect3DMaterial *
return (IDirect3DMaterialImpl *)((char*)iface - FIELD_OFFSET(IDirect3DMaterialImpl, IDirect3DMaterial_vtbl));
}
static inline IDirect3DMaterialImpl *material_from_material2(IDirect3DMaterial2 *iface)
{
return (IDirect3DMaterialImpl *)((char*)iface - FIELD_OFFSET(IDirect3DMaterialImpl, IDirect3DMaterial2_vtbl));
}
/*****************************************************************************
* IUnknown Methods.
*****************************************************************************/
......@@ -347,9 +352,8 @@ Thunk_IDirect3DMaterialImpl_2_GetHandle(LPDIRECT3DMATERIAL2 iface,
LPD3DMATERIALHANDLE lpHandle)
{
TRACE_(ddraw_thunk)("(%p)->(%p,%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpDirect3DDevice2, lpHandle);
return IDirect3DMaterial3_GetHandle(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface),
COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, lpDirect3DDevice2),
lpHandle);
return IDirect3DMaterial3_GetHandle((IDirect3DMaterial3 *)material_from_material2(iface), lpDirect3DDevice2 ?
(IDirect3DDevice3 *)&device_from_device2(lpDirect3DDevice2)->IDirect3DDevice3_vtbl : NULL, lpHandle);
}
static HRESULT WINAPI
......@@ -358,9 +362,8 @@ Thunk_IDirect3DMaterialImpl_1_GetHandle(LPDIRECT3DMATERIAL iface,
LPD3DMATERIALHANDLE lpHandle)
{
TRACE_(ddraw_thunk)("(%p)->(%p,%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpDirect3DDevice, lpHandle);
return IDirect3DMaterial3_GetHandle(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface),
COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice3, lpDirect3DDevice),
lpHandle);
return IDirect3DMaterial3_GetHandle((IDirect3DMaterial3 *)material_from_material1(iface), lpDirect3DDevice ?
(IDirect3DDevice3 *)&device_from_device1(lpDirect3DDevice)->IDirect3DDevice3_vtbl : NULL, lpHandle);
}
static HRESULT WINAPI
......@@ -369,9 +372,7 @@ Thunk_IDirect3DMaterialImpl_2_QueryInterface(LPDIRECT3DMATERIAL2 iface,
LPVOID* obp)
{
TRACE_(ddraw_thunk)("(%p)->(%s,%p) thunking to IDirect3DMaterial3 interface.\n", iface, debugstr_guid(riid), obp);
return IDirect3DMaterial3_QueryInterface(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface),
riid,
obp);
return IDirect3DMaterial3_QueryInterface((IDirect3DMaterial3 *)material_from_material2(iface), riid, obp);
}
static HRESULT WINAPI
......@@ -380,37 +381,35 @@ Thunk_IDirect3DMaterialImpl_1_QueryInterface(LPDIRECT3DMATERIAL iface,
LPVOID* obp)
{
TRACE_(ddraw_thunk)("(%p)->(%s,%p) thunking to IDirect3DMaterial3 interface.\n", iface, debugstr_guid(riid), obp);
return IDirect3DMaterial3_QueryInterface(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface),
riid,
obp);
return IDirect3DMaterial3_QueryInterface((IDirect3DMaterial3 *)material_from_material1(iface), riid, obp);
}
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_2_AddRef(LPDIRECT3DMATERIAL2 iface)
{
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
return IDirect3DMaterial3_AddRef(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface));
return IDirect3DMaterial3_AddRef((IDirect3DMaterial3 *)material_from_material2(iface));
}
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_1_AddRef(LPDIRECT3DMATERIAL iface)
{
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
return IDirect3DMaterial3_AddRef(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface));
return IDirect3DMaterial3_AddRef((IDirect3DMaterial3 *)material_from_material1(iface));
}
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_2_Release(LPDIRECT3DMATERIAL2 iface)
{
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
return IDirect3DMaterial3_Release(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface));
return IDirect3DMaterial3_Release((IDirect3DMaterial3 *)material_from_material2(iface));
}
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_1_Release(LPDIRECT3DMATERIAL iface)
{
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
return IDirect3DMaterial3_Release(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface));
return IDirect3DMaterial3_Release((IDirect3DMaterial3 *)material_from_material1(iface));
}
static HRESULT WINAPI
......@@ -418,8 +417,7 @@ Thunk_IDirect3DMaterialImpl_2_SetMaterial(LPDIRECT3DMATERIAL2 iface,
LPD3DMATERIAL lpMat)
{
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
return IDirect3DMaterial3_SetMaterial(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface),
lpMat);
return IDirect3DMaterial3_SetMaterial((IDirect3DMaterial3 *)material_from_material2(iface), lpMat);
}
static HRESULT WINAPI
......@@ -427,8 +425,7 @@ Thunk_IDirect3DMaterialImpl_1_SetMaterial(LPDIRECT3DMATERIAL iface,
LPD3DMATERIAL lpMat)
{
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
return IDirect3DMaterial3_SetMaterial(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface),
lpMat);
return IDirect3DMaterial3_SetMaterial((IDirect3DMaterial3 *)material_from_material1(iface), lpMat);
}
static HRESULT WINAPI
......@@ -436,8 +433,7 @@ Thunk_IDirect3DMaterialImpl_2_GetMaterial(LPDIRECT3DMATERIAL2 iface,
LPD3DMATERIAL lpMat)
{
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
return IDirect3DMaterial3_GetMaterial(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface),
lpMat);
return IDirect3DMaterial3_GetMaterial((IDirect3DMaterial3 *)material_from_material2(iface), lpMat);
}
static HRESULT WINAPI
......@@ -445,8 +441,7 @@ Thunk_IDirect3DMaterialImpl_1_GetMaterial(LPDIRECT3DMATERIAL iface,
LPD3DMATERIAL lpMat)
{
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
return IDirect3DMaterial3_GetMaterial(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface),
lpMat);
return IDirect3DMaterial3_GetMaterial((IDirect3DMaterial3 *)material_from_material1(iface), lpMat);
}
......
......@@ -118,7 +118,7 @@ IDirectDrawSurfaceImpl_QueryInterface(IDirectDrawSurface7 *iface,
/* Call into IDirect3D7 for creation */
IDirect3D7_CreateDevice((IDirect3D7 *)&This->ddraw->IDirect3D7_vtbl, riid, (IDirectDrawSurface7 *)This, &d3d);
*obj = COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice7, IDirect3DDevice, d3d);
*obj = d3d ? (IDirect3DDevice *)&((IDirect3DDeviceImpl *)d3d)->IDirect3DDevice_vtbl : NULL;
TRACE("(%p) Returning IDirect3DDevice interface at %p\n", This, *obj);
return S_OK;
......
......@@ -29,26 +29,14 @@
#include "winerror.h"
#include "ddraw_private.h"
#include "ddcomimpl.h"
#define CONVERT(pdds) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, \
IDirectDrawSurface3, \
IDirectDrawSurface7, \
(pdds))
#define CONVERT_REV(pdds) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, \
IDirectDrawSurface7, \
IDirectDrawSurface3, \
(pdds))
#define CONVERT(pdds) ((pdds) ? (IDirectDrawSurface7 *)surface_from_surface3(pdds) : NULL)
#define CONVERT_REV(pdds) \
((pdds) ? (IDirectDrawSurface3 *)&((IDirectDrawSurfaceImpl *)(pdds))->IDirectDrawSurface3_vtbl : NULL)
WINE_DEFAULT_DEBUG_CHANNEL(ddraw_thunk);
WINE_DECLARE_DEBUG_CHANNEL(ddraw);
static inline IDirectDrawSurfaceImpl *surface_from_surface3(IDirectDrawSurface3 *iface)
{
return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirectDrawSurface3_vtbl));
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_QueryInterface(LPDIRECTDRAWSURFACE3 This, REFIID iid,
LPVOID *ppObj)
......
......@@ -84,7 +84,7 @@ Thunk_IDirect3DTextureImpl_1_AddRef(IDirect3DTexture *iface)
IDirectDrawSurfaceImpl *This = surface_from_texture1(iface);
TRACE("(%p)->() thunking to IDirectDrawSurface7 interface.\n", This);
return IDirectDrawSurface7_AddRef(COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirect3DTexture, IDirectDrawSurface7, iface));
return IDirectDrawSurface7_AddRef((IDirectDrawSurface7 *)This);
}
static ULONG WINAPI
......@@ -103,7 +103,7 @@ Thunk_IDirect3DTextureImpl_1_Release(IDirect3DTexture *iface)
IDirectDrawSurfaceImpl *This = surface_from_texture1(iface);
TRACE("(%p)->() thunking to IDirectDrawSurface7 interface.\n", This);
return IDirectDrawSurface7_Release(COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirect3DTexture, IDirectDrawSurface7, iface));
return IDirectDrawSurface7_Release((IDirectDrawSurface7 *)This);
}
/*****************************************************************************
......@@ -162,9 +162,7 @@ Thunk_IDirect3DTextureImpl_1_PaletteChanged(IDirect3DTexture *iface,
IDirectDrawSurfaceImpl *This = surface_from_texture1(iface);
TRACE("(%p)->(%08x,%08x) thunking to IDirect3DTexture2 interface.\n", This, Start, Count);
return IDirect3DTexture2_PaletteChanged(COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirect3DTexture, IDirect3DTexture2, iface),
Start,
Count);
return IDirect3DTexture2_PaletteChanged((IDirect3DTexture2 *)&This->IDirect3DTexture2_vtbl, Start, Count);
}
......@@ -469,8 +467,8 @@ Thunk_IDirect3DTextureImpl_1_Load(IDirect3DTexture *iface,
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),
COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirect3DTexture, IDirect3DTexture2, D3DTexture));
return IDirect3DTexture2_Load((IDirect3DTexture2 *)&This->IDirect3DTexture2_vtbl,
D3DTexture ? (IDirect3DTexture2 *)&surface_from_texture1(D3DTexture)->IDirect3DTexture2_vtbl : NULL);
}
/*****************************************************************************
......
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