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 static inline struct dxgi_output
*impl_from_IDXGIOutput(IDXGIOutput
*iface
)
28 return CONTAINING_RECORD(iface
, struct dxgi_output
, IDXGIOutput_iface
);
31 /* IUnknown methods */
33 static HRESULT STDMETHODCALLTYPE
dxgi_output_QueryInterface(IDXGIOutput
*iface
, REFIID riid
, void **object
)
35 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
37 if (IsEqualGUID(riid
, &IID_IDXGIOutput
)
38 || IsEqualGUID(riid
, &IID_IDXGIObject
)
39 || IsEqualGUID(riid
, &IID_IUnknown
))
41 IUnknown_AddRef(iface
);
46 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
52 static ULONG STDMETHODCALLTYPE
dxgi_output_AddRef(IDXGIOutput
*iface
)
54 struct dxgi_output
*This
= impl_from_IDXGIOutput(iface
);
55 ULONG refcount
= InterlockedIncrement(&This
->refcount
);
57 TRACE("%p increasing refcount to %u.\n", This
, refcount
);
62 static ULONG STDMETHODCALLTYPE
dxgi_output_Release(IDXGIOutput
*iface
)
64 struct dxgi_output
*This
= impl_from_IDXGIOutput(iface
);
65 ULONG refcount
= InterlockedDecrement(&This
->refcount
);
67 TRACE("%p decreasing refcount to %u.\n", This
, refcount
);
71 HeapFree(GetProcessHeap(), 0, This
);
77 /* IDXGIObject methods */
79 static HRESULT STDMETHODCALLTYPE
dxgi_output_SetPrivateData(IDXGIOutput
*iface
,
80 REFGUID guid
, UINT data_size
, const void *data
)
82 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface
, debugstr_guid(guid
), data_size
, data
);
87 static HRESULT STDMETHODCALLTYPE
dxgi_output_SetPrivateDataInterface(IDXGIOutput
*iface
,
88 REFGUID guid
, const IUnknown
*object
)
90 FIXME("iface %p, guid %s, object %p stub!\n", iface
, debugstr_guid(guid
), object
);
95 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetPrivateData(IDXGIOutput
*iface
,
96 REFGUID guid
, UINT
*data_size
, void *data
)
98 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface
, debugstr_guid(guid
), data_size
, data
);
103 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetParent(IDXGIOutput
*iface
,
104 REFIID riid
, void **parent
)
106 struct dxgi_output
*This
= impl_from_IDXGIOutput(iface
);
108 TRACE("iface %p, riid %s, parent %p.\n", iface
, debugstr_guid(riid
), parent
);
110 return IDXGIAdapter_QueryInterface((IDXGIAdapter
*)This
->adapter
, riid
, parent
);
113 /* IDXGIOutput methods */
115 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetDesc(IDXGIOutput
*iface
, DXGI_OUTPUT_DESC
*desc
)
117 FIXME("iface %p, desc %p stub!\n", iface
, desc
);
122 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetDisplayModeList(IDXGIOutput
*iface
,
123 DXGI_FORMAT format
, UINT flags
, UINT
*mode_count
, DXGI_MODE_DESC
*desc
)
125 struct dxgi_output
*This
= impl_from_IDXGIOutput(iface
);
126 enum wined3d_format_id wined3d_format
;
127 struct wined3d
*wined3d
;
131 FIXME("iface %p, format %s, flags %#x, mode_count %p, desc %p partial stub!\n",
132 iface
, debug_dxgi_format(format
), flags
, mode_count
, desc
);
135 return DXGI_ERROR_INVALID_CALL
;
137 if (format
== DXGI_FORMAT_UNKNOWN
)
143 wined3d
= This
->adapter
->parent
->wined3d
;
144 wined3d_format
= wined3dformat_from_dxgi_format(format
);
146 EnterCriticalSection(&dxgi_cs
);
147 max_count
= wined3d_get_adapter_mode_count(wined3d
, This
->adapter
->ordinal
,
148 wined3d_format
, WINED3D_SCANLINE_ORDERING_UNKNOWN
);
152 LeaveCriticalSection(&dxgi_cs
);
153 *mode_count
= max_count
;
157 if (max_count
> *mode_count
)
159 LeaveCriticalSection(&dxgi_cs
);
160 return DXGI_ERROR_MORE_DATA
;
163 *mode_count
= max_count
;
165 for (i
= 0; i
< *mode_count
; ++i
)
167 struct wined3d_display_mode mode
;
170 hr
= wined3d_enum_adapter_modes(wined3d
, This
->adapter
->ordinal
, wined3d_format
,
171 WINED3D_SCANLINE_ORDERING_UNKNOWN
, i
, &mode
);
174 WARN("EnumAdapterModes failed, hr %#x.\n", hr
);
175 LeaveCriticalSection(&dxgi_cs
);
179 desc
[i
].Width
= mode
.width
;
180 desc
[i
].Height
= mode
.height
;
181 desc
[i
].RefreshRate
.Numerator
= mode
.refresh_rate
;
182 desc
[i
].RefreshRate
.Denominator
= 1;
183 desc
[i
].Format
= format
;
184 desc
[i
].ScanlineOrdering
= mode
.scanline_ordering
;
185 desc
[i
].Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
; /* FIXME */
187 LeaveCriticalSection(&dxgi_cs
);
192 static HRESULT STDMETHODCALLTYPE
dxgi_output_FindClosestMatchingMode(IDXGIOutput
*iface
,
193 const DXGI_MODE_DESC
*mode
, DXGI_MODE_DESC
*closest_match
, IUnknown
*device
)
195 FIXME("iface %p, mode %p, closest_match %p, device %p stub!\n", iface
, mode
, closest_match
, device
);
200 static HRESULT STDMETHODCALLTYPE
dxgi_output_WaitForVBlank(IDXGIOutput
*iface
)
202 FIXME("iface %p stub!\n", iface
);
207 static HRESULT STDMETHODCALLTYPE
dxgi_output_TakeOwnership(IDXGIOutput
*iface
, IUnknown
*device
, BOOL exclusive
)
209 FIXME("iface %p, device %p, exclusive %d stub!\n", iface
, device
, exclusive
);
214 static void STDMETHODCALLTYPE
dxgi_output_ReleaseOwnership(IDXGIOutput
*iface
)
216 FIXME("iface %p stub!\n", iface
);
219 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetGammaControlCapabilities(IDXGIOutput
*iface
,
220 DXGI_GAMMA_CONTROL_CAPABILITIES
*gamma_caps
)
222 FIXME("iface %p, gamma_caps %p stub!\n", iface
, gamma_caps
);
227 static HRESULT STDMETHODCALLTYPE
dxgi_output_SetGammaControl(IDXGIOutput
*iface
,
228 const DXGI_GAMMA_CONTROL
*gamma_control
)
230 FIXME("iface %p, gamma_control %p stub!\n", iface
, gamma_control
);
235 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetGammaControl(IDXGIOutput
*iface
, DXGI_GAMMA_CONTROL
*gamma_control
)
237 FIXME("iface %p, gamma_control %p stub!\n", iface
, gamma_control
);
242 static HRESULT STDMETHODCALLTYPE
dxgi_output_SetDisplaySurface(IDXGIOutput
*iface
, IDXGISurface
*surface
)
244 FIXME("iface %p, surface %p stub!\n", iface
, surface
);
249 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetDisplaySurfaceData(IDXGIOutput
*iface
, IDXGISurface
*surface
)
251 FIXME("iface %p, surface %p stub!\n", iface
, surface
);
256 static HRESULT STDMETHODCALLTYPE
dxgi_output_GetFrameStatistics(IDXGIOutput
*iface
, DXGI_FRAME_STATISTICS
*stats
)
258 FIXME("iface %p, stats %p stub!\n", iface
, stats
);
263 static const struct IDXGIOutputVtbl dxgi_output_vtbl
=
265 dxgi_output_QueryInterface
,
268 /* IDXGIObject methods */
269 dxgi_output_SetPrivateData
,
270 dxgi_output_SetPrivateDataInterface
,
271 dxgi_output_GetPrivateData
,
272 dxgi_output_GetParent
,
273 /* IDXGIOutput methods */
275 dxgi_output_GetDisplayModeList
,
276 dxgi_output_FindClosestMatchingMode
,
277 dxgi_output_WaitForVBlank
,
278 dxgi_output_TakeOwnership
,
279 dxgi_output_ReleaseOwnership
,
280 dxgi_output_GetGammaControlCapabilities
,
281 dxgi_output_SetGammaControl
,
282 dxgi_output_GetGammaControl
,
283 dxgi_output_SetDisplaySurface
,
284 dxgi_output_GetDisplaySurfaceData
,
285 dxgi_output_GetFrameStatistics
,
288 void dxgi_output_init(struct dxgi_output
*output
, struct dxgi_adapter
*adapter
)
290 output
->IDXGIOutput_iface
.lpVtbl
= &dxgi_output_vtbl
;
291 output
->refcount
= 1;
292 output
->adapter
= adapter
;