2 * Copyright 2008 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/port.h"
23 #include "dxgi_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
27 /* IUnknown methods */
29 static HRESULT STDMETHODCALLTYPE dxgi_adapter_QueryInterface(IWineDXGIAdapter *iface, REFIID riid, void **object)
31 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
33 if (IsEqualGUID(riid, &IID_IUnknown)
34 || IsEqualGUID(riid, &IID_IDXGIObject)
35 || IsEqualGUID(riid, &IID_IDXGIAdapter)
36 || IsEqualGUID(riid, &IID_IWineDXGIAdapter))
38 IUnknown_AddRef(iface);
43 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
49 static ULONG STDMETHODCALLTYPE dxgi_adapter_AddRef(IWineDXGIAdapter *iface)
51 struct dxgi_adapter *This = (struct dxgi_adapter *)iface;
52 ULONG refcount = InterlockedIncrement(&This->refcount);
54 TRACE("%p increasing refcount to %u\n", This, refcount);
59 static ULONG STDMETHODCALLTYPE dxgi_adapter_Release(IWineDXGIAdapter *iface)
61 struct dxgi_adapter *This = (struct dxgi_adapter *)iface;
62 ULONG refcount = InterlockedDecrement(&This->refcount);
64 TRACE("%p decreasing refcount to %u\n", This, refcount);
68 IDXGIOutput_Release(This->output);
69 HeapFree(GetProcessHeap(), 0, This);
75 /* IDXGIObject methods */
77 static HRESULT STDMETHODCALLTYPE dxgi_adapter_SetPrivateData(IWineDXGIAdapter *iface,
78 REFGUID guid, UINT data_size, const void *data)
80 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
85 static HRESULT STDMETHODCALLTYPE dxgi_adapter_SetPrivateDataInterface(IWineDXGIAdapter *iface,
86 REFGUID guid, const IUnknown *object)
88 FIXME("iface %p, guid %s, object %p stub!\n", iface, debugstr_guid(guid), object);
93 static HRESULT STDMETHODCALLTYPE dxgi_adapter_GetPrivateData(IWineDXGIAdapter *iface,
94 REFGUID guid, UINT *data_size, void *data)
96 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
101 static HRESULT STDMETHODCALLTYPE dxgi_adapter_GetParent(IWineDXGIAdapter *iface, REFIID riid, void **parent)
103 struct dxgi_adapter *This = (struct dxgi_adapter *)iface;
105 TRACE("iface %p, riid %s, parent %p\n", iface, debugstr_guid(riid), parent);
107 return IDXGIFactory_QueryInterface(This->parent, riid, parent);
110 /* IDXGIAdapter methods */
112 static HRESULT STDMETHODCALLTYPE dxgi_adapter_EnumOutputs(IWineDXGIAdapter *iface,
113 UINT output_idx, IDXGIOutput **output)
115 struct dxgi_adapter *This = (struct dxgi_adapter *)iface;
117 TRACE("iface %p, output_idx %u, output %p.\n", iface, output_idx, output);
122 return DXGI_ERROR_NOT_FOUND;
125 *output = This->output;
126 IDXGIOutput_AddRef(*output);
128 TRACE("Returning output %p.\n", output);
133 static HRESULT STDMETHODCALLTYPE dxgi_adapter_GetDesc(IWineDXGIAdapter *iface, DXGI_ADAPTER_DESC *desc)
135 FIXME("iface %p, desc %p stub!\n", iface, desc);
140 static HRESULT STDMETHODCALLTYPE dxgi_adapter_CheckInterfaceSupport(IWineDXGIAdapter *iface,
141 REFGUID guid, LARGE_INTEGER *umd_version)
143 FIXME("iface %p, guid %s, umd_version %p stub!\n", iface, debugstr_guid(guid), umd_version);
148 /* IWineDXGIAdapter methods */
150 static UINT STDMETHODCALLTYPE dxgi_adapter_get_ordinal(IWineDXGIAdapter *iface)
152 struct dxgi_adapter *This = (struct dxgi_adapter *)iface;
154 TRACE("iface %p, returning %u\n", iface, This->ordinal);
156 return This->ordinal;
159 static const struct IWineDXGIAdapterVtbl dxgi_adapter_vtbl =
161 /* IUnknown methods */
162 dxgi_adapter_QueryInterface,
164 dxgi_adapter_Release,
165 /* IDXGIObject methods */
166 dxgi_adapter_SetPrivateData,
167 dxgi_adapter_SetPrivateDataInterface,
168 dxgi_adapter_GetPrivateData,
169 dxgi_adapter_GetParent,
170 /* IDXGIAdapter methods */
171 dxgi_adapter_EnumOutputs,
172 dxgi_adapter_GetDesc,
173 dxgi_adapter_CheckInterfaceSupport,
174 /* IWineDXGIAdapter methods */
175 dxgi_adapter_get_ordinal,
178 HRESULT dxgi_adapter_init(struct dxgi_adapter *adapter, IDXGIFactory *parent, UINT ordinal)
180 struct dxgi_output *output;
182 adapter->vtbl = &dxgi_adapter_vtbl;
183 adapter->parent = parent;
184 adapter->refcount = 1;
185 adapter->ordinal = ordinal;
187 output = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*output));
190 return E_OUTOFMEMORY;
192 dxgi_output_init(output);
193 adapter->output = (IDXGIOutput *)output;