wined3d: Create fragment processing state templates and select one.
[wine.git] / dlls / ddraw / surface.c
bloba716149daa2631f7f479a8f04939cc28709ef058
1 /* DirectDraw Surface Implementation
3 * Copyright (c) 1997-2000 Marcus Meissner
4 * Copyright (c) 1998-2000 Lionel Ulmer
5 * Copyright (c) 2000-2001 TransGaming Technologies Inc.
6 * Copyright (c) 2006 Stefan Dösinger
8 * This file contains the (internal) driver registration functions,
9 * driver enumeration APIs and DirectDraw creation functions.
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "config.h"
27 #include "wine/port.h"
29 #include <assert.h>
30 #include <stdarg.h>
31 #include <string.h>
32 #include <stdlib.h>
34 #define COBJMACROS
35 #define NONAMELESSUNION
37 #include "windef.h"
38 #include "winbase.h"
39 #include "winerror.h"
40 #include "wingdi.h"
41 #include "wine/exception.h"
43 #include "ddraw.h"
44 #include "d3d.h"
46 #include "ddraw_private.h"
47 #include "wine/debug.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
51 /*****************************************************************************
52 * IUnknown parts follow
53 *****************************************************************************/
55 /*****************************************************************************
56 * IDirectDrawSurface7::QueryInterface
58 * A normal QueryInterface implementation. For QueryInterface rules
59 * see ddraw.c, IDirectDraw7::QueryInterface. This method
60 * can Query IDirectDrawSurface interfaces in all version, IDirect3DTexture
61 * in all versions, the IDirectDrawGammaControl interface and it can
62 * create an IDirect3DDevice. (Uses IDirect3D7::CreateDevice)
64 * Params:
65 * riid: The interface id queried for
66 * obj: Address to write the pointer to
68 * Returns:
69 * S_OK on success
70 * E_NOINTERFACE if the requested interface wasn't found
72 *****************************************************************************/
73 static HRESULT WINAPI
74 IDirectDrawSurfaceImpl_QueryInterface(IDirectDrawSurface7 *iface,
75 REFIID riid,
76 void **obj)
78 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
80 /* According to COM docs, if the QueryInterface fails, obj should be set to NULL */
81 *obj = NULL;
83 if(!riid)
84 return DDERR_INVALIDPARAMS;
86 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),obj);
87 if (IsEqualGUID(riid, &IID_IUnknown)
88 || IsEqualGUID(riid, &IID_IDirectDrawSurface7)
89 || IsEqualGUID(riid, &IID_IDirectDrawSurface4) )
91 IUnknown_AddRef(iface);
92 *obj = ICOM_INTERFACE(This, IDirectDrawSurface7);
93 TRACE("(%p) returning IDirectDrawSurface7 interface at %p\n", This, *obj);
94 return S_OK;
96 else if( IsEqualGUID(riid, &IID_IDirectDrawSurface3)
97 || IsEqualGUID(riid, &IID_IDirectDrawSurface2)
98 || IsEqualGUID(riid, &IID_IDirectDrawSurface) )
100 IUnknown_AddRef(iface);
101 *obj = ICOM_INTERFACE(This, IDirectDrawSurface3);
102 TRACE("(%p) returning IDirectDrawSurface3 interface at %p\n", This, *obj);
103 return S_OK;
105 else if( IsEqualGUID(riid, &IID_IDirectDrawGammaControl) )
107 IUnknown_AddRef(iface);
108 *obj = ICOM_INTERFACE(This, IDirectDrawGammaControl);
109 TRACE("(%p) returning IDirectDrawGammaControl interface at %p\n", This, *obj);
110 return S_OK;
112 else if( IsEqualGUID(riid, &IID_D3DDEVICE_WineD3D) ||
113 IsEqualGUID(riid, &IID_IDirect3DHALDevice)||
114 IsEqualGUID(riid, &IID_IDirect3DRGBDevice) )
116 IDirect3DDevice7 *d3d;
118 /* Call into IDirect3D7 for creation */
119 IDirect3D7_CreateDevice(ICOM_INTERFACE(This->ddraw, IDirect3D7),
120 riid,
121 ICOM_INTERFACE(This, IDirectDrawSurface7),
122 &d3d);
124 *obj = COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice7, IDirect3DDevice, d3d);
125 TRACE("(%p) Returning IDirect3DDevice interface at %p\n", This, *obj);
127 return S_OK;
129 else if (IsEqualGUID( &IID_IDirect3DTexture, riid ) ||
130 IsEqualGUID( &IID_IDirect3DTexture2, riid ))
132 if (IsEqualGUID( &IID_IDirect3DTexture, riid ))
134 *obj = ICOM_INTERFACE(This, IDirect3DTexture);
135 TRACE(" returning Direct3DTexture interface at %p.\n", *obj);
137 else
139 *obj = ICOM_INTERFACE(This, IDirect3DTexture2);
140 TRACE(" returning Direct3DTexture2 interface at %p.\n", *obj);
142 IUnknown_AddRef( (IUnknown *) *obj);
143 return S_OK;
146 ERR("No interface\n");
147 return E_NOINTERFACE;
150 /*****************************************************************************
151 * IDirectDrawSurface7::AddRef
153 * A normal addref implementation
155 * Returns:
156 * The new refcount
158 *****************************************************************************/
159 static ULONG WINAPI
160 IDirectDrawSurfaceImpl_AddRef(IDirectDrawSurface7 *iface)
162 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
163 ULONG refCount = InterlockedIncrement(&This->ref);
165 TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
166 return refCount;
169 /*****************************************************************************
170 * IDirectDrawSurfaceImpl_Destroy
172 * A helper function for IDirectDrawSurface7::Release
174 * Frees the surface, regardless of its refcount.
175 * See IDirectDrawSurface7::Release for more information
177 * Params:
178 * This: Surface to free
180 *****************************************************************************/
181 void IDirectDrawSurfaceImpl_Destroy(IDirectDrawSurfaceImpl *This)
183 TRACE("(%p)\n", This);
185 /* Check the refcount and give a warning */
186 if(This->ref > 1)
188 /* This can happen when a complex surface is destroyed,
189 * because the 2nd surface was addref()ed when the app
190 * called GetAttachedSurface
192 WARN("(%p): Destroying surface with refount %d\n", This, This->ref);
195 /* Check for attached surfaces and detach them */
196 if(This->first_attached != This)
198 /* Well, this shouldn't happen: The surface being attached is addref()ed
199 * in AddAttachedSurface, so it shouldn't be released until DeleteAttachedSurface
200 * is called, because the refcount is held. It looks like the app released()
201 * it often enough to force this
203 IDirectDrawSurface7 *root = ICOM_INTERFACE(This->first_attached, IDirectDrawSurface7);
204 IDirectDrawSurface7 *detach = ICOM_INTERFACE(This, IDirectDrawSurface7);
206 FIXME("(%p) Freeing a surface that is attached to surface %p\n", This, This->first_attached);
208 /* The refcount will drop to -1 here */
209 if(IDirectDrawSurface7_DeleteAttachedSurface(root, 0, detach) != DD_OK)
211 ERR("(%p) DeleteAttachedSurface failed!\n", This);
215 while(This->next_attached != NULL)
217 IDirectDrawSurface7 *root = ICOM_INTERFACE(This, IDirectDrawSurface7);
218 IDirectDrawSurface7 *detach = ICOM_INTERFACE(This->next_attached, IDirectDrawSurface7);
220 if(IDirectDrawSurface7_DeleteAttachedSurface(root, 0, detach) != DD_OK)
222 ERR("(%p) DeleteAttachedSurface failed!\n", This);
223 assert(0);
227 /* Now destroy the surface. Wait: It could have been released if we are a texture */
228 if(This->WineD3DSurface)
229 IWineD3DSurface_Release(This->WineD3DSurface);
231 /* Having a texture handle set implies that the device still exists */
232 if(This->Handle)
234 This->ddraw->d3ddevice->Handles[This->Handle - 1].ptr = NULL;
235 This->ddraw->d3ddevice->Handles[This->Handle - 1].type = DDrawHandle_Unknown;
238 /* Reduce the ddraw surface count */
239 InterlockedDecrement(&This->ddraw->surfaces);
240 list_remove(&This->surface_list_entry);
242 HeapFree(GetProcessHeap(), 0, This);
245 /*****************************************************************************
246 * IDirectDrawSurface7::Release
248 * Reduces the surface's refcount by 1. If the refcount falls to 0, the
249 * surface is destroyed.
251 * Destroying the surface is a bit tricky. For the connection between
252 * WineD3DSurfaces and DirectDrawSurfaces see IDirectDraw7::CreateSurface
253 * It has a nice graph explaining the connection.
255 * What happens here is basically this:
256 * When a surface is destroyed, its WineD3DSurface is released,
257 * and the refcount of the DirectDraw interface is reduced by 1. If it has
258 * complex surfaces attached to it, then these surfaces are destroyed too,
259 * regardless of their refcount. If any surface being destroyed has another
260 * surface attached to it (with a "soft" attachment, not complex), then
261 * this surface is detached with DeleteAttachedSurface.
263 * When the surface is a texture, the WineD3DTexture is released.
264 * If the surface is the Direct3D render target, then the D3D
265 * capabilities of the WineD3DDevice are uninitialized, which causes the
266 * swapchain to be released.
268 * When a complex sublevel falls to ref zero, then this is ignored.
270 * Returns:
271 * The new refcount
273 *****************************************************************************/
274 static ULONG WINAPI
275 IDirectDrawSurfaceImpl_Release(IDirectDrawSurface7 *iface)
277 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
278 ULONG ref;
279 TRACE("(%p) : Releasing from %d\n", This, This->ref);
280 ref = InterlockedDecrement(&This->ref);
282 if (ref == 0)
285 IDirectDrawSurfaceImpl *surf;
286 IDirectDrawImpl *ddraw;
287 IUnknown *ifaceToRelease = This->ifaceToRelease;
288 int i;
290 /* Complex attached surfaces are destroyed implicitly when the root is released */
291 EnterCriticalSection(&ddraw_cs);
292 if(!This->is_complex_root)
294 WARN("(%p) Attempt to destroy a surface that is not a complex root\n", This);
295 LeaveCriticalSection(&ddraw_cs);
296 return ref;
298 ddraw = This->ddraw;
300 /* If it's a texture, destroy the WineD3DTexture.
301 * WineD3D will destroy the IParent interfaces
302 * of the sublevels, which destroys the WineD3DSurfaces.
303 * Set the surfaces to NULL to avoid destroying them again later
305 if(This->wineD3DTexture)
307 IWineD3DBaseTexture_Release(This->wineD3DTexture);
309 /* If it's the RenderTarget, destroy the d3ddevice */
310 else if( (ddraw->d3d_initialized) && (This == ddraw->d3d_target))
312 TRACE("(%p) Destroying the render target, uninitializing D3D\n", This);
314 /* Unset any index buffer, just to be sure */
315 IWineD3DDevice_SetIndices(ddraw->wineD3DDevice, NULL);
316 IWineD3DDevice_SetDepthStencilSurface(ddraw->wineD3DDevice, NULL);
317 IWineD3DDevice_SetVertexDeclaration(ddraw->wineD3DDevice, NULL);
318 for(i = 0; i < ddraw->numConvertedDecls; i++)
320 IWineD3DVertexDeclaration_Release(ddraw->decls[i].decl);
322 HeapFree(GetProcessHeap(), 0, ddraw->decls);
323 ddraw->numConvertedDecls = 0;
325 if(IWineD3DDevice_Uninit3D(ddraw->wineD3DDevice, D3D7CB_DestroyDepthStencilSurface, D3D7CB_DestroySwapChain) != D3D_OK)
327 /* Not good */
328 ERR("(%p) Failed to uninit 3D\n", This);
330 else
332 /* Free the d3d window if one was created */
333 if(ddraw->d3d_window != 0)
335 TRACE(" (%p) Destroying the hidden render window %p\n", This, ddraw->d3d_window);
336 DestroyWindow(ddraw->d3d_window);
337 ddraw->d3d_window = 0;
339 /* Unset the pointers */
342 ddraw->d3d_initialized = FALSE;
343 ddraw->d3d_target = NULL;
345 /* Reset to the default surface implementation type. This is needed if apps use
346 * non render target surfaces and expect blits to work after destroying the render
347 * target.
349 * TODO: Recreate existing offscreen surfaces
351 ddraw->ImplType = DefaultSurfaceType;
353 /* Write a trace because D3D unloading was the reason for many
354 * crashes during development.
356 TRACE("(%p) D3D unloaded\n", This);
358 else if(This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE |
359 DDSCAPS_3DDEVICE |
360 DDSCAPS_TEXTURE ) )
362 /* It's a render target, but no swapchain was created.
363 * The IParent interfaces have to be released manually.
364 * The same applies for textures without an
365 * IWineD3DTexture object attached
367 IParent *Parent;
369 for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
371 if(This->complex_array[i])
373 /* Only the topmost level can have more than 1 surfaces in the complex
374 * attachment array(Cube texture roots), for all others there is only
375 * one
377 surf = This->complex_array[i];
378 while(surf)
380 IWineD3DSurface_GetParent(surf->WineD3DSurface,
381 (IUnknown **) &Parent);
382 IParent_Release(Parent); /* For the getParent */
383 IParent_Release(Parent); /* To release it */
384 surf = surf->complex_array[0];
389 /* Now the top-level surface */
390 IWineD3DSurface_GetParent(This->WineD3DSurface,
391 (IUnknown **) &Parent);
392 IParent_Release(Parent); /* For the getParent */
393 IParent_Release(Parent); /* To release it */
396 /* The refcount test shows that the palette is detached when the surface is destroyed */
397 IDirectDrawSurface7_SetPalette(ICOM_INTERFACE(This, IDirectDrawSurface7),
398 NULL);
400 /* Loop through all complex attached surfaces,
401 * and destroy them.
403 * Yet again, only the root can have more than one complexly attached surface, all the others
404 * have a total of one;
406 for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
408 if(!This->complex_array[i]) break;
410 surf = This->complex_array[i];
411 This->complex_array[i] = NULL;
412 while(surf)
414 IDirectDrawSurfaceImpl *destroy = surf;
415 surf = surf->complex_array[0]; /* Iterate through the "tree" */
416 IDirectDrawSurfaceImpl_Destroy(destroy); /* Destroy it */
420 /* Destroy the root surface.
422 IDirectDrawSurfaceImpl_Destroy(This);
424 /* Reduce the ddraw refcount */
425 if(ifaceToRelease) IUnknown_Release(ifaceToRelease);
426 LeaveCriticalSection(&ddraw_cs);
429 return ref;
432 /*****************************************************************************
433 * IDirectDrawSurface7::GetAttachedSurface
435 * Returns an attached surface with the requested caps. Surface attachment
436 * and complex surfaces are not clearly described by the MSDN or sdk,
437 * so this method is tricky and likely to contain problems.
438 * This implementation searches the complex list first, then the
439 * attachment chain.
441 * The chains are searched from This down to the last surface in the chain,
442 * not from the first element in the chain. The first surface found is
443 * returned. The MSDN says that this method fails if more than one surface
444 * matches the caps, but it is not sure if that is right. The attachment
445 * structure may not even allow two matching surfaces.
447 * The found surface is AddRef-ed before it is returned.
449 * Params:
450 * Caps: Pointer to a DDCAPS2 structure describing the caps asked for
451 * Surface: Address to store the found surface
453 * Returns:
454 * DD_OK on success
455 * DDERR_INVALIDPARAMS if Caps or Surface is NULL
456 * DDERR_NOTFOUND if no surface was found
458 *****************************************************************************/
459 static HRESULT WINAPI
460 IDirectDrawSurfaceImpl_GetAttachedSurface(IDirectDrawSurface7 *iface,
461 DDSCAPS2 *Caps,
462 IDirectDrawSurface7 **Surface)
464 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
465 IDirectDrawSurfaceImpl *surf;
466 DDSCAPS2 our_caps;
467 int i;
469 TRACE("(%p)->(%p,%p)\n", This, Caps, Surface);
470 EnterCriticalSection(&ddraw_cs);
472 our_caps = *Caps;
474 if(This->version < 7)
476 /* Earlier dx apps put garbage into these members, clear them */
477 our_caps.dwCaps2 = 0;
478 our_caps.dwCaps3 = 0;
479 our_caps.dwCaps4 = 0;
482 TRACE("(%p): Looking for caps: %x,%x,%x,%x\n", This, our_caps.dwCaps, our_caps.dwCaps2, our_caps.dwCaps3, our_caps.dwCaps4); /* FIXME: Better debugging */
484 for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
486 surf = This->complex_array[i];
487 if(!surf) break;
489 if (TRACE_ON(ddraw))
491 TRACE("Surface: (%p) caps: %x,%x,%x,%x\n", surf,
492 surf->surface_desc.ddsCaps.dwCaps,
493 surf->surface_desc.ddsCaps.dwCaps2,
494 surf->surface_desc.ddsCaps.dwCaps3,
495 surf->surface_desc.ddsCaps.dwCaps4);
498 if (((surf->surface_desc.ddsCaps.dwCaps & our_caps.dwCaps) == our_caps.dwCaps) &&
499 ((surf->surface_desc.ddsCaps.dwCaps2 & our_caps.dwCaps2) == our_caps.dwCaps2)) {
501 /* MSDN: "This method fails if more than one surface is attached
502 * that matches the capabilities requested."
504 * Not sure how to test this.
507 TRACE("(%p): Returning surface %p\n", This, surf);
508 TRACE("(%p): mipmapcount=%d\n", This, surf->mipmap_level);
509 *Surface = ICOM_INTERFACE(surf, IDirectDrawSurface7);
510 IDirectDrawSurface7_AddRef(*Surface);
511 LeaveCriticalSection(&ddraw_cs);
512 return DD_OK;
516 /* Next, look at the attachment chain */
517 surf = This;
519 while( (surf = surf->next_attached) )
521 if (TRACE_ON(ddraw))
523 TRACE("Surface: (%p) caps: %x,%x,%x,%x\n", surf,
524 surf->surface_desc.ddsCaps.dwCaps,
525 surf->surface_desc.ddsCaps.dwCaps2,
526 surf->surface_desc.ddsCaps.dwCaps3,
527 surf->surface_desc.ddsCaps.dwCaps4);
530 if (((surf->surface_desc.ddsCaps.dwCaps & our_caps.dwCaps) == our_caps.dwCaps) &&
531 ((surf->surface_desc.ddsCaps.dwCaps2 & our_caps.dwCaps2) == our_caps.dwCaps2)) {
533 TRACE("(%p): Returning surface %p\n", This, surf);
534 *Surface = ICOM_INTERFACE(surf, IDirectDrawSurface7);
535 IDirectDrawSurface7_AddRef(*Surface);
536 LeaveCriticalSection(&ddraw_cs);
537 return DD_OK;
541 TRACE("(%p) Didn't find a valid surface\n", This);
542 LeaveCriticalSection(&ddraw_cs);
544 *Surface = NULL;
545 return DDERR_NOTFOUND;
548 /*****************************************************************************
549 * IDirectDrawSurface7::Lock
551 * Locks the surface and returns a pointer to the surface's memory
553 * Params:
554 * Rect: Rectangle to lock. If NULL, the whole surface is locked
555 * DDSD: Pointer to a DDSURFACEDESC2 which shall receive the surface's desc.
556 * Flags: Locking flags, e.g Read only or write only
557 * h: An event handle that's not used and must be NULL
559 * Returns:
560 * DD_OK on success
561 * DDERR_INVALIDPARAMS if DDSD is NULL
562 * For more details, see IWineD3DSurface::LockRect
564 *****************************************************************************/
565 static HRESULT WINAPI
566 IDirectDrawSurfaceImpl_Lock(IDirectDrawSurface7 *iface,
567 RECT *Rect,
568 DDSURFACEDESC2 *DDSD,
569 DWORD Flags,
570 HANDLE h)
572 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
573 WINED3DLOCKED_RECT LockedRect;
574 HRESULT hr;
575 TRACE("(%p)->(%p,%p,%x,%p)\n", This, Rect, DDSD, Flags, h);
577 if(!DDSD)
578 return DDERR_INVALIDPARAMS;
580 /* This->surface_desc.dwWidth and dwHeight are changeable, thus lock */
581 EnterCriticalSection(&ddraw_cs);
583 /* Should I check for the handle to be NULL?
585 * The DDLOCK flags and the D3DLOCK flags are equal
586 * for the supported values. The others are ignored by WineD3D
589 if(DDSD->dwSize != sizeof(DDSURFACEDESC) &&
590 DDSD->dwSize != sizeof(DDSURFACEDESC2))
592 WARN("Invalid structure size %d, returning DDERR_INVALIDPARAMS\n", DDERR_INVALIDPARAMS);
593 LeaveCriticalSection(&ddraw_cs);
594 return DDERR_INVALIDPARAMS;
597 /* Windows zeroes this if the rect is invalid */
598 DDSD->lpSurface = 0;
600 if (Rect)
602 if ((Rect->left < 0)
603 || (Rect->top < 0)
604 || (Rect->left > Rect->right)
605 || (Rect->top > Rect->bottom)
606 || (Rect->right > This->surface_desc.dwWidth)
607 || (Rect->bottom > This->surface_desc.dwHeight))
609 WARN("Trying to lock an invalid rectangle, returning DDERR_INVALIDPARAMS\n");
610 LeaveCriticalSection(&ddraw_cs);
611 return DDERR_INVALIDPARAMS;
615 hr = IWineD3DSurface_LockRect(This->WineD3DSurface,
616 &LockedRect,
617 Rect,
618 Flags);
619 if(hr != D3D_OK)
621 LeaveCriticalSection(&ddraw_cs);
622 switch(hr)
624 /* D3D8 and D3D9 return the general D3DERR_INVALIDCALL error, but ddraw has a more
625 * specific error. But since IWineD3DSurface::LockRect returns that error in this
626 * only occasion, keep d3d8 and d3d9 free from the return value override. There are
627 * many different places where d3d8/9 would have to catch the DDERR_SURFACEBUSY, it
628 * is much easier to do it in one place in ddraw
630 case WINED3DERR_INVALIDCALL: return DDERR_SURFACEBUSY;
631 default: return hr;
635 /* Override the memory area. The pitch should be set already. Strangely windows
636 * does not set the LPSURFACE flag on locked surfaces !?!.
637 * DDSD->dwFlags |= DDSD_LPSURFACE;
639 This->surface_desc.lpSurface = LockedRect.pBits;
640 DD_STRUCT_COPY_BYSIZE(DDSD,&(This->surface_desc));
642 TRACE("locked surface returning description :\n");
643 if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD);
645 LeaveCriticalSection(&ddraw_cs);
646 return DD_OK;
649 /*****************************************************************************
650 * IDirectDrawSurface7::Unlock
652 * Unlocks an locked surface
654 * Params:
655 * Rect: Not used by this implementation
657 * Returns:
658 * D3D_OK on success
659 * For more details, see IWineD3DSurface::UnlockRect
661 *****************************************************************************/
662 static HRESULT WINAPI
663 IDirectDrawSurfaceImpl_Unlock(IDirectDrawSurface7 *iface,
664 RECT *pRect)
666 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
667 HRESULT hr;
668 TRACE("(%p)->(%p)\n", This, pRect);
670 EnterCriticalSection(&ddraw_cs);
671 hr = IWineD3DSurface_UnlockRect(This->WineD3DSurface);
672 if(SUCCEEDED(hr))
674 This->surface_desc.lpSurface = NULL;
676 LeaveCriticalSection(&ddraw_cs);
677 return hr;
680 /*****************************************************************************
681 * IDirectDrawSurface7::Flip
683 * Flips a surface with the DDSCAPS_FLIP flag. The flip is relayed to
684 * IWineD3DSurface::Flip. Because WineD3D doesn't handle attached surfaces,
685 * the flip target is passed to WineD3D, even if the app didn't specify one
687 * Params:
688 * DestOverride: Specifies the surface that will become the new front
689 * buffer. If NULL, the current back buffer is used
690 * Flags: some DirectDraw flags, see include/ddraw.h
692 * Returns:
693 * DD_OK on success
694 * DDERR_NOTFLIPPABLE if no flip target could be found
695 * DDERR_INVALIDOBJECT if the surface isn't a front buffer
696 * For more details, see IWineD3DSurface::Flip
698 *****************************************************************************/
699 static HRESULT WINAPI
700 IDirectDrawSurfaceImpl_Flip(IDirectDrawSurface7 *iface,
701 IDirectDrawSurface7 *DestOverride,
702 DWORD Flags)
704 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
705 IDirectDrawSurfaceImpl *Override = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DestOverride);
706 IDirectDrawSurface7 *Override7;
707 HRESULT hr;
708 TRACE("(%p)->(%p,%x)\n", This, DestOverride, Flags);
710 /* Flip has to be called from a front buffer
711 * What about overlay surfaces, AFAIK they can flip too?
713 if( !(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER) )
714 return DDERR_INVALIDOBJECT; /* Unchecked */
716 EnterCriticalSection(&ddraw_cs);
718 /* WineD3D doesn't keep track of attached surface, so find the target */
719 if(!Override)
721 DDSCAPS2 Caps;
723 memset(&Caps, 0, sizeof(Caps));
724 Caps.dwCaps |= DDSCAPS_BACKBUFFER;
725 hr = IDirectDrawSurface7_GetAttachedSurface(iface, &Caps, &Override7);
726 if(hr != DD_OK)
728 ERR("Can't find a flip target\n");
729 LeaveCriticalSection(&ddraw_cs);
730 return DDERR_NOTFLIPPABLE; /* Unchecked */
732 Override = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Override7);
734 /* For the GetAttachedSurface */
735 IDirectDrawSurface7_Release(Override7);
738 hr = IWineD3DSurface_Flip(This->WineD3DSurface,
739 Override->WineD3DSurface,
740 Flags);
741 LeaveCriticalSection(&ddraw_cs);
742 return hr;
745 /*****************************************************************************
746 * IDirectDrawSurface7::Blt
748 * Performs a blit on the surface
750 * Params:
751 * DestRect: Destination rectangle, can be NULL
752 * SrcSurface: Source surface, can be NULL
753 * SrcRect: Source rectangle, can be NULL
754 * Flags: Blt flags
755 * DDBltFx: Some extended blt parameters, connected to the flags
757 * Returns:
758 * D3D_OK on success
759 * See IWineD3DSurface::Blt for more details
761 *****************************************************************************/
762 static HRESULT WINAPI
763 IDirectDrawSurfaceImpl_Blt(IDirectDrawSurface7 *iface,
764 RECT *DestRect,
765 IDirectDrawSurface7 *SrcSurface,
766 RECT *SrcRect,
767 DWORD Flags,
768 DDBLTFX *DDBltFx)
770 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
771 HRESULT hr;
772 IDirectDrawSurfaceImpl *Src = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, SrcSurface);
773 TRACE("(%p)->(%p,%p,%p,%x,%p)\n", This, DestRect, Src, SrcRect, Flags, DDBltFx);
775 /* Check for validity of the flags here. WineD3D Has the software-opengl selection path and would have
776 * to check at 2 places, and sometimes do double checks. This also saves the call to wined3d :-)
778 if((Flags & DDBLT_KEYSRCOVERRIDE) && (!DDBltFx || Flags & DDBLT_KEYSRC)) {
779 WARN("Invalid source color key parameters, returning DDERR_INVALIDPARAMS\n");
780 return DDERR_INVALIDPARAMS;
783 if((Flags & DDBLT_KEYDESTOVERRIDE) && (!DDBltFx || Flags & DDBLT_KEYDEST)) {
784 WARN("Invalid destination color key parameters, returning DDERR_INVALIDPARAMS\n");
785 return DDERR_INVALIDPARAMS;
788 /* Sizes can change, therefore hold the lock when testing the rectangles */
789 EnterCriticalSection(&ddraw_cs);
790 if(DestRect)
792 if(DestRect->top >= DestRect->bottom || DestRect->left >= DestRect->right ||
793 DestRect->right > This->surface_desc.dwWidth ||
794 DestRect->bottom > This->surface_desc.dwHeight)
796 WARN("Destination rectangle is invalid, returning DDERR_INVALIDRECT\n");
797 LeaveCriticalSection(&ddraw_cs);
798 return DDERR_INVALIDRECT;
801 if(Src && SrcRect)
803 if(SrcRect->top >= SrcRect->bottom || SrcRect->left >=SrcRect->right ||
804 SrcRect->right > Src->surface_desc.dwWidth ||
805 SrcRect->bottom > Src->surface_desc.dwHeight)
807 WARN("Source rectangle is invalid, returning DDERR_INVALIDRECT\n");
808 LeaveCriticalSection(&ddraw_cs);
809 return DDERR_INVALIDRECT;
813 if(Flags & DDBLT_KEYSRC && (!Src || !(Src->surface_desc.dwFlags & DDSD_CKSRCBLT))) {
814 WARN("DDBLT_KEYDEST blit without color key in surface, returning DDERR_INVALIDPARAMS\n");
815 LeaveCriticalSection(&ddraw_cs);
816 return DDERR_INVALIDPARAMS;
819 /* TODO: Check if the DDBltFx contains any ddraw surface pointers. If it does, copy the struct,
820 * and replace the ddraw surfaces with the wined3d surfaces
821 * So far no blitting operations using surfaces in the bltfx struct are supported anyway.
823 hr = IWineD3DSurface_Blt(This->WineD3DSurface,
824 DestRect,
825 Src ? Src->WineD3DSurface : NULL,
826 SrcRect,
827 Flags,
828 (WINEDDBLTFX *) DDBltFx,
829 WINED3DTEXF_POINT);
831 LeaveCriticalSection(&ddraw_cs);
832 switch(hr)
834 case WINED3DERR_NOTAVAILABLE: return DDERR_UNSUPPORTED;
835 case WINED3DERR_WRONGTEXTUREFORMAT: return DDERR_INVALIDPIXELFORMAT;
836 default: return hr;
840 /*****************************************************************************
841 * IDirectDrawSurface7::AddAttachedSurface
843 * Attaches a surface to another surface. How the surface attachments work
844 * is not totally understood yet, and this method is prone to problems.
845 * he surface that is attached is AddRef-ed.
847 * Tests with complex surfaces suggest that the surface attachments form a
848 * tree, but no method to test this has been found yet.
850 * The attachment list consists of a first surface (first_attached) and
851 * for each surface a pointer to the next attached surface (next_attached).
852 * For the first surface, and a surface that has no attachments
853 * first_attached points to the surface itself. A surface that has
854 * no successors in the chain has next_attached set to NULL.
856 * Newly attached surfaces are attached right after the root surface.
857 * If a surface is attached to a complex surface compound, it's attached to
858 * the surface that the app requested, not the complex root. See
859 * GetAttachedSurface for a description how surfaces are found.
861 * This is how the current implementation works, and it was coded by looking
862 * at the needs of the applications.
864 * So far only Z-Buffer attachments are tested, and they are activated in
865 * WineD3D. Mipmaps could be tricky to activate in WineD3D.
866 * Back buffers should work in 2D mode, but they are not tested(They can be
867 * attached in older iface versions). Rendering to the front buffer and
868 * switching between that and double buffering is not yet implemented in
869 * WineD3D, so for 3D it might have unexpected results.
871 * IDirectDrawSurfaceImpl_AddAttachedSurface is the real thing,
872 * IDirectDrawSurface7Impl_AddAttachedSurface is a wrapper around it that
873 * performs additional checks. Version 7 of this interface is much more restrictive
874 * than its predecessors.
876 * Params:
877 * Attach: Surface to attach to iface
879 * Returns:
880 * DD_OK on success
881 * DDERR_CANNOTATTACHSURFACE if the surface can't be attached for some reason
883 *****************************************************************************/
884 HRESULT WINAPI
885 IDirectDrawSurfaceImpl_AddAttachedSurface(IDirectDrawSurfaceImpl *This,
886 IDirectDrawSurfaceImpl *Surf)
888 TRACE("(%p)->(%p)\n", This, Surf);
890 if(Surf == This)
891 return DDERR_CANNOTATTACHSURFACE; /* unchecked */
893 EnterCriticalSection(&ddraw_cs);
895 /* Check if the surface is already attached somewhere */
896 if( (Surf->next_attached != NULL) ||
897 (Surf->first_attached != Surf) )
899 /* TODO: Test for the structure of the manual attachment. Is it a chain or a list?
900 * What happens if one surface is attached to 2 different surfaces?
902 FIXME("(%p) The Surface %p is already attached somewhere else: next_attached = %p, first_attached = %p, can't handle by now\n", This, Surf, Surf->next_attached, Surf->first_attached);
903 LeaveCriticalSection(&ddraw_cs);
904 return DDERR_SURFACEALREADYATTACHED;
907 /* This inserts the new surface at the 2nd position in the chain, right after the root surface */
908 Surf->next_attached = This->next_attached;
909 Surf->first_attached = This->first_attached;
910 This->next_attached = Surf;
912 /* Check if the WineD3D depth stencil needs updating */
913 if(This->ddraw->d3ddevice)
915 IDirect3DDeviceImpl_UpdateDepthStencil(This->ddraw->d3ddevice);
918 /* MSDN:
919 * "This method increments the reference count of the surface being attached."
921 IDirectDrawSurface7_AddRef(ICOM_INTERFACE(Surf, IDirectDrawSurface7));
922 LeaveCriticalSection(&ddraw_cs);
923 return DD_OK;
926 static HRESULT WINAPI
927 IDirectDrawSurface7Impl_AddAttachedSurface(IDirectDrawSurface7 *iface,
928 IDirectDrawSurface7 *Attach)
930 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
931 IDirectDrawSurfaceImpl *Surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Attach);
933 /* Version 7 of this interface seems to refuse everything except z buffers, as per msdn */
934 if(!(Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
937 WARN("Application tries to attach a non Z buffer surface. caps %08x\n",
938 Surf->surface_desc.ddsCaps.dwCaps);
939 return DDERR_CANNOTATTACHSURFACE;
942 return IDirectDrawSurfaceImpl_AddAttachedSurface(This,
943 Surf);
945 /*****************************************************************************
946 * IDirectDrawSurface7::DeleteAttachedSurface
948 * Removes a surface from the attachment chain. The surface's refcount
949 * is decreased by one after it has been removed
951 * Params:
952 * Flags: Some flags, not used by this implementation
953 * Attach: Surface to detach
955 * Returns:
956 * DD_OK on success
957 * DDERR_SURFACENOTATTACHED if the surface isn't attached to
959 *****************************************************************************/
960 static HRESULT WINAPI
961 IDirectDrawSurfaceImpl_DeleteAttachedSurface(IDirectDrawSurface7 *iface,
962 DWORD Flags,
963 IDirectDrawSurface7 *Attach)
965 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
966 IDirectDrawSurfaceImpl *Surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Attach);
967 IDirectDrawSurfaceImpl *Prev = This;
968 TRACE("(%p)->(%08x,%p)\n", This, Flags, Surf);
970 EnterCriticalSection(&ddraw_cs);
971 if (!Surf || (Surf->first_attached != This) || (Surf == This) )
973 LeaveCriticalSection(&ddraw_cs);
974 return DDERR_CANNOTDETACHSURFACE;
977 /* Remove MIPMAPSUBLEVEL if this seemed to be one */
978 if (This->surface_desc.ddsCaps.dwCaps &
979 Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
981 Surf->surface_desc.ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
982 /* FIXME: we should probably also subtract from dwMipMapCount of this
983 * and all parent surfaces */
986 /* Find the predecessor of the detached surface */
987 while(Prev)
989 if(Prev->next_attached == Surf) break;
990 Prev = Prev->next_attached;
993 /* There must be a surface, otherwise there's a bug */
994 assert(Prev != NULL);
996 /* Unchain the surface */
997 Prev->next_attached = Surf->next_attached;
998 Surf->next_attached = NULL;
999 Surf->first_attached = Surf;
1001 /* Check if the WineD3D depth stencil needs updating */
1002 if(This->ddraw->d3ddevice)
1004 IDirect3DDeviceImpl_UpdateDepthStencil(This->ddraw->d3ddevice);
1007 IDirectDrawSurface7_Release(Attach);
1008 LeaveCriticalSection(&ddraw_cs);
1009 return DD_OK;
1012 /*****************************************************************************
1013 * IDirectDrawSurface7::AddOverlayDirtyRect
1015 * "This method is not currently implemented"
1017 * Params:
1018 * Rect: ?
1020 * Returns:
1021 * DDERR_UNSUPPORTED
1023 *****************************************************************************/
1024 static HRESULT WINAPI
1025 IDirectDrawSurfaceImpl_AddOverlayDirtyRect(IDirectDrawSurface7 *iface,
1026 LPRECT Rect)
1028 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1029 TRACE("(%p)->(%p)\n",This,Rect);
1031 /* MSDN says it's not implemented. I could forward it to WineD3D,
1032 * then we'd implement it, but I don't think that's a good idea
1033 * (Stefan Dösinger)
1035 #if 0
1036 return IWineD3DSurface_AddOverlayDirtyRect(This->WineD3DSurface, pRect);
1037 #endif
1038 return DDERR_UNSUPPORTED; /* unchecked */
1041 /*****************************************************************************
1042 * IDirectDrawSurface7::GetDC
1044 * Returns a GDI device context for the surface
1046 * Params:
1047 * hdc: Address of a HDC variable to store the dc to
1049 * Returns:
1050 * DD_OK on success
1051 * DDERR_INVALIDPARAMS if hdc is NULL
1052 * For details, see IWineD3DSurface::GetDC
1054 *****************************************************************************/
1055 static HRESULT WINAPI
1056 IDirectDrawSurfaceImpl_GetDC(IDirectDrawSurface7 *iface,
1057 HDC *hdc)
1059 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1060 HRESULT hr;
1061 TRACE("(%p)->(%p): Relay\n", This, hdc);
1063 if(!hdc)
1064 return DDERR_INVALIDPARAMS;
1066 EnterCriticalSection(&ddraw_cs);
1067 hr = IWineD3DSurface_GetDC(This->WineD3DSurface,
1068 hdc);
1069 LeaveCriticalSection(&ddraw_cs);
1070 return hr;
1073 /*****************************************************************************
1074 * IDirectDrawSurface7::ReleaseDC
1076 * Releases the DC that was constructed with GetDC
1078 * Params:
1079 * hdc: HDC to release
1081 * Returns:
1082 * DD_OK on success
1083 * For more details, see IWineD3DSurface::ReleaseDC
1085 *****************************************************************************/
1086 static HRESULT WINAPI
1087 IDirectDrawSurfaceImpl_ReleaseDC(IDirectDrawSurface7 *iface,
1088 HDC hdc)
1090 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1091 HRESULT hr;
1092 TRACE("(%p)->(%p): Relay\n", This, hdc);
1094 EnterCriticalSection(&ddraw_cs);
1095 hr = IWineD3DSurface_ReleaseDC(This->WineD3DSurface, hdc);
1096 LeaveCriticalSection(&ddraw_cs);
1097 return hr;
1100 /*****************************************************************************
1101 * IDirectDrawSurface7::GetCaps
1103 * Returns the surface's caps
1105 * Params:
1106 * Caps: Address to write the caps to
1108 * Returns:
1109 * DD_OK on success
1110 * DDERR_INVALIDPARAMS if Caps is NULL
1112 *****************************************************************************/
1113 static HRESULT WINAPI
1114 IDirectDrawSurfaceImpl_GetCaps(IDirectDrawSurface7 *iface,
1115 DDSCAPS2 *Caps)
1117 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1118 TRACE("(%p)->(%p)\n",This,Caps);
1120 if(!Caps)
1121 return DDERR_INVALIDPARAMS;
1123 *Caps = This->surface_desc.ddsCaps;
1124 return DD_OK;
1127 /*****************************************************************************
1128 * IDirectDrawSurface7::SetPriority
1130 * Sets a texture priority for managed textures.
1132 * Params:
1133 * Priority: The new priority
1135 * Returns:
1136 * DD_OK on success
1137 * For more details, see IWineD3DSurface::SetPriority
1139 *****************************************************************************/
1140 static HRESULT WINAPI
1141 IDirectDrawSurfaceImpl_SetPriority(IDirectDrawSurface7 *iface, DWORD Priority)
1143 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1144 HRESULT hr;
1145 TRACE("(%p)->(%d): Relay!\n",This,Priority);
1147 EnterCriticalSection(&ddraw_cs);
1148 hr = IWineD3DSurface_SetPriority(This->WineD3DSurface, Priority);
1149 LeaveCriticalSection(&ddraw_cs);
1150 return hr;
1153 /*****************************************************************************
1154 * IDirectDrawSurface7::GetPriority
1156 * Returns the surface's priority
1158 * Params:
1159 * Priority: Address of a variable to write the priority to
1161 * Returns:
1162 * D3D_OK on success
1163 * DDERR_INVALIDPARAMS if Priority == NULL
1164 * For more details, see IWineD3DSurface::GetPriority
1166 *****************************************************************************/
1167 static HRESULT WINAPI
1168 IDirectDrawSurfaceImpl_GetPriority(IDirectDrawSurface7 *iface,
1169 DWORD *Priority)
1171 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1172 TRACE("(%p)->(%p): Relay\n",This,Priority);
1174 if(!Priority)
1176 return DDERR_INVALIDPARAMS;
1179 EnterCriticalSection(&ddraw_cs);
1180 *Priority = IWineD3DSurface_GetPriority(This->WineD3DSurface);
1181 LeaveCriticalSection(&ddraw_cs);
1182 return DD_OK;
1185 /*****************************************************************************
1186 * IDirectDrawSurface7::SetPrivateData
1188 * Stores some data in the surface that is intended for the application's
1189 * use.
1191 * Params:
1192 * tag: GUID that identifies the data
1193 * Data: Pointer to the private data
1194 * Size: Size of the private data
1195 * Flags: Some flags
1197 * Returns:
1198 * D3D_OK on success
1199 * For more details, see IWineD3DSurface::SetPrivateData
1201 *****************************************************************************/
1202 static HRESULT WINAPI
1203 IDirectDrawSurfaceImpl_SetPrivateData(IDirectDrawSurface7 *iface,
1204 REFGUID tag,
1205 void *Data,
1206 DWORD Size,
1207 DWORD Flags)
1209 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1210 HRESULT hr;
1211 TRACE("(%p)->(%s,%p,%d,%x): Relay\n", This, debugstr_guid(tag), Data, Size, Flags);
1213 EnterCriticalSection(&ddraw_cs);
1214 hr = IWineD3DSurface_SetPrivateData(This->WineD3DSurface,
1215 tag,
1216 Data,
1217 Size,
1218 Flags);
1219 LeaveCriticalSection(&ddraw_cs);
1220 switch(hr)
1222 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1223 default: return hr;
1227 /*****************************************************************************
1228 * IDirectDrawSurface7::GetPrivateData
1230 * Returns the private data set with IDirectDrawSurface7::SetPrivateData
1232 * Params:
1233 * tag: GUID of the data to return
1234 * Data: Address where to write the data to
1235 * Size: Size of the buffer at Data
1237 * Returns:
1238 * DD_OK on success
1239 * DDERR_INVALIDPARAMS if Data is NULL
1240 * For more details, see IWineD3DSurface::GetPrivateData
1242 *****************************************************************************/
1243 static HRESULT WINAPI
1244 IDirectDrawSurfaceImpl_GetPrivateData(IDirectDrawSurface7 *iface,
1245 REFGUID tag,
1246 void *Data,
1247 DWORD *Size)
1249 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1250 HRESULT hr;
1251 TRACE("(%p)->(%s,%p,%p): Relay\n", This, debugstr_guid(tag), Data, Size);
1253 if(!Data)
1254 return DDERR_INVALIDPARAMS;
1256 EnterCriticalSection(&ddraw_cs);
1257 hr = IWineD3DSurface_GetPrivateData(This->WineD3DSurface,
1258 tag,
1259 Data,
1260 Size);
1261 LeaveCriticalSection(&ddraw_cs);
1262 return hr;
1265 /*****************************************************************************
1266 * IDirectDrawSurface7::FreePrivateData
1268 * Frees private data stored in the surface
1270 * Params:
1271 * tag: Tag of the data to free
1273 * Returns:
1274 * D3D_OK on success
1275 * For more details, see IWineD3DSurface::FreePrivateData
1277 *****************************************************************************/
1278 static HRESULT WINAPI
1279 IDirectDrawSurfaceImpl_FreePrivateData(IDirectDrawSurface7 *iface,
1280 REFGUID tag)
1282 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1283 HRESULT hr;
1284 TRACE("(%p)->(%s): Relay\n", This, debugstr_guid(tag));
1286 EnterCriticalSection(&ddraw_cs);
1287 hr = IWineD3DSurface_FreePrivateData(This->WineD3DSurface, tag);
1288 LeaveCriticalSection(&ddraw_cs);
1289 return hr;
1292 /*****************************************************************************
1293 * IDirectDrawSurface7::PageLock
1295 * Prevents a sysmem surface from being paged out
1297 * Params:
1298 * Flags: Not used, must be 0(unchecked)
1300 * Returns:
1301 * DD_OK, because it's a stub
1303 *****************************************************************************/
1304 static HRESULT WINAPI
1305 IDirectDrawSurfaceImpl_PageLock(IDirectDrawSurface7 *iface,
1306 DWORD Flags)
1308 TRACE("(%p)->(%x)\n", iface, Flags);
1310 /* This is Windows memory management related - we don't need this */
1311 return DD_OK;
1314 /*****************************************************************************
1315 * IDirectDrawSurface7::PageUnlock
1317 * Allows a sysmem surface to be paged out
1319 * Params:
1320 * Flags: Not used, must be 0(unchecked)
1322 * Returns:
1323 * DD_OK, because it's a stub
1325 *****************************************************************************/
1326 static HRESULT WINAPI
1327 IDirectDrawSurfaceImpl_PageUnlock(IDirectDrawSurface7 *iface,
1328 DWORD Flags)
1330 TRACE("(%p)->(%x)\n", iface, Flags);
1332 return DD_OK;
1335 /*****************************************************************************
1336 * IDirectDrawSurface7::BltBatch
1338 * An unimplemented function
1340 * Params:
1343 * Returns:
1344 * DDERR_UNSUPPORTED
1346 *****************************************************************************/
1347 static HRESULT WINAPI IDirectDrawSurfaceImpl_BltBatch(IDirectDrawSurface7 *iface, DDBLTBATCH *Batch, DWORD Count, DWORD Flags)
1349 TRACE("(%p)->(%p,%d,%08x)\n",iface,Batch,Count,Flags);
1351 /* MSDN: "not currently implemented" */
1352 return DDERR_UNSUPPORTED;
1355 /*****************************************************************************
1356 * IDirectDrawSurface7::EnumAttachedSurfaces
1358 * Enumerates all surfaces attached to this surface
1360 * Params:
1361 * context: Pointer to pass unmodified to the callback
1362 * cb: Callback function to call for each surface
1364 * Returns:
1365 * DD_OK on success
1366 * DDERR_INVALIDPARAMS if cb is NULL
1368 *****************************************************************************/
1369 static HRESULT WINAPI
1370 IDirectDrawSurfaceImpl_EnumAttachedSurfaces(IDirectDrawSurface7 *iface,
1371 void *context,
1372 LPDDENUMSURFACESCALLBACK7 cb)
1374 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1375 IDirectDrawSurfaceImpl *surf;
1376 DDSURFACEDESC2 desc;
1377 int i;
1379 /* Attached surfaces aren't handled in WineD3D */
1380 TRACE("(%p)->(%p,%p)\n",This,context,cb);
1382 if(!cb)
1383 return DDERR_INVALIDPARAMS;
1385 EnterCriticalSection(&ddraw_cs);
1386 for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
1388 surf = This->complex_array[i];
1389 if(!surf) break;
1391 IDirectDrawSurface7_AddRef(ICOM_INTERFACE(surf, IDirectDrawSurface7));
1392 desc = surf->surface_desc;
1393 /* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
1394 if (cb(ICOM_INTERFACE(surf, IDirectDrawSurface7), &desc, context) == DDENUMRET_CANCEL)
1396 LeaveCriticalSection(&ddraw_cs);
1397 return DD_OK;
1401 for (surf = This->next_attached; surf != NULL; surf = surf->next_attached)
1403 IDirectDrawSurface7_AddRef(ICOM_INTERFACE(surf, IDirectDrawSurface7));
1404 desc = surf->surface_desc;
1405 /* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
1406 if (cb( ICOM_INTERFACE(surf, IDirectDrawSurface7), &desc, context) == DDENUMRET_CANCEL)
1408 LeaveCriticalSection(&ddraw_cs);
1409 return DD_OK;
1413 TRACE(" end of enumeration.\n");
1415 LeaveCriticalSection(&ddraw_cs);
1416 return DD_OK;
1419 /*****************************************************************************
1420 * IDirectDrawSurface7::EnumOverlayZOrders
1422 * "Enumerates the overlay surfaces on the specified destination"
1424 * Params:
1425 * Flags: DDENUMOVERLAYZ_BACKTOFRONT or DDENUMOVERLAYZ_FRONTTOBACK
1426 * context: context to pass back to the callback
1427 * cb: callback function to call for each enumerated surface
1429 * Returns:
1430 * DD_OK, because it's a stub
1432 *****************************************************************************/
1433 static HRESULT WINAPI
1434 IDirectDrawSurfaceImpl_EnumOverlayZOrders(IDirectDrawSurface7 *iface,
1435 DWORD Flags,
1436 void *context,
1437 LPDDENUMSURFACESCALLBACK7 cb)
1439 FIXME("(%p)->(%x,%p,%p): Stub!\n", iface, Flags, context, cb);
1441 return DD_OK;
1444 /*****************************************************************************
1445 * IDirectDrawSurface7::GetBltStatus
1447 * Returns the blitting status
1449 * Params:
1450 * Flags: DDGBS_CANBLT or DDGBS_ISBLTDONE
1452 * Returns:
1453 * See IWineD3DSurface::Blt
1455 *****************************************************************************/
1456 static HRESULT WINAPI
1457 IDirectDrawSurfaceImpl_GetBltStatus(IDirectDrawSurface7 *iface,
1458 DWORD Flags)
1460 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1461 HRESULT hr;
1462 TRACE("(%p)->(%x): Relay\n", This, Flags);
1464 EnterCriticalSection(&ddraw_cs);
1465 hr = IWineD3DSurface_GetBltStatus(This->WineD3DSurface, Flags);
1466 LeaveCriticalSection(&ddraw_cs);
1467 switch(hr)
1469 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1470 default: return hr;
1474 /*****************************************************************************
1475 * IDirectDrawSurface7::GetColorKey
1477 * Returns the color key assigned to the surface
1479 * Params:
1480 * Flags: Some flags
1481 * CKey: Address to store the key to
1483 * Returns:
1484 * DD_OK on success
1485 * DDERR_INVALIDPARAMS if CKey is NULL
1487 *****************************************************************************/
1488 static HRESULT WINAPI
1489 IDirectDrawSurfaceImpl_GetColorKey(IDirectDrawSurface7 *iface,
1490 DWORD Flags,
1491 DDCOLORKEY *CKey)
1493 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1494 TRACE("(%p)->(%08x,%p)\n", This, Flags, CKey);
1496 if(!CKey)
1497 return DDERR_INVALIDPARAMS;
1499 EnterCriticalSection(&ddraw_cs);
1501 switch (Flags)
1503 case DDCKEY_DESTBLT:
1504 if (!(This->surface_desc.dwFlags & DDSD_CKDESTBLT))
1506 LeaveCriticalSection(&ddraw_cs);
1507 return DDERR_NOCOLORKEY;
1509 *CKey = This->surface_desc.ddckCKDestBlt;
1510 break;
1512 case DDCKEY_DESTOVERLAY:
1513 if (!(This->surface_desc.dwFlags & DDSD_CKDESTOVERLAY))
1515 LeaveCriticalSection(&ddraw_cs);
1516 return DDERR_NOCOLORKEY;
1518 *CKey = This->surface_desc.u3.ddckCKDestOverlay;
1519 break;
1521 case DDCKEY_SRCBLT:
1522 if (!(This->surface_desc.dwFlags & DDSD_CKSRCBLT))
1524 LeaveCriticalSection(&ddraw_cs);
1525 return DDERR_NOCOLORKEY;
1527 *CKey = This->surface_desc.ddckCKSrcBlt;
1528 break;
1530 case DDCKEY_SRCOVERLAY:
1531 if (!(This->surface_desc.dwFlags & DDSD_CKSRCOVERLAY))
1533 LeaveCriticalSection(&ddraw_cs);
1534 return DDERR_NOCOLORKEY;
1536 *CKey = This->surface_desc.ddckCKSrcOverlay;
1537 break;
1539 default:
1540 LeaveCriticalSection(&ddraw_cs);
1541 return DDERR_INVALIDPARAMS;
1544 LeaveCriticalSection(&ddraw_cs);
1545 return DD_OK;
1548 /*****************************************************************************
1549 * IDirectDrawSurface7::GetFlipStatus
1551 * Returns the flipping status of the surface
1553 * Params:
1554 * Flags: DDGFS_CANFLIP of DDGFS_ISFLIPDONE
1556 * Returns:
1557 * See IWineD3DSurface::GetFlipStatus
1559 *****************************************************************************/
1560 static HRESULT WINAPI
1561 IDirectDrawSurfaceImpl_GetFlipStatus(IDirectDrawSurface7 *iface,
1562 DWORD Flags)
1564 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1565 HRESULT hr;
1566 TRACE("(%p)->(%x): Relay\n", This, Flags);
1568 EnterCriticalSection(&ddraw_cs);
1569 hr = IWineD3DSurface_GetFlipStatus(This->WineD3DSurface, Flags);
1570 LeaveCriticalSection(&ddraw_cs);
1571 switch(hr)
1573 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1574 default: return hr;
1578 /*****************************************************************************
1579 * IDirectDrawSurface7::GetOverlayPosition
1581 * Returns the display coordinates of a visible and active overlay surface
1583 * Params:
1587 * Returns:
1588 * DDERR_NOTAOVERLAYSURFACE, because it's a stub
1589 *****************************************************************************/
1590 static HRESULT WINAPI
1591 IDirectDrawSurfaceImpl_GetOverlayPosition(IDirectDrawSurface7 *iface,
1592 LONG *X,
1593 LONG *Y) {
1594 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1595 HRESULT hr;
1596 TRACE("(%p)->(%p,%p): Relay\n", This, X, Y);
1598 EnterCriticalSection(&ddraw_cs);
1599 hr = IWineD3DSurface_GetOverlayPosition(This->WineD3DSurface,
1602 LeaveCriticalSection(&ddraw_cs);
1603 return hr;
1606 /*****************************************************************************
1607 * IDirectDrawSurface7::GetPixelFormat
1609 * Returns the pixel format of the Surface
1611 * Params:
1612 * PixelFormat: Pointer to a DDPIXELFORMAT structure to which the pixel
1613 * format should be written
1615 * Returns:
1616 * DD_OK on success
1617 * DDERR_INVALIDPARAMS if PixelFormat is NULL
1619 *****************************************************************************/
1620 static HRESULT WINAPI
1621 IDirectDrawSurfaceImpl_GetPixelFormat(IDirectDrawSurface7 *iface,
1622 DDPIXELFORMAT *PixelFormat)
1624 /* What is DDERR_INVALIDSURFACETYPE for here? */
1625 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1626 TRACE("(%p)->(%p)\n",This,PixelFormat);
1628 if(!PixelFormat)
1629 return DDERR_INVALIDPARAMS;
1631 EnterCriticalSection(&ddraw_cs);
1632 DD_STRUCT_COPY_BYSIZE(PixelFormat,&This->surface_desc.u4.ddpfPixelFormat);
1633 LeaveCriticalSection(&ddraw_cs);
1635 return DD_OK;
1639 /*****************************************************************************
1640 * IDirectDrawSurface7::GetSurfaceDesc
1642 * Returns the description of this surface
1644 * Params:
1645 * DDSD: Address of a DDSURFACEDESC2 structure that is to be filled with the
1646 * surface desc
1648 * Returns:
1649 * DD_OK on success
1650 * DDERR_INVALIDPARAMS if DDSD is NULL
1652 *****************************************************************************/
1653 static HRESULT WINAPI
1654 IDirectDrawSurfaceImpl_GetSurfaceDesc(IDirectDrawSurface7 *iface,
1655 DDSURFACEDESC2 *DDSD)
1657 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1659 TRACE("(%p)->(%p)\n",This,DDSD);
1661 if(!DDSD)
1662 return DDERR_INVALIDPARAMS;
1664 if (DDSD->dwSize != sizeof(DDSURFACEDESC2))
1666 WARN("Incorrect struct size %d, returning DDERR_INVALIDPARAMS\n",DDSD->dwSize);
1667 return DDERR_INVALIDPARAMS;
1670 EnterCriticalSection(&ddraw_cs);
1671 DD_STRUCT_COPY_BYSIZE(DDSD,&This->surface_desc);
1672 TRACE("Returning surface desc:\n");
1673 if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD);
1675 LeaveCriticalSection(&ddraw_cs);
1676 return DD_OK;
1679 /*****************************************************************************
1680 * IDirectDrawSurface7::Initialize
1682 * Initializes the surface. This is a no-op in Wine
1684 * Params:
1685 * DD: Pointer to an DirectDraw interface
1686 * DDSD: Surface description for initialization
1688 * Returns:
1689 * DDERR_ALREADYINITIALIZED
1691 *****************************************************************************/
1692 static HRESULT WINAPI
1693 IDirectDrawSurfaceImpl_Initialize(IDirectDrawSurface7 *iface,
1694 IDirectDraw *DD,
1695 DDSURFACEDESC2 *DDSD)
1697 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1698 IDirectDrawImpl *ddimpl = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, DD);
1699 TRACE("(%p)->(%p,%p)\n",This,ddimpl,DDSD);
1701 return DDERR_ALREADYINITIALIZED;
1704 /*****************************************************************************
1705 * IDirectDrawSurface7::IsLost
1707 * Checks if the surface is lost
1709 * Returns:
1710 * DD_OK, if the surface is usable
1711 * DDERR_ISLOST if the surface is lost
1712 * See IWineD3DSurface::IsLost for more details
1714 *****************************************************************************/
1715 static HRESULT WINAPI
1716 IDirectDrawSurfaceImpl_IsLost(IDirectDrawSurface7 *iface)
1718 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1719 HRESULT hr;
1720 TRACE("(%p)\n", This);
1722 EnterCriticalSection(&ddraw_cs);
1723 /* We lose the surface if the implementation was changed */
1724 if(This->ImplType != This->ddraw->ImplType)
1726 /* But this shouldn't happen. When we change the implementation,
1727 * all surfaces are re-created automatically, and their content
1728 * is copied
1730 ERR(" (%p) Implementation was changed from %d to %d\n", This, This->ImplType, This->ddraw->ImplType);
1731 LeaveCriticalSection(&ddraw_cs);
1732 return DDERR_SURFACELOST;
1735 hr = IWineD3DSurface_IsLost(This->WineD3DSurface);
1736 LeaveCriticalSection(&ddraw_cs);
1737 switch(hr)
1739 /* D3D8 and 9 loose full devices, thus there's only a DEVICELOST error.
1740 * WineD3D uses the same error for surfaces
1742 case WINED3DERR_DEVICELOST: return DDERR_SURFACELOST;
1743 default: return hr;
1747 /*****************************************************************************
1748 * IDirectDrawSurface7::Restore
1750 * Restores a lost surface. This makes the surface usable again, but
1751 * doesn't reload its old contents
1753 * Returns:
1754 * DD_OK on success
1755 * See IWineD3DSurface::Restore for more details
1757 *****************************************************************************/
1758 static HRESULT WINAPI
1759 IDirectDrawSurfaceImpl_Restore(IDirectDrawSurface7 *iface)
1761 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1762 HRESULT hr;
1763 TRACE("(%p)\n", This);
1765 EnterCriticalSection(&ddraw_cs);
1766 if(This->ImplType != This->ddraw->ImplType)
1768 /* Call the recreation callback. Make sure to AddRef first */
1769 IDirectDrawSurface_AddRef(iface);
1770 IDirectDrawImpl_RecreateSurfacesCallback(iface,
1771 &This->surface_desc,
1772 NULL /* Not needed */);
1774 hr = IWineD3DSurface_Restore(This->WineD3DSurface);
1775 LeaveCriticalSection(&ddraw_cs);
1776 return hr;
1779 /*****************************************************************************
1780 * IDirectDrawSurface7::SetOverlayPosition
1782 * Changes the display coordinates of an overlay surface
1784 * Params:
1785 * X:
1786 * Y:
1788 * Returns:
1789 * DDERR_NOTAOVERLAYSURFACE, because we don't support overlays right now
1790 *****************************************************************************/
1791 static HRESULT WINAPI
1792 IDirectDrawSurfaceImpl_SetOverlayPosition(IDirectDrawSurface7 *iface,
1793 LONG X,
1794 LONG Y)
1796 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1797 HRESULT hr;
1798 TRACE("(%p)->(%d,%d): Relay\n", This, X, Y);
1800 EnterCriticalSection(&ddraw_cs);
1801 hr = IWineD3DSurface_SetOverlayPosition(This->WineD3DSurface,
1804 LeaveCriticalSection(&ddraw_cs);
1805 return hr;
1808 /*****************************************************************************
1809 * IDirectDrawSurface7::UpdateOverlay
1811 * Modifies the attributes of an overlay surface.
1813 * Params:
1814 * SrcRect: The section of the source being used for the overlay
1815 * DstSurface: Address of the surface that is overlaid
1816 * DstRect: Place of the overlay
1817 * Flags: some DDOVER_* flags
1819 * Returns:
1820 * DDERR_UNSUPPORTED, because we don't support overlays
1822 *****************************************************************************/
1823 static HRESULT WINAPI
1824 IDirectDrawSurfaceImpl_UpdateOverlay(IDirectDrawSurface7 *iface,
1825 LPRECT SrcRect,
1826 IDirectDrawSurface7 *DstSurface,
1827 LPRECT DstRect,
1828 DWORD Flags,
1829 LPDDOVERLAYFX FX)
1831 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1832 IDirectDrawSurfaceImpl *Dst = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DstSurface);
1833 HRESULT hr;
1834 TRACE("(%p)->(%p,%p,%p,%x,%p): Relay\n", This, SrcRect, Dst, DstRect, Flags, FX);
1836 EnterCriticalSection(&ddraw_cs);
1837 hr = IWineD3DSurface_UpdateOverlay(This->WineD3DSurface,
1838 SrcRect,
1839 Dst ? Dst->WineD3DSurface : NULL,
1840 DstRect,
1841 Flags,
1842 (WINEDDOVERLAYFX *) FX);
1843 LeaveCriticalSection(&ddraw_cs);
1844 return hr;
1847 /*****************************************************************************
1848 * IDirectDrawSurface7::UpdateOverlayDisplay
1850 * The DX7 sdk says that it's not implemented
1852 * Params:
1853 * Flags: ?
1855 * Returns: DDERR_UNSUPPORTED, because we don't support overlays
1857 *****************************************************************************/
1858 static HRESULT WINAPI
1859 IDirectDrawSurfaceImpl_UpdateOverlayDisplay(IDirectDrawSurface7 *iface,
1860 DWORD Flags)
1862 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1863 TRACE("(%p)->(%x)\n", This, Flags);
1864 return DDERR_UNSUPPORTED;
1867 /*****************************************************************************
1868 * IDirectDrawSurface7::UpdateOverlayZOrder
1870 * Sets an overlay's Z order
1872 * Params:
1873 * Flags: DDOVERZ_* flags
1874 * DDSRef: Defines the relative position in the overlay chain
1876 * Returns:
1877 * DDERR_NOTOVERLAYSURFACE, because we don't support overlays
1879 *****************************************************************************/
1880 static HRESULT WINAPI
1881 IDirectDrawSurfaceImpl_UpdateOverlayZOrder(IDirectDrawSurface7 *iface,
1882 DWORD Flags,
1883 IDirectDrawSurface7 *DDSRef)
1885 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1886 HRESULT hr;
1887 IDirectDrawSurfaceImpl *Ref = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DDSRef);
1889 TRACE("(%p)->(%x,%p): Relay\n", This, Flags, Ref);
1890 EnterCriticalSection(&ddraw_cs);
1891 hr = IWineD3DSurface_UpdateOverlayZOrder(This->WineD3DSurface,
1892 Flags,
1893 Ref ? Ref->WineD3DSurface : NULL);
1894 LeaveCriticalSection(&ddraw_cs);
1895 return hr;
1898 /*****************************************************************************
1899 * IDirectDrawSurface7::GetDDInterface
1901 * Returns the IDirectDraw7 interface pointer of the DirectDraw object this
1902 * surface belongs to
1904 * Params:
1905 * DD: Address to write the interface pointer to
1907 * Returns:
1908 * DD_OK on success
1909 * DDERR_INVALIDPARAMS if DD is NULL
1911 *****************************************************************************/
1912 static HRESULT WINAPI
1913 IDirectDrawSurfaceImpl_GetDDInterface(IDirectDrawSurface7 *iface,
1914 void **DD)
1916 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1918 TRACE("(%p)->(%p)\n",This,DD);
1920 if(!DD)
1921 return DDERR_INVALIDPARAMS;
1923 switch(This->version)
1925 case 7:
1926 *((IDirectDraw7 **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw7);
1927 IDirectDraw7_AddRef(*(IDirectDraw7 **) DD);
1928 break;
1930 case 4:
1931 *((IDirectDraw4 **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw4);
1932 IDirectDraw4_AddRef(*(IDirectDraw4 **) DD);
1933 break;
1935 case 2:
1936 *((IDirectDraw2 **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw2);
1937 IDirectDraw_AddRef( *(IDirectDraw2 **) DD);
1938 break;
1940 case 1:
1941 *((IDirectDraw **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw);
1942 IDirectDraw_AddRef( *(IDirectDraw **) DD);
1943 break;
1947 return DD_OK;
1950 /* This seems also windows implementation specific - I don't think WineD3D needs this */
1951 static HRESULT WINAPI IDirectDrawSurfaceImpl_ChangeUniquenessValue(IDirectDrawSurface7 *iface)
1953 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1954 volatile IDirectDrawSurfaceImpl* vThis = This;
1956 TRACE("(%p)\n",This);
1957 EnterCriticalSection(&ddraw_cs);
1958 /* A uniqueness value of 0 is apparently special.
1959 * This needs to be checked.
1960 * TODO: Write tests for this code and check if the volatile, interlocked stuff is really needed
1962 while (1) {
1963 DWORD old_uniqueness_value = vThis->uniqueness_value;
1964 DWORD new_uniqueness_value = old_uniqueness_value+1;
1966 if (old_uniqueness_value == 0) break;
1967 if (new_uniqueness_value == 0) new_uniqueness_value = 1;
1969 if (InterlockedCompareExchange((LONG*)&vThis->uniqueness_value,
1970 old_uniqueness_value,
1971 new_uniqueness_value)
1972 == old_uniqueness_value)
1973 break;
1976 LeaveCriticalSection(&ddraw_cs);
1977 return DD_OK;
1980 static HRESULT WINAPI IDirectDrawSurfaceImpl_GetUniquenessValue(IDirectDrawSurface7 *iface, LPDWORD pValue)
1982 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1984 TRACE("(%p)->(%p)\n",This,pValue);
1985 EnterCriticalSection(&ddraw_cs);
1986 *pValue = This->uniqueness_value;
1987 LeaveCriticalSection(&ddraw_cs);
1988 return DD_OK;
1991 /*****************************************************************************
1992 * IDirectDrawSurface7::SetLOD
1994 * Sets the level of detail of a texture
1996 * Params:
1997 * MaxLOD: LOD to set
1999 * Returns:
2000 * DD_OK on success
2001 * DDERR_INVALIDOBJECT if the surface is invalid for this method
2003 *****************************************************************************/
2004 static HRESULT WINAPI
2005 IDirectDrawSurfaceImpl_SetLOD(IDirectDrawSurface7 *iface,
2006 DWORD MaxLOD)
2008 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2009 HRESULT hr;
2010 TRACE("(%p)->(%d)\n", This, MaxLOD);
2012 EnterCriticalSection(&ddraw_cs);
2013 if (!(This->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE))
2015 LeaveCriticalSection(&ddraw_cs);
2016 return DDERR_INVALIDOBJECT;
2019 if(!This->wineD3DTexture)
2021 ERR("(%p) The DirectDraw texture has no WineD3DTexture!\n", This);
2022 LeaveCriticalSection(&ddraw_cs);
2023 return DDERR_INVALIDOBJECT;
2026 hr = IWineD3DBaseTexture_SetLOD(This->wineD3DTexture,
2027 MaxLOD);
2028 LeaveCriticalSection(&ddraw_cs);
2029 return hr;
2032 /*****************************************************************************
2033 * IDirectDrawSurface7::GetLOD
2035 * Returns the level of detail of a Direct3D texture
2037 * Params:
2038 * MaxLOD: Address to write the LOD to
2040 * Returns:
2041 * DD_OK on success
2042 * DDERR_INVALIDPARAMS if MaxLOD is NULL
2043 * DDERR_INVALIDOBJECT if the surface is invalid for this method
2045 *****************************************************************************/
2046 static HRESULT WINAPI
2047 IDirectDrawSurfaceImpl_GetLOD(IDirectDrawSurface7 *iface,
2048 DWORD *MaxLOD)
2050 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2051 TRACE("(%p)->(%p)\n", This, MaxLOD);
2053 if(!MaxLOD)
2054 return DDERR_INVALIDPARAMS;
2056 EnterCriticalSection(&ddraw_cs);
2057 if (!(This->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE))
2059 LeaveCriticalSection(&ddraw_cs);
2060 return DDERR_INVALIDOBJECT;
2063 *MaxLOD = IWineD3DBaseTexture_GetLOD(This->wineD3DTexture);
2064 LeaveCriticalSection(&ddraw_cs);
2065 return DD_OK;
2068 /*****************************************************************************
2069 * IDirectDrawSurface7::BltFast
2071 * Performs a fast Blit.
2073 * Params:
2074 * dstx: The x coordinate to blit to on the destination
2075 * dsty: The y coordinate to blit to on the destination
2076 * Source: The source surface
2077 * rsrc: The source rectangle
2078 * trans: Type of transfer. Some DDBLTFAST_* flags
2080 * Returns:
2081 * DD_OK on success
2082 * For more details, see IWineD3DSurface::BltFast
2084 *****************************************************************************/
2085 static HRESULT WINAPI
2086 IDirectDrawSurfaceImpl_BltFast(IDirectDrawSurface7 *iface,
2087 DWORD dstx,
2088 DWORD dsty,
2089 IDirectDrawSurface7 *Source,
2090 RECT *rsrc,
2091 DWORD trans)
2093 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2094 HRESULT hr;
2095 IDirectDrawSurfaceImpl *src = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Source);
2096 TRACE("(%p)->(%d,%d,%p,%p,%d): Relay\n", This, dstx, dsty, Source, rsrc, trans);
2098 /* Source must be != NULL, This is not checked by windows. Windows happily throws a 0xc0000005
2099 * in that case
2101 if(rsrc)
2103 if(rsrc->top > rsrc->bottom || rsrc->left > rsrc->right ||
2104 rsrc->right > src->surface_desc.dwWidth ||
2105 rsrc->bottom > src->surface_desc.dwHeight)
2107 WARN("Source rectangle is invalid, returning DDERR_INVALIDRECT\n");
2108 return DDERR_INVALIDRECT;
2110 if(dstx + rsrc->right - rsrc->left > This->surface_desc.dwWidth ||
2111 dsty + rsrc->bottom - rsrc->top > This->surface_desc.dwHeight)
2113 WARN("Destination area out of bounds, returning DDERR_INVALIDRECT\n");
2114 return DDERR_INVALIDRECT;
2117 else
2119 if(dstx + src->surface_desc.dwWidth > This->surface_desc.dwWidth ||
2120 dsty + src->surface_desc.dwHeight > This->surface_desc.dwHeight)
2122 WARN("Destination area out of bounds, returning DDERR_INVALIDRECT\n");
2123 return DDERR_INVALIDRECT;
2127 EnterCriticalSection(&ddraw_cs);
2128 hr = IWineD3DSurface_BltFast(This->WineD3DSurface,
2129 dstx, dsty,
2130 src ? src->WineD3DSurface : NULL,
2131 rsrc,
2132 trans);
2133 LeaveCriticalSection(&ddraw_cs);
2134 switch(hr)
2136 case WINED3DERR_NOTAVAILABLE: return DDERR_UNSUPPORTED;
2137 case WINED3DERR_WRONGTEXTUREFORMAT: return DDERR_INVALIDPIXELFORMAT;
2138 default: return hr;
2142 /*****************************************************************************
2143 * IDirectDrawSurface7::GetClipper
2145 * Returns the IDirectDrawClipper interface of the clipper assigned to this
2146 * surface
2148 * Params:
2149 * Clipper: Address to store the interface pointer at
2151 * Returns:
2152 * DD_OK on success
2153 * DDERR_INVALIDPARAMS if Clipper is NULL
2154 * DDERR_NOCLIPPERATTACHED if there's no clipper attached
2156 *****************************************************************************/
2157 static HRESULT WINAPI
2158 IDirectDrawSurfaceImpl_GetClipper(IDirectDrawSurface7 *iface,
2159 IDirectDrawClipper **Clipper)
2161 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2162 TRACE("(%p)->(%p)\n", This, Clipper);
2164 if(!Clipper)
2166 LeaveCriticalSection(&ddraw_cs);
2167 return DDERR_INVALIDPARAMS;
2170 EnterCriticalSection(&ddraw_cs);
2171 if(This->clipper == NULL)
2173 LeaveCriticalSection(&ddraw_cs);
2174 return DDERR_NOCLIPPERATTACHED;
2177 *Clipper = ICOM_INTERFACE(This->clipper, IDirectDrawClipper);
2178 IDirectDrawClipper_AddRef(*Clipper);
2179 LeaveCriticalSection(&ddraw_cs);
2180 return DD_OK;
2183 /*****************************************************************************
2184 * IDirectDrawSurface7::SetClipper
2186 * Sets a clipper for the surface
2188 * Params:
2189 * Clipper: IDirectDrawClipper interface of the clipper to set
2191 * Returns:
2192 * DD_OK on success
2194 *****************************************************************************/
2195 static HRESULT WINAPI
2196 IDirectDrawSurfaceImpl_SetClipper(IDirectDrawSurface7 *iface,
2197 IDirectDrawClipper *Clipper)
2199 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2200 IDirectDrawClipperImpl *oldClipper = This->clipper;
2201 HRESULT hr;
2202 TRACE("(%p)->(%p)\n",This,Clipper);
2204 EnterCriticalSection(&ddraw_cs);
2205 if (ICOM_OBJECT(IDirectDrawClipperImpl, IDirectDrawClipper, Clipper) == This->clipper)
2207 LeaveCriticalSection(&ddraw_cs);
2208 return DD_OK;
2211 This->clipper = ICOM_OBJECT(IDirectDrawClipperImpl, IDirectDrawClipper, Clipper);
2213 if (Clipper != NULL)
2214 IDirectDrawClipper_AddRef(Clipper);
2215 if(oldClipper)
2216 IDirectDrawClipper_Release(ICOM_INTERFACE(oldClipper, IDirectDrawClipper));
2218 hr = IWineD3DSurface_SetClipper(This->WineD3DSurface, This->clipper ? This->clipper->wineD3DClipper : NULL);
2219 LeaveCriticalSection(&ddraw_cs);
2220 return hr;
2223 /*****************************************************************************
2224 * IDirectDrawSurface7::SetSurfaceDesc
2226 * Sets the surface description. It can override the pixel format, the surface
2227 * memory, ...
2228 * It's not really tested.
2230 * Params:
2231 * DDSD: Pointer to the new surface description to set
2232 * Flags: Some flags
2234 * Returns:
2235 * DD_OK on success
2236 * DDERR_INVALIDPARAMS if DDSD is NULL
2238 *****************************************************************************/
2239 static HRESULT WINAPI
2240 IDirectDrawSurfaceImpl_SetSurfaceDesc(IDirectDrawSurface7 *iface,
2241 DDSURFACEDESC2 *DDSD,
2242 DWORD Flags)
2244 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2245 WINED3DFORMAT newFormat = WINED3DFMT_UNKNOWN;
2246 HRESULT hr;
2247 TRACE("(%p)->(%p,%x)\n", This, DDSD, Flags);
2249 if(!DDSD)
2250 return DDERR_INVALIDPARAMS;
2252 EnterCriticalSection(&ddraw_cs);
2253 if (DDSD->dwFlags & DDSD_PIXELFORMAT)
2255 newFormat = PixelFormat_DD2WineD3D(&DDSD->u4.ddpfPixelFormat);
2257 if(newFormat == WINED3DFMT_UNKNOWN)
2259 ERR("Requested to set an unknown pixelformat\n");
2260 LeaveCriticalSection(&ddraw_cs);
2261 return DDERR_INVALIDPARAMS;
2263 if(newFormat != PixelFormat_DD2WineD3D(&This->surface_desc.u4.ddpfPixelFormat) )
2265 hr = IWineD3DSurface_SetFormat(This->WineD3DSurface,
2266 newFormat);
2267 if(hr != DD_OK)
2269 LeaveCriticalSection(&ddraw_cs);
2270 return hr;
2274 if (DDSD->dwFlags & DDSD_CKDESTOVERLAY)
2276 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2277 DDCKEY_DESTOVERLAY,
2278 (WINEDDCOLORKEY *) &DDSD->u3.ddckCKDestOverlay);
2280 if (DDSD->dwFlags & DDSD_CKDESTBLT)
2282 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2283 DDCKEY_DESTBLT,
2284 (WINEDDCOLORKEY *) &DDSD->ddckCKDestBlt);
2286 if (DDSD->dwFlags & DDSD_CKSRCOVERLAY)
2288 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2289 DDCKEY_SRCOVERLAY,
2290 (WINEDDCOLORKEY *) &DDSD->ddckCKSrcOverlay);
2292 if (DDSD->dwFlags & DDSD_CKSRCBLT)
2294 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2295 DDCKEY_SRCBLT,
2296 (WINEDDCOLORKEY *) &DDSD->ddckCKSrcBlt);
2298 if (DDSD->dwFlags & DDSD_LPSURFACE && DDSD->lpSurface)
2300 hr = IWineD3DSurface_SetMem(This->WineD3DSurface, DDSD->lpSurface);
2301 if(hr != WINED3D_OK)
2303 /* No need for a trace here, wined3d does that for us */
2304 LeaveCriticalSection(&ddraw_cs);
2305 switch(hr)
2307 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
2308 default: break; /* Go on */
2314 This->surface_desc = *DDSD;
2316 LeaveCriticalSection(&ddraw_cs);
2317 return DD_OK;
2320 /*****************************************************************************
2321 * IDirectDrawSurface7::GetPalette
2323 * Returns the IDirectDrawPalette interface of the palette currently assigned
2324 * to the surface
2326 * Params:
2327 * Pal: Address to write the interface pointer to
2329 * Returns:
2330 * DD_OK on success
2331 * DDERR_INVALIDPARAMS if Pal is NULL
2333 *****************************************************************************/
2334 static HRESULT WINAPI
2335 IDirectDrawSurfaceImpl_GetPalette(IDirectDrawSurface7 *iface,
2336 IDirectDrawPalette **Pal)
2338 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2339 IWineD3DPalette *wPal;
2340 HRESULT hr;
2341 TRACE("(%p)->(%p): Relay\n", This, Pal);
2343 if(!Pal)
2344 return DDERR_INVALIDPARAMS;
2346 EnterCriticalSection(&ddraw_cs);
2347 hr = IWineD3DSurface_GetPalette(This->WineD3DSurface, &wPal);
2348 if(hr != DD_OK)
2350 LeaveCriticalSection(&ddraw_cs);
2351 return hr;
2354 if(wPal)
2356 hr = IWineD3DPalette_GetParent(wPal, (IUnknown **) Pal);
2358 else
2360 *Pal = NULL;
2361 hr = DDERR_NOPALETTEATTACHED;
2364 LeaveCriticalSection(&ddraw_cs);
2365 return hr;
2368 /*****************************************************************************
2369 * SetColorKeyEnum
2371 * EnumAttachedSurface callback for SetColorKey. Used to set color keys
2372 * recursively in the surface tree
2374 *****************************************************************************/
2375 struct SCKContext
2377 HRESULT ret;
2378 WINEDDCOLORKEY *CKey;
2379 DWORD Flags;
2382 static HRESULT WINAPI
2383 SetColorKeyEnum(IDirectDrawSurface7 *surface,
2384 DDSURFACEDESC2 *desc,
2385 void *context)
2387 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, surface);
2388 struct SCKContext *ctx = context;
2389 HRESULT hr;
2391 hr = IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2392 ctx->Flags,
2393 ctx->CKey);
2394 if(hr != DD_OK)
2396 WARN("IWineD3DSurface_SetColorKey failed, hr = %08x\n", hr);
2397 ctx->ret = hr;
2400 IDirectDrawSurface7_EnumAttachedSurfaces(surface,
2401 context,
2402 SetColorKeyEnum);
2403 IDirectDrawSurface7_Release(surface);
2404 return DDENUMRET_OK;
2407 /*****************************************************************************
2408 * IDirectDrawSurface7::SetColorKey
2410 * Sets the color keying options for the surface. Observations showed that
2411 * in case of complex surfaces the color key has to be assigned to all
2412 * sublevels.
2414 * Params:
2415 * Flags: DDCKEY_*
2416 * CKey: The new color key
2418 * Returns:
2419 * DD_OK on success
2420 * See IWineD3DSurface::SetColorKey for details
2422 *****************************************************************************/
2423 static HRESULT WINAPI
2424 IDirectDrawSurfaceImpl_SetColorKey(IDirectDrawSurface7 *iface,
2425 DWORD Flags,
2426 DDCOLORKEY *CKey)
2428 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2429 struct SCKContext ctx = { DD_OK, (WINEDDCOLORKEY *) CKey, Flags };
2430 TRACE("(%p)->(%x,%p)\n", This, Flags, CKey);
2432 EnterCriticalSection(&ddraw_cs);
2433 if (CKey)
2435 switch (Flags & ~DDCKEY_COLORSPACE)
2437 case DDCKEY_DESTBLT:
2438 This->surface_desc.ddckCKDestBlt = *CKey;
2439 This->surface_desc.dwFlags |= DDSD_CKDESTBLT;
2440 break;
2442 case DDCKEY_DESTOVERLAY:
2443 This->surface_desc.u3.ddckCKDestOverlay = *CKey;
2444 This->surface_desc.dwFlags |= DDSD_CKDESTOVERLAY;
2445 break;
2447 case DDCKEY_SRCOVERLAY:
2448 This->surface_desc.ddckCKSrcOverlay = *CKey;
2449 This->surface_desc.dwFlags |= DDSD_CKSRCOVERLAY;
2450 break;
2452 case DDCKEY_SRCBLT:
2453 This->surface_desc.ddckCKSrcBlt = *CKey;
2454 This->surface_desc.dwFlags |= DDSD_CKSRCBLT;
2455 break;
2457 default:
2458 LeaveCriticalSection(&ddraw_cs);
2459 return DDERR_INVALIDPARAMS;
2462 else
2464 switch (Flags & ~DDCKEY_COLORSPACE)
2466 case DDCKEY_DESTBLT:
2467 This->surface_desc.dwFlags &= ~DDSD_CKDESTBLT;
2468 break;
2470 case DDCKEY_DESTOVERLAY:
2471 This->surface_desc.dwFlags &= ~DDSD_CKDESTOVERLAY;
2472 break;
2474 case DDCKEY_SRCOVERLAY:
2475 This->surface_desc.dwFlags &= ~DDSD_CKSRCOVERLAY;
2476 break;
2478 case DDCKEY_SRCBLT:
2479 This->surface_desc.dwFlags &= ~DDSD_CKSRCBLT;
2480 break;
2482 default:
2483 LeaveCriticalSection(&ddraw_cs);
2484 return DDERR_INVALIDPARAMS;
2487 ctx.ret = IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2488 Flags,
2489 ctx.CKey);
2490 IDirectDrawSurface7_EnumAttachedSurfaces(iface,
2491 (void *) &ctx,
2492 SetColorKeyEnum);
2493 LeaveCriticalSection(&ddraw_cs);
2494 switch(ctx.ret)
2496 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
2497 default: return ctx.ret;
2501 /*****************************************************************************
2502 * IDirectDrawSurface7::SetPalette
2504 * Assigns a DirectDrawPalette object to the surface
2506 * Params:
2507 * Pal: Interface to the palette to set
2509 * Returns:
2510 * DD_OK on success
2512 *****************************************************************************/
2513 static HRESULT WINAPI
2514 IDirectDrawSurfaceImpl_SetPalette(IDirectDrawSurface7 *iface,
2515 IDirectDrawPalette *Pal)
2517 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2518 IDirectDrawPalette *oldPal;
2519 IDirectDrawSurfaceImpl *surf;
2520 IDirectDrawPaletteImpl *PalImpl = ICOM_OBJECT(IDirectDrawPaletteImpl, IDirectDrawPalette, Pal);
2521 HRESULT hr;
2522 TRACE("(%p)->(%p)\n", This, Pal);
2524 if (!(This->surface_desc.u4.ddpfPixelFormat.dwFlags & (DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2 |
2525 DDPF_PALETTEINDEXED4 | DDPF_PALETTEINDEXED8 | DDPF_PALETTEINDEXEDTO8))) {
2526 return DDERR_INVALIDPIXELFORMAT;
2529 /* Find the old palette */
2530 EnterCriticalSection(&ddraw_cs);
2531 hr = IDirectDrawSurface_GetPalette(iface, &oldPal);
2532 if(hr != DD_OK && hr != DDERR_NOPALETTEATTACHED)
2534 LeaveCriticalSection(&ddraw_cs);
2535 return hr;
2537 if(oldPal) IDirectDrawPalette_Release(oldPal); /* For the GetPalette */
2539 /* Set the new Palette */
2540 IWineD3DSurface_SetPalette(This->WineD3DSurface,
2541 PalImpl ? PalImpl->wineD3DPalette : NULL);
2542 /* AddRef the Palette */
2543 if(Pal) IDirectDrawPalette_AddRef(Pal);
2545 /* Release the old palette */
2546 if(oldPal) IDirectDrawPalette_Release(oldPal);
2548 /* If this is a front buffer, also update the back buffers
2549 * TODO: How do things work for palettized cube textures?
2551 if(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
2553 /* For primary surfaces the tree is just a list, so the simpler scheme fits too */
2554 DDSCAPS2 caps2 = { DDSCAPS_PRIMARYSURFACE, 0, 0, 0 };
2556 surf = This;
2557 while(1)
2559 IDirectDrawSurface7 *attach;
2560 HRESULT hr;
2561 hr = IDirectDrawSurface7_GetAttachedSurface(ICOM_INTERFACE(surf, IDirectDrawSurface7),
2562 &caps2, &attach);
2563 if(hr != DD_OK)
2565 break;
2568 TRACE("Setting palette on %p\n", attach);
2569 IDirectDrawSurface7_SetPalette(attach,
2570 Pal);
2571 surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, attach);
2572 IDirectDrawSurface7_Release(attach);
2576 LeaveCriticalSection(&ddraw_cs);
2577 return DD_OK;
2580 /*****************************************************************************
2581 * The VTable
2582 *****************************************************************************/
2584 const IDirectDrawSurface7Vtbl IDirectDrawSurface7_Vtbl =
2586 /*** IUnknown ***/
2587 IDirectDrawSurfaceImpl_QueryInterface,
2588 IDirectDrawSurfaceImpl_AddRef,
2589 IDirectDrawSurfaceImpl_Release,
2590 /*** IDirectDrawSurface ***/
2591 IDirectDrawSurface7Impl_AddAttachedSurface,
2592 IDirectDrawSurfaceImpl_AddOverlayDirtyRect,
2593 IDirectDrawSurfaceImpl_Blt,
2594 IDirectDrawSurfaceImpl_BltBatch,
2595 IDirectDrawSurfaceImpl_BltFast,
2596 IDirectDrawSurfaceImpl_DeleteAttachedSurface,
2597 IDirectDrawSurfaceImpl_EnumAttachedSurfaces,
2598 IDirectDrawSurfaceImpl_EnumOverlayZOrders,
2599 IDirectDrawSurfaceImpl_Flip,
2600 IDirectDrawSurfaceImpl_GetAttachedSurface,
2601 IDirectDrawSurfaceImpl_GetBltStatus,
2602 IDirectDrawSurfaceImpl_GetCaps,
2603 IDirectDrawSurfaceImpl_GetClipper,
2604 IDirectDrawSurfaceImpl_GetColorKey,
2605 IDirectDrawSurfaceImpl_GetDC,
2606 IDirectDrawSurfaceImpl_GetFlipStatus,
2607 IDirectDrawSurfaceImpl_GetOverlayPosition,
2608 IDirectDrawSurfaceImpl_GetPalette,
2609 IDirectDrawSurfaceImpl_GetPixelFormat,
2610 IDirectDrawSurfaceImpl_GetSurfaceDesc,
2611 IDirectDrawSurfaceImpl_Initialize,
2612 IDirectDrawSurfaceImpl_IsLost,
2613 IDirectDrawSurfaceImpl_Lock,
2614 IDirectDrawSurfaceImpl_ReleaseDC,
2615 IDirectDrawSurfaceImpl_Restore,
2616 IDirectDrawSurfaceImpl_SetClipper,
2617 IDirectDrawSurfaceImpl_SetColorKey,
2618 IDirectDrawSurfaceImpl_SetOverlayPosition,
2619 IDirectDrawSurfaceImpl_SetPalette,
2620 IDirectDrawSurfaceImpl_Unlock,
2621 IDirectDrawSurfaceImpl_UpdateOverlay,
2622 IDirectDrawSurfaceImpl_UpdateOverlayDisplay,
2623 IDirectDrawSurfaceImpl_UpdateOverlayZOrder,
2624 /*** IDirectDrawSurface2 ***/
2625 IDirectDrawSurfaceImpl_GetDDInterface,
2626 IDirectDrawSurfaceImpl_PageLock,
2627 IDirectDrawSurfaceImpl_PageUnlock,
2628 /*** IDirectDrawSurface3 ***/
2629 IDirectDrawSurfaceImpl_SetSurfaceDesc,
2630 /*** IDirectDrawSurface4 ***/
2631 IDirectDrawSurfaceImpl_SetPrivateData,
2632 IDirectDrawSurfaceImpl_GetPrivateData,
2633 IDirectDrawSurfaceImpl_FreePrivateData,
2634 IDirectDrawSurfaceImpl_GetUniquenessValue,
2635 IDirectDrawSurfaceImpl_ChangeUniquenessValue,
2636 /*** IDirectDrawSurface7 ***/
2637 IDirectDrawSurfaceImpl_SetPriority,
2638 IDirectDrawSurfaceImpl_GetPriority,
2639 IDirectDrawSurfaceImpl_SetLOD,
2640 IDirectDrawSurfaceImpl_GetLOD