wined3d: Make sure the color buffer is not modified by depth_blt().
[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 static inline 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     int i;
109
110     /* release the ref to the front and back buffer parents */
111     if(This->frontBuffer) {
112         IWineD3DSurface_SetContainer(This->frontBuffer, 0);
113         if(D3DCB_DestroyRenderTarget(This->frontBuffer) > 0) {
114             FIXME("(%p) Something's still holding the front buffer\n",This);
115         }
116     }
117
118     if(This->backBuffer) {
119         int i;
120         for(i = 0; i < This->presentParms.BackBufferCount; i++) {
121             IWineD3DSurface_SetContainer(This->backBuffer[i], 0);
122             if(D3DCB_DestroyRenderTarget(This->backBuffer[i]) > 0) {
123                 FIXME("(%p) Something's still holding the back buffer\n",This);
124             }
125         }
126     }
127
128     /* Restore the screen resolution if we rendered in fullscreen
129      * This will restore the screen resolution to what it was before creating the swapchain. In case of d3d8 and d3d9
130      * this will be the original desktop resolution. In case of d3d7 this will be a NOP because ddraw sets the resolution
131      * before starting up Direct3D, thus orig_width and orig_height will be equal to the modes in the presentation params
132      */
133     if(This->presentParms.Windowed == FALSE) {
134         mode.Width = This->orig_width;
135         mode.Height = This->orig_height;
136         mode.RefreshRate = 0;
137         mode.Format = This->orig_fmt;
138         IWineD3DDevice_SetDisplayMode((IWineD3DDevice *) This->wineD3DDevice, 0, &mode);
139     }
140     for(i = 0; i < This->num_contexts; i++) {
141         DestroyContext(This->wineD3DDevice, This->context[i]);
142     }
143     HeapFree(GetProcessHeap(), 0, This->context);
144
145     HeapFree(GetProcessHeap(), 0, This);
146 }
147
148 static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags) {
149     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
150     DWORD clear_flags = 0;
151
152     ENTER_GL();
153
154     /* Does glXSwapBuffers need a glx context? I don't think so. Blt will activate its own context if needed */
155
156     /* Render the cursor onto the back buffer, using our nifty directdraw blitting code :-) */
157     if(This->wineD3DDevice->bCursorVisible && This->wineD3DDevice->cursorTexture) {
158         IWineD3DSurfaceImpl cursor;
159         RECT destRect = {This->wineD3DDevice->xScreenSpace - This->wineD3DDevice->xHotSpot,
160                          This->wineD3DDevice->yScreenSpace - This->wineD3DDevice->yHotSpot,
161                          This->wineD3DDevice->xScreenSpace + This->wineD3DDevice->cursorWidth - This->wineD3DDevice->xHotSpot,
162                          This->wineD3DDevice->yScreenSpace + This->wineD3DDevice->cursorHeight - This->wineD3DDevice->yHotSpot};
163         TRACE("Rendering the cursor. Creating fake surface at %p\n", &cursor);
164         /* Build a fake surface to call the Blitting code. It is not possible to use the interface passed by
165          * the application because we are only supposed to copy the information out. Using a fake surface
166          * allows to use the Blitting engine and avoid copying the whole texture -> render target blitting code.
167          */
168         memset(&cursor, 0, sizeof(cursor));
169         cursor.lpVtbl = &IWineD3DSurface_Vtbl;
170         cursor.resource.ref = 1;
171         cursor.resource.wineD3DDevice = This->wineD3DDevice;
172         cursor.resource.pool = WINED3DPOOL_SCRATCH;
173         cursor.resource.format = WINED3DFMT_A8R8G8B8;
174         cursor.resource.resourceType = WINED3DRTYPE_SURFACE;
175         cursor.glDescription.textureName = This->wineD3DDevice->cursorTexture;
176         cursor.glDescription.target = GL_TEXTURE_2D;
177         cursor.glDescription.level = 0;
178         cursor.currentDesc.Width = This->wineD3DDevice->cursorWidth;
179         cursor.currentDesc.Height = This->wineD3DDevice->cursorHeight;
180         cursor.glRect.left = 0;
181         cursor.glRect.top = 0;
182         cursor.glRect.right = cursor.currentDesc.Width;
183         cursor.glRect.bottom = cursor.currentDesc.Height;
184         /* The cursor must have pow2 sizes */
185         cursor.pow2Width = cursor.currentDesc.Width;
186         cursor.pow2Height = cursor.currentDesc.Height;
187         /* The surface is in the texture */
188         cursor.Flags |= SFLAG_INTEXTURE;
189         /* DDBLT_KEYSRC will cause BltOverride to enable the alpha test with GL_NOTEQUAL, 0.0,
190          * which is exactly what we want :-)
191          */
192         if (This->presentParms.Windowed) {
193             MapWindowPoints(NULL, This->win_handle, (LPPOINT)&destRect, 2);
194         }
195         IWineD3DSurface_Blt(This->backBuffer[0], &destRect, (IWineD3DSurface *) &cursor, NULL, WINEDDBLT_KEYSRC, NULL, WINED3DTEXF_NONE);
196     }
197
198     if (pSourceRect || pDestRect) FIXME("Unhandled present options %p/%p\n", pSourceRect, pDestRect);
199     /* TODO: If only source rect or dest rect are supplied then clip the window to match */
200     TRACE("preseting display %p, drawable %ld\n", This->context[0]->display, This->context[0]->drawable);
201
202     /* Don't call checkGLcall, as glGetError is not applicable here */
203     if (hDestWindowOverride && This->win_handle != hDestWindowOverride) {
204         HDC hDc;
205         WINED3DLOCKED_RECT r;
206         Display *display;
207         BYTE *mem;
208
209         TRACE("Performing dest override of swapchain %p from window %p to %p\n", This, This->win_handle, hDestWindowOverride);
210         if(This->context[0] == This->wineD3DDevice->contexts[0]) {
211             /* The primary context 'owns' all the opengl resources. Destroying and recreating that context would require downloading
212              * all opengl resources, deleting the gl resources, destroying all other contexts, then recreating all other contexts
213              * and reload the resources
214              */
215             ERR("Cannot change the destination window of the owner of the primary context\n");
216         } else {
217             hDc                          = GetDC(hDestWindowOverride);
218             This->win_handle             = hDestWindowOverride;
219             This->win                    = (Window)GetPropA( hDestWindowOverride, "__wine_x11_whole_window" );
220             display                      = get_display(hDc);
221             ReleaseDC(hDestWindowOverride, hDc);
222
223             /* The old back buffer has to be copied over to the new back buffer. A lockrect - switchcontext - unlockrect
224              * would suffice in theory, but it is rather nasty and may cause troubles with future changes of the locking code
225              * So lock read only, copy the surface out, then lock with the discard flag and write back
226              */
227             IWineD3DSurface_LockRect(This->backBuffer[0], &r, NULL, WINED3DLOCK_READONLY);
228             mem = HeapAlloc(GetProcessHeap(), 0, r.Pitch * ((IWineD3DSurfaceImpl *) This->backBuffer[0])->currentDesc.Height);
229             memcpy(mem, r.pBits, r.Pitch * ((IWineD3DSurfaceImpl *) This->backBuffer[0])->currentDesc.Height);
230             IWineD3DSurface_UnlockRect(This->backBuffer[0]);
231
232             DestroyContext(This->wineD3DDevice, This->context[0]);
233             This->context[0] = CreateContext(This->wineD3DDevice, (IWineD3DSurfaceImpl *) This->frontBuffer, display, This->win);
234
235             IWineD3DSurface_LockRect(This->backBuffer[0], &r, NULL, WINED3DLOCK_DISCARD);
236             memcpy(r.pBits, mem, r.Pitch * ((IWineD3DSurfaceImpl *) This->backBuffer[0])->currentDesc.Height);
237             HeapFree(GetProcessHeap(), 0, mem);
238             IWineD3DSurface_UnlockRect(This->backBuffer[0]);
239         }
240     }
241
242     glXSwapBuffers(This->context[0]->display, This->context[0]->drawable); /* TODO: cycle through the swapchain buffers */
243
244     TRACE("glXSwapBuffers called, Starting new frame\n");
245     /* FPS support */
246     if (TRACE_ON(fps))
247     {
248         DWORD time = GetTickCount();
249         This->frames++;
250         /* every 1.5 seconds */
251         if (time - This->prev_time > 1500) {
252             TRACE_(fps)("%p @ approx %.2ffps\n", This, 1000.0*This->frames/(time - This->prev_time));
253             This->prev_time = time;
254             This->frames = 0;
255         }
256     }
257
258 #if defined(FRAME_DEBUGGING)
259 {
260     if (GetFileAttributesA("C:\\D3DTRACE") != INVALID_FILE_ATTRIBUTES) {
261         if (!isOn) {
262             isOn = TRUE;
263             FIXME("Enabling D3D Trace\n");
264             __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 1);
265 #if defined(SHOW_FRAME_MAKEUP)
266             FIXME("Singe Frame snapshots Starting\n");
267             isDumpingFrames = TRUE;
268             glClear(GL_COLOR_BUFFER_BIT);
269 #endif
270
271 #if defined(SINGLE_FRAME_DEBUGGING)
272         } else {
273 #if defined(SHOW_FRAME_MAKEUP)
274             FIXME("Singe Frame snapshots Finishing\n");
275             isDumpingFrames = FALSE;
276 #endif
277             FIXME("Singe Frame trace complete\n");
278             DeleteFileA("C:\\D3DTRACE");
279             __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 0);
280 #endif
281         }
282     } else {
283         if (isOn) {
284             isOn = FALSE;
285 #if defined(SHOW_FRAME_MAKEUP)
286             FIXME("Single Frame snapshots Finishing\n");
287             isDumpingFrames = FALSE;
288 #endif
289             FIXME("Disabling D3D Trace\n");
290             __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 0);
291         }
292     }
293 }
294 #endif
295
296     LEAVE_GL();
297
298     if (This->wineD3DDevice->stencilBufferTarget) {
299         clear_flags |= WINED3DCLEAR_STENCIL|WINED3DCLEAR_ZBUFFER;
300     }
301
302     /* Although this is not strictly required, a simple demo showed this does occur
303        on (at least non-debug) d3d                                                  */
304     if (This->presentParms.SwapEffect == WINED3DSWAPEFFECT_DISCARD) {
305
306         TRACE("Clearing\n");
307
308         IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL, clear_flags|WINED3DCLEAR_TARGET, 0x00, 1.0, 0);
309
310     } else if (clear_flags) {
311         TRACE("Clearing z/stencil buffer\n");
312
313         IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL, clear_flags, 0x00, 1.0, 0);
314     }
315
316     if(((IWineD3DSurfaceImpl *) This->frontBuffer)->Flags   & SFLAG_INSYSMEM ||
317        ((IWineD3DSurfaceImpl *) This->backBuffer[0])->Flags & SFLAG_INSYSMEM ) {
318         /* Both memory copies of the surfaces are ok, flip them around too instead of dirtifying */
319         IWineD3DSurfaceImpl *front = (IWineD3DSurfaceImpl *) This->frontBuffer;
320         IWineD3DSurfaceImpl *back = (IWineD3DSurfaceImpl *) This->backBuffer[0];
321         BOOL frontuptodate = front->Flags & SFLAG_INSYSMEM;
322         BOOL backuptodate = back->Flags & SFLAG_INSYSMEM;
323
324         /* Flip the DC */
325         {
326             HDC tmp;
327             tmp = front->hDC;
328             front->hDC = back->hDC;
329             back->hDC = tmp;
330         }
331
332         /* Flip the DIBsection */
333         {
334             HBITMAP tmp;
335             BOOL hasDib = front->Flags & SFLAG_DIBSECTION;
336             tmp = front->dib.DIBsection;
337             front->dib.DIBsection = back->dib.DIBsection;
338             back->dib.DIBsection = tmp;
339
340             if(back->Flags & SFLAG_DIBSECTION) front->Flags |= SFLAG_DIBSECTION;
341             else front->Flags &= ~SFLAG_DIBSECTION;
342             if(hasDib) back->Flags |= SFLAG_DIBSECTION;
343             else back->Flags &= ~SFLAG_DIBSECTION;
344         }
345
346         /* Flip the surface data */
347         {
348             void* tmp;
349
350             tmp = front->dib.bitmap_data;
351             front->dib.bitmap_data = back->dib.bitmap_data;
352             back->dib.bitmap_data = tmp;
353
354             tmp = front->resource.allocatedMemory;
355             front->resource.allocatedMemory = back->resource.allocatedMemory;
356             back->resource.allocatedMemory = tmp;
357         }
358
359         /* client_memory should not be different, but just in case */
360         {
361             BOOL tmp;
362             tmp = front->dib.client_memory;
363             front->dib.client_memory = back->dib.client_memory;
364             back->dib.client_memory = tmp;
365         }
366         if(frontuptodate) back->Flags |= SFLAG_INSYSMEM;
367         else back->Flags &= ~SFLAG_INSYSMEM;
368         if(backuptodate) front->Flags |= SFLAG_INSYSMEM;
369         else front->Flags &= ~SFLAG_INSYSMEM;
370     }
371
372     TRACE("returning\n");
373     return WINED3D_OK;
374 }
375
376 static HRESULT WINAPI IWineD3DSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface, IWineD3DSurface *pDestSurface) {
377     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
378     POINT start;
379
380     TRACE("(%p) : iface(%p) pDestSurface(%p)\n", This, iface, pDestSurface);
381
382     start.x = 0;
383     start.y = 0;
384
385     if (This->presentParms.Windowed) {
386         MapWindowPoints(This->win_handle, NULL, &start, 1);
387     }
388
389     IWineD3DSurface_BltFast(pDestSurface, start.x, start.y, This->frontBuffer, NULL, 0);
390     return WINED3D_OK;
391 }
392
393 static HRESULT WINAPI IWineD3DSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface, UINT iBackBuffer, WINED3DBACKBUFFER_TYPE Type, IWineD3DSurface **ppBackBuffer) {
394
395     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
396
397     if (iBackBuffer > This->presentParms.BackBufferCount - 1) {
398         TRACE("Back buffer count out of range\n");
399         /* Native d3d9 doesn't set NULL here, just as wine's d3d9. But set it here
400          * in wined3d to avoid problems in other libs
401          */
402         *ppBackBuffer = NULL;
403         return WINED3DERR_INVALIDCALL;
404     }
405
406     *ppBackBuffer = This->backBuffer[iBackBuffer];
407     TRACE("(%p) : BackBuf %d Type %d  returning %p\n", This, iBackBuffer, Type, *ppBackBuffer);
408
409     /* Note inc ref on returned surface */
410     if(*ppBackBuffer) IWineD3DSurface_AddRef(*ppBackBuffer);
411     return WINED3D_OK;
412
413 }
414
415 static HRESULT WINAPI IWineD3DSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, WINED3DRASTER_STATUS *pRasterStatus) {
416     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
417     static BOOL showFixmes = TRUE;
418     pRasterStatus->InVBlank = TRUE;
419     pRasterStatus->ScanLine = 0;
420     /* No openGL equivalent */
421     if(showFixmes) {
422         FIXME("(%p) : stub (once)\n", This);
423         showFixmes = FALSE;
424     }
425     return WINED3D_OK;
426 }
427
428 static HRESULT WINAPI IWineD3DSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, WINED3DDISPLAYMODE*pMode) {
429     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
430     HDC                 hdc;
431     int                 bpp = 0;
432
433     pMode->Width        = GetSystemMetrics(SM_CXSCREEN);
434     pMode->Height       = GetSystemMetrics(SM_CYSCREEN);
435     pMode->RefreshRate  = 85; /* FIXME: How to identify? */
436
437     hdc = GetDC(0);
438     bpp = GetDeviceCaps(hdc, BITSPIXEL);
439     ReleaseDC(0, hdc);
440
441     switch (bpp) {
442     case  8: pMode->Format       = WINED3DFMT_R8G8B8; break;
443     case 16: pMode->Format       = WINED3DFMT_R5G6B5; break;
444     case 24: /*pMode->Format       = WINED3DFMT_R8G8B8; break; */ /* 32bpp and 24bpp can be aliased for X */
445     case 32: pMode->Format       = WINED3DFMT_A8R8G8B8; break;
446     default:
447        FIXME("Unrecognized display mode format\n");
448        pMode->Format       = WINED3DFMT_UNKNOWN;
449     }
450
451     TRACE("(%p) : returning w(%d) h(%d) rr(%d) fmt(%u,%s)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate,
452     pMode->Format, debug_d3dformat(pMode->Format));
453     return WINED3D_OK;
454 }
455
456 static HRESULT WINAPI IWineD3DSwapChainImpl_GetDevice(IWineD3DSwapChain *iface, IWineD3DDevice**ppDevice) {
457     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
458
459     *ppDevice = (IWineD3DDevice *) This->wineD3DDevice;
460
461     /* Note  Calling this method will increase the internal reference count
462        on the IDirect3DDevice9 interface. */
463     IWineD3DDevice_AddRef(*ppDevice);
464     TRACE("(%p) : returning %p\n", This, *ppDevice);
465     return WINED3D_OK;
466 }
467
468 static HRESULT WINAPI IWineD3DSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface, WINED3DPRESENT_PARAMETERS *pPresentationParameters) {
469     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
470     TRACE("(%p)\n", This);
471
472     *pPresentationParameters = This->presentParms;
473
474     return WINED3D_OK;
475 }
476
477 static HRESULT WINAPI IWineD3DSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface, DWORD Flags, CONST WINED3DGAMMARAMP *pRamp){
478
479     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
480     HDC hDC;
481     TRACE("(%p) : pRamp@%p flags(%d)\n", This, pRamp, Flags);
482     hDC = GetDC(This->win_handle);
483     SetDeviceGammaRamp(hDC, (LPVOID)pRamp);
484     ReleaseDC(This->win_handle, hDC);
485     return WINED3D_OK;
486
487 }
488
489 static HRESULT WINAPI IWineD3DSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface, WINED3DGAMMARAMP *pRamp){
490
491     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
492     HDC hDC;
493     TRACE("(%p) : pRamp@%p\n", This, pRamp);
494     hDC = GetDC(This->win_handle);
495     GetDeviceGammaRamp(hDC, pRamp);
496     ReleaseDC(This->win_handle, hDC);
497     return WINED3D_OK;
498
499 }
500
501
502 const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl =
503 {
504     /* IUnknown */
505     IWineD3DSwapChainImpl_QueryInterface,
506     IWineD3DSwapChainImpl_AddRef,
507     IWineD3DSwapChainImpl_Release,
508     /* IWineD3DSwapChain */
509     IWineD3DSwapChainImpl_GetParent,
510     IWineD3DSwapChainImpl_Destroy,
511     IWineD3DSwapChainImpl_GetDevice,
512     IWineD3DSwapChainImpl_Present,
513     IWineD3DSwapChainImpl_GetFrontBufferData,
514     IWineD3DSwapChainImpl_GetBackBuffer,
515     IWineD3DSwapChainImpl_GetRasterStatus,
516     IWineD3DSwapChainImpl_GetDisplayMode,
517     IWineD3DSwapChainImpl_GetPresentParameters,
518     IWineD3DSwapChainImpl_SetGammaRamp,
519     IWineD3DSwapChainImpl_GetGammaRamp
520 };