d3d8: Add a separate function for surface initialization.
[wine] / dlls / dxgi / output.c
1 /*
2  * Copyright 2009 Henri Verbeet for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "config.h"
20 #include "wine/port.h"
21
22 #include "dxgi_private.h"
23
24 WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
25
26 /* IUnknown methods */
27
28 static HRESULT STDMETHODCALLTYPE dxgi_output_QueryInterface(IDXGIOutput *iface, REFIID riid, void **object)
29 {
30     TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
31
32     if (IsEqualGUID(riid, &IID_IDXGIOutput)
33             || IsEqualGUID(riid, &IID_IDXGIObject)
34             || IsEqualGUID(riid, &IID_IUnknown))
35     {
36         IUnknown_AddRef(iface);
37         *object = iface;
38         return S_OK;
39     }
40
41     WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
42
43     *object = NULL;
44     return E_NOINTERFACE;
45 }
46
47 static ULONG STDMETHODCALLTYPE dxgi_output_AddRef(IDXGIOutput *iface)
48 {
49     struct dxgi_output *This = (struct dxgi_output *)iface;
50     ULONG refcount = InterlockedIncrement(&This->refcount);
51
52     TRACE("%p increasing refcount to %u.\n", This, refcount);
53
54     return refcount;
55 }
56
57 static ULONG STDMETHODCALLTYPE dxgi_output_Release(IDXGIOutput *iface)
58 {
59     struct dxgi_output *This = (struct dxgi_output *)iface;
60     ULONG refcount = InterlockedDecrement(&This->refcount);
61
62     TRACE("%p decreasing refcount to %u.\n", This, refcount);
63
64     if (!refcount)
65     {
66         HeapFree(GetProcessHeap(), 0, This);
67     }
68
69     return refcount;
70 }
71
72 /* IDXGIObject methods */
73
74 static HRESULT STDMETHODCALLTYPE dxgi_output_SetPrivateData(IDXGIOutput *iface,
75         REFGUID guid, UINT data_size, const void *data)
76 {
77     FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
78
79     return E_NOTIMPL;
80 }
81
82 static HRESULT STDMETHODCALLTYPE dxgi_output_SetPrivateDataInterface(IDXGIOutput *iface,
83         REFGUID guid, const IUnknown *object)
84 {
85     FIXME("iface %p, guid %s, object %p stub!\n", iface, debugstr_guid(guid), object);
86
87     return E_NOTIMPL;
88 }
89
90 static HRESULT STDMETHODCALLTYPE dxgi_output_GetPrivateData(IDXGIOutput *iface,
91         REFGUID guid, UINT *data_size, void *data)
92 {
93     FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
94
95     return E_NOTIMPL;
96 }
97
98 static HRESULT STDMETHODCALLTYPE dxgi_output_GetParent(IDXGIOutput *iface,
99         REFIID riid, void **parent)
100 {
101     FIXME("iface %p, riid %s, parent %p stub!\n", iface, debugstr_guid(riid), parent);
102
103     return E_NOTIMPL;
104 }
105
106 /* IDXGIOutput methods */
107
108 static HRESULT STDMETHODCALLTYPE dxgi_output_GetDesc(IDXGIOutput *iface, DXGI_OUTPUT_DESC *desc)
109 {
110     FIXME("iface %p, desc %p stub!\n", iface, desc);
111
112     return E_NOTIMPL;
113 }
114
115 static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput *iface,
116         DXGI_FORMAT format, UINT flags, UINT *mode_count, DXGI_MODE_DESC *desc)
117 {
118     FIXME("iface %p, format %s, flags %#x, mode_count %p, desc %p stub!\n",
119             iface, debug_dxgi_format(format), flags, mode_count, desc);
120
121     return E_NOTIMPL;
122 }
123
124 static HRESULT STDMETHODCALLTYPE dxgi_output_FindClosestMatchingMode(IDXGIOutput *iface,
125         const DXGI_MODE_DESC *mode, DXGI_MODE_DESC *closest_match, IUnknown *device)
126 {
127     FIXME("iface %p, mode %p, closest_match %p, device %p stub!\n", iface, mode, closest_match, device);
128
129     return E_NOTIMPL;
130 }
131
132 static HRESULT STDMETHODCALLTYPE dxgi_output_WaitForVBlank(IDXGIOutput *iface)
133 {
134     FIXME("iface %p stub!\n", iface);
135
136     return E_NOTIMPL;
137 }
138
139 static HRESULT STDMETHODCALLTYPE dxgi_output_TakeOwnership(IDXGIOutput *iface, IUnknown *device, BOOL exclusive)
140 {
141     FIXME("iface %p, device %p, exclusive %d stub!\n", iface, device, exclusive);
142
143     return E_NOTIMPL;
144 }
145
146 static void STDMETHODCALLTYPE dxgi_output_ReleaseOwnership(IDXGIOutput *iface)
147 {
148     FIXME("iface %p stub!\n", iface);
149 }
150
151 static HRESULT STDMETHODCALLTYPE dxgi_output_GetGammaControlCapabilities(IDXGIOutput *iface,
152         DXGI_GAMMA_CONTROL_CAPABILITIES *gamma_caps)
153 {
154     FIXME("iface %p, gamma_caps %p stub!\n", iface, gamma_caps);
155
156     return E_NOTIMPL;
157 }
158
159 static HRESULT STDMETHODCALLTYPE dxgi_output_SetGammaControl(IDXGIOutput *iface,
160         const DXGI_GAMMA_CONTROL *gamma_control)
161 {
162     FIXME("iface %p, gamma_control %p stub!\n", iface, gamma_control);
163
164     return E_NOTIMPL;
165 }
166
167 static HRESULT STDMETHODCALLTYPE dxgi_output_GetGammaControl(IDXGIOutput *iface, DXGI_GAMMA_CONTROL *gamma_control)
168 {
169     FIXME("iface %p, gamma_control %p stub!\n", iface, gamma_control);
170
171     return E_NOTIMPL;
172 }
173
174 static HRESULT STDMETHODCALLTYPE dxgi_output_SetDisplaySurface(IDXGIOutput *iface, IDXGISurface *surface)
175 {
176     FIXME("iface %p, surface %p stub!\n", iface, surface);
177
178     return E_NOTIMPL;
179 }
180
181 static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplaySurfaceData(IDXGIOutput *iface, IDXGISurface *surface)
182 {
183     FIXME("iface %p, surface %p stub!\n", iface, surface);
184
185     return E_NOTIMPL;
186 }
187
188 static HRESULT STDMETHODCALLTYPE dxgi_output_GetFrameStatistics(IDXGIOutput *iface, DXGI_FRAME_STATISTICS *stats)
189 {
190     FIXME("iface %p, stats %p stub!\n", iface, stats);
191
192     return E_NOTIMPL;
193 }
194
195 static const struct IDXGIOutputVtbl dxgi_output_vtbl =
196 {
197     dxgi_output_QueryInterface,
198     dxgi_output_AddRef,
199     dxgi_output_Release,
200     /* IDXGIObject methods */
201     dxgi_output_SetPrivateData,
202     dxgi_output_SetPrivateDataInterface,
203     dxgi_output_GetPrivateData,
204     dxgi_output_GetParent,
205     /* IDXGIOutput methods */
206     dxgi_output_GetDesc,
207     dxgi_output_GetDisplayModeList,
208     dxgi_output_FindClosestMatchingMode,
209     dxgi_output_WaitForVBlank,
210     dxgi_output_TakeOwnership,
211     dxgi_output_ReleaseOwnership,
212     dxgi_output_GetGammaControlCapabilities,
213     dxgi_output_SetGammaControl,
214     dxgi_output_GetGammaControl,
215     dxgi_output_SetDisplaySurface,
216     dxgi_output_GetDisplaySurfaceData,
217     dxgi_output_GetFrameStatistics,
218 };
219
220 void dxgi_output_init(struct dxgi_output *output)
221 {
222     output->vtbl = &dxgi_output_vtbl;
223     output->refcount = 1;
224 }