1 | /*
|
---|
2 | *IDirect3DSwapChain9 implementation
|
---|
3 | *
|
---|
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
|
---|
8 | *
|
---|
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.
|
---|
13 | *
|
---|
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.
|
---|
18 | *
|
---|
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
|
---|
22 | */
|
---|
23 |
|
---|
24 | /*
|
---|
25 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
26 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
27 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
28 | * a choice of LGPL license versions is made available with the language indicating
|
---|
29 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
30 | * of the LGPL is applied is otherwise unspecified.
|
---|
31 | */
|
---|
32 |
|
---|
33 | #include "config.h"
|
---|
34 | #include "wined3d_private.h"
|
---|
35 |
|
---|
36 | WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
---|
37 |
|
---|
38 | /* IDirect3DSwapChain IUnknown parts follow: */
|
---|
39 | HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface, REFIID riid, void **object)
|
---|
40 | {
|
---|
41 | TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
---|
42 |
|
---|
43 | if (IsEqualGUID(riid, &IID_IWineD3DSwapChain)
|
---|
44 | || IsEqualGUID(riid, &IID_IWineD3DBase)
|
---|
45 | || IsEqualGUID(riid, &IID_IUnknown))
|
---|
46 | {
|
---|
47 | IUnknown_AddRef(iface);
|
---|
48 | *object = iface;
|
---|
49 | return S_OK;
|
---|
50 | }
|
---|
51 |
|
---|
52 | WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
---|
53 |
|
---|
54 | *object = NULL;
|
---|
55 | return E_NOINTERFACE;
|
---|
56 | }
|
---|
57 |
|
---|
58 | ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface) {
|
---|
59 | IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
---|
60 | DWORD refCount = InterlockedIncrement(&This->ref);
|
---|
61 | TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
|
---|
62 | return refCount;
|
---|
63 | }
|
---|
64 |
|
---|
65 | ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface) {
|
---|
66 | IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
---|
67 | DWORD refCount;
|
---|
68 | refCount = InterlockedDecrement(&This->ref);
|
---|
69 | TRACE("(%p) : ReleaseRef to %d\n", This, refCount);
|
---|
70 | if (refCount == 0) {
|
---|
71 | IWineD3DSwapChain_Destroy(iface);
|
---|
72 | }
|
---|
73 | return refCount;
|
---|
74 | }
|
---|
75 |
|
---|
76 | HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetParent(IWineD3DSwapChain *iface, IUnknown ** ppParent){
|
---|
77 | IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
---|
78 | *ppParent = This->parent;
|
---|
79 | IUnknown_AddRef(*ppParent);
|
---|
80 | TRACE("(%p) returning %p\n", This , *ppParent);
|
---|
81 | return WINED3D_OK;
|
---|
82 | }
|
---|
83 |
|
---|
84 | HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface, IWineD3DSurface *pDestSurface) {
|
---|
85 | IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
---|
86 | POINT start;
|
---|
87 |
|
---|
88 | TRACE("(%p) : iface(%p) pDestSurface(%p)\n", This, iface, pDestSurface);
|
---|
89 |
|
---|
90 | start.x = 0;
|
---|
91 | start.y = 0;
|
---|
92 |
|
---|
93 | if (This->presentParms.Windowed) {
|
---|
94 | MapWindowPoints(This->win_handle, NULL, &start, 1);
|
---|
95 | }
|
---|
96 |
|
---|
97 | IWineD3DSurface_BltFast(pDestSurface, start.x, start.y, This->frontBuffer, NULL, 0);
|
---|
98 | return WINED3D_OK;
|
---|
99 | }
|
---|
100 |
|
---|
101 | HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface, UINT iBackBuffer, WINED3DBACKBUFFER_TYPE Type, IWineD3DSurface **ppBackBuffer) {
|
---|
102 |
|
---|
103 | IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
---|
104 |
|
---|
105 | if (iBackBuffer > This->presentParms.BackBufferCount - 1) {
|
---|
106 | TRACE("Back buffer count out of range\n");
|
---|
107 | /* Native d3d9 doesn't set NULL here, just as wine's d3d9. But set it
|
---|
108 | * here in wined3d to avoid problems in other libs
|
---|
109 | */
|
---|
110 | *ppBackBuffer = NULL;
|
---|
111 | return WINED3DERR_INVALIDCALL;
|
---|
112 | }
|
---|
113 |
|
---|
114 | /* Return invalid if there is no backbuffer array, otherwise it will crash when ddraw is
|
---|
115 | * used (there This->backBuffer is always NULL). We need this because this function has
|
---|
116 | * to be called from IWineD3DStateBlockImpl_InitStartupStateBlock to get the default
|
---|
117 | * scissorrect dimensions. */
|
---|
118 | if( !This->backBuffer ) {
|
---|
119 | *ppBackBuffer = NULL;
|
---|
120 | return WINED3DERR_INVALIDCALL;
|
---|
121 | }
|
---|
122 |
|
---|
123 | *ppBackBuffer = This->backBuffer[iBackBuffer];
|
---|
124 | TRACE("(%p) : BackBuf %d Type %d returning %p\n", This, iBackBuffer, Type, *ppBackBuffer);
|
---|
125 |
|
---|
126 | /* Note inc ref on returned surface */
|
---|
127 | if(*ppBackBuffer) IWineD3DSurface_AddRef(*ppBackBuffer);
|
---|
128 | return WINED3D_OK;
|
---|
129 |
|
---|
130 | }
|
---|
131 |
|
---|
132 | HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, WINED3DRASTER_STATUS *pRasterStatus) {
|
---|
133 | static BOOL warned;
|
---|
134 | pRasterStatus->InVBlank = TRUE;
|
---|
135 | pRasterStatus->ScanLine = 0;
|
---|
136 | /* No openGL equivalent */
|
---|
137 | if (!warned)
|
---|
138 | {
|
---|
139 | FIXME("iface %p, raster_status %p stub!\n", iface, pRasterStatus);
|
---|
140 | warned = TRUE;
|
---|
141 | }
|
---|
142 | return WINED3D_OK;
|
---|
143 | }
|
---|
144 |
|
---|
145 | HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, WINED3DDISPLAYMODE*pMode) {
|
---|
146 | IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
---|
147 | HRESULT hr;
|
---|
148 |
|
---|
149 | TRACE("(%p)->(%p): Calling GetAdapterDisplayMode\n", This, pMode);
|
---|
150 | hr = IWineD3D_GetAdapterDisplayMode(This->device->wined3d, This->device->adapter->ordinal, pMode);
|
---|
151 |
|
---|
152 | TRACE("(%p) : returning w(%d) h(%d) rr(%d) fmt(%u,%s)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate,
|
---|
153 | pMode->Format, debug_d3dformat(pMode->Format));
|
---|
154 | return hr;
|
---|
155 | }
|
---|
156 |
|
---|
157 | HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDevice(IWineD3DSwapChain *iface, IWineD3DDevice**ppDevice) {
|
---|
158 | IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
---|
159 |
|
---|
160 | *ppDevice = (IWineD3DDevice *)This->device;
|
---|
161 |
|
---|
162 | /* Note Calling this method will increase the internal reference count
|
---|
163 | on the IDirect3DDevice9 interface. */
|
---|
164 | IWineD3DDevice_AddRef(*ppDevice);
|
---|
165 | TRACE("(%p) : returning %p\n", This, *ppDevice);
|
---|
166 | return WINED3D_OK;
|
---|
167 | }
|
---|
168 |
|
---|
169 | HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface, WINED3DPRESENT_PARAMETERS *pPresentationParameters) {
|
---|
170 | IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
---|
171 | TRACE("(%p)\n", This);
|
---|
172 |
|
---|
173 | *pPresentationParameters = This->presentParms;
|
---|
174 |
|
---|
175 | return WINED3D_OK;
|
---|
176 | }
|
---|
177 |
|
---|
178 | HRESULT WINAPI IWineD3DBaseSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface, DWORD Flags, CONST WINED3DGAMMARAMP *pRamp){
|
---|
179 |
|
---|
180 | IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
---|
181 | HDC hDC;
|
---|
182 | TRACE("(%p) : pRamp@%p flags(%d)\n", This, pRamp, Flags);
|
---|
183 | hDC = GetDC(This->device_window);
|
---|
184 | SetDeviceGammaRamp(hDC, (LPVOID)pRamp);
|
---|
185 | ReleaseDC(This->device_window, hDC);
|
---|
186 | return WINED3D_OK;
|
---|
187 |
|
---|
188 | }
|
---|
189 |
|
---|
190 | HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface, WINED3DGAMMARAMP *pRamp){
|
---|
191 |
|
---|
192 | IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
---|
193 | HDC hDC;
|
---|
194 | TRACE("(%p) : pRamp@%p\n", This, pRamp);
|
---|
195 | hDC = GetDC(This->device_window);
|
---|
196 | GetDeviceGammaRamp(hDC, pRamp);
|
---|
197 | ReleaseDC(This->device_window, hDC);
|
---|
198 | return WINED3D_OK;
|
---|
199 |
|
---|
200 | }
|
---|