Michael Stefaniuc : ddraw: COM cleanup for the IDirectDrawClipper iface.

Alexandre Julliard julliard at winehq.org
Mon Jun 20 14:24:09 CDT 2011


Module: wine
Branch: master
Commit: 588ddee736fc2fc95acd91a01f3698c065d34f87
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=588ddee736fc2fc95acd91a01f3698c065d34f87

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Mon Jun 20 11:20:41 2011 +0200

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 c9290c8..b6e66f4 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 0474d19..f6d4191 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 7a45d9f..9b88037 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 38be89c..c0e7b25 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);




More information about the wine-cvs mailing list