include: Added missing importlib.
[wine] / dlls / ddraw / surface_thunks.c
1 /* IDirectDrawSurface3 -> IDirectDrawSurface7 thunks
2  * Copyright 2000 TransGaming Technologies Inc.
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #include "config.h"
20 #include <stdarg.h>
21
22 #include "windef.h"
23 #include "winbase.h"
24 #include "wingdi.h"
25 #include "ddraw.h"
26 #include "winerror.h"
27
28 #include "ddraw_private.h"
29 #include "ddcomimpl.h"
30
31 #define CONVERT(pdds) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,        \
32                                          IDirectDrawSurface3,           \
33                                          IDirectDrawSurface7,           \
34                                          (pdds))
35
36 #define CONVERT_REV(pdds) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,    \
37                                              IDirectDrawSurface7,       \
38                                              IDirectDrawSurface3,       \
39                                              (pdds))
40
41 static HRESULT WINAPI
42 IDirectDrawSurface3Impl_QueryInterface(LPDIRECTDRAWSURFACE3 This, REFIID iid,
43                                        LPVOID *ppObj)
44 {
45     return IDirectDrawSurface7_QueryInterface(CONVERT(This), iid, ppObj);
46 }
47
48 static ULONG WINAPI
49 IDirectDrawSurface3Impl_AddRef(LPDIRECTDRAWSURFACE3 This)
50 {
51     return IDirectDrawSurface7_AddRef(CONVERT(This));
52 }
53
54 static ULONG WINAPI
55 IDirectDrawSurface3Impl_Release(LPDIRECTDRAWSURFACE3 This)
56 {
57     return IDirectDrawSurface7_Release(CONVERT(This));
58 }
59
60 static HRESULT WINAPI
61 IDirectDrawSurface3Impl_AddAttachedSurface(LPDIRECTDRAWSURFACE3 This,
62                                            LPDIRECTDRAWSURFACE3 pAttach)
63 {
64     return IDirectDrawSurface7_AddAttachedSurface(CONVERT(This),
65                                                   CONVERT(pAttach));
66 }
67
68 static HRESULT WINAPI
69 IDirectDrawSurface3Impl_AddOverlayDirtyRect(LPDIRECTDRAWSURFACE3 This,
70                                             LPRECT pRect)
71 {
72     return IDirectDrawSurface7_AddOverlayDirtyRect(CONVERT(This), pRect);
73 }
74
75 static HRESULT WINAPI
76 IDirectDrawSurface3Impl_Blt(LPDIRECTDRAWSURFACE3 This, LPRECT prcDst,
77                             LPDIRECTDRAWSURFACE3 pSrcSurf, LPRECT prcSrc,
78                             DWORD dwFlags, LPDDBLTFX pFX)
79 {
80     return IDirectDrawSurface7_Blt(CONVERT(This), prcDst, CONVERT(pSrcSurf),
81                                    prcSrc, dwFlags, pFX);
82 }
83
84 static HRESULT WINAPI
85 IDirectDrawSurface3Impl_BltBatch(LPDIRECTDRAWSURFACE3 This,
86                                  LPDDBLTBATCH pBatch, DWORD dwCount,
87                                  DWORD dwFlags)
88 {
89     return IDirectDrawSurface7_BltBatch(CONVERT(This), pBatch, dwCount,
90                                         dwFlags);
91 }
92
93 static HRESULT WINAPI
94 IDirectDrawSurface3Impl_BltFast(LPDIRECTDRAWSURFACE3 This, DWORD x, DWORD y,
95                                 LPDIRECTDRAWSURFACE3 pSrcSurf, LPRECT prcSrc,
96                                 DWORD dwTrans)
97 {
98     return IDirectDrawSurface7_BltFast(CONVERT(This), x, y, CONVERT(pSrcSurf),
99                                        prcSrc, dwTrans);
100 }
101
102 static HRESULT WINAPI
103 IDirectDrawSurface3Impl_DeleteAttachedSurface(LPDIRECTDRAWSURFACE3 This,
104                                               DWORD dwFlags,
105                                               LPDIRECTDRAWSURFACE3 pAttached)
106 {
107     return IDirectDrawSurface7_DeleteAttachedSurface(CONVERT(This), dwFlags,
108                                                      CONVERT(pAttached));
109 }
110
111 struct callback_info
112 {
113     LPDDENUMSURFACESCALLBACK callback;
114     LPVOID context;
115 };
116
117 static HRESULT CALLBACK
118 EnumCallback(LPDIRECTDRAWSURFACE7 iface, LPDDSURFACEDESC2 pDDSD,
119              LPVOID context)
120 {
121     const struct callback_info* info = context;
122
123 #if 0
124     /* This is an outgoing conversion so we have to do it. */
125     DDSURFACEDESC ddsd;
126     memset(&ddsd, 0, sizeof(ddsd));
127     ddsd.dwSize = sizeof(ddsd);
128     DDRAW_Convert_DDSURFACEDESC_2_To_1(pDDSD, &ddsd);
129 #endif
130
131     /* the LPDDSURFACEDESC2 -> LPDDSURFACEDESC coercion is safe, since
132      * the data format is compatible with older enum procs */
133     return info->callback((LPDIRECTDRAWSURFACE)CONVERT_REV(iface), (LPDDSURFACEDESC)pDDSD,
134                           info->context);
135 }
136
137 static HRESULT WINAPI
138 IDirectDrawSurface3Impl_EnumAttachedSurfaces(LPDIRECTDRAWSURFACE3 This,
139                                              LPVOID context,
140                                              LPDDENUMSURFACESCALLBACK callback)
141 {
142     struct callback_info info;
143
144     info.callback = callback;
145     info.context  = context;
146
147     return IDirectDrawSurface7_EnumAttachedSurfaces(CONVERT(This), &info,
148                                                     EnumCallback);
149 }
150
151 static HRESULT WINAPI
152 IDirectDrawSurface3Impl_EnumOverlayZOrders(LPDIRECTDRAWSURFACE3 This,
153                                            DWORD dwFlags, LPVOID context,
154                                            LPDDENUMSURFACESCALLBACK callback)
155 {
156     struct callback_info info;
157
158     info.callback = callback;
159     info.context  = context;
160
161     return IDirectDrawSurface7_EnumOverlayZOrders(CONVERT(This), dwFlags,
162                                                   &info, EnumCallback);
163 }
164
165 static HRESULT WINAPI
166 IDirectDrawSurface3Impl_Flip(LPDIRECTDRAWSURFACE3 This,
167                              LPDIRECTDRAWSURFACE3 pOverride, DWORD dwFlags)
168 {
169     return IDirectDrawSurface7_Flip(CONVERT(This), CONVERT(pOverride),
170                                     dwFlags);
171 }
172
173 static HRESULT WINAPI
174 IDirectDrawSurface3Impl_GetAttachedSurface(LPDIRECTDRAWSURFACE3 This,
175                                            LPDDSCAPS pCaps,
176                                            LPDIRECTDRAWSURFACE3* ppAttached)
177 {
178     DDSCAPS2 caps;
179     LPDIRECTDRAWSURFACE7 pAttached7;
180     HRESULT hr;
181
182     caps.dwCaps  = pCaps->dwCaps;
183     caps.dwCaps2 = 0;
184     caps.dwCaps3 = 0;
185     caps.dwCaps4 = 0;
186
187     hr = IDirectDrawSurface7_GetAttachedSurface(CONVERT(This), &caps,
188                                                 &pAttached7);
189     if (FAILED(hr)) return hr;
190
191     *ppAttached = CONVERT_REV(pAttached7);
192     return hr;
193 }
194
195 static HRESULT WINAPI
196 IDirectDrawSurface3Impl_GetBltStatus(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
197 {
198     return IDirectDrawSurface7_GetBltStatus(CONVERT(This), dwFlags);
199 }
200
201 static HRESULT WINAPI
202 IDirectDrawSurface3Impl_GetCaps(LPDIRECTDRAWSURFACE3 This, LPDDSCAPS pCaps)
203 {
204     DDSCAPS2 caps;
205     HRESULT hr;
206
207     hr = IDirectDrawSurface7_GetCaps(CONVERT(This), &caps);
208     if (FAILED(hr)) return hr;
209
210     pCaps->dwCaps = caps.dwCaps;
211     return hr;
212 }
213
214 static HRESULT WINAPI
215 IDirectDrawSurface3Impl_GetClipper(LPDIRECTDRAWSURFACE3 This,
216                                    LPDIRECTDRAWCLIPPER* ppClipper)
217 {
218     return IDirectDrawSurface7_GetClipper(CONVERT(This), ppClipper);
219 }
220
221 static HRESULT WINAPI
222 IDirectDrawSurface3Impl_GetColorKey(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags,
223                                     LPDDCOLORKEY pCKey)
224 {
225     return IDirectDrawSurface7_GetColorKey(CONVERT(This), dwFlags, pCKey);
226 }
227
228 static HRESULT WINAPI
229 IDirectDrawSurface3Impl_GetDC(LPDIRECTDRAWSURFACE3 This, HDC* phDC)
230 {
231     return IDirectDrawSurface7_GetDC(CONVERT(This), phDC);
232 }
233
234 static HRESULT WINAPI
235 IDirectDrawSurface3Impl_GetFlipStatus(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
236 {
237     return IDirectDrawSurface7_GetFlipStatus(CONVERT(This), dwFlags);
238 }
239
240 static HRESULT WINAPI
241 IDirectDrawSurface3Impl_GetOverlayPosition(LPDIRECTDRAWSURFACE3 This, LPLONG pX,
242                                        LPLONG pY)
243 {
244     return IDirectDrawSurface7_GetOverlayPosition(CONVERT(This), pX, pY);
245 }
246
247 static HRESULT WINAPI
248 IDirectDrawSurface3Impl_GetPalette(LPDIRECTDRAWSURFACE3 This,
249                                    LPDIRECTDRAWPALETTE* ppPalette)
250 {
251     return IDirectDrawSurface7_GetPalette(CONVERT(This), ppPalette);
252 }
253
254 static HRESULT WINAPI
255 IDirectDrawSurface3Impl_GetPixelFormat(LPDIRECTDRAWSURFACE3 This,
256                                        LPDDPIXELFORMAT pPixelFormat)
257 {
258     return IDirectDrawSurface7_GetPixelFormat(CONVERT(This), pPixelFormat);
259 }
260
261 static HRESULT WINAPI
262 IDirectDrawSurface3Impl_GetSurfaceDesc(LPDIRECTDRAWSURFACE3 This,
263                                        LPDDSURFACEDESC pDDSD)
264 {
265     return IDirectDrawSurface7_GetSurfaceDesc(CONVERT(This),
266                                               (LPDDSURFACEDESC2)pDDSD);
267 }
268
269 static HRESULT WINAPI
270 IDirectDrawSurface3Impl_Initialize(LPDIRECTDRAWSURFACE3 This, LPDIRECTDRAW pDD,
271                                    LPDDSURFACEDESC pDDSD)
272 {
273     return IDirectDrawSurface7_Initialize(CONVERT(This), pDD,
274                                           (LPDDSURFACEDESC2)pDDSD);
275 }
276
277 static HRESULT WINAPI
278 IDirectDrawSurface3Impl_IsLost(LPDIRECTDRAWSURFACE3 This)
279 {
280     return IDirectDrawSurface7_IsLost(CONVERT(This));
281 }
282
283 static HRESULT WINAPI
284 IDirectDrawSurface3Impl_Lock(LPDIRECTDRAWSURFACE3 This, LPRECT pRect,
285                              LPDDSURFACEDESC pDDSD, DWORD dwFlags, HANDLE h)
286 {
287     return IDirectDrawSurface7_Lock(CONVERT(This), pRect,
288                                     (LPDDSURFACEDESC2)pDDSD, dwFlags, h);
289 }
290
291 static HRESULT WINAPI
292 IDirectDrawSurface3Impl_ReleaseDC(LPDIRECTDRAWSURFACE3 This, HDC hDC)
293 {
294     return IDirectDrawSurface7_ReleaseDC(CONVERT(This), hDC);
295 }
296
297 static HRESULT WINAPI
298 IDirectDrawSurface3Impl_Restore(LPDIRECTDRAWSURFACE3 This)
299 {
300     return IDirectDrawSurface7_Restore(CONVERT(This));
301 }
302
303 static HRESULT WINAPI
304 IDirectDrawSurface3Impl_SetClipper(LPDIRECTDRAWSURFACE3 This,
305                                    LPDIRECTDRAWCLIPPER pClipper)
306 {
307     return IDirectDrawSurface7_SetClipper(CONVERT(This), pClipper);
308 }
309
310 static HRESULT WINAPI
311 IDirectDrawSurface3Impl_SetColorKey(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags,
312                                     LPDDCOLORKEY pCKey)
313 {
314     return IDirectDrawSurface7_SetColorKey(CONVERT(This), dwFlags, pCKey);
315 }
316
317 static HRESULT WINAPI
318 IDirectDrawSurface3Impl_SetOverlayPosition(LPDIRECTDRAWSURFACE3 This, LONG x,
319                                        LONG y)
320 {
321     return IDirectDrawSurface7_SetOverlayPosition(CONVERT(This), x, y);
322 }
323
324 static HRESULT WINAPI
325 IDirectDrawSurface3Impl_SetPalette(LPDIRECTDRAWSURFACE3 This,
326                                    LPDIRECTDRAWPALETTE pPalette)
327 {
328     return IDirectDrawSurface7_SetPalette(CONVERT(This), pPalette);
329 }
330
331 static HRESULT WINAPI
332 IDirectDrawSurface3Impl_Unlock(LPDIRECTDRAWSURFACE3 This, LPVOID data)
333 {
334     /* data might not be the LPRECT of later versions, so drop it. */
335     return IDirectDrawSurface7_Unlock(CONVERT(This), NULL);
336 }
337
338 static HRESULT WINAPI
339 IDirectDrawSurface3Impl_UpdateOverlay(LPDIRECTDRAWSURFACE3 This, LPRECT prcSrc,
340                                       LPDIRECTDRAWSURFACE3 pDstSurf,
341                                       LPRECT prcDst, DWORD dwFlags,
342                                       LPDDOVERLAYFX pFX)
343 {
344     return IDirectDrawSurface7_UpdateOverlay(CONVERT(This), prcSrc,
345                                              CONVERT(pDstSurf), prcDst,
346                                              dwFlags, pFX);
347 }
348
349 static HRESULT WINAPI
350 IDirectDrawSurface3Impl_UpdateOverlayDisplay(LPDIRECTDRAWSURFACE3 This,
351                                              DWORD dwFlags)
352 {
353     return IDirectDrawSurface7_UpdateOverlayDisplay(CONVERT(This), dwFlags);
354 }
355
356 static HRESULT WINAPI
357 IDirectDrawSurface3Impl_UpdateOverlayZOrder(LPDIRECTDRAWSURFACE3 This,
358                                             DWORD dwFlags,
359                                             LPDIRECTDRAWSURFACE3 pSurfReference)
360 {
361     return IDirectDrawSurface7_UpdateOverlayZOrder(CONVERT(This), dwFlags,
362                                                    CONVERT(pSurfReference));
363 }
364
365 static HRESULT WINAPI
366 IDirectDrawSurface3Impl_GetDDInterface(LPDIRECTDRAWSURFACE3 This, LPVOID* ppDD)
367 {
368     return IDirectDrawSurface7_GetDDInterface(CONVERT(This), ppDD);
369 }
370
371 static HRESULT WINAPI
372 IDirectDrawSurface3Impl_PageLock(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
373 {
374     return IDirectDrawSurface7_PageLock(CONVERT(This), dwFlags);
375 }
376
377 static HRESULT WINAPI
378 IDirectDrawSurface3Impl_PageUnlock(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
379 {
380     return IDirectDrawSurface7_PageUnlock(CONVERT(This), dwFlags);
381 }
382
383 static HRESULT WINAPI
384 IDirectDrawSurface3Impl_SetSurfaceDesc(LPDIRECTDRAWSURFACE3 This,
385                                        LPDDSURFACEDESC pDDSD, DWORD dwFlags)
386 {
387     return IDirectDrawSurface7_SetSurfaceDesc(CONVERT(This),
388                                               (LPDDSURFACEDESC2)pDDSD,
389                                               dwFlags);
390 }
391
392 const IDirectDrawSurface3Vtbl DDRAW_IDDS3_Thunk_VTable =
393 {
394     IDirectDrawSurface3Impl_QueryInterface,
395     IDirectDrawSurface3Impl_AddRef,
396     IDirectDrawSurface3Impl_Release,
397     IDirectDrawSurface3Impl_AddAttachedSurface,
398     IDirectDrawSurface3Impl_AddOverlayDirtyRect,
399     IDirectDrawSurface3Impl_Blt,
400     IDirectDrawSurface3Impl_BltBatch,
401     IDirectDrawSurface3Impl_BltFast,
402     IDirectDrawSurface3Impl_DeleteAttachedSurface,
403     IDirectDrawSurface3Impl_EnumAttachedSurfaces,
404     IDirectDrawSurface3Impl_EnumOverlayZOrders,
405     IDirectDrawSurface3Impl_Flip,
406     IDirectDrawSurface3Impl_GetAttachedSurface,
407     IDirectDrawSurface3Impl_GetBltStatus,
408     IDirectDrawSurface3Impl_GetCaps,
409     IDirectDrawSurface3Impl_GetClipper,
410     IDirectDrawSurface3Impl_GetColorKey,
411     IDirectDrawSurface3Impl_GetDC,
412     IDirectDrawSurface3Impl_GetFlipStatus,
413     IDirectDrawSurface3Impl_GetOverlayPosition,
414     IDirectDrawSurface3Impl_GetPalette,
415     IDirectDrawSurface3Impl_GetPixelFormat,
416     IDirectDrawSurface3Impl_GetSurfaceDesc,
417     IDirectDrawSurface3Impl_Initialize,
418     IDirectDrawSurface3Impl_IsLost,
419     IDirectDrawSurface3Impl_Lock,
420     IDirectDrawSurface3Impl_ReleaseDC,
421     IDirectDrawSurface3Impl_Restore,
422     IDirectDrawSurface3Impl_SetClipper,
423     IDirectDrawSurface3Impl_SetColorKey,
424     IDirectDrawSurface3Impl_SetOverlayPosition,
425     IDirectDrawSurface3Impl_SetPalette,
426     IDirectDrawSurface3Impl_Unlock,
427     IDirectDrawSurface3Impl_UpdateOverlay,
428     IDirectDrawSurface3Impl_UpdateOverlayDisplay,
429     IDirectDrawSurface3Impl_UpdateOverlayZOrder,
430     IDirectDrawSurface3Impl_GetDDInterface,
431     IDirectDrawSurface3Impl_PageLock,
432     IDirectDrawSurface3Impl_PageUnlock,
433     IDirectDrawSurface3Impl_SetSurfaceDesc
434 };