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! */
34 #include "ddcomimpl.h"
37 /* XXX Put this somewhere proper. */
38 #define DD_STRUCT_INIT(x) \
40 memset((x), 0, sizeof(*(x))); \
41 (x)->dwSize = sizeof(*x); \
44 #define DD_STRUCT_COPY_BYSIZE(to,from) \
46 DWORD __size = (to)->dwSize; \
47 DWORD __copysize = __size; \
48 memset(to,0,__size); \
49 if ((from)->dwSize < __size) \
50 __copysize = (from)->dwSize; \
51 memcpy(to,from,__copysize); \
52 (to)->dwSize = __size;/*restore size*/ \
55 /*****************************************************************************
56 * IDirectDraw implementation structure
59 typedef struct IDirectDrawImpl IDirectDrawImpl
;
60 typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl
;
61 typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl
;
62 typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl
;
63 typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl
;
65 typedef void (*pixel_convert_func
)(void *src
, void *dst
, DWORD width
,
66 DWORD height
, LONG pitch
,
67 IDirectDrawPaletteImpl
*palette
);
69 typedef void (*palette_convert_func
)(LPPALETTEENTRY palent
,
70 void *screen_palette
, DWORD start
,
73 struct IDirectDrawImpl
75 ICOM_VFIELD_MULTI(IDirectDraw7
);
76 ICOM_VFIELD_MULTI(IDirectDraw4
);
77 ICOM_VFIELD_MULTI(IDirectDraw2
);
78 ICOM_VFIELD_MULTI(IDirectDraw
);
79 ICOM_VFIELD_MULTI(IDirect3D7
);
80 ICOM_VFIELD_MULTI(IDirect3D3
);
81 ICOM_VFIELD_MULTI(IDirect3D2
);
82 ICOM_VFIELD_MULTI(IDirect3D
);
86 /* TRUE if created via DirectDrawCreateEx or CoCreateInstance,
87 * FALSE if created via DirectDrawCreate. */
90 /* Linked list of surfaces, joined by next_ddraw in IDirectSurfaceImpl. */
91 IDirectDrawSurfaceImpl
* surfaces
;
92 /* Linked list of palettes, joined by next_ddraw. */
93 IDirectDrawPaletteImpl
* palettes
;
94 /* Linked list of clippers, joined by next_ddraw. */
95 IDirectDrawClipperImpl
* clippers
;
97 IDirectDrawSurfaceImpl
* primary_surface
;
99 DDRAWI_DIRECTDRAW_LCL local
;
103 DWORD cooperative_level
;
104 WNDPROC original_wndproc
;
108 DDPIXELFORMAT pixelformat
;
110 /* Should each of these go into some structure? */
111 DWORD orig_width
, orig_height
;
113 DDPIXELFORMAT orig_pixelformat
;
115 /* Called when the refcount goes to 0. */
116 void (*final_release
)(IDirectDrawImpl
*This
);
118 HRESULT (*set_exclusive_mode
)(IDirectDrawImpl
*This
, DWORD dwExcl
);
120 HRESULT (*create_palette
)(IDirectDrawImpl
* This
, DWORD dwFlags
,
121 LPDIRECTDRAWPALETTE
* ppPalette
,
122 LPUNKNOWN pUnkOuter
);
124 /* Surface creation functions. For all of these, pOuter == NULL. */
126 /* Do not create any backbuffers or the flipping chain. */
127 HRESULT (*create_primary
)(IDirectDrawImpl
* This
,
128 const DDSURFACEDESC2
* pDDSD
,
129 LPDIRECTDRAWSURFACE7
* ppSurf
, LPUNKNOWN pOuter
);
131 /* Primary may be NULL if we are creating an unattached backbuffer. */
132 HRESULT (*create_backbuffer
)(IDirectDrawImpl
* This
,
133 const DDSURFACEDESC2
* pDDSD
,
134 LPDIRECTDRAWSURFACE7
* ppSurf
,
136 IDirectDrawSurfaceImpl
* primary
);
138 /* shiny happy offscreenplain surfaces */
139 HRESULT (*create_offscreen
)(IDirectDrawImpl
* This
,
140 const DDSURFACEDESC2
* pDDSD
,
141 LPDIRECTDRAWSURFACE7
* ppSurf
,
144 /* dwMipMapLevel is specified as per OpenGL. (i.e. 0 is base) */
145 HRESULT (*create_texture
)(IDirectDrawImpl
* This
,
146 const DDSURFACEDESC2
* pDDSD
,
147 LPDIRECTDRAWSURFACE7
* ppSurf
, LPUNKNOWN pOuter
,
148 DWORD dwMipMapLevel
);
150 HRESULT (*create_zbuffer
)(IDirectDrawImpl
* This
,
151 const DDSURFACEDESC2
* pDDSD
,
152 LPDIRECTDRAWSURFACE7
* ppSurf
, LPUNKNOWN pOuter
);
156 /* Everything below here is still questionable. */
158 DDPIXELFORMAT screen_pixelformat
;
161 pixel_convert_func pixel_convert
;
162 palette_convert_func palette_convert
;
164 /* Use to fool some too strict games */
165 INT32 (*allocate_memory
)(IDirectDrawImpl
*This
, DWORD mem
);
166 void (*free_memory
)(IDirectDrawImpl
*This
, DWORD mem
);
167 DWORD total_vidmem
, available_vidmem
;
169 /* IDirect3D fields */
172 /* Used as a callback function to create a texture */
173 HRESULT (*d3d_create_texture
)(IDirectDrawImpl
*d3d
, IDirectDrawSurfaceImpl
*tex
, BOOLEAN at_creation
, IDirectDrawSurfaceImpl
*main
);
175 /* Used as a callback for Devices to tell to the D3D object it's been created */
176 HRESULT (*d3d_added_device
)(IDirectDrawImpl
*d3d
, IDirect3DDeviceImpl
*device
);
177 HRESULT (*d3d_removed_device
)(IDirectDrawImpl
*d3d
, IDirect3DDeviceImpl
*device
);
179 /* This is needed for delayed texture creation and Z buffer blits */
180 IDirect3DDeviceImpl
*current_device
;
182 /* This is for the fake mainWindow */
188 /*****************************************************************************
189 * IDirectDrawPalette implementation structure
191 struct IDirectDrawPaletteImpl
193 /* IUnknown fields */
194 ICOM_VFIELD_MULTI(IDirectDrawPalette
);
197 DDRAWI_DDRAWPALETTE_LCL local
;
198 DDRAWI_DDRAWPALETTE_GBL global
;
200 /* IDirectDrawPalette fields */
202 WORD palVersion
, palNumEntries
; /* LOGPALETTE */
203 PALETTEENTRY palents
[256];
204 /* This is to store the palette in 'screen format' */
205 int screen_palents
[256];
207 VOID (*final_release
)(IDirectDrawPaletteImpl
* This
);
209 IDirectDrawImpl
* ddraw_owner
;
210 IDirectDrawPaletteImpl
* prev_ddraw
;
211 IDirectDrawPaletteImpl
* next_ddraw
;
216 /*****************************************************************************
217 * IDirectDrawClipper implementation structure
219 struct IDirectDrawClipperImpl
221 /* IUnknown fields */
222 ICOM_VFIELD_MULTI(IDirectDrawClipper
);
225 /* IDirectDrawClipper fields */
228 IDirectDrawImpl
* ddraw_owner
;
229 IDirectDrawClipperImpl
* prev_ddraw
;
230 IDirectDrawClipperImpl
* next_ddraw
;
233 /*****************************************************************************
234 * IDirectDrawSurface implementation structure
237 struct IDirectDrawSurfaceImpl
239 /* IUnknown fields */
240 ICOM_VFIELD_MULTI(IDirectDrawSurface7
);
241 ICOM_VFIELD_MULTI(IDirectDrawSurface3
);
242 ICOM_VFIELD_MULTI(IDirectDrawGammaControl
);
243 ICOM_VFIELD_MULTI(IDirect3DTexture2
);
244 ICOM_VFIELD_MULTI(IDirect3DTexture
);
247 struct IDirectDrawSurfaceImpl
* attached
; /* attached surfaces */
249 struct IDirectDrawSurfaceImpl
* next_ddraw
; /* ddraw surface chain */
250 struct IDirectDrawSurfaceImpl
* prev_ddraw
;
251 struct IDirectDrawSurfaceImpl
* next_attached
; /* attached surface chain */
252 struct IDirectDrawSurfaceImpl
* prev_attached
;
254 IDirectDrawImpl
* ddraw_owner
;
255 IDirectDrawSurfaceImpl
* surface_owner
;
257 IDirectDrawPaletteImpl
* palette
; /* strong ref */
258 IDirectDrawClipperImpl
* clipper
; /* strong ref */
260 DDRAWI_DDRAWSURFACE_LCL local
;
261 DDRAWI_DDRAWSURFACE_MORE more
;
262 /* FIXME: since Flip should swap the GBL structures, they should
263 * probably not be embedded into the IDirectDrawSurfaceImpl structure... */
264 LPDDRAWI_DDRAWSURFACE_GBL_MORE gmore
;
265 DDRAWI_DDRAWSURFACE_GBL global
;
266 DDRAWI_DDRAWSURFACE_GBL_MORE global_more
;
268 DDSURFACEDESC2 surface_desc
;
275 HRESULT (*duplicate_surface
)(IDirectDrawSurfaceImpl
* src
,
276 LPDIRECTDRAWSURFACE7
* dst
);
277 void (*final_release
)(IDirectDrawSurfaceImpl
*This
);
278 HRESULT (*late_allocate
)(IDirectDrawSurfaceImpl
*This
);
279 BOOL (*attach
)(IDirectDrawSurfaceImpl
*This
, IDirectDrawSurfaceImpl
*to
);
280 BOOL (*detach
)(IDirectDrawSurfaceImpl
*This
);
281 void (*lock_update
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
, DWORD dwFlags
);
282 void (*unlock_update
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
);
283 void (*lose_surface
)(IDirectDrawSurfaceImpl
* This
);
284 BOOL (*flip_data
)(IDirectDrawSurfaceImpl
* front
,
285 IDirectDrawSurfaceImpl
* back
,
287 void (*flip_update
)(IDirectDrawSurfaceImpl
* front
, DWORD dwFlags
);
288 HRESULT (*get_dc
)(IDirectDrawSurfaceImpl
* This
, HDC
* phDC
);
289 HRESULT (*release_dc
)(IDirectDrawSurfaceImpl
* This
, HDC hDC
);
290 void (*set_palette
)(IDirectDrawSurfaceImpl
* This
, IDirectDrawPaletteImpl
* pal
);
291 void (*update_palette
)(IDirectDrawSurfaceImpl
* This
, IDirectDrawPaletteImpl
* pal
,
292 DWORD dwStart
, DWORD dwCount
, LPPALETTEENTRY palent
);
293 HWND (*get_display_window
)(IDirectDrawSurfaceImpl
*This
);
294 HRESULT (*get_gamma_ramp
)(IDirectDrawSurfaceImpl
*This
, DWORD dwFlags
, LPDDGAMMARAMP lpGammaRamp
);
295 HRESULT (*set_gamma_ramp
)(IDirectDrawSurfaceImpl
*This
, DWORD dwFlags
, LPDDGAMMARAMP lpGammaRamp
);
297 struct PrivateData
* private_data
;
304 DWORD uniqueness_value
;
308 /* Everything below here is dodgy. */
309 /* For Direct3D use */
310 LPVOID aux_ctx
, aux_data
;
311 void (*aux_release
)(LPVOID ctx
, LPVOID data
);
312 BOOL (*aux_flip
)(LPVOID ctx
, LPVOID data
);
313 void (*aux_unlock
)(LPVOID ctx
, LPVOID data
, LPRECT lpRect
);
314 HRESULT (*aux_blt
)(struct IDirectDrawSurfaceImpl
*This
, LPRECT rdst
, LPDIRECTDRAWSURFACE7 src
, LPRECT rsrc
, DWORD dwFlags
, LPDDBLTFX lpbltfx
);
315 HRESULT (*aux_bltfast
)(struct IDirectDrawSurfaceImpl
*This
, DWORD dstx
, DWORD dsty
, LPDIRECTDRAWSURFACE7 src
, LPRECT rsrc
, DWORD trans
);
316 HRESULT (*aux_setcolorkey_cb
)(struct IDirectDrawSurfaceImpl
*texture
, DWORD dwFlags
, LPDDCOLORKEY ckey
);
317 /* This is to get the D3DDevice object associated to this surface */
318 struct IDirect3DDeviceImpl
*d3ddevice
;
319 /* This is for texture */
320 IDirectDrawSurfaceImpl
*mip_main
;
323 void (*lock_update_prev
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
, DWORD dwFlags
);
324 void (*unlock_update_prev
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
);
327 /*****************************************************************************
328 * Driver initialisation functions.
330 BOOL
DDRAW_HAL_Init(HINSTANCE
, DWORD
, LPVOID
);
331 BOOL
DDRAW_User_Init(HINSTANCE
, DWORD
, LPVOID
);
334 const DDDEVICEIDENTIFIER2
* info
;
335 int preference
; /* how good we are. dga might get 100, xlib 50*/
336 HRESULT (*create
)(const GUID
*, LPDIRECTDRAW7
*, LPUNKNOWN
, BOOL ex
);
338 /* For IDirectDraw7::Initialize. */
339 HRESULT (*init
)(IDirectDrawImpl
*, const GUID
*);
342 void DDRAW_register_driver(const ddraw_driver
*);
344 const ddraw_driver
* DDRAW_FindDriver(const GUID
* guid
);
346 /******************************************************************************
350 /* Get DDSCAPS of surface (shortcutmacro) */
351 #define SDDSCAPS(iface) ((iface)->s.surface_desc.ddsCaps.dwCaps)
352 /* Get the number of bytes per pixel for a given surface */
353 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.u1.dwRGBBitCount+7)/8))
354 #define GET_BPP(desc) PFGET_BPP(desc.u4.ddpfPixelFormat)
356 LONG
DDRAW_width_bpp_to_pitch(DWORD width
, DWORD bpp
);
359 unsigned short bpp
,depth
;
360 unsigned int rmask
,gmask
,bmask
;
364 void (*pixel_convert
)(void *src
, void *dst
, DWORD width
, DWORD height
, LONG pitch
, IDirectDrawPaletteImpl
* palette
);
365 void (*palette_convert
)(LPPALETTEENTRY palent
, void *screen_palette
, DWORD start
, DWORD count
);
369 ConvertMode screen
, dest
;
373 extern Convert ModeEmulations
[8];
374 extern int _common_depth_to_pixelformat(DWORD depth
,LPDIRECTDRAW ddraw
);
375 extern BOOL opengl_initialized
;
377 /******************************************************************************
378 * Structure conversion (for thunks)
380 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS
* pIn
, DDSCAPS2
* pOut
);
381 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2
* pIn
,
382 DDDEVICEIDENTIFIER
* pOut
);
384 /******************************************************************************
385 * Debugging / Flags output functions
387 extern void DDRAW_dump_DDBLTFX(DWORD flagmask
);
388 extern void DDRAW_dump_DDBLTFAST(DWORD flagmask
);
389 extern void DDRAW_dump_DDBLT(DWORD flagmask
);
390 extern void DDRAW_dump_DDSCAPS(const DDSCAPS
*in
);
391 extern void DDRAW_dump_DDSCAPS2(const DDSCAPS2
*in
);
392 extern void DDRAW_dump_pixelformat_flag(DWORD flagmask
);
393 extern void DDRAW_dump_paletteformat(DWORD dwFlags
);
394 extern void DDRAW_dump_pixelformat(const DDPIXELFORMAT
*in
);
395 extern void DDRAW_dump_colorkeyflag(DWORD ck
);
396 extern void DDRAW_dump_surface_desc(const DDSURFACEDESC2
*lpddsd
);
397 extern void DDRAW_dump_cooperativelevel(DWORD cooplevel
);
398 extern void DDRAW_dump_lockflag(DWORD lockflag
);
399 extern void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY
*in
);
400 extern void DDRAW_dump_DDCAPS(const DDCAPS
*lpcaps
);
401 extern void DDRAW_dump_surface_to_disk(IDirectDrawSurfaceImpl
*surface
, FILE *f
) ;
403 /* Used for generic dumping */
410 #define FE(x) { x, #x }
416 void (*func
)(const void *);
420 #define DDRAW_dump_flags(flags,names,num_names) DDRAW_dump_flags_(flags, names, num_names, 1)
421 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
423 extern void DDRAW_dump_flags_(DWORD flags
, const flag_info
* names
, size_t num_names
, int newline
);
424 extern void DDRAW_dump_members(DWORD flags
, const void* data
, const member_info
* mems
, size_t num_mems
);
426 #endif /* __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H */