configure: Explicitly mention that we need 32-bit libraries to try to avoid some...
[wine/multimedia.git] / dlls / ddraw / surface_thunks.c
bloba0786bb78b6b21e52425b27b5cccabaa390f6ebb
1 /* IDirectDrawSurface3 -> IDirectDrawSurface7 thunks
2 * Copyright 2000 TransGaming Technologies Inc.
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.
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.
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
19 #include "config.h"
20 #include "wine/port.h"
21 #include "wine/debug.h"
22 #include <stdarg.h>
23 #include <assert.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "ddraw.h"
29 #include "winerror.h"
31 #include "ddraw_private.h"
32 #include "ddcomimpl.h"
34 #define CONVERT(pdds) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, \
35 IDirectDrawSurface3, \
36 IDirectDrawSurface7, \
37 (pdds))
39 #define CONVERT_REV(pdds) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, \
40 IDirectDrawSurface7, \
41 IDirectDrawSurface3, \
42 (pdds))
44 WINE_DEFAULT_DEBUG_CHANNEL(ddraw_thunk);
45 WINE_DECLARE_DEBUG_CHANNEL(ddraw);
47 static HRESULT WINAPI
48 IDirectDrawSurface3Impl_QueryInterface(LPDIRECTDRAWSURFACE3 This, REFIID iid,
49 LPVOID *ppObj)
51 return IDirectDrawSurface7_QueryInterface(CONVERT(This), iid, ppObj);
54 static ULONG WINAPI
55 IDirectDrawSurface3Impl_AddRef(LPDIRECTDRAWSURFACE3 This)
57 return IDirectDrawSurface7_AddRef(CONVERT(This));
60 static ULONG WINAPI
61 IDirectDrawSurface3Impl_Release(LPDIRECTDRAWSURFACE3 iface)
63 ICOM_THIS_FROM( IDirectDrawSurfaceImpl, IDirectDrawSurface3, iface);
64 TRACE("(%p)\n", This);
65 return IDirectDrawSurface7_Release(CONVERT(iface));
68 static HRESULT WINAPI
69 IDirectDrawSurface3Impl_AddAttachedSurface(LPDIRECTDRAWSURFACE3 iface,
70 LPDIRECTDRAWSURFACE3 pAttach)
72 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface3, iface);
73 IDirectDrawSurfaceImpl *Surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface3, pAttach);
74 TRACE("(%p)->(%p)\n", This, Surf);
76 /* Tests suggest that
77 * -> offscreen plain surfaces can be attached to other offscreen plain surfaces
78 * -> offscreen plain surfaces can be attached to primaries
79 * -> primaries can be attached to offscreen plain surfaces
80 * -> z buffers can be attached to primaries
83 if(This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_OFFSCREENPLAIN) &&
84 Surf->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_OFFSCREENPLAIN))
86 /* Sizes have to match */
87 if(Surf->surface_desc.dwWidth != This->surface_desc.dwWidth ||
88 Surf->surface_desc.dwHeight != This->surface_desc.dwHeight)
90 WARN("Surface sizes do not match\n");
91 return DDERR_CANNOTATTACHSURFACE;
93 /* OK */
95 else if(This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE) &&
96 Surf->surface_desc.ddsCaps.dwCaps & (DDSCAPS_ZBUFFER))
98 /* OK */
100 else
102 WARN("Invalid attachment combination\n");
103 return DDERR_CANNOTATTACHSURFACE;
106 return IDirectDrawSurfaceImpl_AddAttachedSurface(This,
107 Surf);
110 static HRESULT WINAPI
111 IDirectDrawSurface3Impl_AddOverlayDirtyRect(LPDIRECTDRAWSURFACE3 This,
112 LPRECT pRect)
114 return IDirectDrawSurface7_AddOverlayDirtyRect(CONVERT(This), pRect);
117 static HRESULT WINAPI
118 IDirectDrawSurface3Impl_Blt(LPDIRECTDRAWSURFACE3 This, LPRECT prcDst,
119 LPDIRECTDRAWSURFACE3 pSrcSurf, LPRECT prcSrc,
120 DWORD dwFlags, LPDDBLTFX pFX)
122 return IDirectDrawSurface7_Blt(CONVERT(This), prcDst, CONVERT(pSrcSurf),
123 prcSrc, dwFlags, pFX);
126 static HRESULT WINAPI
127 IDirectDrawSurface3Impl_BltBatch(LPDIRECTDRAWSURFACE3 This,
128 LPDDBLTBATCH pBatch, DWORD dwCount,
129 DWORD dwFlags)
131 return IDirectDrawSurface7_BltBatch(CONVERT(This), pBatch, dwCount,
132 dwFlags);
135 static HRESULT WINAPI
136 IDirectDrawSurface3Impl_BltFast(LPDIRECTDRAWSURFACE3 This, DWORD x, DWORD y,
137 LPDIRECTDRAWSURFACE3 pSrcSurf, LPRECT prcSrc,
138 DWORD dwTrans)
140 return IDirectDrawSurface7_BltFast(CONVERT(This), x, y, CONVERT(pSrcSurf),
141 prcSrc, dwTrans);
144 static HRESULT WINAPI
145 IDirectDrawSurface3Impl_DeleteAttachedSurface(LPDIRECTDRAWSURFACE3 This,
146 DWORD dwFlags,
147 LPDIRECTDRAWSURFACE3 pAttached)
149 return IDirectDrawSurface7_DeleteAttachedSurface(CONVERT(This), dwFlags,
150 CONVERT(pAttached));
153 struct callback_info
155 LPDDENUMSURFACESCALLBACK callback;
156 LPVOID context;
159 static HRESULT CALLBACK
160 EnumCallback(LPDIRECTDRAWSURFACE7 iface, LPDDSURFACEDESC2 pDDSD,
161 LPVOID context)
163 const struct callback_info* info = context;
165 #if 0
166 /* This is an outgoing conversion so we have to do it. */
167 DDSURFACEDESC ddsd;
168 memset(&ddsd, 0, sizeof(ddsd));
169 ddsd.dwSize = sizeof(ddsd);
170 DDRAW_Convert_DDSURFACEDESC_2_To_1(pDDSD, &ddsd);
171 #endif
173 /* the LPDDSURFACEDESC2 -> LPDDSURFACEDESC coercion is safe, since
174 * the data format is compatible with older enum procs */
175 return info->callback((LPDIRECTDRAWSURFACE)CONVERT_REV(iface), (LPDDSURFACEDESC)pDDSD,
176 info->context);
179 static HRESULT WINAPI
180 IDirectDrawSurface3Impl_EnumAttachedSurfaces(LPDIRECTDRAWSURFACE3 This,
181 LPVOID context,
182 LPDDENUMSURFACESCALLBACK callback)
184 struct callback_info info;
186 info.callback = callback;
187 info.context = context;
189 return IDirectDrawSurface7_EnumAttachedSurfaces(CONVERT(This), &info,
190 EnumCallback);
193 static HRESULT WINAPI
194 IDirectDrawSurface3Impl_EnumOverlayZOrders(LPDIRECTDRAWSURFACE3 This,
195 DWORD dwFlags, LPVOID context,
196 LPDDENUMSURFACESCALLBACK callback)
198 struct callback_info info;
200 info.callback = callback;
201 info.context = context;
203 return IDirectDrawSurface7_EnumOverlayZOrders(CONVERT(This), dwFlags,
204 &info, EnumCallback);
207 static HRESULT WINAPI
208 IDirectDrawSurface3Impl_Flip(LPDIRECTDRAWSURFACE3 This,
209 LPDIRECTDRAWSURFACE3 pOverride, DWORD dwFlags)
211 return IDirectDrawSurface7_Flip(CONVERT(This), CONVERT(pOverride),
212 dwFlags);
215 static HRESULT WINAPI
216 IDirectDrawSurface3Impl_GetAttachedSurface(LPDIRECTDRAWSURFACE3 This,
217 LPDDSCAPS pCaps,
218 LPDIRECTDRAWSURFACE3* ppAttached)
220 DDSCAPS2 caps;
221 LPDIRECTDRAWSURFACE7 pAttached7;
222 HRESULT hr;
224 caps.dwCaps = pCaps->dwCaps;
225 caps.dwCaps2 = 0;
226 caps.dwCaps3 = 0;
227 caps.dwCaps4 = 0;
229 hr = IDirectDrawSurface7_GetAttachedSurface(CONVERT(This), &caps,
230 &pAttached7);
231 if (FAILED(hr)) *ppAttached = NULL;
232 else *ppAttached = CONVERT_REV(pAttached7);
233 return hr;
236 static HRESULT WINAPI
237 IDirectDrawSurface3Impl_GetBltStatus(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
239 return IDirectDrawSurface7_GetBltStatus(CONVERT(This), dwFlags);
242 static HRESULT WINAPI
243 IDirectDrawSurface3Impl_GetCaps(LPDIRECTDRAWSURFACE3 This, LPDDSCAPS pCaps)
245 DDSCAPS2 caps;
246 HRESULT hr;
248 hr = IDirectDrawSurface7_GetCaps(CONVERT(This), &caps);
249 if (FAILED(hr)) return hr;
251 pCaps->dwCaps = caps.dwCaps;
252 return hr;
255 static HRESULT WINAPI
256 IDirectDrawSurface3Impl_GetClipper(LPDIRECTDRAWSURFACE3 This,
257 LPDIRECTDRAWCLIPPER* ppClipper)
259 return IDirectDrawSurface7_GetClipper(CONVERT(This), ppClipper);
262 static HRESULT WINAPI
263 IDirectDrawSurface3Impl_GetColorKey(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags,
264 LPDDCOLORKEY pCKey)
266 return IDirectDrawSurface7_GetColorKey(CONVERT(This), dwFlags, pCKey);
269 static HRESULT WINAPI
270 IDirectDrawSurface3Impl_GetDC(LPDIRECTDRAWSURFACE3 This, HDC* phDC)
272 return IDirectDrawSurface7_GetDC(CONVERT(This), phDC);
275 static HRESULT WINAPI
276 IDirectDrawSurface3Impl_GetFlipStatus(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
278 return IDirectDrawSurface7_GetFlipStatus(CONVERT(This), dwFlags);
281 static HRESULT WINAPI
282 IDirectDrawSurface3Impl_GetOverlayPosition(LPDIRECTDRAWSURFACE3 This, LPLONG pX,
283 LPLONG pY)
285 return IDirectDrawSurface7_GetOverlayPosition(CONVERT(This), pX, pY);
288 static HRESULT WINAPI
289 IDirectDrawSurface3Impl_GetPalette(LPDIRECTDRAWSURFACE3 This,
290 LPDIRECTDRAWPALETTE* ppPalette)
292 return IDirectDrawSurface7_GetPalette(CONVERT(This), ppPalette);
295 static HRESULT WINAPI
296 IDirectDrawSurface3Impl_GetPixelFormat(LPDIRECTDRAWSURFACE3 This,
297 LPDDPIXELFORMAT pPixelFormat)
299 return IDirectDrawSurface7_GetPixelFormat(CONVERT(This), pPixelFormat);
302 static HRESULT WINAPI
303 IDirectDrawSurface3Impl_GetSurfaceDesc(LPDIRECTDRAWSURFACE3 iface,
304 LPDDSURFACEDESC pDDSD)
306 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface3, iface);
308 TRACE_(ddraw)("(%p)->(%p)\n",This,pDDSD);
310 if(!pDDSD)
311 return DDERR_INVALIDPARAMS;
313 if (pDDSD->dwSize != sizeof(DDSURFACEDESC))
315 WARN("Incorrect struct size %d, returning DDERR_INVALIDPARAMS\n",pDDSD->dwSize);
316 return DDERR_INVALIDPARAMS;
319 EnterCriticalSection(&ddraw_cs);
320 DD_STRUCT_COPY_BYSIZE(pDDSD,(DDSURFACEDESC *) &This->surface_desc);
321 TRACE("Returning surface desc:\n");
322 if (TRACE_ON(ddraw))
324 /* DDRAW_dump_surface_desc handles the smaller size */
325 DDRAW_dump_surface_desc((DDSURFACEDESC2 *) pDDSD);
328 LeaveCriticalSection(&ddraw_cs);
329 return DD_OK;
332 static HRESULT WINAPI
333 IDirectDrawSurface3Impl_Initialize(LPDIRECTDRAWSURFACE3 This, LPDIRECTDRAW pDD,
334 LPDDSURFACEDESC pDDSD)
336 return IDirectDrawSurface7_Initialize(CONVERT(This), pDD,
337 (LPDDSURFACEDESC2)pDDSD);
340 static HRESULT WINAPI
341 IDirectDrawSurface3Impl_IsLost(LPDIRECTDRAWSURFACE3 This)
343 return IDirectDrawSurface7_IsLost(CONVERT(This));
346 static HRESULT WINAPI
347 IDirectDrawSurface3Impl_Lock(LPDIRECTDRAWSURFACE3 This, LPRECT pRect,
348 LPDDSURFACEDESC pDDSD, DWORD dwFlags, HANDLE h)
350 return IDirectDrawSurface7_Lock(CONVERT(This), pRect,
351 (LPDDSURFACEDESC2)pDDSD, dwFlags, h);
354 static HRESULT WINAPI
355 IDirectDrawSurface3Impl_ReleaseDC(LPDIRECTDRAWSURFACE3 This, HDC hDC)
357 return IDirectDrawSurface7_ReleaseDC(CONVERT(This), hDC);
360 static HRESULT WINAPI
361 IDirectDrawSurface3Impl_Restore(LPDIRECTDRAWSURFACE3 This)
363 return IDirectDrawSurface7_Restore(CONVERT(This));
366 static HRESULT WINAPI
367 IDirectDrawSurface3Impl_SetClipper(LPDIRECTDRAWSURFACE3 This,
368 LPDIRECTDRAWCLIPPER pClipper)
370 return IDirectDrawSurface7_SetClipper(CONVERT(This), pClipper);
373 static HRESULT WINAPI
374 IDirectDrawSurface3Impl_SetColorKey(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags,
375 LPDDCOLORKEY pCKey)
377 return IDirectDrawSurface7_SetColorKey(CONVERT(This), dwFlags, pCKey);
380 static HRESULT WINAPI
381 IDirectDrawSurface3Impl_SetOverlayPosition(LPDIRECTDRAWSURFACE3 This, LONG x,
382 LONG y)
384 return IDirectDrawSurface7_SetOverlayPosition(CONVERT(This), x, y);
387 static HRESULT WINAPI
388 IDirectDrawSurface3Impl_SetPalette(LPDIRECTDRAWSURFACE3 This,
389 LPDIRECTDRAWPALETTE pPalette)
391 return IDirectDrawSurface7_SetPalette(CONVERT(This), pPalette);
394 static HRESULT WINAPI
395 IDirectDrawSurface3Impl_Unlock(LPDIRECTDRAWSURFACE3 This, LPVOID data)
397 /* data might not be the LPRECT of later versions, so drop it. */
398 return IDirectDrawSurface7_Unlock(CONVERT(This), NULL);
401 static HRESULT WINAPI
402 IDirectDrawSurface3Impl_UpdateOverlay(LPDIRECTDRAWSURFACE3 This, LPRECT prcSrc,
403 LPDIRECTDRAWSURFACE3 pDstSurf,
404 LPRECT prcDst, DWORD dwFlags,
405 LPDDOVERLAYFX pFX)
407 return IDirectDrawSurface7_UpdateOverlay(CONVERT(This), prcSrc,
408 CONVERT(pDstSurf), prcDst,
409 dwFlags, pFX);
412 static HRESULT WINAPI
413 IDirectDrawSurface3Impl_UpdateOverlayDisplay(LPDIRECTDRAWSURFACE3 This,
414 DWORD dwFlags)
416 return IDirectDrawSurface7_UpdateOverlayDisplay(CONVERT(This), dwFlags);
419 static HRESULT WINAPI
420 IDirectDrawSurface3Impl_UpdateOverlayZOrder(LPDIRECTDRAWSURFACE3 This,
421 DWORD dwFlags,
422 LPDIRECTDRAWSURFACE3 pSurfReference)
424 return IDirectDrawSurface7_UpdateOverlayZOrder(CONVERT(This), dwFlags,
425 CONVERT(pSurfReference));
428 static HRESULT WINAPI
429 IDirectDrawSurface3Impl_GetDDInterface(LPDIRECTDRAWSURFACE3 This, LPVOID* ppDD)
431 return IDirectDrawSurface7_GetDDInterface(CONVERT(This), ppDD);
434 static HRESULT WINAPI
435 IDirectDrawSurface3Impl_PageLock(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
437 return IDirectDrawSurface7_PageLock(CONVERT(This), dwFlags);
440 static HRESULT WINAPI
441 IDirectDrawSurface3Impl_PageUnlock(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
443 return IDirectDrawSurface7_PageUnlock(CONVERT(This), dwFlags);
446 static HRESULT WINAPI
447 IDirectDrawSurface3Impl_SetSurfaceDesc(LPDIRECTDRAWSURFACE3 This,
448 LPDDSURFACEDESC pDDSD, DWORD dwFlags)
450 return IDirectDrawSurface7_SetSurfaceDesc(CONVERT(This),
451 (LPDDSURFACEDESC2)pDDSD,
452 dwFlags);
455 const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl =
457 IDirectDrawSurface3Impl_QueryInterface,
458 IDirectDrawSurface3Impl_AddRef,
459 IDirectDrawSurface3Impl_Release,
460 IDirectDrawSurface3Impl_AddAttachedSurface,
461 IDirectDrawSurface3Impl_AddOverlayDirtyRect,
462 IDirectDrawSurface3Impl_Blt,
463 IDirectDrawSurface3Impl_BltBatch,
464 IDirectDrawSurface3Impl_BltFast,
465 IDirectDrawSurface3Impl_DeleteAttachedSurface,
466 IDirectDrawSurface3Impl_EnumAttachedSurfaces,
467 IDirectDrawSurface3Impl_EnumOverlayZOrders,
468 IDirectDrawSurface3Impl_Flip,
469 IDirectDrawSurface3Impl_GetAttachedSurface,
470 IDirectDrawSurface3Impl_GetBltStatus,
471 IDirectDrawSurface3Impl_GetCaps,
472 IDirectDrawSurface3Impl_GetClipper,
473 IDirectDrawSurface3Impl_GetColorKey,
474 IDirectDrawSurface3Impl_GetDC,
475 IDirectDrawSurface3Impl_GetFlipStatus,
476 IDirectDrawSurface3Impl_GetOverlayPosition,
477 IDirectDrawSurface3Impl_GetPalette,
478 IDirectDrawSurface3Impl_GetPixelFormat,
479 IDirectDrawSurface3Impl_GetSurfaceDesc,
480 IDirectDrawSurface3Impl_Initialize,
481 IDirectDrawSurface3Impl_IsLost,
482 IDirectDrawSurface3Impl_Lock,
483 IDirectDrawSurface3Impl_ReleaseDC,
484 IDirectDrawSurface3Impl_Restore,
485 IDirectDrawSurface3Impl_SetClipper,
486 IDirectDrawSurface3Impl_SetColorKey,
487 IDirectDrawSurface3Impl_SetOverlayPosition,
488 IDirectDrawSurface3Impl_SetPalette,
489 IDirectDrawSurface3Impl_Unlock,
490 IDirectDrawSurface3Impl_UpdateOverlay,
491 IDirectDrawSurface3Impl_UpdateOverlayDisplay,
492 IDirectDrawSurface3Impl_UpdateOverlayZOrder,
493 IDirectDrawSurface3Impl_GetDDInterface,
494 IDirectDrawSurface3Impl_PageLock,
495 IDirectDrawSurface3Impl_PageUnlock,
496 IDirectDrawSurface3Impl_SetSurfaceDesc