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