Commit 4e29ade6 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

dxgi: Add a separate function for surface initialization.

parent 89c96ca3
......@@ -262,6 +262,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_surface(IWineDXGIDevice *ifa
DXGI_USAGE usage, const DXGI_SHARED_RESOURCE *shared_resource, IUnknown *outer, void **surface)
{
struct dxgi_surface *object;
HRESULT hr;
FIXME("iface %p, desc %p, usage %#x, shared_resource %p, outer %p, surface %p partial stub!\n",
iface, desc, usage, shared_resource, outer, surface);
......@@ -273,22 +274,16 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_surface(IWineDXGIDevice *ifa
return E_OUTOFMEMORY;
}
object->vtbl = &dxgi_surface_vtbl;
object->inner_unknown_vtbl = &dxgi_surface_inner_unknown_vtbl;
object->refcount = 1;
if (outer)
{
object->outer_unknown = outer;
*surface = &object->inner_unknown_vtbl;
}
else
hr = dxgi_surface_init(object, outer);
if (FAILED(hr))
{
object->outer_unknown = (IUnknown *)&object->inner_unknown_vtbl;
*surface = object;
WARN("Failed to initialize surface, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created IDXGISurface %p\n", object);
*surface = outer ? (void *)&object->inner_unknown_vtbl : object;
return S_OK;
}
......
......@@ -130,8 +130,6 @@ struct dxgi_swapchain
};
/* IDXGISurface */
extern const struct IDXGISurfaceVtbl dxgi_surface_vtbl DECLSPEC_HIDDEN;
extern const struct IUnknownVtbl dxgi_surface_inner_unknown_vtbl DECLSPEC_HIDDEN;
struct dxgi_surface
{
const struct IDXGISurfaceVtbl *vtbl;
......@@ -140,4 +138,6 @@ struct dxgi_surface
LONG refcount;
};
HRESULT dxgi_surface_init(struct dxgi_surface *surface, IUnknown *outer) DECLSPEC_HIDDEN;
#endif /* __WINE_DXGI_PRIVATE_H */
......@@ -165,7 +165,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_surface_Unmap(IDXGISurface *iface)
return E_NOTIMPL;
}
const struct IDXGISurfaceVtbl dxgi_surface_vtbl =
static const struct IDXGISurfaceVtbl dxgi_surface_vtbl =
{
/* IUnknown methods */
dxgi_surface_QueryInterface,
......@@ -184,10 +184,20 @@ const struct IDXGISurfaceVtbl dxgi_surface_vtbl =
dxgi_surface_Unmap,
};
const struct IUnknownVtbl dxgi_surface_inner_unknown_vtbl =
static const struct IUnknownVtbl dxgi_surface_inner_unknown_vtbl =
{
/* IUnknown methods */
dxgi_surface_inner_QueryInterface,
dxgi_surface_inner_AddRef,
dxgi_surface_inner_Release,
};
HRESULT dxgi_surface_init(struct dxgi_surface *surface, IUnknown *outer)
{
surface->vtbl = &dxgi_surface_vtbl;
surface->inner_unknown_vtbl = &dxgi_surface_inner_unknown_vtbl;
surface->refcount = 1;
surface->outer_unknown = outer ? outer : (IUnknown *)&surface->inner_unknown_vtbl;
return S_OK;
}
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