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 CreateDXGIFactory(ptr ptr)
@ stdcall CreateDXGIFactory1(ptr ptr)
@ stdcall DXGID3D10CreateDevice(ptr ptr ptr long ptr ptr) @ stdcall DXGID3D10CreateDevice(ptr ptr ptr long ptr ptr)
@ stdcall DXGID3D10RegisterLayers(ptr long) @ stdcall DXGID3D10RegisterLayers(ptr long)

View File

@ -66,36 +66,18 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
return TRUE; 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); TRACE("riid %s, factory %p\n", debugstr_guid(riid), factory);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); return dxgi_factory_create(riid, factory, TRUE);
if (!object) }
{
ERR("Failed to allocate DXGI factory object memory\n");
*factory = NULL;
return E_OUTOFMEMORY;
}
hr = dxgi_factory_init(object); HRESULT WINAPI CreateDXGIFactory(REFIID riid, void **factory)
if (FAILED(hr)) {
{ TRACE("riid %s, factory %p\n", debugstr_guid(riid), factory);
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, FALSE);
hr = IDXGIFactory_QueryInterface((IDXGIFactory *)object, riid, factory);
IDXGIFactory_Release((IDXGIFactory *)object);
return hr;
} }
static BOOL get_layer(enum dxgi_device_layer_id id, struct dxgi_device_layer *layer) 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; struct wined3d *wined3d;
UINT adapter_count; UINT adapter_count;
IWineDXGIAdapter **adapters; 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 */ /* IDXGIDevice */
struct dxgi_device 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) 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); TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
if (IsEqualGUID(riid, &IID_IUnknown) if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDXGIObject) || IsEqualGUID(riid, &IID_IDXGIObject)
|| IsEqualGUID(riid, &IID_IDXGIFactory) || IsEqualGUID(riid, &IID_IDXGIFactory)
|| IsEqualGUID(riid, &IID_IDXGIFactory1) || (factory->extended && IsEqualGUID(riid, &IID_IDXGIFactory1))
|| IsEqualGUID(riid, &IID_IWineDXGIFactory)) || IsEqualGUID(riid, &IID_IWineDXGIFactory))
{ {
IUnknown_AddRef(iface); IUnknown_AddRef(iface);
@ -318,7 +320,7 @@ static const struct IWineDXGIFactoryVtbl dxgi_factory_vtbl =
dxgi_factory_get_wined3d, 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; HRESULT hr;
UINT i; UINT i;
@ -379,6 +381,8 @@ HRESULT dxgi_factory_init(struct dxgi_factory *factory)
factory->adapters[i] = &adapter->IWineDXGIAdapter_iface; factory->adapters[i] = &adapter->IWineDXGIAdapter_iface;
} }
factory->extended = extended;
return S_OK; return S_OK;
fail: fail:
@ -388,3 +392,26 @@ fail:
LeaveCriticalSection(&dxgi_cs); LeaveCriticalSection(&dxgi_cs);
return hr; 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;
}