From 5d358a2bac82229a7c9bafa3381b252d9506da7e Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 19 Apr 2012 20:44:59 +0200 Subject: [PATCH] dxgi: COM cleanup for the surface IUnknown interface. --- dlls/dxgi/device.c | 2 +- dlls/dxgi/dxgi_private.h | 2 +- dlls/dxgi/surface.c | 36 ++++++++++++++++++------------------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c index bc01b16a56e..3115032eb57 100644 --- a/dlls/dxgi/device.c +++ b/dlls/dxgi/device.c @@ -284,7 +284,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_surface(IWineDXGIDevice *ifa } TRACE("Created IDXGISurface %p\n", object); - *surface = outer ? (void *)&object->inner_unknown_vtbl : object; + *surface = outer ? &object->IUnknown_iface : (IUnknown *)&object->IDXGISurface_iface; return S_OK; } diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h index 533f1faf43a..4c426ba7bae 100644 --- a/dlls/dxgi/dxgi_private.h +++ b/dlls/dxgi/dxgi_private.h @@ -136,7 +136,7 @@ HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device struct dxgi_surface { IDXGISurface IDXGISurface_iface; - const struct IUnknownVtbl *inner_unknown_vtbl; + IUnknown IUnknown_iface; IUnknown *outer_unknown; LONG refcount; IDXGIDevice *device; diff --git a/dlls/dxgi/surface.c b/dlls/dxgi/surface.c index 374832b2080..f7fa93176ce 100644 --- a/dlls/dxgi/surface.c +++ b/dlls/dxgi/surface.c @@ -26,54 +26,54 @@ WINE_DEFAULT_DEBUG_CHANNEL(dxgi); /* Inner IUnknown methods */ -static inline struct dxgi_surface *dxgi_surface_from_inner_unknown(IUnknown *iface) +static inline struct dxgi_surface *impl_from_IUnknown(IUnknown *iface) { - return (struct dxgi_surface *)((char*)iface - FIELD_OFFSET(struct dxgi_surface, inner_unknown_vtbl)); + return CONTAINING_RECORD(iface, struct dxgi_surface, IUnknown_iface); } -static HRESULT STDMETHODCALLTYPE dxgi_surface_inner_QueryInterface(IUnknown *iface, REFIID riid, void **object) +static HRESULT STDMETHODCALLTYPE dxgi_surface_inner_QueryInterface(IUnknown *iface, REFIID riid, void **out) { - struct dxgi_surface *This = dxgi_surface_from_inner_unknown(iface); + struct dxgi_surface *surface = impl_from_IUnknown(iface); - TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object); + TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out); if (IsEqualGUID(riid, &IID_IDXGISurface) || IsEqualGUID(riid, &IID_IDXGIDeviceSubObject) || IsEqualGUID(riid, &IID_IDXGIObject) || IsEqualGUID(riid, &IID_IUnknown)) { - IDXGISurface_AddRef(&This->IDXGISurface_iface); - *object = &This->IDXGISurface_iface; + IDXGISurface_AddRef(&surface->IDXGISurface_iface); + *out = &surface->IDXGISurface_iface; return S_OK; } WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid)); - *object = NULL; + *out = NULL; return E_NOINTERFACE; } static ULONG STDMETHODCALLTYPE dxgi_surface_inner_AddRef(IUnknown *iface) { - struct dxgi_surface *This = dxgi_surface_from_inner_unknown(iface); - ULONG refcount = InterlockedIncrement(&This->refcount); + struct dxgi_surface *surface = impl_from_IUnknown(iface); + ULONG refcount = InterlockedIncrement(&surface->refcount); - TRACE("%p increasing refcount to %u\n", This, refcount); + TRACE("%p increasing refcount to %u.\n", surface, refcount); return refcount; } static ULONG STDMETHODCALLTYPE dxgi_surface_inner_Release(IUnknown *iface) { - struct dxgi_surface *This = dxgi_surface_from_inner_unknown(iface); - ULONG refcount = InterlockedDecrement(&This->refcount); + struct dxgi_surface *surface = impl_from_IUnknown(iface); + ULONG refcount = InterlockedDecrement(&surface->refcount); - TRACE("%p decreasing refcount to %u\n", This, refcount); + TRACE("%p decreasing refcount to %u.\n", surface, refcount); if (!refcount) { - IDXGIDevice_Release(This->device); - HeapFree(GetProcessHeap(), 0, This); + IDXGIDevice_Release(surface->device); + HeapFree(GetProcessHeap(), 0, surface); } return refcount; @@ -206,9 +206,9 @@ static const struct IUnknownVtbl dxgi_surface_inner_unknown_vtbl = HRESULT dxgi_surface_init(struct dxgi_surface *surface, IDXGIDevice *device, IUnknown *outer) { surface->IDXGISurface_iface.lpVtbl = &dxgi_surface_vtbl; - surface->inner_unknown_vtbl = &dxgi_surface_inner_unknown_vtbl; + surface->IUnknown_iface.lpVtbl = &dxgi_surface_inner_unknown_vtbl; surface->refcount = 1; - surface->outer_unknown = outer ? outer : (IUnknown *)&surface->inner_unknown_vtbl; + surface->outer_unknown = outer ? outer : &surface->IUnknown_iface; surface->device = device; IDXGIDevice_AddRef(device);