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