1 /*
2 * Copyright 2008 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
20 #include "config.h"
21 #include "wine/port.h"
22
23 #include "dxgi_private.h"
24
25 WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
26
27 /* IUnknown methods */
28
29 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_QueryInterface(IDXGISwapChain *iface, REFIID riid, void **object)
30 {
31 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
32
33 if (IsEqualGUID(riid, &IID_IUnknown)
34 || IsEqualGUID(riid, &IID_IDXGIObject)
35 || IsEqualGUID(riid, &IID_IDXGIDeviceSubObject)
36 || IsEqualGUID(riid, &IID_IDXGISwapChain))
37 {
38 IUnknown_AddRef(iface);
39 *object = iface;
40 return S_OK;
41 }
42
43 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
44
45 *object = NULL;
46 return E_NOINTERFACE;
47 }
48
49 static ULONG STDMETHODCALLTYPE dxgi_swapchain_AddRef(IDXGISwapChain *iface)
50 {
51 struct dxgi_swapchain *This = (struct dxgi_swapchain *)iface;
52 ULONG refcount = InterlockedIncrement(&This->refcount);
53
54 TRACE("%p increasing refcount to %u\n", This, refcount);
55
56 return refcount;
57 }
58
59 static ULONG STDMETHODCALLTYPE destroy_surface(IWineD3DSurface *surface)
60 {
61 IDXGISurface *dxgi_surface;
62
63 TRACE("surface %p\n", surface);
64
65 IWineD3DSurface_GetParent(surface, (IUnknown **)&dxgi_surface);
66 IDXGISurface_Release(dxgi_surface);
67
68 return IDXGISurface_Release(dxgi_surface);
69 }
70
71 static ULONG STDMETHODCALLTYPE destroy_swapchain(IWineD3DSwapChain *swapchain)
72 {
73 TRACE("swapchain %p\n", swapchain);
74
75 return IWineD3DSwapChain_Release(swapchain);
76 }
77
78 static ULONG STDMETHODCALLTYPE dxgi_swapchain_Release(IDXGISwapChain *iface)
79 {
80 struct dxgi_swapchain *This = (struct dxgi_swapchain *)iface;
81 ULONG refcount = InterlockedDecrement(&This->refcount);
82
83 TRACE("%p decreasing refcount to %u\n", This, refcount);
84
85 if (!refcount)
86 {
87 IWineD3DDevice *wined3d_device;
88 HRESULT hr;
89
90 FIXME("Only a single swapchain is supported\n");
91
92 hr = IWineD3DSwapChain_GetDevice(This->wined3d_swapchain, &wined3d_device);
93 if (FAILED(hr))
94 {
95 ERR("Failed to get the wined3d device, hr %#x\n", hr);
96 }
97 else
98 {
99 hr = IWineD3DDevice_Uninit3D(wined3d_device, destroy_surface, destroy_swapchain);
100 IWineD3DDevice_Release(wined3d_device);
101 if (FAILED(hr))
102 {
103 ERR("Uninit3D failed, hr %#x\n", hr);
104 }
105 }
106
107 HeapFree(GetProcessHeap(), 0, This);
108 }
109
110 return refcount;
111 }
112
113 /* IDXGIObject methods */
114
115 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetPrivateData(IDXGISwapChain *iface,
116 REFGUID guid, UINT data_size, const void *data)
117 {
118 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
119
120 return E_NOTIMPL;
121 }
122
123 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetPrivateDataInterface(IDXGISwapChain *iface,
124 REFGUID guid, const IUnknown *object)
125 {
126 FIXME("iface %p, guid %s, object %p stub!\n", iface, debugstr_guid(guid), object);
127
128 return E_NOTIMPL;
129 }
130
131 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetPrivateData(IDXGISwapChain *iface,
132 REFGUID guid, UINT *data_size, void *data)
133 {
134 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
135
136 return E_NOTIMPL;
137 }
138
139 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetParent(IDXGISwapChain *iface, REFIID riid, void **parent)
140 {
141 FIXME("iface %p, riid %s, parent %p stub!\n", iface, debugstr_guid(riid), parent);
142
143 return E_NOTIMPL;
144 }
145
146 /* IDXGIDeviceSubObject methods */
147
148 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDevice(IDXGISwapChain *iface, REFIID riid, void **device)
149 {
150 FIXME("iface %p, riid %s, device %p stub!\n", iface, debugstr_guid(riid), device);
151
152 return E_NOTIMPL;
153 }
154
155 /* IDXGISwapChain methods */
156
157 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present(IDXGISwapChain *iface, UINT sync_interval, UINT flags)
158 {
159 struct dxgi_swapchain *This = (struct dxgi_swapchain *)iface;
160
161 TRACE("iface %p, sync_interval %u, flags %#x\n", iface, sync_interval, flags);
162
163 if (sync_interval) FIXME("Unimplemented sync interval %u\n", sync_interval);
164 if (flags) FIXME("Unimplemented flags %#x\n", flags);
165
166 return IWineD3DSwapChain_Present(This->wined3d_swapchain, NULL, NULL, NULL, NULL, 0);
167 }
168
169 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain *iface,
170 UINT buffer_idx, REFIID riid, void **surface)
171 {
172 struct dxgi_swapchain *This = (struct dxgi_swapchain *)iface;
173 IWineD3DSurface *backbuffer;
174 IUnknown *parent;
175 HRESULT hr;
176
177 TRACE("iface %p, buffer_idx %u, riid %s, surface %p\n",
178 iface, buffer_idx, debugstr_guid(riid), surface);
179
180 EnterCriticalSection(&dxgi_cs);
181
182 hr = IWineD3DSwapChain_GetBackBuffer(This->wined3d_swapchain, buffer_idx, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer);
183 if (FAILED(hr))
184 {
185 LeaveCriticalSection(&dxgi_cs);
186 return hr;
187 }
188
189 hr = IWineD3DSurface_GetParent(backbuffer, &parent);
190 IWineD3DSurface_Release(backbuffer);
191 LeaveCriticalSection(&dxgi_cs);
192 if (FAILED(hr))
193 {
194 return hr;
195 }
196
197 hr = IUnknown_QueryInterface(parent, riid, surface);
198 IUnknown_Release(parent);
199
200 return hr;
201 }
202
203 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetFullscreenState(IDXGISwapChain *iface,
204 BOOL fullscreen, IDXGIOutput *target)
205 {
206 FIXME("iface %p, fullscreen %u, target %p stub!\n", iface, fullscreen, target);
207
208 return E_NOTIMPL;
209 }
210
211 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFullscreenState(IDXGISwapChain *iface,
212 BOOL *fullscreen, IDXGIOutput **target)
213 {
214 FIXME("iface %p, fullscreen %p, target %p stub!\n", iface, fullscreen, target);
215
216 return E_NOTIMPL;
217 }
218
219 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDesc(IDXGISwapChain *iface, DXGI_SWAP_CHAIN_DESC *desc)
220 {
221 FIXME("iface %p, desc %p stub!\n", iface, desc);
222
223 return E_NOTIMPL;
224 }
225
226 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeBuffers(IDXGISwapChain *iface,
227 UINT buffer_count, UINT width, UINT height, DXGI_FORMAT format, UINT flags)
228 {
229 FIXME("iface %p, buffer_count %u, width %u, height %u, format %s, flags %#x stub!\n",
230 iface, buffer_count, width, height, debug_dxgi_format(format), flags);
231
232 return E_NOTIMPL;
233 }
234
235 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeTarget(IDXGISwapChain *iface,
236 const DXGI_MODE_DESC *target_mode_desc)
237 {
238 FIXME("iface %p, target_mode_desc %p stub!\n", iface, target_mode_desc);
239
240 return E_NOTIMPL;
241 }
242
243 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetContainingOutput(IDXGISwapChain *iface, IDXGIOutput **output)
244 {
245 FIXME("iface %p, output %p stub!\n", iface, output);
246
247 return E_NOTIMPL;
248 }
249
250 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFrameStatistics(IDXGISwapChain *iface, DXGI_FRAME_STATISTICS *stats)
251 {
252 FIXME("iface %p, stats %p stub!\n", iface, stats);
253
254 return E_NOTIMPL;
255 }
256
257 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetLastPresentCount(IDXGISwapChain *iface, UINT *last_present_count)
258 {
259 FIXME("iface %p, last_present_count %p stub!\n", iface, last_present_count);
260
261 return E_NOTIMPL;
262 }
263
264 const struct IDXGISwapChainVtbl dxgi_swapchain_vtbl =
265 {
266 /* IUnknown methods */
267 dxgi_swapchain_QueryInterface,
268 dxgi_swapchain_AddRef,
269 dxgi_swapchain_Release,
270 /* IDXGIObject methods */
271 dxgi_swapchain_SetPrivateData,
272 dxgi_swapchain_SetPrivateDataInterface,
273 dxgi_swapchain_GetPrivateData,
274 dxgi_swapchain_GetParent,
275 /* IDXGIDeviceSubObject methods */
276 dxgi_swapchain_GetDevice,
277 /* IDXGISwapChain methods */
278 dxgi_swapchain_Present,
279 dxgi_swapchain_GetBuffer,
280 dxgi_swapchain_SetFullscreenState,
281 dxgi_swapchain_GetFullscreenState,
282 dxgi_swapchain_GetDesc,
283 dxgi_swapchain_ResizeBuffers,
284 dxgi_swapchain_ResizeTarget,
285 dxgi_swapchain_GetContainingOutput,
286 dxgi_swapchain_GetFrameStatistics,
287 dxgi_swapchain_GetLastPresentCount,
288 };
289
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.