Authors: Andrew Lewycky <andrew@transgaming.com>, Gavriel State <gav@transgaming...
[wine] / dlls / ddraw / ddraw / thunks.c
1 /* Direct Draw Thunks and old vtables
2  * Copyright 2000 TransGaming Technologies Inc.
3  */
4 #include <ddraw.h>
5 #include "ddraw_private.h"
6 #include "ddcomimpl.h"
7
8 static HRESULT WINAPI
9 IDirectDrawImpl_QueryInterface(LPDIRECTDRAW This, REFIID iid, LPVOID *ppObj)
10 {
11     return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl,
12                                                           IDirectDraw,
13                                                           IDirectDraw7, This),
14                                        iid, ppObj);
15 }
16
17 static HRESULT WINAPI
18 IDirectDraw2Impl_QueryInterface(LPDIRECTDRAW2 This, REFIID iid, LPVOID *ppObj)
19 {
20     return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl,
21                                                           IDirectDraw2,
22                                                           IDirectDraw7, This),
23                                        iid, ppObj);
24 }
25
26
27 static HRESULT WINAPI
28 IDirectDraw4Impl_QueryInterface(LPDIRECTDRAW4 This, REFIID iid, LPVOID *ppObj)
29 {
30     return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl,
31                                                           IDirectDraw4,
32                                                           IDirectDraw7, This),
33                                        iid, ppObj);
34 }
35
36 static ULONG WINAPI
37 IDirectDrawImpl_AddRef(LPDIRECTDRAW This)
38 {
39     return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl,
40                                                   IDirectDraw, IDirectDraw7,
41                                                   This));
42 }
43
44 static ULONG WINAPI
45 IDirectDraw2Impl_AddRef(LPDIRECTDRAW2 This)
46 {
47     return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl,
48                                                   IDirectDraw2, IDirectDraw7,
49                                                   This));
50 }
51
52 static ULONG WINAPI
53 IDirectDraw4Impl_AddRef(LPDIRECTDRAW4 This)
54 {
55     return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl,
56                                                   IDirectDraw4, IDirectDraw7,
57                                                   This));
58 }
59
60 static ULONG WINAPI
61 IDirectDrawImpl_Release(LPDIRECTDRAW This)
62 {
63     return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
64                                                    IDirectDraw, IDirectDraw7,
65                                                    This));
66 }
67
68 static ULONG WINAPI
69 IDirectDraw2Impl_Release(LPDIRECTDRAW2 This)
70 {
71     return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
72                                                    IDirectDraw2, IDirectDraw7,
73                                                    This));
74 }
75
76 static ULONG WINAPI
77 IDirectDraw4Impl_Release(LPDIRECTDRAW4 This)
78 {
79     return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
80                                                    IDirectDraw4, IDirectDraw7,
81                                                    This));
82 }
83
84 static HRESULT WINAPI
85 IDirectDrawImpl_Compact(LPDIRECTDRAW This)
86 {
87     return IDirectDraw7_Compact(COM_INTERFACE_CAST(IDirectDrawImpl,
88                                                    IDirectDraw, IDirectDraw7,
89                                                    This));
90 }
91
92 static HRESULT WINAPI
93 IDirectDraw2Impl_Compact(LPDIRECTDRAW2 This)
94 {
95     return IDirectDraw7_Compact(COM_INTERFACE_CAST(IDirectDrawImpl,
96                                                    IDirectDraw2, IDirectDraw7,
97                                                    This));
98 }
99
100 static HRESULT WINAPI
101 IDirectDraw4Impl_Compact(LPDIRECTDRAW4 This)
102 {
103     return IDirectDraw7_Compact(COM_INTERFACE_CAST(IDirectDrawImpl,
104                                                    IDirectDraw4, IDirectDraw7,
105                                                    This));
106 }
107
108 static HRESULT WINAPI
109 IDirectDrawImpl_CreateClipper(LPDIRECTDRAW This, DWORD dwFlags,
110                               LPDIRECTDRAWCLIPPER *ppClipper,
111                               IUnknown *pUnkOuter)
112 {
113     return IDirectDraw7_CreateClipper(COM_INTERFACE_CAST(IDirectDrawImpl,
114                                                          IDirectDraw,
115                                                          IDirectDraw7,
116                                                          This),
117                                       dwFlags, ppClipper, pUnkOuter);
118 }
119
120 static HRESULT WINAPI
121 IDirectDraw2Impl_CreateClipper(LPDIRECTDRAW2 This, DWORD dwFlags,
122                                LPDIRECTDRAWCLIPPER *ppClipper,
123                                IUnknown *pUnkOuter)
124 {
125     return IDirectDraw7_CreateClipper(COM_INTERFACE_CAST(IDirectDrawImpl,
126                                                          IDirectDraw2,
127                                                          IDirectDraw7,
128                                                          This),
129                                       dwFlags, ppClipper, pUnkOuter);
130 }
131
132 static HRESULT WINAPI
133 IDirectDraw4Impl_CreateClipper(LPDIRECTDRAW4 This, DWORD dwFlags,
134                                LPDIRECTDRAWCLIPPER *ppClipper,
135                                IUnknown *pUnkOuter)
136 {
137     return IDirectDraw7_CreateClipper(COM_INTERFACE_CAST(IDirectDrawImpl,
138                                                          IDirectDraw4,
139                                                          IDirectDraw7,
140                                                          This),
141                                       dwFlags, ppClipper, pUnkOuter);
142 }
143
144 static HRESULT WINAPI
145 IDirectDrawImpl_CreatePalette(LPDIRECTDRAW This, DWORD dwFlags,
146                               LPPALETTEENTRY pEntries,
147                               LPDIRECTDRAWPALETTE *ppPalette,
148                               IUnknown *pUnkOuter)
149 {
150     return IDirectDraw7_CreatePalette(COM_INTERFACE_CAST(IDirectDrawImpl,
151                                                          IDirectDraw,
152                                                          IDirectDraw7,
153                                                          This),
154                                       dwFlags, pEntries, ppPalette, pUnkOuter);
155 }
156
157 static HRESULT WINAPI
158 IDirectDraw2Impl_CreatePalette(LPDIRECTDRAW2 This, DWORD dwFlags,
159                                LPPALETTEENTRY pEntries,
160                                LPDIRECTDRAWPALETTE *ppPalette,
161                                IUnknown *pUnkOuter)
162 {
163     return IDirectDraw7_CreatePalette(COM_INTERFACE_CAST(IDirectDrawImpl,
164                                                          IDirectDraw2,
165                                                          IDirectDraw7,
166                                                          This),
167                                       dwFlags, pEntries, ppPalette, pUnkOuter);
168 }
169
170 static HRESULT WINAPI
171 IDirectDraw4Impl_CreatePalette(LPDIRECTDRAW4 This, DWORD dwFlags,
172                                LPPALETTEENTRY pEntries,
173                                LPDIRECTDRAWPALETTE *ppPalette,
174                                IUnknown *pUnkOuter)
175 {
176     return IDirectDraw7_CreatePalette(COM_INTERFACE_CAST(IDirectDrawImpl,
177                                                          IDirectDraw4,
178                                                          IDirectDraw7,
179                                                          This),
180                                       dwFlags, pEntries, ppPalette, pUnkOuter);
181 }
182
183 static HRESULT WINAPI
184 IDirectDrawImpl_CreateSurface(LPDIRECTDRAW This, LPDDSURFACEDESC pSDesc,
185                               LPDIRECTDRAWSURFACE *ppSurface,
186                               IUnknown *pUnkOuter)
187 {
188     LPDIRECTDRAWSURFACE7 pSurface7;
189     HRESULT hr;
190
191     hr = IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
192                                                        IDirectDraw,
193                                                        IDirectDraw7,
194                                                        This),
195                                     pSDesc, &pSurface7, pUnkOuter);
196
197     *ppSurface = COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
198                                     IDirectDrawSurface7, IDirectDrawSurface3,
199                                     pSurface7);
200
201     return hr;
202 }
203
204 static HRESULT WINAPI
205 IDirectDraw2Impl_CreateSurface(LPDIRECTDRAW2 This, LPDDSURFACEDESC pSDesc,
206                                LPDIRECTDRAWSURFACE *ppSurface,
207                                IUnknown *pUnkOuter)
208 {
209     LPDIRECTDRAWSURFACE7 pSurface7;
210     HRESULT hr;
211
212     hr = IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
213                                                        IDirectDraw,
214                                                        IDirectDraw7,
215                                                        This),
216                                     pSDesc, &pSurface7, pUnkOuter);
217
218     *ppSurface = COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
219                                     IDirectDrawSurface7, IDirectDrawSurface3,
220                                     pSurface7);
221
222     return hr;
223 }
224
225 static HRESULT WINAPI
226 IDirectDraw4Impl_CreateSurface(LPDIRECTDRAW4 This, LPDDSURFACEDESC2 pSDesc,
227                                LPDIRECTDRAWSURFACE4 *ppSurface,
228                                IUnknown *pUnkOuter)
229 {
230     return IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
231                                                          IDirectDraw4,
232                                                          IDirectDraw7,
233                                                          This),
234                                       pSDesc,
235                                       (LPDIRECTDRAWSURFACE7 *)ppSurface,
236                                       pUnkOuter);
237 }
238
239 static HRESULT WINAPI
240 IDirectDrawImpl_DuplicateSurface(LPDIRECTDRAW This, LPDIRECTDRAWSURFACE pSrc,
241                                  LPDIRECTDRAWSURFACE *ppDst)
242 {
243     LPDIRECTDRAWSURFACE7 pDst7;
244     HRESULT hr;
245
246     hr = IDirectDraw7_DuplicateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
247                                                           IDirectDraw,
248                                                           IDirectDraw7, This),
249                                        COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
250                                                           IDirectDrawSurface3,
251                                                           IDirectDrawSurface7,
252                                                           pSrc),
253                                        &pDst7);
254
255     *ppDst = COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
256                                 IDirectDrawSurface3, pDst7);
257
258     return hr;
259 }
260
261 static HRESULT WINAPI
262 IDirectDraw2Impl_DuplicateSurface(LPDIRECTDRAW2 This, LPDIRECTDRAWSURFACE pSrc,
263                                   LPDIRECTDRAWSURFACE *ppDst)
264 {
265     LPDIRECTDRAWSURFACE7 pDst7;
266     HRESULT hr;
267
268     hr = IDirectDraw7_DuplicateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
269                                                           IDirectDraw2,
270                                                           IDirectDraw7, This),
271                                        COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
272                                                           IDirectDrawSurface3,
273                                                           IDirectDrawSurface7,
274                                                           pSrc),
275                                        &pDst7);
276
277     *ppDst = COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
278                                 IDirectDrawSurface3, pDst7);
279
280     return hr;
281 }
282
283 static HRESULT WINAPI
284 IDirectDraw4Impl_DuplicateSurface(LPDIRECTDRAW4 This,
285                                   LPDIRECTDRAWSURFACE4 pSrc,
286                                   LPDIRECTDRAWSURFACE4 *ppDst)
287 {
288     return IDirectDraw7_DuplicateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
289                                                             IDirectDraw4,
290                                                             IDirectDraw7,
291                                                             This),
292                                          (LPDIRECTDRAWSURFACE7)pSrc,
293                                          (LPDIRECTDRAWSURFACE7 *)ppDst);
294 }
295
296 struct displaymodescallback_context
297 {
298     LPDDENUMMODESCALLBACK func;
299     LPVOID context;
300 };
301
302 static HRESULT CALLBACK
303 EnumDisplayModesCallbackThunk(LPDDSURFACEDESC2 pDDSD2, LPVOID context)
304 {
305     struct displaymodescallback_context *cbcontext = context;
306
307     return cbcontext->func((LPDDSURFACEDESC)pDDSD2, cbcontext->context);
308 }
309
310 static HRESULT WINAPI
311 IDirectDrawImpl_EnumDisplayModes(LPDIRECTDRAW This, DWORD dwFlags,
312                                  LPDDSURFACEDESC pDDSD, LPVOID context,
313                                  LPDDENUMMODESCALLBACK cb)
314 {
315     struct displaymodescallback_context cbcontext = { cb, context };
316
317     return IDirectDraw7_EnumDisplayModes(COM_INTERFACE_CAST(IDirectDrawImpl,
318                                                             IDirectDraw,
319                                                             IDirectDraw7,
320                                                             This),
321                                          dwFlags, pDDSD, &cbcontext,
322                                          EnumDisplayModesCallbackThunk);
323 }
324
325 static HRESULT WINAPI
326 IDirectDraw2Impl_EnumDisplayModes(LPDIRECTDRAW2 This, DWORD dwFlags,
327                                   LPDDSURFACEDESC pDDSD, LPVOID context,
328                                   LPDDENUMMODESCALLBACK cb)
329 {
330     struct displaymodescallback_context cbcontext = { cb, context };
331
332     return IDirectDraw7_EnumDisplayModes(COM_INTERFACE_CAST(IDirectDrawImpl,
333                                                             IDirectDraw2,
334                                                             IDirectDraw7,
335                                                             This),
336                                          dwFlags, pDDSD, &cbcontext,
337                                          EnumDisplayModesCallbackThunk);
338 }
339
340 static HRESULT WINAPI
341 IDirectDraw4Impl_EnumDisplayModes(LPDIRECTDRAW4 This, DWORD dwFlags,
342                                   LPDDSURFACEDESC2 pDDSD, LPVOID context,
343                                   LPDDENUMMODESCALLBACK2 cb)
344 {
345     return IDirectDraw7_EnumDisplayModes(COM_INTERFACE_CAST(IDirectDrawImpl,
346                                                             IDirectDraw4,
347                                                             IDirectDraw7,
348                                                             This),
349                                          dwFlags, pDDSD, context, cb);
350 }
351
352 struct surfacescallback_context
353 {
354     LPDDENUMSURFACESCALLBACK func;
355     LPVOID context;
356 };
357
358 static HRESULT CALLBACK
359 EnumSurfacesCallbackThunk(LPDIRECTDRAWSURFACE7 pSurf, LPDDSURFACEDESC2 pDDSD,
360                           LPVOID context)
361 {
362     struct surfacescallback_context *cbcontext = context;
363
364     return cbcontext->func(COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
365                                               IDirectDrawSurface7,
366                                               IDirectDrawSurface3, pSurf),
367                            (LPDDSURFACEDESC)pDDSD, cbcontext->context);
368 }
369
370 static HRESULT WINAPI
371 IDirectDrawImpl_EnumSurfaces(LPDIRECTDRAW This, DWORD dwFlags,
372                              LPDDSURFACEDESC pDDSD, LPVOID context,
373                              LPDDENUMSURFACESCALLBACK cb)
374 {
375     struct surfacescallback_context cbcontext = { cb, context };
376     return IDirectDraw7_EnumSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl,
377                                                         IDirectDraw,
378                                                         IDirectDraw7, This),
379                                      dwFlags, (LPDDSURFACEDESC2)pDDSD,
380                                      &cbcontext, EnumSurfacesCallbackThunk);
381 }
382
383 static HRESULT WINAPI
384 IDirectDraw2Impl_EnumSurfaces(LPDIRECTDRAW2 This, DWORD dwFlags,
385                               LPDDSURFACEDESC pDDSD, LPVOID context,
386                               LPDDENUMSURFACESCALLBACK cb)
387 {
388     struct surfacescallback_context cbcontext = { cb, context };
389     return IDirectDraw7_EnumSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl,
390                                                         IDirectDraw2,
391                                                         IDirectDraw7, This),
392                                      dwFlags, (LPDDSURFACEDESC2)pDDSD,
393                                      &cbcontext, EnumSurfacesCallbackThunk);
394 }
395
396 static HRESULT WINAPI
397 IDirectDraw4Impl_EnumSurfaces(LPDIRECTDRAW4 This, DWORD dwFlags,
398                               LPDDSURFACEDESC2 pDDSD, LPVOID context,
399                               LPDDENUMSURFACESCALLBACK2 cb)
400 {
401     return IDirectDraw7_EnumSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl,
402                                                         IDirectDraw4,
403                                                         IDirectDraw7, This),
404                                      dwFlags, pDDSD, context,
405                                      (LPDDENUMSURFACESCALLBACK7)cb);
406 }
407
408 static HRESULT WINAPI
409 IDirectDrawImpl_FlipToGDISurface(LPDIRECTDRAW This)
410 {
411     return IDirectDraw7_FlipToGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
412                                                             IDirectDraw,
413                                                             IDirectDraw7,
414                                                             This));
415 }
416
417 static HRESULT WINAPI
418 IDirectDraw2Impl_FlipToGDISurface(LPDIRECTDRAW2 This)
419 {
420     return IDirectDraw7_FlipToGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
421                                                             IDirectDraw2,
422                                                             IDirectDraw7,
423                                                             This));
424 }
425
426 static HRESULT WINAPI
427 IDirectDraw4Impl_FlipToGDISurface(LPDIRECTDRAW4 This)
428 {
429     return IDirectDraw7_FlipToGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
430                                                             IDirectDraw4,
431                                                             IDirectDraw7,
432                                                             This));
433 }
434
435 static HRESULT WINAPI
436 IDirectDrawImpl_GetCaps(LPDIRECTDRAW This, LPDDCAPS pDDC1, LPDDCAPS pDDC2)
437 {
438     return IDirectDraw7_GetCaps(COM_INTERFACE_CAST(IDirectDrawImpl,
439                                                    IDirectDraw, IDirectDraw7,
440                                                    This), pDDC1, pDDC2);
441 }
442
443 static HRESULT WINAPI
444 IDirectDraw2Impl_GetCaps(LPDIRECTDRAW2 This, LPDDCAPS pDDC1, LPDDCAPS pDDC2)
445 {
446     return IDirectDraw7_GetCaps(COM_INTERFACE_CAST(IDirectDrawImpl,
447                                                    IDirectDraw2, IDirectDraw7,
448                                                    This), pDDC1, pDDC2);
449 }
450
451 static HRESULT WINAPI
452 IDirectDraw4Impl_GetCaps(LPDIRECTDRAW4 This, LPDDCAPS pDDC1, LPDDCAPS pDDC2)
453 {
454     return IDirectDraw7_GetCaps(COM_INTERFACE_CAST(IDirectDrawImpl,
455                                                    IDirectDraw4, IDirectDraw7,
456                                                    This), pDDC1, pDDC2);
457 }
458
459 static HRESULT WINAPI
460 IDirectDrawImpl_GetDisplayMode(LPDIRECTDRAW This, LPDDSURFACEDESC pDDSD)
461 {
462     return IDirectDraw7_GetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
463                                                           IDirectDraw,
464                                                           IDirectDraw7, This),
465                                        (LPDDSURFACEDESC2)pDDSD);
466 }
467
468 static HRESULT WINAPI
469 IDirectDraw2Impl_GetDisplayMode(LPDIRECTDRAW2 This, LPDDSURFACEDESC pDDSD)
470 {
471     return IDirectDraw7_GetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
472                                                           IDirectDraw2,
473                                                           IDirectDraw7, This),
474                                        (LPDDSURFACEDESC2)pDDSD);
475 }
476
477 static HRESULT WINAPI
478 IDirectDraw4Impl_GetDisplayMode(LPDIRECTDRAW4 This, LPDDSURFACEDESC2 pDDSD)
479 {
480     return IDirectDraw7_GetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
481                                                           IDirectDraw4,
482                                                           IDirectDraw7, This),
483                                        pDDSD);
484 }
485
486 static HRESULT WINAPI
487 IDirectDrawImpl_GetFourCCCodes(LPDIRECTDRAW This, LPDWORD lpNumCodes,
488                                LPDWORD lpCodes)
489 {
490     return IDirectDraw7_GetFourCCCodes(COM_INTERFACE_CAST(IDirectDrawImpl,
491                                                           IDirectDraw,
492                                                           IDirectDraw7,
493                                                           This),
494                                        lpNumCodes, lpCodes);
495 }
496
497 static HRESULT WINAPI
498 IDirectDraw2Impl_GetFourCCCodes(LPDIRECTDRAW2 This, LPDWORD lpNumCodes,
499                                 LPDWORD lpCodes)
500 {
501     return IDirectDraw7_GetFourCCCodes(COM_INTERFACE_CAST(IDirectDrawImpl,
502                                                           IDirectDraw2,
503                                                           IDirectDraw7,
504                                                           This),
505                                        lpNumCodes, lpCodes);
506 }
507
508 static HRESULT WINAPI
509 IDirectDraw4Impl_GetFourCCCodes(LPDIRECTDRAW4 This, LPDWORD lpNumCodes,
510                                 LPDWORD lpCodes)
511 {
512     return IDirectDraw7_GetFourCCCodes(COM_INTERFACE_CAST(IDirectDrawImpl,
513                                                           IDirectDraw4,
514                                                           IDirectDraw7,
515                                                           This),
516                                        lpNumCodes, lpCodes);
517 }
518
519 static HRESULT WINAPI
520 IDirectDrawImpl_GetGDISurface(LPDIRECTDRAW This, LPDIRECTDRAWSURFACE *ppSurf)
521 {
522     LPDIRECTDRAWSURFACE7 pSurf7;
523     HRESULT hr;
524
525     hr = IDirectDraw7_GetGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
526                                                        IDirectDraw,
527                                                        IDirectDraw7,
528                                                        This), &pSurf7);
529
530     *ppSurf = COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
531                                  IDirectDrawSurface3, pSurf7);
532
533     return hr;
534 }
535
536 static HRESULT WINAPI
537 IDirectDraw2Impl_GetGDISurface(LPDIRECTDRAW2 This, LPDIRECTDRAWSURFACE *ppSurf)
538 {
539     LPDIRECTDRAWSURFACE7 pSurf7;
540     HRESULT hr;
541
542     hr = IDirectDraw7_GetGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
543                                                        IDirectDraw2,
544                                                        IDirectDraw7,
545                                                        This), &pSurf7);
546
547     *ppSurf = COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
548                                  IDirectDrawSurface3, pSurf7);
549
550     return hr;
551 }
552
553 static HRESULT WINAPI
554 IDirectDraw4Impl_GetGDISurface(LPDIRECTDRAW4 This,
555                                LPDIRECTDRAWSURFACE4 *ppSurf)
556 {
557     return IDirectDraw7_GetGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
558                                                          IDirectDraw4,
559                                                          IDirectDraw7,
560                                                          This),
561                                       (LPDIRECTDRAWSURFACE7 *)ppSurf);
562 }
563
564 static HRESULT WINAPI
565 IDirectDrawImpl_GetMonitorFrequency(LPDIRECTDRAW This, LPDWORD pdwFreq)
566 {
567     return IDirectDraw7_GetMonitorFrequency(COM_INTERFACE_CAST(IDirectDrawImpl,
568                                                                IDirectDraw,
569                                                                IDirectDraw7,
570                                                                This),
571                                             pdwFreq);
572 }
573
574 static HRESULT WINAPI
575 IDirectDraw2Impl_GetMonitorFrequency(LPDIRECTDRAW2 This, LPDWORD pdwFreq)
576 {
577     return IDirectDraw7_GetMonitorFrequency(COM_INTERFACE_CAST(IDirectDrawImpl,
578                                                                IDirectDraw2,
579                                                                IDirectDraw7,
580                                                                This),
581                                             pdwFreq);
582 }
583
584 static HRESULT WINAPI
585 IDirectDraw4Impl_GetMonitorFrequency(LPDIRECTDRAW4 This, LPDWORD pdwFreq)
586 {
587     return IDirectDraw7_GetMonitorFrequency(COM_INTERFACE_CAST(IDirectDrawImpl,
588                                                                IDirectDraw4,
589                                                                IDirectDraw7,
590                                                                This),
591                                             pdwFreq);
592 }
593
594 static HRESULT WINAPI
595 IDirectDrawImpl_GetScanLine(LPDIRECTDRAW This, LPDWORD pdwLine)
596 {
597     return IDirectDraw7_GetScanLine(COM_INTERFACE_CAST(IDirectDrawImpl,
598                                                        IDirectDraw,
599                                                        IDirectDraw7,
600                                                        This), pdwLine);
601 }
602
603 static HRESULT WINAPI
604 IDirectDraw2Impl_GetScanLine(LPDIRECTDRAW2 This, LPDWORD pdwLine)
605 {
606     return IDirectDraw7_GetScanLine(COM_INTERFACE_CAST(IDirectDrawImpl,
607                                                        IDirectDraw2,
608                                                        IDirectDraw7,
609                                                        This), pdwLine);
610 }
611
612 static HRESULT WINAPI
613 IDirectDraw4Impl_GetScanLine(LPDIRECTDRAW4 This, LPDWORD pdwLine)
614 {
615     return IDirectDraw7_GetScanLine(COM_INTERFACE_CAST(IDirectDrawImpl,
616                                                        IDirectDraw4,
617                                                        IDirectDraw7,
618                                                        This), pdwLine);
619 }
620
621 static HRESULT WINAPI
622 IDirectDrawImpl_GetVerticalBlankStatus(LPDIRECTDRAW This, LPBOOL lpbIsInVB)
623 {
624     return IDirectDraw7_GetVerticalBlankStatus(COM_INTERFACE_CAST(IDirectDrawImpl,
625                                                                   IDirectDraw,
626                                                                   IDirectDraw7,
627                                                                   This),
628                                                lpbIsInVB);
629 }
630
631 static HRESULT WINAPI
632 IDirectDraw2Impl_GetVerticalBlankStatus(LPDIRECTDRAW2 This, LPBOOL lpbIsInVB)
633 {
634     return IDirectDraw7_GetVerticalBlankStatus(COM_INTERFACE_CAST(IDirectDrawImpl,
635                                                                   IDirectDraw2,
636                                                                   IDirectDraw7,
637                                                                   This),
638                                                lpbIsInVB);
639 }
640
641 static HRESULT WINAPI
642 IDirectDraw4Impl_GetVerticalBlankStatus(LPDIRECTDRAW4 This, LPBOOL lpbIsInVB)
643 {
644     return IDirectDraw7_GetVerticalBlankStatus(COM_INTERFACE_CAST(IDirectDrawImpl,
645                                                                   IDirectDraw4,
646                                                                   IDirectDraw7,
647                                                                   This),
648                                                lpbIsInVB);
649 }
650
651 static HRESULT WINAPI
652 IDirectDrawImpl_Initialize(LPDIRECTDRAW This, LPGUID pGUID)
653 {
654     return IDirectDraw7_Initialize(COM_INTERFACE_CAST(IDirectDrawImpl,
655                                                       IDirectDraw,
656                                                       IDirectDraw7, This),
657                                    pGUID);
658 }
659
660 static HRESULT WINAPI
661 IDirectDraw2Impl_Initialize(LPDIRECTDRAW2 This, LPGUID pGUID)
662 {
663     return IDirectDraw7_Initialize(COM_INTERFACE_CAST(IDirectDrawImpl,
664                                                       IDirectDraw2,
665                                                       IDirectDraw7, This),
666                                    pGUID);
667 }
668
669 static HRESULT WINAPI
670 IDirectDraw4Impl_Initialize(LPDIRECTDRAW4 This, LPGUID pGUID)
671 {
672     return IDirectDraw7_Initialize(COM_INTERFACE_CAST(IDirectDrawImpl,
673                                                       IDirectDraw4,
674                                                       IDirectDraw7, This),
675                                    pGUID);
676 }
677
678 static HRESULT WINAPI
679 IDirectDrawImpl_RestoreDisplayMode(LPDIRECTDRAW This)
680 {
681     return IDirectDraw7_RestoreDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
682                                                               IDirectDraw,
683                                                               IDirectDraw7,
684                                                               This));
685 }
686
687 static HRESULT WINAPI
688 IDirectDraw2Impl_RestoreDisplayMode(LPDIRECTDRAW2 This)
689 {
690     return IDirectDraw7_RestoreDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
691                                                               IDirectDraw2,
692                                                               IDirectDraw7,
693                                                               This));
694 }
695
696 static HRESULT WINAPI
697 IDirectDraw4Impl_RestoreDisplayMode(LPDIRECTDRAW4 This)
698 {
699     return IDirectDraw7_RestoreDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
700                                                               IDirectDraw4,
701                                                               IDirectDraw7,
702                                                               This));
703 }
704
705 static HRESULT WINAPI
706 IDirectDrawImpl_SetCooperativeLevel(LPDIRECTDRAW This, HWND hWnd,
707                                     DWORD dwFlags)
708 {
709     return IDirectDraw7_SetCooperativeLevel(COM_INTERFACE_CAST(IDirectDrawImpl,
710                                                                IDirectDraw,
711                                                                IDirectDraw7,
712                                                                This),
713                                             hWnd, dwFlags);
714 }
715
716 static HRESULT WINAPI
717 IDirectDraw2Impl_SetCooperativeLevel(LPDIRECTDRAW2 This, HWND hWnd,
718                                      DWORD dwFlags)
719 {
720     return IDirectDraw7_SetCooperativeLevel(COM_INTERFACE_CAST(IDirectDrawImpl,
721                                                                IDirectDraw2,
722                                                                IDirectDraw7,
723                                                                This),
724                                             hWnd, dwFlags);
725 }
726
727 static HRESULT WINAPI
728 IDirectDraw4Impl_SetCooperativeLevel(LPDIRECTDRAW4 This, HWND hWnd,
729                                      DWORD dwFlags)
730 {
731     return IDirectDraw7_SetCooperativeLevel(COM_INTERFACE_CAST(IDirectDrawImpl,
732                                                                IDirectDraw4,
733                                                                IDirectDraw7,
734                                                                This),
735                                             hWnd, dwFlags);
736 }
737
738 static HRESULT WINAPI
739 IDirectDrawImpl_SetDisplayMode(LPDIRECTDRAW This, DWORD a, DWORD b, DWORD c)
740 {
741     return IDirectDraw7_SetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
742                                                           IDirectDraw,
743                                                           IDirectDraw7,
744                                                           This),
745                                        a, b, c, 0, 0);
746 }
747
748 static HRESULT WINAPI
749 IDirectDraw2Impl_SetDisplayMode(LPDIRECTDRAW2 This, DWORD a, DWORD b, DWORD c,
750                                 DWORD d, DWORD e)
751 {
752     return IDirectDraw7_SetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
753                                                           IDirectDraw2,
754                                                           IDirectDraw7,
755                                                           This),
756                                        a, b, c, d, e);
757 }
758
759 static HRESULT WINAPI
760 IDirectDraw4Impl_SetDisplayMode(LPDIRECTDRAW4 This, DWORD a, DWORD b, DWORD c,
761                                 DWORD d, DWORD e)
762 {
763     return IDirectDraw7_SetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
764                                                           IDirectDraw4,
765                                                           IDirectDraw7,
766                                                           This),
767                                        a, b, c, d, e);
768 }
769
770 static HRESULT WINAPI
771 IDirectDrawImpl_WaitForVerticalBlank(LPDIRECTDRAW This, DWORD dwFlags,
772                                      HANDLE hEvent)
773 {
774     return IDirectDraw7_WaitForVerticalBlank(COM_INTERFACE_CAST(IDirectDrawImpl,
775                                                                 IDirectDraw,
776                                                                 IDirectDraw7,
777                                                                 This),
778                                              dwFlags, hEvent);
779 }
780
781 static HRESULT WINAPI
782 IDirectDraw2Impl_WaitForVerticalBlank(LPDIRECTDRAW2 This, DWORD dwFlags,
783                                       HANDLE hEvent)
784 {
785     return IDirectDraw7_WaitForVerticalBlank(COM_INTERFACE_CAST(IDirectDrawImpl,
786                                                                 IDirectDraw2,
787                                                                 IDirectDraw7,
788                                                                 This),
789                                              dwFlags, hEvent);
790 }
791
792 static HRESULT WINAPI
793 IDirectDraw4Impl_WaitForVerticalBlank(LPDIRECTDRAW4 This, DWORD dwFlags,
794                                       HANDLE hEvent)
795 {
796     return IDirectDraw7_WaitForVerticalBlank(COM_INTERFACE_CAST(IDirectDrawImpl,
797                                                                 IDirectDraw4,
798                                                                 IDirectDraw7,
799                                                                 This),
800                                              dwFlags, hEvent);
801 }
802
803 static HRESULT WINAPI
804 IDirectDraw2Impl_GetAvailableVidMem(LPDIRECTDRAW2 This, LPDDSCAPS pCaps,
805                                     LPDWORD pdwTotal, LPDWORD pdwFree)
806 {
807     DDSCAPS2 Caps2;
808     DDRAW_Convert_DDSCAPS_1_To_2(pCaps, &Caps2);
809
810     return IDirectDraw7_GetAvailableVidMem(COM_INTERFACE_CAST(IDirectDrawImpl,
811                                                               IDirectDraw2,
812                                                               IDirectDraw7,
813                                                               This),
814                                            &Caps2, pdwTotal, pdwFree);
815 }
816
817 static HRESULT WINAPI
818 IDirectDraw4Impl_GetAvailableVidMem(LPDIRECTDRAW4 This, LPDDSCAPS2 pCaps,
819                                     LPDWORD pdwTotal, LPDWORD pdwFree)
820 {
821     return IDirectDraw7_GetAvailableVidMem(COM_INTERFACE_CAST(IDirectDrawImpl,
822                                                               IDirectDraw2,
823                                                               IDirectDraw7,
824                                                               This),
825                                            pCaps, pdwTotal, pdwFree);
826 }
827
828 static HRESULT WINAPI
829 IDirectDraw4Impl_GetSurfaceFromDC(LPDIRECTDRAW4 This, HDC hDC,
830                                   LPDIRECTDRAWSURFACE4 *pSurf)
831 {
832     return IDirectDraw7_GetSurfaceFromDC(COM_INTERFACE_CAST(IDirectDrawImpl,
833                                                             IDirectDraw4,
834                                                             IDirectDraw7,
835                                                             This),
836                                          hDC, (LPDIRECTDRAWSURFACE7 *)pSurf);
837 }
838
839 static HRESULT WINAPI
840 IDirectDraw4Impl_RestoreAllSurfaces(LPDIRECTDRAW4 This)
841 {
842     return IDirectDraw7_RestoreAllSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl,
843                                                               IDirectDraw4,
844                                                               IDirectDraw7,
845                                                               This));
846 }
847
848 static HRESULT WINAPI
849 IDirectDraw4Impl_TestCooperativeLevel(LPDIRECTDRAW4 This)
850 {
851     return IDirectDraw7_TestCooperativeLevel(COM_INTERFACE_CAST(IDirectDrawImpl,
852                                                                 IDirectDraw4,
853                                                                 IDirectDraw7,
854                                                                 This));
855 }
856
857 static HRESULT WINAPI
858 IDirectDraw4Impl_GetDeviceIdentifier(LPDIRECTDRAW4 This,
859                                      LPDDDEVICEIDENTIFIER pDDDI, DWORD dwFlags)
860 {
861     DDDEVICEIDENTIFIER2 DDDI2;
862     HRESULT hr;
863
864     hr = IDirectDraw7_GetDeviceIdentifier(COM_INTERFACE_CAST(IDirectDrawImpl,
865                                                              IDirectDraw4,
866                                                              IDirectDraw7,
867                                                              This),
868                                           &DDDI2, dwFlags);
869
870     DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(pDDDI, &DDDI2);
871
872     return hr;
873 }
874
875 ICOM_VTABLE(IDirectDraw) DDRAW_IDirectDraw_VTable =
876 {
877     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
878     IDirectDrawImpl_QueryInterface,
879     IDirectDrawImpl_AddRef,
880     IDirectDrawImpl_Release,
881     IDirectDrawImpl_Compact,
882     IDirectDrawImpl_CreateClipper,
883     IDirectDrawImpl_CreatePalette,
884     IDirectDrawImpl_CreateSurface,
885     IDirectDrawImpl_DuplicateSurface,
886     IDirectDrawImpl_EnumDisplayModes,
887     IDirectDrawImpl_EnumSurfaces,
888     IDirectDrawImpl_FlipToGDISurface,
889     IDirectDrawImpl_GetCaps,
890     IDirectDrawImpl_GetDisplayMode,
891     IDirectDrawImpl_GetFourCCCodes,
892     IDirectDrawImpl_GetGDISurface,
893     IDirectDrawImpl_GetMonitorFrequency,
894     IDirectDrawImpl_GetScanLine,
895     IDirectDrawImpl_GetVerticalBlankStatus,
896     IDirectDrawImpl_Initialize,
897     IDirectDrawImpl_RestoreDisplayMode,
898     IDirectDrawImpl_SetCooperativeLevel,
899     IDirectDrawImpl_SetDisplayMode,
900     IDirectDrawImpl_WaitForVerticalBlank,
901 };
902
903 ICOM_VTABLE(IDirectDraw2) DDRAW_IDirectDraw2_VTable =
904 {
905     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
906     IDirectDraw2Impl_QueryInterface,
907     IDirectDraw2Impl_AddRef,
908     IDirectDraw2Impl_Release,
909     IDirectDraw2Impl_Compact,
910     IDirectDraw2Impl_CreateClipper,
911     IDirectDraw2Impl_CreatePalette,
912     IDirectDraw2Impl_CreateSurface,
913     IDirectDraw2Impl_DuplicateSurface,
914     IDirectDraw2Impl_EnumDisplayModes,
915     IDirectDraw2Impl_EnumSurfaces,
916     IDirectDraw2Impl_FlipToGDISurface,
917     IDirectDraw2Impl_GetCaps,
918     IDirectDraw2Impl_GetDisplayMode,
919     IDirectDraw2Impl_GetFourCCCodes,
920     IDirectDraw2Impl_GetGDISurface,
921     IDirectDraw2Impl_GetMonitorFrequency,
922     IDirectDraw2Impl_GetScanLine,
923     IDirectDraw2Impl_GetVerticalBlankStatus,
924     IDirectDraw2Impl_Initialize,
925     IDirectDraw2Impl_RestoreDisplayMode,
926     IDirectDraw2Impl_SetCooperativeLevel,
927     IDirectDraw2Impl_SetDisplayMode,
928     IDirectDraw2Impl_WaitForVerticalBlank,
929     IDirectDraw2Impl_GetAvailableVidMem
930 };
931
932 ICOM_VTABLE(IDirectDraw4) DDRAW_IDirectDraw4_VTable =
933 {
934     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
935     IDirectDraw4Impl_QueryInterface,
936     IDirectDraw4Impl_AddRef,
937     IDirectDraw4Impl_Release,
938     IDirectDraw4Impl_Compact,
939     IDirectDraw4Impl_CreateClipper,
940     IDirectDraw4Impl_CreatePalette,
941     IDirectDraw4Impl_CreateSurface,
942     IDirectDraw4Impl_DuplicateSurface,
943     IDirectDraw4Impl_EnumDisplayModes,
944     IDirectDraw4Impl_EnumSurfaces,
945     IDirectDraw4Impl_FlipToGDISurface,
946     IDirectDraw4Impl_GetCaps,
947     IDirectDraw4Impl_GetDisplayMode,
948     IDirectDraw4Impl_GetFourCCCodes,
949     IDirectDraw4Impl_GetGDISurface,
950     IDirectDraw4Impl_GetMonitorFrequency,
951     IDirectDraw4Impl_GetScanLine,
952     IDirectDraw4Impl_GetVerticalBlankStatus,
953     IDirectDraw4Impl_Initialize,
954     IDirectDraw4Impl_RestoreDisplayMode,
955     IDirectDraw4Impl_SetCooperativeLevel,
956     IDirectDraw4Impl_SetDisplayMode,
957     IDirectDraw4Impl_WaitForVerticalBlank,
958     IDirectDraw4Impl_GetAvailableVidMem,
959     IDirectDraw4Impl_GetSurfaceFromDC,
960     IDirectDraw4Impl_RestoreAllSurfaces,
961     IDirectDraw4Impl_TestCooperativeLevel,
962     IDirectDraw4Impl_GetDeviceIdentifier
963 };