Make 16-bit task properly inherit the current directory of their
[wine] / dlls / ddraw / ddraw_private.h
1 /*
2  * Copyright 2000-2001 TransGaming Technologies Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
20 #define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
21
22 /* MAY NOT CONTAIN X11 or DGA specific includes/defines/structs! */
23
24 #include <stdarg.h>
25 #include <stdio.h>
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wtypes.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "ddraw.h"
33 #include "d3d.h"
34 #include "ddcomimpl.h"
35 #include "ddrawi.h"
36
37 /* XXX Put this somewhere proper. */
38 #define DD_STRUCT_INIT(x)                       \
39         do {                                    \
40                 memset((x), 0, sizeof(*(x)));   \
41                 (x)->dwSize = sizeof(*x);       \
42         } while (0)
43
44 #define DD_STRUCT_COPY_BYSIZE(to,from)                  \
45         do {                                            \
46                 DWORD __size = (to)->dwSize;            \
47                 DWORD __copysize = __size;              \
48                 DWORD __resetsize = __size;             \
49                 if (__resetsize > sizeof(*to))          \
50                     __resetsize = sizeof(*to);          \
51                 memset(to,0,__resetsize);               \
52                 if ((from)->dwSize < __size)            \
53                     __copysize = (from)->dwSize;        \
54                 memcpy(to,from,__copysize);             \
55                 (to)->dwSize = __size;/*restore size*/  \
56         } while (0)
57
58 #define MAKE_FOURCC(a,b,c,d) ((a << 0) | (b << 8) | (c << 16) | (d << 24))
59
60 /*****************************************************************************
61  * IDirectDraw implementation structure
62  */
63
64 typedef struct IDirectDrawImpl IDirectDrawImpl;
65 typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl;
66 typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl;
67 typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl;
68 typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl;
69
70 typedef void (*pixel_convert_func)(void *src, void *dst, DWORD width,
71                                    DWORD height, LONG pitch,
72                                    IDirectDrawPaletteImpl *palette);
73
74 typedef void (*palette_convert_func)(LPPALETTEENTRY palent,
75                                      void *screen_palette, DWORD start,
76                                      DWORD count);
77
78 struct IDirectDrawImpl
79 {
80     ICOM_VFIELD_MULTI(IDirectDraw7);
81     ICOM_VFIELD_MULTI(IDirectDraw4);
82     ICOM_VFIELD_MULTI(IDirectDraw2);
83     ICOM_VFIELD_MULTI(IDirectDraw);
84     ICOM_VFIELD_MULTI(IDirect3D7);
85     ICOM_VFIELD_MULTI(IDirect3D3);
86     ICOM_VFIELD_MULTI(IDirect3D2);
87     ICOM_VFIELD_MULTI(IDirect3D);
88
89     LONG ref;
90
91     /* TRUE if created via DirectDrawCreateEx or CoCreateInstance,
92      * FALSE if created via DirectDrawCreate. */
93     BOOL ex;
94
95     /* Linked list of surfaces, joined by next_ddraw in IDirectSurfaceImpl. */
96     IDirectDrawSurfaceImpl* surfaces;
97     /* Linked list of palettes, joined by next_ddraw. */
98     IDirectDrawPaletteImpl* palettes;
99     /* Linked list of clippers, joined by next_ddraw. */
100     IDirectDrawClipperImpl* clippers;
101
102     IDirectDrawSurfaceImpl* primary_surface;
103
104     DDRAWI_DIRECTDRAW_LCL local;
105     DDCAPS caps;
106
107     HWND window;
108     DWORD cooperative_level;
109     WNDPROC original_wndproc;
110
111     DWORD width, height;
112     LONG pitch;
113     DDPIXELFORMAT pixelformat;
114     DWORD cur_scanline;
115
116     /* Should each of these go into some structure? */
117     DWORD orig_width, orig_height;
118     LONG orig_pitch;
119     DDPIXELFORMAT orig_pixelformat;
120
121     /* Called when the refcount goes to 0. */
122     void (*final_release)(IDirectDrawImpl *This);
123
124     HRESULT (*set_exclusive_mode)(IDirectDrawImpl *This, DWORD dwExcl);
125
126     HRESULT (*create_palette)(IDirectDrawImpl* This, DWORD dwFlags,
127                               LPDIRECTDRAWPALETTE* ppPalette,
128                               LPUNKNOWN pUnkOuter);
129
130     /* Surface creation functions. For all of these, pOuter == NULL. */
131
132     /* Do not create any backbuffers or the flipping chain. */
133     HRESULT (*create_primary)(IDirectDrawImpl* This,
134                               const DDSURFACEDESC2* pDDSD,
135                               LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
136
137     /* Primary may be NULL if we are creating an unattached backbuffer. */
138     HRESULT (*create_backbuffer)(IDirectDrawImpl* This,
139                                  const DDSURFACEDESC2* pDDSD,
140                                  LPDIRECTDRAWSURFACE7* ppSurf,
141                                  LPUNKNOWN pOuter,
142                                  IDirectDrawSurfaceImpl* primary);
143
144     /* shiny happy offscreenplain surfaces */
145     HRESULT (*create_offscreen)(IDirectDrawImpl* This,
146                                 const DDSURFACEDESC2* pDDSD,
147                                 LPDIRECTDRAWSURFACE7* ppSurf,
148                                 LPUNKNOWN pOuter);
149
150     /* dwMipMapLevel is specified as per OpenGL. (i.e. 0 is base) */
151     HRESULT (*create_texture)(IDirectDrawImpl* This,
152                               const DDSURFACEDESC2* pDDSD,
153                               LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter,
154                               DWORD dwMipMapLevel);
155
156     HRESULT (*create_zbuffer)(IDirectDrawImpl* This,
157                               const DDSURFACEDESC2* pDDSD,
158                               LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
159
160     LPVOID      private;
161
162     /* Everything below here is still questionable. */
163
164     DDPIXELFORMAT screen_pixelformat;
165
166     int           pixmap_depth;
167     pixel_convert_func pixel_convert;
168     palette_convert_func palette_convert;
169
170     /* Use to fool some too strict games */
171     INT32 (*allocate_memory)(IDirectDrawImpl *This, DWORD mem);
172     void (*free_memory)(IDirectDrawImpl *This, DWORD mem);
173     DWORD total_vidmem, available_vidmem;
174     
175     /* IDirect3D fields */
176     LPVOID d3d_private;
177
178     /* Used as a callback function to create a texture */
179     HRESULT (*d3d_create_texture)(IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *tex, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main);
180
181     /* Used as a callback for Devices to tell to the D3D object it's been created */
182     HRESULT (*d3d_added_device)(IDirectDrawImpl *d3d, IDirect3DDeviceImpl *device);
183     HRESULT (*d3d_removed_device)(IDirectDrawImpl *d3d, IDirect3DDeviceImpl *device);
184
185     /* This is needed for delayed texture creation and Z buffer blits */
186     IDirect3DDeviceImpl *current_device;
187
188     /* This is for the fake mainWindow */
189     ATOM        winclass;
190     PAINTSTRUCT ps;
191     BOOL        paintable;
192 };
193
194 /*****************************************************************************
195  * IDirectDrawPalette implementation structure
196  */
197 struct IDirectDrawPaletteImpl
198 {
199     /* IUnknown fields */
200     ICOM_VFIELD_MULTI(IDirectDrawPalette);
201     LONG ref;
202
203     DDRAWI_DDRAWPALETTE_LCL local;
204     DDRAWI_DDRAWPALETTE_GBL global;
205
206     /* IDirectDrawPalette fields */
207     HPALETTE            hpal;
208     WORD                palVersion, palNumEntries; /* LOGPALETTE */
209     PALETTEENTRY        palents[256];
210     /* This is to store the palette in 'screen format' */
211     int                 screen_palents[256];
212
213     VOID (*final_release)(IDirectDrawPaletteImpl* This);
214
215     IDirectDrawImpl* ddraw_owner;
216     IDirectDrawPaletteImpl* prev_ddraw;
217     IDirectDrawPaletteImpl* next_ddraw;
218
219     LPVOID              private;
220 };
221
222 /*****************************************************************************
223  * IDirectDrawClipper implementation structure
224  */
225 struct IDirectDrawClipperImpl
226 {
227     /* IUnknown fields */
228     ICOM_VFIELD_MULTI(IDirectDrawClipper);
229     LONG ref;
230
231     /* IDirectDrawClipper fields */
232     HWND hWnd;
233
234     IDirectDrawImpl* ddraw_owner;
235     IDirectDrawClipperImpl* prev_ddraw;
236     IDirectDrawClipperImpl* next_ddraw;
237 };
238
239 /*****************************************************************************
240  * IDirectDrawSurface implementation structure
241  */
242
243 struct IDirectDrawSurfaceImpl
244 {
245     /* IUnknown fields */
246     ICOM_VFIELD_MULTI(IDirectDrawSurface7);
247     ICOM_VFIELD_MULTI(IDirectDrawSurface3);
248     ICOM_VFIELD_MULTI(IDirectDrawGammaControl);
249     ICOM_VFIELD_MULTI(IDirect3DTexture2);
250     ICOM_VFIELD_MULTI(IDirect3DTexture);
251     LONG ref;
252
253     struct IDirectDrawSurfaceImpl* attached; /* attached surfaces */
254
255     struct IDirectDrawSurfaceImpl* next_ddraw; /* ddraw surface chain */
256     struct IDirectDrawSurfaceImpl* prev_ddraw;
257     struct IDirectDrawSurfaceImpl* next_attached; /* attached surface chain */
258     struct IDirectDrawSurfaceImpl* prev_attached;
259
260     IDirectDrawImpl* ddraw_owner;
261     IDirectDrawSurfaceImpl* surface_owner;
262
263     IDirectDrawPaletteImpl* palette; /* strong ref */
264     IDirectDrawClipperImpl* clipper; /* strong ref */
265
266     DDRAWI_DDRAWSURFACE_LCL local;
267     DDRAWI_DDRAWSURFACE_MORE more;
268     /* FIXME: since Flip should swap the GBL structures, they should
269      * probably not be embedded into the IDirectDrawSurfaceImpl structure... */
270     LPDDRAWI_DDRAWSURFACE_GBL_MORE gmore;
271     DDRAWI_DDRAWSURFACE_GBL global;
272     DDRAWI_DDRAWSURFACE_GBL_MORE global_more;
273
274     DDSURFACEDESC2 surface_desc;
275
276     HDC hDC;
277     RECT lastlockrect;
278     DWORD lastlocktype;
279     BOOL dc_in_use;
280     BOOL locked;
281
282     HRESULT (*duplicate_surface)(IDirectDrawSurfaceImpl* src,
283                                  LPDIRECTDRAWSURFACE7* dst);
284     void (*final_release)(IDirectDrawSurfaceImpl *This);
285     HRESULT (*late_allocate)(IDirectDrawSurfaceImpl *This);
286     BOOL (*attach)(IDirectDrawSurfaceImpl *This, IDirectDrawSurfaceImpl *to);
287     BOOL (*detach)(IDirectDrawSurfaceImpl *This);
288     void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
289     void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
290     void (*lose_surface)(IDirectDrawSurfaceImpl* This);
291     BOOL (*flip_data)(IDirectDrawSurfaceImpl* front,
292                       IDirectDrawSurfaceImpl* back,
293                       DWORD dwFlags);
294     void (*flip_update)(IDirectDrawSurfaceImpl* front, DWORD dwFlags);
295     HRESULT (*get_dc)(IDirectDrawSurfaceImpl* This, HDC* phDC);
296     HRESULT (*release_dc)(IDirectDrawSurfaceImpl* This, HDC hDC);
297     void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal);
298     void (*update_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal,
299                            DWORD dwStart, DWORD dwCount, LPPALETTEENTRY palent);
300     HWND (*get_display_window)(IDirectDrawSurfaceImpl *This);
301     HRESULT (*get_gamma_ramp)(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp);
302     HRESULT (*set_gamma_ramp)(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp);
303
304     struct PrivateData* private_data;
305
306     DWORD max_lod;
307     DWORD priority;
308
309     BOOL lost;
310
311     DWORD uniqueness_value;
312
313     LPVOID private;
314
315     /* Everything below here is dodgy. */
316     /* For Direct3D use */
317     LPVOID aux_ctx, aux_data;
318     void (*aux_release)(LPVOID ctx, LPVOID data);
319     BOOL (*aux_flip)(LPVOID ctx, LPVOID data);
320     void (*aux_unlock)(LPVOID ctx, LPVOID data, LPRECT lpRect);
321     HRESULT (*aux_blt)(struct IDirectDrawSurfaceImpl *This, LPRECT rdst, LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx);
322     HRESULT (*aux_bltfast)(struct IDirectDrawSurfaceImpl *This, DWORD dstx, DWORD dsty, LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, DWORD trans);
323     HRESULT (*aux_setcolorkey_cb)(struct IDirectDrawSurfaceImpl *texture, DWORD dwFlags, LPDDCOLORKEY ckey );
324     /* This is to get the D3DDevice object associated to this surface */
325     struct IDirect3DDeviceImpl *d3ddevice;
326     /* This is for texture */
327     IDirectDrawSurfaceImpl *mip_main;
328     int mipmap_level;
329     LPVOID tex_private;
330     void (*lock_update_prev)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
331     void (*unlock_update_prev)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
332     BOOLEAN (*get_dirty_status)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
333 };
334
335 /*****************************************************************************
336  * Driver initialisation functions.
337  */
338 BOOL DDRAW_HAL_Init(HINSTANCE, DWORD, LPVOID);
339 BOOL DDRAW_User_Init(HINSTANCE, DWORD, LPVOID);
340
341 typedef struct {
342     const DDDEVICEIDENTIFIER2* info;
343     int preference;     /* how good we are. dga might get 100, xlib 50*/
344     HRESULT (*create)(const GUID*, LPDIRECTDRAW7*, LPUNKNOWN, BOOL ex);
345
346     /* For IDirectDraw7::Initialize. */
347     HRESULT (*init)(IDirectDrawImpl *, const GUID*);
348 } ddraw_driver;
349
350 void DDRAW_register_driver(const ddraw_driver*);
351
352 const ddraw_driver* DDRAW_FindDriver(const GUID* guid);
353
354 /******************************************************************************
355  * Random utilities
356  */
357
358 /* Get DDSCAPS of surface (shortcutmacro) */
359 #define SDDSCAPS(iface) ((iface)->s.surface_desc.ddsCaps.dwCaps)
360 /* Get the number of bytes per pixel for a given surface */
361 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.u1.dwRGBBitCount+7)/8))
362 #define GET_BPP(desc) PFGET_BPP(desc.u4.ddpfPixelFormat)
363
364 LONG DDRAW_width_bpp_to_pitch(DWORD width, DWORD bpp);
365
366 typedef struct {
367     unsigned short      bpp,depth;
368     unsigned int        rmask,gmask,bmask;
369 } ConvertMode;
370
371 typedef struct {
372     void (*pixel_convert)(void *src, void *dst, DWORD width, DWORD height, LONG pitch, IDirectDrawPaletteImpl* palette);
373     void (*palette_convert)(LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count);
374 } ConvertFuncs;
375
376 typedef struct {
377     ConvertMode screen, dest;
378     ConvertFuncs funcs;
379 } Convert;
380
381 extern Convert ModeEmulations[8];
382 extern int _common_depth_to_pixelformat(DWORD depth,LPDIRECTDRAW ddraw);
383 extern BOOL opengl_initialized;
384 extern BOOL s3tc_initialized;
385
386 typedef void (*FUNC_FETCH_2D_TEXEL_RGBA_DXT1)(int srcRowStride, const BYTE *pixdata, int i, int j, void *texel);
387 typedef void (*FUNC_FETCH_2D_TEXEL_RGBA_DXT3)(int srcRowStride, const BYTE *pixdata, int i, int j, void *texel);
388 typedef void (*FUNC_FETCH_2D_TEXEL_RGBA_DXT5)(int srcRowStride, const BYTE *pixdata, int i, int j, void *texel);
389
390 extern FUNC_FETCH_2D_TEXEL_RGBA_DXT1 fetch_2d_texel_rgba_dxt1;
391 extern FUNC_FETCH_2D_TEXEL_RGBA_DXT3 fetch_2d_texel_rgba_dxt3;
392 extern FUNC_FETCH_2D_TEXEL_RGBA_DXT5 fetch_2d_texel_rgba_dxt5;
393
394 /******************************************************************************
395  * Structure conversion (for thunks)
396  */
397 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut);
398 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn,
399                                              DDDEVICEIDENTIFIER* pOut);
400
401 /******************************************************************************
402  * Debugging / Flags output functions
403  */
404 extern void DDRAW_dump_DDBLTFX(DWORD flagmask);
405 extern void DDRAW_dump_DDBLTFAST(DWORD flagmask);
406 extern void DDRAW_dump_DDBLT(DWORD flagmask);
407 extern void DDRAW_dump_DDSCAPS(const DDSCAPS *in);
408 extern void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in);
409 extern void DDRAW_dump_pixelformat_flag(DWORD flagmask);
410 extern void DDRAW_dump_paletteformat(DWORD dwFlags);
411 extern void DDRAW_dump_pixelformat(const DDPIXELFORMAT *in);
412 extern void DDRAW_dump_colorkeyflag(DWORD ck);
413 extern void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd);
414 extern void DDRAW_dump_cooperativelevel(DWORD cooplevel);
415 extern void DDRAW_dump_lockflag(DWORD lockflag);
416 extern void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY *in);
417 extern void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps);
418 extern void DDRAW_dump_surface_to_disk(IDirectDrawSurfaceImpl *surface, FILE *f, int scale) ;
419
420 /* Used for generic dumping */
421 typedef struct
422 {
423     DWORD val;
424     const char* name;
425 } flag_info;
426
427 #define FE(x) { x, #x }
428
429 typedef struct
430 {
431     DWORD val;
432     const char* name;
433     void (*func)(const void *);
434     ptrdiff_t offset;
435 } member_info;
436
437 #define DDRAW_dump_flags(flags,names,num_names) DDRAW_dump_flags_(flags, names, num_names, 1)
438 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
439
440 extern void DDRAW_dump_flags_(DWORD flags, const flag_info* names, size_t num_names, int newline);
441 extern void DDRAW_dump_members(DWORD flags, const void* data, const member_info* mems, size_t num_mems);
442
443 void DirectDrawSurface_RegisterClass(void);
444 void DirectDrawSurface_UnregisterClass(void);
445
446 extern const IDirectDrawSurface3Vtbl DDRAW_IDDS3_Thunk_VTable;
447
448 /*****************************************************************************
449  * IDirectDrawClipper declarations
450  */
451 HRESULT DDRAW_CreateClipper(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppObj);
452 void Main_DirectDrawClipper_ForceDestroy(IDirectDrawClipperImpl* This);
453
454 HRESULT WINAPI
455 Main_DirectDrawClipper_SetHwnd(LPDIRECTDRAWCLIPPER iface, DWORD dwFlags,
456                                HWND hWnd);
457 ULONG WINAPI Main_DirectDrawClipper_Release(LPDIRECTDRAWCLIPPER iface);
458 HRESULT WINAPI
459 Main_DirectDrawClipper_GetClipList(LPDIRECTDRAWCLIPPER iface, LPRECT lpRect,
460                                    LPRGNDATA lpClipList, LPDWORD lpdwSize);
461 HRESULT WINAPI
462 Main_DirectDrawClipper_SetClipList(LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,
463                                    DWORD dwFlag);
464 HRESULT WINAPI
465 Main_DirectDrawClipper_QueryInterface(LPDIRECTDRAWCLIPPER iface, REFIID riid,
466                                       LPVOID* ppvObj);
467 ULONG WINAPI Main_DirectDrawClipper_AddRef( LPDIRECTDRAWCLIPPER iface );
468 HRESULT WINAPI
469 Main_DirectDrawClipper_GetHWnd(LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr);
470 HRESULT WINAPI
471 Main_DirectDrawClipper_Initialize(LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD,
472                                   DWORD dwFlags);
473 HRESULT WINAPI
474 Main_DirectDrawClipper_IsClipListChanged(LPDIRECTDRAWCLIPPER iface,
475                                          BOOL* lpbChanged);
476
477 /*****************************************************************************
478  * IDirectDrawPalette MAIN declarations
479  */
480 HRESULT Main_DirectDrawPalette_Construct(IDirectDrawPaletteImpl* This,
481                                          IDirectDrawImpl* pDD, DWORD dwFlags);
482 void Main_DirectDrawPalette_final_release(IDirectDrawPaletteImpl* This);
483
484 HRESULT Main_DirectDrawPalette_Create(IDirectDrawImpl* pDD, DWORD dwFlags,
485                                       LPDIRECTDRAWPALETTE* ppPalette,
486                                       LPUNKNOWN pUnkOuter);
487 void Main_DirectDrawPalette_ForceDestroy(IDirectDrawPaletteImpl* This);
488
489 DWORD Main_DirectDrawPalette_Size(DWORD dwFlags);
490
491 HRESULT WINAPI
492 Main_DirectDrawPalette_GetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
493                                   DWORD dwStart, DWORD dwCount,
494                                   LPPALETTEENTRY palent);
495 HRESULT WINAPI
496 Main_DirectDrawPalette_SetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
497                                   DWORD dwStart, DWORD dwCount,
498                                   LPPALETTEENTRY palent);
499 ULONG WINAPI
500 Main_DirectDrawPalette_Release(LPDIRECTDRAWPALETTE iface);
501 ULONG WINAPI Main_DirectDrawPalette_AddRef(LPDIRECTDRAWPALETTE iface);
502 HRESULT WINAPI
503 Main_DirectDrawPalette_Initialize(LPDIRECTDRAWPALETTE iface,
504                                   LPDIRECTDRAW ddraw, DWORD dwFlags,
505                                   LPPALETTEENTRY palent);
506 HRESULT WINAPI
507 Main_DirectDrawPalette_GetCaps(LPDIRECTDRAWPALETTE iface, LPDWORD lpdwCaps);
508 HRESULT WINAPI
509 Main_DirectDrawPalette_QueryInterface(LPDIRECTDRAWPALETTE iface,
510                                       REFIID refiid, LPVOID *obj);
511
512 /*****************************************************************************
513  * IDirectDrawPalette HAL declarations
514  */
515 HRESULT HAL_DirectDrawPalette_Construct(IDirectDrawPaletteImpl* This,
516                                          IDirectDrawImpl* pDD, DWORD dwFlags);
517 void HAL_DirectDrawPalette_final_release(IDirectDrawPaletteImpl* This);
518
519 HRESULT HAL_DirectDrawPalette_Create(IDirectDrawImpl* pDD, DWORD dwFlags,
520                                      LPDIRECTDRAWPALETTE* ppPalette,
521                                      LPUNKNOWN pUnkOuter);
522
523 HRESULT WINAPI
524 HAL_DirectDrawPalette_SetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
525                                  DWORD dwStart, DWORD dwCount,
526                                  LPPALETTEENTRY palent);
527
528 /*****************************************************************************
529  * IDirectDraw MAIN declarations
530  */
531 /* internal virtual functions */
532 void Main_DirectDraw_final_release(IDirectDrawImpl* This);
533 HRESULT Main_create_offscreen(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
534                               LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
535 HRESULT Main_create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
536                             LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter,
537                             DWORD dwMipMapLevel);
538 HRESULT Main_create_zbuffer(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
539                             LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
540
541 /* internal functions */
542 HRESULT Main_DirectDraw_Construct(IDirectDrawImpl *This, BOOL ex);
543 void Main_DirectDraw_AddSurface(IDirectDrawImpl* This,
544                                 IDirectDrawSurfaceImpl* surface);
545 void Main_DirectDraw_RemoveSurface(IDirectDrawImpl* This,
546                                    IDirectDrawSurfaceImpl* surface);
547 void Main_DirectDraw_AddClipper(IDirectDrawImpl* This,
548                                 IDirectDrawClipperImpl* clipper);
549 void Main_DirectDraw_RemoveClipper(IDirectDrawImpl* This,
550                                    IDirectDrawClipperImpl* clipper);
551 void Main_DirectDraw_AddPalette(IDirectDrawImpl* This,
552                                 IDirectDrawPaletteImpl* palette);
553 void Main_DirectDraw_RemovePalette(IDirectDrawImpl* This,
554                                    IDirectDrawPaletteImpl* palette);
555
556 /* interface functions */
557 ULONG WINAPI Main_DirectDraw_AddRef(LPDIRECTDRAW7 iface);
558 ULONG WINAPI Main_DirectDraw_Release(LPDIRECTDRAW7 iface);
559 HRESULT WINAPI Main_DirectDraw_QueryInterface(LPDIRECTDRAW7 iface,
560                                               REFIID refiid,LPVOID *obj);
561 HRESULT WINAPI Main_DirectDraw_Compact(LPDIRECTDRAW7 iface);
562 HRESULT WINAPI Main_DirectDraw_CreateClipper(LPDIRECTDRAW7 iface,
563                                              DWORD dwFlags,
564                                              LPDIRECTDRAWCLIPPER *ppClipper,
565                                              IUnknown *pUnkOuter);
566 HRESULT WINAPI
567 Main_DirectDraw_CreatePalette(LPDIRECTDRAW7 iface, DWORD dwFlags,
568                               LPPALETTEENTRY palent,
569                               LPDIRECTDRAWPALETTE* ppPalette,
570                               LPUNKNOWN pUnknown);
571 HRESULT WINAPI
572 Main_DirectDraw_CreateSurface(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD,
573                               LPDIRECTDRAWSURFACE7 *ppSurf,
574                               IUnknown *pUnkOuter);
575 HRESULT WINAPI
576 Main_DirectDraw_DuplicateSurface(LPDIRECTDRAW7 iface, LPDIRECTDRAWSURFACE7 src,
577                                  LPDIRECTDRAWSURFACE7* dst);
578 HRESULT WINAPI
579 Main_DirectDraw_EnumSurfaces(LPDIRECTDRAW7 iface, DWORD dwFlags,
580                              LPDDSURFACEDESC2 lpDDSD2, LPVOID context,
581                              LPDDENUMSURFACESCALLBACK7 callback);
582 HRESULT WINAPI
583 Main_DirectDraw_EvaluateMode(LPDIRECTDRAW7 iface,DWORD a,DWORD* b);
584 HRESULT WINAPI Main_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface);
585 HRESULT WINAPI
586 Main_DirectDraw_GetCaps(LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps,
587                         LPDDCAPS pHELCaps);
588 HRESULT WINAPI
589 Main_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD pNumCodes,
590                                LPDWORD pCodes);
591 HRESULT WINAPI
592 Main_DirectDraw_GetGDISurface(LPDIRECTDRAW7 iface,
593                               LPDIRECTDRAWSURFACE7 *lplpGDIDDSSurface);
594 HRESULT WINAPI
595 Main_DirectDraw_GetMonitorFrequency(LPDIRECTDRAW7 iface,LPDWORD freq);
596 HRESULT WINAPI
597 Main_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine);
598 HRESULT WINAPI
599 Main_DirectDraw_GetSurfaceFromDC(LPDIRECTDRAW7 iface, HDC hdc,
600                                  LPDIRECTDRAWSURFACE7 *lpDDS);
601 HRESULT WINAPI
602 Main_DirectDraw_GetVerticalBlankStatus(LPDIRECTDRAW7 iface, LPBOOL status);
603 HRESULT WINAPI
604 Main_DirectDraw_Initialize(LPDIRECTDRAW7 iface, LPGUID lpGuid);
605 HRESULT WINAPI Main_DirectDraw_RestoreAllSurfaces(LPDIRECTDRAW7 iface);
606 HRESULT WINAPI
607 Main_DirectDraw_SetCooperativeLevel(LPDIRECTDRAW7 iface, HWND hwnd,
608                                     DWORD cooplevel);
609 HRESULT WINAPI
610 Main_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
611                                DWORD dwHeight, LONG lPitch,
612                                DWORD dwRefreshRate, DWORD dwFlags,
613                                const DDPIXELFORMAT* pixelformat);
614 HRESULT WINAPI Main_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface);
615 HRESULT WINAPI
616 Main_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD dwFlags,
617                                      HANDLE h);
618 HRESULT WINAPI
619 Main_DirectDraw_GetDisplayMode(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD);
620 HRESULT WINAPI
621 Main_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface,LPDDSCAPS2 ddscaps,
622                                    LPDWORD total, LPDWORD free);
623 HRESULT WINAPI Main_DirectDraw_TestCooperativeLevel(LPDIRECTDRAW7 iface);
624 HRESULT WINAPI
625 Main_DirectDraw_StartModeTest(LPDIRECTDRAW7 iface, LPSIZE pModes,
626                               DWORD dwNumModes, DWORD dwFlags);
627
628 /*****************************************************************************
629  * IDirectDraw USER object declarations
630  */
631 #define USER_DDRAW_PRIV(ddraw) ((User_DirectDrawImpl*)((ddraw)->private))
632 #define USER_DDRAW_PRIV_VAR(name,ddraw) \
633         User_DirectDrawImpl* name = USER_DDRAW_PRIV(ddraw)
634
635 typedef struct
636 {
637     int empty;
638     /* empty */
639 } User_DirectDrawImpl_Part;
640
641 typedef struct
642 {
643     User_DirectDrawImpl_Part user;
644 } User_DirectDrawImpl;
645
646 void User_DirectDraw_final_release(IDirectDrawImpl* This);
647 HRESULT User_DirectDraw_create_primary(IDirectDrawImpl* This,
648                                        const DDSURFACEDESC2* pDDSD,
649                                        LPDIRECTDRAWSURFACE7* ppSurf,
650                                        LPUNKNOWN pOuter);
651 HRESULT User_DirectDraw_create_backbuffer(IDirectDrawImpl* This,
652                                           const DDSURFACEDESC2* pDDSD,
653                                           LPDIRECTDRAWSURFACE7* ppSurf,
654                                           LPUNKNOWN pOuter,
655                                           IDirectDrawSurfaceImpl* primary);
656 HRESULT User_DirectDraw_Construct(IDirectDrawImpl *This, BOOL ex);
657 HRESULT User_DirectDraw_Create(const GUID* pGUID, LPDIRECTDRAW7* pIface,
658                                IUnknown* pUnkOuter, BOOL ex);
659
660 HRESULT WINAPI
661 User_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags,
662                                  LPDDSURFACEDESC2 pDDSD, LPVOID context,
663                                  LPDDENUMMODESCALLBACK2 callback);
664 HRESULT WINAPI
665 User_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7 iface,
666                                     LPDDDEVICEIDENTIFIER2 pDDDI,
667                                     DWORD dwFlags);
668 HRESULT WINAPI
669 User_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
670                                DWORD dwHeight, DWORD dwBPP,
671                                DWORD dwRefreshRate, DWORD dwFlags);
672
673 /*****************************************************************************
674  * IDirectDraw HAL declarations
675  */
676 #define HAL_DDRAW_PRIV(ddraw) \
677         ((HAL_DirectDrawImpl*)((ddraw)->private))
678 #define HAL_DDRAW_PRIV_VAR(name,ddraw) \
679         HAL_DirectDrawImpl* name = HAL_DDRAW_PRIV(ddraw)
680
681 typedef struct
682 {
683     DWORD next_vofs;
684 } HAL_DirectDrawImpl_Part;
685
686 typedef struct
687 {
688     User_DirectDrawImpl_Part user;
689     HAL_DirectDrawImpl_Part hal;
690 } HAL_DirectDrawImpl;
691
692 void HAL_DirectDraw_final_release(IDirectDrawImpl* This);
693 HRESULT HAL_DirectDraw_create_primary(IDirectDrawImpl* This,
694                                       const DDSURFACEDESC2* pDDSD,
695                                       LPDIRECTDRAWSURFACE7* ppSurf,
696                                       LPUNKNOWN pOuter);
697 HRESULT HAL_DirectDraw_create_backbuffer(IDirectDrawImpl* This,
698                                          const DDSURFACEDESC2* pDDSD,
699                                          LPDIRECTDRAWSURFACE7* ppSurf,
700                                          LPUNKNOWN pOuter,
701                                          IDirectDrawSurfaceImpl* primary);
702 HRESULT HAL_DirectDraw_create_texture(IDirectDrawImpl* This,
703                                       const DDSURFACEDESC2* pDDSD,
704                                       LPDIRECTDRAWSURFACE7* ppSurf,
705                                       LPUNKNOWN pOuter,
706                                       DWORD dwMipMapLevel);
707
708 HRESULT HAL_DirectDraw_Construct(IDirectDrawImpl *This, BOOL ex);
709 HRESULT HAL_DirectDraw_Create(const GUID* pGUID, LPDIRECTDRAW7* pIface,
710                                    IUnknown* pUnkOuter, BOOL ex);
711
712 HRESULT WINAPI
713 HAL_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7 iface,
714                                         LPDDDEVICEIDENTIFIER2 pDDDI,
715                                         DWORD dwFlags);
716 HRESULT WINAPI
717 HAL_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
718                                    DWORD dwHeight, DWORD dwBPP,
719                                    DWORD dwRefreshRate, DWORD dwFlags);
720 HRESULT WINAPI HAL_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface);
721
722 /*****************************************************************************
723  * IDirectDrawSurface MAIN declarations
724  */
725 /* Support for IDirectDrawSurface7::Set/Get/FreePrivateData. I don't think
726  * anybody uses it for much so a good implementation is optional. */
727 typedef struct PrivateData
728 {
729     struct PrivateData* next;
730     struct PrivateData* prev;
731
732     GUID tag;
733     DWORD flags; /* DDSPD_* */
734     DWORD uniqueness_value;
735
736     union
737     {
738         LPVOID data;
739         LPUNKNOWN object;
740     } ptr;
741
742     DWORD size;
743 } PrivateData;
744
745 extern const IDirectDrawGammaControlVtbl DDRAW_IDDGC_VTable;
746
747 /* Non-interface functions */
748 HRESULT Main_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This,
749                                          IDirectDrawImpl* pDD,
750                                          const DDSURFACEDESC2* pDDSD);
751 void Main_DirectDrawSurface_ForceDestroy(IDirectDrawSurfaceImpl* This);
752
753 void Main_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This);
754 HRESULT Main_DirectDrawSurface_late_allocate(IDirectDrawSurfaceImpl* This);
755 BOOL Main_DirectDrawSurface_attach(IDirectDrawSurfaceImpl *This,
756                                    IDirectDrawSurfaceImpl *to);
757 BOOL Main_DirectDrawSurface_detach(IDirectDrawSurfaceImpl *This);
758 void Main_DirectDrawSurface_lock_update(IDirectDrawSurfaceImpl* This,
759                                         LPCRECT pRect, DWORD dwFlags);
760 void Main_DirectDrawSurface_unlock_update(IDirectDrawSurfaceImpl* This,
761                                           LPCRECT pRect);
762 void Main_DirectDrawSurface_lose_surface(IDirectDrawSurfaceImpl* This);
763 void Main_DirectDrawSurface_set_palette(IDirectDrawSurfaceImpl* This,
764                                         IDirectDrawPaletteImpl* pal);
765 void Main_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This,
766                                            IDirectDrawPaletteImpl* pal,
767                                            DWORD dwStart, DWORD dwCount,
768                                            LPPALETTEENTRY palent);
769 HWND Main_DirectDrawSurface_get_display_window(IDirectDrawSurfaceImpl* This);
770
771 HRESULT Main_DirectDrawSurface_get_gamma_ramp(IDirectDrawSurfaceImpl* This,
772                                               DWORD dwFlags,
773                                               LPDDGAMMARAMP lpGammaRamp);
774 HRESULT Main_DirectDrawSurface_set_gamma_ramp(IDirectDrawSurfaceImpl* This,
775                                               DWORD dwFlags,
776                                               LPDDGAMMARAMP lpGammaRamp);
777
778 BOOL Main_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front,
779                                       IDirectDrawSurfaceImpl* back,
780                                       DWORD dwFlags);
781
782 #define CHECK_LOST(This)                                        \
783         do {                                                    \
784                 if (This->lost) return DDERR_SURFACELOST;       \
785         } while (0)
786
787 #define CHECK_TEXTURE(This)                                     \
788         do {                                                    \
789                 if (!(This->surface_desc.ddsCaps.dwCaps2        \
790                       & DDSCAPS2_TEXTUREMANAGE))                \
791                         return DDERR_INVALIDOBJECT;             \
792         } while (0)
793
794 #define LOCK_OBJECT(This) do { } while (0)
795 #define UNLOCK_OBJECT(This) do { } while (0)
796
797 /* IDirectDrawSurface7 (partial) implementation */
798 ULONG WINAPI Main_DirectDrawSurface_AddRef(LPDIRECTDRAWSURFACE7 iface);
799 ULONG WINAPI Main_DirectDrawSurface_Release(LPDIRECTDRAWSURFACE7 iface);
800 HRESULT WINAPI
801 Main_DirectDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7 iface, REFIID riid,
802                                       LPVOID* ppObj);
803 HRESULT WINAPI
804 Main_DirectDrawSurface_AddAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
805                                           LPDIRECTDRAWSURFACE7 pAttach);
806 HRESULT WINAPI
807 Main_DirectDrawSurface_AddOverlayDirtyRect(LPDIRECTDRAWSURFACE7 iface,
808                                            LPRECT pRect);
809 HRESULT WINAPI
810 Main_DirectDrawSurface_BltBatch(LPDIRECTDRAWSURFACE7 iface,
811                                 LPDDBLTBATCH pBatch, DWORD dwCount,
812                                 DWORD dwFlags);
813 HRESULT WINAPI
814 Main_DirectDrawSurface_ChangeUniquenessValue(LPDIRECTDRAWSURFACE7 iface);
815 HRESULT WINAPI
816 Main_DirectDrawSurface_DeleteAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
817                                              DWORD dwFlags,
818                                              LPDIRECTDRAWSURFACE7 pAttach);
819 HRESULT WINAPI
820 Main_DirectDrawSurface_EnumAttachedSurfaces(LPDIRECTDRAWSURFACE7 iface,
821                                             LPVOID context,
822                                             LPDDENUMSURFACESCALLBACK7 cb);
823 HRESULT WINAPI
824 Main_DirectDrawSurface_EnumOverlayZOrders(LPDIRECTDRAWSURFACE7 iface,
825                                           DWORD dwFlags, LPVOID context,
826                                           LPDDENUMSURFACESCALLBACK7 cb);
827 HRESULT WINAPI
828 Main_DirectDrawSurface_Flip(LPDIRECTDRAWSURFACE7 iface,
829                             LPDIRECTDRAWSURFACE7 override, DWORD dwFlags);
830 HRESULT WINAPI
831 Main_DirectDrawSurface_FreePrivateData(LPDIRECTDRAWSURFACE7 iface,
832                                        REFGUID tag);
833 HRESULT WINAPI
834 Main_DirectDrawSurface_GetAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
835                                           LPDDSCAPS2 pCaps,
836                                           LPDIRECTDRAWSURFACE7* ppSurface);
837 HRESULT WINAPI
838 Main_DirectDrawSurface_GetBltStatus(LPDIRECTDRAWSURFACE7 iface,
839                                     DWORD dwFlags);
840 HRESULT WINAPI
841 Main_DirectDrawSurface_GetCaps(LPDIRECTDRAWSURFACE7 iface,
842                                LPDDSCAPS2 pCaps);
843 HRESULT WINAPI
844 Main_DirectDrawSurface_GetClipper(LPDIRECTDRAWSURFACE7 iface,
845                                   LPDIRECTDRAWCLIPPER* ppClipper);
846 HRESULT WINAPI
847 Main_DirectDrawSurface_GetColorKey(LPDIRECTDRAWSURFACE7 iface,
848                                    DWORD dwFlags, LPDDCOLORKEY pCKey);
849 HRESULT WINAPI
850 Main_DirectDrawSurface_GetDC(LPDIRECTDRAWSURFACE7 iface, HDC *phDC);
851 HRESULT WINAPI
852 Main_DirectDrawSurface_GetDDInterface(LPDIRECTDRAWSURFACE7 iface,
853                                       LPVOID* pDD);
854 HRESULT WINAPI
855 Main_DirectDrawSurface_GetFlipStatus(LPDIRECTDRAWSURFACE7 iface,
856                                      DWORD dwFlags);
857 HRESULT WINAPI
858 Main_DirectDrawSurface_GetLOD(LPDIRECTDRAWSURFACE7 iface,
859                               LPDWORD pdwMaxLOD);
860 HRESULT WINAPI
861 Main_DirectDrawSurface_GetOverlayPosition(LPDIRECTDRAWSURFACE7 iface,
862                                           LPLONG pX, LPLONG pY);
863 HRESULT WINAPI
864 Main_DirectDrawSurface_GetPalette(LPDIRECTDRAWSURFACE7 iface,
865                                   LPDIRECTDRAWPALETTE* ppPalette);
866 HRESULT WINAPI
867 Main_DirectDrawSurface_GetPixelFormat(LPDIRECTDRAWSURFACE7 iface,
868                                       LPDDPIXELFORMAT pDDPixelFormat);
869 HRESULT WINAPI
870 Main_DirectDrawSurface_GetPriority(LPDIRECTDRAWSURFACE7 iface,
871                                    LPDWORD pdwPriority);
872 HRESULT WINAPI
873 Main_DirectDrawSurface_GetPrivateData(LPDIRECTDRAWSURFACE7 iface, REFGUID tag,
874                                       LPVOID pBuffer, LPDWORD pcbBufferSize);
875 HRESULT WINAPI
876 Main_DirectDrawSurface_GetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface,
877                                       LPDDSURFACEDESC2 pDDSD);
878 HRESULT WINAPI
879 Main_DirectDrawSurface_GetUniquenessValue(LPDIRECTDRAWSURFACE7 iface,
880                                           LPDWORD pValue);
881 HRESULT WINAPI
882 Main_DirectDrawSurface_Initialize(LPDIRECTDRAWSURFACE7 iface,
883                                   LPDIRECTDRAW pDD, LPDDSURFACEDESC2 pDDSD);
884 HRESULT WINAPI
885 Main_DirectDrawSurface_IsLost(LPDIRECTDRAWSURFACE7 iface);
886 HRESULT WINAPI
887 Main_DirectDrawSurface_Lock(LPDIRECTDRAWSURFACE7 iface, LPRECT prect,
888                             LPDDSURFACEDESC2 pDDSD, DWORD flags, HANDLE h);
889 HRESULT WINAPI
890 Main_DirectDrawSurface_PageLock(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags);
891 HRESULT WINAPI
892 Main_DirectDrawSurface_PageUnlock(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags);
893 HRESULT WINAPI
894 Main_DirectDrawSurface_ReleaseDC(LPDIRECTDRAWSURFACE7 iface, HDC hDC);
895 HRESULT WINAPI
896 Main_DirectDrawSurface_SetClipper(LPDIRECTDRAWSURFACE7 iface,
897                                   LPDIRECTDRAWCLIPPER pDDClipper);
898 HRESULT WINAPI
899 Main_DirectDrawSurface_SetColorKey(LPDIRECTDRAWSURFACE7 iface,
900                                    DWORD dwFlags, LPDDCOLORKEY pCKey);
901 HRESULT WINAPI
902 Main_DirectDrawSurface_SetLOD(LPDIRECTDRAWSURFACE7 iface, DWORD dwMaxLOD);
903 HRESULT WINAPI
904 Main_DirectDrawSurface_SetOverlayPosition(LPDIRECTDRAWSURFACE7 iface,
905                                           LONG X, LONG Y);
906 HRESULT WINAPI
907 Main_DirectDrawSurface_SetPalette(LPDIRECTDRAWSURFACE7 iface,
908                                   LPDIRECTDRAWPALETTE pPalette);
909 HRESULT WINAPI
910 Main_DirectDrawSurface_SetPriority(LPDIRECTDRAWSURFACE7 iface,
911                                    DWORD dwPriority);
912 HRESULT WINAPI
913 Main_DirectDrawSurface_SetPrivateData(LPDIRECTDRAWSURFACE7 iface,
914                                       REFGUID tag, LPVOID pData,
915                                       DWORD cbSize, DWORD dwFlags);
916 HRESULT WINAPI
917 Main_DirectDrawSurface_Unlock(LPDIRECTDRAWSURFACE7 iface, LPRECT pRect);
918 HRESULT WINAPI
919 Main_DirectDrawSurface_UpdateOverlay(LPDIRECTDRAWSURFACE7 iface,
920                                      LPRECT pSrcRect,
921                                      LPDIRECTDRAWSURFACE7 pDstSurface,
922                                      LPRECT pDstRect, DWORD dwFlags,
923                                      LPDDOVERLAYFX pFX);
924 HRESULT WINAPI
925 Main_DirectDrawSurface_UpdateOverlayDisplay(LPDIRECTDRAWSURFACE7 iface,
926                                             DWORD dwFlags);
927 HRESULT WINAPI
928 Main_DirectDrawSurface_UpdateOverlayZOrder(LPDIRECTDRAWSURFACE7 iface,
929                                            DWORD dwFlags,
930                                            LPDIRECTDRAWSURFACE7 pDDSRef);
931
932 /*****************************************************************************
933  * IDirectDrawSurface DIB declarations
934  */
935 #define DIB_PRIV(surf) ((DIB_DirectDrawSurfaceImpl*)((surf)->private))
936
937 #define DIB_PRIV_VAR(name, surf) \
938         DIB_DirectDrawSurfaceImpl* name = DIB_PRIV(surf)
939
940 struct DIB_DirectDrawSurfaceImpl_Part
941 {
942     HBITMAP DIBsection;
943     void* bitmap_data;
944     HGDIOBJ holdbitmap;
945     BOOL client_memory;
946     DWORD d3d_data[4]; /* room for Direct3D driver data */
947 };
948
949 typedef struct
950 {
951     struct DIB_DirectDrawSurfaceImpl_Part dib;
952 } DIB_DirectDrawSurfaceImpl;
953
954 HRESULT
955 DIB_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl *This,
956                                 IDirectDrawImpl *pDD,
957                                 const DDSURFACEDESC2 *pDDSD);
958 HRESULT
959 DIB_DirectDrawSurface_Create(IDirectDrawImpl *pDD,
960                              const DDSURFACEDESC2 *pDDSD,
961                              LPDIRECTDRAWSURFACE7 *ppSurf,
962                              IUnknown *pUnkOuter);
963
964 void DIB_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This);
965 BOOL DIB_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front,
966                                      IDirectDrawSurfaceImpl* back,
967                                      DWORD dwFlags);
968
969 void DIB_DirectDrawSurface_set_palette(IDirectDrawSurfaceImpl* This,
970                                        IDirectDrawPaletteImpl* pal);
971 void DIB_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This,
972                                           IDirectDrawPaletteImpl* pal,
973                                           DWORD dwStart, DWORD dwCount,
974                                           LPPALETTEENTRY palent);
975
976 HRESULT DIB_DirectDrawSurface_get_dc(IDirectDrawSurfaceImpl* This, HDC* phDC);
977 HRESULT DIB_DirectDrawSurface_release_dc(IDirectDrawSurfaceImpl* This,HDC hDC);
978
979 HRESULT DIB_DirectDrawSurface_alloc_dc(IDirectDrawSurfaceImpl* This,HDC* phDC);
980 HRESULT DIB_DirectDrawSurface_free_dc(IDirectDrawSurfaceImpl* This, HDC hDC);
981
982 HRESULT WINAPI
983 DIB_DirectDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT prcDest,
984                           LPDIRECTDRAWSURFACE7 pSrcSurf, LPRECT prcSrc,
985                           DWORD dwFlags, LPDDBLTFX pBltFx);
986 HRESULT WINAPI
987 DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dwX,
988                               DWORD dwY, LPDIRECTDRAWSURFACE7 pSrcSurf,
989                               LPRECT prcSrc, DWORD dwTrans);
990 HRESULT WINAPI DIB_DirectDrawSurface_Restore(LPDIRECTDRAWSURFACE7 iface);
991 HRESULT WINAPI
992 DIB_DirectDrawSurface_SetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface,
993                                      LPDDSURFACEDESC2 pDDSD, DWORD dwFlags);
994
995 /*****************************************************************************
996  * IDirectDrawSurface USER declarations
997  */
998 #define USER_PRIV(surf) ((User_DirectDrawSurfaceImpl*)((surf)->private))
999
1000 #define USER_PRIV_VAR(name,surf) \
1001         User_DirectDrawSurfaceImpl* name = USER_PRIV(surf)
1002
1003 struct User_DirectDrawSurfaceImpl_Part
1004 {
1005     HWND window;
1006     HDC cached_dc;
1007     HANDLE update_thread, update_event, refresh_event;
1008     volatile int wait_count, in_refresh;
1009     CRITICAL_SECTION crit;
1010 };
1011
1012 typedef struct
1013 {
1014     struct DIB_DirectDrawSurfaceImpl_Part dib;
1015     struct User_DirectDrawSurfaceImpl_Part user;
1016 } User_DirectDrawSurfaceImpl;
1017
1018 HRESULT User_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This,
1019                                          IDirectDrawImpl* pDD,
1020                                          const DDSURFACEDESC2* pDDSD);
1021
1022 HRESULT User_DirectDrawSurface_Create(IDirectDrawImpl *pDD,
1023                                       const DDSURFACEDESC2 *pDDSD,
1024                                       LPDIRECTDRAWSURFACE7 *ppSurf,
1025                                       IUnknown *pUnkOuter);
1026
1027 void User_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This);
1028
1029 void User_DirectDrawSurface_lock_update(IDirectDrawSurfaceImpl* This,
1030                                         LPCRECT pRect, DWORD dwFlags);
1031 void User_DirectDrawSurface_unlock_update(IDirectDrawSurfaceImpl* This,
1032                                           LPCRECT pRect);
1033 void User_DirectDrawSurface_set_palette(IDirectDrawSurfaceImpl* This,
1034                                         IDirectDrawPaletteImpl* pal);
1035 void User_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This,
1036                                            IDirectDrawPaletteImpl* pal,
1037                                            DWORD dwStart, DWORD dwCount,
1038                                            LPPALETTEENTRY palent);
1039 HRESULT User_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
1040                                                  LPDIRECTDRAWSURFACE7* ppDup);
1041 BOOL User_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front,
1042                                       IDirectDrawSurfaceImpl* back,
1043                                       DWORD dwFlags);
1044 void User_DirectDrawSurface_flip_update(IDirectDrawSurfaceImpl* This,
1045                                         DWORD dwFlags);
1046 HWND User_DirectDrawSurface_get_display_window(IDirectDrawSurfaceImpl* This);
1047
1048 HRESULT User_DirectDrawSurface_get_dc(IDirectDrawSurfaceImpl* This, HDC* phDC);
1049 HRESULT User_DirectDrawSurface_release_dc(IDirectDrawSurfaceImpl* This,
1050                                           HDC hDC);
1051
1052 HRESULT User_DirectDrawSurface_get_gamma_ramp(IDirectDrawSurfaceImpl* This,
1053                                               DWORD dwFlags,
1054                                               LPDDGAMMARAMP lpGammaRamp);
1055 HRESULT User_DirectDrawSurface_set_gamma_ramp(IDirectDrawSurfaceImpl* This,
1056                                               DWORD dwFlags,
1057                                               LPDDGAMMARAMP lpGammaRamp);
1058
1059 /*****************************************************************************
1060  * IDirectDrawSurface HAL declarations
1061  */
1062 #define HAL_PRIV(surf) ((HAL_DirectDrawSurfaceImpl*)((surf)->private))
1063
1064 #define HAL_PRIV_VAR(name,surf) \
1065         HAL_DirectDrawSurfaceImpl* name = HAL_PRIV(surf)
1066
1067 struct HAL_DirectDrawSurfaceImpl_Part
1068 {
1069     DWORD need_late;
1070     LPVOID fb_addr;
1071     DWORD fb_pitch, fb_vofs;
1072 };
1073
1074 typedef struct
1075 {
1076     struct DIB_DirectDrawSurfaceImpl_Part dib;
1077     struct User_DirectDrawSurfaceImpl_Part user;
1078     struct HAL_DirectDrawSurfaceImpl_Part hal;
1079 } HAL_DirectDrawSurfaceImpl;
1080
1081 HRESULT HAL_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This,
1082                                         IDirectDrawImpl* pDD,
1083                                         const DDSURFACEDESC2* pDDSD);
1084
1085 HRESULT HAL_DirectDrawSurface_Create(IDirectDrawImpl *pDD,
1086                                      const DDSURFACEDESC2 *pDDSD,
1087                                      LPDIRECTDRAWSURFACE7 *ppSurf,
1088                                      IUnknown *pUnkOuter);
1089
1090 void HAL_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This);
1091 HRESULT HAL_DirectDrawSurface_late_allocate(IDirectDrawSurfaceImpl* This);
1092
1093 void HAL_DirectDrawSurface_set_palette(IDirectDrawSurfaceImpl* This,
1094                                        IDirectDrawPaletteImpl* pal);
1095 void HAL_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This,
1096                                           IDirectDrawPaletteImpl* pal,
1097                                           DWORD dwStart, DWORD dwCount,
1098                                           LPPALETTEENTRY palent);
1099 HRESULT HAL_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
1100                                                 LPDIRECTDRAWSURFACE7* ppDup);
1101 void HAL_DirectDrawSurface_lock_update(IDirectDrawSurfaceImpl* This,
1102                                        LPCRECT pRect, DWORD dwFlags);
1103 void HAL_DirectDrawSurface_unlock_update(IDirectDrawSurfaceImpl* This,
1104                                          LPCRECT pRect);
1105 BOOL HAL_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front,
1106                                      IDirectDrawSurfaceImpl* back,
1107                                      DWORD dwFlags);
1108 void HAL_DirectDrawSurface_flip_update(IDirectDrawSurfaceImpl* This,
1109                                        DWORD dwFlags);
1110 HWND HAL_DirectDrawSurface_get_display_window(IDirectDrawSurfaceImpl* This);
1111
1112 /*****************************************************************************
1113  * IDirectDrawSurface FAKEZBUFFER declarations
1114  */
1115 typedef struct
1116 {
1117     BOOLEAN in_memory;
1118 } FakeZBuffer_DirectDrawSurfaceImpl;
1119
1120 HRESULT FakeZBuffer_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This,
1121                                                 IDirectDrawImpl* pDD,
1122                                                 const DDSURFACEDESC2* pDDSD);
1123
1124 HRESULT FakeZBuffer_DirectDrawSurface_Create(IDirectDrawImpl* pDD,
1125                                              const DDSURFACEDESC2* pDDSD,
1126                                              LPDIRECTDRAWSURFACE7* ppSurf,
1127                                              IUnknown* pUnkOuter);
1128
1129 void FakeZBuffer_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This);
1130
1131 HRESULT FakeZBuffer_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
1132                                                         LPDIRECTDRAWSURFACE7* ppDup);
1133
1134 #endif /* __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H */