Synchronize with trunk r58457.
[reactos.git] / dll / directx / wine / ddraw / ddraw_private.h
1 /*
2 * Copyright 2006 Stefan Dösinger
3 *
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.
8 *
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.
13 *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
20 #define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
21
22 #define _INC_WINDOWS
23 #define COM_NO_WINDOWS_H
24
25 #include <assert.h>
26 #define COBJMACROS
27 #define NONAMELESSSTRUCT
28 #define NONAMELESSUNION
29 #include <wine/debug.h>
30
31 #include <winbase.h>
32 #include <wingdi.h>
33 #include "winuser.h"
34 #include <winuser.h>
35
36 #include <d3d.h>
37 //#include "ddraw.h"
38 #ifdef DDRAW_INIT_GUID
39 #include <initguid.h>
40 #endif
41 #include <wine/list.h>
42 #include <wine/wined3d.h>
43
44 enum ddraw_surface_type
45 {
46 DDRAW_SURFACE_TYPE_OPENGL,
47 DDRAW_SURFACE_TYPE_GDI,
48 };
49
50 extern const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops DECLSPEC_HIDDEN;
51 extern enum ddraw_surface_type DefaultSurfaceType DECLSPEC_HIDDEN;
52 extern DWORD force_refresh_rate DECLSPEC_HIDDEN;
53
54 /*****************************************************************************
55 * IDirectDraw implementation structure
56 *****************************************************************************/
57 struct FvfToDecl
58 {
59 DWORD fvf;
60 struct wined3d_vertex_declaration *decl;
61 };
62
63 struct ddraw
64 {
65 /* Interfaces */
66 IDirectDraw7 IDirectDraw7_iface;
67 IDirectDraw4 IDirectDraw4_iface;
68 IDirectDraw2 IDirectDraw2_iface;
69 IDirectDraw IDirectDraw_iface;
70 IDirect3D7 IDirect3D7_iface;
71 IDirect3D3 IDirect3D3_iface;
72 IDirect3D2 IDirect3D2_iface;
73 IDirect3D IDirect3D_iface;
74 struct wined3d_device_parent device_parent;
75
76 /* See comment in IDirectDraw::AddRef */
77 LONG ref7, ref4, ref2, ref3, ref1, numIfaces;
78 BOOL initialized;
79
80 struct wined3d *wined3d;
81 struct wined3d_device *wined3d_device;
82 BOOL d3d_initialized;
83 BOOL restore_mode;
84
85 struct ddraw_surface *primary;
86 RECT primary_lock;
87 struct wined3d_surface *wined3d_frontbuffer;
88 struct wined3d_swapchain *wined3d_swapchain;
89 HWND swapchain_window;
90
91 /* DirectDraw things, which are not handled by WineD3D */
92 DWORD cooperative_level;
93
94 /* D3D things */
95 HWND d3d_window;
96 struct d3d_device *d3ddevice;
97 int d3dversion;
98
99 /* Various HWNDs */
100 HWND focuswindow;
101 HWND devicewindow;
102 HWND dest_window;
103
104 /* For the dll unload cleanup code */
105 struct list ddraw_list_entry;
106 /* The surface list - can't relay this to WineD3D
107 * because of IParent
108 */
109 struct list surface_list;
110
111 /* FVF management */
112 struct FvfToDecl *decls;
113 UINT numConvertedDecls, declArraySize;
114 };
115
116 #define DDRAW_WINDOW_CLASS_NAME "DirectDrawDeviceWnd"
117
118 HRESULT ddraw_init(struct ddraw *ddraw, enum wined3d_device_type device_type) DECLSPEC_HIDDEN;
119 void ddraw_destroy_swapchain(struct ddraw *ddraw) DECLSPEC_HIDDEN;
120
121 static inline void ddraw_set_swapchain_window(struct ddraw *ddraw, HWND window)
122 {
123 if (window == GetDesktopWindow())
124 window = NULL;
125 ddraw->swapchain_window = window;
126 }
127
128 /* Utility functions */
129 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS *pIn, DDSCAPS2 *pOut) DECLSPEC_HIDDEN;
130 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2 *pIn, DDDEVICEIDENTIFIER *pOut) DECLSPEC_HIDDEN;
131 struct wined3d_vertex_declaration *ddraw_find_decl(struct ddraw *ddraw, DWORD fvf) DECLSPEC_HIDDEN;
132
133 struct ddraw_surface
134 {
135 /* IUnknown fields */
136 IDirectDrawSurface7 IDirectDrawSurface7_iface;
137 IDirectDrawSurface4 IDirectDrawSurface4_iface;
138 IDirectDrawSurface3 IDirectDrawSurface3_iface;
139 IDirectDrawSurface2 IDirectDrawSurface2_iface;
140 IDirectDrawSurface IDirectDrawSurface_iface;
141 IDirectDrawGammaControl IDirectDrawGammaControl_iface;
142 IDirect3DTexture2 IDirect3DTexture2_iface;
143 IDirect3DTexture IDirect3DTexture_iface;
144
145 LONG ref7, ref4, ref3, ref2, ref1, iface_count, gamma_count;
146 IUnknown *ifaceToRelease;
147 IUnknown *texture_outer;
148
149 int version;
150
151 /* Connections to other Objects */
152 struct ddraw *ddraw;
153 struct wined3d_surface *wined3d_surface;
154 struct wined3d_texture *wined3d_texture;
155 struct d3d_device *device1;
156
157 /* This implementation handles attaching surfaces to other surfaces */
158 struct ddraw_surface *next_attached;
159 struct ddraw_surface *first_attached;
160 IUnknown *attached_iface;
161
162 /* Complex surfaces are organized in a tree, although the tree is degenerated to a list in most cases.
163 * In mipmap and primary surfaces each level has only one attachment, which is the next surface level.
164 * Only the cube texture root has 6 surfaces attached, which then have a normal mipmap chain attached
165 * to them. So hardcode the array to 6, a dynamic array or a list would be an overkill.
166 */
167 #define MAX_COMPLEX_ATTACHED 6
168 struct ddraw_surface *complex_array[MAX_COMPLEX_ATTACHED];
169 /* You can't traverse the tree upwards. Only a flag for Surface::Release because its needed there,
170 * but no pointer to prevent temptations to traverse it in the wrong direction.
171 */
172 BOOL is_complex_root;
173
174 /* Surface description, for GetAttachedSurface */
175 DDSURFACEDESC2 surface_desc;
176
177 /* Misc things */
178 DWORD uniqueness_value;
179 UINT mipmap_level;
180
181 /* Clipper objects */
182 struct ddraw_clipper *clipper;
183
184 /* For the ddraw surface list */
185 struct list surface_list_entry;
186
187 DWORD Handle;
188 };
189
190 HRESULT ddraw_surface_create_texture(struct ddraw_surface *surface) DECLSPEC_HIDDEN;
191 HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
192 DDSURFACEDESC2 *desc, UINT version) DECLSPEC_HIDDEN;
193 ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN;
194
195 static inline struct ddraw_surface *impl_from_IDirect3DTexture(IDirect3DTexture *iface)
196 {
197 return CONTAINING_RECORD(iface, struct ddraw_surface, IDirect3DTexture_iface);
198 }
199
200 static inline struct ddraw_surface *impl_from_IDirect3DTexture2(IDirect3DTexture2 *iface)
201 {
202 return CONTAINING_RECORD(iface, struct ddraw_surface, IDirect3DTexture2_iface);
203 }
204
205 static inline struct ddraw_surface *impl_from_IDirectDrawSurface(IDirectDrawSurface *iface)
206 {
207 return CONTAINING_RECORD(iface, struct ddraw_surface, IDirectDrawSurface_iface);
208 }
209
210 static inline struct ddraw_surface *impl_from_IDirectDrawSurface2(IDirectDrawSurface2 *iface)
211 {
212 return CONTAINING_RECORD(iface, struct ddraw_surface, IDirectDrawSurface2_iface);
213 }
214
215 static inline struct ddraw_surface *impl_from_IDirectDrawSurface3(IDirectDrawSurface3 *iface)
216 {
217 return CONTAINING_RECORD(iface, struct ddraw_surface, IDirectDrawSurface3_iface);
218 }
219
220 static inline struct ddraw_surface *impl_from_IDirectDrawSurface4(IDirectDrawSurface4 *iface)
221 {
222 return CONTAINING_RECORD(iface, struct ddraw_surface, IDirectDrawSurface4_iface);
223 }
224
225 static inline struct ddraw_surface *impl_from_IDirectDrawSurface7(IDirectDrawSurface7 *iface)
226 {
227 return CONTAINING_RECORD(iface, struct ddraw_surface, IDirectDrawSurface7_iface);
228 }
229
230 struct ddraw_surface *unsafe_impl_from_IDirectDrawSurface(IDirectDrawSurface *iface) DECLSPEC_HIDDEN;
231 struct ddraw_surface *unsafe_impl_from_IDirectDrawSurface4(IDirectDrawSurface4 *iface) DECLSPEC_HIDDEN;
232 struct ddraw_surface *unsafe_impl_from_IDirectDrawSurface7(IDirectDrawSurface7 *iface) DECLSPEC_HIDDEN;
233
234 struct ddraw_surface *unsafe_impl_from_IDirect3DTexture(IDirect3DTexture *iface) DECLSPEC_HIDDEN;
235 struct ddraw_surface *unsafe_impl_from_IDirect3DTexture2(IDirect3DTexture2 *iface) DECLSPEC_HIDDEN;
236
237 #define DDRAW_INVALID_HANDLE ~0U
238
239 enum ddraw_handle_type
240 {
241 DDRAW_HANDLE_FREE,
242 DDRAW_HANDLE_MATERIAL,
243 DDRAW_HANDLE_MATRIX,
244 DDRAW_HANDLE_STATEBLOCK,
245 DDRAW_HANDLE_SURFACE,
246 };
247
248 struct ddraw_handle_entry
249 {
250 void *object;
251 enum ddraw_handle_type type;
252 };
253
254 struct ddraw_handle_table
255 {
256 struct ddraw_handle_entry *entries;
257 struct ddraw_handle_entry *free_entries;
258 UINT table_size;
259 UINT entry_count;
260 };
261
262 BOOL ddraw_handle_table_init(struct ddraw_handle_table *t, UINT initial_size) DECLSPEC_HIDDEN;
263 void ddraw_handle_table_destroy(struct ddraw_handle_table *t) DECLSPEC_HIDDEN;
264 DWORD ddraw_allocate_handle(struct ddraw_handle_table *t, void *object, enum ddraw_handle_type type) DECLSPEC_HIDDEN;
265 void *ddraw_free_handle(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type) DECLSPEC_HIDDEN;
266 void *ddraw_get_object(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type) DECLSPEC_HIDDEN;
267
268 struct d3d_device
269 {
270 /* IUnknown */
271 IDirect3DDevice7 IDirect3DDevice7_iface;
272 IDirect3DDevice3 IDirect3DDevice3_iface;
273 IDirect3DDevice2 IDirect3DDevice2_iface;
274 IDirect3DDevice IDirect3DDevice_iface;
275 IUnknown IUnknown_inner;
276 LONG ref;
277 UINT version;
278
279 IUnknown *outer_unknown;
280 struct wined3d_device *wined3d_device;
281 struct ddraw *ddraw;
282 struct ddraw_surface *target;
283
284 struct wined3d_buffer *index_buffer;
285 UINT index_buffer_size;
286 UINT index_buffer_pos;
287
288 struct wined3d_buffer *vertex_buffer;
289 UINT vertex_buffer_size;
290 UINT vertex_buffer_pos;
291
292 /* Viewport management */
293 struct list viewport_list;
294 struct d3d_viewport *current_viewport;
295 D3DVIEWPORT7 active_viewport;
296
297 /* Required to keep track which of two available texture blending modes in d3ddevice3 is used */
298 BOOL legacyTextureBlending;
299
300 D3DMATRIX legacy_projection;
301 D3DMATRIX legacy_clipspace;
302
303 /* Light state */
304 DWORD material;
305
306 /* Rendering functions to wrap D3D(1-3) to D3D7 */
307 D3DPRIMITIVETYPE primitive_type;
308 DWORD vertex_type;
309 DWORD render_flags;
310 DWORD nb_vertices;
311 LPBYTE sysmem_vertex_buffer;
312 DWORD vertex_size;
313 DWORD buffer_size;
314
315 /* Handle management */
316 struct ddraw_handle_table handle_table;
317 D3DMATRIXHANDLE world, proj, view;
318 };
319
320 HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target,
321 UINT version, struct d3d_device **device, IUnknown *outer_unknown) DECLSPEC_HIDDEN;
322 enum wined3d_depth_buffer_type d3d_device_update_depth_stencil(struct d3d_device *device) DECLSPEC_HIDDEN;
323
324 /* The IID */
325 extern const GUID IID_D3DDEVICE_WineD3D DECLSPEC_HIDDEN;
326
327 /* Helper functions */
328 HRESULT IDirect3DImpl_GetCaps(const struct wined3d *wined3d,
329 D3DDEVICEDESC *Desc123, D3DDEVICEDESC7 *Desc7) DECLSPEC_HIDDEN;
330
331 static inline struct d3d_device *impl_from_IDirect3DDevice(IDirect3DDevice *iface)
332 {
333 return CONTAINING_RECORD(iface, struct d3d_device, IDirect3DDevice_iface);
334 }
335
336 static inline struct d3d_device *impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface)
337 {
338 return CONTAINING_RECORD(iface, struct d3d_device, IDirect3DDevice2_iface);
339 }
340
341 static inline struct d3d_device *impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface)
342 {
343 return CONTAINING_RECORD(iface, struct d3d_device, IDirect3DDevice3_iface);
344 }
345
346 static inline struct d3d_device *impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface)
347 {
348 return CONTAINING_RECORD(iface, struct d3d_device, IDirect3DDevice7_iface);
349 }
350
351 struct d3d_device *unsafe_impl_from_IDirect3DDevice(IDirect3DDevice *iface) DECLSPEC_HIDDEN;
352 struct d3d_device *unsafe_impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface) DECLSPEC_HIDDEN;
353 struct d3d_device *unsafe_impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface) DECLSPEC_HIDDEN;
354 struct d3d_device *unsafe_impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface) DECLSPEC_HIDDEN;
355
356 struct ddraw_clipper
357 {
358 IDirectDrawClipper IDirectDrawClipper_iface;
359 LONG ref;
360 HWND window;
361 HRGN region;
362 BOOL initialized;
363 };
364
365 HRESULT ddraw_clipper_init(struct ddraw_clipper *clipper) DECLSPEC_HIDDEN;
366 struct ddraw_clipper *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface) DECLSPEC_HIDDEN;
367
368 /*****************************************************************************
369 * IDirectDrawPalette implementation structure
370 *****************************************************************************/
371 struct ddraw_palette
372 {
373 /* IUnknown fields */
374 IDirectDrawPalette IDirectDrawPalette_iface;
375 LONG ref;
376
377 struct wined3d_palette *wineD3DPalette;
378
379 /* IDirectDrawPalette fields */
380 IUnknown *ifaceToRelease;
381 };
382
383 static inline struct ddraw_palette *impl_from_IDirectDrawPalette(IDirectDrawPalette *iface)
384 {
385 return CONTAINING_RECORD(iface, struct ddraw_palette, IDirectDrawPalette_iface);
386 }
387
388 struct ddraw_palette *unsafe_impl_from_IDirectDrawPalette(IDirectDrawPalette *iface) DECLSPEC_HIDDEN;
389
390 HRESULT ddraw_palette_init(struct ddraw_palette *palette,
391 struct ddraw *ddraw, DWORD flags, PALETTEENTRY *entries) DECLSPEC_HIDDEN;
392
393 /* Helper structures */
394 struct object_creation_info
395 {
396 const CLSID *clsid;
397 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID riid,
398 void **ppObj);
399 };
400
401 /******************************************************************************
402 * IDirect3DLight implementation structure - Wraps to D3D7
403 ******************************************************************************/
404 struct d3d_light
405 {
406 IDirect3DLight IDirect3DLight_iface;
407 LONG ref;
408
409 /* IDirect3DLight fields */
410 struct ddraw *ddraw;
411
412 /* If this light is active for one viewport, put the viewport here */
413 struct d3d_viewport *active_viewport;
414
415 D3DLIGHT2 light;
416 D3DLIGHT7 light7;
417
418 DWORD dwLightIndex;
419
420 struct list entry;
421 };
422
423 /* Helper functions */
424 void light_activate(struct d3d_light *light) DECLSPEC_HIDDEN;
425 void light_deactivate(struct d3d_light *light) DECLSPEC_HIDDEN;
426 void d3d_light_init(struct d3d_light *light, struct ddraw *ddraw) DECLSPEC_HIDDEN;
427 struct d3d_light *unsafe_impl_from_IDirect3DLight(IDirect3DLight *iface) DECLSPEC_HIDDEN;
428
429 /******************************************************************************
430 * IDirect3DMaterial implementation structure - Wraps to D3D7
431 ******************************************************************************/
432 struct d3d_material
433 {
434 IDirect3DMaterial3 IDirect3DMaterial3_iface;
435 IDirect3DMaterial2 IDirect3DMaterial2_iface;
436 IDirect3DMaterial IDirect3DMaterial_iface;
437 LONG ref;
438
439 /* IDirect3DMaterial2 fields */
440 struct ddraw *ddraw;
441 struct d3d_device *active_device;
442
443 D3DMATERIAL mat;
444 DWORD Handle;
445 };
446
447 /* Helper functions */
448 void material_activate(struct d3d_material *material) DECLSPEC_HIDDEN;
449 struct d3d_material *d3d_material_create(struct ddraw *ddraw) DECLSPEC_HIDDEN;
450
451 /*****************************************************************************
452 * IDirect3DViewport - Wraps to D3D7
453 *****************************************************************************/
454 struct d3d_viewport
455 {
456 IDirect3DViewport3 IDirect3DViewport3_iface;
457 LONG ref;
458
459 /* IDirect3DViewport fields */
460 struct ddraw *ddraw;
461
462 /* If this viewport is active for one device, put the device here */
463 struct d3d_device *active_device;
464
465 DWORD num_lights;
466 DWORD map_lights;
467
468 int use_vp2;
469
470 union
471 {
472 D3DVIEWPORT vp1;
473 D3DVIEWPORT2 vp2;
474 } viewports;
475
476 struct list entry;
477 struct list light_list;
478 struct d3d_material *background;
479 };
480
481 struct d3d_viewport *unsafe_impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface) DECLSPEC_HIDDEN;
482 struct d3d_viewport *unsafe_impl_from_IDirect3DViewport2(IDirect3DViewport2 *iface) DECLSPEC_HIDDEN;
483 struct d3d_viewport *unsafe_impl_from_IDirect3DViewport(IDirect3DViewport *iface) DECLSPEC_HIDDEN;
484
485 /* Helper functions */
486 void viewport_activate(struct d3d_viewport *viewport, BOOL ignore_lights) DECLSPEC_HIDDEN;
487 void d3d_viewport_init(struct d3d_viewport *viewport, struct ddraw *ddraw) DECLSPEC_HIDDEN;
488
489 /*****************************************************************************
490 * IDirect3DExecuteBuffer - Wraps to D3D7
491 *****************************************************************************/
492 struct d3d_execute_buffer
493 {
494 IDirect3DExecuteBuffer IDirect3DExecuteBuffer_iface;
495 LONG ref;
496 /* IDirect3DExecuteBuffer fields */
497 struct ddraw *ddraw;
498 struct d3d_device *d3ddev;
499
500 D3DEXECUTEBUFFERDESC desc;
501 D3DEXECUTEDATA data;
502
503 /* This buffer will store the transformed vertices */
504 void *vertex_data;
505 WORD *indices;
506 unsigned int nb_indices;
507 unsigned int nb_vertices;
508
509 /* This flags is set to TRUE if we allocated ourselves the
510 * data buffer
511 */
512 BOOL need_free;
513 };
514
515 HRESULT d3d_execute_buffer_init(struct d3d_execute_buffer *execute_buffer,
516 struct d3d_device *device, D3DEXECUTEBUFFERDESC *desc) DECLSPEC_HIDDEN;
517 struct d3d_execute_buffer *unsafe_impl_from_IDirect3DExecuteBuffer(IDirect3DExecuteBuffer *iface) DECLSPEC_HIDDEN;
518
519 /* The execute function */
520 HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *execute_buffer,
521 struct d3d_device *device, struct d3d_viewport *viewport) DECLSPEC_HIDDEN;
522
523 /*****************************************************************************
524 * IDirect3DVertexBuffer
525 *****************************************************************************/
526 struct d3d_vertex_buffer
527 {
528 IDirect3DVertexBuffer7 IDirect3DVertexBuffer7_iface;
529 IDirect3DVertexBuffer IDirect3DVertexBuffer_iface;
530 LONG ref;
531
532 /*** WineD3D and ddraw links ***/
533 struct wined3d_buffer *wineD3DVertexBuffer;
534 struct wined3d_vertex_declaration *wineD3DVertexDeclaration;
535 struct ddraw *ddraw;
536
537 /*** Storage for D3D7 specific things ***/
538 DWORD Caps;
539 DWORD fvf;
540 DWORD size;
541 BOOL dynamic;
542
543 BOOL read_since_last_map;
544 };
545
546 HRESULT d3d_vertex_buffer_create(struct d3d_vertex_buffer **buffer, struct ddraw *ddraw,
547 D3DVERTEXBUFFERDESC *desc) DECLSPEC_HIDDEN;
548 struct d3d_vertex_buffer *unsafe_impl_from_IDirect3DVertexBuffer(IDirect3DVertexBuffer *iface) DECLSPEC_HIDDEN;
549 struct d3d_vertex_buffer *unsafe_impl_from_IDirect3DVertexBuffer7(IDirect3DVertexBuffer7 *iface) DECLSPEC_HIDDEN;
550
551 /*****************************************************************************
552 * Helper functions from utils.c
553 *****************************************************************************/
554
555 #define GET_TEXCOUNT_FROM_FVF(d3dvtVertexType) \
556 (((d3dvtVertexType) & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT)
557
558 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
559 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
560
561 void PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat, enum wined3d_format_id WineD3DFormat) DECLSPEC_HIDDEN;
562 enum wined3d_format_id PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat) DECLSPEC_HIDDEN;
563 void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd) DECLSPEC_HIDDEN;
564 void dump_D3DMATRIX(const D3DMATRIX *mat) DECLSPEC_HIDDEN;
565 void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps) DECLSPEC_HIDDEN;
566 DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
567 void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in) DECLSPEC_HIDDEN;
568 void DDRAW_dump_cooperativelevel(DWORD cooplevel) DECLSPEC_HIDDEN;
569 void DDSD_to_DDSD2(const DDSURFACEDESC *in, DDSURFACEDESC2 *out) DECLSPEC_HIDDEN;
570 void DDSD2_to_DDSD(const DDSURFACEDESC2 *in, DDSURFACEDESC *out) DECLSPEC_HIDDEN;
571
572 void multiply_matrix(D3DMATRIX *dst, const D3DMATRIX *src1, const D3DMATRIX *src2) DECLSPEC_HIDDEN;
573
574 /* Used for generic dumping */
575 struct flag_info
576 {
577 DWORD val;
578 const char *name;
579 };
580
581 #define FE(x) { x, #x }
582
583 struct member_info
584 {
585 DWORD val;
586 const char *name;
587 void (*func)(const void *);
588 ptrdiff_t offset;
589 };
590
591 /* Structure copy */
592 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
593
594 #define DD_STRUCT_COPY_BYSIZE_(to,from,from_size) \
595 do { \
596 DWORD __size = (to)->dwSize; \
597 DWORD __resetsize = min(__size, sizeof(*to)); \
598 DWORD __copysize = min(__resetsize, from_size); \
599 assert(to != from); \
600 memcpy(to, from, __copysize); \
601 memset((char*)(to) + __copysize, 0, __resetsize - __copysize); \
602 (to)->dwSize = __size; /* restore size */ \
603 } while (0)
604
605 #define DD_STRUCT_COPY_BYSIZE(to,from) DD_STRUCT_COPY_BYSIZE_(to,from,(from)->dwSize)
606
607 #define SIZEOF_END_PADDING(type, last_field) \
608 (sizeof(type) - offsetof(type, last_field) - sizeof(((type *)0)->last_field))
609
610 static inline void copy_to_surfacedesc2(DDSURFACEDESC2 *to, DDSURFACEDESC2 *from)
611 {
612 DWORD from_size = from->dwSize;
613 if (from_size == sizeof(DDSURFACEDESC))
614 from_size -= SIZEOF_END_PADDING(DDSURFACEDESC, ddsCaps);
615 to->dwSize = sizeof(DDSURFACEDESC2); /* for struct copy */
616 DD_STRUCT_COPY_BYSIZE_(to, from, from_size);
617 }
618
619 HRESULT hr_ddraw_from_wined3d(HRESULT hr) DECLSPEC_HIDDEN;
620
621 #endif