2 * Copyright 2009 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
20 #include "wine/port.h"
22 #include "dxgi_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
26 /* IUnknown methods */
28 static HRESULT STDMETHODCALLTYPE dxgi_output_QueryInterface(IDXGIOutput *iface, REFIID riid, void **object)
30 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
32 if (IsEqualGUID(riid, &IID_IDXGIOutput)
33 || IsEqualGUID(riid, &IID_IDXGIObject)
34 || IsEqualGUID(riid, &IID_IUnknown))
36 IUnknown_AddRef(iface);
41 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
47 static ULONG STDMETHODCALLTYPE dxgi_output_AddRef(IDXGIOutput *iface)
49 struct dxgi_output *This = (struct dxgi_output *)iface;
50 ULONG refcount = InterlockedIncrement(&This->refcount);
52 TRACE("%p increasing refcount to %u.\n", This, refcount);
57 static ULONG STDMETHODCALLTYPE dxgi_output_Release(IDXGIOutput *iface)
59 struct dxgi_output *This = (struct dxgi_output *)iface;
60 ULONG refcount = InterlockedDecrement(&This->refcount);
62 TRACE("%p decreasing refcount to %u.\n", This, refcount);
66 HeapFree(GetProcessHeap(), 0, This);
72 /* IDXGIObject methods */
74 static HRESULT STDMETHODCALLTYPE dxgi_output_SetPrivateData(IDXGIOutput *iface,
75 REFGUID guid, UINT data_size, const void *data)
77 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
82 static HRESULT STDMETHODCALLTYPE dxgi_output_SetPrivateDataInterface(IDXGIOutput *iface,
83 REFGUID guid, const IUnknown *object)
85 FIXME("iface %p, guid %s, object %p stub!\n", iface, debugstr_guid(guid), object);
90 static HRESULT STDMETHODCALLTYPE dxgi_output_GetPrivateData(IDXGIOutput *iface,
91 REFGUID guid, UINT *data_size, void *data)
93 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
98 static HRESULT STDMETHODCALLTYPE dxgi_output_GetParent(IDXGIOutput *iface,
99 REFIID riid, void **parent)
101 struct dxgi_output *This = (struct dxgi_output *)iface;
103 TRACE("iface %p, riid %s, parent %p.\n", iface, debugstr_guid(riid), parent);
105 return IDXGIAdapter_QueryInterface((IDXGIAdapter *)This->adapter, riid, parent);
108 /* IDXGIOutput methods */
110 static HRESULT STDMETHODCALLTYPE dxgi_output_GetDesc(IDXGIOutput *iface, DXGI_OUTPUT_DESC *desc)
112 FIXME("iface %p, desc %p stub!\n", iface, desc);
117 static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput *iface,
118 DXGI_FORMAT format, UINT flags, UINT *mode_count, DXGI_MODE_DESC *desc)
120 struct dxgi_output *This = (struct dxgi_output *)iface;
121 WINED3DFORMAT wined3d_format;
125 TRACE("iface %p, format %s, flags %#x, mode_count %p, desc %p.\n",
126 iface, debug_dxgi_format(format), flags, mode_count, desc);
128 wined3d = IWineDXGIFactory_get_wined3d(This->adapter->parent);
129 wined3d_format = wined3dformat_from_dxgi_format(format);
133 EnterCriticalSection(&dxgi_cs);
134 *mode_count = IWineD3D_GetAdapterModeCount(wined3d, This->adapter->ordinal, wined3d_format);
135 IWineD3D_Release(wined3d);
136 LeaveCriticalSection(&dxgi_cs);
141 EnterCriticalSection(&dxgi_cs);
142 for (i = 0; i < *mode_count; ++i)
144 WINED3DDISPLAYMODE mode;
147 hr = IWineD3D_EnumAdapterModes(wined3d, This->adapter->ordinal, wined3d_format, i, &mode);
150 WARN("EnumAdapterModes failed, hr %#x.\n", hr);
151 IWineD3D_Release(wined3d);
152 LeaveCriticalSection(&dxgi_cs);
156 desc[i].Width = mode.Width;
157 desc[i].Height = mode.Height;
158 desc[i].RefreshRate.Numerator = mode.RefreshRate;
159 desc[i].RefreshRate.Denominator = 1;
160 desc[i].Format = format;
161 desc[i].ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; /* FIXME */
162 desc[i].Scaling = DXGI_MODE_SCALING_UNSPECIFIED; /* FIXME */
164 IWineD3D_Release(wined3d);
165 LeaveCriticalSection(&dxgi_cs);
170 static HRESULT STDMETHODCALLTYPE dxgi_output_FindClosestMatchingMode(IDXGIOutput *iface,
171 const DXGI_MODE_DESC *mode, DXGI_MODE_DESC *closest_match, IUnknown *device)
173 FIXME("iface %p, mode %p, closest_match %p, device %p stub!\n", iface, mode, closest_match, device);
178 static HRESULT STDMETHODCALLTYPE dxgi_output_WaitForVBlank(IDXGIOutput *iface)
180 FIXME("iface %p stub!\n", iface);
185 static HRESULT STDMETHODCALLTYPE dxgi_output_TakeOwnership(IDXGIOutput *iface, IUnknown *device, BOOL exclusive)
187 FIXME("iface %p, device %p, exclusive %d stub!\n", iface, device, exclusive);
192 static void STDMETHODCALLTYPE dxgi_output_ReleaseOwnership(IDXGIOutput *iface)
194 FIXME("iface %p stub!\n", iface);
197 static HRESULT STDMETHODCALLTYPE dxgi_output_GetGammaControlCapabilities(IDXGIOutput *iface,
198 DXGI_GAMMA_CONTROL_CAPABILITIES *gamma_caps)
200 FIXME("iface %p, gamma_caps %p stub!\n", iface, gamma_caps);
205 static HRESULT STDMETHODCALLTYPE dxgi_output_SetGammaControl(IDXGIOutput *iface,
206 const DXGI_GAMMA_CONTROL *gamma_control)
208 FIXME("iface %p, gamma_control %p stub!\n", iface, gamma_control);
213 static HRESULT STDMETHODCALLTYPE dxgi_output_GetGammaControl(IDXGIOutput *iface, DXGI_GAMMA_CONTROL *gamma_control)
215 FIXME("iface %p, gamma_control %p stub!\n", iface, gamma_control);
220 static HRESULT STDMETHODCALLTYPE dxgi_output_SetDisplaySurface(IDXGIOutput *iface, IDXGISurface *surface)
222 FIXME("iface %p, surface %p stub!\n", iface, surface);
227 static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplaySurfaceData(IDXGIOutput *iface, IDXGISurface *surface)
229 FIXME("iface %p, surface %p stub!\n", iface, surface);
234 static HRESULT STDMETHODCALLTYPE dxgi_output_GetFrameStatistics(IDXGIOutput *iface, DXGI_FRAME_STATISTICS *stats)
236 FIXME("iface %p, stats %p stub!\n", iface, stats);
241 static const struct IDXGIOutputVtbl dxgi_output_vtbl =
243 dxgi_output_QueryInterface,
246 /* IDXGIObject methods */
247 dxgi_output_SetPrivateData,
248 dxgi_output_SetPrivateDataInterface,
249 dxgi_output_GetPrivateData,
250 dxgi_output_GetParent,
251 /* IDXGIOutput methods */
253 dxgi_output_GetDisplayModeList,
254 dxgi_output_FindClosestMatchingMode,
255 dxgi_output_WaitForVBlank,
256 dxgi_output_TakeOwnership,
257 dxgi_output_ReleaseOwnership,
258 dxgi_output_GetGammaControlCapabilities,
259 dxgi_output_SetGammaControl,
260 dxgi_output_GetGammaControl,
261 dxgi_output_SetDisplaySurface,
262 dxgi_output_GetDisplaySurfaceData,
263 dxgi_output_GetFrameStatistics,
266 void dxgi_output_init(struct dxgi_output *output, struct dxgi_adapter *adapter)
268 output->vtbl = &dxgi_output_vtbl;
269 output->refcount = 1;
270 output->adapter = adapter;