diff --git a/reactos/lib/ddraw/ddraw.xml b/reactos/lib/ddraw/ddraw.xml index cf2277e6173..181a47984ea 100644 --- a/reactos/lib/ddraw/ddraw.xml +++ b/reactos/lib/ddraw/ddraw.xml @@ -1,4 +1,4 @@ - + . @@ -35,4 +35,9 @@ ddraw.c surface.c + + + ddraw.c + surface.c + diff --git a/reactos/lib/ddraw/main.c b/reactos/lib/ddraw/main.c index 323877c3c70..c4b236f62a1 100644 --- a/reactos/lib/ddraw/main.c +++ b/reactos/lib/ddraw/main.c @@ -13,8 +13,7 @@ #include "rosdraw.h" -HRESULT WINAPI Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface, - IUnknown* pUnkOuter, BOOL ex) +HRESULT WINAPI Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface, REFIID id, BOOL ex) { IDirectDrawImpl* This = (IDirectDrawImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawImpl)); @@ -23,10 +22,17 @@ HRESULT WINAPI Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface, ZeroMemory(This,sizeof(IDirectDrawImpl)); - This->lpVtbl = &DirectDraw_Vtable; + This->lpVtbl = &DirectDraw7_Vtable; + This->lpVtbl_v1 = &DDRAW_IDirectDraw_VTable; + This->lpVtbl_v2 = &DDRAW_IDirectDraw2_VTable; + This->lpVtbl_v4 = &DDRAW_IDirectDraw4_VTable; + This->DirectDrawGlobal.dwRefCnt = 1; *pIface = (LPDIRECTDRAW)This; + if(This->lpVtbl->QueryInterface ((LPDIRECTDRAW7)This, id, (void**)&pIface) != S_OK) + return DDERR_INVALIDPARAMS; + return This->lpVtbl->Initialize ((LPDIRECTDRAW7)This, pGUID); } @@ -39,10 +45,10 @@ HRESULT WINAPI DirectDrawCreate (LPGUID lpGUID, LPDIRECTDRAW* lplpDD, LPUNKNOWN return DDERR_INVALIDPARAMS; } - return Create_DirectDraw (lpGUID, lplpDD, pUnkOuter, FALSE); + return Create_DirectDraw (lpGUID, lplpDD, &IID_IDirectDraw, FALSE); } -HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID* lplpDD, REFIID iid, LPUNKNOWN pUnkOuter) +HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID* lplpDD, REFIID id, LPUNKNOWN pUnkOuter) { /* check see if pUnkOuter is null or not */ if (pUnkOuter) @@ -52,12 +58,12 @@ HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID* lplpDD, REFIID iid, LPU } /* Is it a DirectDraw 7 Request or not */ - if (!IsEqualGUID(iid, &IID_IDirectDraw7)) + if (!IsEqualGUID(id, &IID_IDirectDraw7)) { return DDERR_INVALIDPARAMS; } - return Create_DirectDraw (lpGUID, (LPDIRECTDRAW*)lplpDD, pUnkOuter, TRUE); + return Create_DirectDraw (lpGUID, (LPDIRECTDRAW*)lplpDD, id, TRUE); } HRESULT WINAPI DirectDrawEnumerateA( @@ -65,7 +71,7 @@ HRESULT WINAPI DirectDrawEnumerateA( LPVOID lpContext ) { - return DD_OK; + DX_STUB; } @@ -74,7 +80,7 @@ HRESULT WINAPI DirectDrawEnumerateW( LPVOID lpContext ) { - return DD_OK; + DX_STUB; } HRESULT WINAPI DirectDrawEnumerateExA( @@ -83,7 +89,7 @@ HRESULT WINAPI DirectDrawEnumerateExA( DWORD dwFlags ) { - return DD_OK; + DX_STUB; } HRESULT WINAPI DirectDrawEnumerateExW( @@ -92,7 +98,7 @@ HRESULT WINAPI DirectDrawEnumerateExW( DWORD dwFlags ) { - return DD_OK; + DX_STUB; } HRESULT WINAPI DirectDrawCreateClipper( @@ -101,6 +107,5 @@ HRESULT WINAPI DirectDrawCreateClipper( LPUNKNOWN pUnkOuter ) { - return DD_OK; + DX_STUB; } - diff --git a/reactos/lib/ddraw/main/clipper.c b/reactos/lib/ddraw/main/clipper.c index f6a00116982..1a278d40355 100644 --- a/reactos/lib/ddraw/main/clipper.c +++ b/reactos/lib/ddraw/main/clipper.c @@ -3,7 +3,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS * FILE: lib/ddraw/main/clipper.c - * PURPOSE: DirectDraw Implementation + * PURPOSE: IDirectDrawClipper Implementation * PROGRAMMER: Maarten Bosma * */ diff --git a/reactos/lib/ddraw/main/color.c b/reactos/lib/ddraw/main/color.c index 5e2dc140689..9e362478db6 100644 --- a/reactos/lib/ddraw/main/color.c +++ b/reactos/lib/ddraw/main/color.c @@ -3,7 +3,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS * FILE: lib/ddraw/main/color.c - * PURPOSE: DirectDraw Implementation + * PURPOSE: IDirectDrawColorControl Implementation * PROGRAMMER: Maarten Bosma * */ diff --git a/reactos/lib/ddraw/main/ddraw.c b/reactos/lib/ddraw/main/ddraw.c index 6bd83c6e05b..d3dc8492a10 100644 --- a/reactos/lib/ddraw/main/ddraw.c +++ b/reactos/lib/ddraw/main/ddraw.c @@ -3,7 +3,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS * FILE: lib/ddraw/main/ddraw.c - * PURPOSE: DirectDraw Implementation + * PURPOSE: IDirectDraw7 Implementation * PROGRAMMER: Magnus Olsen, Maarten Bosma * */ @@ -140,7 +140,9 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE if (That == NULL) return E_OUTOFMEMORY; - That->lpVtbl = &DirectDrawSurface_Vtable; + That->lpVtbl = &DirectDrawSurface7_Vtable; + That->lpVtbl_v3 = &DDRAW_IDDS3_Thunk_VTable; + That->ref = 1; *ppSurf = (LPDIRECTDRAWSURFACE7)That; @@ -173,13 +175,39 @@ ULONG WINAPI Main_DirectDraw_Release (LPDIRECTDRAW7 iface) return ref; } -/**** Stubs ****/ - -HRESULT WINAPI Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface,REFIID refiid,LPVOID *obj) +HRESULT WINAPI Main_DirectDraw_QueryInterface ( + LPDIRECTDRAW7 iface, REFIID id, LPVOID *obj ) { - DX_STUB; + IDirectDrawImpl* This = (IDirectDrawImpl*)iface; + + if (IsEqualGUID(&IID_IDirectDraw7, id)) + { + *obj = &This->lpVtbl; + } + else if (IsEqualGUID(&IID_IDirectDraw, id)) + { + *obj = &This->lpVtbl_v1; + } + else if (IsEqualGUID(&IID_IDirectDraw2, id)) + { + *obj = &This->lpVtbl_v2; + } + else if (IsEqualGUID(&IID_IDirectDraw4, id)) + { + *obj = &This->lpVtbl_v4; + } + else + { + *obj = NULL; + return E_NOINTERFACE; + } + + Main_DirectDraw_AddRef(iface); + return S_OK; } +/**** Stubs ****/ + HRESULT WINAPI Main_DirectDraw_Compact(LPDIRECTDRAW7 iface) { DX_STUB; @@ -380,7 +408,7 @@ HRESULT WINAPI Main_DirectDraw_EvaluateMode(LPDIRECTDRAW7 iface,DWORD a,DWORD* b DX_STUB; } -IDirectDraw7Vtbl DirectDraw_Vtable = +IDirectDraw7Vtbl DirectDraw7_Vtable = { Main_DirectDraw_QueryInterface, Main_DirectDraw_AddRef, diff --git a/reactos/lib/ddraw/main/gamma.c b/reactos/lib/ddraw/main/gamma.c index e5a5236f2a3..58dfc0dfe35 100644 --- a/reactos/lib/ddraw/main/gamma.c +++ b/reactos/lib/ddraw/main/gamma.c @@ -3,7 +3,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS * FILE: lib/ddraw/main/gamma.c - * PURPOSE: DirectDraw Implementation + * PURPOSE: IDirectDrawGamma Implementation * PROGRAMMER: Maarten Bosma * */ diff --git a/reactos/lib/ddraw/main/palette.c b/reactos/lib/ddraw/main/palette.c index 032c673c925..e3ec8e575ad 100644 --- a/reactos/lib/ddraw/main/palette.c +++ b/reactos/lib/ddraw/main/palette.c @@ -3,7 +3,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS * FILE: lib/ddraw/main/palette.c - * PURPOSE: DirectDraw Implementation + * PURPOSE: IDirectDrawPalette Implementation * PROGRAMMER: Maarten Bosma * */ diff --git a/reactos/lib/ddraw/main/surface.c b/reactos/lib/ddraw/main/surface.c index 37ef677f1c4..e026d7edb92 100644 --- a/reactos/lib/ddraw/main/surface.c +++ b/reactos/lib/ddraw/main/surface.c @@ -3,7 +3,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS * FILE: lib/ddraw/main/surface.c - * PURPOSE: DirectDraw Implementation + * PURPOSE: IDirectDrawSurface7 Implementation * PROGRAMMER: Magnus Olsen, Maarten Bosma * */ @@ -113,6 +113,13 @@ ULONG WINAPI Main_DDrawSurface_Release(LPDIRECTDRAWSURFACE7 iface) /**** Stubs ****/ +HRESULT WINAPI +Main_DDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7 iface, REFIID riid, + LPVOID* ppObj) +{ + DX_STUB; +} + HRESULT WINAPI Main_DDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rdst, LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx) { @@ -130,13 +137,6 @@ HRESULT WINAPI Main_DDrawSurface_Unlock (LPDIRECTDRAWSURFACE7 iface, LPRECT pRec DX_STUB; } -HRESULT WINAPI -Main_DDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7 iface, REFIID riid, - LPVOID* ppObj) -{ - DX_STUB; -} - HRESULT WINAPI Main_DDrawSurface_AddAttachedSurface(LPDIRECTDRAWSURFACE7 iface, LPDIRECTDRAWSURFACE7 pAttach) @@ -421,7 +421,7 @@ HRESULT WINAPI Main_DDrawSurface_UpdateOverlayZOrder (LPDIRECTDRAWSURFACE7 iface DX_STUB; } -IDirectDrawSurface7Vtbl DirectDrawSurface_Vtable = +IDirectDrawSurface7Vtbl DirectDrawSurface7_Vtable = { Main_DDrawSurface_QueryInterface, Main_DDrawSurface_AddRef, diff --git a/reactos/lib/ddraw/rosdraw.h b/reactos/lib/ddraw/rosdraw.h index 8c84881408d..b0823c69ad0 100644 --- a/reactos/lib/ddraw/rosdraw.h +++ b/reactos/lib/ddraw/rosdraw.h @@ -3,7 +3,6 @@ /********* Includes *********/ - #include #include #include @@ -16,6 +15,10 @@ typedef struct { IDirectDraw7Vtbl* lpVtbl; + IDirectDraw4Vtbl* lpVtbl_v4; + IDirectDraw2Vtbl* lpVtbl_v2; + IDirectDrawVtbl* lpVtbl_v1; + DDRAWI_DIRECTDRAW_GBL DirectDrawGlobal; DDHALINFO HalInfo; @@ -33,6 +36,8 @@ typedef struct typedef struct { IDirectDrawSurface7Vtbl* lpVtbl; + IDirectDrawSurface3Vtbl* lpVtbl_v3; + LONG ref; IDirectDrawImpl* owner; @@ -63,8 +68,14 @@ typedef struct /*********** VTables ************/ -extern IDirectDraw7Vtbl DirectDraw_Vtable; -extern IDirectDrawSurface7Vtbl DirectDrawSurface_Vtable; +extern IDirectDraw7Vtbl DirectDraw7_Vtable; +extern IDirectDrawVtbl DDRAW_IDirectDraw_VTable; +extern IDirectDraw2Vtbl DDRAW_IDirectDraw2_VTable; +extern IDirectDraw4Vtbl DDRAW_IDirectDraw4_VTable; + +extern IDirectDrawSurface7Vtbl DirectDrawSurface7_Vtable; +extern IDirectDrawSurface3Vtbl DDRAW_IDDS3_Thunk_VTable; + extern IDirectDrawPaletteVtbl DirectDrawPalette_Vtable; extern IDirectDrawClipperVtbl DirectDrawClipper_Vtable; extern IDirectDrawColorControlVtbl DirectDrawColorControl_Vtable; diff --git a/reactos/lib/ddraw/thunks/ddraw.c b/reactos/lib/ddraw/thunks/ddraw.c new file mode 100644 index 00000000000..a779f38a82a --- /dev/null +++ b/reactos/lib/ddraw/thunks/ddraw.c @@ -0,0 +1,1049 @@ +/* Direct Draw Thunks and old vtables + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Taken form wine (wine/dlls/ddraw/ddraw_thunks.c rev 1.2) + * with some little changes + * + */ + +#include "winedraw.h" + + +static HRESULT WINAPI +IDirectDrawImpl_QueryInterface(LPDIRECTDRAW This, REFIID iid, LPVOID *ppObj) +{ + return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, 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); +} + + +static HRESULT WINAPI +IDirectDraw4Impl_QueryInterface(LPDIRECTDRAW4 This, REFIID iid, LPVOID *ppObj) +{ + return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, This), + iid, ppObj); +} + +static ULONG WINAPI +IDirectDrawImpl_AddRef(LPDIRECTDRAW This) +{ + return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, IDirectDraw7, + This)); +} + +static ULONG WINAPI +IDirectDraw2Impl_AddRef(LPDIRECTDRAW2 This) +{ + return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, IDirectDraw7, + This)); +} + +static ULONG WINAPI +IDirectDraw4Impl_AddRef(LPDIRECTDRAW4 This) +{ + return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, IDirectDraw7, + This)); +} + +static ULONG WINAPI +IDirectDrawImpl_Release(LPDIRECTDRAW This) +{ + return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, IDirectDraw7, + This)); +} + +static ULONG WINAPI +IDirectDraw2Impl_Release(LPDIRECTDRAW2 This) +{ + return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, IDirectDraw7, + This)); +} + +static ULONG WINAPI +IDirectDraw4Impl_Release(LPDIRECTDRAW4 This) +{ + return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, IDirectDraw7, + This)); +} + +static HRESULT WINAPI +IDirectDrawImpl_Compact(LPDIRECTDRAW This) +{ + return IDirectDraw7_Compact(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, IDirectDraw7, + This)); +} + +static HRESULT WINAPI +IDirectDraw2Impl_Compact(LPDIRECTDRAW2 This) +{ + return IDirectDraw7_Compact(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, IDirectDraw7, + This)); +} + +static HRESULT WINAPI +IDirectDraw4Impl_Compact(LPDIRECTDRAW4 This) +{ + return IDirectDraw7_Compact(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, IDirectDraw7, + This)); +} + +static HRESULT WINAPI +IDirectDrawImpl_CreateClipper(LPDIRECTDRAW This, DWORD dwFlags, + LPDIRECTDRAWCLIPPER *ppClipper, + IUnknown *pUnkOuter) +{ + return IDirectDraw7_CreateClipper(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, + This), + dwFlags, ppClipper, pUnkOuter); +} + +static HRESULT WINAPI +IDirectDraw2Impl_CreateClipper(LPDIRECTDRAW2 This, DWORD dwFlags, + LPDIRECTDRAWCLIPPER *ppClipper, + IUnknown *pUnkOuter) +{ + return IDirectDraw7_CreateClipper(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, + IDirectDraw7, + This), + dwFlags, ppClipper, pUnkOuter); +} + +static HRESULT WINAPI +IDirectDraw4Impl_CreateClipper(LPDIRECTDRAW4 This, DWORD dwFlags, + LPDIRECTDRAWCLIPPER *ppClipper, + IUnknown *pUnkOuter) +{ + return IDirectDraw7_CreateClipper(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This), + dwFlags, ppClipper, pUnkOuter); +} + +static HRESULT WINAPI +IDirectDrawImpl_CreatePalette(LPDIRECTDRAW This, DWORD dwFlags, + LPPALETTEENTRY pEntries, + LPDIRECTDRAWPALETTE *ppPalette, + IUnknown *pUnkOuter) +{ + return IDirectDraw7_CreatePalette(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, + This), + dwFlags, pEntries, ppPalette, pUnkOuter); +} + +static HRESULT WINAPI +IDirectDraw2Impl_CreatePalette(LPDIRECTDRAW2 This, DWORD dwFlags, + LPPALETTEENTRY pEntries, + LPDIRECTDRAWPALETTE *ppPalette, + IUnknown *pUnkOuter) +{ + return IDirectDraw7_CreatePalette(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, + IDirectDraw7, + This), + dwFlags, pEntries, ppPalette, pUnkOuter); +} + +static HRESULT WINAPI +IDirectDraw4Impl_CreatePalette(LPDIRECTDRAW4 This, DWORD dwFlags, + LPPALETTEENTRY pEntries, + LPDIRECTDRAWPALETTE *ppPalette, + IUnknown *pUnkOuter) +{ + return IDirectDraw7_CreatePalette(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This), + dwFlags, pEntries, ppPalette, pUnkOuter); +} + +static HRESULT WINAPI +IDirectDrawImpl_CreateSurface(LPDIRECTDRAW This, LPDDSURFACEDESC pSDesc, + LPDIRECTDRAWSURFACE *ppSurface, + IUnknown *pUnkOuter) +{ + LPDIRECTDRAWSURFACE7 pSurface7; + HRESULT hr; + + /* 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); + + /* 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); + + return hr; +} + +static HRESULT WINAPI +IDirectDraw2Impl_CreateSurface(LPDIRECTDRAW2 This, LPDDSURFACEDESC pSDesc, + LPDIRECTDRAWSURFACE *ppSurface, + IUnknown *pUnkOuter) +{ + LPDIRECTDRAWSURFACE7 pSurface7; + HRESULT hr; + + hr = IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, + IDirectDraw7, + 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); + + return hr; +} + +static HRESULT WINAPI +IDirectDraw4Impl_CreateSurface(LPDIRECTDRAW4 This, LPDDSURFACEDESC2 pSDesc, + LPDIRECTDRAWSURFACE4 *ppSurface, + IUnknown *pUnkOuter) +{ + return IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This), + pSDesc, + (LPDIRECTDRAWSURFACE7 *)ppSurface, + pUnkOuter); +} + +static HRESULT WINAPI +IDirectDrawImpl_DuplicateSurface(LPDIRECTDRAW This, LPDIRECTDRAWSURFACE pSrc, + LPDIRECTDRAWSURFACE *ppDst) +{ + LPDIRECTDRAWSURFACE7 pDst7; + HRESULT hr; + + hr = IDirectDraw7_DuplicateSurface(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, This), + COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, + IDirectDrawSurface3, + IDirectDrawSurface7, + pSrc), + &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); + + return hr; +} + +static HRESULT WINAPI +IDirectDraw2Impl_DuplicateSurface(LPDIRECTDRAW2 This, LPDIRECTDRAWSURFACE pSrc, + LPDIRECTDRAWSURFACE *ppDst) +{ + LPDIRECTDRAWSURFACE7 pDst7; + HRESULT hr; + + hr = IDirectDraw7_DuplicateSurface(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, + IDirectDraw7, This), + COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, + IDirectDrawSurface3, + IDirectDrawSurface7, + pSrc), + &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); + + return hr; +} + +static HRESULT WINAPI +IDirectDraw4Impl_DuplicateSurface(LPDIRECTDRAW4 This, + LPDIRECTDRAWSURFACE4 pSrc, + LPDIRECTDRAWSURFACE4 *ppDst) +{ + return IDirectDraw7_DuplicateSurface(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This), + (LPDIRECTDRAWSURFACE7)pSrc, + (LPDIRECTDRAWSURFACE7 *)ppDst); +} + +struct displaymodescallback_context +{ + LPDDENUMMODESCALLBACK func; + LPVOID context; +}; + +static HRESULT CALLBACK +EnumDisplayModesCallbackThunk(LPDDSURFACEDESC2 pDDSD2, LPVOID context) +{ + DDSURFACEDESC DDSD; + struct displaymodescallback_context *cbcontext = context; + + memcpy(&DDSD,pDDSD2,sizeof(DDSD)); + DDSD.dwSize = sizeof(DDSD); + + return cbcontext->func(&DDSD, cbcontext->context); +} + +static HRESULT WINAPI +IDirectDrawImpl_EnumDisplayModes(LPDIRECTDRAW This, DWORD dwFlags, + LPDDSURFACEDESC pDDSD, LPVOID context, + LPDDENUMMODESCALLBACK cb) +{ + struct displaymodescallback_context cbcontext; + + cbcontext.func = cb; + cbcontext.context = context; + + return IDirectDraw7_EnumDisplayModes(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, + This), + dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext, + EnumDisplayModesCallbackThunk); +} + +static HRESULT WINAPI +IDirectDraw2Impl_EnumDisplayModes(LPDIRECTDRAW2 This, DWORD dwFlags, + LPDDSURFACEDESC pDDSD, LPVOID context, + LPDDENUMMODESCALLBACK cb) +{ + struct displaymodescallback_context cbcontext; + + cbcontext.func = cb; + cbcontext.context = context; + + return IDirectDraw7_EnumDisplayModes(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, + IDirectDraw7, + This), + dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext, + EnumDisplayModesCallbackThunk); +} + +static HRESULT WINAPI +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); +} + +struct surfacescallback_context +{ + LPDDENUMSURFACESCALLBACK func; + LPVOID context; +}; + +static HRESULT CALLBACK +EnumSurfacesCallbackThunk(LPDIRECTDRAWSURFACE7 pSurf, LPDDSURFACEDESC2 pDDSD, + LPVOID context) +{ + struct surfacescallback_context *cbcontext = context; + + /* 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); +} + +static HRESULT WINAPI +IDirectDrawImpl_EnumSurfaces(LPDIRECTDRAW This, DWORD dwFlags, + LPDDSURFACEDESC pDDSD, LPVOID context, + LPDDENUMSURFACESCALLBACK cb) +{ + struct surfacescallback_context cbcontext; + + cbcontext.func = cb; + cbcontext.context = context; + + return IDirectDraw7_EnumSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, This), + dwFlags, (LPDDSURFACEDESC2)pDDSD, + &cbcontext, EnumSurfacesCallbackThunk); +} + +static HRESULT WINAPI +IDirectDraw2Impl_EnumSurfaces(LPDIRECTDRAW2 This, DWORD dwFlags, + LPDDSURFACEDESC pDDSD, LPVOID context, + LPDDENUMSURFACESCALLBACK cb) +{ + struct surfacescallback_context cbcontext; + + cbcontext.func = cb; + cbcontext.context = context; + + return IDirectDraw7_EnumSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, + IDirectDraw7, This), + dwFlags, (LPDDSURFACEDESC2)pDDSD, + &cbcontext, EnumSurfacesCallbackThunk); +} + +static HRESULT WINAPI +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); +} + +static HRESULT WINAPI +IDirectDrawImpl_FlipToGDISurface(LPDIRECTDRAW This) +{ + return IDirectDraw7_FlipToGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, + This)); +} + +static HRESULT WINAPI +IDirectDraw2Impl_FlipToGDISurface(LPDIRECTDRAW2 This) +{ + return IDirectDraw7_FlipToGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, + IDirectDraw7, + This)); +} + +static HRESULT WINAPI +IDirectDraw4Impl_FlipToGDISurface(LPDIRECTDRAW4 This) +{ + return IDirectDraw7_FlipToGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This)); +} + +static HRESULT WINAPI +IDirectDrawImpl_GetCaps(LPDIRECTDRAW This, LPDDCAPS pDDC1, LPDDCAPS pDDC2) +{ + return IDirectDraw7_GetCaps(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, IDirectDraw7, + 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); +} + +static HRESULT WINAPI +IDirectDraw4Impl_GetCaps(LPDIRECTDRAW4 This, LPDDCAPS pDDC1, LPDDCAPS pDDC2) +{ + return IDirectDraw7_GetCaps(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, IDirectDraw7, + This), pDDC1, pDDC2); +} + +static HRESULT WINAPI +IDirectDrawImpl_GetDisplayMode(LPDIRECTDRAW This, LPDDSURFACEDESC pDDSD) +{ + return IDirectDraw7_GetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, This), + (LPDDSURFACEDESC2)pDDSD); +} + +static HRESULT WINAPI +IDirectDraw2Impl_GetDisplayMode(LPDIRECTDRAW2 This, LPDDSURFACEDESC pDDSD) +{ + return IDirectDraw7_GetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, + IDirectDraw7, This), + (LPDDSURFACEDESC2)pDDSD); +} + +static HRESULT WINAPI +IDirectDraw4Impl_GetDisplayMode(LPDIRECTDRAW4 This, LPDDSURFACEDESC2 pDDSD) +{ + return IDirectDraw7_GetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, This), + pDDSD); +} + +static HRESULT WINAPI +IDirectDrawImpl_GetFourCCCodes(LPDIRECTDRAW This, LPDWORD lpNumCodes, + LPDWORD lpCodes) +{ + return IDirectDraw7_GetFourCCCodes(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, + 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); +} + +static HRESULT WINAPI +IDirectDraw4Impl_GetFourCCCodes(LPDIRECTDRAW4 This, LPDWORD lpNumCodes, + LPDWORD lpCodes) +{ + return IDirectDraw7_GetFourCCCodes(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This), + lpNumCodes, lpCodes); +} + +static HRESULT WINAPI +IDirectDrawImpl_GetGDISurface(LPDIRECTDRAW This, LPDIRECTDRAWSURFACE *ppSurf) +{ + LPDIRECTDRAWSURFACE7 pSurf7; + HRESULT hr; + + hr = IDirectDraw7_GetGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, + 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); + + return hr; +} + +static HRESULT WINAPI +IDirectDraw2Impl_GetGDISurface(LPDIRECTDRAW2 This, LPDIRECTDRAWSURFACE *ppSurf) +{ + LPDIRECTDRAWSURFACE7 pSurf7; + HRESULT hr; + + hr = IDirectDraw7_GetGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, + IDirectDraw7, + 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); + + return hr; +} + +static HRESULT WINAPI +IDirectDraw4Impl_GetGDISurface(LPDIRECTDRAW4 This, + LPDIRECTDRAWSURFACE4 *ppSurf) +{ + return IDirectDraw7_GetGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This), + (LPDIRECTDRAWSURFACE7 *)ppSurf); +} + +static HRESULT WINAPI +IDirectDrawImpl_GetMonitorFrequency(LPDIRECTDRAW This, LPDWORD pdwFreq) +{ + return IDirectDraw7_GetMonitorFrequency(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, + This), + pdwFreq); +} + +static HRESULT WINAPI +IDirectDraw2Impl_GetMonitorFrequency(LPDIRECTDRAW2 This, LPDWORD pdwFreq) +{ + return IDirectDraw7_GetMonitorFrequency(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, + IDirectDraw7, + This), + pdwFreq); +} + +static HRESULT WINAPI +IDirectDraw4Impl_GetMonitorFrequency(LPDIRECTDRAW4 This, LPDWORD pdwFreq) +{ + return IDirectDraw7_GetMonitorFrequency(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This), + pdwFreq); +} + +static HRESULT WINAPI +IDirectDrawImpl_GetScanLine(LPDIRECTDRAW This, LPDWORD pdwLine) +{ + return IDirectDraw7_GetScanLine(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, + This), pdwLine); +} + +static HRESULT WINAPI +IDirectDraw2Impl_GetScanLine(LPDIRECTDRAW2 This, LPDWORD pdwLine) +{ + return IDirectDraw7_GetScanLine(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, + IDirectDraw7, + This), pdwLine); +} + +static HRESULT WINAPI +IDirectDraw4Impl_GetScanLine(LPDIRECTDRAW4 This, LPDWORD pdwLine) +{ + return IDirectDraw7_GetScanLine(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This), pdwLine); +} + +static HRESULT WINAPI +IDirectDrawImpl_GetVerticalBlankStatus(LPDIRECTDRAW This, LPBOOL lpbIsInVB) +{ + return IDirectDraw7_GetVerticalBlankStatus(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, + This), + lpbIsInVB); +} + +static HRESULT WINAPI +IDirectDraw2Impl_GetVerticalBlankStatus(LPDIRECTDRAW2 This, LPBOOL lpbIsInVB) +{ + return IDirectDraw7_GetVerticalBlankStatus(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, + IDirectDraw7, + This), + lpbIsInVB); +} + +static HRESULT WINAPI +IDirectDraw4Impl_GetVerticalBlankStatus(LPDIRECTDRAW4 This, LPBOOL lpbIsInVB) +{ + return IDirectDraw7_GetVerticalBlankStatus(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This), + lpbIsInVB); +} + +static HRESULT WINAPI +IDirectDrawImpl_Initialize(LPDIRECTDRAW iface, LPGUID pGUID) +{ + ICOM_THIS_FROM(IDirectDrawImpl, IDirectDraw, iface); + HRESULT ret_value; + + ret_value = IDirectDraw7_Initialize(ICOM_INTERFACE(This, IDirectDraw7), pGUID); + + /* Overwrite the falsely set 'DIRECTDRAW7' flag */ + //This->local.dwLocalFlags &= ~DDRAWILCL_DIRECTDRAW7; + + return ret_value; +} + +static HRESULT WINAPI +IDirectDraw2Impl_Initialize(LPDIRECTDRAW2 iface, LPGUID pGUID) +{ + ICOM_THIS_FROM(IDirectDrawImpl, IDirectDraw2, iface); + HRESULT ret_value; + + ret_value = IDirectDraw7_Initialize(ICOM_INTERFACE(This, IDirectDraw7), pGUID); + + /* Overwrite the falsely set 'DIRECTDRAW7' flag */ + //This->local.dwLocalFlags &= ~DDRAWILCL_DIRECTDRAW7; + + return ret_value; +} + +static HRESULT WINAPI +IDirectDraw4Impl_Initialize(LPDIRECTDRAW4 iface, LPGUID pGUID) +{ + ICOM_THIS_FROM(IDirectDrawImpl, IDirectDraw4, iface); + HRESULT ret_value; + + ret_value = IDirectDraw7_Initialize(ICOM_INTERFACE(This, IDirectDraw7), pGUID); + + /* Overwrite the falsely set 'DIRECTDRAW7' flag */ + //This->local.dwLocalFlags &= ~DDRAWILCL_DIRECTDRAW7; + + return ret_value; +} + + +static HRESULT WINAPI +IDirectDrawImpl_RestoreDisplayMode(LPDIRECTDRAW This) +{ + return IDirectDraw7_RestoreDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, + This)); +} + +static HRESULT WINAPI +IDirectDraw2Impl_RestoreDisplayMode(LPDIRECTDRAW2 This) +{ + return IDirectDraw7_RestoreDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, + IDirectDraw7, + This)); +} + +static HRESULT WINAPI +IDirectDraw4Impl_RestoreDisplayMode(LPDIRECTDRAW4 This) +{ + return IDirectDraw7_RestoreDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This)); +} + +static HRESULT WINAPI +IDirectDrawImpl_SetCooperativeLevel(LPDIRECTDRAW This, HWND hWnd, + DWORD dwFlags) +{ + return IDirectDraw7_SetCooperativeLevel(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, + 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); +} + +static HRESULT WINAPI +IDirectDraw4Impl_SetCooperativeLevel(LPDIRECTDRAW4 This, HWND hWnd, + DWORD dwFlags) +{ + return IDirectDraw7_SetCooperativeLevel(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + 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); +} + +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); +} + +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); +} + +static HRESULT WINAPI +IDirectDrawImpl_WaitForVerticalBlank(LPDIRECTDRAW This, DWORD dwFlags, + HANDLE hEvent) +{ + return IDirectDraw7_WaitForVerticalBlank(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw, + IDirectDraw7, + 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); +} + +static HRESULT WINAPI +IDirectDraw4Impl_WaitForVerticalBlank(LPDIRECTDRAW4 This, DWORD dwFlags, + HANDLE hEvent) +{ + return IDirectDraw7_WaitForVerticalBlank(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This), + dwFlags, hEvent); +} + +void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut) +{ + /* 2 adds three additional caps fields to the end. Both versions + * are unversioned. */ + pOut->dwCaps = pIn->dwCaps; + pOut->dwCaps2 = 0; + pOut->dwCaps3 = 0; + pOut->dwCaps4 = 0; +} + +static HRESULT WINAPI +IDirectDraw2Impl_GetAvailableVidMem(LPDIRECTDRAW2 This, LPDDSCAPS pCaps, + LPDWORD pdwTotal, LPDWORD pdwFree) +{ + DDSCAPS2 Caps2; + DDRAW_Convert_DDSCAPS_1_To_2(pCaps, &Caps2); + + return IDirectDraw7_GetAvailableVidMem(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw2, + IDirectDraw7, + 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); +} + +static HRESULT WINAPI +IDirectDraw4Impl_GetSurfaceFromDC(LPDIRECTDRAW4 This, HDC hDC, + LPDIRECTDRAWSURFACE4 *pSurf) +{ + return IDirectDraw7_GetSurfaceFromDC(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This), + hDC, (LPDIRECTDRAWSURFACE7 *)pSurf); +} + +static HRESULT WINAPI +IDirectDraw4Impl_RestoreAllSurfaces(LPDIRECTDRAW4 This) +{ + return IDirectDraw7_RestoreAllSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This)); +} + +static HRESULT WINAPI +IDirectDraw4Impl_TestCooperativeLevel(LPDIRECTDRAW4 This) +{ + return IDirectDraw7_TestCooperativeLevel(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This)); +} + +void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn, + DDDEVICEIDENTIFIER* pOut) +{ + /* 2 adds a dwWHQLLevel field to the end. Both structures are + * unversioned. */ + memcpy(pOut, pIn, sizeof(*pOut)); +} + +static HRESULT WINAPI +IDirectDraw4Impl_GetDeviceIdentifier(LPDIRECTDRAW4 This, + LPDDDEVICEIDENTIFIER pDDDI, DWORD dwFlags) +{ + DDDEVICEIDENTIFIER2 DDDI2; + HRESULT hr; + + hr = IDirectDraw7_GetDeviceIdentifier(COM_INTERFACE_CAST(IDirectDrawImpl, + IDirectDraw4, + IDirectDraw7, + This), + &DDDI2, dwFlags); + + DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(&DDDI2, pDDDI); + + return hr; +} + +IDirectDrawVtbl DDRAW_IDirectDraw_VTable = +{ + IDirectDrawImpl_QueryInterface, + IDirectDrawImpl_AddRef, + IDirectDrawImpl_Release, + IDirectDrawImpl_Compact, + IDirectDrawImpl_CreateClipper, + IDirectDrawImpl_CreatePalette, + IDirectDrawImpl_CreateSurface, + IDirectDrawImpl_DuplicateSurface, + IDirectDrawImpl_EnumDisplayModes, + IDirectDrawImpl_EnumSurfaces, + IDirectDrawImpl_FlipToGDISurface, + IDirectDrawImpl_GetCaps, + IDirectDrawImpl_GetDisplayMode, + IDirectDrawImpl_GetFourCCCodes, + IDirectDrawImpl_GetGDISurface, + IDirectDrawImpl_GetMonitorFrequency, + IDirectDrawImpl_GetScanLine, + IDirectDrawImpl_GetVerticalBlankStatus, + IDirectDrawImpl_Initialize, + IDirectDrawImpl_RestoreDisplayMode, + IDirectDrawImpl_SetCooperativeLevel, + IDirectDrawImpl_SetDisplayMode, + IDirectDrawImpl_WaitForVerticalBlank, +}; + +IDirectDraw2Vtbl DDRAW_IDirectDraw2_VTable = +{ + IDirectDraw2Impl_QueryInterface, + IDirectDraw2Impl_AddRef, + IDirectDraw2Impl_Release, + IDirectDraw2Impl_Compact, + IDirectDraw2Impl_CreateClipper, + IDirectDraw2Impl_CreatePalette, + IDirectDraw2Impl_CreateSurface, + IDirectDraw2Impl_DuplicateSurface, + IDirectDraw2Impl_EnumDisplayModes, + IDirectDraw2Impl_EnumSurfaces, + IDirectDraw2Impl_FlipToGDISurface, + IDirectDraw2Impl_GetCaps, + IDirectDraw2Impl_GetDisplayMode, + IDirectDraw2Impl_GetFourCCCodes, + IDirectDraw2Impl_GetGDISurface, + IDirectDraw2Impl_GetMonitorFrequency, + IDirectDraw2Impl_GetScanLine, + IDirectDraw2Impl_GetVerticalBlankStatus, + IDirectDraw2Impl_Initialize, + IDirectDraw2Impl_RestoreDisplayMode, + IDirectDraw2Impl_SetCooperativeLevel, + IDirectDraw2Impl_SetDisplayMode, + IDirectDraw2Impl_WaitForVerticalBlank, + IDirectDraw2Impl_GetAvailableVidMem +}; + +IDirectDraw4Vtbl DDRAW_IDirectDraw4_VTable = +{ + IDirectDraw4Impl_QueryInterface, + IDirectDraw4Impl_AddRef, + IDirectDraw4Impl_Release, + IDirectDraw4Impl_Compact, + IDirectDraw4Impl_CreateClipper, + IDirectDraw4Impl_CreatePalette, + IDirectDraw4Impl_CreateSurface, + IDirectDraw4Impl_DuplicateSurface, + IDirectDraw4Impl_EnumDisplayModes, + IDirectDraw4Impl_EnumSurfaces, + IDirectDraw4Impl_FlipToGDISurface, + IDirectDraw4Impl_GetCaps, + IDirectDraw4Impl_GetDisplayMode, + IDirectDraw4Impl_GetFourCCCodes, + IDirectDraw4Impl_GetGDISurface, + IDirectDraw4Impl_GetMonitorFrequency, + IDirectDraw4Impl_GetScanLine, + IDirectDraw4Impl_GetVerticalBlankStatus, + IDirectDraw4Impl_Initialize, + IDirectDraw4Impl_RestoreDisplayMode, + IDirectDraw4Impl_SetCooperativeLevel, + IDirectDraw4Impl_SetDisplayMode, + IDirectDraw4Impl_WaitForVerticalBlank, + IDirectDraw4Impl_GetAvailableVidMem, + IDirectDraw4Impl_GetSurfaceFromDC, + IDirectDraw4Impl_RestoreAllSurfaces, + IDirectDraw4Impl_TestCooperativeLevel, + IDirectDraw4Impl_GetDeviceIdentifier +}; diff --git a/reactos/lib/ddraw/thunks/surface.c b/reactos/lib/ddraw/thunks/surface.c new file mode 100644 index 00000000000..fb8022cde23 --- /dev/null +++ b/reactos/lib/ddraw/thunks/surface.c @@ -0,0 +1,430 @@ +/* IDirectDrawSurface3 -> IDirectDrawSurface7 thunks + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Taken form wine (wine/dlls/ddraw/surface_thunks.c rev 1.2) + * with some little changes + * + */ + +#include "winedraw.h" + +#define CONVERT(pdds) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, \ + IDirectDrawSurface3, \ + IDirectDrawSurface7, \ + (pdds)) + +#define CONVERT_REV(pdds) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, \ + IDirectDrawSurface7, \ + IDirectDrawSurface3, \ + (pdds)) + +static HRESULT WINAPI +IDirectDrawSurface3Impl_QueryInterface(LPDIRECTDRAWSURFACE3 This, REFIID iid, + LPVOID *ppObj) +{ + return IDirectDrawSurface7_QueryInterface(CONVERT(This), iid, ppObj); +} + +static ULONG WINAPI +IDirectDrawSurface3Impl_AddRef(LPDIRECTDRAWSURFACE3 This) +{ + return IDirectDrawSurface7_AddRef(CONVERT(This)); +} + +static ULONG WINAPI +IDirectDrawSurface3Impl_Release(LPDIRECTDRAWSURFACE3 This) +{ + return IDirectDrawSurface7_Release(CONVERT(This)); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_AddAttachedSurface(LPDIRECTDRAWSURFACE3 This, + LPDIRECTDRAWSURFACE3 pAttach) +{ + return IDirectDrawSurface7_AddAttachedSurface(CONVERT(This), + CONVERT(pAttach)); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_AddOverlayDirtyRect(LPDIRECTDRAWSURFACE3 This, + LPRECT pRect) +{ + return IDirectDrawSurface7_AddOverlayDirtyRect(CONVERT(This), pRect); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_Blt(LPDIRECTDRAWSURFACE3 This, LPRECT prcDst, + LPDIRECTDRAWSURFACE3 pSrcSurf, LPRECT prcSrc, + DWORD dwFlags, LPDDBLTFX pFX) +{ + return IDirectDrawSurface7_Blt(CONVERT(This), prcDst, CONVERT(pSrcSurf), + prcSrc, dwFlags, pFX); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_BltBatch(LPDIRECTDRAWSURFACE3 This, + LPDDBLTBATCH pBatch, DWORD dwCount, + DWORD dwFlags) +{ + return IDirectDrawSurface7_BltBatch(CONVERT(This), pBatch, dwCount, + dwFlags); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_BltFast(LPDIRECTDRAWSURFACE3 This, DWORD x, DWORD y, + LPDIRECTDRAWSURFACE3 pSrcSurf, LPRECT prcSrc, + DWORD dwTrans) +{ + return IDirectDrawSurface7_BltFast(CONVERT(This), x, y, CONVERT(pSrcSurf), + prcSrc, dwTrans); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_DeleteAttachedSurface(LPDIRECTDRAWSURFACE3 This, + DWORD dwFlags, + LPDIRECTDRAWSURFACE3 pAttached) +{ + return IDirectDrawSurface7_DeleteAttachedSurface(CONVERT(This), dwFlags, + CONVERT(pAttached)); +} + +struct callback_info +{ + LPDDENUMSURFACESCALLBACK callback; + LPVOID context; +}; + +static HRESULT CALLBACK +EnumCallback(LPDIRECTDRAWSURFACE7 iface, LPDDSURFACEDESC2 pDDSD, + LPVOID context) +{ + const struct callback_info* info = context; + +#if 0 + /* This is an outgoing conversion so we have to do it. */ + DDSURFACEDESC ddsd; + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + DDRAW_Convert_DDSURFACEDESC_2_To_1(pDDSD, &ddsd); +#endif + + /* the LPDDSURFACEDESC2 -> LPDDSURFACEDESC coercion is safe, since + * the data format is compatible with older enum procs */ + return info->callback((LPDIRECTDRAWSURFACE)CONVERT_REV(iface), (LPDDSURFACEDESC)pDDSD, + info->context); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_EnumAttachedSurfaces(LPDIRECTDRAWSURFACE3 This, + LPVOID context, + LPDDENUMSURFACESCALLBACK callback) +{ + struct callback_info info; + + info.callback = callback; + info.context = context; + + return IDirectDrawSurface7_EnumAttachedSurfaces(CONVERT(This), &info, + EnumCallback); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_EnumOverlayZOrders(LPDIRECTDRAWSURFACE3 This, + DWORD dwFlags, LPVOID context, + LPDDENUMSURFACESCALLBACK callback) +{ + struct callback_info info; + + info.callback = callback; + info.context = context; + + return IDirectDrawSurface7_EnumOverlayZOrders(CONVERT(This), dwFlags, + &info, EnumCallback); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_Flip(LPDIRECTDRAWSURFACE3 This, + LPDIRECTDRAWSURFACE3 pOverride, DWORD dwFlags) +{ + return IDirectDrawSurface7_Flip(CONVERT(This), CONVERT(pOverride), + dwFlags); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_GetAttachedSurface(LPDIRECTDRAWSURFACE3 This, + LPDDSCAPS pCaps, + LPDIRECTDRAWSURFACE3* ppAttached) +{ + DDSCAPS2 caps; + LPDIRECTDRAWSURFACE7 pAttached7; + HRESULT hr; + + caps.dwCaps = pCaps->dwCaps; + caps.dwCaps2 = 0; + caps.dwCaps3 = 0; + caps.dwCaps4 = 0; + + hr = IDirectDrawSurface7_GetAttachedSurface(CONVERT(This), &caps, + &pAttached7); + if (FAILED(hr)) return hr; + + *ppAttached = CONVERT_REV(pAttached7); + return hr; +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_GetBltStatus(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags) +{ + return IDirectDrawSurface7_GetBltStatus(CONVERT(This), dwFlags); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_GetCaps(LPDIRECTDRAWSURFACE3 This, LPDDSCAPS pCaps) +{ + DDSCAPS2 caps; + HRESULT hr; + + hr = IDirectDrawSurface7_GetCaps(CONVERT(This), &caps); + if (FAILED(hr)) return hr; + + pCaps->dwCaps = caps.dwCaps; + return hr; +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_GetClipper(LPDIRECTDRAWSURFACE3 This, + LPDIRECTDRAWCLIPPER* ppClipper) +{ + return IDirectDrawSurface7_GetClipper(CONVERT(This), ppClipper); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_GetColorKey(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags, + LPDDCOLORKEY pCKey) +{ + return IDirectDrawSurface7_GetColorKey(CONVERT(This), dwFlags, pCKey); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_GetDC(LPDIRECTDRAWSURFACE3 This, HDC* phDC) +{ + return IDirectDrawSurface7_GetDC(CONVERT(This), phDC); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_GetFlipStatus(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags) +{ + return IDirectDrawSurface7_GetFlipStatus(CONVERT(This), dwFlags); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_GetOverlayPosition(LPDIRECTDRAWSURFACE3 This, LPLONG pX, + LPLONG pY) +{ + return IDirectDrawSurface7_GetOverlayPosition(CONVERT(This), pX, pY); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_GetPalette(LPDIRECTDRAWSURFACE3 This, + LPDIRECTDRAWPALETTE* ppPalette) +{ + return IDirectDrawSurface7_GetPalette(CONVERT(This), ppPalette); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_GetPixelFormat(LPDIRECTDRAWSURFACE3 This, + LPDDPIXELFORMAT pPixelFormat) +{ + return IDirectDrawSurface7_GetPixelFormat(CONVERT(This), pPixelFormat); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_GetSurfaceDesc(LPDIRECTDRAWSURFACE3 This, + LPDDSURFACEDESC pDDSD) +{ + return IDirectDrawSurface7_GetSurfaceDesc(CONVERT(This), + (LPDDSURFACEDESC2)pDDSD); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_Initialize(LPDIRECTDRAWSURFACE3 This, LPDIRECTDRAW pDD, + LPDDSURFACEDESC pDDSD) +{ + return IDirectDrawSurface7_Initialize(CONVERT(This), pDD, + (LPDDSURFACEDESC2)pDDSD); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_IsLost(LPDIRECTDRAWSURFACE3 This) +{ + return IDirectDrawSurface7_IsLost(CONVERT(This)); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_Lock(LPDIRECTDRAWSURFACE3 This, LPRECT pRect, + LPDDSURFACEDESC pDDSD, DWORD dwFlags, HANDLE h) +{ + return IDirectDrawSurface7_Lock(CONVERT(This), pRect, + (LPDDSURFACEDESC2)pDDSD, dwFlags, h); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_ReleaseDC(LPDIRECTDRAWSURFACE3 This, HDC hDC) +{ + return IDirectDrawSurface7_ReleaseDC(CONVERT(This), hDC); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_Restore(LPDIRECTDRAWSURFACE3 This) +{ + return IDirectDrawSurface7_Restore(CONVERT(This)); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_SetClipper(LPDIRECTDRAWSURFACE3 This, + LPDIRECTDRAWCLIPPER pClipper) +{ + return IDirectDrawSurface7_SetClipper(CONVERT(This), pClipper); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_SetColorKey(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags, + LPDDCOLORKEY pCKey) +{ + return IDirectDrawSurface7_SetColorKey(CONVERT(This), dwFlags, pCKey); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_SetOverlayPosition(LPDIRECTDRAWSURFACE3 This, LONG x, + LONG y) +{ + return IDirectDrawSurface7_SetOverlayPosition(CONVERT(This), x, y); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_SetPalette(LPDIRECTDRAWSURFACE3 This, + LPDIRECTDRAWPALETTE pPalette) +{ + return IDirectDrawSurface7_SetPalette(CONVERT(This), pPalette); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_Unlock(LPDIRECTDRAWSURFACE3 This, LPVOID data) +{ + /* data might not be the LPRECT of later versions, so drop it. */ + return IDirectDrawSurface7_Unlock(CONVERT(This), NULL); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_UpdateOverlay(LPDIRECTDRAWSURFACE3 This, LPRECT prcSrc, + LPDIRECTDRAWSURFACE3 pDstSurf, + LPRECT prcDst, DWORD dwFlags, + LPDDOVERLAYFX pFX) +{ + return IDirectDrawSurface7_UpdateOverlay(CONVERT(This), prcSrc, + CONVERT(pDstSurf), prcDst, + dwFlags, pFX); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_UpdateOverlayDisplay(LPDIRECTDRAWSURFACE3 This, + DWORD dwFlags) +{ + return IDirectDrawSurface7_UpdateOverlayDisplay(CONVERT(This), dwFlags); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_UpdateOverlayZOrder(LPDIRECTDRAWSURFACE3 This, + DWORD dwFlags, + LPDIRECTDRAWSURFACE3 pSurfReference) +{ + return IDirectDrawSurface7_UpdateOverlayZOrder(CONVERT(This), dwFlags, + CONVERT(pSurfReference)); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_GetDDInterface(LPDIRECTDRAWSURFACE3 This, LPVOID* ppDD) +{ + return IDirectDrawSurface7_GetDDInterface(CONVERT(This), ppDD); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_PageLock(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags) +{ + return IDirectDrawSurface7_PageLock(CONVERT(This), dwFlags); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_PageUnlock(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags) +{ + return IDirectDrawSurface7_PageUnlock(CONVERT(This), dwFlags); +} + +static HRESULT WINAPI +IDirectDrawSurface3Impl_SetSurfaceDesc(LPDIRECTDRAWSURFACE3 This, + LPDDSURFACEDESC pDDSD, DWORD dwFlags) +{ + return IDirectDrawSurface7_SetSurfaceDesc(CONVERT(This), + (LPDDSURFACEDESC2)pDDSD, + dwFlags); +} + +IDirectDrawSurface3Vtbl DDRAW_IDDS3_Thunk_VTable = +{ + IDirectDrawSurface3Impl_QueryInterface, + IDirectDrawSurface3Impl_AddRef, + IDirectDrawSurface3Impl_Release, + IDirectDrawSurface3Impl_AddAttachedSurface, + IDirectDrawSurface3Impl_AddOverlayDirtyRect, + IDirectDrawSurface3Impl_Blt, + IDirectDrawSurface3Impl_BltBatch, + IDirectDrawSurface3Impl_BltFast, + IDirectDrawSurface3Impl_DeleteAttachedSurface, + IDirectDrawSurface3Impl_EnumAttachedSurfaces, + IDirectDrawSurface3Impl_EnumOverlayZOrders, + IDirectDrawSurface3Impl_Flip, + IDirectDrawSurface3Impl_GetAttachedSurface, + IDirectDrawSurface3Impl_GetBltStatus, + IDirectDrawSurface3Impl_GetCaps, + IDirectDrawSurface3Impl_GetClipper, + IDirectDrawSurface3Impl_GetColorKey, + IDirectDrawSurface3Impl_GetDC, + IDirectDrawSurface3Impl_GetFlipStatus, + IDirectDrawSurface3Impl_GetOverlayPosition, + IDirectDrawSurface3Impl_GetPalette, + IDirectDrawSurface3Impl_GetPixelFormat, + IDirectDrawSurface3Impl_GetSurfaceDesc, + IDirectDrawSurface3Impl_Initialize, + IDirectDrawSurface3Impl_IsLost, + IDirectDrawSurface3Impl_Lock, + IDirectDrawSurface3Impl_ReleaseDC, + IDirectDrawSurface3Impl_Restore, + IDirectDrawSurface3Impl_SetClipper, + IDirectDrawSurface3Impl_SetColorKey, + IDirectDrawSurface3Impl_SetOverlayPosition, + IDirectDrawSurface3Impl_SetPalette, + IDirectDrawSurface3Impl_Unlock, + IDirectDrawSurface3Impl_UpdateOverlay, + IDirectDrawSurface3Impl_UpdateOverlayDisplay, + IDirectDrawSurface3Impl_UpdateOverlayZOrder, + IDirectDrawSurface3Impl_GetDDInterface, + IDirectDrawSurface3Impl_PageLock, + IDirectDrawSurface3Impl_PageUnlock, + IDirectDrawSurface3Impl_SetSurfaceDesc +}; diff --git a/reactos/lib/ddraw/winedraw.h b/reactos/lib/ddraw/winedraw.h new file mode 100644 index 00000000000..cc5d192d6fc --- /dev/null +++ b/reactos/lib/ddraw/winedraw.h @@ -0,0 +1,101 @@ +/* + * Copyright 2000-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _DDCOMIMPL_H_ +#define _DDCOMIMPL_H_ + +#include + +/* Generates the name for a vtable pointer for a given interface. */ +/* The canonical name for a single interface is "lpVtbl". */ +#define ICOM_VFIELD_MULTI_NAME2(iface) ITF_##iface +#define ICOM_VFIELD_MULTI_NAME(iface) ICOM_VFIELD_MULTI_NAME2(iface) + +/* Declares a vtable pointer field in an implementation. */ +#define ICOM_VFIELD_MULTI(iface) \ + iface ICOM_VFIELD_MULTI_NAME(iface) + +/* Returns the offset of a vtable pointer within an implementation object. */ +#define ICOM_VFIELD_OFFSET(impltype, iface) \ + offsetof(impltype, ICOM_VFIELD_MULTI_NAME(iface)) + +/* Given an interface pointer, returns the implementation pointer. */ +#define ICOM_OBJECT(impltype, ifacename, ifaceptr) \ + (impltype*)((ifaceptr) == NULL ? NULL \ + : (char*)(ifaceptr) - ICOM_VFIELD_OFFSET(impltype,ifacename)) + +#define ICOM_THIS_FROM(impltype, ifacename, ifaceptr) \ + impltype* This = ICOM_OBJECT(impltype, ifacename, ifaceptr) + +/* Given an object and interface name, returns a pointer to that interface. */ +#define ICOM_INTERFACE(implobj, iface) \ + (&((implobj)->ICOM_VFIELD_MULTI_NAME(iface))) + +#define ICOM_INIT_INTERFACE(implobj, ifacename, vtblname) \ + do { \ + (implobj)->ICOM_VFIELD_MULTI_NAME(ifacename).lpVtbl = &(vtblname); \ + } while (0) + +#define COM_INTERFACE_CAST(impltype, ifnamefrom, ifnameto, ifaceptr) \ + ICOM_INTERFACE(ICOM_OBJECT(impltype, ifnamefrom, ifaceptr), ifnameto) + +#endif /* _DDCOMIMPL_H_ */ + +#ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H +#define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H + +/* MAY NOT CONTAIN X11 or DGA specific includes/defines/structs! */ + +#include +#include + +#include "windef.h" +#include "winbase.h" +#include "wtypes.h" +#include "wingdi.h" +#include "winuser.h" +#include "ddraw.h" +#include "d3d.h" +#include "ddrawi.h" + +/***************************************************************************** + * IDirectDraw implementation structure + */ + +typedef struct IDirectDrawImpl IDirectDrawImpl; +typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl; + +struct IDirectDrawImpl +{ + ICOM_VFIELD_MULTI(IDirectDraw7); + ICOM_VFIELD_MULTI(IDirectDraw4); + ICOM_VFIELD_MULTI(IDirectDraw2); + ICOM_VFIELD_MULTI(IDirectDraw); +}; + +/***************************************************************************** + * IDirectDrawSurface implementation structure + */ + +struct IDirectDrawSurfaceImpl +{ + /* IUnknown fields */ + ICOM_VFIELD_MULTI(IDirectDrawSurface7); + ICOM_VFIELD_MULTI(IDirectDrawSurface3); +}; + +#endif /* __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H */