Fixes for -Wmissing-declaration and -Wwrite-string warnings.
[wine] / dlls / ddraw / surface_user.c
1 /*      User-based primary surface driver
2  *
3  * Copyright 2000-2001 TransGaming Technologies Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #include "config.h"
21
22 #include <assert.h>
23 #include <stdlib.h>
24 #include <string.h>
25
26 #define CONST_VTABLE
27
28 #include "winerror.h"
29 #include "wine/debug.h"
30 #include "ddraw_private.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
33
34 /* if you use OWN_WINDOW, don't use SYNC_UPDATE, or you may get trouble */
35 /* #define SYNC_UPDATE */
36 /*
37  * FIXME: This does not work any more because the created window has its own
38  *        thread queue that cannot be manipulated by application threads.
39  * #define OWN_WINDOW
40  */
41
42 #ifdef OWN_WINDOW
43 static void User_create_own_window(IDirectDrawSurfaceImpl* This);
44 static void User_destroy_own_window(IDirectDrawSurfaceImpl* This);
45 #endif
46 #ifndef SYNC_UPDATE
47 static DWORD CALLBACK User_update_thread(LPVOID);
48 #endif
49 static void User_copy_to_screen(IDirectDrawSurfaceImpl* This, LPCRECT rc);
50
51 static HWND get_display_window(IDirectDrawSurfaceImpl* This, LPPOINT pt);
52
53 static const IDirectDrawSurface7Vtbl User_IDirectDrawSurface7_VTable;
54
55 HRESULT
56 User_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This,
57                                  IDirectDrawImpl* pDD,
58                                  const DDSURFACEDESC2* pDDSD)
59 {
60     USER_PRIV_VAR(priv, This);
61     HRESULT hr;
62
63     TRACE("(%p,%p,%p)\n",This,pDD,pDDSD);
64     hr = DIB_DirectDrawSurface_Construct(This, pDD, pDDSD);
65     if (FAILED(hr)) return hr;
66
67     ICOM_INIT_INTERFACE(This, IDirectDrawSurface7,
68                         User_IDirectDrawSurface7_VTable);
69
70     This->final_release = User_DirectDrawSurface_final_release;
71     This->duplicate_surface = User_DirectDrawSurface_duplicate_surface;
72
73     This->lock_update   = User_DirectDrawSurface_lock_update;
74     This->unlock_update = User_DirectDrawSurface_unlock_update;
75
76     This->flip_data   = User_DirectDrawSurface_flip_data;
77     This->flip_update = User_DirectDrawSurface_flip_update;
78
79     This->get_dc     = User_DirectDrawSurface_get_dc;
80     This->release_dc = User_DirectDrawSurface_release_dc;
81
82     This->set_palette    = User_DirectDrawSurface_set_palette;
83     This->update_palette = User_DirectDrawSurface_update_palette;
84
85     This->get_gamma_ramp = User_DirectDrawSurface_get_gamma_ramp;
86     This->set_gamma_ramp = User_DirectDrawSurface_set_gamma_ramp;
87
88     This->get_display_window = User_DirectDrawSurface_get_display_window;
89
90     if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
91     {
92 #ifdef OWN_WINDOW
93         DirectDrawSurface_RegisterClass();
94 #endif
95 #ifndef SYNC_UPDATE
96         InitializeCriticalSection(&priv->user.crit);
97         priv->user.refresh_event = CreateEventW(NULL, TRUE, FALSE, NULL);
98         priv->user.update_event = CreateEventW(NULL, FALSE, FALSE, NULL);
99         priv->user.update_thread = CreateThread(NULL, 0, User_update_thread, This, 0, NULL);
100 #ifdef OWN_WINDOW
101         if (This->ddraw_owner->cooperative_level & DDSCL_FULLSCREEN) {
102             /* wait for window creation (or update thread destruction) */
103             while (WaitForMultipleObjects(1, &priv->user.update_thread, FALSE, 100) == WAIT_TIMEOUT)
104                 if (This->more.lpDDRAWReserved) break;
105             if (!This->more.lpDDRAWReserved) {
106                 ERR("window creation failed\n");
107             }
108         }
109 #endif
110 #else
111 #ifdef OWN_WINDOW
112         User_create_own_window(This);
113 #endif
114 #endif
115         if (!This->more.lpDDRAWReserved)
116             This->more.lpDDRAWReserved = (LPVOID)pDD->window;
117     }
118
119     return DIB_DirectDrawSurface_alloc_dc(This, &priv->user.cached_dc);
120 }
121
122 HRESULT
123 User_DirectDrawSurface_Create(IDirectDrawImpl *pDD,
124                               const DDSURFACEDESC2 *pDDSD,
125                               LPDIRECTDRAWSURFACE7 *ppSurf,
126                               IUnknown *pUnkOuter)
127 {
128     IDirectDrawSurfaceImpl* This;
129     HRESULT hr;
130     assert(pUnkOuter == NULL);
131
132     This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
133                      sizeof(*This) + sizeof(User_DirectDrawSurfaceImpl));
134     if (This == NULL) return E_OUTOFMEMORY;
135
136     This->private = (User_DirectDrawSurfaceImpl*)(This+1);
137
138     hr = User_DirectDrawSurface_Construct(This, pDD, pDDSD);
139     if (FAILED(hr))
140         HeapFree(GetProcessHeap(), 0, This);
141     else
142         *ppSurf = ICOM_INTERFACE(This, IDirectDrawSurface7);
143
144     return hr;
145 }
146
147 void User_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This)
148 {
149     USER_PRIV_VAR(priv, This);
150
151     if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
152     {
153 #ifndef SYNC_UPDATE
154         HANDLE event = priv->user.update_event;
155         priv->user.update_event = 0;
156         SetEvent(event);
157         TRACE("waiting for update thread to terminate...\n");
158 #ifdef OWN_WINDOW
159         /* dispatch any waiting sendmessages */
160         {
161             MSG msg;
162             PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
163         }
164         /* to avoid deadlocks, allow SendMessages from update thread
165          * through while we wait for it */
166         while (MsgWaitForMultipleObjects(1, &priv->user.update_thread, FALSE,
167                                          INFINITE, QS_SENDMESSAGE) == WAIT_OBJECT_0+1)
168         {
169             MSG msg;
170             PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
171         }
172 #else
173         WaitForSingleObject(priv->user.update_thread,INFINITE);
174 #endif
175         TRACE("update thread terminated\n");
176         CloseHandle(event);
177         CloseHandle(priv->user.update_thread);
178         CloseHandle(priv->user.refresh_event);
179         DeleteCriticalSection(&priv->user.crit);
180 #else
181 #ifdef OWN_WINDOW
182         User_destroy_own_window(This);
183 #endif
184 #endif
185         This->more.lpDDRAWReserved = 0;
186 #ifdef OWN_WINDOW
187         DirectDrawSurface_UnregisterClass();
188 #endif
189     }
190     DIB_DirectDrawSurface_free_dc(This, priv->user.cached_dc);
191     DIB_DirectDrawSurface_final_release(This);
192 }
193
194 static int User_DirectDrawSurface_init_wait(IDirectDrawSurfaceImpl* This)
195 {
196     USER_PRIV_VAR(priv, This);
197     int need_wait;
198     EnterCriticalSection(&priv->user.crit);
199     priv->user.wait_count++;
200     need_wait = priv->user.in_refresh;
201     LeaveCriticalSection(&priv->user.crit);
202     return need_wait;
203 }
204
205 static void User_DirectDrawSurface_end_wait(IDirectDrawSurfaceImpl* This)
206 {
207     USER_PRIV_VAR(priv, This);
208     EnterCriticalSection(&priv->user.crit);
209     if (!--priv->user.wait_count)
210         ResetEvent(priv->user.refresh_event);
211     LeaveCriticalSection(&priv->user.crit);
212 }
213
214 static void User_DirectDrawSurface_wait_update(IDirectDrawSurfaceImpl* This)
215 {
216     USER_PRIV_VAR(priv, This);
217     if (priv->user.in_refresh) {
218         if (User_DirectDrawSurface_init_wait(This))
219             WaitForSingleObject(priv->user.refresh_event, 2);
220         User_DirectDrawSurface_end_wait(This);
221     }
222 }
223
224 void User_DirectDrawSurface_lock_update(IDirectDrawSurfaceImpl* This,
225                                         LPCRECT pRect, DWORD dwFlags)
226 {
227 #if 0
228     if (!(dwFlags & DDLOCK_WRITEONLY))
229         User_copy_from_screen(This, pRect);
230 #endif
231     if (dwFlags & DDLOCK_WAIT) User_DirectDrawSurface_wait_update(This);
232
233     if (pRect) {
234         This->lastlockrect = *pRect;
235     } else {
236         This->lastlockrect.left = This->lastlockrect.right = 0;
237     }
238 }
239
240 void User_DirectDrawSurface_unlock_update(IDirectDrawSurfaceImpl* This,
241                                           LPCRECT pRect)
242 {
243     if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
244     {
245 #ifdef SYNC_UPDATE
246         User_copy_to_screen(This, pRect);
247 #else
248         USER_PRIV_VAR(priv, This);
249         SetEvent(priv->user.update_event);
250 #endif
251     }
252 }
253
254 void User_DirectDrawSurface_set_palette(IDirectDrawSurfaceImpl* This,
255                                         IDirectDrawPaletteImpl* pal)
256 {
257     USER_PRIV_VAR(priv, This);
258
259     if (!pal) {
260         FIXME("selecting null palette\n");
261         /* I don't think selecting GDI object 0 will work, we should select
262          * the original palette, returned by the first SelectPalette */
263         SelectPalette(priv->user.cached_dc, 0, FALSE);
264         return;
265     }
266
267     SelectPalette(priv->user.cached_dc, pal->hpal, FALSE);
268
269     DIB_DirectDrawSurface_set_palette(This, pal);
270 }
271
272 void User_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This,
273                                            IDirectDrawPaletteImpl* pal,
274                                            DWORD dwStart, DWORD dwCount,
275                                            LPPALETTEENTRY palent)
276 {
277 #ifndef SYNC_UPDATE
278     USER_PRIV_VAR(priv, This);
279 #endif
280
281     DIB_DirectDrawSurface_update_palette(This, pal, dwStart, dwCount, palent);
282     /* FIXME: realize palette on display window */
283
284 #ifndef SYNC_UPDATE
285     /* with async updates, it's probably cool to force an update */
286     SetEvent(priv->user.update_event);
287 #endif
288 }
289
290 HRESULT User_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
291                                                  LPDIRECTDRAWSURFACE7* ppDup)
292 {
293     return User_DirectDrawSurface_Create(This->ddraw_owner,
294                                          &This->surface_desc, ppDup, NULL);
295 }
296
297 BOOL User_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front,
298                                       IDirectDrawSurfaceImpl* back,
299                                       DWORD dwFlags)
300 {
301     USER_PRIV_VAR(front_priv, front);
302     USER_PRIV_VAR(back_priv, back);
303
304     {
305         HDC tmp;
306         tmp = front_priv->user.cached_dc;
307         front_priv->user.cached_dc = back_priv->user.cached_dc;
308         back_priv->user.cached_dc = tmp;
309     }
310
311     return DIB_DirectDrawSurface_flip_data(front, back, dwFlags);
312 }
313
314 void User_DirectDrawSurface_flip_update(IDirectDrawSurfaceImpl* This, DWORD dwFlags)
315 {
316 #ifdef SYNC_UPDATE
317     This->lastlockrect.left = This->lastlockrect.right = 0;
318     assert(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE);
319     User_copy_to_screen(This,NULL);
320 #else
321     USER_PRIV_VAR(priv, This);
322     assert(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE);
323     if (dwFlags & DDFLIP_WAIT) User_DirectDrawSurface_wait_update(This);
324     This->lastlockrect.left = This->lastlockrect.right = 0;
325     SetEvent(priv->user.update_event);
326 #endif
327 }
328
329 HRESULT User_DirectDrawSurface_get_dc(IDirectDrawSurfaceImpl* This, HDC* phDC)
330 {
331     USER_PRIV_VAR(priv, This);
332
333     *phDC = priv->user.cached_dc;
334     return S_OK;
335 }
336
337 HRESULT User_DirectDrawSurface_release_dc(IDirectDrawSurfaceImpl* This,
338                                           HDC hDC)
339 {
340     return S_OK;
341 }
342
343 HRESULT User_DirectDrawSurface_get_gamma_ramp(IDirectDrawSurfaceImpl* This,
344                                               DWORD dwFlags,
345                                               LPDDGAMMARAMP lpGammaRamp)
346 {
347     if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
348     {
349         POINT offset;
350         HWND hDisplayWnd;
351         HDC hDisplayDC;
352         HRESULT hr;
353         hDisplayWnd = get_display_window(This, &offset);
354         hDisplayDC = GetDCEx(hDisplayWnd, 0, DCX_CLIPSIBLINGS|DCX_CACHE);
355         hr = GetDeviceGammaRamp(hDisplayDC, lpGammaRamp) ? DD_OK : DDERR_UNSUPPORTED;
356         ReleaseDC(hDisplayWnd, hDisplayDC);
357         return hr;
358     }
359     return Main_DirectDrawSurface_get_gamma_ramp(This, dwFlags, lpGammaRamp);
360 }
361
362 HRESULT User_DirectDrawSurface_set_gamma_ramp(IDirectDrawSurfaceImpl* This,
363                                               DWORD dwFlags,
364                                               LPDDGAMMARAMP lpGammaRamp)
365 {
366     if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
367     {
368         POINT offset;
369         HWND hDisplayWnd;
370         HDC hDisplayDC;
371         HRESULT hr;
372         hDisplayWnd = get_display_window(This, &offset);
373         hDisplayDC = GetDCEx(hDisplayWnd, 0, DCX_CLIPSIBLINGS|DCX_CACHE);
374         hr = SetDeviceGammaRamp(hDisplayDC, lpGammaRamp) ? DD_OK : DDERR_UNSUPPORTED;
375         ReleaseDC(hDisplayWnd, hDisplayDC);
376         return hr;
377     }
378     return Main_DirectDrawSurface_set_gamma_ramp(This, dwFlags, lpGammaRamp);
379 }
380
381 /* Returns the window that hosts the display.
382  * *pt is set to the upper left position of the window relative to the
383  * upper left corner of the surface. */
384 static HWND get_display_window(IDirectDrawSurfaceImpl* This, LPPOINT pt)
385 {
386     memset(pt, 0, sizeof(*pt));
387
388     if (This->ddraw_owner->cooperative_level & DDSCL_FULLSCREEN)
389     {
390 #ifdef OWN_WINDOW
391         USER_PRIV_VAR(priv, This);
392 #if 1
393         SetWindowPos(priv->user.window, HWND_TOP, 0, 0, 0, 0,
394                      SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|
395                      SWP_NOREDRAW|SWP_NOSENDCHANGING|SWP_NOSIZE);
396 #endif
397         return priv->user.window;
398 #else
399         return This->ddraw_owner->window;
400 #endif
401     }
402     else
403     {
404         if (This->clipper != NULL)
405         {
406             /* looks silly, but since we don't have the clipper locked */
407             HWND hWnd = This->clipper->hWnd;
408
409             if (hWnd != 0)
410             {
411                 ClientToScreen(hWnd, pt);
412                 return hWnd;
413             }
414             else
415             {
416                 static BOOL warn = 0;
417                 if (!warn++) FIXME("clipper clip lists not supported\n");
418
419                 return GetDesktopWindow();
420             }
421         }
422         else
423         {
424             static BOOL warn = 0;
425             if (!warn++) WARN("hosting on root\n");
426
427             return GetDesktopWindow();
428         }
429     }
430 }
431
432 HWND User_DirectDrawSurface_get_display_window(IDirectDrawSurfaceImpl* This)
433 {
434     POINT offset;
435     return get_display_window(This, &offset);
436 }
437
438 #ifdef OWN_WINDOW
439 static void User_create_own_window(IDirectDrawSurfaceImpl* This)
440 {
441     USER_PRIV_VAR(priv, This);
442
443     if (This->ddraw_owner->cooperative_level & DDSCL_FULLSCREEN)
444     {
445         priv->user.window = CreateWindowExA(WS_EX_TOPMOST |
446                                             WS_EX_LAYERED |
447                                             WS_EX_TRANSPARENT,
448                                             "WINE_DDRAW", "DirectDraw",
449                                             WS_POPUP,
450                                             0, 0,
451                                             This->surface_desc.dwWidth,
452                                             This->surface_desc.dwHeight,
453                                             GetDesktopWindow(),
454                                             0, 0, This);
455         This->more.lpDDRAWReserved = (LPVOID)priv->user.window;
456         SetWindowPos(priv->user.window, HWND_TOP, 0, 0, 0, 0,
457                      SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|
458                      SWP_NOREDRAW|SWP_NOSENDCHANGING|SWP_NOSIZE|SWP_SHOWWINDOW);
459         UpdateWindow(priv->user.window);
460     }
461 }
462
463 static void User_destroy_own_window(IDirectDrawSurfaceImpl* This)
464 {
465     USER_PRIV_VAR(priv, This);
466
467     if (priv->user.window)
468     {
469         SetWindowPos(priv->user.window, 0, 0, 0, 0, 0,
470                      SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|
471                      SWP_NOREDRAW|SWP_NOSENDCHANGING|SWP_NOSIZE|SWP_HIDEWINDOW);
472         This->more.lpDDRAWReserved = NULL;
473         DestroyWindow(priv->user.window);
474         priv->user.window = 0;
475     }
476 }
477 #endif
478
479 #ifndef SYNC_UPDATE
480 static DWORD CALLBACK User_update_thread(LPVOID arg)
481 {
482     IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)arg;
483     USER_PRIV_VAR(priv, This);
484     volatile HANDLE *pActive = (volatile HANDLE *)&priv->user.update_event;
485     HANDLE event = *pActive;
486
487 #ifdef OWN_WINDOW
488     User_create_own_window(This);
489 #endif
490
491     /* the point of this is that many games lock the primary surface
492      * multiple times per frame; this thread will then simply copy as
493      * often as it can without keeping the main thread waiting for
494      * each unlock, thus keeping the frame rate high */
495     do {
496 #ifdef OWN_WINDOW
497         DWORD ret = MsgWaitForMultipleObjects(1, &event, FALSE, INFINITE, QS_ALLINPUT);
498         MSG msg;
499
500         while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
501         {
502             switch (msg.message) {
503             case WM_PAINT:
504                 DispatchMessageA(&msg);
505                 break;
506             default:
507                 /* since we risk getting keyboard messages posted to us,
508                  * repost posted messages to cooperative window */
509                 PostMessageA(This->ddraw_owner->window, msg.message, msg.wParam, msg.lParam);
510             }
511         }
512 #else
513         DWORD ret = WaitForSingleObject(event, INFINITE);
514 #endif
515         if (ret == WAIT_OBJECT_0)
516         {
517             if (*pActive) {
518                 priv->user.in_refresh = TRUE;
519                 User_copy_to_screen(This, NULL);
520                 EnterCriticalSection(&priv->user.crit);
521                 priv->user.in_refresh = FALSE;
522                 if (priv->user.wait_count)
523                     SetEvent(priv->user.refresh_event);
524                 LeaveCriticalSection(&priv->user.crit);
525             } else
526                 break;
527         }
528         else if (ret != WAIT_OBJECT_0+1) break;
529     } while (TRUE);
530
531     SetEvent(priv->user.refresh_event);
532 #ifdef OWN_WINDOW
533     User_destroy_own_window(This);
534 #endif
535
536     return 0;
537 }
538 #endif
539
540 static void User_copy_to_screen(IDirectDrawSurfaceImpl* This, LPCRECT rc)
541 {
542     if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
543     {
544         POINT offset;
545         HWND hDisplayWnd;
546         HDC hDisplayDC;
547         HDC hSurfaceDC;
548         RECT drawrect;
549
550         if (FAILED(This->get_dc(This, &hSurfaceDC)))
551             return;
552
553         hDisplayWnd = get_display_window(This, &offset);
554         hDisplayDC = GetDCEx(hDisplayWnd, 0, DCX_CLIPSIBLINGS|DCX_CACHE);
555 #if 0
556         /* FIXME: this doesn't work... if users really want to run
557          * X in 8bpp, then we need to call directly into display.drv
558          * (or Wine's equivalent), and force a private colormap
559          * without default entries. */
560         if (This->palette) {
561             SelectPalette(hDisplayDC, This->palette->hpal, FALSE);
562             RealizePalette(hDisplayDC); /* sends messages => deadlocks */
563         }
564 #endif
565         drawrect.left   = 0;
566         drawrect.right  = This->surface_desc.dwWidth;
567         drawrect.top    = 0;
568         drawrect.bottom = This->surface_desc.dwHeight;
569
570         if (This->clipper) {
571             RECT xrc;
572             HWND hwnd = This->clipper->hWnd;
573             if (hwnd && GetClientRect(hwnd,&xrc)) {
574                 OffsetRect(&xrc,offset.x,offset.y);
575                 IntersectRect(&drawrect,&drawrect,&xrc);
576             }
577         }
578         if (rc)
579             IntersectRect(&drawrect,&drawrect,rc);
580         else {
581             /* Only use this if the caller did not pass a rectangle, since
582              * due to double locking this could be the wrong one ... */
583             if (This->lastlockrect.left != This->lastlockrect.right)
584                 IntersectRect(&drawrect,&drawrect,&This->lastlockrect);
585         }
586         BitBlt(hDisplayDC,
587                 drawrect.left-offset.x, drawrect.top-offset.y,
588                 drawrect.right-drawrect.left, drawrect.bottom-drawrect.top,
589                 hSurfaceDC,
590                 drawrect.left, drawrect.top,
591                 SRCCOPY
592         );
593         ReleaseDC(hDisplayWnd, hDisplayDC);
594     }
595 }
596
597 #if 0
598 static void User_copy_from_screen(IDirectDrawSurfaceImpl* This, LPCRECT rc)
599 {
600     if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
601     {
602         POINT offset;
603         HWND hDisplayWnd = get_display_window(This, &offset);
604         HDC hDisplayDC = GetDC(hDisplayWnd);
605         RECT drawrect;
606
607         drawrect.left   = 0;
608         drawrect.right  = This->surface_desc.dwWidth;
609         drawrect.top    = 0;
610         drawrect.bottom = This->surface_desc.dwHeight;
611         if (rc)
612             IntersectRect(&drawrect,&drawrect,rc);
613
614         BitBlt(This->hDC,
615             drawrect.left, drawrect.top,
616             drawrect.right-drawrect.left, drawrect.bottom-drawrect.top,
617             hDisplayDC,
618             drawrect.left+offset.x, drawrect.top+offset.y,
619             SRCCOPY
620         );
621         ReleaseDC(hDisplayWnd, hDisplayDC);
622     }
623 }
624 #endif
625
626 static const IDirectDrawSurface7Vtbl User_IDirectDrawSurface7_VTable =
627 {
628     Main_DirectDrawSurface_QueryInterface,
629     Main_DirectDrawSurface_AddRef,
630     Main_DirectDrawSurface_Release,
631     Main_DirectDrawSurface_AddAttachedSurface,
632     Main_DirectDrawSurface_AddOverlayDirtyRect,
633     DIB_DirectDrawSurface_Blt,
634     Main_DirectDrawSurface_BltBatch,
635     DIB_DirectDrawSurface_BltFast,
636     Main_DirectDrawSurface_DeleteAttachedSurface,
637     Main_DirectDrawSurface_EnumAttachedSurfaces,
638     Main_DirectDrawSurface_EnumOverlayZOrders,
639     Main_DirectDrawSurface_Flip,
640     Main_DirectDrawSurface_GetAttachedSurface,
641     Main_DirectDrawSurface_GetBltStatus,
642     Main_DirectDrawSurface_GetCaps,
643     Main_DirectDrawSurface_GetClipper,
644     Main_DirectDrawSurface_GetColorKey,
645     Main_DirectDrawSurface_GetDC,
646     Main_DirectDrawSurface_GetFlipStatus,
647     Main_DirectDrawSurface_GetOverlayPosition,
648     Main_DirectDrawSurface_GetPalette,
649     Main_DirectDrawSurface_GetPixelFormat,
650     Main_DirectDrawSurface_GetSurfaceDesc,
651     Main_DirectDrawSurface_Initialize,
652     Main_DirectDrawSurface_IsLost,
653     Main_DirectDrawSurface_Lock,
654     Main_DirectDrawSurface_ReleaseDC,
655     DIB_DirectDrawSurface_Restore,
656     Main_DirectDrawSurface_SetClipper,
657     Main_DirectDrawSurface_SetColorKey,
658     Main_DirectDrawSurface_SetOverlayPosition,
659     Main_DirectDrawSurface_SetPalette,
660     Main_DirectDrawSurface_Unlock,
661     Main_DirectDrawSurface_UpdateOverlay,
662     Main_DirectDrawSurface_UpdateOverlayDisplay,
663     Main_DirectDrawSurface_UpdateOverlayZOrder,
664     Main_DirectDrawSurface_GetDDInterface,
665     Main_DirectDrawSurface_PageLock,
666     Main_DirectDrawSurface_PageUnlock,
667     DIB_DirectDrawSurface_SetSurfaceDesc,
668     Main_DirectDrawSurface_SetPrivateData,
669     Main_DirectDrawSurface_GetPrivateData,
670     Main_DirectDrawSurface_FreePrivateData,
671     Main_DirectDrawSurface_GetUniquenessValue,
672     Main_DirectDrawSurface_ChangeUniquenessValue,
673     Main_DirectDrawSurface_SetPriority,
674     Main_DirectDrawSurface_GetPriority,
675     Main_DirectDrawSurface_SetLOD,
676     Main_DirectDrawSurface_GetLOD
677 };