Commit 5d358a2b authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

dxgi: COM cleanup for the surface IUnknown interface.

parent 230c5fc7
......@@ -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;
}
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment