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