kernel32: GlobalMemoryStatusEx: return the size of physical memory + swapsize in...
[wine] / dlls / wined3d / swapchain.c
1 /*
2  *IDirect3DSwapChain9 implementation
3  *
4  *Copyright 2002-2003 Jason Edmeades
5  *Copyright 2002-2003 Raphael Junqueira
6  *Copyright 2005 Oliver Stieber
7  *
8  *This library is free software; you can redistribute it and/or
9  *modify it under the terms of the GNU Lesser General Public
10  *License as published by the Free Software Foundation; either
11  *version 2.1 of the License, or (at your option) any later version.
12  *
13  *This library is distributed in the hope that it will be useful,
14  *but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  *Lesser General Public License for more details.
17  *
18  *You should have received a copy of the GNU Lesser General Public
19  *License along with this library; if not, write to the Free Software
20  *Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22
23 #include "config.h"
24 #include "wined3d_private.h"
25
26
27 /* TODO: move to shared header (or context manager )*/
28 /* x11drv GDI escapes */
29 #define X11DRV_ESCAPE 6789
30 enum x11drv_escape_codes
31 {
32     X11DRV_GET_DISPLAY,   /* get X11 display for a DC */
33     X11DRV_GET_DRAWABLE,  /* get current drawable for a DC */
34     X11DRV_GET_FONT,      /* get current X font for a DC */
35 };
36
37 /* retrieve the X display to use on a given DC */
38 inline static Display *get_display( HDC hdc )
39 {
40     Display *display;
41     enum x11drv_escape_codes escape = X11DRV_GET_DISPLAY;
42
43     if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape,
44                     sizeof(display), (LPSTR)&display )) display = NULL;
45     return display;
46 }
47
48 /*TODO: some of the additional parameters may be required to
49     set the gamma ramp (for some weird reason microsoft have left swap gammaramp in device
50     but it operates on a swapchain, it may be a good idea to move it to IWineD3DSwapChain for IWineD3D)*/
51
52
53 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
54 WINE_DECLARE_DEBUG_CHANNEL(fps);
55
56
57 /* IDirect3DSwapChain IUnknown parts follow: */
58 static ULONG WINAPI IWineD3DSwapChainImpl_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 static HRESULT WINAPI IWineD3DSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface, REFIID riid, LPVOID *ppobj)
66 {
67     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
68     TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppobj);
69     if (IsEqualGUID(riid, &IID_IUnknown)
70         || IsEqualGUID(riid, &IID_IWineD3DBase)
71         || IsEqualGUID(riid, &IID_IWineD3DSwapChain)){
72         IWineD3DSwapChainImpl_AddRef(iface);
73         if(ppobj == NULL){
74             ERR("Query interface called but now data allocated\n");
75             return E_NOINTERFACE;
76         }
77         *ppobj = This;
78         return WINED3D_OK;
79     }
80     *ppobj = NULL;
81     return E_NOINTERFACE;
82 }
83
84
85 static ULONG WINAPI IWineD3DSwapChainImpl_Release(IWineD3DSwapChain *iface) {
86     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
87     DWORD refCount;
88     refCount = InterlockedDecrement(&This->ref);
89     TRACE("(%p) : ReleaseRef to %d\n", This, refCount);
90     if (refCount == 0) {
91         IWineD3DSwapChain_Destroy(iface, D3DCB_DefaultDestroySurface);
92     }
93     return refCount;
94 }
95
96 static HRESULT WINAPI IWineD3DSwapChainImpl_GetParent(IWineD3DSwapChain *iface, IUnknown ** ppParent){
97     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
98     *ppParent = This->parent;
99     IUnknown_AddRef(*ppParent);
100     TRACE("(%p) returning %p\n", This , *ppParent);
101     return WINED3D_OK;
102 }
103
104 /*IWineD3DSwapChain parts follow: */
105 static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroyRenderTarget) {
106     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
107     WINED3DDISPLAYMODE mode;
108
109     /* release the ref to the front and back buffer parents */
110     if(This->frontBuffer) {
111         IWineD3DSurface_SetContainer(This->frontBuffer, 0);
112         if(D3DCB_DestroyRenderTarget(This->frontBuffer) > 0) {
113             FIXME("(%p) Something's still holding the front buffer\n",This);
114         }
115     }
116
117     if(This->backBuffer) {
118         int i;
119         for(i = 0; i < This->presentParms.BackBufferCount; i++) {
120             IWineD3DSurface_SetContainer(This->backBuffer[i], 0);
121             if(D3DCB_DestroyRenderTarget(This->backBuffer[i]) > 0) {
122                 FIXME("(%p) Something's still holding the back buffer\n",This);
123             }
124         }
125     }
126
127     /* Restore the screen resolution if we rendered in fullscreen
128      * This will restore the screen resolution to what it was before creating the swapchain. In case of d3d8 and d3d9
129      * this will be the original desktop resolution. In case of d3d7 this will be a NOP because ddraw sets the resolution
130      * before starting up Direct3D, thus orig_width and orig_height will be equal to the modes in the presentation params
131      */
132     if(This->presentParms.Windowed == FALSE) {
133         mode.Width = This->orig_width;
134         mode.Height = This->orig_height;
135         mode.RefreshRate = 0;
136         mode.Format = This->orig_fmt;
137         IWineD3DDevice_SetDisplayMode((IWineD3DDevice *) This->wineD3DDevice, 0, &mode);
138     }
139     DestroyContext(This->wineD3DDevice, This->context);
140
141     HeapFree(GetProcessHeap(), 0, This);
142 }
143
144 static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags) {
145     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
146
147     ENTER_GL();
148
149     /* Render the cursor onto the back buffer, using our nifty directdraw blitting code :-) */
150     if(This->wineD3DDevice->bCursorVisible && This->wineD3DDevice->cursorTexture) {
151         IWineD3DSurfaceImpl cursor;
152         RECT destRect = {This->wineD3DDevice->xScreenSpace - This->wineD3DDevice->xHotSpot,
153                          This->wineD3DDevice->yScreenSpace - This->wineD3DDevice->yHotSpot,
154                          This->wineD3DDevice->xScreenSpace + This->wineD3DDevice->cursorWidth - This->wineD3DDevice->xHotSpot,
155                          This->wineD3DDevice->yScreenSpace + This->wineD3DDevice->cursorHeight - This->wineD3DDevice->yHotSpot};
156         TRACE("Rendering the cursor. Creating fake surface at %p\n", &cursor);
157         /* Build a fake surface to call the Blitting code. It is not possible to use the interface passed by
158          * the application because we are only supposed to copy the information out. Using a fake surface
159          * allows to use the Blitting engine and avoid copying the whole texture -> render target blitting code.
160          */
161         memset(&cursor, 0, sizeof(cursor));
162         cursor.lpVtbl = &IWineD3DSurface_Vtbl;
163         cursor.resource.ref = 1;
164         cursor.resource.wineD3DDevice = This->wineD3DDevice;
165         cursor.resource.pool = WINED3DPOOL_SCRATCH;
166         cursor.resource.format = WINED3DFMT_A8R8G8B8;
167         cursor.resource.resourceType = WINED3DRTYPE_SURFACE;
168         cursor.glDescription.textureName = This->wineD3DDevice->cursorTexture;
169         cursor.glDescription.target = GL_TEXTURE_2D;
170         cursor.glDescription.level = 0;
171         cursor.currentDesc.Width = This->wineD3DDevice->cursorWidth;
172         cursor.currentDesc.Height = This->wineD3DDevice->cursorHeight;
173         cursor.glRect.left = 0;
174         cursor.glRect.top = 0;
175         cursor.glRect.right = cursor.currentDesc.Width;
176         cursor.glRect.bottom = cursor.currentDesc.Height;
177         /* The cursor must have pow2 sizes */
178         cursor.pow2Width = cursor.currentDesc.Width;
179         cursor.pow2Height = cursor.currentDesc.Height;
180         /* The surface is in the texture */
181         cursor.Flags |= SFLAG_INTEXTURE;
182         /* DDBLT_KEYSRC will cause BltOverride to enable the alpha test with GL_NOTEQUAL, 0.0,
183          * which is exactly what we want :-)
184          */
185         if (This->presentParms.Windowed) {
186             MapWindowPoints(NULL, This->win_handle, (LPPOINT)&destRect, 2);
187         }
188         IWineD3DSurface_Blt(This->backBuffer[0], &destRect, (IWineD3DSurface *) &cursor, NULL, DDBLT_KEYSRC, NULL);
189     }
190
191     if (pSourceRect || pDestRect) FIXME("Unhandled present options %p/%p\n", pSourceRect, pDestRect);
192     /* TODO: If only source rect or dest rect are supplied then clip the window to match */
193     TRACE("preseting display %p, drawable %ld\n", This->context->display, This->context->drawable);
194
195     /* Don't call checkGLcall, as glGetError is not applicable here */
196     if (hDestWindowOverride && This->win_handle != hDestWindowOverride) {
197         HDC hDc;
198         WINED3DLOCKED_RECT r;
199         Display *display;
200         BYTE *mem;
201
202         TRACE("Performing dest override of swapchain %p from window %p to %p\n", This, This->win_handle, hDestWindowOverride);
203         if(This->context == This->wineD3DDevice->contexts[0]) {
204             /* The primary context 'owns' all the opengl resources. Destroying and recreating that context would require downloading
205              * all opengl resources, deleting the gl resources, destroying all other contexts, then recreating all other contexts
206              * and reload the resources
207              */
208             ERR("Cannot change the destination window of the owner of the primary context\n");
209         } else {
210             hDc                          = GetDC(hDestWindowOverride);
211             This->win_handle             = hDestWindowOverride;
212             This->win                    = (Window)GetPropA( hDestWindowOverride, "__wine_x11_whole_window" );
213             display                      = get_display(hDc);
214             ReleaseDC(hDestWindowOverride, hDc);
215
216             /* The old back buffer has to be copied over to the new back buffer. A lockrect - switchcontext - unlockrect
217              * would suffice in theory, but it is rather nasty and may cause troubles with future changes of the locking code
218              * So lock read only, copy the surface out, then lock with the discard flag and write back
219              */
220             IWineD3DSurface_LockRect(This->backBuffer[0], &r, NULL, WINED3DLOCK_READONLY);
221             mem = HeapAlloc(GetProcessHeap(), 0, r.Pitch * ((IWineD3DSurfaceImpl *) This->backBuffer[0])->currentDesc.Height);
222             memcpy(mem, r.pBits, r.Pitch * ((IWineD3DSurfaceImpl *) This->backBuffer[0])->currentDesc.Height);
223             IWineD3DSurface_UnlockRect(This->backBuffer[0]);
224
225             DestroyContext(This->wineD3DDevice, This->context);
226             This->context = CreateContext(This->wineD3DDevice, (IWineD3DSurfaceImpl *) This->frontBuffer, display, This->win);
227
228             IWineD3DSurface_LockRect(This->backBuffer[0], &r, NULL, WINED3DLOCK_DISCARD);
229             memcpy(r.pBits, mem, r.Pitch * ((IWineD3DSurfaceImpl *) This->backBuffer[0])->currentDesc.Height);
230             HeapFree(GetProcessHeap(), 0, mem);
231             IWineD3DSurface_UnlockRect(This->backBuffer[0]);
232         }
233     }
234
235     glXSwapBuffers(This->context->display, This->context->drawable); /* TODO: cycle through the swapchain buffers */
236
237     TRACE("glXSwapBuffers called, Starting new frame\n");
238     /* FPS support */
239     if (TRACE_ON(fps))
240     {
241         DWORD time = GetTickCount();
242         This->frames++;
243         /* every 1.5 seconds */
244         if (time - This->prev_time > 1500) {
245             TRACE_(fps)("%p @ approx %.2ffps\n", This, 1000.0*This->frames/(time - This->prev_time));
246             This->prev_time = time;
247             This->frames = 0;
248         }
249     }
250
251 #if defined(FRAME_DEBUGGING)
252 {
253     if (GetFileAttributesA("C:\\D3DTRACE") != INVALID_FILE_ATTRIBUTES) {
254         if (!isOn) {
255             isOn = TRUE;
256             FIXME("Enabling D3D Trace\n");
257             __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 1);
258 #if defined(SHOW_FRAME_MAKEUP)
259             FIXME("Singe Frame snapshots Starting\n");
260             isDumpingFrames = TRUE;
261             glClear(GL_COLOR_BUFFER_BIT);
262 #endif
263
264 #if defined(SINGLE_FRAME_DEBUGGING)
265         } else {
266 #if defined(SHOW_FRAME_MAKEUP)
267             FIXME("Singe Frame snapshots Finishing\n");
268             isDumpingFrames = FALSE;
269 #endif
270             FIXME("Singe Frame trace complete\n");
271             DeleteFileA("C:\\D3DTRACE");
272             __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 0);
273 #endif
274         }
275     } else {
276         if (isOn) {
277             isOn = FALSE;
278 #if defined(SHOW_FRAME_MAKEUP)
279             FIXME("Single Frame snapshots Finishing\n");
280             isDumpingFrames = FALSE;
281 #endif
282             FIXME("Disabling D3D Trace\n");
283             __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 0);
284         }
285     }
286 }
287 #endif
288
289     LEAVE_GL();
290     /* Although this is not strictly required, a simple demo showed this does occur
291        on (at least non-debug) d3d                                                  */
292     if (This->presentParms.SwapEffect == WINED3DSWAPEFFECT_DISCARD) {
293
294         TRACE("Clearing\n");
295
296         IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL, WINED3DCLEAR_STENCIL|WINED3DCLEAR_ZBUFFER|WINED3DCLEAR_TARGET, 0x00, 1.0, 0);
297
298     } else {
299         TRACE("Clearing z/stencil buffer\n");
300
301         IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL, WINED3DCLEAR_STENCIL|WINED3DCLEAR_ZBUFFER, 0x00, 1.0, 0);
302     }
303
304     if(((IWineD3DSurfaceImpl *) This->frontBuffer)->Flags   & SFLAG_INSYSMEM ||
305        ((IWineD3DSurfaceImpl *) This->backBuffer[0])->Flags & SFLAG_INSYSMEM ) {
306         /* Both memory copies of the surfaces are ok, flip them around too instead of dirtifying */
307         IWineD3DSurfaceImpl *front = (IWineD3DSurfaceImpl *) This->frontBuffer;
308         IWineD3DSurfaceImpl *back = (IWineD3DSurfaceImpl *) This->backBuffer[0];
309         BOOL frontuptodate = front->Flags & SFLAG_INSYSMEM;
310         BOOL backuptodate = back->Flags & SFLAG_INSYSMEM;
311
312         /* Flip the DC */
313         {
314             HDC tmp;
315             tmp = front->hDC;
316             front->hDC = back->hDC;
317             back->hDC = tmp;
318         }
319
320         /* Flip the DIBsection */
321         {
322             HBITMAP tmp;
323             BOOL hasDib = front->Flags & SFLAG_DIBSECTION;
324             tmp = front->dib.DIBsection;
325             front->dib.DIBsection = back->dib.DIBsection;
326             back->dib.DIBsection = tmp;
327
328             if(back->Flags & SFLAG_DIBSECTION) front->Flags |= SFLAG_DIBSECTION;
329             else front->Flags &= ~SFLAG_DIBSECTION;
330             if(hasDib) back->Flags |= SFLAG_DIBSECTION;
331             else back->Flags &= ~SFLAG_DIBSECTION;
332         }
333
334         /* Flip the surface data */
335         {
336             void* tmp;
337
338             tmp = front->dib.bitmap_data;
339             front->dib.bitmap_data = back->dib.bitmap_data;
340             back->dib.bitmap_data = tmp;
341
342             tmp = front->resource.allocatedMemory;
343             front->resource.allocatedMemory = back->resource.allocatedMemory;
344             back->resource.allocatedMemory = tmp;
345         }
346
347         /* client_memory should not be different, but just in case */
348         {
349             BOOL tmp;
350             tmp = front->dib.client_memory;
351             front->dib.client_memory = back->dib.client_memory;
352             back->dib.client_memory = tmp;
353         }
354         if(frontuptodate) back->Flags |= SFLAG_INSYSMEM;
355         else back->Flags &= ~SFLAG_INSYSMEM;
356         if(backuptodate) front->Flags |= SFLAG_INSYSMEM;
357         else front->Flags &= ~SFLAG_INSYSMEM;
358     }
359
360     TRACE("returning\n");
361     return WINED3D_OK;
362 }
363
364 static HRESULT WINAPI IWineD3DSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface, IWineD3DSurface *pDestSurface) {
365     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
366     POINT start;
367
368     TRACE("(%p) : iface(%p) pDestSurface(%p)\n", This, iface, pDestSurface);
369
370     start.x = 0;
371     start.y = 0;
372
373     if (This->presentParms.Windowed) {
374         MapWindowPoints(This->win_handle, NULL, &start, 1);
375     }
376
377     IWineD3DSurface_BltFast(pDestSurface, start.x, start.y, This->frontBuffer, NULL, 0);
378     return WINED3D_OK;
379 }
380
381 static HRESULT WINAPI IWineD3DSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface, UINT iBackBuffer, WINED3DBACKBUFFER_TYPE Type, IWineD3DSurface **ppBackBuffer) {
382
383     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
384
385     if (iBackBuffer > This->presentParms.BackBufferCount - 1) {
386         TRACE("Back buffer count out of range\n");
387         /* Native d3d9 doesn't set NULL here, just as wine's d3d9. But set it here
388          * in wined3d to avoid problems in other libs
389          */
390         *ppBackBuffer = NULL;
391         return WINED3DERR_INVALIDCALL;
392     }
393
394     *ppBackBuffer = This->backBuffer[iBackBuffer];
395     TRACE("(%p) : BackBuf %d Type %d  returning %p\n", This, iBackBuffer, Type, *ppBackBuffer);
396
397     /* Note inc ref on returned surface */
398     if(*ppBackBuffer) IWineD3DSurface_AddRef(*ppBackBuffer);
399     return WINED3D_OK;
400
401 }
402
403 static HRESULT WINAPI IWineD3DSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, WINED3DRASTER_STATUS *pRasterStatus) {
404     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
405     static BOOL showFixmes = TRUE;
406     pRasterStatus->InVBlank = TRUE;
407     pRasterStatus->ScanLine = 0;
408     /* No openGL equivalent */
409     if(showFixmes) {
410         FIXME("(%p) : stub (once)\n", This);
411         showFixmes = FALSE;
412     }
413     return WINED3D_OK;
414 }
415
416 static HRESULT WINAPI IWineD3DSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, WINED3DDISPLAYMODE*pMode) {
417     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
418     HDC                 hdc;
419     int                 bpp = 0;
420
421     pMode->Width        = GetSystemMetrics(SM_CXSCREEN);
422     pMode->Height       = GetSystemMetrics(SM_CYSCREEN);
423     pMode->RefreshRate  = 85; /* FIXME: How to identify? */
424
425     hdc = GetDC(0);
426     bpp = GetDeviceCaps(hdc, BITSPIXEL);
427     ReleaseDC(0, hdc);
428
429     switch (bpp) {
430     case  8: pMode->Format       = WINED3DFMT_R8G8B8; break;
431     case 16: pMode->Format       = WINED3DFMT_R5G6B5; break;
432     case 24: /*pMode->Format       = WINED3DFMT_R8G8B8; break; */ /* 32bpp and 24bpp can be aliased for X */
433     case 32: pMode->Format       = WINED3DFMT_A8R8G8B8; break;
434     default:
435        FIXME("Unrecognized display mode format\n");
436        pMode->Format       = WINED3DFMT_UNKNOWN;
437     }
438
439     TRACE("(%p) : returning w(%d) h(%d) rr(%d) fmt(%u,%s)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate,
440     pMode->Format, debug_d3dformat(pMode->Format));
441     return WINED3D_OK;
442 }
443
444 static HRESULT WINAPI IWineD3DSwapChainImpl_GetDevice(IWineD3DSwapChain *iface, IWineD3DDevice**ppDevice) {
445     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
446
447     *ppDevice = (IWineD3DDevice *) This->wineD3DDevice;
448
449     /* Note  Calling this method will increase the internal reference count
450        on the IDirect3DDevice9 interface. */
451     IWineD3DDevice_AddRef(*ppDevice);
452     TRACE("(%p) : returning %p\n", This, *ppDevice);
453     return WINED3D_OK;
454 }
455
456 static HRESULT WINAPI IWineD3DSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface, WINED3DPRESENT_PARAMETERS *pPresentationParameters) {
457     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
458     TRACE("(%p)\n", This);
459
460     *pPresentationParameters = This->presentParms;
461
462     return WINED3D_OK;
463 }
464
465 static HRESULT WINAPI IWineD3DSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface, DWORD Flags, CONST WINED3DGAMMARAMP *pRamp){
466
467     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
468     HDC hDC;
469     TRACE("(%p) : pRamp@%p flags(%d)\n", This, pRamp, Flags);
470     hDC = GetDC(This->win_handle);
471     SetDeviceGammaRamp(hDC, (LPVOID)pRamp);
472     ReleaseDC(This->win_handle, hDC);
473     return WINED3D_OK;
474
475 }
476
477 static HRESULT WINAPI IWineD3DSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface, WINED3DGAMMARAMP *pRamp){
478
479     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
480     HDC hDC;
481     TRACE("(%p) : pRamp@%p\n", This, pRamp);
482     hDC = GetDC(This->win_handle);
483     GetDeviceGammaRamp(hDC, pRamp);
484     ReleaseDC(This->win_handle, hDC);
485     return WINED3D_OK;
486
487 }
488
489
490 const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl =
491 {
492     /* IUnknown */
493     IWineD3DSwapChainImpl_QueryInterface,
494     IWineD3DSwapChainImpl_AddRef,
495     IWineD3DSwapChainImpl_Release,
496     /* IWineD3DSwapChain */
497     IWineD3DSwapChainImpl_GetParent,
498     IWineD3DSwapChainImpl_Destroy,
499     IWineD3DSwapChainImpl_GetDevice,
500     IWineD3DSwapChainImpl_Present,
501     IWineD3DSwapChainImpl_GetFrontBufferData,
502     IWineD3DSwapChainImpl_GetBackBuffer,
503     IWineD3DSwapChainImpl_GetRasterStatus,
504     IWineD3DSwapChainImpl_GetDisplayMode,
505     IWineD3DSwapChainImpl_GetPresentParameters,
506     IWineD3DSwapChainImpl_SetGammaRamp,
507     IWineD3DSwapChainImpl_GetGammaRamp
508 };