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! */
32 #include "ddcomimpl.h"
35 /* XXX Put this somewhere proper. */
36 #define DD_STRUCT_INIT(x) \
38 memset((x), 0, sizeof(*(x))); \
39 (x)->dwSize = sizeof(*x); \
42 #define DD_STRUCT_COPY_BYSIZE(to,from) \
44 DWORD __size = (to)->dwSize; \
45 DWORD __copysize = __size; \
46 memset(to,0,__size); \
47 if ((from)->dwSize < __size) \
48 __copysize = (from)->dwSize; \
49 memcpy(to,from,__copysize); \
50 (to)->dwSize = __size;/*restore size*/ \
53 /*****************************************************************************
54 * IDirectDraw implementation structure
57 typedef struct IDirectDrawImpl IDirectDrawImpl
;
58 typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl
;
59 typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl
;
60 typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl
;
62 typedef void (*pixel_convert_func
)(void *src
, void *dst
, DWORD width
,
63 DWORD height
, LONG pitch
,
64 IDirectDrawPaletteImpl
*palette
);
66 typedef void (*palette_convert_func
)(LPPALETTEENTRY palent
,
67 void *screen_palette
, DWORD start
,
70 struct IDirectDrawImpl
72 ICOM_VFIELD_MULTI(IDirectDraw7
);
73 ICOM_VFIELD_MULTI(IDirectDraw4
);
74 ICOM_VFIELD_MULTI(IDirectDraw2
);
75 ICOM_VFIELD_MULTI(IDirectDraw
);
79 /* TRUE if created via DirectDrawCreateEx or CoCreateInstance,
80 * FALSE if created via DirectDrawCreate. */
83 /* Linked list of surfaces, joined by next_ddraw in IDirectSurfaceImpl. */
84 IDirectDrawSurfaceImpl
* surfaces
;
85 /* Linked list of palettes, joined by next_ddraw. */
86 IDirectDrawPaletteImpl
* palettes
;
87 /* Linked list of clippers, joined by next_ddraw. */
88 IDirectDrawClipperImpl
* clippers
;
90 IDirectDrawSurfaceImpl
* primary_surface
;
92 DDRAWI_DIRECTDRAW_LCL local
;
96 DWORD cooperative_level
;
97 WNDPROC original_wndproc
;
101 DDPIXELFORMAT pixelformat
;
103 /* Should each of these go into some structure? */
104 DWORD orig_width
, orig_height
;
106 DDPIXELFORMAT orig_pixelformat
;
108 /* Called when the refcount goes to 0. */
109 void (*final_release
)(IDirectDrawImpl
*This
);
111 HRESULT (*set_exclusive_mode
)(IDirectDrawImpl
*This
, DWORD dwExcl
);
113 HRESULT (*create_palette
)(IDirectDrawImpl
* This
, DWORD dwFlags
,
114 LPDIRECTDRAWPALETTE
* ppPalette
,
115 LPUNKNOWN pUnkOuter
);
117 /* Surface creation functions. For all of these, pOuter == NULL. */
119 /* Do not create any backbuffers or the flipping chain. */
120 HRESULT (*create_primary
)(IDirectDrawImpl
* This
,
121 const DDSURFACEDESC2
* pDDSD
,
122 LPDIRECTDRAWSURFACE7
* ppSurf
, LPUNKNOWN pOuter
);
124 /* Primary may be NULL if we are creating an unattached backbuffer. */
125 HRESULT (*create_backbuffer
)(IDirectDrawImpl
* This
,
126 const DDSURFACEDESC2
* pDDSD
,
127 LPDIRECTDRAWSURFACE7
* ppSurf
,
129 IDirectDrawSurfaceImpl
* primary
);
131 /* shiny happy offscreenplain surfaces */
132 HRESULT (*create_offscreen
)(IDirectDrawImpl
* This
,
133 const DDSURFACEDESC2
* pDDSD
,
134 LPDIRECTDRAWSURFACE7
* ppSurf
,
137 /* dwMipMapLevel is specified as per OpenGL. (i.e. 0 is base) */
138 HRESULT (*create_texture
)(IDirectDrawImpl
* This
,
139 const DDSURFACEDESC2
* pDDSD
,
140 LPDIRECTDRAWSURFACE7
* ppSurf
, LPUNKNOWN pOuter
,
141 DWORD dwMipMapLevel
);
143 HRESULT (*create_zbuffer
)(IDirectDrawImpl
* This
,
144 const DDSURFACEDESC2
* pDDSD
,
145 LPDIRECTDRAWSURFACE7
* ppSurf
, LPUNKNOWN pOuter
);
149 /* Everything below here is still questionable. */
151 DDPIXELFORMAT screen_pixelformat
;
154 pixel_convert_func pixel_convert
;
155 palette_convert_func palette_convert
;
157 /* Use to fool some too strict games */
158 INT32 (*allocate_memory
)(IDirectDrawImpl
*This
, DWORD mem
);
159 void (*free_memory
)(IDirectDrawImpl
*This
, DWORD mem
);
160 DWORD total_vidmem
, available_vidmem
;
162 /* This is to get the D3D object associated to this DDraw object */
163 struct IDirect3DImpl
*d3d
;
165 /* This is for the fake mainWindow */
171 /*****************************************************************************
172 * IDirectDrawPalette implementation structure
174 struct IDirectDrawPaletteImpl
176 /* IUnknown fields */
177 ICOM_VFIELD_MULTI(IDirectDrawPalette
);
180 DDRAWI_DDRAWPALETTE_LCL local
;
181 DDRAWI_DDRAWPALETTE_GBL global
;
183 /* IDirectDrawPalette fields */
185 WORD palVersion
, palNumEntries
; /* LOGPALETTE */
186 PALETTEENTRY palents
[256];
187 /* This is to store the palette in 'screen format' */
188 int screen_palents
[256];
190 VOID (*final_release
)(IDirectDrawPaletteImpl
* This
);
192 IDirectDrawImpl
* ddraw_owner
;
193 IDirectDrawPaletteImpl
* prev_ddraw
;
194 IDirectDrawPaletteImpl
* next_ddraw
;
199 /*****************************************************************************
200 * IDirectDrawClipper implementation structure
202 struct IDirectDrawClipperImpl
204 /* IUnknown fields */
205 ICOM_VFIELD_MULTI(IDirectDrawClipper
);
208 /* IDirectDrawClipper fields */
211 IDirectDrawImpl
* ddraw_owner
;
212 IDirectDrawClipperImpl
* prev_ddraw
;
213 IDirectDrawClipperImpl
* next_ddraw
;
216 /*****************************************************************************
217 * IDirectDrawSurface implementation structure
220 struct IDirectDrawSurfaceImpl
222 /* IUnknown fields */
223 ICOM_VFIELD_MULTI(IDirectDrawSurface7
);
224 ICOM_VFIELD_MULTI(IDirectDrawSurface3
);
225 ICOM_VFIELD_MULTI(IDirectDrawGammaControl
);
226 ICOM_VFIELD_MULTI(IDirect3DTexture2
);
227 ICOM_VFIELD_MULTI(IDirect3DTexture
);
230 struct IDirectDrawSurfaceImpl
* attached
; /* attached surfaces */
232 struct IDirectDrawSurfaceImpl
* next_ddraw
; /* ddraw surface chain */
233 struct IDirectDrawSurfaceImpl
* prev_ddraw
;
234 struct IDirectDrawSurfaceImpl
* next_attached
; /* attached surface chain */
235 struct IDirectDrawSurfaceImpl
* prev_attached
;
237 IDirectDrawImpl
* ddraw_owner
;
238 IDirectDrawSurfaceImpl
* surface_owner
;
240 IDirectDrawPaletteImpl
* palette
; /* strong ref */
241 IDirectDrawClipperImpl
* clipper
; /* strong ref */
243 DDRAWI_DDRAWSURFACE_LCL local
;
244 DDRAWI_DDRAWSURFACE_MORE more
;
245 /* FIXME: since Flip should swap the GBL structures, they should
246 * probably not be embedded into the IDirectDrawSurfaceImpl structure... */
247 LPDDRAWI_DDRAWSURFACE_GBL_MORE gmore
;
248 DDRAWI_DDRAWSURFACE_GBL global
;
249 DDRAWI_DDRAWSURFACE_GBL_MORE global_more
;
251 DDSURFACEDESC2 surface_desc
;
258 HRESULT (*duplicate_surface
)(IDirectDrawSurfaceImpl
* src
,
259 LPDIRECTDRAWSURFACE7
* dst
);
260 void (*final_release
)(IDirectDrawSurfaceImpl
*This
);
261 HRESULT (*late_allocate
)(IDirectDrawSurfaceImpl
*This
);
262 BOOL (*attach
)(IDirectDrawSurfaceImpl
*This
, IDirectDrawSurfaceImpl
*to
);
263 BOOL (*detach
)(IDirectDrawSurfaceImpl
*This
);
264 void (*lock_update
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
, DWORD dwFlags
);
265 void (*unlock_update
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
);
266 void (*lose_surface
)(IDirectDrawSurfaceImpl
* This
);
267 BOOL (*flip_data
)(IDirectDrawSurfaceImpl
* front
,
268 IDirectDrawSurfaceImpl
* back
,
270 void (*flip_update
)(IDirectDrawSurfaceImpl
* front
, DWORD dwFlags
);
271 HRESULT (*get_dc
)(IDirectDrawSurfaceImpl
* This
, HDC
* phDC
);
272 HRESULT (*release_dc
)(IDirectDrawSurfaceImpl
* This
, HDC hDC
);
273 void (*set_palette
)(IDirectDrawSurfaceImpl
* This
, IDirectDrawPaletteImpl
* pal
);
274 void (*update_palette
)(IDirectDrawSurfaceImpl
* This
, IDirectDrawPaletteImpl
* pal
,
275 DWORD dwStart
, DWORD dwCount
, LPPALETTEENTRY palent
);
276 HWND (*get_display_window
)(IDirectDrawSurfaceImpl
*This
);
277 HRESULT (*get_gamma_ramp
)(IDirectDrawSurfaceImpl
*This
, DWORD dwFlags
, LPDDGAMMARAMP lpGammaRamp
);
278 HRESULT (*set_gamma_ramp
)(IDirectDrawSurfaceImpl
*This
, DWORD dwFlags
, LPDDGAMMARAMP lpGammaRamp
);
280 struct PrivateData
* private_data
;
287 DWORD uniqueness_value
;
291 /* Everything below here is dodgy. */
292 /* For Direct3D use */
293 LPVOID aux_ctx
, aux_data
;
294 void (*aux_release
)(LPVOID ctx
, LPVOID data
);
295 BOOL (*aux_flip
)(LPVOID ctx
, LPVOID data
);
296 void (*aux_unlock
)(LPVOID ctx
, LPVOID data
, LPRECT lpRect
);
297 HRESULT (*aux_blt
)(struct IDirectDrawSurfaceImpl
*This
, LPRECT rdst
, LPDIRECTDRAWSURFACE7 src
, LPRECT rsrc
, DWORD dwFlags
, LPDDBLTFX lpbltfx
);
298 HRESULT (*aux_bltfast
)(struct IDirectDrawSurfaceImpl
*This
, DWORD dstx
, DWORD dsty
, LPDIRECTDRAWSURFACE7 src
, LPRECT rsrc
, DWORD trans
);
299 HRESULT (*aux_setcolorkey_cb
)(struct IDirectDrawSurfaceImpl
*texture
, DWORD dwFlags
, LPDDCOLORKEY ckey
);
300 /* This is to get the D3DDevice object associated to this surface */
301 struct IDirect3DDeviceImpl
*d3ddevice
;
302 /* This is for texture */
303 IDirectDrawSurfaceImpl
*mip_main
;
308 /*****************************************************************************
309 * Driver initialisation functions.
311 BOOL
DDRAW_HAL_Init(HINSTANCE
, DWORD
, LPVOID
);
312 BOOL
DDRAW_User_Init(HINSTANCE
, DWORD
, LPVOID
);
315 const DDDEVICEIDENTIFIER2
* info
;
316 int preference
; /* how good we are. dga might get 100, xlib 50*/
317 HRESULT (*create
)(const GUID
*, LPDIRECTDRAW7
*, LPUNKNOWN
, BOOL ex
);
319 /* For IDirectDraw7::Initialize. */
320 HRESULT (*init
)(IDirectDrawImpl
*, const GUID
*);
323 void DDRAW_register_driver(const ddraw_driver
*);
325 const ddraw_driver
* DDRAW_FindDriver(const GUID
* guid
);
327 /******************************************************************************
331 /* Get DDSCAPS of surface (shortcutmacro) */
332 #define SDDSCAPS(iface) ((iface)->s.surface_desc.ddsCaps.dwCaps)
333 /* Get the number of bytes per pixel for a given surface */
334 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.u1.dwRGBBitCount+7)/8))
335 #define GET_BPP(desc) PFGET_BPP(desc.u4.ddpfPixelFormat)
337 LONG
DDRAW_width_bpp_to_pitch(DWORD width
, DWORD bpp
);
340 unsigned short bpp
,depth
;
341 unsigned int rmask
,gmask
,bmask
;
345 void (*pixel_convert
)(void *src
, void *dst
, DWORD width
, DWORD height
, LONG pitch
, IDirectDrawPaletteImpl
* palette
);
346 void (*palette_convert
)(LPPALETTEENTRY palent
, void *screen_palette
, DWORD start
, DWORD count
);
350 ConvertMode screen
, dest
;
354 extern Convert ModeEmulations
[8];
355 extern int _common_depth_to_pixelformat(DWORD depth
,LPDIRECTDRAW ddraw
);
357 /******************************************************************************
358 * Structure conversion (for thunks)
360 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS
* pIn
, DDSCAPS2
* pOut
);
361 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2
* pIn
,
362 DDDEVICEIDENTIFIER
* pOut
);
364 /******************************************************************************
365 * Debugging / Flags output functions
367 extern void DDRAW_dump_DDBLTFX(DWORD flagmask
);
368 extern void DDRAW_dump_DDBLTFAST(DWORD flagmask
);
369 extern void DDRAW_dump_DDBLT(DWORD flagmask
);
370 extern void DDRAW_dump_DDSCAPS(const DDSCAPS
*in
);
371 extern void DDRAW_dump_DDSCAPS2(const DDSCAPS2
*in
);
372 extern void DDRAW_dump_pixelformat_flag(DWORD flagmask
);
373 extern void DDRAW_dump_paletteformat(DWORD dwFlags
);
374 extern void DDRAW_dump_pixelformat(const DDPIXELFORMAT
*in
);
375 extern void DDRAW_dump_colorkeyflag(DWORD ck
);
376 extern void DDRAW_dump_surface_desc(const DDSURFACEDESC2
*lpddsd
);
377 extern void DDRAW_dump_cooperativelevel(DWORD cooplevel
);
378 extern void DDRAW_dump_lockflag(DWORD lockflag
);
379 extern void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY
*in
);
380 extern void DDRAW_dump_DDCAPS(const DDCAPS
*lpcaps
);
381 extern void DDRAW_dump_surface_to_disk(IDirectDrawSurfaceImpl
*surface
, FILE *f
) ;
383 /* Used for generic dumping */
390 #define FE(x) { x, #x }
396 void (*func
)(const void *);
400 #define DDRAW_dump_flags(flags,names,num_names) DDRAW_dump_flags_(flags, names, num_names, 1)
401 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
403 extern void DDRAW_dump_flags_(DWORD flags
, const flag_info
* names
, size_t num_names
, int newline
);
404 extern void DDRAW_dump_members(DWORD flags
, const void* data
, const member_info
* mems
, size_t num_mems
);
406 #endif /* __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H */