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"
33 WINE_DEFAULT_DEBUG_CHANNEL(ddraw_thunk);
34 WINE_DECLARE_DEBUG_CHANNEL(ddraw);
37 IDirectDrawSurface3Impl_QueryInterface(LPDIRECTDRAWSURFACE3 This, REFIID iid,
40 return IDirectDrawSurface7_QueryInterface((IDirectDrawSurface7 *)surface_from_surface3(This), iid, ppObj);
44 IDirectDrawSurface3Impl_AddRef(LPDIRECTDRAWSURFACE3 This)
46 return IDirectDrawSurface7_AddRef((IDirectDrawSurface7 *)surface_from_surface3(This));
50 IDirectDrawSurface3Impl_Release(LPDIRECTDRAWSURFACE3 iface)
52 IDirectDrawSurfaceImpl *This = surface_from_surface3(iface);
53 TRACE("(%p)\n", This);
54 return IDirectDrawSurface7_Release((IDirectDrawSurface7 *)surface_from_surface3(iface));
58 IDirectDrawSurface3Impl_AddAttachedSurface(LPDIRECTDRAWSURFACE3 iface,
59 LPDIRECTDRAWSURFACE3 pAttach)
61 IDirectDrawSurfaceImpl *This = surface_from_surface3(iface);
62 IDirectDrawSurfaceImpl *Surf = surface_from_surface3(pAttach);
63 TRACE("(%p)->(%p)\n", This, Surf);
66 * -> offscreen plain surfaces can be attached to other offscreen plain surfaces
67 * -> offscreen plain surfaces can be attached to primaries
68 * -> primaries can be attached to offscreen plain surfaces
69 * -> z buffers can be attached to primaries
72 if(This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_OFFSCREENPLAIN) &&
73 Surf->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_OFFSCREENPLAIN))
75 /* Sizes have to match */
76 if(Surf->surface_desc.dwWidth != This->surface_desc.dwWidth ||
77 Surf->surface_desc.dwHeight != This->surface_desc.dwHeight)
79 WARN("Surface sizes do not match\n");
80 return DDERR_CANNOTATTACHSURFACE;
84 else if(This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE) &&
85 Surf->surface_desc.ddsCaps.dwCaps & (DDSCAPS_ZBUFFER))
91 WARN("Invalid attachment combination\n");
92 return DDERR_CANNOTATTACHSURFACE;
95 return IDirectDrawSurfaceImpl_AddAttachedSurface(This,
100 IDirectDrawSurface3Impl_AddOverlayDirtyRect(LPDIRECTDRAWSURFACE3 This,
103 return IDirectDrawSurface7_AddOverlayDirtyRect((IDirectDrawSurface7 *)surface_from_surface3(This), pRect);
106 static HRESULT WINAPI
107 IDirectDrawSurface3Impl_Blt(LPDIRECTDRAWSURFACE3 This, LPRECT prcDst,
108 LPDIRECTDRAWSURFACE3 pSrcSurf, LPRECT prcSrc,
109 DWORD dwFlags, LPDDBLTFX pFX)
111 return IDirectDrawSurface7_Blt((IDirectDrawSurface7 *)surface_from_surface3(This), prcDst,
112 pSrcSurf ? (IDirectDrawSurface7 *)surface_from_surface3(pSrcSurf) : NULL, prcSrc, dwFlags, pFX);
115 static HRESULT WINAPI
116 IDirectDrawSurface3Impl_BltBatch(LPDIRECTDRAWSURFACE3 This,
117 LPDDBLTBATCH pBatch, DWORD dwCount,
120 return IDirectDrawSurface7_BltBatch((IDirectDrawSurface7 *)surface_from_surface3(This), pBatch, dwCount, dwFlags);
123 static HRESULT WINAPI
124 IDirectDrawSurface3Impl_BltFast(LPDIRECTDRAWSURFACE3 This, DWORD x, DWORD y,
125 LPDIRECTDRAWSURFACE3 pSrcSurf, LPRECT prcSrc,
128 return IDirectDrawSurface7_BltFast((IDirectDrawSurface7 *)surface_from_surface3(This), x, y,
129 pSrcSurf ? (IDirectDrawSurface7 *)surface_from_surface3(pSrcSurf) : NULL, prcSrc, dwTrans);
132 static HRESULT WINAPI
133 IDirectDrawSurface3Impl_DeleteAttachedSurface(LPDIRECTDRAWSURFACE3 This,
135 LPDIRECTDRAWSURFACE3 pAttached)
137 return IDirectDrawSurface7_DeleteAttachedSurface((IDirectDrawSurface7 *)surface_from_surface3(This), dwFlags,
138 pAttached ? (IDirectDrawSurface7 *)surface_from_surface3(pAttached) : NULL);
143 LPDDENUMSURFACESCALLBACK callback;
147 static HRESULT CALLBACK
148 EnumCallback(LPDIRECTDRAWSURFACE7 iface, LPDDSURFACEDESC2 pDDSD,
151 const struct callback_info* info = context;
154 /* This is an outgoing conversion so we have to do it. */
156 memset(&ddsd, 0, sizeof(ddsd));
157 ddsd.dwSize = sizeof(ddsd);
158 DDRAW_Convert_DDSURFACEDESC_2_To_1(pDDSD, &ddsd);
161 /* the LPDDSURFACEDESC2 -> LPDDSURFACEDESC coercion is safe, since
162 * the data format is compatible with older enum procs */
163 return info->callback(iface ?
164 (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)iface)->IDirectDrawSurface3_vtbl : NULL,
165 (LPDDSURFACEDESC)pDDSD, info->context);
168 static HRESULT WINAPI
169 IDirectDrawSurface3Impl_EnumAttachedSurfaces(LPDIRECTDRAWSURFACE3 This,
171 LPDDENUMSURFACESCALLBACK callback)
173 struct callback_info info;
175 info.callback = callback;
176 info.context = context;
178 return IDirectDrawSurface7_EnumAttachedSurfaces((IDirectDrawSurface7 *)surface_from_surface3(This),
179 &info, EnumCallback);
182 static HRESULT WINAPI
183 IDirectDrawSurface3Impl_EnumOverlayZOrders(LPDIRECTDRAWSURFACE3 This,
184 DWORD dwFlags, LPVOID context,
185 LPDDENUMSURFACESCALLBACK callback)
187 struct callback_info info;
189 info.callback = callback;
190 info.context = context;
192 return IDirectDrawSurface7_EnumOverlayZOrders((IDirectDrawSurface7 *)surface_from_surface3(This),
193 dwFlags, &info, EnumCallback);
196 static HRESULT WINAPI
197 IDirectDrawSurface3Impl_Flip(LPDIRECTDRAWSURFACE3 This,
198 LPDIRECTDRAWSURFACE3 pOverride, DWORD dwFlags)
200 return IDirectDrawSurface7_Flip((IDirectDrawSurface7 *)surface_from_surface3(This),
201 pOverride ? (IDirectDrawSurface7 *)surface_from_surface3(pOverride) : NULL, dwFlags);
204 static HRESULT WINAPI
205 IDirectDrawSurface3Impl_GetAttachedSurface(LPDIRECTDRAWSURFACE3 This,
207 LPDIRECTDRAWSURFACE3* ppAttached)
210 LPDIRECTDRAWSURFACE7 pAttached7;
213 caps.dwCaps = pCaps->dwCaps;
218 hr = IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)surface_from_surface3(This), &caps, &pAttached7);
219 if (FAILED(hr)) *ppAttached = NULL;
220 else *ppAttached = pAttached7 ?
221 (IDirectDrawSurface3 *)&((IDirectDrawSurfaceImpl *)pAttached7)->IDirectDrawSurface3_vtbl : NULL;
225 static HRESULT WINAPI
226 IDirectDrawSurface3Impl_GetBltStatus(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
228 return IDirectDrawSurface7_GetBltStatus((IDirectDrawSurface7 *)surface_from_surface3(This), dwFlags);
231 static HRESULT WINAPI
232 IDirectDrawSurface3Impl_GetCaps(LPDIRECTDRAWSURFACE3 This, LPDDSCAPS pCaps)
237 hr = IDirectDrawSurface7_GetCaps((IDirectDrawSurface7 *)surface_from_surface3(This), &caps);
238 if (FAILED(hr)) return hr;
240 pCaps->dwCaps = caps.dwCaps;
244 static HRESULT WINAPI
245 IDirectDrawSurface3Impl_GetClipper(LPDIRECTDRAWSURFACE3 This,
246 LPDIRECTDRAWCLIPPER* ppClipper)
248 return IDirectDrawSurface7_GetClipper((IDirectDrawSurface7 *)surface_from_surface3(This), ppClipper);
251 static HRESULT WINAPI
252 IDirectDrawSurface3Impl_GetColorKey(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags,
255 return IDirectDrawSurface7_GetColorKey((IDirectDrawSurface7 *)surface_from_surface3(This), dwFlags, pCKey);
258 static HRESULT WINAPI
259 IDirectDrawSurface3Impl_GetDC(LPDIRECTDRAWSURFACE3 This, HDC* phDC)
261 return IDirectDrawSurface7_GetDC((IDirectDrawSurface7 *)surface_from_surface3(This), phDC);
264 static HRESULT WINAPI
265 IDirectDrawSurface3Impl_GetFlipStatus(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
267 return IDirectDrawSurface7_GetFlipStatus((IDirectDrawSurface7 *)surface_from_surface3(This), dwFlags);
270 static HRESULT WINAPI
271 IDirectDrawSurface3Impl_GetOverlayPosition(LPDIRECTDRAWSURFACE3 This, LPLONG pX,
274 return IDirectDrawSurface7_GetOverlayPosition((IDirectDrawSurface7 *)surface_from_surface3(This), pX, pY);
277 static HRESULT WINAPI
278 IDirectDrawSurface3Impl_GetPalette(LPDIRECTDRAWSURFACE3 This,
279 LPDIRECTDRAWPALETTE* ppPalette)
281 return IDirectDrawSurface7_GetPalette((IDirectDrawSurface7 *)surface_from_surface3(This), ppPalette);
284 static HRESULT WINAPI
285 IDirectDrawSurface3Impl_GetPixelFormat(LPDIRECTDRAWSURFACE3 This,
286 LPDDPIXELFORMAT pPixelFormat)
288 return IDirectDrawSurface7_GetPixelFormat((IDirectDrawSurface7 *)surface_from_surface3(This), pPixelFormat);
291 static HRESULT WINAPI
292 IDirectDrawSurface3Impl_GetSurfaceDesc(LPDIRECTDRAWSURFACE3 iface,
293 LPDDSURFACEDESC pDDSD)
295 IDirectDrawSurfaceImpl *This = surface_from_surface3(iface);
297 TRACE_(ddraw)("(%p)->(%p)\n",This,pDDSD);
300 return DDERR_INVALIDPARAMS;
302 if (pDDSD->dwSize != sizeof(DDSURFACEDESC))
304 WARN("Incorrect struct size %d, returning DDERR_INVALIDPARAMS\n",pDDSD->dwSize);
305 return DDERR_INVALIDPARAMS;
308 EnterCriticalSection(&ddraw_cs);
309 DD_STRUCT_COPY_BYSIZE(pDDSD,(DDSURFACEDESC *) &This->surface_desc);
310 TRACE("Returning surface desc:\n");
313 /* DDRAW_dump_surface_desc handles the smaller size */
314 DDRAW_dump_surface_desc((DDSURFACEDESC2 *) pDDSD);
317 LeaveCriticalSection(&ddraw_cs);
321 static HRESULT WINAPI
322 IDirectDrawSurface3Impl_Initialize(LPDIRECTDRAWSURFACE3 This, LPDIRECTDRAW pDD,
323 LPDDSURFACEDESC pDDSD)
325 return IDirectDrawSurface7_Initialize((IDirectDrawSurface7 *)surface_from_surface3(This),
326 pDD, (LPDDSURFACEDESC2)pDDSD);
329 static HRESULT WINAPI
330 IDirectDrawSurface3Impl_IsLost(LPDIRECTDRAWSURFACE3 This)
332 return IDirectDrawSurface7_IsLost((IDirectDrawSurface7 *)surface_from_surface3(This));
335 static HRESULT WINAPI
336 IDirectDrawSurface3Impl_Lock(LPDIRECTDRAWSURFACE3 This, LPRECT pRect,
337 LPDDSURFACEDESC pDDSD, DWORD dwFlags, HANDLE h)
339 return IDirectDrawSurface7_Lock((IDirectDrawSurface7 *)surface_from_surface3(This),
340 pRect, (LPDDSURFACEDESC2)pDDSD, dwFlags, h);
343 static HRESULT WINAPI
344 IDirectDrawSurface3Impl_ReleaseDC(LPDIRECTDRAWSURFACE3 This, HDC hDC)
346 return IDirectDrawSurface7_ReleaseDC((IDirectDrawSurface7 *)surface_from_surface3(This), hDC);
349 static HRESULT WINAPI
350 IDirectDrawSurface3Impl_Restore(LPDIRECTDRAWSURFACE3 This)
352 return IDirectDrawSurface7_Restore((IDirectDrawSurface7 *)surface_from_surface3(This));
355 static HRESULT WINAPI
356 IDirectDrawSurface3Impl_SetClipper(LPDIRECTDRAWSURFACE3 This,
357 LPDIRECTDRAWCLIPPER pClipper)
359 return IDirectDrawSurface7_SetClipper((IDirectDrawSurface7 *)surface_from_surface3(This), pClipper);
362 static HRESULT WINAPI
363 IDirectDrawSurface3Impl_SetColorKey(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags,
366 return IDirectDrawSurface7_SetColorKey((IDirectDrawSurface7 *)surface_from_surface3(This), dwFlags, pCKey);
369 static HRESULT WINAPI
370 IDirectDrawSurface3Impl_SetOverlayPosition(LPDIRECTDRAWSURFACE3 This, LONG x,
373 return IDirectDrawSurface7_SetOverlayPosition((IDirectDrawSurface7 *)surface_from_surface3(This), x, y);
376 static HRESULT WINAPI
377 IDirectDrawSurface3Impl_SetPalette(LPDIRECTDRAWSURFACE3 This,
378 LPDIRECTDRAWPALETTE pPalette)
380 return IDirectDrawSurface7_SetPalette((IDirectDrawSurface7 *)surface_from_surface3(This), pPalette);
383 static HRESULT WINAPI
384 IDirectDrawSurface3Impl_Unlock(LPDIRECTDRAWSURFACE3 This, LPVOID data)
386 /* data might not be the LPRECT of later versions, so drop it. */
387 return IDirectDrawSurface7_Unlock((IDirectDrawSurface7 *)surface_from_surface3(This), NULL);
390 static HRESULT WINAPI
391 IDirectDrawSurface3Impl_UpdateOverlay(LPDIRECTDRAWSURFACE3 This, LPRECT prcSrc,
392 LPDIRECTDRAWSURFACE3 pDstSurf,
393 LPRECT prcDst, DWORD dwFlags,
396 return IDirectDrawSurface7_UpdateOverlay((IDirectDrawSurface7 *)surface_from_surface3(This), prcSrc,
397 pDstSurf ? (IDirectDrawSurface7 *)surface_from_surface3(pDstSurf) : NULL, prcDst, dwFlags, pFX);
400 static HRESULT WINAPI
401 IDirectDrawSurface3Impl_UpdateOverlayDisplay(LPDIRECTDRAWSURFACE3 This,
404 return IDirectDrawSurface7_UpdateOverlayDisplay((IDirectDrawSurface7 *)surface_from_surface3(This), dwFlags);
407 static HRESULT WINAPI
408 IDirectDrawSurface3Impl_UpdateOverlayZOrder(LPDIRECTDRAWSURFACE3 This,
410 LPDIRECTDRAWSURFACE3 pSurfReference)
412 return IDirectDrawSurface7_UpdateOverlayZOrder((IDirectDrawSurface7 *)surface_from_surface3(This), dwFlags,
413 pSurfReference ? (IDirectDrawSurface7 *)surface_from_surface3(pSurfReference) : NULL);
416 static HRESULT WINAPI
417 IDirectDrawSurface3Impl_GetDDInterface(LPDIRECTDRAWSURFACE3 This, LPVOID* ppDD)
419 return IDirectDrawSurface7_GetDDInterface((IDirectDrawSurface7 *)surface_from_surface3(This), ppDD);
422 static HRESULT WINAPI
423 IDirectDrawSurface3Impl_PageLock(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
425 return IDirectDrawSurface7_PageLock((IDirectDrawSurface7 *)surface_from_surface3(This), dwFlags);
428 static HRESULT WINAPI
429 IDirectDrawSurface3Impl_PageUnlock(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
431 return IDirectDrawSurface7_PageUnlock((IDirectDrawSurface7 *)surface_from_surface3(This), dwFlags);
434 static HRESULT WINAPI
435 IDirectDrawSurface3Impl_SetSurfaceDesc(LPDIRECTDRAWSURFACE3 This,
436 LPDDSURFACEDESC pDDSD, DWORD dwFlags)
438 return IDirectDrawSurface7_SetSurfaceDesc((IDirectDrawSurface7 *)surface_from_surface3(This),
439 (LPDDSURFACEDESC2)pDDSD, dwFlags);
442 const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl =
444 IDirectDrawSurface3Impl_QueryInterface,
445 IDirectDrawSurface3Impl_AddRef,
446 IDirectDrawSurface3Impl_Release,
447 IDirectDrawSurface3Impl_AddAttachedSurface,
448 IDirectDrawSurface3Impl_AddOverlayDirtyRect,
449 IDirectDrawSurface3Impl_Blt,
450 IDirectDrawSurface3Impl_BltBatch,
451 IDirectDrawSurface3Impl_BltFast,
452 IDirectDrawSurface3Impl_DeleteAttachedSurface,
453 IDirectDrawSurface3Impl_EnumAttachedSurfaces,
454 IDirectDrawSurface3Impl_EnumOverlayZOrders,
455 IDirectDrawSurface3Impl_Flip,
456 IDirectDrawSurface3Impl_GetAttachedSurface,
457 IDirectDrawSurface3Impl_GetBltStatus,
458 IDirectDrawSurface3Impl_GetCaps,
459 IDirectDrawSurface3Impl_GetClipper,
460 IDirectDrawSurface3Impl_GetColorKey,
461 IDirectDrawSurface3Impl_GetDC,
462 IDirectDrawSurface3Impl_GetFlipStatus,
463 IDirectDrawSurface3Impl_GetOverlayPosition,
464 IDirectDrawSurface3Impl_GetPalette,
465 IDirectDrawSurface3Impl_GetPixelFormat,
466 IDirectDrawSurface3Impl_GetSurfaceDesc,
467 IDirectDrawSurface3Impl_Initialize,
468 IDirectDrawSurface3Impl_IsLost,
469 IDirectDrawSurface3Impl_Lock,
470 IDirectDrawSurface3Impl_ReleaseDC,
471 IDirectDrawSurface3Impl_Restore,
472 IDirectDrawSurface3Impl_SetClipper,
473 IDirectDrawSurface3Impl_SetColorKey,
474 IDirectDrawSurface3Impl_SetOverlayPosition,
475 IDirectDrawSurface3Impl_SetPalette,
476 IDirectDrawSurface3Impl_Unlock,
477 IDirectDrawSurface3Impl_UpdateOverlay,
478 IDirectDrawSurface3Impl_UpdateOverlayDisplay,
479 IDirectDrawSurface3Impl_UpdateOverlayZOrder,
480 IDirectDrawSurface3Impl_GetDDInterface,
481 IDirectDrawSurface3Impl_PageLock,
482 IDirectDrawSurface3Impl_PageUnlock,
483 IDirectDrawSurface3Impl_SetSurfaceDesc