push 8724397e7ede0f147b6e05994a72142d44d4fecc
[wine/hacks.git] / dlls / dxgi / swapchain.c
blob8b4fe755fde0895b793d2625c0c638ef78fd3015
1 /*
2 * Copyright 2008 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 "config.h"
21 #include "wine/port.h"
23 #include "dxgi_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
27 /* IUnknown methods */
29 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_QueryInterface(IDXGISwapChain *iface, REFIID riid, void **object)
31 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
33 if (IsEqualGUID(riid, &IID_IUnknown)
34 || IsEqualGUID(riid, &IID_IDXGIObject)
35 || IsEqualGUID(riid, &IID_IDXGIDeviceSubObject)
36 || IsEqualGUID(riid, &IID_IDXGISwapChain))
38 IUnknown_AddRef(iface);
39 *object = iface;
40 return S_OK;
43 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
45 *object = NULL;
46 return E_NOINTERFACE;
49 static ULONG STDMETHODCALLTYPE dxgi_swapchain_AddRef(IDXGISwapChain *iface)
51 struct dxgi_swapchain *This = (struct dxgi_swapchain *)iface;
52 ULONG refcount = InterlockedIncrement(&This->refcount);
54 TRACE("%p increasing refcount to %u\n", This, refcount);
56 return refcount;
59 static ULONG STDMETHODCALLTYPE destroy_surface(IWineD3DSurface *surface)
61 IDXGISurface *dxgi_surface;
63 TRACE("surface %p\n", surface);
65 IWineD3DSurface_GetParent(surface, (IUnknown **)&dxgi_surface);
66 IDXGISurface_Release(dxgi_surface);
68 return IDXGISurface_Release(dxgi_surface);
71 static ULONG STDMETHODCALLTYPE destroy_swapchain(IWineD3DSwapChain *swapchain)
73 TRACE("swapchain %p\n", swapchain);
75 return IWineD3DSwapChain_Release(swapchain);
78 static ULONG STDMETHODCALLTYPE dxgi_swapchain_Release(IDXGISwapChain *iface)
80 struct dxgi_swapchain *This = (struct dxgi_swapchain *)iface;
81 ULONG refcount = InterlockedDecrement(&This->refcount);
83 TRACE("%p decreasing refcount to %u\n", This, refcount);
85 if (!refcount)
87 IWineD3DDevice *wined3d_device;
88 HRESULT hr;
90 FIXME("Only a single swapchain is supported\n");
92 hr = IWineD3DSwapChain_GetDevice(This->wined3d_swapchain, &wined3d_device);
93 if (FAILED(hr))
95 ERR("Failed to get the wined3d device, hr %#x\n", hr);
97 else
99 hr = IWineD3DDevice_Uninit3D(wined3d_device, destroy_surface, destroy_swapchain);
100 IWineD3DDevice_Release(wined3d_device);
101 if (FAILED(hr))
103 ERR("Uninit3D failed, hr %#x\n", hr);
107 HeapFree(GetProcessHeap(), 0, This);
110 return refcount;
113 /* IDXGIObject methods */
115 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetPrivateData(IDXGISwapChain *iface,
116 REFGUID guid, UINT data_size, const void *data)
118 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
120 return E_NOTIMPL;
123 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetPrivateDataInterface(IDXGISwapChain *iface,
124 REFGUID guid, const IUnknown *object)
126 FIXME("iface %p, guid %s, object %p stub!\n", iface, debugstr_guid(guid), object);
128 return E_NOTIMPL;
131 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetPrivateData(IDXGISwapChain *iface,
132 REFGUID guid, UINT *data_size, void *data)
134 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
136 return E_NOTIMPL;
139 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetParent(IDXGISwapChain *iface, REFIID riid, void **parent)
141 FIXME("iface %p, riid %s, parent %p stub!\n", iface, debugstr_guid(riid), parent);
143 return E_NOTIMPL;
146 /* IDXGIDeviceSubObject methods */
148 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDevice(IDXGISwapChain *iface, REFIID riid, void **device)
150 FIXME("iface %p, riid %s, device %p stub!\n", iface, debugstr_guid(riid), device);
152 return E_NOTIMPL;
155 /* IDXGISwapChain methods */
157 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present(IDXGISwapChain *iface, UINT sync_interval, UINT flags)
159 struct dxgi_swapchain *This = (struct dxgi_swapchain *)iface;
161 TRACE("iface %p, sync_interval %u, flags %#x\n", iface, sync_interval, flags);
163 if (sync_interval) FIXME("Unimplemented sync interval %u\n", sync_interval);
164 if (flags) FIXME("Unimplemented flags %#x\n", flags);
166 return IWineD3DSwapChain_Present(This->wined3d_swapchain, NULL, NULL, NULL, NULL, 0);
169 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain *iface,
170 UINT buffer_idx, REFIID riid, void **surface)
172 struct dxgi_swapchain *This = (struct dxgi_swapchain *)iface;
173 IWineD3DSurface *backbuffer;
174 IUnknown *parent;
175 HRESULT hr;
177 TRACE("iface %p, buffer_idx %u, riid %s, surface %p\n",
178 iface, buffer_idx, debugstr_guid(riid), surface);
180 EnterCriticalSection(&dxgi_cs);
182 hr = IWineD3DSwapChain_GetBackBuffer(This->wined3d_swapchain, buffer_idx, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer);
183 if (FAILED(hr))
185 LeaveCriticalSection(&dxgi_cs);
186 return hr;
189 hr = IWineD3DSurface_GetParent(backbuffer, &parent);
190 IWineD3DSurface_Release(backbuffer);
191 LeaveCriticalSection(&dxgi_cs);
192 if (FAILED(hr))
194 return hr;
197 hr = IUnknown_QueryInterface(parent, riid, surface);
198 IUnknown_Release(parent);
200 return hr;
203 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetFullscreenState(IDXGISwapChain *iface,
204 BOOL fullscreen, IDXGIOutput *target)
206 FIXME("iface %p, fullscreen %u, target %p stub!\n", iface, fullscreen, target);
208 return E_NOTIMPL;
211 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFullscreenState(IDXGISwapChain *iface,
212 BOOL *fullscreen, IDXGIOutput **target)
214 FIXME("iface %p, fullscreen %p, target %p stub!\n", iface, fullscreen, target);
216 return E_NOTIMPL;
219 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDesc(IDXGISwapChain *iface, DXGI_SWAP_CHAIN_DESC *desc)
221 FIXME("iface %p, desc %p stub!\n", iface, desc);
223 return E_NOTIMPL;
226 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeBuffers(IDXGISwapChain *iface,
227 UINT buffer_count, UINT width, UINT height, DXGI_FORMAT format, UINT flags)
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);
232 return E_NOTIMPL;
235 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeTarget(IDXGISwapChain *iface,
236 const DXGI_MODE_DESC *target_mode_desc)
238 FIXME("iface %p, target_mode_desc %p stub!\n", iface, target_mode_desc);
240 return E_NOTIMPL;
243 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetContainingOutput(IDXGISwapChain *iface, IDXGIOutput **output)
245 FIXME("iface %p, output %p stub!\n", iface, output);
247 return E_NOTIMPL;
250 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFrameStatistics(IDXGISwapChain *iface, DXGI_FRAME_STATISTICS *stats)
252 FIXME("iface %p, stats %p stub!\n", iface, stats);
254 return E_NOTIMPL;
257 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetLastPresentCount(IDXGISwapChain *iface, UINT *last_present_count)
259 FIXME("iface %p, last_present_count %p stub!\n", iface, last_present_count);
261 return E_NOTIMPL;
264 const struct IDXGISwapChainVtbl dxgi_swapchain_vtbl =
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,