2 * Copyright 2000-2001 TransGaming Technologies Inc.
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.
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.
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
19 #ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
20 #define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
22 /* MAY NOT CONTAIN X11 or DGA specific includes/defines/structs! */
30 #include "ddcomimpl.h"
33 /* XXX Put this somewhere proper. */
34 #define DD_STRUCT_INIT(x) \
36 memset((x), 0, sizeof(*(x))); \
37 (x)->dwSize = sizeof(*x); \
40 #define DD_STRUCT_COPY_BYSIZE(to,from) \
42 DWORD __size = (to)->dwSize; \
43 DWORD __copysize = __size; \
44 memset(to,0,__size); \
45 if ((from)->dwSize < __size) \
46 __copysize = (from)->dwSize; \
47 memcpy(to,from,__copysize); \
48 (to)->dwSize = __size;/*restore size*/ \
51 /*****************************************************************************
52 * IDirectDraw implementation structure
55 typedef struct IDirectDrawImpl IDirectDrawImpl;
56 typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl;
57 typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl;
58 typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl;
60 typedef void (*pixel_convert_func)(void *src, void *dst, DWORD width,
61 DWORD height, LONG pitch,
62 IDirectDrawPaletteImpl *palette);
64 typedef void (*palette_convert_func)(LPPALETTEENTRY palent,
65 void *screen_palette, DWORD start,
68 struct IDirectDrawImpl
70 ICOM_VFIELD_MULTI(IDirectDraw7);
71 ICOM_VFIELD_MULTI(IDirectDraw4);
72 ICOM_VFIELD_MULTI(IDirectDraw2);
73 ICOM_VFIELD_MULTI(IDirectDraw);
77 /* TRUE if created via DirectDrawCreateEx or CoCreateInstance,
78 * FALSE if created via DirectDrawCreate. */
81 /* Linked list of surfaces, joined by next_ddraw in IDirectSurfaceImpl. */
82 IDirectDrawSurfaceImpl* surfaces;
83 /* Linked list of palettes, joined by next_ddraw. */
84 IDirectDrawPaletteImpl* palettes;
85 /* Linked list of clippers, joined by next_ddraw. */
86 IDirectDrawClipperImpl* clippers;
88 IDirectDrawSurfaceImpl* primary_surface;
90 DDRAWI_DIRECTDRAW_LCL local;
94 DWORD cooperative_level;
95 WNDPROC original_wndproc;
99 DDPIXELFORMAT pixelformat;
101 /* Should each of these go into some structure? */
102 DWORD orig_width, orig_height;
104 DDPIXELFORMAT orig_pixelformat;
106 /* Called when the refcount goes to 0. */
107 void (*final_release)(IDirectDrawImpl *This);
109 HRESULT (*set_exclusive_mode)(IDirectDrawImpl *This, DWORD dwExcl);
111 HRESULT (*create_palette)(IDirectDrawImpl* This, DWORD dwFlags,
112 LPDIRECTDRAWPALETTE* ppPalette,
113 LPUNKNOWN pUnkOuter);
115 /* Surface creation functions. For all of these, pOuter == NULL. */
117 /* Do not create any backbuffers or the flipping chain. */
118 HRESULT (*create_primary)(IDirectDrawImpl* This,
119 const DDSURFACEDESC2* pDDSD,
120 LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
122 /* Primary may be NULL if we are creating an unattached backbuffer. */
123 HRESULT (*create_backbuffer)(IDirectDrawImpl* This,
124 const DDSURFACEDESC2* pDDSD,
125 LPDIRECTDRAWSURFACE7* ppSurf,
127 IDirectDrawSurfaceImpl* primary);
129 /* shiny happy offscreenplain surfaces */
130 HRESULT (*create_offscreen)(IDirectDrawImpl* This,
131 const DDSURFACEDESC2* pDDSD,
132 LPDIRECTDRAWSURFACE7* ppSurf,
135 /* dwMipMapLevel is specified as per OpenGL. (i.e. 0 is base) */
136 HRESULT (*create_texture)(IDirectDrawImpl* This,
137 const DDSURFACEDESC2* pDDSD,
138 LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter,
139 DWORD dwMipMapLevel);
141 HRESULT (*create_zbuffer)(IDirectDrawImpl* This,
142 const DDSURFACEDESC2* pDDSD,
143 LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
147 /* Everything below here is still questionable. */
149 DDPIXELFORMAT screen_pixelformat;
152 pixel_convert_func pixel_convert;
153 palette_convert_func palette_convert;
155 /* Use to fool some too strict games */
156 INT32 (*allocate_memory)(IDirectDrawImpl *This, DWORD mem);
157 void (*free_memory)(IDirectDrawImpl *This, DWORD mem);
158 DWORD total_vidmem, available_vidmem;
160 /* This is to get the D3D object associated to this DDraw object */
161 struct IDirect3DImpl *d3d;
163 /* This is for the fake mainWindow */
169 /*****************************************************************************
170 * IDirectDrawPalette implementation structure
172 struct IDirectDrawPaletteImpl
174 /* IUnknown fields */
175 ICOM_VFIELD_MULTI(IDirectDrawPalette);
178 DDRAWI_DDRAWPALETTE_LCL local;
179 DDRAWI_DDRAWPALETTE_GBL global;
181 /* IDirectDrawPalette fields */
183 WORD palVersion, palNumEntries; /* LOGPALETTE */
184 PALETTEENTRY palents[256];
185 /* This is to store the palette in 'screen format' */
186 int screen_palents[256];
188 VOID (*final_release)(IDirectDrawPaletteImpl* This);
190 IDirectDrawImpl* ddraw_owner;
191 IDirectDrawPaletteImpl* prev_ddraw;
192 IDirectDrawPaletteImpl* next_ddraw;
197 /*****************************************************************************
198 * IDirectDrawClipper implementation structure
200 struct IDirectDrawClipperImpl
202 /* IUnknown fields */
203 ICOM_VFIELD_MULTI(IDirectDrawClipper);
206 /* IDirectDrawClipper fields */
209 IDirectDrawImpl* ddraw_owner;
210 IDirectDrawClipperImpl* prev_ddraw;
211 IDirectDrawClipperImpl* next_ddraw;
214 /*****************************************************************************
215 * IDirectDrawSurface implementation structure
218 struct IDirectDrawSurfaceImpl
220 /* IUnknown fields */
221 ICOM_VFIELD_MULTI(IDirectDrawSurface7);
222 ICOM_VFIELD_MULTI(IDirectDrawSurface3);
223 ICOM_VFIELD_MULTI(IDirectDrawGammaControl);
224 ICOM_VFIELD_MULTI(IDirect3DTexture2);
225 ICOM_VFIELD_MULTI(IDirect3DTexture);
228 struct IDirectDrawSurfaceImpl* attached; /* attached surfaces */
230 struct IDirectDrawSurfaceImpl* next_ddraw; /* ddraw surface chain */
231 struct IDirectDrawSurfaceImpl* prev_ddraw;
232 struct IDirectDrawSurfaceImpl* next_attached; /* attached surface chain */
233 struct IDirectDrawSurfaceImpl* prev_attached;
235 IDirectDrawImpl* ddraw_owner;
236 IDirectDrawSurfaceImpl* surface_owner;
238 IDirectDrawPaletteImpl* palette; /* strong ref */
239 IDirectDrawClipperImpl* clipper; /* strong ref */
241 DDRAWI_DDRAWSURFACE_LCL local;
242 DDRAWI_DDRAWSURFACE_MORE more;
243 /* FIXME: since Flip should swap the GBL structures, they should
244 * probably not be embedded into the IDirectDrawSurfaceImpl structure... */
245 LPDDRAWI_DDRAWSURFACE_GBL_MORE gmore;
246 DDRAWI_DDRAWSURFACE_GBL global;
247 DDRAWI_DDRAWSURFACE_GBL_MORE global_more;
249 DDSURFACEDESC2 surface_desc;
256 HRESULT (*duplicate_surface)(IDirectDrawSurfaceImpl* src,
257 LPDIRECTDRAWSURFACE7* dst);
258 void (*final_release)(IDirectDrawSurfaceImpl *This);
259 HRESULT (*late_allocate)(IDirectDrawSurfaceImpl *This);
260 BOOL (*attach)(IDirectDrawSurfaceImpl *This, IDirectDrawSurfaceImpl *to);
261 BOOL (*detach)(IDirectDrawSurfaceImpl *This);
262 void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
263 void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
264 void (*lose_surface)(IDirectDrawSurfaceImpl* This);
265 BOOL (*flip_data)(IDirectDrawSurfaceImpl* front,
266 IDirectDrawSurfaceImpl* back,
268 void (*flip_update)(IDirectDrawSurfaceImpl* front, DWORD dwFlags);
269 HRESULT (*get_dc)(IDirectDrawSurfaceImpl* This, HDC* phDC);
270 HRESULT (*release_dc)(IDirectDrawSurfaceImpl* This, HDC hDC);
271 void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal);
272 void (*update_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal,
273 DWORD dwStart, DWORD dwCount, LPPALETTEENTRY palent);
274 HWND (*get_display_window)(IDirectDrawSurfaceImpl *This);
275 HRESULT (*get_gamma_ramp)(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp);
276 HRESULT (*set_gamma_ramp)(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp);
278 struct PrivateData* private_data;
285 DWORD uniqueness_value;
289 /* Everything below here is dodgy. */
290 /* For Direct3D use */
291 LPVOID aux_ctx, aux_data;
292 void (*aux_release)(LPVOID ctx, LPVOID data);
293 BOOL (*aux_flip)(LPVOID ctx, LPVOID data);
294 void (*aux_unlock)(LPVOID ctx, LPVOID data, LPRECT lpRect);
295 HRESULT (WINAPI *SetColorKey_cb)(struct IDirectDrawSurfaceImpl *texture, DWORD dwFlags, LPDDCOLORKEY ckey ) ;
296 /* This is to get the D3DDevice object associated to this surface */
297 struct IDirect3DDeviceImpl *d3ddevice;
301 /*****************************************************************************
302 * Driver initialisation functions.
304 BOOL DDRAW_HAL_Init(HINSTANCE, DWORD, LPVOID);
305 BOOL DDRAW_User_Init(HINSTANCE, DWORD, LPVOID);
308 const DDDEVICEIDENTIFIER2* info;
309 int preference; /* how good we are. dga might get 100, xlib 50*/
310 HRESULT (*create)(const GUID*, LPDIRECTDRAW7*, LPUNKNOWN, BOOL ex);
312 /* For IDirectDraw7::Initialize. */
313 HRESULT (*init)(IDirectDrawImpl *, const GUID*);
316 void DDRAW_register_driver(const ddraw_driver*);
318 const ddraw_driver* DDRAW_FindDriver(const GUID* guid);
320 /******************************************************************************
324 /* Get DDSCAPS of surface (shortcutmacro) */
325 #define SDDSCAPS(iface) ((iface)->s.surface_desc.ddsCaps.dwCaps)
326 /* Get the number of bytes per pixel for a given surface */
327 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.u1.dwRGBBitCount+7)/8))
328 #define GET_BPP(desc) PFGET_BPP(desc.u4.ddpfPixelFormat)
330 LONG DDRAW_width_bpp_to_pitch(DWORD width, DWORD bpp);
333 unsigned short bpp,depth;
334 unsigned int rmask,gmask,bmask;
338 void (*pixel_convert)(void *src, void *dst, DWORD width, DWORD height, LONG pitch, IDirectDrawPaletteImpl* palette);
339 void (*palette_convert)(LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count);
343 ConvertMode screen, dest;
347 extern Convert ModeEmulations[8];
348 extern int _common_depth_to_pixelformat(DWORD depth,LPDIRECTDRAW ddraw);
350 /******************************************************************************
351 * Structure conversion (for thunks)
353 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut);
354 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn,
355 DDDEVICEIDENTIFIER* pOut);
357 /******************************************************************************
358 * Debugging / Flags output functions
360 extern void DDRAW_dump_DDBLTFX(DWORD flagmask);
361 extern void DDRAW_dump_DDBLTFAST(DWORD flagmask);
362 extern void DDRAW_dump_DDBLT(DWORD flagmask);
363 extern void DDRAW_dump_DDSCAPS(const DDSCAPS *in);
364 extern void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in);
365 extern void DDRAW_dump_pixelformat_flag(DWORD flagmask);
366 extern void DDRAW_dump_paletteformat(DWORD dwFlags);
367 extern void DDRAW_dump_pixelformat(const DDPIXELFORMAT *in);
368 extern void DDRAW_dump_colorkeyflag(DWORD ck);
369 extern void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd);
370 extern void DDRAW_dump_cooperativelevel(DWORD cooplevel);
371 extern void DDRAW_dump_lockflag(DWORD lockflag);
372 extern void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY *in);
373 extern void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps);
375 /* Used for generic dumping */
382 #define FE(x) { x, #x }
388 void (*func)(const void *);
392 #define DDRAW_dump_flags(flags,names,num_names) DDRAW_dump_flags_(flags, names, num_names, 1)
393 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
395 extern void DDRAW_dump_flags_(DWORD flags, const flag_info* names, size_t num_names, int newline);
396 extern void DDRAW_dump_members(DWORD flags, const void* data, const member_info* mems, size_t num_mems);
398 #endif /* __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H */