mscoree/tests: Comment out a couple of tests that crash on Windows.
[wine/testsucceed.git] / dlls / wined3d / swapchain_base.c
blob917a8b61563e57d2239d2c947c928e1d5b0a68f5
1 /*
2 *IDirect3DSwapChain9 implementation
4 *Copyright 2002-2003 Jason Edmeades
5 *Copyright 2002-2003 Raphael Junqueira
6 *Copyright 2005 Oliver Stieber
7 *Copyright 2007-2008 Stefan Dösinger for CodeWeavers
9 *This library is free software; you can redistribute it and/or
10 *modify it under the terms of the GNU Lesser General Public
11 *License as published by the Free Software Foundation; either
12 *version 2.1 of the License, or (at your option) any later version.
14 *This library is distributed in the hope that it will be useful,
15 *but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 *Lesser General Public License for more details.
19 *You should have received a copy of the GNU Lesser General Public
20 *License along with this library; if not, write to the Free Software
21 *Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "config.h"
25 #include "wined3d_private.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
29 /* IDirect3DSwapChain IUnknown parts follow: */
30 HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface, REFIID riid, void **object)
32 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
34 if (IsEqualGUID(riid, &IID_IWineD3DSwapChain)
35 || IsEqualGUID(riid, &IID_IWineD3DBase)
36 || IsEqualGUID(riid, &IID_IUnknown))
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 ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface) {
50 IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
51 DWORD refCount = InterlockedIncrement(&This->ref);
52 TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
53 return refCount;
56 ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface) {
57 IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
58 DWORD refCount;
59 refCount = InterlockedDecrement(&This->ref);
60 TRACE("(%p) : ReleaseRef to %d\n", This, refCount);
61 if (refCount == 0) {
62 IWineD3DSwapChain_Destroy(iface);
64 return refCount;
67 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetParent(IWineD3DSwapChain *iface, IUnknown ** ppParent){
68 IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
69 *ppParent = This->parent;
70 IUnknown_AddRef(*ppParent);
71 TRACE("(%p) returning %p\n", This , *ppParent);
72 return WINED3D_OK;
75 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface, IWineD3DSurface *dst_surface)
77 IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
78 POINT start;
80 TRACE("iface %p, dst_surface %p.\n", iface, dst_surface);
82 start.x = 0;
83 start.y = 0;
85 if (This->presentParms.Windowed) {
86 MapWindowPoints(This->win_handle, NULL, &start, 1);
89 IWineD3DSurface_BltFast(dst_surface, start.x, start.y, (IWineD3DSurface *)This->front_buffer, NULL, 0);
90 return WINED3D_OK;
93 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface,
94 UINT back_buffer_idx, WINED3DBACKBUFFER_TYPE type, IWineD3DSurface **back_buffer)
96 IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
98 TRACE("iface %p, back_buffer_idx %u, type %#x, back_buffer %p.\n",
99 iface, back_buffer_idx, type, back_buffer);
101 /* Return invalid if there is no backbuffer array, otherwise it will
102 * crash when ddraw is used (there swapchain->back_buffers is always NULL).
103 * We need this because this function is called from
104 * IWineD3DStateBlockImpl_InitStartupStateBlock() to get the default
105 * scissorrect dimensions. */
106 if (!swapchain->back_buffers || back_buffer_idx >= swapchain->presentParms.BackBufferCount)
108 WARN("Invalid back buffer index.\n");
109 /* Native d3d9 doesn't set NULL here, just as wine's d3d9. But set it
110 * here in wined3d to avoid problems in other libs. */
111 *back_buffer = NULL;
112 return WINED3DERR_INVALIDCALL;
115 *back_buffer = (IWineD3DSurface *)swapchain->back_buffers[back_buffer_idx];
116 if (*back_buffer) IWineD3DSurface_AddRef(*back_buffer);
118 TRACE("Returning back buffer %p.\n", *back_buffer);
120 return WINED3D_OK;
123 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, WINED3DRASTER_STATUS *pRasterStatus) {
124 static BOOL warned;
125 /* No OpenGL equivalent */
126 if (!warned)
128 FIXME("iface %p, raster_status %p stub!\n", iface, pRasterStatus);
129 warned = TRUE;
131 /* Obtaining the raster status is a widely implemented but optional feature.
132 * When this method returns OK then the application Starcraft 2 expects that
133 * the pRasterStatus->InVBlank value differs over time. To prevent Starcraft 2
134 * from running in an infinite loop at startup this method returns INVALIDCALL.
136 return WINED3DERR_INVALIDCALL;
139 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, WINED3DDISPLAYMODE*pMode) {
140 IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
141 HRESULT hr;
143 TRACE("(%p)->(%p): Calling GetAdapterDisplayMode\n", This, pMode);
144 hr = IWineD3D_GetAdapterDisplayMode(This->device->wined3d, This->device->adapter->ordinal, pMode);
146 TRACE("(%p) : returning w(%d) h(%d) rr(%d) fmt(%u,%s)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate,
147 pMode->Format, debug_d3dformat(pMode->Format));
148 return hr;
151 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDevice(IWineD3DSwapChain *iface, IWineD3DDevice **device)
153 IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
155 *device = (IWineD3DDevice *)This->device;
156 IWineD3DDevice_AddRef(*device);
158 TRACE("(%p) : returning %p\n", This, *device);
159 return WINED3D_OK;
162 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface, WINED3DPRESENT_PARAMETERS *pPresentationParameters) {
163 IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
164 TRACE("(%p)\n", This);
166 *pPresentationParameters = This->presentParms;
168 return WINED3D_OK;
171 HRESULT WINAPI IWineD3DBaseSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface, DWORD Flags, CONST WINED3DGAMMARAMP *pRamp){
173 IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
174 HDC hDC;
175 TRACE("(%p) : pRamp@%p flags(%d)\n", This, pRamp, Flags);
176 hDC = GetDC(This->device_window);
177 SetDeviceGammaRamp(hDC, (LPVOID)pRamp);
178 ReleaseDC(This->device_window, hDC);
179 return WINED3D_OK;
183 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface, WINED3DGAMMARAMP *pRamp){
185 IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
186 HDC hDC;
187 TRACE("(%p) : pRamp@%p\n", This, pRamp);
188 hDC = GetDC(This->device_window);
189 GetDeviceGammaRamp(hDC, pRamp);
190 ReleaseDC(This->device_window, hDC);
191 return WINED3D_OK;