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
20 #include "wine/port.h"
21 #include "wine/debug.h"
31 #include "ddraw_private.h"
32 #include "ddcomimpl.h"
34 #define CONVERT(pdds) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, \
35 IDirectDrawSurface3, \
36 IDirectDrawSurface7, \
39 #define CONVERT_REV(pdds) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, \
40 IDirectDrawSurface7, \
41 IDirectDrawSurface3, \
44 WINE_DEFAULT_DEBUG_CHANNEL(ddraw_thunk);
45 WINE_DECLARE_DEBUG_CHANNEL(ddraw);
47 static inline IDirectDrawSurfaceImpl *surface_from_surface3(IDirectDrawSurface3 *iface)
49 return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirectDrawSurface3_vtbl));
53 IDirectDrawSurface3Impl_QueryInterface(LPDIRECTDRAWSURFACE3 This, REFIID iid,
56 return IDirectDrawSurface7_QueryInterface(CONVERT(This), iid, ppObj);
60 IDirectDrawSurface3Impl_AddRef(LPDIRECTDRAWSURFACE3 This)
62 return IDirectDrawSurface7_AddRef(CONVERT(This));
66 IDirectDrawSurface3Impl_Release(LPDIRECTDRAWSURFACE3 iface)
68 IDirectDrawSurfaceImpl *This = surface_from_surface3(iface);
69 TRACE("(%p)\n", This);
70 return IDirectDrawSurface7_Release(CONVERT(iface));
74 IDirectDrawSurface3Impl_AddAttachedSurface(LPDIRECTDRAWSURFACE3 iface,
75 LPDIRECTDRAWSURFACE3 pAttach)
77 IDirectDrawSurfaceImpl *This = surface_from_surface3(iface);
78 IDirectDrawSurfaceImpl *Surf = surface_from_surface3(pAttach);
79 TRACE("(%p)->(%p)\n", This, Surf);
82 * -> offscreen plain surfaces can be attached to other offscreen plain surfaces
83 * -> offscreen plain surfaces can be attached to primaries
84 * -> primaries can be attached to offscreen plain surfaces
85 * -> z buffers can be attached to primaries
88 if(This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_OFFSCREENPLAIN) &&
89 Surf->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_OFFSCREENPLAIN))
91 /* Sizes have to match */
92 if(Surf->surface_desc.dwWidth != This->surface_desc.dwWidth ||
93 Surf->surface_desc.dwHeight != This->surface_desc.dwHeight)
95 WARN("Surface sizes do not match\n");
96 return DDERR_CANNOTATTACHSURFACE;
100 else if(This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE) &&
101 Surf->surface_desc.ddsCaps.dwCaps & (DDSCAPS_ZBUFFER))
107 WARN("Invalid attachment combination\n");
108 return DDERR_CANNOTATTACHSURFACE;
111 return IDirectDrawSurfaceImpl_AddAttachedSurface(This,
115 static HRESULT WINAPI
116 IDirectDrawSurface3Impl_AddOverlayDirtyRect(LPDIRECTDRAWSURFACE3 This,
119 return IDirectDrawSurface7_AddOverlayDirtyRect(CONVERT(This), pRect);
122 static HRESULT WINAPI
123 IDirectDrawSurface3Impl_Blt(LPDIRECTDRAWSURFACE3 This, LPRECT prcDst,
124 LPDIRECTDRAWSURFACE3 pSrcSurf, LPRECT prcSrc,
125 DWORD dwFlags, LPDDBLTFX pFX)
127 return IDirectDrawSurface7_Blt(CONVERT(This), prcDst, CONVERT(pSrcSurf),
128 prcSrc, dwFlags, pFX);
131 static HRESULT WINAPI
132 IDirectDrawSurface3Impl_BltBatch(LPDIRECTDRAWSURFACE3 This,
133 LPDDBLTBATCH pBatch, DWORD dwCount,
136 return IDirectDrawSurface7_BltBatch(CONVERT(This), pBatch, dwCount,
140 static HRESULT WINAPI
141 IDirectDrawSurface3Impl_BltFast(LPDIRECTDRAWSURFACE3 This, DWORD x, DWORD y,
142 LPDIRECTDRAWSURFACE3 pSrcSurf, LPRECT prcSrc,
145 return IDirectDrawSurface7_BltFast(CONVERT(This), x, y, CONVERT(pSrcSurf),
149 static HRESULT WINAPI
150 IDirectDrawSurface3Impl_DeleteAttachedSurface(LPDIRECTDRAWSURFACE3 This,
152 LPDIRECTDRAWSURFACE3 pAttached)
154 return IDirectDrawSurface7_DeleteAttachedSurface(CONVERT(This), dwFlags,
160 LPDDENUMSURFACESCALLBACK callback;
164 static HRESULT CALLBACK
165 EnumCallback(LPDIRECTDRAWSURFACE7 iface, LPDDSURFACEDESC2 pDDSD,
168 const struct callback_info* info = context;
171 /* This is an outgoing conversion so we have to do it. */
173 memset(&ddsd, 0, sizeof(ddsd));
174 ddsd.dwSize = sizeof(ddsd);
175 DDRAW_Convert_DDSURFACEDESC_2_To_1(pDDSD, &ddsd);
178 /* the LPDDSURFACEDESC2 -> LPDDSURFACEDESC coercion is safe, since
179 * the data format is compatible with older enum procs */
180 return info->callback((LPDIRECTDRAWSURFACE)CONVERT_REV(iface), (LPDDSURFACEDESC)pDDSD,
184 static HRESULT WINAPI
185 IDirectDrawSurface3Impl_EnumAttachedSurfaces(LPDIRECTDRAWSURFACE3 This,
187 LPDDENUMSURFACESCALLBACK callback)
189 struct callback_info info;
191 info.callback = callback;
192 info.context = context;
194 return IDirectDrawSurface7_EnumAttachedSurfaces(CONVERT(This), &info,
198 static HRESULT WINAPI
199 IDirectDrawSurface3Impl_EnumOverlayZOrders(LPDIRECTDRAWSURFACE3 This,
200 DWORD dwFlags, LPVOID context,
201 LPDDENUMSURFACESCALLBACK callback)
203 struct callback_info info;
205 info.callback = callback;
206 info.context = context;
208 return IDirectDrawSurface7_EnumOverlayZOrders(CONVERT(This), dwFlags,
209 &info, EnumCallback);
212 static HRESULT WINAPI
213 IDirectDrawSurface3Impl_Flip(LPDIRECTDRAWSURFACE3 This,
214 LPDIRECTDRAWSURFACE3 pOverride, DWORD dwFlags)
216 return IDirectDrawSurface7_Flip(CONVERT(This), CONVERT(pOverride),
220 static HRESULT WINAPI
221 IDirectDrawSurface3Impl_GetAttachedSurface(LPDIRECTDRAWSURFACE3 This,
223 LPDIRECTDRAWSURFACE3* ppAttached)
226 LPDIRECTDRAWSURFACE7 pAttached7;
229 caps.dwCaps = pCaps->dwCaps;
234 hr = IDirectDrawSurface7_GetAttachedSurface(CONVERT(This), &caps,
236 if (FAILED(hr)) *ppAttached = NULL;
237 else *ppAttached = CONVERT_REV(pAttached7);
241 static HRESULT WINAPI
242 IDirectDrawSurface3Impl_GetBltStatus(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
244 return IDirectDrawSurface7_GetBltStatus(CONVERT(This), dwFlags);
247 static HRESULT WINAPI
248 IDirectDrawSurface3Impl_GetCaps(LPDIRECTDRAWSURFACE3 This, LPDDSCAPS pCaps)
253 hr = IDirectDrawSurface7_GetCaps(CONVERT(This), &caps);
254 if (FAILED(hr)) return hr;
256 pCaps->dwCaps = caps.dwCaps;
260 static HRESULT WINAPI
261 IDirectDrawSurface3Impl_GetClipper(LPDIRECTDRAWSURFACE3 This,
262 LPDIRECTDRAWCLIPPER* ppClipper)
264 return IDirectDrawSurface7_GetClipper(CONVERT(This), ppClipper);
267 static HRESULT WINAPI
268 IDirectDrawSurface3Impl_GetColorKey(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags,
271 return IDirectDrawSurface7_GetColorKey(CONVERT(This), dwFlags, pCKey);
274 static HRESULT WINAPI
275 IDirectDrawSurface3Impl_GetDC(LPDIRECTDRAWSURFACE3 This, HDC* phDC)
277 return IDirectDrawSurface7_GetDC(CONVERT(This), phDC);
280 static HRESULT WINAPI
281 IDirectDrawSurface3Impl_GetFlipStatus(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
283 return IDirectDrawSurface7_GetFlipStatus(CONVERT(This), dwFlags);
286 static HRESULT WINAPI
287 IDirectDrawSurface3Impl_GetOverlayPosition(LPDIRECTDRAWSURFACE3 This, LPLONG pX,
290 return IDirectDrawSurface7_GetOverlayPosition(CONVERT(This), pX, pY);
293 static HRESULT WINAPI
294 IDirectDrawSurface3Impl_GetPalette(LPDIRECTDRAWSURFACE3 This,
295 LPDIRECTDRAWPALETTE* ppPalette)
297 return IDirectDrawSurface7_GetPalette(CONVERT(This), ppPalette);
300 static HRESULT WINAPI
301 IDirectDrawSurface3Impl_GetPixelFormat(LPDIRECTDRAWSURFACE3 This,
302 LPDDPIXELFORMAT pPixelFormat)
304 return IDirectDrawSurface7_GetPixelFormat(CONVERT(This), pPixelFormat);
307 static HRESULT WINAPI
308 IDirectDrawSurface3Impl_GetSurfaceDesc(LPDIRECTDRAWSURFACE3 iface,
309 LPDDSURFACEDESC pDDSD)
311 IDirectDrawSurfaceImpl *This = surface_from_surface3(iface);
313 TRACE_(ddraw)("(%p)->(%p)\n",This,pDDSD);
316 return DDERR_INVALIDPARAMS;
318 if (pDDSD->dwSize != sizeof(DDSURFACEDESC))
320 WARN("Incorrect struct size %d, returning DDERR_INVALIDPARAMS\n",pDDSD->dwSize);
321 return DDERR_INVALIDPARAMS;
324 EnterCriticalSection(&ddraw_cs);
325 DD_STRUCT_COPY_BYSIZE(pDDSD,(DDSURFACEDESC *) &This->surface_desc);
326 TRACE("Returning surface desc:\n");
329 /* DDRAW_dump_surface_desc handles the smaller size */
330 DDRAW_dump_surface_desc((DDSURFACEDESC2 *) pDDSD);
333 LeaveCriticalSection(&ddraw_cs);
337 static HRESULT WINAPI
338 IDirectDrawSurface3Impl_Initialize(LPDIRECTDRAWSURFACE3 This, LPDIRECTDRAW pDD,
339 LPDDSURFACEDESC pDDSD)
341 return IDirectDrawSurface7_Initialize(CONVERT(This), pDD,
342 (LPDDSURFACEDESC2)pDDSD);
345 static HRESULT WINAPI
346 IDirectDrawSurface3Impl_IsLost(LPDIRECTDRAWSURFACE3 This)
348 return IDirectDrawSurface7_IsLost(CONVERT(This));
351 static HRESULT WINAPI
352 IDirectDrawSurface3Impl_Lock(LPDIRECTDRAWSURFACE3 This, LPRECT pRect,
353 LPDDSURFACEDESC pDDSD, DWORD dwFlags, HANDLE h)
355 return IDirectDrawSurface7_Lock(CONVERT(This), pRect,
356 (LPDDSURFACEDESC2)pDDSD, dwFlags, h);
359 static HRESULT WINAPI
360 IDirectDrawSurface3Impl_ReleaseDC(LPDIRECTDRAWSURFACE3 This, HDC hDC)
362 return IDirectDrawSurface7_ReleaseDC(CONVERT(This), hDC);
365 static HRESULT WINAPI
366 IDirectDrawSurface3Impl_Restore(LPDIRECTDRAWSURFACE3 This)
368 return IDirectDrawSurface7_Restore(CONVERT(This));
371 static HRESULT WINAPI
372 IDirectDrawSurface3Impl_SetClipper(LPDIRECTDRAWSURFACE3 This,
373 LPDIRECTDRAWCLIPPER pClipper)
375 return IDirectDrawSurface7_SetClipper(CONVERT(This), pClipper);
378 static HRESULT WINAPI
379 IDirectDrawSurface3Impl_SetColorKey(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags,
382 return IDirectDrawSurface7_SetColorKey(CONVERT(This), dwFlags, pCKey);
385 static HRESULT WINAPI
386 IDirectDrawSurface3Impl_SetOverlayPosition(LPDIRECTDRAWSURFACE3 This, LONG x,
389 return IDirectDrawSurface7_SetOverlayPosition(CONVERT(This), x, y);
392 static HRESULT WINAPI
393 IDirectDrawSurface3Impl_SetPalette(LPDIRECTDRAWSURFACE3 This,
394 LPDIRECTDRAWPALETTE pPalette)
396 return IDirectDrawSurface7_SetPalette(CONVERT(This), pPalette);
399 static HRESULT WINAPI
400 IDirectDrawSurface3Impl_Unlock(LPDIRECTDRAWSURFACE3 This, LPVOID data)
402 /* data might not be the LPRECT of later versions, so drop it. */
403 return IDirectDrawSurface7_Unlock(CONVERT(This), NULL);
406 static HRESULT WINAPI
407 IDirectDrawSurface3Impl_UpdateOverlay(LPDIRECTDRAWSURFACE3 This, LPRECT prcSrc,
408 LPDIRECTDRAWSURFACE3 pDstSurf,
409 LPRECT prcDst, DWORD dwFlags,
412 return IDirectDrawSurface7_UpdateOverlay(CONVERT(This), prcSrc,
413 CONVERT(pDstSurf), prcDst,
417 static HRESULT WINAPI
418 IDirectDrawSurface3Impl_UpdateOverlayDisplay(LPDIRECTDRAWSURFACE3 This,
421 return IDirectDrawSurface7_UpdateOverlayDisplay(CONVERT(This), dwFlags);
424 static HRESULT WINAPI
425 IDirectDrawSurface3Impl_UpdateOverlayZOrder(LPDIRECTDRAWSURFACE3 This,
427 LPDIRECTDRAWSURFACE3 pSurfReference)
429 return IDirectDrawSurface7_UpdateOverlayZOrder(CONVERT(This), dwFlags,
430 CONVERT(pSurfReference));
433 static HRESULT WINAPI
434 IDirectDrawSurface3Impl_GetDDInterface(LPDIRECTDRAWSURFACE3 This, LPVOID* ppDD)
436 return IDirectDrawSurface7_GetDDInterface(CONVERT(This), ppDD);
439 static HRESULT WINAPI
440 IDirectDrawSurface3Impl_PageLock(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
442 return IDirectDrawSurface7_PageLock(CONVERT(This), dwFlags);
445 static HRESULT WINAPI
446 IDirectDrawSurface3Impl_PageUnlock(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
448 return IDirectDrawSurface7_PageUnlock(CONVERT(This), dwFlags);
451 static HRESULT WINAPI
452 IDirectDrawSurface3Impl_SetSurfaceDesc(LPDIRECTDRAWSURFACE3 This,
453 LPDDSURFACEDESC pDDSD, DWORD dwFlags)
455 return IDirectDrawSurface7_SetSurfaceDesc(CONVERT(This),
456 (LPDDSURFACEDESC2)pDDSD,
460 const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl =
462 IDirectDrawSurface3Impl_QueryInterface,
463 IDirectDrawSurface3Impl_AddRef,
464 IDirectDrawSurface3Impl_Release,
465 IDirectDrawSurface3Impl_AddAttachedSurface,
466 IDirectDrawSurface3Impl_AddOverlayDirtyRect,
467 IDirectDrawSurface3Impl_Blt,
468 IDirectDrawSurface3Impl_BltBatch,
469 IDirectDrawSurface3Impl_BltFast,
470 IDirectDrawSurface3Impl_DeleteAttachedSurface,
471 IDirectDrawSurface3Impl_EnumAttachedSurfaces,
472 IDirectDrawSurface3Impl_EnumOverlayZOrders,
473 IDirectDrawSurface3Impl_Flip,
474 IDirectDrawSurface3Impl_GetAttachedSurface,
475 IDirectDrawSurface3Impl_GetBltStatus,
476 IDirectDrawSurface3Impl_GetCaps,
477 IDirectDrawSurface3Impl_GetClipper,
478 IDirectDrawSurface3Impl_GetColorKey,
479 IDirectDrawSurface3Impl_GetDC,
480 IDirectDrawSurface3Impl_GetFlipStatus,
481 IDirectDrawSurface3Impl_GetOverlayPosition,
482 IDirectDrawSurface3Impl_GetPalette,
483 IDirectDrawSurface3Impl_GetPixelFormat,
484 IDirectDrawSurface3Impl_GetSurfaceDesc,
485 IDirectDrawSurface3Impl_Initialize,
486 IDirectDrawSurface3Impl_IsLost,
487 IDirectDrawSurface3Impl_Lock,
488 IDirectDrawSurface3Impl_ReleaseDC,
489 IDirectDrawSurface3Impl_Restore,
490 IDirectDrawSurface3Impl_SetClipper,
491 IDirectDrawSurface3Impl_SetColorKey,
492 IDirectDrawSurface3Impl_SetOverlayPosition,
493 IDirectDrawSurface3Impl_SetPalette,
494 IDirectDrawSurface3Impl_Unlock,
495 IDirectDrawSurface3Impl_UpdateOverlay,
496 IDirectDrawSurface3Impl_UpdateOverlayDisplay,
497 IDirectDrawSurface3Impl_UpdateOverlayZOrder,
498 IDirectDrawSurface3Impl_GetDDInterface,
499 IDirectDrawSurface3Impl_PageLock,
500 IDirectDrawSurface3Impl_PageUnlock,
501 IDirectDrawSurface3Impl_SetSurfaceDesc