Michael Stefaniuc : dxgi: COM cleanup for the IWineDXGIFactory iface.

Alexandre Julliard julliard at winehq.org
Tue Jun 7 12:02:35 CDT 2011


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

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Tue Jun  7 09:56:55 2011 +0200

dxgi: COM cleanup for the IWineDXGIFactory iface.

---

 dlls/dxgi/dxgi_private.h |    2 +-
 dlls/dxgi/factory.c      |   17 +++++++++++------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h
index 98fdea8..5af04b4 100644
--- a/dlls/dxgi/dxgi_private.h
+++ b/dlls/dxgi/dxgi_private.h
@@ -77,7 +77,7 @@ enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format) DECLSP
 /* IDXGIFactory */
 struct dxgi_factory
 {
-    const struct IWineDXGIFactoryVtbl *vtbl;
+    IWineDXGIFactory IWineDXGIFactory_iface;
     LONG refcount;
     struct wined3d *wined3d;
     UINT adapter_count;
diff --git a/dlls/dxgi/factory.c b/dlls/dxgi/factory.c
index 71e9fe1..dd1ec5e 100644
--- a/dlls/dxgi/factory.c
+++ b/dlls/dxgi/factory.c
@@ -24,6 +24,11 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
 
+static inline struct dxgi_factory *impl_from_IWineDXGIFactory(IWineDXGIFactory *iface)
+{
+    return CONTAINING_RECORD(iface, struct dxgi_factory, IWineDXGIFactory_iface);
+}
+
 /* IUnknown methods */
 
 static HRESULT STDMETHODCALLTYPE dxgi_factory_QueryInterface(IWineDXGIFactory *iface, REFIID riid, void **object)
@@ -48,7 +53,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_QueryInterface(IWineDXGIFactory *i
 
 static ULONG STDMETHODCALLTYPE dxgi_factory_AddRef(IWineDXGIFactory *iface)
 {
-    struct dxgi_factory *This = (struct dxgi_factory *)iface;
+    struct dxgi_factory *This = impl_from_IWineDXGIFactory(iface);
     ULONG refcount = InterlockedIncrement(&This->refcount);
 
     TRACE("%p increasing refcount to %u\n", This, refcount);
@@ -58,7 +63,7 @@ static ULONG STDMETHODCALLTYPE dxgi_factory_AddRef(IWineDXGIFactory *iface)
 
 static ULONG STDMETHODCALLTYPE dxgi_factory_Release(IWineDXGIFactory *iface)
 {
-    struct dxgi_factory *This = (struct dxgi_factory *)iface;
+    struct dxgi_factory *This = impl_from_IWineDXGIFactory(iface);
     ULONG refcount = InterlockedDecrement(&This->refcount);
 
     TRACE("%p decreasing refcount to %u\n", This, refcount);
@@ -122,7 +127,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_GetParent(IWineDXGIFactory *iface,
 static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters(IWineDXGIFactory *iface,
         UINT adapter_idx, IDXGIAdapter **adapter)
 {
-    struct dxgi_factory *This = (struct dxgi_factory *)iface;
+    struct dxgi_factory *This = impl_from_IWineDXGIFactory(iface);
 
     TRACE("iface %p, adapter_idx %u, adapter %p\n", iface, adapter_idx, adapter);
 
@@ -258,7 +263,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSoftwareAdapter(IWineDXGIFac
 
 static struct wined3d * STDMETHODCALLTYPE dxgi_factory_get_wined3d(IWineDXGIFactory *iface)
 {
-    struct dxgi_factory *This = (struct dxgi_factory *)iface;
+    struct dxgi_factory *This = impl_from_IWineDXGIFactory(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -294,7 +299,7 @@ HRESULT dxgi_factory_init(struct dxgi_factory *factory)
     HRESULT hr;
     UINT i;
 
-    factory->vtbl = &dxgi_factory_vtbl;
+    factory->IWineDXGIFactory_iface.lpVtbl = &dxgi_factory_vtbl;
     factory->refcount = 1;
 
     EnterCriticalSection(&dxgi_cs);
@@ -332,7 +337,7 @@ HRESULT dxgi_factory_init(struct dxgi_factory *factory)
             goto fail;
         }
 
-        hr = dxgi_adapter_init(adapter, (IWineDXGIFactory *)factory, i);
+        hr = dxgi_adapter_init(adapter, &factory->IWineDXGIFactory_iface, i);
         if (FAILED(hr))
         {
             UINT j;




More information about the wine-cvs mailing list