Commit a13a5465 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

dxgi: Implement CreateDXGIFactory1().

parent 386d2aa8
@ stdcall CreateDXGIFactory(ptr ptr)
@ stdcall CreateDXGIFactory1(ptr ptr)
@ stdcall DXGID3D10CreateDevice(ptr ptr ptr long ptr ptr)
@ stdcall DXGID3D10RegisterLayers(ptr long)
......@@ -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;
}
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;
}
TRACE("Created IDXGIFactory %p\n", object);
return dxgi_factory_create(riid, factory, TRUE);
}
hr = IDXGIFactory_QueryInterface((IDXGIFactory *)object, riid, factory);
IDXGIFactory_Release((IDXGIFactory *)object);
HRESULT WINAPI CreateDXGIFactory(REFIID riid, void **factory)
{
TRACE("riid %s, factory %p\n", debugstr_guid(riid), factory);
return hr;
return dxgi_factory_create(riid, factory, FALSE);
}
static BOOL get_layer(enum dxgi_device_layer_id id, struct dxgi_device_layer *layer)
......
......@@ -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
......
......@@ -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;
}
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