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
19 #include "dxgi_private.h"
21 static inline struct dxgi_output
*impl_from_IDXGIOutput(IDXGIOutput
*iface
)
23 return CONTAINING_RECORD(iface
, struct dxgi_output
, IDXGIOutput_iface
);
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
= impl_from_IDXGIOutput(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
= impl_from_IDXGIOutput(iface
);
60 ULONG refcount
= InterlockedDecrement(&This
->refcount
);
62 TRACE("%p decreasing refcount to %u.\n", This
, refcount
);
66 wined3d_private_store_cleanup(&This
->private_store
);
67 HeapFree(GetProcessHeap(), 0, This
);
73 /* IDXGIObject methods */
75 static HRESULT STDMETHODCALLTYPE
dxgi_output_SetPrivateData(IDXGIOutput
*iface
,
76 REFGUID guid
, UINT data_size
, const void *data
)
78 struct dxgi_output
*output
= impl_from_IDXGIOutput(iface
);
80 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
82 return dxgi_set_private_data(&output
->private_store
, guid
, data_size
, data
);
85 static HRESULT STDMETHODCALLTYPE
dxgi_output_SetPrivateDataInterface(IDXGIOutput
*iface
,
86 REFGUID guid
, const IUnknown
*object
)
88 struct dxgi_output
*output
= impl_from_IDXGIOutput(iface
);
90 TRACE("iface %p, guid %s, object %p.\n", iface
, debugstr_guid(guid
), object
);
92 return dxgi_set_private_data_interface(&output
->private_store
, guid
, object
);
95 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetPrivateData(IDXGIOutput
*iface
,
96 REFGUID guid
, UINT
*data_size
, void *data
)
98 struct dxgi_output
*output
= impl_from_IDXGIOutput(iface
);
100 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface
, debugstr_guid(guid
), data_size
, data
);
102 return dxgi_get_private_data(&output
->private_store
, guid
, data_size
, data
);
105 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetParent(IDXGIOutput
*iface
,
106 REFIID riid
, void **parent
)
108 struct dxgi_output
*This
= impl_from_IDXGIOutput(iface
);
110 TRACE("iface %p, riid %s, parent %p.\n", iface
, debugstr_guid(riid
), parent
);
112 return IDXGIAdapter_QueryInterface((IDXGIAdapter
*)This
->adapter
, riid
, parent
);
115 /* IDXGIOutput methods */
117 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetDesc(IDXGIOutput
*iface
, DXGI_OUTPUT_DESC
*desc
)
119 struct dxgi_output
*This
= impl_from_IDXGIOutput(iface
);
120 struct wined3d
*wined3d
;
121 MONITORINFOEXW monitor_info
;
123 FIXME("iface %p, desc %p semi-stub!\n", iface
, desc
);
126 return DXGI_ERROR_INVALID_CALL
;
128 wined3d
= This
->adapter
->parent
->wined3d
;
130 EnterCriticalSection(&dxgi_cs
);
131 desc
->Monitor
= wined3d_get_adapter_monitor(wined3d
, This
->adapter
->ordinal
);
132 LeaveCriticalSection(&dxgi_cs
);
135 return DXGI_ERROR_INVALID_CALL
;
137 monitor_info
.cbSize
= sizeof(monitor_info
);
138 if (!GetMonitorInfoW(desc
->Monitor
, (MONITORINFO
*)&monitor_info
))
139 return DXGI_ERROR_INVALID_CALL
;
141 memcpy(&desc
->DeviceName
, &monitor_info
.szDevice
, sizeof(desc
->DeviceName
));
142 memcpy(&desc
->DesktopCoordinates
, &monitor_info
.rcMonitor
, sizeof(RECT
));
143 desc
->AttachedToDesktop
= TRUE
;
144 desc
->Rotation
= DXGI_MODE_ROTATION_IDENTITY
;
149 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetDisplayModeList(IDXGIOutput
*iface
,
150 DXGI_FORMAT format
, UINT flags
, UINT
*mode_count
, DXGI_MODE_DESC
*desc
)
152 struct dxgi_output
*This
= impl_from_IDXGIOutput(iface
);
153 enum wined3d_format_id wined3d_format
;
154 struct wined3d
*wined3d
;
158 FIXME("iface %p, format %s, flags %#x, mode_count %p, desc %p partial stub!\n",
159 iface
, debug_dxgi_format(format
), flags
, mode_count
, desc
);
162 return DXGI_ERROR_INVALID_CALL
;
164 if (format
== DXGI_FORMAT_UNKNOWN
)
170 wined3d
= This
->adapter
->parent
->wined3d
;
171 wined3d_format
= wined3dformat_from_dxgi_format(format
);
173 EnterCriticalSection(&dxgi_cs
);
174 max_count
= wined3d_get_adapter_mode_count(wined3d
, This
->adapter
->ordinal
,
175 wined3d_format
, WINED3D_SCANLINE_ORDERING_UNKNOWN
);
179 LeaveCriticalSection(&dxgi_cs
);
180 *mode_count
= max_count
;
184 if (max_count
> *mode_count
)
186 LeaveCriticalSection(&dxgi_cs
);
187 return DXGI_ERROR_MORE_DATA
;
190 *mode_count
= max_count
;
192 for (i
= 0; i
< *mode_count
; ++i
)
194 struct wined3d_display_mode mode
;
197 hr
= wined3d_enum_adapter_modes(wined3d
, This
->adapter
->ordinal
, wined3d_format
,
198 WINED3D_SCANLINE_ORDERING_UNKNOWN
, i
, &mode
);
201 WARN("EnumAdapterModes failed, hr %#x.\n", hr
);
202 LeaveCriticalSection(&dxgi_cs
);
206 desc
[i
].Width
= mode
.width
;
207 desc
[i
].Height
= mode
.height
;
208 desc
[i
].RefreshRate
.Numerator
= mode
.refresh_rate
;
209 desc
[i
].RefreshRate
.Denominator
= 1;
210 desc
[i
].Format
= format
;
211 desc
[i
].ScanlineOrdering
= mode
.scanline_ordering
;
212 desc
[i
].Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
; /* FIXME */
214 LeaveCriticalSection(&dxgi_cs
);
219 static HRESULT STDMETHODCALLTYPE
dxgi_output_FindClosestMatchingMode(IDXGIOutput
*iface
,
220 const DXGI_MODE_DESC
*mode
, DXGI_MODE_DESC
*closest_match
, IUnknown
*device
)
222 FIXME("iface %p, mode %p, closest_match %p, device %p stub!\n", iface
, mode
, closest_match
, device
);
227 static HRESULT STDMETHODCALLTYPE
dxgi_output_WaitForVBlank(IDXGIOutput
*iface
)
229 FIXME("iface %p stub!\n", iface
);
234 static HRESULT STDMETHODCALLTYPE
dxgi_output_TakeOwnership(IDXGIOutput
*iface
, IUnknown
*device
, BOOL exclusive
)
236 FIXME("iface %p, device %p, exclusive %d stub!\n", iface
, device
, exclusive
);
241 static void STDMETHODCALLTYPE
dxgi_output_ReleaseOwnership(IDXGIOutput
*iface
)
243 FIXME("iface %p stub!\n", iface
);
246 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetGammaControlCapabilities(IDXGIOutput
*iface
,
247 DXGI_GAMMA_CONTROL_CAPABILITIES
*gamma_caps
)
249 FIXME("iface %p, gamma_caps %p stub!\n", iface
, gamma_caps
);
254 static HRESULT STDMETHODCALLTYPE
dxgi_output_SetGammaControl(IDXGIOutput
*iface
,
255 const DXGI_GAMMA_CONTROL
*gamma_control
)
257 FIXME("iface %p, gamma_control %p stub!\n", iface
, gamma_control
);
262 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetGammaControl(IDXGIOutput
*iface
, DXGI_GAMMA_CONTROL
*gamma_control
)
264 FIXME("iface %p, gamma_control %p stub!\n", iface
, gamma_control
);
269 static HRESULT STDMETHODCALLTYPE
dxgi_output_SetDisplaySurface(IDXGIOutput
*iface
, IDXGISurface
*surface
)
271 FIXME("iface %p, surface %p stub!\n", iface
, surface
);
276 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetDisplaySurfaceData(IDXGIOutput
*iface
, IDXGISurface
*surface
)
278 FIXME("iface %p, surface %p stub!\n", iface
, surface
);
283 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetFrameStatistics(IDXGIOutput
*iface
, DXGI_FRAME_STATISTICS
*stats
)
285 FIXME("iface %p, stats %p stub!\n", iface
, stats
);
290 static const struct IDXGIOutputVtbl dxgi_output_vtbl
=
292 dxgi_output_QueryInterface
,
295 /* IDXGIObject methods */
296 dxgi_output_SetPrivateData
,
297 dxgi_output_SetPrivateDataInterface
,
298 dxgi_output_GetPrivateData
,
299 dxgi_output_GetParent
,
300 /* IDXGIOutput methods */
302 dxgi_output_GetDisplayModeList
,
303 dxgi_output_FindClosestMatchingMode
,
304 dxgi_output_WaitForVBlank
,
305 dxgi_output_TakeOwnership
,
306 dxgi_output_ReleaseOwnership
,
307 dxgi_output_GetGammaControlCapabilities
,
308 dxgi_output_SetGammaControl
,
309 dxgi_output_GetGammaControl
,
310 dxgi_output_SetDisplaySurface
,
311 dxgi_output_GetDisplaySurfaceData
,
312 dxgi_output_GetFrameStatistics
,
315 void dxgi_output_init(struct dxgi_output
*output
, struct dxgi_adapter
*adapter
)
317 output
->IDXGIOutput_iface
.lpVtbl
= &dxgi_output_vtbl
;
318 output
->refcount
= 1;
319 wined3d_private_store_init(&output
->private_store
);
320 output
->adapter
= adapter
;