msxml3: Added fixmes to stubs.
[wine] / dlls / 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 /* MAY NOT CONTAIN X11 or DGA specific includes/defines/structs! */
23
24 #include <stdarg.h>
25 #include <stdio.h>
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wtypes.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "ddraw.h"
33 #include "ddrawi.h"
34 #include "d3d.h"
35
36 #include "ddcomimpl.h"
37
38 #include "wine/wined3d_interface.h"
39 #include "wine/list.h"
40
41 /*****************************************************************************
42  * IParent - a helper interface
43  *****************************************************************************/
44 DEFINE_GUID(IID_IParent, 0xc20e4c88, 0x74e7, 0x4940, 0xba, 0x9f, 0x2e, 0x32, 0x3f, 0x9d, 0xc9, 0x81);
45 typedef struct IParent *LPPARENT, *PPARENT;
46
47 #define INTERFACE IParent
48 DECLARE_INTERFACE_(IParent,IUnknown)
49 {
50     /*** IUnknown methods ***/
51     STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
52     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
53     STDMETHOD_(ULONG,Release)(THIS) PURE;
54 };
55 #undef INTERFACE
56
57 #if !defined(__cplusplus) || defined(CINTERFACE)
58 /*** IUnknown methods ***/
59 #define IParent_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
60 #define IParent_AddRef(p)             (p)->lpVtbl->AddRef(p)
61 #define IParent_Release(p)            (p)->lpVtbl->Release(p)
62 #endif
63
64
65 /* Typdef the interfaces */
66 typedef struct IDirectDrawImpl            IDirectDrawImpl;
67 typedef struct IDirectDrawSurfaceImpl     IDirectDrawSurfaceImpl;
68 typedef struct IDirectDrawClipperImpl     IDirectDrawClipperImpl;
69 typedef struct IDirectDrawPaletteImpl     IDirectDrawPaletteImpl;
70 typedef struct IDirect3DDeviceImpl        IDirect3DDeviceImpl;
71 typedef struct IDirect3DLightImpl         IDirect3DLightImpl;
72 typedef struct IDirect3DViewportImpl      IDirect3DViewportImpl;
73 typedef struct IDirect3DMaterialImpl      IDirect3DMaterialImpl;
74 typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
75 typedef struct IDirect3DVertexBufferImpl  IDirect3DVertexBufferImpl;
76 typedef struct IParentImpl                IParentImpl;
77
78 /* Callbacks for implicit object destruction */
79 extern ULONG WINAPI D3D7CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain);
80
81 extern ULONG WINAPI D3D7CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface);
82
83 /* Global critical section */
84 extern CRITICAL_SECTION ddraw_cs;
85
86 extern DWORD force_refresh_rate;
87
88 /*****************************************************************************
89  * IDirectDraw implementation structure
90  *****************************************************************************/
91 struct FvfToDecl
92 {
93     DWORD fvf;
94     IWineD3DVertexDeclaration *decl;
95 };
96
97 struct IDirectDrawImpl
98 {
99     /* IUnknown fields */
100     ICOM_VFIELD_MULTI(IDirectDraw7);
101     ICOM_VFIELD_MULTI(IDirectDraw4);
102     ICOM_VFIELD_MULTI(IDirectDraw3);
103     ICOM_VFIELD_MULTI(IDirectDraw2);
104     ICOM_VFIELD_MULTI(IDirectDraw);
105     ICOM_VFIELD_MULTI(IDirect3D7);
106     ICOM_VFIELD_MULTI(IDirect3D3);
107     ICOM_VFIELD_MULTI(IDirect3D2);
108     ICOM_VFIELD_MULTI(IDirect3D);
109
110     /* See comment in IDirectDraw::AddRef */
111     LONG                    ref7, ref4, ref2, ref3, ref1, numIfaces;
112
113     /* WineD3D linkage */
114     IWineD3D                *wineD3D;
115     IWineD3DDevice          *wineD3DDevice;
116     IDirectDrawSurfaceImpl  *DepthStencilBuffer;
117     BOOL                    d3d_initialized;
118
119     /* Misc ddraw fields */
120     UINT                    total_vidmem;
121     DWORD                   cur_scanline;
122     BOOL                    fake_vblank;
123     BOOL                    initialized;
124
125     /* DirectDraw things, which are not handled by WineD3D */
126     DWORD                   cooperative_level;
127
128     DWORD                   orig_width, orig_height;
129     DWORD                   orig_bpp;
130
131     DDCAPS                  caps;
132
133     /* D3D things */
134     IDirectDrawSurfaceImpl  *d3d_target;
135     HWND                    d3d_window;
136     IDirect3DDeviceImpl     *d3ddevice;
137     int                     d3dversion;
138
139     /* Various HWNDs */
140     HWND                    focuswindow;
141     HWND                    devicewindow;
142
143     /* The surface type to request */
144     WINED3DSURFTYPE         ImplType;
145
146
147     /* Our private window class */
148     char classname[32];
149     WNDCLASSA wnd_class;
150
151     /* Helpers for surface creation */
152     IDirectDrawSurfaceImpl *tex_root;
153     BOOL                    depthstencil;
154
155     /* For the dll unload cleanup code */
156     struct list ddraw_list_entry;
157     /* The surface list - can't relay this to WineD3D
158      * because of IParent
159      */
160     struct list surface_list;
161     LONG surfaces;
162
163     /* FVF management */
164     struct FvfToDecl       *decls;
165     UINT                    numConvertedDecls, declArraySize;
166 };
167
168 /* Declare the VTables. They can be found ddraw.c */
169 const IDirectDraw7Vtbl IDirectDraw7_Vtbl;
170 const IDirectDraw4Vtbl IDirectDraw4_Vtbl;
171 const IDirectDraw3Vtbl IDirectDraw3_Vtbl;
172 const IDirectDraw2Vtbl IDirectDraw2_Vtbl;
173 const IDirectDrawVtbl  IDirectDraw1_Vtbl;
174
175 /* Helper structures */
176 typedef struct EnumDisplayModesCBS
177 {
178     void *context;
179     LPDDENUMMODESCALLBACK2 callback;
180 } EnumDisplayModesCBS;
181
182 typedef struct EnumSurfacesCBS
183 {
184     void *context;
185     LPDDENUMSURFACESCALLBACK7 callback;
186     LPDDSURFACEDESC2 pDDSD;
187     DWORD Flags;
188 } EnumSurfacesCBS;
189
190 /* Utility functions */
191 void
192 DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn,
193                              DDSCAPS2* pOut);
194 void
195 DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn,
196                                         DDDEVICEIDENTIFIER* pOut);
197 void
198 IDirectDrawImpl_Destroy(IDirectDrawImpl *This);
199
200 HRESULT WINAPI
201 IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf,
202                                          DDSURFACEDESC2 *desc,
203                                          void *Context);
204 IWineD3DVertexDeclaration *
205 IDirectDrawImpl_FindDecl(IDirectDrawImpl *This,
206                          DWORD fvf);
207
208 /* The default surface type */
209 extern WINED3DSURFTYPE DefaultSurfaceType;
210
211 /*****************************************************************************
212  * IDirectDrawSurface implementation structure
213  *****************************************************************************/
214
215 struct IDirectDrawSurfaceImpl
216 {
217     /* IUnknown fields */
218     ICOM_VFIELD_MULTI(IDirectDrawSurface7);
219     ICOM_VFIELD_MULTI(IDirectDrawSurface3);
220     ICOM_VFIELD_MULTI(IDirectDrawGammaControl);
221     ICOM_VFIELD_MULTI(IDirect3DTexture2);
222     ICOM_VFIELD_MULTI(IDirect3DTexture);
223
224     LONG                     ref;
225     IUnknown                *ifaceToRelease;
226
227     int                     version;
228
229     /* Connections to other Objects */
230     IDirectDrawImpl         *ddraw;
231     IWineD3DSurface         *WineD3DSurface;
232     IWineD3DBaseTexture     *wineD3DTexture;
233
234     /* This implementation handles attaching surfaces to other surfaces */
235     IDirectDrawSurfaceImpl  *next_attached;
236     IDirectDrawSurfaceImpl  *first_attached;
237
238     /* Complex surfaces are organized in a tree, although the tree is degenerated to a list in most cases.
239      * In mipmap and primary surfaces each level has only one attachment, which is the next surface level.
240      * Only the cube texture root has 6 surfaces attached, which then have a normal mipmap chain attached
241      * to them. So hardcode the array to 6, a dynamic array or a list would be an overkill.
242      */
243 #define MAX_COMPLEX_ATTACHED 6
244     IDirectDrawSurfaceImpl  *complex_array[MAX_COMPLEX_ATTACHED];
245     /* You can't traverse the tree upwards. Only a flag for Surface::Release because its needed there,
246      * but no pointer to prevent temptations to traverse it in the wrong direction.
247      */
248     BOOL                    is_complex_root;
249
250     /* Surface description, for GetAttachedSurface */
251     DDSURFACEDESC2          surface_desc;
252
253     /* Misc things */
254     DWORD                   uniqueness_value;
255     UINT                    mipmap_level;
256     WINED3DSURFTYPE         ImplType;
257
258     /* For D3DDevice creation */
259     BOOL                    isRenderTarget;
260
261     /* Clipper objects */
262     IDirectDrawClipperImpl  *clipper;
263
264     /* For the ddraw surface list */
265     struct list             surface_list_entry;
266
267     DWORD                   Handle;
268 };
269
270 /* VTable declaration. It's located in surface.c / surface_thunks.c */
271 const IDirectDrawSurface7Vtbl IDirectDrawSurface7_Vtbl;
272 const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl;
273 const IDirectDrawGammaControlVtbl IDirectDrawGammaControl_Vtbl;
274 const IDirect3DTexture2Vtbl IDirect3DTexture2_Vtbl;
275 const IDirect3DTextureVtbl IDirect3DTexture1_Vtbl;
276
277 HRESULT WINAPI IDirectDrawSurfaceImpl_AddAttachedSurface(IDirectDrawSurfaceImpl *This, IDirectDrawSurfaceImpl *Surf);
278 void IDirectDrawSurfaceImpl_Destroy(IDirectDrawSurfaceImpl *This);
279
280 /* Get the number of bytes per pixel for a given surface */
281 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.dwRGBBitCount+7)/8))
282 #define GET_BPP(desc) PFGET_BPP(desc.ddpfPixelFormat)
283
284 /*****************************************************************************
285  * IParent Implementation
286  *****************************************************************************/
287 struct IParentImpl
288 {
289     /* IUnknown fields */
290     ICOM_VFIELD_MULTI(IParent);
291     LONG                    ref;
292
293     /* IParentImpl fields */
294     IUnknown      *child;
295
296 };
297
298 const IParentVtbl IParent_Vtbl;
299
300 /*****************************************************************************
301  * IDirect3DDevice implementation
302  *****************************************************************************/
303 typedef enum
304 {
305     DDrawHandle_Unknown       = 0,
306     DDrawHandle_Texture       = 1,
307     DDrawHandle_Material      = 2,
308     DDrawHandle_Matrix        = 3,
309     DDrawHandle_StateBlock    = 4
310 } DDrawHandleTypes;
311
312 struct HandleEntry
313 {
314     void    *ptr;
315     DDrawHandleTypes      type;
316 };
317
318 struct IDirect3DDeviceImpl
319 {
320     /* IUnknown */
321     ICOM_VFIELD_MULTI(IDirect3DDevice7);
322     ICOM_VFIELD_MULTI(IDirect3DDevice3);
323     ICOM_VFIELD_MULTI(IDirect3DDevice2);
324     ICOM_VFIELD_MULTI(IDirect3DDevice);
325     LONG                    ref;
326
327     /* Other object connections */
328     IWineD3DDevice          *wineD3DDevice;
329     IDirectDrawImpl         *ddraw;
330     IWineD3DIndexBuffer     *indexbuffer;
331     IDirectDrawSurfaceImpl  *target;
332     BOOL                    OffScreenTarget;
333
334     /* Viewport management */
335     IDirect3DViewportImpl *viewport_list;
336     IDirect3DViewportImpl *current_viewport;
337     D3DVIEWPORT7 active_viewport;
338
339     /* Light state */
340     DWORD material;
341
342     /* Rendering functions to wrap D3D(1-3) to D3D7 */
343     D3DPRIMITIVETYPE primitive_type;
344     DWORD vertex_type;
345     DWORD render_flags;
346     DWORD nb_vertices;
347     LPBYTE vertex_buffer;
348     DWORD vertex_size;
349     DWORD buffer_size;
350
351     /* Handle management */
352     struct HandleEntry      *Handles;
353     DWORD                    numHandles;
354     D3DMATRIXHANDLE          world, proj, view;
355 };
356
357 /* Vtables in various versions */
358 const IDirect3DDevice7Vtbl IDirect3DDevice7_Vtbl;
359 const IDirect3DDevice3Vtbl IDirect3DDevice3_Vtbl;
360 const IDirect3DDevice2Vtbl IDirect3DDevice2_Vtbl;
361 const IDirect3DDeviceVtbl  IDirect3DDevice1_Vtbl;
362
363 /* The IID */
364 const GUID IID_D3DDEVICE_WineD3D;
365
366 /* Helper functions */
367 HRESULT IDirect3DImpl_GetCaps(IWineD3D *WineD3D, D3DDEVICEDESC *Desc123, D3DDEVICEDESC7 *Desc7);
368 DWORD IDirect3DDeviceImpl_CreateHandle(IDirect3DDeviceImpl *This);
369 WINED3DZBUFFERTYPE IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *This);
370
371 /* Structures */
372 struct EnumTextureFormatsCBS
373 {
374     LPD3DENUMTEXTUREFORMATSCALLBACK cbv2;
375     LPD3DENUMPIXELFORMATSCALLBACK cbv7;
376     void *Context;
377 };
378
379 /*****************************************************************************
380  * IDirect3D implementation
381  *****************************************************************************/
382
383 /* No implementation structure as this is only another interface to DirectDraw */
384
385 /* the Vtables */
386 const IDirect3DVtbl  IDirect3D1_Vtbl;
387 const IDirect3D2Vtbl IDirect3D2_Vtbl;
388 const IDirect3D3Vtbl IDirect3D3_Vtbl;
389 const IDirect3D7Vtbl IDirect3D7_Vtbl;
390
391 /* Structure for EnumZBufferFormats */
392 struct EnumZBufferFormatsData
393 {
394     LPD3DENUMPIXELFORMATSCALLBACK Callback;
395     void *Context;
396 };
397
398 /*****************************************************************************
399  * IDirectDrawClipper implementation structure
400  *****************************************************************************/
401 struct IDirectDrawClipperImpl
402 {
403     /* IUnknown fields */
404     ICOM_VFIELD_MULTI(IDirectDrawClipper);
405     LONG ref;
406
407     IWineD3DClipper           *wineD3DClipper;
408     IDirectDrawImpl           *ddraw_owner;
409 };
410
411 const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl;
412
413 typedef IWineD3DClipper* (WINAPI *fnWineDirect3DCreateClipper)(IUnknown *);
414 fnWineDirect3DCreateClipper pWineDirect3DCreateClipper;
415
416 /*****************************************************************************
417  * IDirectDrawPalette implementation structure
418  *****************************************************************************/
419 struct IDirectDrawPaletteImpl
420 {
421     /* IUnknown fields */
422     ICOM_VFIELD_MULTI(IDirectDrawPalette);
423     LONG ref;
424
425     /* WineD3D uplink */
426     IWineD3DPalette           *wineD3DPalette;
427
428     /* IDirectDrawPalette fields */
429     IDirectDrawImpl           *ddraw_owner;
430     IUnknown                  *ifaceToRelease;
431 };
432 const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl;
433
434 /******************************************************************************
435  * DirectDraw ClassFactory implementation - incomplete
436  ******************************************************************************/
437 typedef struct
438 {
439     ICOM_VFIELD_MULTI(IClassFactory);
440
441     LONG ref;
442     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID iid, LPVOID *ppObj);
443 } IClassFactoryImpl;
444
445 /* Helper structures */
446 struct object_creation_info
447 {
448     const CLSID *clsid;
449     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID riid,
450                                  void **ppObj);
451 };
452
453 /******************************************************************************
454  * IDirect3DLight implementation structure - Wraps to D3D7
455  ******************************************************************************/
456 struct IDirect3DLightImpl
457 {
458     ICOM_VFIELD_MULTI(IDirect3DLight);
459     LONG ref;
460
461     /* IDirect3DLight fields */
462     IDirectDrawImpl           *ddraw;
463
464     /* If this light is active for one viewport, put the viewport here */
465     IDirect3DViewportImpl     *active_viewport;
466
467     D3DLIGHT2 light;
468     D3DLIGHT7 light7;
469
470     DWORD dwLightIndex;
471
472     /* Chained list used for adding / removing from viewports */
473     IDirect3DLightImpl        *next;
474
475     /* Activation function */
476     void                      (*activate)(IDirect3DLightImpl*);
477     void                      (*desactivate)(IDirect3DLightImpl*);
478     void                      (*update)(IDirect3DLightImpl*);
479 };
480
481 /* Vtable */
482 const IDirect3DLightVtbl IDirect3DLight_Vtbl;
483
484 /* Helper functions */
485 void light_update(IDirect3DLightImpl* This);
486 void light_activate(IDirect3DLightImpl* This);
487 void light_desactivate(IDirect3DLightImpl* This);
488
489 /******************************************************************************
490  * IDirect3DMaterial implementation structure - Wraps to D3D7
491  ******************************************************************************/
492 struct IDirect3DMaterialImpl
493 {
494     ICOM_VFIELD_MULTI(IDirect3DMaterial3);
495     ICOM_VFIELD_MULTI(IDirect3DMaterial2);
496     ICOM_VFIELD_MULTI(IDirect3DMaterial);
497     LONG  ref;
498
499     /* IDirect3DMaterial2 fields */
500     IDirectDrawImpl               *ddraw;
501     IDirect3DDeviceImpl           *active_device;
502
503     D3DMATERIAL mat;
504     DWORD Handle;
505
506     void (*activate)(IDirect3DMaterialImpl* this);
507 };
508
509 /* VTables in various versions */
510 const IDirect3DMaterialVtbl IDirect3DMaterial_Vtbl;
511 const IDirect3DMaterial2Vtbl IDirect3DMaterial2_Vtbl;
512 const IDirect3DMaterial3Vtbl IDirect3DMaterial3_Vtbl;
513
514 /* Helper functions */
515 void material_activate(IDirect3DMaterialImpl* This);
516
517 /*****************************************************************************
518  * IDirect3DViewport - Wraps to D3D7
519  *****************************************************************************/
520 struct IDirect3DViewportImpl
521 {
522     ICOM_VFIELD_MULTI(IDirect3DViewport3);
523     LONG ref;
524
525     /* IDirect3DViewport fields */
526     IDirectDrawImpl           *ddraw;
527
528     /* If this viewport is active for one device, put the device here */
529     IDirect3DDeviceImpl       *active_device;
530
531     DWORD                     num_lights;
532     DWORD                     map_lights;
533
534     int                       use_vp2;
535
536     union
537     {
538         D3DVIEWPORT vp1;
539         D3DVIEWPORT2 vp2;
540     } viewports;
541
542     /* Activation function */
543     void                      (*activate)(IDirect3DViewportImpl*);
544
545     /* Field used to chain viewports together */
546     IDirect3DViewportImpl     *next;
547
548     /* Lights list */
549     IDirect3DLightImpl        *lights;
550
551     /* Background material */
552     IDirect3DMaterialImpl     *background;
553 };
554
555 /* Vtable */
556 const IDirect3DViewport3Vtbl IDirect3DViewport3_Vtbl;
557
558 /* Helper functions */
559 void viewport_activate(IDirect3DViewportImpl* This);
560
561 /*****************************************************************************
562  * IDirect3DExecuteBuffer - Wraps to D3D7
563  *****************************************************************************/
564 struct IDirect3DExecuteBufferImpl
565 {
566     /* IUnknown */
567     ICOM_VFIELD_MULTI(IDirect3DExecuteBuffer);
568     LONG                 ref;
569
570     /* IDirect3DExecuteBuffer fields */
571     IDirectDrawImpl      *ddraw;
572     IDirect3DDeviceImpl  *d3ddev;
573
574     D3DEXECUTEBUFFERDESC desc;
575     D3DEXECUTEDATA       data;
576
577     /* This buffer will store the transformed vertices */
578     void                 *vertex_data;
579     WORD                 *indices;
580     int                  nb_indices;
581
582     /* This flags is set to TRUE if we allocated ourselves the
583      * data buffer
584      */
585     BOOL                 need_free;
586 };
587
588 /* The VTable */
589 const IDirect3DExecuteBufferVtbl IDirect3DExecuteBuffer_Vtbl;
590
591 /* The execute function */
592 void
593 IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
594                                    IDirect3DDeviceImpl *Device,
595                                    IDirect3DViewportImpl *ViewportImpl);
596
597 /*****************************************************************************
598  * IDirect3DVertexBuffer
599  *****************************************************************************/
600 struct IDirect3DVertexBufferImpl
601 {
602     /*** IUnknown Methods ***/
603     ICOM_VFIELD_MULTI(IDirect3DVertexBuffer7);
604     ICOM_VFIELD_MULTI(IDirect3DVertexBuffer);
605     LONG                 ref;
606
607     /*** WineD3D and ddraw links ***/
608     IWineD3DVertexBuffer *wineD3DVertexBuffer;
609     IWineD3DVertexDeclaration *wineD3DVertexDeclaration;
610     IDirectDrawImpl *ddraw;
611
612     /*** Storage for D3D7 specific things ***/
613     DWORD                Caps;
614 };
615
616 /* The Vtables */
617 const IDirect3DVertexBuffer7Vtbl IDirect3DVertexBuffer7_Vtbl;
618 const IDirect3DVertexBufferVtbl IDirect3DVertexBuffer1_Vtbl;
619
620 /*****************************************************************************
621  * Helper functions from utils.c
622  *****************************************************************************/
623
624 #define GET_TEXCOUNT_FROM_FVF(d3dvtVertexType) \
625     (((d3dvtVertexType) & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT)
626
627 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
628     (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
629
630 void PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat, WINED3DFORMAT WineD3DFormat);
631 WINED3DFORMAT PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat);
632 void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd);
633 void DDRAW_dump_pixelformat(const DDPIXELFORMAT *PixelFormat);
634 void dump_D3DMATRIX(const D3DMATRIX *mat);
635 void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps);
636 DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
637 void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in);
638 void DDRAW_dump_cooperativelevel(DWORD cooplevel);
639
640 /* This only needs to be here as long the processvertices functionality of
641  * IDirect3DExecuteBuffer isn't in WineD3D */
642 void multiply_matrix(LPD3DMATRIX dest, const D3DMATRIX *src1, const D3DMATRIX *src2);
643
644 /* Used for generic dumping */
645 typedef struct
646 {
647     DWORD val;
648     const char* name;
649 } flag_info;
650
651 #define FE(x) { x, #x }
652
653 typedef struct
654 {
655     DWORD val;
656     const char* name;
657     void (*func)(const void *);
658     ptrdiff_t offset;
659 } member_info;
660
661 /* Structure copy */
662 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
663
664 #define DD_STRUCT_COPY_BYSIZE(to,from)                  \
665         do {                                            \
666                 DWORD __size = (to)->dwSize;            \
667                 DWORD __copysize = __size;              \
668                 DWORD __resetsize = __size;             \
669                 assert(to != from);                     \
670                 if (__resetsize > sizeof(*to))          \
671                     __resetsize = sizeof(*to);          \
672                 memset(to,0,__resetsize);               \
673                 if ((from)->dwSize < __size)            \
674                     __copysize = (from)->dwSize;        \
675                 memcpy(to,from,__copysize);             \
676                 (to)->dwSize = __size;/*restore size*/  \
677         } while (0)
678
679
680 #endif
681
682 HRESULT hr_ddraw_from_wined3d(HRESULT hr);