dxgi: Add a separate function for surface initialization.

This commit is contained in:
Henri Verbeet 2009-12-07 11:08:38 +01:00 committed by Alexandre Julliard
parent 89c96ca31e
commit 4e29ade658
3 changed files with 21 additions and 16 deletions

View File

@ -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)
hr = dxgi_surface_init(object, outer);
if (FAILED(hr))
{
object->outer_unknown = outer;
*surface = &object->inner_unknown_vtbl;
}
else
{
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;
}

View File

@ -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 */

View File

@ -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;
}