mshtml/tests: Fix some test failures on IE8.
[wine] / dlls / wined3d / surface_gdi.c
1 /*
2  * 2D Surface implementation without OpenGL
3  *
4  * Copyright 1997-2000 Marcus Meissner
5  * Copyright 1998-2000 Lionel Ulmer
6  * Copyright 2000-2001 TransGaming Technologies Inc.
7  * Copyright 2002-2005 Jason Edmeades
8  * Copyright 2002-2003 Raphael Junqueira
9  * Copyright 2004 Christian Costa
10  * Copyright 2005 Oliver Stieber
11  * Copyright 2006-2008 Stefan Dösinger
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public
15  * License as published by the Free Software Foundation; either
16  * version 2.1 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this library; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26  */
27
28 #include "config.h"
29 #include "wine/port.h"
30 #include "wined3d_private.h"
31
32 #include <assert.h>
33 #include <stdio.h>
34
35 /* Use the d3d_surface debug channel to have one channel for all surfaces */
36 WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
37
38 /*****************************************************************************
39  * IWineD3DSurface::Release, GDI version
40  *
41  * In general a normal COM Release method, but the GDI version doesn't have
42  * to destroy all the GL things.
43  *
44  *****************************************************************************/
45 static ULONG WINAPI IWineGDISurfaceImpl_Release(IWineD3DSurface *iface) {
46     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
47     ULONG ref = InterlockedDecrement(&This->resource.ref);
48     TRACE("(%p) : Releasing from %d\n", This, ref + 1);
49     if (ref == 0) {
50         TRACE("(%p) : cleaning up\n", This);
51
52         if(This->Flags & SFLAG_DIBSECTION) {
53             /* Release the DC */
54             SelectObject(This->hDC, This->dib.holdbitmap);
55             DeleteDC(This->hDC);
56             /* Release the DIB section */
57             DeleteObject(This->dib.DIBsection);
58             This->dib.bitmap_data = NULL;
59             This->resource.allocatedMemory = NULL;
60         }
61         if(This->Flags & SFLAG_USERPTR) IWineD3DSurface_SetMem(iface, NULL);
62
63         HeapFree(GetProcessHeap(), 0, This->palette9);
64
65         resource_cleanup((IWineD3DResource *)iface);
66
67         if(This->overlay_dest) {
68             list_remove(&This->overlay_entry);
69         }
70
71         TRACE("(%p) Released\n", This);
72         HeapFree(GetProcessHeap(), 0, This);
73
74     }
75     return ref;
76 }
77
78 /*****************************************************************************
79  * IWineD3DSurface::PreLoad, GDI version
80  *
81  * This call is unsupported on GDI surfaces, if it's called something went
82  * wrong in the parent library. Write an informative warning
83  *
84  *****************************************************************************/
85 static void WINAPI
86 IWineGDISurfaceImpl_PreLoad(IWineD3DSurface *iface)
87 {
88     ERR("(%p): PreLoad is not supported on X11 surfaces!\n", iface);
89     ERR("(%p): Most likely the parent library did something wrong.\n", iface);
90     ERR("(%p): Please report to wine-devel\n", iface);
91 }
92
93 /*****************************************************************************
94  * IWineD3DSurface::UnLoad, GDI version
95  *
96  * This call is unsupported on GDI surfaces, if it's called something went
97  * wrong in the parent library. Write an informative warning.
98  *
99  *****************************************************************************/
100 static void WINAPI IWineGDISurfaceImpl_UnLoad(IWineD3DSurface *iface)
101 {
102     ERR("(%p): UnLoad is not supported on X11 surfaces!\n", iface);
103     ERR("(%p): Most likely the parent library did something wrong.\n", iface);
104     ERR("(%p): Please report to wine-devel\n", iface);
105 }
106
107 /*****************************************************************************
108  * IWineD3DSurface::LockRect, GDI version
109  *
110  * Locks the surface and returns a pointer to the surface memory
111  *
112  * Params:
113  *  pLockedRect: Address to return the locking info at
114  *  pRect: Rectangle to lock
115  *  Flags: Some flags
116  *
117  * Returns:
118  *  WINED3D_OK on success
119  *  WINED3DERR_INVALIDCALL on errors
120  *
121  *****************************************************************************/
122 static HRESULT WINAPI
123 IWineGDISurfaceImpl_LockRect(IWineD3DSurface *iface,
124                              WINED3DLOCKED_RECT* pLockedRect,
125                              CONST RECT* pRect,
126                              DWORD Flags)
127 {
128     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
129
130     /* Already locked? */
131     if(This->Flags & SFLAG_LOCKED)
132     {
133         WARN("(%p) Surface already locked\n", This);
134         /* What should I return here? */
135         return WINED3DERR_INVALIDCALL;
136     }
137     This->Flags |= SFLAG_LOCKED;
138
139     if(!This->resource.allocatedMemory) {
140         /* This happens on gdi surfaces if the application set a user pointer and resets it.
141          * Recreate the DIB section
142          */
143         IWineD3DBaseSurfaceImpl_CreateDIBSection(iface);
144         This->resource.allocatedMemory = This->dib.bitmap_data;
145     }
146
147     return IWineD3DBaseSurfaceImpl_LockRect(iface, pLockedRect, pRect, Flags);
148 }
149
150 /*****************************************************************************
151  * IWineD3DSurface::UnlockRect, GDI version
152  *
153  * Unlocks a surface. This implementation doesn't do much, except updating
154  * the window if the front buffer is unlocked
155  *
156  * Returns:
157  *  WINED3D_OK on success
158  *  WINED3DERR_INVALIDCALL on failure
159  *
160  *****************************************************************************/
161 static HRESULT WINAPI
162 IWineGDISurfaceImpl_UnlockRect(IWineD3DSurface *iface)
163 {
164     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
165     IWineD3DSwapChainImpl *swapchain = NULL;
166     TRACE("(%p)\n", This);
167
168     if (!(This->Flags & SFLAG_LOCKED))
169     {
170         WARN("trying to Unlock an unlocked surf@%p\n", This);
171         return WINEDDERR_NOTLOCKED;
172     }
173
174     /* Can be useful for debugging */
175 #if 0
176         {
177             static unsigned int gen = 0;
178             char buffer[4096];
179             ++gen;
180             if ((gen % 10) == 0) {
181                 snprintf(buffer, sizeof(buffer), "/tmp/surface%p_type%u_level%u_%u.ppm", This, This->glDescription.target, This->glDescription.level, gen);
182                 IWineD3DSurfaceImpl_SaveSnapshot(iface, buffer);
183             }
184             /*
185              * debugging crash code
186             if (gen == 250) {
187               void** test = NULL;
188               *test = 0;
189             }
190             */
191         }
192 #endif
193
194     /* Tell the swapchain to update the screen */
195     if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain)))
196     {
197         x11_copy_to_screen(swapchain, &This->lockedRect);
198         IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
199     }
200
201     This->Flags &= ~SFLAG_LOCKED;
202     memset(&This->lockedRect, 0, sizeof(RECT));
203     return WINED3D_OK;
204 }
205
206 /*****************************************************************************
207  * IWineD3DSurface::Flip, GDI version
208  *
209  * Flips 2 flipping enabled surfaces. Determining the 2 targets is done by
210  * the parent library. This implementation changes the data pointers of the
211  * surfaces and copies the new front buffer content to the screen
212  *
213  * Params:
214  *  override: Flipping target(e.g. back buffer)
215  *
216  * Returns:
217  *  WINED3D_OK on success
218  *
219  *****************************************************************************/
220 static HRESULT WINAPI
221 IWineGDISurfaceImpl_Flip(IWineD3DSurface *iface,
222                          IWineD3DSurface *override,
223                          DWORD Flags)
224 {
225     IWineD3DSwapChainImpl *swapchain = NULL;
226     HRESULT hr;
227
228     if(FAILED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain)))
229     {
230         ERR("Flipped surface is not on a swapchain\n");
231         return WINEDDERR_NOTFLIPPABLE;
232     }
233
234     hr = IWineD3DSwapChain_Present((IWineD3DSwapChain *) swapchain, NULL, NULL, 0, NULL, 0);
235     IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
236     return hr;
237 }
238
239 /*****************************************************************************
240  * IWineD3DSurface::LoadTexture, GDI version
241  *
242  * This is mutually unsupported by GDI surfaces
243  *
244  * Returns:
245  *  D3DERR_INVALIDCALL
246  *
247  *****************************************************************************/
248 static HRESULT WINAPI
249 IWineGDISurfaceImpl_LoadTexture(IWineD3DSurface *iface, BOOL srgb_mode)
250 {
251     ERR("Unsupported on X11 surfaces\n");
252     return WINED3DERR_INVALIDCALL;
253 }
254
255 /*****************************************************************************
256  * IWineD3DSurface::SaveSnapshot, GDI version
257  *
258  * This method writes the surface's contents to the in tga format to the
259  * file specified in filename.
260  *
261  * Params:
262  *  filename: File to write to
263  *
264  * Returns:
265  *  WINED3DERR_INVALIDCALL if the file couldn't be opened
266  *  WINED3D_OK on success
267  *
268  *****************************************************************************/
269 static int get_shift(DWORD color_mask) {
270     int shift = 0;
271     while (color_mask > 0xFF) {
272         color_mask >>= 1;
273         shift += 1;
274     }
275     while ((color_mask & 0x80) == 0) {
276         color_mask <<= 1;
277         shift -= 1;
278     }
279     return shift;
280 }
281
282
283 static HRESULT WINAPI
284 IWineGDISurfaceImpl_SaveSnapshot(IWineD3DSurface *iface,
285 const char* filename)
286 {
287     FILE* f = NULL;
288     UINT y = 0, x = 0;
289     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
290     static char *output = NULL;
291     static UINT size = 0;
292     const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
293
294     if (This->pow2Width > size) {
295         output = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->pow2Width * 3);
296         size = This->pow2Width;
297     }
298
299
300     f = fopen(filename, "w+");
301     if (NULL == f) {
302         ERR("opening of %s failed with\n", filename);
303         return WINED3DERR_INVALIDCALL;
304     }
305     fprintf(f, "P6\n%d %d\n255\n", This->pow2Width, This->pow2Height);
306
307     if (This->resource.format_desc->format == WINED3DFMT_P8)
308     {
309         unsigned char table[256][3];
310         int i;
311
312         if (This->palette == NULL) {
313             fclose(f);
314             return WINED3DERR_INVALIDCALL;
315         }
316         for (i = 0; i < 256; i++) {
317             table[i][0] = This->palette->palents[i].peRed;
318             table[i][1] = This->palette->palents[i].peGreen;
319             table[i][2] = This->palette->palents[i].peBlue;
320         }
321         for (y = 0; y < This->pow2Height; y++) {
322             unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface));
323             for (x = 0; x < This->pow2Width; x++) {
324                 unsigned char color = *src;
325                 src += 1;
326
327                 output[3 * x + 0] = table[color][0];
328                 output[3 * x + 1] = table[color][1];
329                 output[3 * x + 2] = table[color][2];
330             }
331             fwrite(output, 3 * This->pow2Width, 1, f);
332         }
333     } else {
334         int red_shift, green_shift, blue_shift, pix_width, alpha_shift;
335
336         pix_width = format_desc->byte_count;
337
338         red_shift = get_shift(format_desc->red_mask);
339         green_shift = get_shift(format_desc->green_mask);
340         blue_shift = get_shift(format_desc->blue_mask);
341         alpha_shift = get_shift(format_desc->alpha_mask);
342
343         for (y = 0; y < This->pow2Height; y++) {
344             const unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface));
345             for (x = 0; x < This->pow2Width; x++) {
346                 unsigned int color;
347                 unsigned int comp;
348                 int i;
349
350                 color = 0;
351                 for (i = 0; i < pix_width; i++) {
352                     color |= src[i] << (8 * i);
353                 }
354                 src += 1 * pix_width;
355
356                 comp = color & format_desc->red_mask;
357                 output[3 * x + 0] = red_shift > 0 ? comp >> red_shift : comp << -red_shift;
358                 comp = color & format_desc->green_mask;
359                 output[3 * x + 1] = green_shift > 0 ? comp >> green_shift : comp << -green_shift;
360                 comp = color & format_desc->alpha_mask;
361                 output[3 * x + 2] = alpha_shift > 0 ? comp >> alpha_shift : comp << -alpha_shift;
362             }
363             fwrite(output, 3 * This->pow2Width, 1, f);
364         }
365     }
366     fclose(f);
367     return WINED3D_OK;
368 }
369
370 static HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
371     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
372     WINED3DLOCKED_RECT lock;
373     HRESULT hr;
374     RGBQUAD col[256];
375
376     TRACE("(%p)->(%p)\n",This,pHDC);
377
378     if(This->Flags & SFLAG_USERPTR) {
379         ERR("Not supported on surfaces with an application-provided surfaces\n");
380         return WINEDDERR_NODC;
381     }
382
383     /* Give more detailed info for ddraw */
384     if (This->Flags & SFLAG_DCINUSE)
385         return WINEDDERR_DCALREADYCREATED;
386
387     /* Can't GetDC if the surface is locked */
388     if (This->Flags & SFLAG_LOCKED)
389         return WINED3DERR_INVALIDCALL;
390
391     memset(&lock, 0, sizeof(lock)); /* To be sure */
392
393     /* Should have a DIB section already */
394
395     /* Lock the surface */
396     hr = IWineD3DSurface_LockRect(iface,
397                                   &lock,
398                                   NULL,
399                                   0);
400     if(FAILED(hr)) {
401         ERR("IWineD3DSurface_LockRect failed with hr = %08x\n", hr);
402         /* keep the dib section */
403         return hr;
404     }
405
406     if (This->resource.format_desc->format == WINED3DFMT_P8
407             || This->resource.format_desc->format == WINED3DFMT_A8P8)
408     {
409         unsigned int n;
410         const PALETTEENTRY *pal = NULL;
411
412         if(This->palette) {
413             pal = This->palette->palents;
414         } else {
415             IWineD3DSurfaceImpl *dds_primary;
416             IWineD3DSwapChainImpl *swapchain;
417             swapchain = (IWineD3DSwapChainImpl *)This->resource.wineD3DDevice->swapchains[0];
418             dds_primary = (IWineD3DSurfaceImpl *)swapchain->frontBuffer;
419             if (dds_primary && dds_primary->palette)
420                 pal = dds_primary->palette->palents;
421         }
422
423         if (pal) {
424             for (n=0; n<256; n++) {
425                 col[n].rgbRed   = pal[n].peRed;
426                 col[n].rgbGreen = pal[n].peGreen;
427                 col[n].rgbBlue  = pal[n].peBlue;
428                 col[n].rgbReserved = 0;
429             }
430             SetDIBColorTable(This->hDC, 0, 256, col);
431         }
432     }
433
434     *pHDC = This->hDC;
435     TRACE("returning %p\n",*pHDC);
436     This->Flags |= SFLAG_DCINUSE;
437
438     return WINED3D_OK;
439 }
440
441 static HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
442     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
443
444     TRACE("(%p)->(%p)\n",This,hDC);
445
446     if (!(This->Flags & SFLAG_DCINUSE))
447         return WINEDDERR_NODC;
448
449     if (This->hDC !=hDC) {
450         WARN("Application tries to release an invalid DC(%p), surface dc is %p\n", hDC, This->hDC);
451         return WINEDDERR_NODC;
452     }
453
454     /* we locked first, so unlock now */
455     IWineD3DSurface_UnlockRect(iface);
456
457     This->Flags &= ~SFLAG_DCINUSE;
458
459     return WINED3D_OK;
460 }
461
462 static HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
463     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
464     RGBQUAD col[256];
465     IWineD3DPaletteImpl *pal = This->palette;
466     unsigned int n;
467     IWineD3DSwapChainImpl *swapchain;
468     TRACE("(%p)\n", This);
469
470     if (!pal) return WINED3D_OK;
471
472     if(This->Flags & SFLAG_DIBSECTION) {
473         TRACE("(%p): Updating the hdc's palette\n", This);
474         for (n=0; n<256; n++) {
475             col[n].rgbRed   = pal->palents[n].peRed;
476             col[n].rgbGreen = pal->palents[n].peGreen;
477             col[n].rgbBlue  = pal->palents[n].peBlue;
478             col[n].rgbReserved = 0;
479         }
480         SetDIBColorTable(This->hDC, 0, 256, col);
481     }
482
483     /* Update the image because of the palette change. Some games like e.g Red Alert
484        call SetEntries a lot to implement fading. */
485     /* Tell the swapchain to update the screen */
486     if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain)))
487     {
488         x11_copy_to_screen(swapchain, NULL);
489         IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
490     }
491
492     return WINED3D_OK;
493 }
494
495 /*****************************************************************************
496  * IWineD3DSurface::PrivateSetup, GDI version
497  *
498  * Initializes the GDI surface, aka creates the DIB section we render to
499  * The DIB section creation is done by calling GetDC, which will create the
500  * section and releasing the dc to allow the app to use it. The dib section
501  * will stay until the surface is released
502  *
503  * GDI surfaces do not need to be a power of 2 in size, so the pow2 sizes
504  * are set to the real sizes to save memory. The NONPOW2 flag is unset to
505  * avoid confusion in the shared surface code.
506  *
507  * Returns:
508  *  WINED3D_OK on success
509  *  The return values of called methods on failure
510  *
511  *****************************************************************************/
512 static HRESULT WINAPI
513 IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
514 {
515     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
516
517     if(This->resource.usage & WINED3DUSAGE_OVERLAY)
518     {
519         ERR("(%p) Overlays not yet supported by GDI surfaces\n", This);
520         return WINED3DERR_INVALIDCALL;
521     }
522     /* Sysmem textures have memory already allocated -
523      * release it, this avoids an unnecessary memcpy
524      */
525     HeapFree(GetProcessHeap(), 0, This->resource.heapMemory);
526     This->resource.allocatedMemory = NULL;
527     This->resource.heapMemory = NULL;
528
529     /* We don't mind the nonpow2 stuff in GDI */
530     This->pow2Width = This->currentDesc.Width;
531     This->pow2Height = This->currentDesc.Height;
532
533     IWineD3DBaseSurfaceImpl_CreateDIBSection(iface);
534     This->resource.allocatedMemory = This->dib.bitmap_data;
535
536     return WINED3D_OK;
537 }
538
539 static void WINAPI IWineGDISurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription) {
540     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
541     FIXME("(%p) : Should not be called on a GDI surface\n", This);
542     *glDescription = NULL;
543 }
544
545 static HRESULT WINAPI IWineGDISurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
546     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
547
548     /* Render targets depend on their hdc, and we can't create an hdc on a user pointer */
549     if(This->resource.usage & WINED3DUSAGE_RENDERTARGET) {
550         ERR("Not supported on render targets\n");
551         return WINED3DERR_INVALIDCALL;
552     }
553
554     if(This->Flags & (SFLAG_LOCKED | SFLAG_DCINUSE)) {
555         WARN("Surface is locked or the HDC is in use\n");
556         return WINED3DERR_INVALIDCALL;
557     }
558
559     if(Mem && Mem != This->resource.allocatedMemory) {
560         void *release = NULL;
561
562         /* Do I have to copy the old surface content? */
563         if(This->Flags & SFLAG_DIBSECTION) {
564                 /* Release the DC. No need to hold the critical section for the update
565             * Thread because this thread runs only on front buffers, but this method
566             * fails for render targets in the check above.
567                 */
568             SelectObject(This->hDC, This->dib.holdbitmap);
569             DeleteDC(This->hDC);
570             /* Release the DIB section */
571             DeleteObject(This->dib.DIBsection);
572             This->dib.bitmap_data = NULL;
573             This->resource.allocatedMemory = NULL;
574             This->hDC = NULL;
575             This->Flags &= ~SFLAG_DIBSECTION;
576         } else if(!(This->Flags & SFLAG_USERPTR)) {
577             release = This->resource.allocatedMemory;
578         }
579         This->resource.allocatedMemory = Mem;
580         This->Flags |= SFLAG_USERPTR | SFLAG_INSYSMEM;
581
582         /* Now free the old memory if any */
583         HeapFree(GetProcessHeap(), 0, release);
584     } else if(This->Flags & SFLAG_USERPTR) {
585         /* LockRect and GetDC will re-create the dib section and allocated memory */
586         This->resource.allocatedMemory = NULL;
587         This->Flags &= ~SFLAG_USERPTR;
588     }
589     return WINED3D_OK;
590 }
591
592 /***************************
593  *
594  ***************************/
595 static void WINAPI IWineGDISurfaceImpl_ModifyLocation(IWineD3DSurface *iface, DWORD flag, BOOL persistent) {
596     TRACE("(%p)->(%s, %s)\n", iface,
597           flag == SFLAG_INSYSMEM ? "SFLAG_INSYSMEM" : flag == SFLAG_INDRAWABLE ? "SFLAG_INDRAWABLE" : "SFLAG_INTEXTURE",
598           persistent ? "TRUE" : "FALSE");
599     /* GDI surfaces can be in system memory only */
600     if(flag != SFLAG_INSYSMEM) {
601         ERR("GDI Surface requested in gl %s memory\n", flag == SFLAG_INDRAWABLE ? "drawable" : "texture");
602     }
603 }
604
605 static HRESULT WINAPI IWineGDISurfaceImpl_LoadLocation(IWineD3DSurface *iface, DWORD flag, const RECT *rect) {
606     if(flag != SFLAG_INSYSMEM) {
607         ERR("GDI Surface requested to be copied to gl %s\n", flag == SFLAG_INTEXTURE ? "texture" : "drawable");
608     } else {
609         TRACE("Surface requested in surface memory\n");
610     }
611     return WINED3D_OK;
612 }
613
614 static WINED3DSURFTYPE WINAPI IWineGDISurfaceImpl_GetImplType(IWineD3DSurface *iface) {
615     return SURFACE_GDI;
616 }
617
618 static HRESULT WINAPI IWineGDISurfaceImpl_DrawOverlay(IWineD3DSurface *iface) {
619     FIXME("GDI surfaces can't draw overlays yet\n");
620     return E_FAIL;
621 }
622
623 /* FIXME: This vtable should not use any IWineD3DSurface* implementation functions,
624  * only IWineD3DBaseSurface and IWineGDISurface ones.
625  */
626 const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl =
627 {
628     /* IUnknown */
629     IWineD3DBaseSurfaceImpl_QueryInterface,
630     IWineD3DBaseSurfaceImpl_AddRef,
631     IWineGDISurfaceImpl_Release,
632     /* IWineD3DResource */
633     IWineD3DBaseSurfaceImpl_GetParent,
634     IWineD3DBaseSurfaceImpl_GetDevice,
635     IWineD3DBaseSurfaceImpl_SetPrivateData,
636     IWineD3DBaseSurfaceImpl_GetPrivateData,
637     IWineD3DBaseSurfaceImpl_FreePrivateData,
638     IWineD3DBaseSurfaceImpl_SetPriority,
639     IWineD3DBaseSurfaceImpl_GetPriority,
640     IWineGDISurfaceImpl_PreLoad,
641     IWineGDISurfaceImpl_UnLoad,
642     IWineD3DBaseSurfaceImpl_GetType,
643     /* IWineD3DSurface */
644     IWineD3DBaseSurfaceImpl_GetContainer,
645     IWineD3DBaseSurfaceImpl_GetDesc,
646     IWineGDISurfaceImpl_LockRect,
647     IWineGDISurfaceImpl_UnlockRect,
648     IWineGDISurfaceImpl_GetDC,
649     IWineGDISurfaceImpl_ReleaseDC,
650     IWineGDISurfaceImpl_Flip,
651     IWineD3DBaseSurfaceImpl_Blt,
652     IWineD3DBaseSurfaceImpl_GetBltStatus,
653     IWineD3DBaseSurfaceImpl_GetFlipStatus,
654     IWineD3DBaseSurfaceImpl_IsLost,
655     IWineD3DBaseSurfaceImpl_Restore,
656     IWineD3DBaseSurfaceImpl_BltFast,
657     IWineD3DBaseSurfaceImpl_GetPalette,
658     IWineD3DBaseSurfaceImpl_SetPalette,
659     IWineGDISurfaceImpl_RealizePalette,
660     IWineD3DBaseSurfaceImpl_SetColorKey,
661     IWineD3DBaseSurfaceImpl_GetPitch,
662     IWineGDISurfaceImpl_SetMem,
663     IWineD3DBaseSurfaceImpl_SetOverlayPosition,
664     IWineD3DBaseSurfaceImpl_GetOverlayPosition,
665     IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder,
666     IWineD3DBaseSurfaceImpl_UpdateOverlay,
667     IWineD3DBaseSurfaceImpl_SetClipper,
668     IWineD3DBaseSurfaceImpl_GetClipper,
669     /* Internal use: */
670     IWineGDISurfaceImpl_LoadTexture,
671     IWineD3DBaseSurfaceImpl_BindTexture,
672     IWineGDISurfaceImpl_SaveSnapshot,
673     IWineD3DBaseSurfaceImpl_SetContainer,
674     IWineGDISurfaceImpl_GetGlDesc,
675     IWineD3DBaseSurfaceImpl_GetData,
676     IWineD3DBaseSurfaceImpl_SetFormat,
677     IWineGDISurfaceImpl_PrivateSetup,
678     IWineGDISurfaceImpl_ModifyLocation,
679     IWineGDISurfaceImpl_LoadLocation,
680     IWineGDISurfaceImpl_GetImplType,
681     IWineGDISurfaceImpl_DrawOverlay
682 };