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 DWORD __resetsize = __size; \
49 if (__resetsize > sizeof(*to)) \
50 __resetsize = sizeof(*to); \
51 memset(to,0,__resetsize); \
52 if ((from)->dwSize < __size) \
53 __copysize = (from)->dwSize; \
54 memcpy(to,from,__copysize); \
55 (to)->dwSize = __size;/*restore size*/ \
58 /*****************************************************************************
59 * IDirectDraw implementation structure
62 typedef struct IDirectDrawImpl IDirectDrawImpl
;
63 typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl
;
64 typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl
;
65 typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl
;
66 typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl
;
68 typedef void (*pixel_convert_func
)(void *src
, void *dst
, DWORD width
,
69 DWORD height
, LONG pitch
,
70 IDirectDrawPaletteImpl
*palette
);
72 typedef void (*palette_convert_func
)(LPPALETTEENTRY palent
,
73 void *screen_palette
, DWORD start
,
76 struct IDirectDrawImpl
78 ICOM_VFIELD_MULTI(IDirectDraw7
);
79 ICOM_VFIELD_MULTI(IDirectDraw4
);
80 ICOM_VFIELD_MULTI(IDirectDraw2
);
81 ICOM_VFIELD_MULTI(IDirectDraw
);
82 ICOM_VFIELD_MULTI(IDirect3D7
);
83 ICOM_VFIELD_MULTI(IDirect3D3
);
84 ICOM_VFIELD_MULTI(IDirect3D2
);
85 ICOM_VFIELD_MULTI(IDirect3D
);
89 /* TRUE if created via DirectDrawCreateEx or CoCreateInstance,
90 * FALSE if created via DirectDrawCreate. */
93 /* Linked list of surfaces, joined by next_ddraw in IDirectSurfaceImpl. */
94 IDirectDrawSurfaceImpl
* surfaces
;
95 /* Linked list of palettes, joined by next_ddraw. */
96 IDirectDrawPaletteImpl
* palettes
;
97 /* Linked list of clippers, joined by next_ddraw. */
98 IDirectDrawClipperImpl
* clippers
;
100 IDirectDrawSurfaceImpl
* primary_surface
;
102 DDRAWI_DIRECTDRAW_LCL local
;
106 DWORD cooperative_level
;
107 WNDPROC original_wndproc
;
111 DDPIXELFORMAT pixelformat
;
113 /* Should each of these go into some structure? */
114 DWORD orig_width
, orig_height
;
116 DDPIXELFORMAT orig_pixelformat
;
118 /* Called when the refcount goes to 0. */
119 void (*final_release
)(IDirectDrawImpl
*This
);
121 HRESULT (*set_exclusive_mode
)(IDirectDrawImpl
*This
, DWORD dwExcl
);
123 HRESULT (*create_palette
)(IDirectDrawImpl
* This
, DWORD dwFlags
,
124 LPDIRECTDRAWPALETTE
* ppPalette
,
125 LPUNKNOWN pUnkOuter
);
127 /* Surface creation functions. For all of these, pOuter == NULL. */
129 /* Do not create any backbuffers or the flipping chain. */
130 HRESULT (*create_primary
)(IDirectDrawImpl
* This
,
131 const DDSURFACEDESC2
* pDDSD
,
132 LPDIRECTDRAWSURFACE7
* ppSurf
, LPUNKNOWN pOuter
);
134 /* Primary may be NULL if we are creating an unattached backbuffer. */
135 HRESULT (*create_backbuffer
)(IDirectDrawImpl
* This
,
136 const DDSURFACEDESC2
* pDDSD
,
137 LPDIRECTDRAWSURFACE7
* ppSurf
,
139 IDirectDrawSurfaceImpl
* primary
);
141 /* shiny happy offscreenplain surfaces */
142 HRESULT (*create_offscreen
)(IDirectDrawImpl
* This
,
143 const DDSURFACEDESC2
* pDDSD
,
144 LPDIRECTDRAWSURFACE7
* ppSurf
,
147 /* dwMipMapLevel is specified as per OpenGL. (i.e. 0 is base) */
148 HRESULT (*create_texture
)(IDirectDrawImpl
* This
,
149 const DDSURFACEDESC2
* pDDSD
,
150 LPDIRECTDRAWSURFACE7
* ppSurf
, LPUNKNOWN pOuter
,
151 DWORD dwMipMapLevel
);
153 HRESULT (*create_zbuffer
)(IDirectDrawImpl
* This
,
154 const DDSURFACEDESC2
* pDDSD
,
155 LPDIRECTDRAWSURFACE7
* ppSurf
, LPUNKNOWN pOuter
);
159 /* Everything below here is still questionable. */
161 DDPIXELFORMAT screen_pixelformat
;
164 pixel_convert_func pixel_convert
;
165 palette_convert_func palette_convert
;
167 /* Use to fool some too strict games */
168 INT32 (*allocate_memory
)(IDirectDrawImpl
*This
, DWORD mem
);
169 void (*free_memory
)(IDirectDrawImpl
*This
, DWORD mem
);
170 DWORD total_vidmem
, available_vidmem
;
172 /* IDirect3D fields */
175 /* Used as a callback function to create a texture */
176 HRESULT (*d3d_create_texture
)(IDirectDrawImpl
*d3d
, IDirectDrawSurfaceImpl
*tex
, BOOLEAN at_creation
, IDirectDrawSurfaceImpl
*main
);
178 /* Used as a callback for Devices to tell to the D3D object it's been created */
179 HRESULT (*d3d_added_device
)(IDirectDrawImpl
*d3d
, IDirect3DDeviceImpl
*device
);
180 HRESULT (*d3d_removed_device
)(IDirectDrawImpl
*d3d
, IDirect3DDeviceImpl
*device
);
182 /* This is needed for delayed texture creation and Z buffer blits */
183 IDirect3DDeviceImpl
*current_device
;
185 /* This is for the fake mainWindow */
191 /*****************************************************************************
192 * IDirectDrawPalette implementation structure
194 struct IDirectDrawPaletteImpl
196 /* IUnknown fields */
197 ICOM_VFIELD_MULTI(IDirectDrawPalette
);
200 DDRAWI_DDRAWPALETTE_LCL local
;
201 DDRAWI_DDRAWPALETTE_GBL global
;
203 /* IDirectDrawPalette fields */
205 WORD palVersion
, palNumEntries
; /* LOGPALETTE */
206 PALETTEENTRY palents
[256];
207 /* This is to store the palette in 'screen format' */
208 int screen_palents
[256];
210 VOID (*final_release
)(IDirectDrawPaletteImpl
* This
);
212 IDirectDrawImpl
* ddraw_owner
;
213 IDirectDrawPaletteImpl
* prev_ddraw
;
214 IDirectDrawPaletteImpl
* next_ddraw
;
219 /*****************************************************************************
220 * IDirectDrawClipper implementation structure
222 struct IDirectDrawClipperImpl
224 /* IUnknown fields */
225 ICOM_VFIELD_MULTI(IDirectDrawClipper
);
228 /* IDirectDrawClipper fields */
231 IDirectDrawImpl
* ddraw_owner
;
232 IDirectDrawClipperImpl
* prev_ddraw
;
233 IDirectDrawClipperImpl
* next_ddraw
;
236 /*****************************************************************************
237 * IDirectDrawSurface implementation structure
240 struct IDirectDrawSurfaceImpl
242 /* IUnknown fields */
243 ICOM_VFIELD_MULTI(IDirectDrawSurface7
);
244 ICOM_VFIELD_MULTI(IDirectDrawSurface3
);
245 ICOM_VFIELD_MULTI(IDirectDrawGammaControl
);
246 ICOM_VFIELD_MULTI(IDirect3DTexture2
);
247 ICOM_VFIELD_MULTI(IDirect3DTexture
);
250 struct IDirectDrawSurfaceImpl
* attached
; /* attached surfaces */
252 struct IDirectDrawSurfaceImpl
* next_ddraw
; /* ddraw surface chain */
253 struct IDirectDrawSurfaceImpl
* prev_ddraw
;
254 struct IDirectDrawSurfaceImpl
* next_attached
; /* attached surface chain */
255 struct IDirectDrawSurfaceImpl
* prev_attached
;
257 IDirectDrawImpl
* ddraw_owner
;
258 IDirectDrawSurfaceImpl
* surface_owner
;
260 IDirectDrawPaletteImpl
* palette
; /* strong ref */
261 IDirectDrawClipperImpl
* clipper
; /* strong ref */
263 DDRAWI_DDRAWSURFACE_LCL local
;
264 DDRAWI_DDRAWSURFACE_MORE more
;
265 /* FIXME: since Flip should swap the GBL structures, they should
266 * probably not be embedded into the IDirectDrawSurfaceImpl structure... */
267 LPDDRAWI_DDRAWSURFACE_GBL_MORE gmore
;
268 DDRAWI_DDRAWSURFACE_GBL global
;
269 DDRAWI_DDRAWSURFACE_GBL_MORE global_more
;
271 DDSURFACEDESC2 surface_desc
;
278 HRESULT (*duplicate_surface
)(IDirectDrawSurfaceImpl
* src
,
279 LPDIRECTDRAWSURFACE7
* dst
);
280 void (*final_release
)(IDirectDrawSurfaceImpl
*This
);
281 HRESULT (*late_allocate
)(IDirectDrawSurfaceImpl
*This
);
282 BOOL (*attach
)(IDirectDrawSurfaceImpl
*This
, IDirectDrawSurfaceImpl
*to
);
283 BOOL (*detach
)(IDirectDrawSurfaceImpl
*This
);
284 void (*lock_update
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
, DWORD dwFlags
);
285 void (*unlock_update
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
);
286 void (*lose_surface
)(IDirectDrawSurfaceImpl
* This
);
287 BOOL (*flip_data
)(IDirectDrawSurfaceImpl
* front
,
288 IDirectDrawSurfaceImpl
* back
,
290 void (*flip_update
)(IDirectDrawSurfaceImpl
* front
, DWORD dwFlags
);
291 HRESULT (*get_dc
)(IDirectDrawSurfaceImpl
* This
, HDC
* phDC
);
292 HRESULT (*release_dc
)(IDirectDrawSurfaceImpl
* This
, HDC hDC
);
293 void (*set_palette
)(IDirectDrawSurfaceImpl
* This
, IDirectDrawPaletteImpl
* pal
);
294 void (*update_palette
)(IDirectDrawSurfaceImpl
* This
, IDirectDrawPaletteImpl
* pal
,
295 DWORD dwStart
, DWORD dwCount
, LPPALETTEENTRY palent
);
296 HWND (*get_display_window
)(IDirectDrawSurfaceImpl
*This
);
297 HRESULT (*get_gamma_ramp
)(IDirectDrawSurfaceImpl
*This
, DWORD dwFlags
, LPDDGAMMARAMP lpGammaRamp
);
298 HRESULT (*set_gamma_ramp
)(IDirectDrawSurfaceImpl
*This
, DWORD dwFlags
, LPDDGAMMARAMP lpGammaRamp
);
300 struct PrivateData
* private_data
;
307 DWORD uniqueness_value
;
311 /* Everything below here is dodgy. */
312 /* For Direct3D use */
313 LPVOID aux_ctx
, aux_data
;
314 void (*aux_release
)(LPVOID ctx
, LPVOID data
);
315 BOOL (*aux_flip
)(LPVOID ctx
, LPVOID data
);
316 void (*aux_unlock
)(LPVOID ctx
, LPVOID data
, LPRECT lpRect
);
317 HRESULT (*aux_blt
)(struct IDirectDrawSurfaceImpl
*This
, LPRECT rdst
, LPDIRECTDRAWSURFACE7 src
, LPRECT rsrc
, DWORD dwFlags
, LPDDBLTFX lpbltfx
);
318 HRESULT (*aux_bltfast
)(struct IDirectDrawSurfaceImpl
*This
, DWORD dstx
, DWORD dsty
, LPDIRECTDRAWSURFACE7 src
, LPRECT rsrc
, DWORD trans
);
319 HRESULT (*aux_setcolorkey_cb
)(struct IDirectDrawSurfaceImpl
*texture
, DWORD dwFlags
, LPDDCOLORKEY ckey
);
320 /* This is to get the D3DDevice object associated to this surface */
321 struct IDirect3DDeviceImpl
*d3ddevice
;
322 /* This is for texture */
323 IDirectDrawSurfaceImpl
*mip_main
;
326 void (*lock_update_prev
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
, DWORD dwFlags
);
327 void (*unlock_update_prev
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
);
328 BOOLEAN (*get_dirty_status
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
);
331 /*****************************************************************************
332 * Driver initialisation functions.
334 BOOL
DDRAW_HAL_Init(HINSTANCE
, DWORD
, LPVOID
);
335 BOOL
DDRAW_User_Init(HINSTANCE
, DWORD
, LPVOID
);
338 const DDDEVICEIDENTIFIER2
* info
;
339 int preference
; /* how good we are. dga might get 100, xlib 50*/
340 HRESULT (*create
)(const GUID
*, LPDIRECTDRAW7
*, LPUNKNOWN
, BOOL ex
);
342 /* For IDirectDraw7::Initialize. */
343 HRESULT (*init
)(IDirectDrawImpl
*, const GUID
*);
346 void DDRAW_register_driver(const ddraw_driver
*);
348 const ddraw_driver
* DDRAW_FindDriver(const GUID
* guid
);
350 /******************************************************************************
354 /* Get DDSCAPS of surface (shortcutmacro) */
355 #define SDDSCAPS(iface) ((iface)->s.surface_desc.ddsCaps.dwCaps)
356 /* Get the number of bytes per pixel for a given surface */
357 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.u1.dwRGBBitCount+7)/8))
358 #define GET_BPP(desc) PFGET_BPP(desc.u4.ddpfPixelFormat)
360 LONG
DDRAW_width_bpp_to_pitch(DWORD width
, DWORD bpp
);
363 unsigned short bpp
,depth
;
364 unsigned int rmask
,gmask
,bmask
;
368 void (*pixel_convert
)(void *src
, void *dst
, DWORD width
, DWORD height
, LONG pitch
, IDirectDrawPaletteImpl
* palette
);
369 void (*palette_convert
)(LPPALETTEENTRY palent
, void *screen_palette
, DWORD start
, DWORD count
);
373 ConvertMode screen
, dest
;
377 extern Convert ModeEmulations
[8];
378 extern int _common_depth_to_pixelformat(DWORD depth
,LPDIRECTDRAW ddraw
);
379 extern BOOL opengl_initialized
;
381 /******************************************************************************
382 * Structure conversion (for thunks)
384 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS
* pIn
, DDSCAPS2
* pOut
);
385 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2
* pIn
,
386 DDDEVICEIDENTIFIER
* pOut
);
388 /******************************************************************************
389 * Debugging / Flags output functions
391 extern void DDRAW_dump_DDBLTFX(DWORD flagmask
);
392 extern void DDRAW_dump_DDBLTFAST(DWORD flagmask
);
393 extern void DDRAW_dump_DDBLT(DWORD flagmask
);
394 extern void DDRAW_dump_DDSCAPS(const DDSCAPS
*in
);
395 extern void DDRAW_dump_DDSCAPS2(const DDSCAPS2
*in
);
396 extern void DDRAW_dump_pixelformat_flag(DWORD flagmask
);
397 extern void DDRAW_dump_paletteformat(DWORD dwFlags
);
398 extern void DDRAW_dump_pixelformat(const DDPIXELFORMAT
*in
);
399 extern void DDRAW_dump_colorkeyflag(DWORD ck
);
400 extern void DDRAW_dump_surface_desc(const DDSURFACEDESC2
*lpddsd
);
401 extern void DDRAW_dump_cooperativelevel(DWORD cooplevel
);
402 extern void DDRAW_dump_lockflag(DWORD lockflag
);
403 extern void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY
*in
);
404 extern void DDRAW_dump_DDCAPS(const DDCAPS
*lpcaps
);
405 extern void DDRAW_dump_surface_to_disk(IDirectDrawSurfaceImpl
*surface
, FILE *f
, int scale
) ;
407 /* Used for generic dumping */
414 #define FE(x) { x, #x }
420 void (*func
)(const void *);
424 #define DDRAW_dump_flags(flags,names,num_names) DDRAW_dump_flags_(flags, names, num_names, 1)
425 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
427 extern void DDRAW_dump_flags_(DWORD flags
, const flag_info
* names
, size_t num_names
, int newline
);
428 extern void DDRAW_dump_members(DWORD flags
, const void* data
, const member_info
* mems
, size_t num_mems
);
430 #endif /* __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H */