1 /* Copyright 2000 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"
15 /* XXX Put this somewhere proper. */
16 #define DD_STRUCT_INIT(x) \
18 memset((x), 0, sizeof(*(x))); \
19 (x)->dwSize = sizeof(*x); \
22 #define DD_STRUCT_COPY_BYSIZE(to,from) \
24 DWORD __size = (to)->dwSize; \
25 DWORD __copysize = __size; \
26 if ((from)->dwSize < __size) \
27 __copysize = (from)->dwSize; \
28 memcpy(to,from,__copysize); \
29 (to)->dwSize = __size;/*restore size*/ \
32 /*****************************************************************************
33 * IDirectDraw implementation structure
36 typedef struct IDirectDrawImpl IDirectDrawImpl;
37 typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl;
38 typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl;
39 typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl;
41 typedef void (*pixel_convert_func)(void *src, void *dst, DWORD width,
42 DWORD height, LONG pitch,
43 IDirectDrawPaletteImpl *palette);
45 typedef void (*palette_convert_func)(LPPALETTEENTRY palent,
46 void *screen_palette, DWORD start,
49 struct IDirectDrawImpl
51 ICOM_VFIELD_MULTI(IDirectDraw7);
52 ICOM_VFIELD_MULTI(IDirectDraw4);
53 ICOM_VFIELD_MULTI(IDirectDraw2);
54 ICOM_VFIELD_MULTI(IDirectDraw);
58 /* TRUE if created via DirectDrawCreateEx or CoCreateInstance,
59 * FALSE if created via DirectDrawCreate. */
62 /* Linked list of surfaces, joined by next_ddraw in IDirectSurfaceImpl. */
63 IDirectDrawSurfaceImpl* surfaces;
64 /* Linked list of palettes, joined by next_ddraw. */
65 IDirectDrawPaletteImpl* palettes;
66 /* Linked list of clippers, joined by next_ddraw. */
67 IDirectDrawClipperImpl* clippers;
69 IDirectDrawSurfaceImpl* primary_surface;
72 DWORD cooperative_level;
73 WNDPROC original_wndproc;
77 DDPIXELFORMAT pixelformat;
79 /* Should each of these go into some structure? */
80 DWORD orig_width, orig_height;
82 DDPIXELFORMAT orig_pixelformat;
84 /* Called when the refcount goes to 0. */
85 void (*final_release)(IDirectDrawImpl *This);
87 HRESULT (*create_palette)(IDirectDrawImpl* This, DWORD dwFlags,
88 LPDIRECTDRAWPALETTE* ppPalette,
91 /* Surface creation functions. For all of these, pOuter == NULL. */
93 /* Do not create any backbuffers or the flipping chain. */
94 HRESULT (*create_primary)(IDirectDrawImpl* This,
95 const DDSURFACEDESC2* pDDSD,
96 LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
98 /* Primary may be NULL if we are creating an unattached backbuffer. */
99 HRESULT (*create_backbuffer)(IDirectDrawImpl* This,
100 const DDSURFACEDESC2* pDDSD,
101 LPDIRECTDRAWSURFACE7* ppSurf,
103 IDirectDrawSurfaceImpl* primary);
105 /* shiny happy offscreenplain surfaces */
106 HRESULT (*create_offscreen)(IDirectDrawImpl* This,
107 const DDSURFACEDESC2* pDDSD,
108 LPDIRECTDRAWSURFACE7* ppSurf,
111 /* dwMipMapLevel is specified as per OpenGL. (i.e. 0 is base) */
112 HRESULT (*create_texture)(IDirectDrawImpl* This,
113 const DDSURFACEDESC2* pDDSD,
114 LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter,
115 DWORD dwMipMapLevel);
117 HRESULT (*create_zbuffer)(IDirectDrawImpl* This,
118 const DDSURFACEDESC2* pDDSD,
119 LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
123 /* Everything below here is still questionable. */
125 DDPIXELFORMAT screen_pixelformat;
128 pixel_convert_func pixel_convert;
129 palette_convert_func palette_convert;
130 const struct tagDC_FUNCS *funcs, *old_funcs; /* DISPLAY.DRV overrides */
132 /* This is for the fake mainWindow */
138 /*****************************************************************************
139 * IDirectDrawPalette implementation structure
141 struct IDirectDrawPaletteImpl
143 /* IUnknown fields */
144 ICOM_VFIELD_MULTI(IDirectDrawPalette);
147 /* IDirectDrawPalette fields */
150 WORD palVersion, palNumEntries; /* LOGPALETTE */
151 PALETTEENTRY palents[256];
152 /* This is to store the palette in 'screen format' */
153 int screen_palents[256];
155 VOID (*final_release)(IDirectDrawPaletteImpl* This);
157 IDirectDrawImpl* ddraw_owner;
158 IDirectDrawPaletteImpl* prev_ddraw;
159 IDirectDrawPaletteImpl* next_ddraw;
164 /*****************************************************************************
165 * IDirectDrawClipper implementation structure
167 struct IDirectDrawClipperImpl
169 /* IUnknown fields */
170 ICOM_VFIELD_MULTI(IDirectDrawClipper);
173 /* IDirectDrawClipper fields */
176 IDirectDrawImpl* ddraw_owner;
177 IDirectDrawClipperImpl* prev_ddraw;
178 IDirectDrawClipperImpl* next_ddraw;
181 /*****************************************************************************
182 * IDirectDrawSurface implementation structure
185 struct IDirectDrawSurfaceImpl
187 /* IUnknown fields */
188 ICOM_VFIELD_MULTI(IDirectDrawSurface7);
189 ICOM_VFIELD_MULTI(IDirectDrawSurface3);
192 struct IDirectDrawSurfaceImpl* attached; /* attached surfaces */
194 struct IDirectDrawSurfaceImpl* next_ddraw; /* ddraw surface chain */
195 struct IDirectDrawSurfaceImpl* prev_ddraw;
196 struct IDirectDrawSurfaceImpl* next_attached; /* attached surface chain */
197 struct IDirectDrawSurfaceImpl* prev_attached;
199 IDirectDrawImpl* ddraw_owner;
200 IDirectDrawSurfaceImpl* surface_owner;
202 IDirectDrawPaletteImpl* palette; /* strong ref */
203 IDirectDrawClipperImpl* clipper; /* strong ref */
205 DDSURFACEDESC2 surface_desc;
210 HRESULT (*duplicate_surface)(IDirectDrawSurfaceImpl* src,
211 LPDIRECTDRAWSURFACE7* dst);
212 void (*final_release)(IDirectDrawSurfaceImpl *This);
213 BOOL (*attach)(IDirectDrawSurfaceImpl *This, IDirectDrawSurfaceImpl *to);
214 BOOL (*detach)(IDirectDrawSurfaceImpl *This);
215 void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
216 void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
217 void (*lose_surface)(IDirectDrawSurfaceImpl* This);
218 void (*flip_data)(IDirectDrawSurfaceImpl* front,
219 IDirectDrawSurfaceImpl* back);
220 void (*flip_update)(IDirectDrawSurfaceImpl* front);
221 HRESULT (*get_dc)(IDirectDrawSurfaceImpl* This, HDC* phDC);
222 HRESULT (*release_dc)(IDirectDrawSurfaceImpl* This, HDC hDC);
223 void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal);
224 void (*update_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal,
225 DWORD dwStart, DWORD dwCount, LPPALETTEENTRY palent);
226 HWND (*get_display_window)(IDirectDrawSurfaceImpl *This);
228 struct PrivateData* private_data;
235 DWORD uniqueness_value;
239 /* Everything below here is dodgy. */
240 /* For Direct3D use */
241 LPVOID aux_ctx, aux_data;
242 void (*aux_release)(LPVOID ctx, LPVOID data);
243 BOOL (*aux_flip)(LPVOID ctx, LPVOID data);
244 void (*aux_unlock)(LPVOID ctx, LPVOID data, LPRECT lpRect);
245 struct IDirect3DTexture2Impl* texture;
246 HRESULT WINAPI (*SetColorKey_cb)(struct IDirect3DTexture2Impl *texture, DWORD dwFlags, LPDDCOLORKEY ckey ) ;
249 /*****************************************************************************
250 * Driver initialisation functions.
252 BOOL DDRAW_User_Init(HINSTANCE, DWORD, LPVOID);
255 const DDDEVICEIDENTIFIER2* info;
256 int preference; /* how good we are. dga might get 100, xlib 50*/
257 HRESULT (*create)(const GUID*, LPDIRECTDRAW7*, LPUNKNOWN, BOOL ex);
259 /* For IDirectDraw7::Initialize. */
260 HRESULT (*init)(IDirectDrawImpl *, const GUID*);
263 void DDRAW_register_driver(const ddraw_driver*);
264 BOOL DDRAW_XVidMode_Init(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv);
265 BOOL DDRAW_XF86DGA2_Init(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv);
267 const ddraw_driver* DDRAW_FindDriver(const GUID* guid);
269 /******************************************************************************
273 /* Get DDSCAPS of surface (shortcutmacro) */
274 #define SDDSCAPS(iface) ((iface)->s.surface_desc.ddsCaps.dwCaps)
275 /* Get the number of bytes per pixel for a given surface */
276 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.u1.dwRGBBitCount+7)/8))
277 #define GET_BPP(desc) PFGET_BPP(desc.u4.ddpfPixelFormat)
279 LONG DDRAW_width_bpp_to_pitch(DWORD width, DWORD bpp);
282 unsigned short bpp,depth;
283 unsigned int rmask,gmask,bmask;
287 void (*pixel_convert)(void *src, void *dst, DWORD width, DWORD height, LONG pitch, IDirectDrawPaletteImpl* palette);
288 void (*palette_convert)(LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count);
292 ConvertMode screen, dest;
296 extern Convert ModeEmulations[8];
297 extern int _common_depth_to_pixelformat(DWORD depth,LPDIRECTDRAW ddraw);
299 extern HRESULT create_direct3d(LPVOID *obj,IDirectDrawImpl*);
300 extern HRESULT create_direct3d2(LPVOID *obj,IDirectDrawImpl*);
301 extern HRESULT create_direct3d3(LPVOID *obj,IDirectDrawImpl*);
302 extern HRESULT create_direct3d7(LPVOID *obj,IDirectDrawImpl*);
304 /******************************************************************************
305 * Structure conversion (for thunks)
307 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut);
308 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER* pIn,
309 DDDEVICEIDENTIFIER2* pOut);
311 /******************************************************************************
312 * Debugging / Flags output functions
314 extern void DDRAW_dump_DDBLTFX(DWORD flagmask);
315 extern void DDRAW_dump_DDBLTFAST(DWORD flagmask);
316 extern void DDRAW_dump_DDBLT(DWORD flagmask);
317 extern void DDRAW_dump_DDSCAPS(const DDSCAPS2 *in);
318 extern void DDRAW_dump_pixelformat_flag(DWORD flagmask);
319 extern void DDRAW_dump_paletteformat(DWORD dwFlags);
320 extern void DDRAW_dump_pixelformat(const DDPIXELFORMAT *in);
321 extern void DDRAW_dump_colorkeyflag(DWORD ck);
322 extern void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd);
323 extern void DDRAW_dump_cooperativelevel(DWORD cooplevel);
324 extern void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY *in);
325 #endif /* __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H */