Commit 219a8302 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

dxgi: COM cleanup for the IDXGISurface iface.

parent 2486da82
...@@ -135,7 +135,7 @@ HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device ...@@ -135,7 +135,7 @@ HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device
/* IDXGISurface */ /* IDXGISurface */
struct dxgi_surface struct dxgi_surface
{ {
const struct IDXGISurfaceVtbl *vtbl; IDXGISurface IDXGISurface_iface;
const struct IUnknownVtbl *inner_unknown_vtbl; const struct IUnknownVtbl *inner_unknown_vtbl;
IUnknown *outer_unknown; IUnknown *outer_unknown;
LONG refcount; LONG refcount;
......
...@@ -42,7 +42,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_surface_inner_QueryInterface(IUnknown *ifa ...@@ -42,7 +42,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_surface_inner_QueryInterface(IUnknown *ifa
|| IsEqualGUID(riid, &IID_IDXGIObject) || IsEqualGUID(riid, &IID_IDXGIObject)
|| IsEqualGUID(riid, &IID_IUnknown)) || IsEqualGUID(riid, &IID_IUnknown))
{ {
IUnknown_AddRef((IUnknown *)This); IDXGISurface_AddRef(&This->IDXGISurface_iface);
*object = This; *object = This;
return S_OK; return S_OK;
} }
...@@ -79,25 +79,31 @@ static ULONG STDMETHODCALLTYPE dxgi_surface_inner_Release(IUnknown *iface) ...@@ -79,25 +79,31 @@ static ULONG STDMETHODCALLTYPE dxgi_surface_inner_Release(IUnknown *iface)
return refcount; return refcount;
} }
static inline struct dxgi_surface *impl_from_IDXGISurface(IDXGISurface *iface)
{
return CONTAINING_RECORD(iface, struct dxgi_surface, IDXGISurface_iface);
}
/* IUnknown methods */ /* IUnknown methods */
static HRESULT STDMETHODCALLTYPE dxgi_surface_QueryInterface(IDXGISurface *iface, REFIID riid, void **object) static HRESULT STDMETHODCALLTYPE dxgi_surface_QueryInterface(IDXGISurface *iface, REFIID riid,
void **object)
{ {
struct dxgi_surface *This = (struct dxgi_surface *)iface; struct dxgi_surface *This = impl_from_IDXGISurface(iface);
TRACE("Forwarding to outer IUnknown\n"); TRACE("Forwarding to outer IUnknown\n");
return IUnknown_QueryInterface(This->outer_unknown, riid, object); return IUnknown_QueryInterface(This->outer_unknown, riid, object);
} }
static ULONG STDMETHODCALLTYPE dxgi_surface_AddRef(IDXGISurface *iface) static ULONG STDMETHODCALLTYPE dxgi_surface_AddRef(IDXGISurface *iface)
{ {
struct dxgi_surface *This = (struct dxgi_surface *)iface; struct dxgi_surface *This = impl_from_IDXGISurface(iface);
TRACE("Forwarding to outer IUnknown\n"); TRACE("Forwarding to outer IUnknown\n");
return IUnknown_AddRef(This->outer_unknown); return IUnknown_AddRef(This->outer_unknown);
} }
static ULONG STDMETHODCALLTYPE dxgi_surface_Release(IDXGISurface *iface) static ULONG STDMETHODCALLTYPE dxgi_surface_Release(IDXGISurface *iface)
{ {
struct dxgi_surface *This = (struct dxgi_surface *)iface; struct dxgi_surface *This = impl_from_IDXGISurface(iface);
TRACE("Forwarding to outer IUnknown\n"); TRACE("Forwarding to outer IUnknown\n");
return IUnknown_Release(This->outer_unknown); return IUnknown_Release(This->outer_unknown);
} }
...@@ -130,7 +136,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_surface_GetPrivateData(IDXGISurface *iface ...@@ -130,7 +136,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_surface_GetPrivateData(IDXGISurface *iface
static HRESULT STDMETHODCALLTYPE dxgi_surface_GetParent(IDXGISurface *iface, REFIID riid, void **parent) static HRESULT STDMETHODCALLTYPE dxgi_surface_GetParent(IDXGISurface *iface, REFIID riid, void **parent)
{ {
struct dxgi_surface *This = (struct dxgi_surface *)iface; struct dxgi_surface *This = impl_from_IDXGISurface(iface);
TRACE("iface %p, riid %s, parent %p.\n", iface, debugstr_guid(riid), parent); TRACE("iface %p, riid %s, parent %p.\n", iface, debugstr_guid(riid), parent);
...@@ -141,7 +147,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_surface_GetParent(IDXGISurface *iface, REF ...@@ -141,7 +147,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_surface_GetParent(IDXGISurface *iface, REF
static HRESULT STDMETHODCALLTYPE dxgi_surface_GetDevice(IDXGISurface *iface, REFIID riid, void **device) static HRESULT STDMETHODCALLTYPE dxgi_surface_GetDevice(IDXGISurface *iface, REFIID riid, void **device)
{ {
struct dxgi_surface *This = (struct dxgi_surface *)iface; struct dxgi_surface *This = impl_from_IDXGISurface(iface);
TRACE("iface %p, riid %s, device %p.\n", iface, debugstr_guid(riid), device); TRACE("iface %p, riid %s, device %p.\n", iface, debugstr_guid(riid), device);
...@@ -199,7 +205,7 @@ static const struct IUnknownVtbl dxgi_surface_inner_unknown_vtbl = ...@@ -199,7 +205,7 @@ static const struct IUnknownVtbl dxgi_surface_inner_unknown_vtbl =
HRESULT dxgi_surface_init(struct dxgi_surface *surface, IDXGIDevice *device, IUnknown *outer) HRESULT dxgi_surface_init(struct dxgi_surface *surface, IDXGIDevice *device, IUnknown *outer)
{ {
surface->vtbl = &dxgi_surface_vtbl; surface->IDXGISurface_iface.lpVtbl = &dxgi_surface_vtbl;
surface->inner_unknown_vtbl = &dxgi_surface_inner_unknown_vtbl; surface->inner_unknown_vtbl = &dxgi_surface_inner_unknown_vtbl;
surface->refcount = 1; surface->refcount = 1;
surface->outer_unknown = outer ? outer : (IUnknown *)&surface->inner_unknown_vtbl; surface->outer_unknown = outer ? outer : (IUnknown *)&surface->inner_unknown_vtbl;
......
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