Wait for the asynchronous update thread to complete if the app
[wine/hacks.git] / dlls / ddraw / dsurface / user.c
blob90a0cea65d3da8d5cbd409ae8546ff3b1d982d41
1 /* User-based primary surface driver
3 * Copyright 2000-2001 TransGaming Technologies Inc.
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.
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.
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
20 #include "config.h"
22 #include <assert.h>
23 #include <stdlib.h>
24 #include <string.h>
26 #include "winerror.h"
27 #include "wine/debug.h"
28 #include "ddraw_private.h"
29 #include "dsurface/main.h"
30 #include "dsurface/dib.h"
31 #include "dsurface/user.h"
32 #include "dsurface/wndproc.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
36 /* if you use OWN_WINDOW, don't use SYNC_UPDATE, or you may get trouble */
37 /* #define SYNC_UPDATE */
39 * FIXME: This does not work any more because the created window has its own
40 * thread queue that cannot be manipulated by application threads.
41 * #define OWN_WINDOW
44 #ifdef OWN_WINDOW
45 static void User_create_own_window(IDirectDrawSurfaceImpl* This);
46 static void User_destroy_own_window(IDirectDrawSurfaceImpl* This);
47 #endif
48 #ifndef SYNC_UPDATE
49 static DWORD CALLBACK User_update_thread(LPVOID);
50 #endif
51 static void User_copy_to_screen(IDirectDrawSurfaceImpl* This, LPCRECT rc);
52 static void User_copy_from_screen(IDirectDrawSurfaceImpl* This, LPCRECT rc);
54 static HWND get_display_window(IDirectDrawSurfaceImpl* This, LPPOINT pt);
56 static ICOM_VTABLE(IDirectDrawSurface7) User_IDirectDrawSurface7_VTable;
58 HRESULT
59 User_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This,
60 IDirectDrawImpl* pDD,
61 const DDSURFACEDESC2* pDDSD)
63 USER_PRIV_VAR(priv, This);
64 HRESULT hr;
66 TRACE("(%p,%p,%p)\n",This,pDD,pDDSD);
67 hr = DIB_DirectDrawSurface_Construct(This, pDD, pDDSD);
68 if (FAILED(hr)) return hr;
70 ICOM_INIT_INTERFACE(This, IDirectDrawSurface7,
71 User_IDirectDrawSurface7_VTable);
73 This->final_release = User_DirectDrawSurface_final_release;
74 This->duplicate_surface = User_DirectDrawSurface_duplicate_surface;
76 This->lock_update = User_DirectDrawSurface_lock_update;
77 This->unlock_update = User_DirectDrawSurface_unlock_update;
79 This->flip_data = User_DirectDrawSurface_flip_data;
80 This->flip_update = User_DirectDrawSurface_flip_update;
82 This->get_dc = User_DirectDrawSurface_get_dc;
83 This->release_dc = User_DirectDrawSurface_release_dc;
85 This->set_palette = User_DirectDrawSurface_set_palette;
86 This->update_palette = User_DirectDrawSurface_update_palette;
88 This->get_gamma_ramp = User_DirectDrawSurface_get_gamma_ramp;
89 This->set_gamma_ramp = User_DirectDrawSurface_set_gamma_ramp;
91 This->get_display_window = User_DirectDrawSurface_get_display_window;
93 if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
95 #ifdef OWN_WINDOW
96 DirectDrawSurface_RegisterClass();
97 #endif
98 #ifndef SYNC_UPDATE
99 InitializeCriticalSection(&priv->user.crit);
100 priv->user.refresh_event = CreateEventA(NULL, TRUE, FALSE, NULL);
101 priv->user.update_event = CreateEventA(NULL, FALSE, FALSE, NULL);
102 priv->user.update_thread = CreateThread(NULL, 0, User_update_thread, This, 0, NULL);
103 #ifdef OWN_WINDOW
104 if (This->ddraw_owner->cooperative_level & DDSCL_FULLSCREEN) {
105 /* wait for window creation (or update thread destruction) */
106 while (WaitForMultipleObjects(1, &priv->user.update_thread, FALSE, 100) == WAIT_TIMEOUT)
107 if (This->more.lpDDRAWReserved) break;
108 if (!This->more.lpDDRAWReserved) {
109 ERR("window creation failed\n");
112 #endif
113 #else
114 #ifdef OWN_WINDOW
115 User_create_own_window(This);
116 #endif
117 #endif
118 if (!This->more.lpDDRAWReserved)
119 This->more.lpDDRAWReserved = (LPVOID)pDD->window;
122 return DIB_DirectDrawSurface_alloc_dc(This, &priv->user.cached_dc);
125 HRESULT
126 User_DirectDrawSurface_Create(IDirectDrawImpl *pDD,
127 const DDSURFACEDESC2 *pDDSD,
128 LPDIRECTDRAWSURFACE7 *ppSurf,
129 IUnknown *pUnkOuter)
131 IDirectDrawSurfaceImpl* This;
132 HRESULT hr;
133 assert(pUnkOuter == NULL);
135 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
136 sizeof(*This) + sizeof(User_DirectDrawSurfaceImpl));
137 if (This == NULL) return E_OUTOFMEMORY;
139 This->private = (User_DirectDrawSurfaceImpl*)(This+1);
141 hr = User_DirectDrawSurface_Construct(This, pDD, pDDSD);
142 if (FAILED(hr))
143 HeapFree(GetProcessHeap(), 0, This);
144 else
145 *ppSurf = ICOM_INTERFACE(This, IDirectDrawSurface7);
147 return hr;
150 void User_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This)
152 USER_PRIV_VAR(priv, This);
154 if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
156 #ifndef SYNC_UPDATE
157 HANDLE event = priv->user.update_event;
158 priv->user.update_event = 0;
159 SetEvent(event);
160 TRACE("waiting for update thread to terminate...\n");
161 #ifdef OWN_WINDOW
162 /* dispatch any waiting sendmessages */
164 MSG msg;
165 PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
167 /* to avoid deadlocks, allow SendMessages from update thread
168 * through while we wait for it */
169 while (MsgWaitForMultipleObjects(1, &priv->user.update_thread, FALSE,
170 INFINITE, QS_SENDMESSAGE) == WAIT_OBJECT_0+1)
172 MSG msg;
173 PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
175 #else
176 WaitForSingleObject(priv->user.update_thread,INFINITE);
177 #endif
178 TRACE("update thread terminated\n");
179 CloseHandle(event);
180 CloseHandle(priv->user.update_thread);
181 CloseHandle(priv->user.refresh_event);
182 DeleteCriticalSection(&priv->user.crit);
183 #else
184 #ifdef OWN_WINDOW
185 User_destroy_own_window(This);
186 #endif
187 #endif
188 This->more.lpDDRAWReserved = 0;
189 #ifdef OWN_WINDOW
190 DirectDrawSurface_UnregisterClass();
191 #endif
193 DIB_DirectDrawSurface_free_dc(This, priv->user.cached_dc);
194 DIB_DirectDrawSurface_final_release(This);
197 static int User_DirectDrawSurface_init_wait(IDirectDrawSurfaceImpl* This)
199 USER_PRIV_VAR(priv, This);
200 int need_wait;
201 EnterCriticalSection(&priv->user.crit);
202 priv->user.wait_count++;
203 need_wait = priv->user.in_refresh;
204 LeaveCriticalSection(&priv->user.crit);
205 return need_wait;
208 static void User_DirectDrawSurface_end_wait(IDirectDrawSurfaceImpl* This)
210 USER_PRIV_VAR(priv, This);
211 EnterCriticalSection(&priv->user.crit);
212 if (!--priv->user.wait_count)
213 ResetEvent(priv->user.refresh_event);
214 LeaveCriticalSection(&priv->user.crit);
217 static void User_DirectDrawSurface_wait_update(IDirectDrawSurfaceImpl* This)
219 USER_PRIV_VAR(priv, This);
220 if (priv->user.in_refresh) {
221 if (User_DirectDrawSurface_init_wait(This))
222 WaitForSingleObject(priv->user.refresh_event, 2);
223 User_DirectDrawSurface_end_wait(This);
227 void User_DirectDrawSurface_lock_update(IDirectDrawSurfaceImpl* This,
228 LPCRECT pRect, DWORD dwFlags)
230 #if 0
231 if (!(dwFlags & DDLOCK_WRITEONLY))
232 User_copy_from_screen(This, pRect);
233 #endif
234 if (dwFlags & DDLOCK_WAIT) User_DirectDrawSurface_wait_update(This);
236 if (pRect) {
237 This->lastlockrect = *pRect;
238 } else {
239 This->lastlockrect.left = This->lastlockrect.right = 0;
243 void User_DirectDrawSurface_unlock_update(IDirectDrawSurfaceImpl* This,
244 LPCRECT pRect)
246 if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
248 #ifdef SYNC_UPDATE
249 User_copy_to_screen(This, pRect);
250 #else
251 USER_PRIV_VAR(priv, This);
252 SetEvent(priv->user.update_event);
253 #endif
257 void User_DirectDrawSurface_set_palette(IDirectDrawSurfaceImpl* This,
258 IDirectDrawPaletteImpl* pal)
260 USER_PRIV_VAR(priv, This);
262 if (!pal) {
263 FIXME("selecting null palette\n");
264 /* I don't think selecting GDI object 0 will work, we should select
265 * the original palette, returned by the first SelectPalette */
266 SelectPalette(priv->user.cached_dc, 0, FALSE);
267 return;
270 SelectPalette(priv->user.cached_dc, pal->hpal, FALSE);
272 DIB_DirectDrawSurface_set_palette(This, pal);
275 void User_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This,
276 IDirectDrawPaletteImpl* pal,
277 DWORD dwStart, DWORD dwCount,
278 LPPALETTEENTRY palent)
280 #ifndef SYNC_UPDATE
281 USER_PRIV_VAR(priv, This);
282 #endif
284 DIB_DirectDrawSurface_update_palette(This, pal, dwStart, dwCount, palent);
285 /* FIXME: realize palette on display window */
287 #ifndef SYNC_UPDATE
288 /* with async updates, it's probably cool to force an update */
289 SetEvent(priv->user.update_event);
290 #endif
293 HRESULT User_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
294 LPDIRECTDRAWSURFACE7* ppDup)
296 return User_DirectDrawSurface_Create(This->ddraw_owner,
297 &This->surface_desc, ppDup, NULL);
300 BOOL User_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front,
301 IDirectDrawSurfaceImpl* back,
302 DWORD dwFlags)
304 USER_PRIV_VAR(front_priv, front);
305 USER_PRIV_VAR(back_priv, back);
308 HDC tmp;
309 tmp = front_priv->user.cached_dc;
310 front_priv->user.cached_dc = back_priv->user.cached_dc;
311 back_priv->user.cached_dc = tmp;
314 return DIB_DirectDrawSurface_flip_data(front, back, dwFlags);
317 void User_DirectDrawSurface_flip_update(IDirectDrawSurfaceImpl* This, DWORD dwFlags)
319 #ifdef SYNC_UPDATE
320 This->lastlockrect.left = This->lastlockrect.right = 0;
321 assert(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE);
322 User_copy_to_screen(This,NULL);
323 #else
324 USER_PRIV_VAR(priv, This);
325 assert(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE);
326 if (dwFlags & DDFLIP_WAIT) User_DirectDrawSurface_wait_update(This);
327 This->lastlockrect.left = This->lastlockrect.right = 0;
328 SetEvent(priv->user.update_event);
329 #endif
332 HRESULT User_DirectDrawSurface_get_dc(IDirectDrawSurfaceImpl* This, HDC* phDC)
334 USER_PRIV_VAR(priv, This);
336 *phDC = priv->user.cached_dc;
337 return S_OK;
340 HRESULT User_DirectDrawSurface_release_dc(IDirectDrawSurfaceImpl* This,
341 HDC hDC)
343 return S_OK;
346 HRESULT User_DirectDrawSurface_get_gamma_ramp(IDirectDrawSurfaceImpl* This,
347 DWORD dwFlags,
348 LPDDGAMMARAMP lpGammaRamp)
350 if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
352 POINT offset;
353 HWND hDisplayWnd;
354 HDC hDisplayDC;
355 HRESULT hr;
356 hDisplayWnd = get_display_window(This, &offset);
357 hDisplayDC = GetDCEx(hDisplayWnd, 0, DCX_CLIPSIBLINGS|DCX_CACHE);
358 hr = GetDeviceGammaRamp(hDisplayDC, lpGammaRamp) ? DD_OK : DDERR_UNSUPPORTED;
359 ReleaseDC(hDisplayWnd, hDisplayDC);
360 return hr;
362 return Main_DirectDrawSurface_get_gamma_ramp(This, dwFlags, lpGammaRamp);
365 HRESULT User_DirectDrawSurface_set_gamma_ramp(IDirectDrawSurfaceImpl* This,
366 DWORD dwFlags,
367 LPDDGAMMARAMP lpGammaRamp)
369 if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
371 POINT offset;
372 HWND hDisplayWnd;
373 HDC hDisplayDC;
374 HRESULT hr;
375 hDisplayWnd = get_display_window(This, &offset);
376 hDisplayDC = GetDCEx(hDisplayWnd, 0, DCX_CLIPSIBLINGS|DCX_CACHE);
377 hr = SetDeviceGammaRamp(hDisplayDC, lpGammaRamp) ? DD_OK : DDERR_UNSUPPORTED;
378 ReleaseDC(hDisplayWnd, hDisplayDC);
379 return hr;
381 return Main_DirectDrawSurface_set_gamma_ramp(This, dwFlags, lpGammaRamp);
384 /* Returns the window that hosts the display.
385 * *pt is set to the upper left position of the window relative to the
386 * upper left corner of the surface. */
387 static HWND get_display_window(IDirectDrawSurfaceImpl* This, LPPOINT pt)
389 memset(pt, 0, sizeof(*pt));
391 if (This->ddraw_owner->cooperative_level & DDSCL_FULLSCREEN)
393 #ifdef OWN_WINDOW
394 USER_PRIV_VAR(priv, This);
395 #if 1
396 SetWindowPos(priv->user.window, HWND_TOP, 0, 0, 0, 0,
397 SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|
398 SWP_NOREDRAW|SWP_NOSENDCHANGING|SWP_NOSIZE);
399 #endif
400 return priv->user.window;
401 #else
402 return This->ddraw_owner->window;
403 #endif
405 else
407 if (This->clipper != NULL)
409 /* looks silly, but since we don't have the clipper locked */
410 HWND hWnd = This->clipper->hWnd;
412 if (hWnd != 0)
414 ClientToScreen(hWnd, pt);
415 return hWnd;
417 else
419 static BOOL warn = 0;
420 if (!warn++) FIXME("clipper clip lists not supported\n");
422 return GetDesktopWindow();
425 else
427 static BOOL warn = 0;
428 if (!warn++) WARN("hosting on root\n");
430 return GetDesktopWindow();
435 HWND User_DirectDrawSurface_get_display_window(IDirectDrawSurfaceImpl* This)
437 POINT offset;
438 return get_display_window(This, &offset);
441 #ifdef OWN_WINDOW
442 static void User_create_own_window(IDirectDrawSurfaceImpl* This)
444 USER_PRIV_VAR(priv, This);
446 if (This->ddraw_owner->cooperative_level & DDSCL_FULLSCREEN)
448 priv->user.window = CreateWindowExA(WS_EX_TOPMOST |
449 WS_EX_LAYERED |
450 WS_EX_TRANSPARENT,
451 "WINE_DDRAW", "DirectDraw",
452 WS_POPUP,
453 0, 0,
454 This->surface_desc.dwWidth,
455 This->surface_desc.dwHeight,
456 GetDesktopWindow(),
457 0, 0, This);
458 This->more.lpDDRAWReserved = (LPVOID)priv->user.window;
459 SetWindowPos(priv->user.window, HWND_TOP, 0, 0, 0, 0,
460 SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|
461 SWP_NOREDRAW|SWP_NOSENDCHANGING|SWP_NOSIZE|SWP_SHOWWINDOW);
462 UpdateWindow(priv->user.window);
466 static void User_destroy_own_window(IDirectDrawSurfaceImpl* This)
468 USER_PRIV_VAR(priv, This);
470 if (priv->user.window)
472 SetWindowPos(priv->user.window, 0, 0, 0, 0, 0,
473 SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|
474 SWP_NOREDRAW|SWP_NOSENDCHANGING|SWP_NOSIZE|SWP_HIDEWINDOW);
475 This->more.lpDDRAWReserved = NULL;
476 DestroyWindow(priv->user.window);
477 priv->user.window = 0;
480 #endif
482 #ifndef SYNC_UPDATE
483 static DWORD CALLBACK User_update_thread(LPVOID arg)
485 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)arg;
486 USER_PRIV_VAR(priv, This);
487 volatile DWORD *pActive = (volatile DWORD *)&priv->user.update_event;
488 HANDLE event = *pActive;
490 #ifdef OWN_WINDOW
491 User_create_own_window(This);
492 #endif
494 /* the point of this is that many games lock the primary surface
495 * multiple times per frame; this thread will then simply copy as
496 * often as it can without keeping the main thread waiting for
497 * each unlock, thus keeping the frame rate high */
498 do {
499 #ifdef OWN_WINDOW
500 DWORD ret = MsgWaitForMultipleObjects(1, &event, FALSE, INFINITE, QS_ALLINPUT);
501 MSG msg;
503 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
505 switch (msg.message) {
506 case WM_PAINT:
507 DispatchMessageA(&msg);
508 break;
509 default:
510 /* since we risk getting keyboard messages posted to us,
511 * repost posted messages to cooperative window */
512 PostMessageA(This->ddraw_owner->window, msg.message, msg.wParam, msg.lParam);
515 #else
516 DWORD ret = WaitForSingleObject(event, INFINITE);
517 #endif
518 if (ret == WAIT_OBJECT_0)
520 if (*pActive) {
521 priv->user.in_refresh = TRUE;
522 User_copy_to_screen(This, NULL);
523 EnterCriticalSection(&priv->user.crit);
524 priv->user.in_refresh = FALSE;
525 if (priv->user.wait_count)
526 SetEvent(priv->user.refresh_event);
527 LeaveCriticalSection(&priv->user.crit);
528 } else
529 break;
531 else if (ret != WAIT_OBJECT_0+1) break;
532 } while (TRUE);
534 SetEvent(priv->user.refresh_event);
535 #ifdef OWN_WINDOW
536 User_destroy_own_window(This);
537 #endif
539 return 0;
541 #endif
543 static void User_copy_to_screen(IDirectDrawSurfaceImpl* This, LPCRECT rc)
545 if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
547 POINT offset;
548 HWND hDisplayWnd;
549 HDC hDisplayDC;
550 HDC hSurfaceDC;
551 RECT drawrect;
553 if (FAILED(This->get_dc(This, &hSurfaceDC)))
554 return;
556 hDisplayWnd = get_display_window(This, &offset);
557 hDisplayDC = GetDCEx(hDisplayWnd, 0, DCX_CLIPSIBLINGS|DCX_CACHE);
558 #if 0
559 /* FIXME: this doesn't work... if users really want to run
560 * X in 8bpp, then we need to call directly into display.drv
561 * (or Wine's equivalent), and force a private colormap
562 * without default entries. */
563 if (This->palette) {
564 SelectPalette(hDisplayDC, This->palette->hpal, FALSE);
565 RealizePalette(hDisplayDC); /* sends messages => deadlocks */
567 #endif
568 drawrect.left = 0;
569 drawrect.right = This->surface_desc.dwWidth;
570 drawrect.top = 0;
571 drawrect.bottom = This->surface_desc.dwHeight;
573 if (This->clipper) {
574 RECT xrc;
575 HWND hwnd = This->clipper->hWnd;
576 if (hwnd && GetClientRect(hwnd,&xrc)) {
577 OffsetRect(&xrc,offset.x,offset.y);
578 IntersectRect(&drawrect,&drawrect,&xrc);
581 if (rc)
582 IntersectRect(&drawrect,&drawrect,rc);
583 else {
584 /* Only use this if the caller did not pass a rectangle, since
585 * due to double locking this could be the wrong one ... */
586 if (This->lastlockrect.left != This->lastlockrect.right)
587 IntersectRect(&drawrect,&drawrect,&This->lastlockrect);
589 BitBlt(hDisplayDC,
590 drawrect.left-offset.x, drawrect.top-offset.y,
591 drawrect.right-drawrect.left, drawrect.bottom-drawrect.top,
592 hSurfaceDC,
593 drawrect.left, drawrect.top,
594 SRCCOPY
596 ReleaseDC(hDisplayWnd, hDisplayDC);
600 static void User_copy_from_screen(IDirectDrawSurfaceImpl* This, LPCRECT rc)
602 if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
604 POINT offset;
605 HWND hDisplayWnd = get_display_window(This, &offset);
606 HDC hDisplayDC = GetDC(hDisplayWnd);
607 RECT drawrect;
609 drawrect.left = 0;
610 drawrect.right = This->surface_desc.dwWidth;
611 drawrect.top = 0;
612 drawrect.bottom = This->surface_desc.dwHeight;
613 if (rc)
614 IntersectRect(&drawrect,&drawrect,rc);
616 BitBlt(This->hDC,
617 drawrect.left, drawrect.top,
618 drawrect.right-drawrect.left, drawrect.bottom-drawrect.top,
619 hDisplayDC,
620 drawrect.left+offset.x, drawrect.top+offset.y,
621 SRCCOPY
623 ReleaseDC(hDisplayWnd, hDisplayDC);
627 static ICOM_VTABLE(IDirectDrawSurface7) User_IDirectDrawSurface7_VTable =
629 Main_DirectDrawSurface_QueryInterface,
630 Main_DirectDrawSurface_AddRef,
631 Main_DirectDrawSurface_Release,
632 Main_DirectDrawSurface_AddAttachedSurface,
633 Main_DirectDrawSurface_AddOverlayDirtyRect,
634 DIB_DirectDrawSurface_Blt,
635 Main_DirectDrawSurface_BltBatch,
636 DIB_DirectDrawSurface_BltFast,
637 Main_DirectDrawSurface_DeleteAttachedSurface,
638 Main_DirectDrawSurface_EnumAttachedSurfaces,
639 Main_DirectDrawSurface_EnumOverlayZOrders,
640 Main_DirectDrawSurface_Flip,
641 Main_DirectDrawSurface_GetAttachedSurface,
642 Main_DirectDrawSurface_GetBltStatus,
643 Main_DirectDrawSurface_GetCaps,
644 Main_DirectDrawSurface_GetClipper,
645 Main_DirectDrawSurface_GetColorKey,
646 Main_DirectDrawSurface_GetDC,
647 Main_DirectDrawSurface_GetFlipStatus,
648 Main_DirectDrawSurface_GetOverlayPosition,
649 Main_DirectDrawSurface_GetPalette,
650 Main_DirectDrawSurface_GetPixelFormat,
651 Main_DirectDrawSurface_GetSurfaceDesc,
652 Main_DirectDrawSurface_Initialize,
653 Main_DirectDrawSurface_IsLost,
654 Main_DirectDrawSurface_Lock,
655 Main_DirectDrawSurface_ReleaseDC,
656 DIB_DirectDrawSurface_Restore,
657 Main_DirectDrawSurface_SetClipper,
658 Main_DirectDrawSurface_SetColorKey,
659 Main_DirectDrawSurface_SetOverlayPosition,
660 Main_DirectDrawSurface_SetPalette,
661 Main_DirectDrawSurface_Unlock,
662 Main_DirectDrawSurface_UpdateOverlay,
663 Main_DirectDrawSurface_UpdateOverlayDisplay,
664 Main_DirectDrawSurface_UpdateOverlayZOrder,
665 Main_DirectDrawSurface_GetDDInterface,
666 Main_DirectDrawSurface_PageLock,
667 Main_DirectDrawSurface_PageUnlock,
668 DIB_DirectDrawSurface_SetSurfaceDesc,
669 Main_DirectDrawSurface_SetPrivateData,
670 Main_DirectDrawSurface_GetPrivateData,
671 Main_DirectDrawSurface_FreePrivateData,
672 Main_DirectDrawSurface_GetUniquenessValue,
673 Main_DirectDrawSurface_ChangeUniquenessValue,
674 Main_DirectDrawSurface_SetPriority,
675 Main_DirectDrawSurface_GetPriority,
676 Main_DirectDrawSurface_SetLOD,
677 Main_DirectDrawSurface_GetLOD