dxgi: Implement CreateDXGIFactory1().

This commit is contained in:
Henri Verbeet 2014-02-11 11:42:20 +01:00 committed by Alexandre Julliard
parent 386d2aa8b7
commit a13a546573
4 changed files with 39 additions and 28 deletions

View File

@ -1,3 +1,4 @@
@ stdcall CreateDXGIFactory(ptr ptr)
@ stdcall CreateDXGIFactory1(ptr ptr)
@ stdcall DXGID3D10CreateDevice(ptr ptr ptr long ptr ptr)
@ stdcall DXGID3D10RegisterLayers(ptr long)

View File

@ -66,36 +66,18 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
return TRUE;
}
HRESULT WINAPI CreateDXGIFactory(REFIID riid, void **factory)
HRESULT WINAPI CreateDXGIFactory1(REFIID riid, void **factory)
{
struct dxgi_factory *object;
HRESULT hr;
TRACE("riid %s, factory %p\n", debugstr_guid(riid), factory);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
ERR("Failed to allocate DXGI factory object memory\n");
*factory = NULL;
return E_OUTOFMEMORY;
}
return dxgi_factory_create(riid, factory, TRUE);
}
hr = dxgi_factory_init(object);
if (FAILED(hr))
{
WARN("Failed to initialize swapchain, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
*factory = NULL;
return hr;
}
HRESULT WINAPI CreateDXGIFactory(REFIID riid, void **factory)
{
TRACE("riid %s, factory %p\n", debugstr_guid(riid), factory);
TRACE("Created IDXGIFactory %p\n", object);
hr = IDXGIFactory_QueryInterface((IDXGIFactory *)object, riid, factory);
IDXGIFactory_Release((IDXGIFactory *)object);
return hr;
return dxgi_factory_create(riid, factory, FALSE);
}
static BOOL get_layer(enum dxgi_device_layer_id id, struct dxgi_device_layer *layer)

View File

@ -83,9 +83,10 @@ struct dxgi_factory
struct wined3d *wined3d;
UINT adapter_count;
IWineDXGIAdapter **adapters;
BOOL extended;
};
HRESULT dxgi_factory_init(struct dxgi_factory *factory) DECLSPEC_HIDDEN;
HRESULT dxgi_factory_create(REFIID riid, void **factory, BOOL extended) DECLSPEC_HIDDEN;
/* IDXGIDevice */
struct dxgi_device

View File

@ -33,12 +33,14 @@ static inline struct dxgi_factory *impl_from_IWineDXGIFactory(IWineDXGIFactory *
static HRESULT STDMETHODCALLTYPE dxgi_factory_QueryInterface(IWineDXGIFactory *iface, REFIID riid, void **object)
{
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDXGIObject)
|| IsEqualGUID(riid, &IID_IDXGIFactory)
|| IsEqualGUID(riid, &IID_IDXGIFactory1)
|| (factory->extended && IsEqualGUID(riid, &IID_IDXGIFactory1))
|| IsEqualGUID(riid, &IID_IWineDXGIFactory))
{
IUnknown_AddRef(iface);
@ -318,7 +320,7 @@ static const struct IWineDXGIFactoryVtbl dxgi_factory_vtbl =
dxgi_factory_get_wined3d,
};
HRESULT dxgi_factory_init(struct dxgi_factory *factory)
static HRESULT dxgi_factory_init(struct dxgi_factory *factory, BOOL extended)
{
HRESULT hr;
UINT i;
@ -379,6 +381,8 @@ HRESULT dxgi_factory_init(struct dxgi_factory *factory)
factory->adapters[i] = &adapter->IWineDXGIAdapter_iface;
}
factory->extended = extended;
return S_OK;
fail:
@ -388,3 +392,26 @@ fail:
LeaveCriticalSection(&dxgi_cs);
return hr;
}
HRESULT dxgi_factory_create(REFIID riid, void **factory, BOOL extended)
{
struct dxgi_factory *object;
HRESULT hr;
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = dxgi_factory_init(object, extended)))
{
WARN("Failed to initialize factory, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created factory %p.\n", object);
hr = IWineDXGIFactory_QueryInterface(&object->IWineDXGIFactory_iface, riid, factory);
IWineDXGIFactory_Release(&object->IWineDXGIFactory_iface);
return hr;
}