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

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


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

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Tue Jun  7 10:00:30 2011 +0200

dxgi: COM cleanup for the IWineDXGIDevice iface.

---

 dlls/dxgi/device.c       |   23 +++++++++++++++--------
 dlls/dxgi/dxgi_private.h |    2 +-
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c
index 8c61d67..f7ad811 100644
--- a/dlls/dxgi/device.c
+++ b/dlls/dxgi/device.c
@@ -24,11 +24,16 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
 
+static inline struct dxgi_device *impl_from_IWineDXGIDevice(IWineDXGIDevice *iface)
+{
+    return CONTAINING_RECORD(iface, struct dxgi_device, IWineDXGIDevice_iface);
+}
+
 /* IUnknown methods */
 
 static HRESULT STDMETHODCALLTYPE dxgi_device_QueryInterface(IWineDXGIDevice *iface, REFIID riid, void **object)
 {
-    struct dxgi_device *This = (struct dxgi_device *)iface;
+    struct dxgi_device *This = impl_from_IWineDXGIDevice(iface);
 
     TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
 
@@ -56,7 +61,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_QueryInterface(IWineDXGIDevice *ifa
 
 static ULONG STDMETHODCALLTYPE dxgi_device_AddRef(IWineDXGIDevice *iface)
 {
-    struct dxgi_device *This = (struct dxgi_device *)iface;
+    struct dxgi_device *This = impl_from_IWineDXGIDevice(iface);
     ULONG refcount = InterlockedIncrement(&This->refcount);
 
     TRACE("%p increasing refcount to %u\n", This, refcount);
@@ -66,7 +71,7 @@ static ULONG STDMETHODCALLTYPE dxgi_device_AddRef(IWineDXGIDevice *iface)
 
 static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface)
 {
-    struct dxgi_device *This = (struct dxgi_device *)iface;
+    struct dxgi_device *This = impl_from_IWineDXGIDevice(iface);
     ULONG refcount = InterlockedDecrement(&This->refcount);
 
     TRACE("%p decreasing refcount to %u\n", This, refcount);
@@ -134,7 +139,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_GetParent(IWineDXGIDevice *iface, R
 
 static HRESULT STDMETHODCALLTYPE dxgi_device_GetAdapter(IWineDXGIDevice *iface, IDXGIAdapter **adapter)
 {
-    struct dxgi_device *This = (struct dxgi_device *)iface;
+    struct dxgi_device *This = impl_from_IWineDXGIDevice(iface);
     WINED3DDEVICE_CREATION_PARAMETERS create_parameters;
     HRESULT hr;
 
@@ -244,7 +249,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_GetGPUThreadPriority(IWineDXGIDevic
 
 static struct wined3d_device * STDMETHODCALLTYPE dxgi_device_get_wined3d_device(IWineDXGIDevice *iface)
 {
-    struct dxgi_device *This = (struct dxgi_device *)iface;
+    struct dxgi_device *This = impl_from_IWineDXGIDevice(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -287,6 +292,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_surface(IWineDXGIDevice *ifa
 static HRESULT STDMETHODCALLTYPE dxgi_device_create_swapchain(IWineDXGIDevice *iface,
         WINED3DPRESENT_PARAMETERS *present_parameters, struct wined3d_swapchain **wined3d_swapchain)
 {
+    struct dxgi_device *This = impl_from_IWineDXGIDevice(iface);
     struct dxgi_swapchain *object;
     HRESULT hr;
 
@@ -300,7 +306,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_swapchain(IWineDXGIDevice *i
         return E_OUTOFMEMORY;
     }
 
-    hr = dxgi_swapchain_init(object, (struct dxgi_device *)iface, present_parameters);
+    hr = dxgi_swapchain_init(object, This, present_parameters);
     if (FAILED(hr))
     {
         WARN("Failed to initialize swapchain, hr %#x.\n", hr);
@@ -348,7 +354,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
     void *layer_base;
     HRESULT hr;
 
-    device->vtbl = &dxgi_device_vtbl;
+    device->IWineDXGIDevice_iface.lpVtbl = &dxgi_device_vtbl;
     device->refcount = 1;
 
     layer_base = device + 1;
@@ -381,7 +387,8 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
     adapter_ordinal = IWineDXGIAdapter_get_ordinal(wine_adapter);
     IWineDXGIAdapter_Release(wine_adapter);
 
-    hr = IUnknown_QueryInterface((IUnknown *)device, &IID_IWineDXGIDeviceParent, (void **)&dxgi_device_parent);
+    hr = IWineDXGIDevice_QueryInterface(&device->IWineDXGIDevice_iface, &IID_IWineDXGIDeviceParent,
+            (void **)&dxgi_device_parent);
     if (FAILED(hr))
     {
         ERR("DXGI device should implement IWineD3DDeviceParent.\n");
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h
index 5af04b4..023e68e 100644
--- a/dlls/dxgi/dxgi_private.h
+++ b/dlls/dxgi/dxgi_private.h
@@ -89,7 +89,7 @@ HRESULT dxgi_factory_init(struct dxgi_factory *factory) DECLSPEC_HIDDEN;
 /* IDXGIDevice */
 struct dxgi_device
 {
-    const struct IWineDXGIDeviceVtbl *vtbl;
+    IWineDXGIDevice IWineDXGIDevice_iface;
     IUnknown *child_layer;
     LONG refcount;
     struct wined3d_device *wined3d_device;




More information about the wine-cvs mailing list