From 588ddee736fc2fc95acd91a01f3698c065d34f87 Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Mon, 20 Jun 2011 11:20:41 +0200 Subject: [PATCH] ddraw: COM cleanup for the IDirectDrawClipper iface. --- dlls/ddraw/clipper.c | 70 +++++++++++++++++++------------------- dlls/ddraw/ddraw.c | 2 +- dlls/ddraw/ddraw_private.h | 3 +- dlls/ddraw/surface.c | 2 +- 4 files changed, 38 insertions(+), 39 deletions(-) diff --git a/dlls/ddraw/clipper.c b/dlls/ddraw/clipper.c index c9290c85a50..b6e66f4164d 100644 --- a/dlls/ddraw/clipper.c +++ b/dlls/ddraw/clipper.c @@ -26,9 +26,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw); -/***************************************************************************** - * IUnknown methods - *****************************************************************************/ +static inline IDirectDrawClipperImpl *impl_from_IDirectDrawClipper(IDirectDrawClipper *iface) +{ + return CONTAINING_RECORD(iface, IDirectDrawClipperImpl, IDirectDrawClipper_iface); +} /***************************************************************************** * IDirectDrawClipper::QueryInterface @@ -46,9 +47,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw); * E_NOINTERFACE if the requested interface wasn't found. * *****************************************************************************/ -static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface( - LPDIRECTDRAWCLIPPER iface, REFIID riid, LPVOID* ppvObj -) { +static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface(IDirectDrawClipper *iface, REFIID riid, + void **ppvObj) +{ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppvObj); @@ -69,9 +70,9 @@ static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface( * Increases the reference count of the interface, returns the new count * *****************************************************************************/ -static ULONG WINAPI IDirectDrawClipperImpl_AddRef( LPDIRECTDRAWCLIPPER iface ) +static ULONG WINAPI IDirectDrawClipperImpl_AddRef(IDirectDrawClipper *iface) { - IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; + IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface); ULONG ref = InterlockedIncrement(&This->ref); TRACE("%p increasing refcount to %u.\n", This, ref); @@ -86,8 +87,9 @@ static ULONG WINAPI IDirectDrawClipperImpl_AddRef( LPDIRECTDRAWCLIPPER iface ) * If the refcount is decreased to 0, the interface is destroyed. * *****************************************************************************/ -static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface) { - IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; +static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface) +{ + IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("%p decreasing refcount to %u.\n", This, ref); @@ -118,10 +120,10 @@ static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface) { * *****************************************************************************/ -static HRESULT WINAPI IDirectDrawClipperImpl_SetHwnd( - LPDIRECTDRAWCLIPPER iface, DWORD dwFlags, HWND hWnd -) { - IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; +static HRESULT WINAPI IDirectDrawClipperImpl_SetHwnd(IDirectDrawClipper *iface, DWORD dwFlags, + HWND hWnd) +{ + IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface); HRESULT hr; TRACE("iface %p, flags %#x, window %p.\n", iface, dwFlags, hWnd); @@ -154,11 +156,10 @@ static HRESULT WINAPI IDirectDrawClipperImpl_SetHwnd( * RETURNS * Either DD_OK or DDERR_* ************************************************************************/ -static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList( - LPDIRECTDRAWCLIPPER iface, LPRECT lpRect, LPRGNDATA lpClipList, - LPDWORD lpdwSize) +static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(IDirectDrawClipper *iface, RECT *lpRect, + RGNDATA *lpClipList, DWORD *lpdwSize) { - IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; + IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface); HRESULT hr; TRACE("iface %p, rect %s, clip_list %p, clip_list_size %p.\n", @@ -184,10 +185,10 @@ static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList( * RETURNS * Either DD_OK or DDERR_* *****************************************************************************/ -static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList( - LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,DWORD dwFlag -) { - IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; +static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(IDirectDrawClipper *iface, RGNDATA *lprgn, + DWORD dwFlag) +{ + IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface); HRESULT hr; TRACE("iface %p, clip_list %p, flags %#x.\n", iface, lprgn, dwFlag); @@ -209,10 +210,9 @@ static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList( * Return values: * Always returns DD_OK; *****************************************************************************/ -static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd( - LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr -) { - IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; +static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(IDirectDrawClipper *iface, HWND *hWndPtr) +{ + IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface); HRESULT hr; TRACE("iface %p, window %p.\n", iface, hWndPtr); @@ -237,12 +237,12 @@ static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd( * DD_OK on success * DDERR_ALREADYINITIALIZED if this interface isn't initialized already *****************************************************************************/ -static HRESULT WINAPI IDirectDrawClipperImpl_Initialize( - LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags -) { - IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; +static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(IDirectDrawClipper *iface, + IDirectDraw *ddraw, DWORD dwFlags) +{ + IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface); - TRACE("iface %p, ddraw %p, flags %#x.\n", iface, lpDD, dwFlags); + TRACE("iface %p, ddraw %p, flags %#x.\n", iface, ddraw, dwFlags); EnterCriticalSection(&ddraw_cs); if (This->initialized) @@ -268,9 +268,9 @@ static HRESULT WINAPI IDirectDrawClipperImpl_Initialize( * Return values: * DD_OK, because it's a stub *****************************************************************************/ -static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged( - LPDIRECTDRAWCLIPPER iface, BOOL* lpbChanged -) { +static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged(IDirectDrawClipper *iface, + BOOL *lpbChanged) +{ FIXME("iface %p, changed %p stub!\n", iface, lpbChanged); /* XXX What is safest? */ @@ -297,7 +297,7 @@ static const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl = HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper) { - clipper->lpVtbl = &ddraw_clipper_vtbl; + clipper->IDirectDrawClipper_iface.lpVtbl = &ddraw_clipper_vtbl; clipper->ref = 1; clipper->wineD3DClipper = wined3d_clipper_create(); if (!clipper->wineD3DClipper) diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 0474d19f8ed..f6d41911551 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -3997,7 +3997,7 @@ DirectDrawCreateClipper(DWORD Flags, } TRACE("Created clipper %p.\n", object); - *Clipper = (IDirectDrawClipper *) object; + *Clipper = &object->IDirectDrawClipper_iface; LeaveCriticalSection(&ddraw_cs); return DD_OK; } diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 7a45d9f8f94..9b88037507d 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -358,8 +358,7 @@ static inline IDirect3DDeviceImpl *device_from_device3(IDirect3DDevice3 *iface) *****************************************************************************/ struct IDirectDrawClipperImpl { - /* IUnknown fields */ - const IDirectDrawClipperVtbl *lpVtbl; + IDirectDrawClipper IDirectDrawClipper_iface; LONG ref; struct wined3d_clipper *wineD3DClipper; diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 38be89cd9fd..c0e7b255a22 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -3645,7 +3645,7 @@ static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface, IDir if (Clipper != NULL) IDirectDrawClipper_AddRef(Clipper); if(oldClipper) - IDirectDrawClipper_Release((IDirectDrawClipper *)oldClipper); + IDirectDrawClipper_Release(&oldClipper->IDirectDrawClipper_iface); hr = wined3d_surface_set_clipper(This->wined3d_surface, This->clipper ? This->clipper->wineD3DClipper : NULL);