1 /* Copyright 2000-2001 TransGaming Technologies Inc. */
3 #ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
4 #define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
6 /* MAY NOT CONTAIN X11 or DGA specific includes/defines/structs! */
13 #include "ddcomimpl.h"
16 /* XXX Put this somewhere proper. */
17 #define DD_STRUCT_INIT(x) \
19 memset((x), 0, sizeof(*(x))); \
20 (x)->dwSize = sizeof(*x); \
23 #define DD_STRUCT_COPY_BYSIZE(to,from) \
25 DWORD __size = (to)->dwSize; \
26 DWORD __copysize = __size; \
27 if ((from)->dwSize < __size) \
28 __copysize = (from)->dwSize; \
29 memcpy(to,from,__copysize); \
30 (to)->dwSize = __size;/*restore size*/ \
33 /*****************************************************************************
34 * IDirectDraw implementation structure
37 typedef struct IDirectDrawImpl IDirectDrawImpl
;
38 typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl
;
39 typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl
;
40 typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl
;
42 typedef void (*pixel_convert_func
)(void *src
, void *dst
, DWORD width
,
43 DWORD height
, LONG pitch
,
44 IDirectDrawPaletteImpl
*palette
);
46 typedef void (*palette_convert_func
)(LPPALETTEENTRY palent
,
47 void *screen_palette
, DWORD start
,
50 struct IDirectDrawImpl
52 ICOM_VFIELD_MULTI(IDirectDraw7
);
53 ICOM_VFIELD_MULTI(IDirectDraw4
);
54 ICOM_VFIELD_MULTI(IDirectDraw2
);
55 ICOM_VFIELD_MULTI(IDirectDraw
);
59 /* TRUE if created via DirectDrawCreateEx or CoCreateInstance,
60 * FALSE if created via DirectDrawCreate. */
63 /* Linked list of surfaces, joined by next_ddraw in IDirectSurfaceImpl. */
64 IDirectDrawSurfaceImpl
* surfaces
;
65 /* Linked list of palettes, joined by next_ddraw. */
66 IDirectDrawPaletteImpl
* palettes
;
67 /* Linked list of clippers, joined by next_ddraw. */
68 IDirectDrawClipperImpl
* clippers
;
70 IDirectDrawSurfaceImpl
* primary_surface
;
72 DDRAWI_DIRECTDRAW_LCL local
;
76 DWORD cooperative_level
;
77 WNDPROC original_wndproc
;
81 DDPIXELFORMAT pixelformat
;
83 /* Should each of these go into some structure? */
84 DWORD orig_width
, orig_height
;
86 DDPIXELFORMAT orig_pixelformat
;
88 /* Called when the refcount goes to 0. */
89 void (*final_release
)(IDirectDrawImpl
*This
);
91 HRESULT (*set_exclusive_mode
)(IDirectDrawImpl
*This
, DWORD dwExcl
);
93 HRESULT (*create_palette
)(IDirectDrawImpl
* This
, DWORD dwFlags
,
94 LPDIRECTDRAWPALETTE
* ppPalette
,
97 /* Surface creation functions. For all of these, pOuter == NULL. */
99 /* Do not create any backbuffers or the flipping chain. */
100 HRESULT (*create_primary
)(IDirectDrawImpl
* This
,
101 const DDSURFACEDESC2
* pDDSD
,
102 LPDIRECTDRAWSURFACE7
* ppSurf
, LPUNKNOWN pOuter
);
104 /* Primary may be NULL if we are creating an unattached backbuffer. */
105 HRESULT (*create_backbuffer
)(IDirectDrawImpl
* This
,
106 const DDSURFACEDESC2
* pDDSD
,
107 LPDIRECTDRAWSURFACE7
* ppSurf
,
109 IDirectDrawSurfaceImpl
* primary
);
111 /* shiny happy offscreenplain surfaces */
112 HRESULT (*create_offscreen
)(IDirectDrawImpl
* This
,
113 const DDSURFACEDESC2
* pDDSD
,
114 LPDIRECTDRAWSURFACE7
* ppSurf
,
117 /* dwMipMapLevel is specified as per OpenGL. (i.e. 0 is base) */
118 HRESULT (*create_texture
)(IDirectDrawImpl
* This
,
119 const DDSURFACEDESC2
* pDDSD
,
120 LPDIRECTDRAWSURFACE7
* ppSurf
, LPUNKNOWN pOuter
,
121 DWORD dwMipMapLevel
);
123 HRESULT (*create_zbuffer
)(IDirectDrawImpl
* This
,
124 const DDSURFACEDESC2
* pDDSD
,
125 LPDIRECTDRAWSURFACE7
* ppSurf
, LPUNKNOWN pOuter
);
129 /* Everything below here is still questionable. */
131 DDPIXELFORMAT screen_pixelformat
;
134 pixel_convert_func pixel_convert
;
135 palette_convert_func palette_convert
;
137 /* This is for the fake mainWindow */
143 /*****************************************************************************
144 * IDirectDrawPalette implementation structure
146 struct IDirectDrawPaletteImpl
148 /* IUnknown fields */
149 ICOM_VFIELD_MULTI(IDirectDrawPalette
);
152 DDRAWI_DDRAWPALETTE_LCL local
;
153 DDRAWI_DDRAWPALETTE_GBL global
;
155 /* IDirectDrawPalette fields */
158 WORD palVersion
, palNumEntries
; /* LOGPALETTE */
159 PALETTEENTRY palents
[256];
160 /* This is to store the palette in 'screen format' */
161 int screen_palents
[256];
163 VOID (*final_release
)(IDirectDrawPaletteImpl
* This
);
165 IDirectDrawImpl
* ddraw_owner
;
166 IDirectDrawPaletteImpl
* prev_ddraw
;
167 IDirectDrawPaletteImpl
* next_ddraw
;
172 /*****************************************************************************
173 * IDirectDrawClipper implementation structure
175 struct IDirectDrawClipperImpl
177 /* IUnknown fields */
178 ICOM_VFIELD_MULTI(IDirectDrawClipper
);
181 /* IDirectDrawClipper fields */
184 IDirectDrawImpl
* ddraw_owner
;
185 IDirectDrawClipperImpl
* prev_ddraw
;
186 IDirectDrawClipperImpl
* next_ddraw
;
189 /*****************************************************************************
190 * IDirectDrawSurface implementation structure
193 struct IDirectDrawSurfaceImpl
195 /* IUnknown fields */
196 ICOM_VFIELD_MULTI(IDirectDrawSurface7
);
197 ICOM_VFIELD_MULTI(IDirectDrawSurface3
);
198 ICOM_VFIELD_MULTI(IDirectDrawGammaControl
);
201 struct IDirectDrawSurfaceImpl
* attached
; /* attached surfaces */
203 struct IDirectDrawSurfaceImpl
* next_ddraw
; /* ddraw surface chain */
204 struct IDirectDrawSurfaceImpl
* prev_ddraw
;
205 struct IDirectDrawSurfaceImpl
* next_attached
; /* attached surface chain */
206 struct IDirectDrawSurfaceImpl
* prev_attached
;
208 IDirectDrawImpl
* ddraw_owner
;
209 IDirectDrawSurfaceImpl
* surface_owner
;
211 IDirectDrawPaletteImpl
* palette
; /* strong ref */
212 IDirectDrawClipperImpl
* clipper
; /* strong ref */
214 DDRAWI_DDRAWSURFACE_LCL local
;
215 DDRAWI_DDRAWSURFACE_MORE more
;
216 /* FIXME: since Flip should swap the GBL structures, they should
217 * probably not be embedded into the IDirectDrawSurfaceImpl structure... */
218 LPDDRAWI_DDRAWSURFACE_GBL_MORE gmore
;
219 DDRAWI_DDRAWSURFACE_GBL global
;
220 DDRAWI_DDRAWSURFACE_GBL_MORE global_more
;
222 DDSURFACEDESC2 surface_desc
;
228 HRESULT (*duplicate_surface
)(IDirectDrawSurfaceImpl
* src
,
229 LPDIRECTDRAWSURFACE7
* dst
);
230 void (*final_release
)(IDirectDrawSurfaceImpl
*This
);
231 HRESULT (*late_allocate
)(IDirectDrawSurfaceImpl
*This
);
232 BOOL (*attach
)(IDirectDrawSurfaceImpl
*This
, IDirectDrawSurfaceImpl
*to
);
233 BOOL (*detach
)(IDirectDrawSurfaceImpl
*This
);
234 void (*lock_update
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
, DWORD dwFlags
);
235 void (*unlock_update
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
);
236 void (*lose_surface
)(IDirectDrawSurfaceImpl
* This
);
237 BOOL (*flip_data
)(IDirectDrawSurfaceImpl
* front
,
238 IDirectDrawSurfaceImpl
* back
,
240 void (*flip_update
)(IDirectDrawSurfaceImpl
* front
, DWORD dwFlags
);
241 HRESULT (*get_dc
)(IDirectDrawSurfaceImpl
* This
, HDC
* phDC
);
242 HRESULT (*release_dc
)(IDirectDrawSurfaceImpl
* This
, HDC hDC
);
243 void (*set_palette
)(IDirectDrawSurfaceImpl
* This
, IDirectDrawPaletteImpl
* pal
);
244 void (*update_palette
)(IDirectDrawSurfaceImpl
* This
, IDirectDrawPaletteImpl
* pal
,
245 DWORD dwStart
, DWORD dwCount
, LPPALETTEENTRY palent
);
246 HWND (*get_display_window
)(IDirectDrawSurfaceImpl
*This
);
247 HRESULT (*get_gamma_ramp
)(IDirectDrawSurfaceImpl
*This
, DWORD dwFlags
, LPDDGAMMARAMP lpGammaRamp
);
248 HRESULT (*set_gamma_ramp
)(IDirectDrawSurfaceImpl
*This
, DWORD dwFlags
, LPDDGAMMARAMP lpGammaRamp
);
250 struct PrivateData
* private_data
;
257 DWORD uniqueness_value
;
261 /* Everything below here is dodgy. */
262 /* For Direct3D use */
263 LPVOID aux_ctx
, aux_data
;
264 void (*aux_release
)(LPVOID ctx
, LPVOID data
);
265 BOOL (*aux_flip
)(LPVOID ctx
, LPVOID data
);
266 void (*aux_unlock
)(LPVOID ctx
, LPVOID data
, LPRECT lpRect
);
267 struct IDirect3DTexture2Impl
* texture
;
268 HRESULT
WINAPI (*SetColorKey_cb
)(struct IDirect3DTexture2Impl
*texture
, DWORD dwFlags
, LPDDCOLORKEY ckey
) ;
271 /*****************************************************************************
272 * Driver initialisation functions.
274 BOOL
DDRAW_HAL_Init(HINSTANCE
, DWORD
, LPVOID
);
275 BOOL
DDRAW_User_Init(HINSTANCE
, DWORD
, LPVOID
);
278 const DDDEVICEIDENTIFIER2
* info
;
279 int preference
; /* how good we are. dga might get 100, xlib 50*/
280 HRESULT (*create
)(const GUID
*, LPDIRECTDRAW7
*, LPUNKNOWN
, BOOL ex
);
282 /* For IDirectDraw7::Initialize. */
283 HRESULT (*init
)(IDirectDrawImpl
*, const GUID
*);
286 void DDRAW_register_driver(const ddraw_driver
*);
288 const ddraw_driver
* DDRAW_FindDriver(const GUID
* guid
);
290 /******************************************************************************
294 /* Get DDSCAPS of surface (shortcutmacro) */
295 #define SDDSCAPS(iface) ((iface)->s.surface_desc.ddsCaps.dwCaps)
296 /* Get the number of bytes per pixel for a given surface */
297 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.u1.dwRGBBitCount+7)/8))
298 #define GET_BPP(desc) PFGET_BPP(desc.u4.ddpfPixelFormat)
300 LONG
DDRAW_width_bpp_to_pitch(DWORD width
, DWORD bpp
);
303 unsigned short bpp
,depth
;
304 unsigned int rmask
,gmask
,bmask
;
308 void (*pixel_convert
)(void *src
, void *dst
, DWORD width
, DWORD height
, LONG pitch
, IDirectDrawPaletteImpl
* palette
);
309 void (*palette_convert
)(LPPALETTEENTRY palent
, void *screen_palette
, DWORD start
, DWORD count
);
313 ConvertMode screen
, dest
;
317 extern Convert ModeEmulations
[8];
318 extern int _common_depth_to_pixelformat(DWORD depth
,LPDIRECTDRAW ddraw
);
320 extern HRESULT
create_direct3d(LPVOID
*obj
,IDirectDrawImpl
*);
321 extern HRESULT
create_direct3d2(LPVOID
*obj
,IDirectDrawImpl
*);
322 extern HRESULT
create_direct3d3(LPVOID
*obj
,IDirectDrawImpl
*);
323 extern HRESULT
create_direct3d7(LPVOID
*obj
,IDirectDrawImpl
*);
325 /******************************************************************************
326 * Structure conversion (for thunks)
328 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS
* pIn
, DDSCAPS2
* pOut
);
329 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2
* pIn
,
330 DDDEVICEIDENTIFIER
* pOut
);
332 /******************************************************************************
333 * Debugging / Flags output functions
335 extern void DDRAW_dump_DDBLTFX(DWORD flagmask
);
336 extern void DDRAW_dump_DDBLTFAST(DWORD flagmask
);
337 extern void DDRAW_dump_DDBLT(DWORD flagmask
);
338 extern void DDRAW_dump_DDSCAPS(const DDSCAPS2
*in
);
339 extern void DDRAW_dump_pixelformat_flag(DWORD flagmask
);
340 extern void DDRAW_dump_paletteformat(DWORD dwFlags
);
341 extern void DDRAW_dump_pixelformat(const DDPIXELFORMAT
*in
);
342 extern void DDRAW_dump_colorkeyflag(DWORD ck
);
343 extern void DDRAW_dump_surface_desc(const DDSURFACEDESC2
*lpddsd
);
344 extern void DDRAW_dump_cooperativelevel(DWORD cooplevel
);
345 extern void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY
*in
);
346 #endif /* __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H */