Henri Verbeet : d3d9: Get rid of the implicit swapchain refcounting hacks.

Alexandre Julliard julliard at winehq.org
Tue Apr 12 11:07:34 CDT 2011


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Mon Apr 11 20:55:17 2011 +0200

d3d9: Get rid of the implicit swapchain refcounting hacks.

---

 dlls/d3d9/d3d9_private.h |    3 ---
 dlls/d3d9/device.c       |   16 +++++-----------
 dlls/d3d9/swapchain.c    |   17 ++++++-----------
 3 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index 6e5d6d8..f1c0a8c 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -222,9 +222,6 @@ typedef struct IDirect3DSwapChain9Impl
 
     /* Parent reference */
     LPDIRECT3DDEVICE9EX       parentDevice;
-
-    /* Flags an implicit swap chain */
-    BOOL                        isImplicit;
 } IDirect3DSwapChain9Impl;
 
 HRESULT swapchain_init(IDirect3DSwapChain9Impl *swapchain, IDirect3DDevice9Impl *device,
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 1a66104..9565815 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -183,14 +183,9 @@ static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, U
 
 static ULONG WINAPI D3D9CB_DestroySwapChain(IWineD3DSwapChain *swapchain)
 {
-    IDirect3DSwapChain9Impl *parent;
-
     TRACE("swapchain %p.\n", swapchain);
 
-    parent = IWineD3DSwapChain_GetParent(swapchain);
-    parent->isImplicit = FALSE;
-    IDirect3DSwapChain9_AddRef((IDirect3DSwapChain9 *)parent);
-    return IDirect3DSwapChain9_Release((IDirect3DSwapChain9 *)parent);
+    return IWineD3DSwapChain_Release(swapchain);
 }
 
 /* IDirect3D IUnknown parts follow: */
@@ -3174,8 +3169,8 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
         WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
 {
     struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
-    IDirect3DSwapChain9Impl *d3d_swapchain;
     D3DPRESENT_PARAMETERS local_parameters;
+    IDirect3DSwapChain9 *d3d_swapchain;
     HRESULT hr;
 
     TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
@@ -3197,7 +3192,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
     local_parameters.PresentationInterval = present_parameters->PresentationInterval;
 
     hr = IDirect3DDevice9Impl_CreateAdditionalSwapChain((IDirect3DDevice9Ex *)This,
-            &local_parameters, (IDirect3DSwapChain9 **)&d3d_swapchain);
+            &local_parameters, &d3d_swapchain);
     if (FAILED(hr))
     {
         ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface, hr);
@@ -3205,9 +3200,8 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
         return hr;
     }
 
-    *swapchain = d3d_swapchain->wineD3DSwapChain;
-    d3d_swapchain->isImplicit = TRUE;
-    /* Implicit swap chains are created with an refcount of 0 */
+    *swapchain = ((IDirect3DSwapChain9Impl *)d3d_swapchain)->wineD3DSwapChain;
+    IWineD3DSwapChain_AddRef(*swapchain);
     IDirect3DSwapChain9_Release((IDirect3DSwapChain9 *)d3d_swapchain);
 
     /* Copy back the presentation parameters */
diff --git a/dlls/d3d9/swapchain.c b/dlls/d3d9/swapchain.c
index df1cc77..7301247 100644
--- a/dlls/d3d9/swapchain.c
+++ b/dlls/d3d9/swapchain.c
@@ -55,12 +55,9 @@ static ULONG WINAPI IDirect3DSwapChain9Impl_AddRef(LPDIRECT3DSWAPCHAIN9 iface) {
         if (This->parentDevice)
             IDirect3DDevice9Ex_AddRef(This->parentDevice);
 
-        if (!This->isImplicit)
-        {
-            wined3d_mutex_lock();
-            IWineD3DSwapChain_AddRef(This->wineD3DSwapChain);
-            wined3d_mutex_unlock();
-        }
+        wined3d_mutex_lock();
+        IWineD3DSwapChain_AddRef(This->wineD3DSwapChain);
+        wined3d_mutex_unlock();
     }
 
     return ref;
@@ -75,11 +72,9 @@ static ULONG WINAPI IDirect3DSwapChain9Impl_Release(LPDIRECT3DSWAPCHAIN9 iface)
     if (ref == 0) {
         IDirect3DDevice9Ex *parentDevice = This->parentDevice;
 
-        if (!This->isImplicit) {
-            wined3d_mutex_lock();
-            IWineD3DSwapChain_Destroy(This->wineD3DSwapChain);
-            wined3d_mutex_unlock();
-        }
+        wined3d_mutex_lock();
+        IWineD3DSwapChain_Release(This->wineD3DSwapChain);
+        wined3d_mutex_unlock();
 
         /* Release the device last, as it may cause the device to be destroyed. */
         if (parentDevice) IDirect3DDevice9Ex_Release(parentDevice);




More information about the wine-cvs mailing list