[PATCH 5/5] dxgi: Add a separate function for swapchain initialization.

Henri Verbeet hverbeet at codeweavers.com
Mon Dec 28 10:38:05 CST 2009


---
 dlls/dxgi/device.c       |   14 ++++++--------
 dlls/dxgi/dxgi_private.h |    4 +++-
 dlls/dxgi/swapchain.c    |   21 ++++++++++++++++++++-
 3 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c
index eddb1e4..616be6a 100644
--- a/dlls/dxgi/device.c
+++ b/dlls/dxgi/device.c
@@ -291,10 +291,12 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_surface(IWineDXGIDevice *ifa
 static HRESULT STDMETHODCALLTYPE dxgi_device_create_swapchain(IWineDXGIDevice *iface,
         WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **wined3d_swapchain)
 {
-    struct dxgi_device *This = (struct dxgi_device *)iface;
     struct dxgi_swapchain *object;
     HRESULT hr;
 
+    TRACE("iface %p, present_parameters %p, wined3d_swapchain %p.\n",
+            iface, present_parameters, wined3d_swapchain);
+
     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
     if (!object)
     {
@@ -302,20 +304,16 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_swapchain(IWineDXGIDevice *i
         return E_OUTOFMEMORY;
     }
 
-    object->vtbl = &dxgi_swapchain_vtbl;
-    object->refcount = 1;
-
-    hr = IWineD3DDevice_CreateSwapChain(This->wined3d_device, present_parameters,
-            &object->wined3d_swapchain, (IUnknown *)object, SURFACE_OPENGL);
+    hr = dxgi_swapchain_init(object, (struct dxgi_device *)iface, present_parameters);
     if (FAILED(hr))
     {
-        WARN("Failed to create a swapchain, returning %#x\n", hr);
+        WARN("Failed to initialize swapchain, hr %#x.\n", hr);
         HeapFree(GetProcessHeap(), 0, object);
         return hr;
     }
-    *wined3d_swapchain = object->wined3d_swapchain;
 
     TRACE("Created IDXGISwapChain %p\n", object);
+    *wined3d_swapchain = object->wined3d_swapchain;
 
     return S_OK;
 }
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h
index 6151800..693bc39 100644
--- a/dlls/dxgi/dxgi_private.h
+++ b/dlls/dxgi/dxgi_private.h
@@ -121,7 +121,6 @@ struct dxgi_adapter
 HRESULT dxgi_adapter_init(struct dxgi_adapter *adapter, IWineDXGIFactory *parent, UINT ordinal) DECLSPEC_HIDDEN;
 
 /* IDXGISwapChain */
-extern const struct IDXGISwapChainVtbl dxgi_swapchain_vtbl DECLSPEC_HIDDEN;
 struct dxgi_swapchain
 {
     const struct IDXGISwapChainVtbl *vtbl;
@@ -129,6 +128,9 @@ struct dxgi_swapchain
     IWineD3DSwapChain *wined3d_swapchain;
 };
 
+HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device *device,
+        WINED3DPRESENT_PARAMETERS *present_parameters) DECLSPEC_HIDDEN;
+
 /* IDXGISurface */
 struct dxgi_surface
 {
diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c
index a76cb12..891c4ec 100644
--- a/dlls/dxgi/swapchain.c
+++ b/dlls/dxgi/swapchain.c
@@ -249,7 +249,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetLastPresentCount(IDXGISwapCha
     return E_NOTIMPL;
 }
 
-const struct IDXGISwapChainVtbl dxgi_swapchain_vtbl =
+static const struct IDXGISwapChainVtbl dxgi_swapchain_vtbl =
 {
     /* IUnknown methods */
     dxgi_swapchain_QueryInterface,
@@ -274,3 +274,22 @@ const struct IDXGISwapChainVtbl dxgi_swapchain_vtbl =
     dxgi_swapchain_GetFrameStatistics,
     dxgi_swapchain_GetLastPresentCount,
 };
+
+HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device *device,
+        WINED3DPRESENT_PARAMETERS *present_parameters)
+{
+    HRESULT hr;
+
+    swapchain->vtbl = &dxgi_swapchain_vtbl;
+    swapchain->refcount = 1;
+
+    hr = IWineD3DDevice_CreateSwapChain(device->wined3d_device, present_parameters,
+            &swapchain->wined3d_swapchain, (IUnknown *)swapchain, SURFACE_OPENGL);
+    if (FAILED(hr))
+    {
+        WARN("Failed to create wined3d swapchain, hr %#x.\n", hr);
+        return hr;
+    }
+
+    return S_OK;
+}
-- 
1.6.4.4




More information about the wine-patches mailing list