[PATCH 8/8] ddraw: Add a separate function for clipper initialization.

Henri Verbeet hverbeet at codeweavers.com
Wed Aug 18 12:26:25 CDT 2010


---
 dlls/ddraw/clipper.c       |   16 +++++++++++++++-
 dlls/ddraw/ddraw.c         |   12 +++++++-----
 dlls/ddraw/ddraw_private.h |    2 +-
 3 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/dlls/ddraw/clipper.c b/dlls/ddraw/clipper.c
index 25e71fa..a7ec624 100644
--- a/dlls/ddraw/clipper.c
+++ b/dlls/ddraw/clipper.c
@@ -283,7 +283,7 @@ static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged(
 /*****************************************************************************
  * The VTable
  *****************************************************************************/
-const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl =
+static const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl =
 {
     IDirectDrawClipperImpl_QueryInterface,
     IDirectDrawClipperImpl_AddRef,
@@ -295,3 +295,17 @@ const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl =
     IDirectDrawClipperImpl_SetClipList,
     IDirectDrawClipperImpl_SetHwnd
 };
+
+HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper)
+{
+    clipper->lpVtbl = &ddraw_clipper_vtbl;
+    clipper->ref = 1;
+    clipper->wineD3DClipper = pWineDirect3DCreateClipper((IUnknown *)clipper);
+    if (!clipper->wineD3DClipper)
+    {
+        WARN("Failed to create wined3d clipper.\n");
+        return E_OUTOFMEMORY;
+    }
+
+    return DD_OK;
+}
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index df79f0e..20f31ee 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -3840,6 +3840,8 @@ DirectDrawCreateClipper(DWORD Flags,
                         IUnknown *UnkOuter)
 {
     IDirectDrawClipperImpl* object;
+    HRESULT hr;
+
     TRACE("(%08x,%p,%p)\n", Flags, Clipper, UnkOuter);
 
     EnterCriticalSection(&ddraw_cs);
@@ -3863,16 +3865,16 @@ DirectDrawCreateClipper(DWORD Flags,
         return E_OUTOFMEMORY;
     }
 
-    object->lpVtbl = &IDirectDrawClipper_Vtbl;
-    object->ref = 1;
-    object->wineD3DClipper = pWineDirect3DCreateClipper((IUnknown *) object);
-    if(!object->wineD3DClipper)
+    hr = ddraw_clipper_init(object);
+    if (FAILED(hr))
     {
+        WARN("Failed to initialize clipper, hr %#x.\n", hr);
         HeapFree(GetProcessHeap(), 0, object);
         LeaveCriticalSection(&ddraw_cs);
-        return E_OUTOFMEMORY;
+        return hr;
     }
 
+    TRACE("Created clipper %p.\n", object);
     *Clipper = (IDirectDrawClipper *) object;
     LeaveCriticalSection(&ddraw_cs);
     return DD_OK;
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index 40f3bfd..6341f3f 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -462,7 +462,7 @@ struct IDirectDrawClipperImpl
     BOOL initialized;
 };
 
-extern const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl DECLSPEC_HIDDEN;
+HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper) DECLSPEC_HIDDEN;
 
 typeof(WineDirect3DCreateClipper) *pWineDirect3DCreateClipper DECLSPEC_HIDDEN;
 
-- 
1.7.1




More information about the wine-patches mailing list