Moved a large number of 16-bit functions to a separate gdi16.c file.
[wine/hacks.git] / dlls / ddraw / ddraw_private.h
blob7ad653968970efe0a2a5d074f121ca1f2471e43e
1 /*
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! */
24 #include "winbase.h"
25 #include "wtypes.h"
26 #include "wingdi.h"
27 #include "winuser.h"
28 #include "ddraw.h"
29 #include "ddcomimpl.h"
30 #include "ddrawi.h"
32 /* XXX Put this somewhere proper. */
33 #define DD_STRUCT_INIT(x) \
34 do { \
35 memset((x), 0, sizeof(*(x))); \
36 (x)->dwSize = sizeof(*x); \
37 } while (0)
39 #define DD_STRUCT_COPY_BYSIZE(to,from) \
40 do { \
41 DWORD __size = (to)->dwSize; \
42 DWORD __copysize = __size; \
43 if ((from)->dwSize < __size) \
44 __copysize = (from)->dwSize; \
45 memcpy(to,from,__copysize); \
46 (to)->dwSize = __size;/*restore size*/ \
47 } while (0)
49 /*****************************************************************************
50 * IDirectDraw implementation structure
53 typedef struct IDirectDrawImpl IDirectDrawImpl;
54 typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl;
55 typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl;
56 typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl;
58 typedef void (*pixel_convert_func)(void *src, void *dst, DWORD width,
59 DWORD height, LONG pitch,
60 IDirectDrawPaletteImpl *palette);
62 typedef void (*palette_convert_func)(LPPALETTEENTRY palent,
63 void *screen_palette, DWORD start,
64 DWORD count);
66 struct IDirectDrawImpl
68 ICOM_VFIELD_MULTI(IDirectDraw7);
69 ICOM_VFIELD_MULTI(IDirectDraw4);
70 ICOM_VFIELD_MULTI(IDirectDraw2);
71 ICOM_VFIELD_MULTI(IDirectDraw);
73 DWORD ref;
75 /* TRUE if created via DirectDrawCreateEx or CoCreateInstance,
76 * FALSE if created via DirectDrawCreate. */
77 BOOL ex;
79 /* Linked list of surfaces, joined by next_ddraw in IDirectSurfaceImpl. */
80 IDirectDrawSurfaceImpl* surfaces;
81 /* Linked list of palettes, joined by next_ddraw. */
82 IDirectDrawPaletteImpl* palettes;
83 /* Linked list of clippers, joined by next_ddraw. */
84 IDirectDrawClipperImpl* clippers;
86 IDirectDrawSurfaceImpl* primary_surface;
88 DDRAWI_DIRECTDRAW_LCL local;
89 DDCAPS caps;
91 HWND window;
92 DWORD cooperative_level;
93 WNDPROC original_wndproc;
95 DWORD width, height;
96 LONG pitch;
97 DDPIXELFORMAT pixelformat;
99 /* Should each of these go into some structure? */
100 DWORD orig_width, orig_height;
101 LONG orig_pitch;
102 DDPIXELFORMAT orig_pixelformat;
104 /* Called when the refcount goes to 0. */
105 void (*final_release)(IDirectDrawImpl *This);
107 HRESULT (*set_exclusive_mode)(IDirectDrawImpl *This, DWORD dwExcl);
109 HRESULT (*create_palette)(IDirectDrawImpl* This, DWORD dwFlags,
110 LPDIRECTDRAWPALETTE* ppPalette,
111 LPUNKNOWN pUnkOuter);
113 /* Surface creation functions. For all of these, pOuter == NULL. */
115 /* Do not create any backbuffers or the flipping chain. */
116 HRESULT (*create_primary)(IDirectDrawImpl* This,
117 const DDSURFACEDESC2* pDDSD,
118 LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
120 /* Primary may be NULL if we are creating an unattached backbuffer. */
121 HRESULT (*create_backbuffer)(IDirectDrawImpl* This,
122 const DDSURFACEDESC2* pDDSD,
123 LPDIRECTDRAWSURFACE7* ppSurf,
124 LPUNKNOWN pOuter,
125 IDirectDrawSurfaceImpl* primary);
127 /* shiny happy offscreenplain surfaces */
128 HRESULT (*create_offscreen)(IDirectDrawImpl* This,
129 const DDSURFACEDESC2* pDDSD,
130 LPDIRECTDRAWSURFACE7* ppSurf,
131 LPUNKNOWN pOuter);
133 /* dwMipMapLevel is specified as per OpenGL. (i.e. 0 is base) */
134 HRESULT (*create_texture)(IDirectDrawImpl* This,
135 const DDSURFACEDESC2* pDDSD,
136 LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter,
137 DWORD dwMipMapLevel);
139 HRESULT (*create_zbuffer)(IDirectDrawImpl* This,
140 const DDSURFACEDESC2* pDDSD,
141 LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
143 LPVOID private;
145 /* Everything below here is still questionable. */
147 DDPIXELFORMAT screen_pixelformat;
149 int pixmap_depth;
150 pixel_convert_func pixel_convert;
151 palette_convert_func palette_convert;
153 /* This is for the fake mainWindow */
154 ATOM winclass;
155 PAINTSTRUCT ps;
156 BOOL paintable;
159 /*****************************************************************************
160 * IDirectDrawPalette implementation structure
162 struct IDirectDrawPaletteImpl
164 /* IUnknown fields */
165 ICOM_VFIELD_MULTI(IDirectDrawPalette);
166 DWORD ref;
168 DDRAWI_DDRAWPALETTE_LCL local;
169 DDRAWI_DDRAWPALETTE_GBL global;
171 /* IDirectDrawPalette fields */
172 HPALETTE hpal;
173 WORD palVersion, palNumEntries; /* LOGPALETTE */
174 PALETTEENTRY palents[256];
175 /* This is to store the palette in 'screen format' */
176 int screen_palents[256];
178 VOID (*final_release)(IDirectDrawPaletteImpl* This);
180 IDirectDrawImpl* ddraw_owner;
181 IDirectDrawPaletteImpl* prev_ddraw;
182 IDirectDrawPaletteImpl* next_ddraw;
184 LPVOID private;
187 /*****************************************************************************
188 * IDirectDrawClipper implementation structure
190 struct IDirectDrawClipperImpl
192 /* IUnknown fields */
193 ICOM_VFIELD_MULTI(IDirectDrawClipper);
194 DWORD ref;
196 /* IDirectDrawClipper fields */
197 HWND hWnd;
199 IDirectDrawImpl* ddraw_owner;
200 IDirectDrawClipperImpl* prev_ddraw;
201 IDirectDrawClipperImpl* next_ddraw;
204 /*****************************************************************************
205 * IDirectDrawSurface implementation structure
208 struct IDirectDrawSurfaceImpl
210 /* IUnknown fields */
211 ICOM_VFIELD_MULTI(IDirectDrawSurface7);
212 ICOM_VFIELD_MULTI(IDirectDrawSurface3);
213 ICOM_VFIELD_MULTI(IDirectDrawGammaControl);
214 DWORD ref;
216 struct IDirectDrawSurfaceImpl* attached; /* attached surfaces */
218 struct IDirectDrawSurfaceImpl* next_ddraw; /* ddraw surface chain */
219 struct IDirectDrawSurfaceImpl* prev_ddraw;
220 struct IDirectDrawSurfaceImpl* next_attached; /* attached surface chain */
221 struct IDirectDrawSurfaceImpl* prev_attached;
223 IDirectDrawImpl* ddraw_owner;
224 IDirectDrawSurfaceImpl* surface_owner;
226 IDirectDrawPaletteImpl* palette; /* strong ref */
227 IDirectDrawClipperImpl* clipper; /* strong ref */
229 DDRAWI_DDRAWSURFACE_LCL local;
230 DDRAWI_DDRAWSURFACE_MORE more;
231 /* FIXME: since Flip should swap the GBL structures, they should
232 * probably not be embedded into the IDirectDrawSurfaceImpl structure... */
233 LPDDRAWI_DDRAWSURFACE_GBL_MORE gmore;
234 DDRAWI_DDRAWSURFACE_GBL global;
235 DDRAWI_DDRAWSURFACE_GBL_MORE global_more;
237 DDSURFACEDESC2 surface_desc;
239 HDC hDC;
240 RECT lastlockrect;
241 BOOL dc_in_use;
243 HRESULT (*duplicate_surface)(IDirectDrawSurfaceImpl* src,
244 LPDIRECTDRAWSURFACE7* dst);
245 void (*final_release)(IDirectDrawSurfaceImpl *This);
246 HRESULT (*late_allocate)(IDirectDrawSurfaceImpl *This);
247 BOOL (*attach)(IDirectDrawSurfaceImpl *This, IDirectDrawSurfaceImpl *to);
248 BOOL (*detach)(IDirectDrawSurfaceImpl *This);
249 void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
250 void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
251 void (*lose_surface)(IDirectDrawSurfaceImpl* This);
252 BOOL (*flip_data)(IDirectDrawSurfaceImpl* front,
253 IDirectDrawSurfaceImpl* back,
254 DWORD dwFlags);
255 void (*flip_update)(IDirectDrawSurfaceImpl* front, DWORD dwFlags);
256 HRESULT (*get_dc)(IDirectDrawSurfaceImpl* This, HDC* phDC);
257 HRESULT (*release_dc)(IDirectDrawSurfaceImpl* This, HDC hDC);
258 void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal);
259 void (*update_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal,
260 DWORD dwStart, DWORD dwCount, LPPALETTEENTRY palent);
261 HWND (*get_display_window)(IDirectDrawSurfaceImpl *This);
262 HRESULT (*get_gamma_ramp)(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp);
263 HRESULT (*set_gamma_ramp)(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp);
265 struct PrivateData* private_data;
267 DWORD max_lod;
268 DWORD priority;
270 BOOL lost;
272 DWORD uniqueness_value;
274 LPVOID private;
276 /* Everything below here is dodgy. */
277 /* For Direct3D use */
278 LPVOID aux_ctx, aux_data;
279 void (*aux_release)(LPVOID ctx, LPVOID data);
280 BOOL (*aux_flip)(LPVOID ctx, LPVOID data);
281 void (*aux_unlock)(LPVOID ctx, LPVOID data, LPRECT lpRect);
282 struct IDirect3DTexture2Impl* texture;
283 HRESULT (WINAPI *SetColorKey_cb)(struct IDirect3DTexture2Impl *texture, DWORD dwFlags, LPDDCOLORKEY ckey ) ;
286 /*****************************************************************************
287 * Driver initialisation functions.
289 BOOL DDRAW_HAL_Init(HINSTANCE, DWORD, LPVOID);
290 BOOL DDRAW_User_Init(HINSTANCE, DWORD, LPVOID);
292 typedef struct {
293 const DDDEVICEIDENTIFIER2* info;
294 int preference; /* how good we are. dga might get 100, xlib 50*/
295 HRESULT (*create)(const GUID*, LPDIRECTDRAW7*, LPUNKNOWN, BOOL ex);
297 /* For IDirectDraw7::Initialize. */
298 HRESULT (*init)(IDirectDrawImpl *, const GUID*);
299 } ddraw_driver;
301 void DDRAW_register_driver(const ddraw_driver*);
303 const ddraw_driver* DDRAW_FindDriver(const GUID* guid);
305 /******************************************************************************
306 * Random utilities
309 /* Get DDSCAPS of surface (shortcutmacro) */
310 #define SDDSCAPS(iface) ((iface)->s.surface_desc.ddsCaps.dwCaps)
311 /* Get the number of bytes per pixel for a given surface */
312 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.u1.dwRGBBitCount+7)/8))
313 #define GET_BPP(desc) PFGET_BPP(desc.u4.ddpfPixelFormat)
315 LONG DDRAW_width_bpp_to_pitch(DWORD width, DWORD bpp);
317 typedef struct {
318 unsigned short bpp,depth;
319 unsigned int rmask,gmask,bmask;
320 } ConvertMode;
322 typedef struct {
323 void (*pixel_convert)(void *src, void *dst, DWORD width, DWORD height, LONG pitch, IDirectDrawPaletteImpl* palette);
324 void (*palette_convert)(LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count);
325 } ConvertFuncs;
327 typedef struct {
328 ConvertMode screen, dest;
329 ConvertFuncs funcs;
330 } Convert;
332 extern Convert ModeEmulations[8];
333 extern int _common_depth_to_pixelformat(DWORD depth,LPDIRECTDRAW ddraw);
335 extern HRESULT create_direct3d(LPVOID *obj,IDirectDrawImpl*);
336 extern HRESULT create_direct3d2(LPVOID *obj,IDirectDrawImpl*);
337 extern HRESULT create_direct3d3(LPVOID *obj,IDirectDrawImpl*);
338 extern HRESULT create_direct3d7(LPVOID *obj,IDirectDrawImpl*);
340 /******************************************************************************
341 * Structure conversion (for thunks)
343 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut);
344 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn,
345 DDDEVICEIDENTIFIER* pOut);
347 /******************************************************************************
348 * Debugging / Flags output functions
350 extern void DDRAW_dump_DDBLTFX(DWORD flagmask);
351 extern void DDRAW_dump_DDBLTFAST(DWORD flagmask);
352 extern void DDRAW_dump_DDBLT(DWORD flagmask);
353 extern void DDRAW_dump_DDSCAPS(const DDSCAPS2 *in);
354 extern void DDRAW_dump_pixelformat_flag(DWORD flagmask);
355 extern void DDRAW_dump_paletteformat(DWORD dwFlags);
356 extern void DDRAW_dump_pixelformat(const DDPIXELFORMAT *in);
357 extern void DDRAW_dump_colorkeyflag(DWORD ck);
358 extern void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd);
359 extern void DDRAW_dump_cooperativelevel(DWORD cooplevel);
360 extern void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY *in);
361 extern void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps);
362 #endif /* __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H */