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! */
29 #include "ddcomimpl.h"
32 /* XXX Put this somewhere proper. */
33 #define DD_STRUCT_INIT(x) \
35 memset((x), 0, sizeof(*(x))); \
36 (x)->dwSize = sizeof(*x); \
39 #define DD_STRUCT_COPY_BYSIZE(to,from) \
41 DWORD __size = (to)->dwSize; \
42 DWORD __copysize = __size; \
43 memset(to,0,__size); \
44 if ((from)->dwSize < __size) \
45 __copysize = (from)->dwSize; \
46 memcpy(to,from,__copysize); \
47 (to)->dwSize = __size;/*restore size*/ \
50 /*****************************************************************************
51 * IDirectDraw implementation structure
54 typedef struct IDirectDrawImpl IDirectDrawImpl;
55 typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl;
56 typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl;
57 typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl;
59 typedef void (*pixel_convert_func)(void *src, void *dst, DWORD width,
60 DWORD height, LONG pitch,
61 IDirectDrawPaletteImpl *palette);
63 typedef void (*palette_convert_func)(LPPALETTEENTRY palent,
64 void *screen_palette, DWORD start,
67 struct IDirectDrawImpl
69 ICOM_VFIELD_MULTI(IDirectDraw7);
70 ICOM_VFIELD_MULTI(IDirectDraw4);
71 ICOM_VFIELD_MULTI(IDirectDraw2);
72 ICOM_VFIELD_MULTI(IDirectDraw);
76 /* TRUE if created via DirectDrawCreateEx or CoCreateInstance,
77 * FALSE if created via DirectDrawCreate. */
80 /* Linked list of surfaces, joined by next_ddraw in IDirectSurfaceImpl. */
81 IDirectDrawSurfaceImpl* surfaces;
82 /* Linked list of palettes, joined by next_ddraw. */
83 IDirectDrawPaletteImpl* palettes;
84 /* Linked list of clippers, joined by next_ddraw. */
85 IDirectDrawClipperImpl* clippers;
87 IDirectDrawSurfaceImpl* primary_surface;
89 DDRAWI_DIRECTDRAW_LCL local;
93 DWORD cooperative_level;
94 WNDPROC original_wndproc;
98 DDPIXELFORMAT pixelformat;
100 /* Should each of these go into some structure? */
101 DWORD orig_width, orig_height;
103 DDPIXELFORMAT orig_pixelformat;
105 /* Called when the refcount goes to 0. */
106 void (*final_release)(IDirectDrawImpl *This);
108 HRESULT (*set_exclusive_mode)(IDirectDrawImpl *This, DWORD dwExcl);
110 HRESULT (*create_palette)(IDirectDrawImpl* This, DWORD dwFlags,
111 LPDIRECTDRAWPALETTE* ppPalette,
112 LPUNKNOWN pUnkOuter);
114 /* Surface creation functions. For all of these, pOuter == NULL. */
116 /* Do not create any backbuffers or the flipping chain. */
117 HRESULT (*create_primary)(IDirectDrawImpl* This,
118 const DDSURFACEDESC2* pDDSD,
119 LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
121 /* Primary may be NULL if we are creating an unattached backbuffer. */
122 HRESULT (*create_backbuffer)(IDirectDrawImpl* This,
123 const DDSURFACEDESC2* pDDSD,
124 LPDIRECTDRAWSURFACE7* ppSurf,
126 IDirectDrawSurfaceImpl* primary);
128 /* shiny happy offscreenplain surfaces */
129 HRESULT (*create_offscreen)(IDirectDrawImpl* This,
130 const DDSURFACEDESC2* pDDSD,
131 LPDIRECTDRAWSURFACE7* ppSurf,
134 /* dwMipMapLevel is specified as per OpenGL. (i.e. 0 is base) */
135 HRESULT (*create_texture)(IDirectDrawImpl* This,
136 const DDSURFACEDESC2* pDDSD,
137 LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter,
138 DWORD dwMipMapLevel);
140 HRESULT (*create_zbuffer)(IDirectDrawImpl* This,
141 const DDSURFACEDESC2* pDDSD,
142 LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
146 /* Everything below here is still questionable. */
148 DDPIXELFORMAT screen_pixelformat;
151 pixel_convert_func pixel_convert;
152 palette_convert_func palette_convert;
154 /* This is for the fake mainWindow */
160 /*****************************************************************************
161 * IDirectDrawPalette implementation structure
163 struct IDirectDrawPaletteImpl
165 /* IUnknown fields */
166 ICOM_VFIELD_MULTI(IDirectDrawPalette);
169 DDRAWI_DDRAWPALETTE_LCL local;
170 DDRAWI_DDRAWPALETTE_GBL global;
172 /* IDirectDrawPalette fields */
174 WORD palVersion, palNumEntries; /* LOGPALETTE */
175 PALETTEENTRY palents[256];
176 /* This is to store the palette in 'screen format' */
177 int screen_palents[256];
179 VOID (*final_release)(IDirectDrawPaletteImpl* This);
181 IDirectDrawImpl* ddraw_owner;
182 IDirectDrawPaletteImpl* prev_ddraw;
183 IDirectDrawPaletteImpl* next_ddraw;
188 /*****************************************************************************
189 * IDirectDrawClipper implementation structure
191 struct IDirectDrawClipperImpl
193 /* IUnknown fields */
194 ICOM_VFIELD_MULTI(IDirectDrawClipper);
197 /* IDirectDrawClipper fields */
200 IDirectDrawImpl* ddraw_owner;
201 IDirectDrawClipperImpl* prev_ddraw;
202 IDirectDrawClipperImpl* next_ddraw;
205 /*****************************************************************************
206 * IDirectDrawSurface implementation structure
209 struct IDirectDrawSurfaceImpl
211 /* IUnknown fields */
212 ICOM_VFIELD_MULTI(IDirectDrawSurface7);
213 ICOM_VFIELD_MULTI(IDirectDrawSurface3);
214 ICOM_VFIELD_MULTI(IDirectDrawGammaControl);
217 struct IDirectDrawSurfaceImpl* attached; /* attached surfaces */
219 struct IDirectDrawSurfaceImpl* next_ddraw; /* ddraw surface chain */
220 struct IDirectDrawSurfaceImpl* prev_ddraw;
221 struct IDirectDrawSurfaceImpl* next_attached; /* attached surface chain */
222 struct IDirectDrawSurfaceImpl* prev_attached;
224 IDirectDrawImpl* ddraw_owner;
225 IDirectDrawSurfaceImpl* surface_owner;
227 IDirectDrawPaletteImpl* palette; /* strong ref */
228 IDirectDrawClipperImpl* clipper; /* strong ref */
230 DDRAWI_DDRAWSURFACE_LCL local;
231 DDRAWI_DDRAWSURFACE_MORE more;
232 /* FIXME: since Flip should swap the GBL structures, they should
233 * probably not be embedded into the IDirectDrawSurfaceImpl structure... */
234 LPDDRAWI_DDRAWSURFACE_GBL_MORE gmore;
235 DDRAWI_DDRAWSURFACE_GBL global;
236 DDRAWI_DDRAWSURFACE_GBL_MORE global_more;
238 DDSURFACEDESC2 surface_desc;
244 HRESULT (*duplicate_surface)(IDirectDrawSurfaceImpl* src,
245 LPDIRECTDRAWSURFACE7* dst);
246 void (*final_release)(IDirectDrawSurfaceImpl *This);
247 HRESULT (*late_allocate)(IDirectDrawSurfaceImpl *This);
248 BOOL (*attach)(IDirectDrawSurfaceImpl *This, IDirectDrawSurfaceImpl *to);
249 BOOL (*detach)(IDirectDrawSurfaceImpl *This);
250 void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
251 void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
252 void (*lose_surface)(IDirectDrawSurfaceImpl* This);
253 BOOL (*flip_data)(IDirectDrawSurfaceImpl* front,
254 IDirectDrawSurfaceImpl* back,
256 void (*flip_update)(IDirectDrawSurfaceImpl* front, DWORD dwFlags);
257 HRESULT (*get_dc)(IDirectDrawSurfaceImpl* This, HDC* phDC);
258 HRESULT (*release_dc)(IDirectDrawSurfaceImpl* This, HDC hDC);
259 void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal);
260 void (*update_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal,
261 DWORD dwStart, DWORD dwCount, LPPALETTEENTRY palent);
262 HWND (*get_display_window)(IDirectDrawSurfaceImpl *This);
263 HRESULT (*get_gamma_ramp)(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp);
264 HRESULT (*set_gamma_ramp)(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp);
266 struct PrivateData* private_data;
273 DWORD uniqueness_value;
277 /* Everything below here is dodgy. */
278 /* For Direct3D use */
279 LPVOID aux_ctx, aux_data;
280 void (*aux_release)(LPVOID ctx, LPVOID data);
281 BOOL (*aux_flip)(LPVOID ctx, LPVOID data);
282 void (*aux_unlock)(LPVOID ctx, LPVOID data, LPRECT lpRect);
283 struct IDirect3DTextureImpl *texture;
284 HRESULT (WINAPI *SetColorKey_cb)(struct IDirect3DTextureImpl *texture, DWORD dwFlags, LPDDCOLORKEY ckey ) ;
287 /*****************************************************************************
288 * Driver initialisation functions.
290 BOOL DDRAW_HAL_Init(HINSTANCE, DWORD, LPVOID);
291 BOOL DDRAW_User_Init(HINSTANCE, DWORD, LPVOID);
294 const DDDEVICEIDENTIFIER2* info;
295 int preference; /* how good we are. dga might get 100, xlib 50*/
296 HRESULT (*create)(const GUID*, LPDIRECTDRAW7*, LPUNKNOWN, BOOL ex);
298 /* For IDirectDraw7::Initialize. */
299 HRESULT (*init)(IDirectDrawImpl *, const GUID*);
302 void DDRAW_register_driver(const ddraw_driver*);
304 const ddraw_driver* DDRAW_FindDriver(const GUID* guid);
306 /******************************************************************************
310 /* Get DDSCAPS of surface (shortcutmacro) */
311 #define SDDSCAPS(iface) ((iface)->s.surface_desc.ddsCaps.dwCaps)
312 /* Get the number of bytes per pixel for a given surface */
313 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.u1.dwRGBBitCount+7)/8))
314 #define GET_BPP(desc) PFGET_BPP(desc.u4.ddpfPixelFormat)
316 LONG DDRAW_width_bpp_to_pitch(DWORD width, DWORD bpp);
319 unsigned short bpp,depth;
320 unsigned int rmask,gmask,bmask;
324 void (*pixel_convert)(void *src, void *dst, DWORD width, DWORD height, LONG pitch, IDirectDrawPaletteImpl* palette);
325 void (*palette_convert)(LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count);
329 ConvertMode screen, dest;
333 extern Convert ModeEmulations[8];
334 extern int _common_depth_to_pixelformat(DWORD depth,LPDIRECTDRAW ddraw);
336 /******************************************************************************
337 * Structure conversion (for thunks)
339 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut);
340 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn,
341 DDDEVICEIDENTIFIER* pOut);
343 /******************************************************************************
344 * Debugging / Flags output functions
346 extern void DDRAW_dump_DDBLTFX(DWORD flagmask);
347 extern void DDRAW_dump_DDBLTFAST(DWORD flagmask);
348 extern void DDRAW_dump_DDBLT(DWORD flagmask);
349 extern void DDRAW_dump_DDSCAPS(const DDSCAPS *in);
350 extern void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in);
351 extern void DDRAW_dump_pixelformat_flag(DWORD flagmask);
352 extern void DDRAW_dump_paletteformat(DWORD dwFlags);
353 extern void DDRAW_dump_pixelformat(const DDPIXELFORMAT *in);
354 extern void DDRAW_dump_colorkeyflag(DWORD ck);
355 extern void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd);
356 extern void DDRAW_dump_cooperativelevel(DWORD cooplevel);
357 extern void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY *in);
358 extern void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps);
359 #endif /* __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H */