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