d3d10: Implement ID3D10EffectTechnique::GetAnnotationByName().
[wine/testsucceed.git] / dlls / ddraw / surface.c
blobb59d01a7fad6febd7d3ce095388e8a1cba9b1286
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 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)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 = iface;
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 = &This->IDirectDrawSurface3_vtbl;
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 = &This->IDirectDrawGammaControl_vtbl;
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((IDirect3D7 *)&This->ddraw->IDirect3D7_vtbl, riid, (IDirectDrawSurface7 *)This, &d3d);
121 *obj = d3d ? (IDirect3DDevice *)&((IDirect3DDeviceImpl *)d3d)->IDirect3DDevice_vtbl : NULL;
122 TRACE("(%p) Returning IDirect3DDevice interface at %p\n", This, *obj);
124 return S_OK;
126 else if (IsEqualGUID( &IID_IDirect3DTexture, riid ) ||
127 IsEqualGUID( &IID_IDirect3DTexture2, riid ))
129 if (IsEqualGUID( &IID_IDirect3DTexture, riid ))
131 *obj = &This->IDirect3DTexture_vtbl;
132 TRACE(" returning Direct3DTexture interface at %p.\n", *obj);
134 else
136 *obj = &This->IDirect3DTexture2_vtbl;
137 TRACE(" returning Direct3DTexture2 interface at %p.\n", *obj);
139 IUnknown_AddRef( (IUnknown *) *obj);
140 return S_OK;
143 ERR("No interface\n");
144 return E_NOINTERFACE;
147 /*****************************************************************************
148 * IDirectDrawSurface7::AddRef
150 * A normal addref implementation
152 * Returns:
153 * The new refcount
155 *****************************************************************************/
156 static ULONG WINAPI
157 IDirectDrawSurfaceImpl_AddRef(IDirectDrawSurface7 *iface)
159 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
160 ULONG refCount = InterlockedIncrement(&This->ref);
162 TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
163 return refCount;
166 /*****************************************************************************
167 * IDirectDrawSurfaceImpl_Destroy
169 * A helper function for IDirectDrawSurface7::Release
171 * Frees the surface, regardless of its refcount.
172 * See IDirectDrawSurface7::Release for more information
174 * Params:
175 * This: Surface to free
177 *****************************************************************************/
178 void IDirectDrawSurfaceImpl_Destroy(IDirectDrawSurfaceImpl *This)
180 TRACE("(%p)\n", This);
182 /* Check the refcount and give a warning */
183 if(This->ref > 1)
185 /* This can happen when a complex surface is destroyed,
186 * because the 2nd surface was addref()ed when the app
187 * called GetAttachedSurface
189 WARN("(%p): Destroying surface with refount %d\n", This, This->ref);
192 /* Check for attached surfaces and detach them */
193 if(This->first_attached != This)
195 /* Well, this shouldn't happen: The surface being attached is addref()ed
196 * in AddAttachedSurface, so it shouldn't be released until DeleteAttachedSurface
197 * is called, because the refcount is held. It looks like the app released()
198 * it often enough to force this
200 IDirectDrawSurface7 *root = (IDirectDrawSurface7 *)This->first_attached;
201 IDirectDrawSurface7 *detach = (IDirectDrawSurface7 *)This;
203 FIXME("(%p) Freeing a surface that is attached to surface %p\n", This, This->first_attached);
205 /* The refcount will drop to -1 here */
206 if(IDirectDrawSurface7_DeleteAttachedSurface(root, 0, detach) != DD_OK)
208 ERR("(%p) DeleteAttachedSurface failed!\n", This);
212 while(This->next_attached != NULL)
214 IDirectDrawSurface7 *root = (IDirectDrawSurface7 *)This;
215 IDirectDrawSurface7 *detach = (IDirectDrawSurface7 *)This->next_attached;
217 if(IDirectDrawSurface7_DeleteAttachedSurface(root, 0, detach) != DD_OK)
219 ERR("(%p) DeleteAttachedSurface failed!\n", This);
220 assert(0);
224 /* Now destroy the surface. Wait: It could have been released if we are a texture */
225 if(This->WineD3DSurface)
226 IWineD3DSurface_Release(This->WineD3DSurface);
228 /* Having a texture handle set implies that the device still exists */
229 if(This->Handle)
231 This->ddraw->d3ddevice->Handles[This->Handle - 1].ptr = NULL;
232 This->ddraw->d3ddevice->Handles[This->Handle - 1].type = DDrawHandle_Unknown;
235 /* Reduce the ddraw surface count */
236 InterlockedDecrement(&This->ddraw->surfaces);
237 list_remove(&This->surface_list_entry);
239 HeapFree(GetProcessHeap(), 0, This);
242 /*****************************************************************************
243 * IDirectDrawSurface7::Release
245 * Reduces the surface's refcount by 1. If the refcount falls to 0, the
246 * surface is destroyed.
248 * Destroying the surface is a bit tricky. For the connection between
249 * WineD3DSurfaces and DirectDrawSurfaces see IDirectDraw7::CreateSurface
250 * It has a nice graph explaining the connection.
252 * What happens here is basically this:
253 * When a surface is destroyed, its WineD3DSurface is released,
254 * and the refcount of the DirectDraw interface is reduced by 1. If it has
255 * complex surfaces attached to it, then these surfaces are destroyed too,
256 * regardless of their refcount. If any surface being destroyed has another
257 * surface attached to it (with a "soft" attachment, not complex), then
258 * this surface is detached with DeleteAttachedSurface.
260 * When the surface is a texture, the WineD3DTexture is released.
261 * If the surface is the Direct3D render target, then the D3D
262 * capabilities of the WineD3DDevice are uninitialized, which causes the
263 * swapchain to be released.
265 * When a complex sublevel falls to ref zero, then this is ignored.
267 * Returns:
268 * The new refcount
270 *****************************************************************************/
271 static ULONG WINAPI
272 IDirectDrawSurfaceImpl_Release(IDirectDrawSurface7 *iface)
274 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
275 ULONG ref;
276 TRACE("(%p) : Releasing from %d\n", This, This->ref);
277 ref = InterlockedDecrement(&This->ref);
279 if (ref == 0)
282 IDirectDrawSurfaceImpl *surf;
283 IDirectDrawImpl *ddraw;
284 IUnknown *ifaceToRelease = This->ifaceToRelease;
285 UINT i;
287 /* Complex attached surfaces are destroyed implicitly when the root is released */
288 EnterCriticalSection(&ddraw_cs);
289 if(!This->is_complex_root)
291 WARN("(%p) Attempt to destroy a surface that is not a complex root\n", This);
292 LeaveCriticalSection(&ddraw_cs);
293 return ref;
295 ddraw = This->ddraw;
297 /* If it's a texture, destroy the WineD3DTexture.
298 * WineD3D will destroy the IParent interfaces
299 * of the sublevels, which destroys the WineD3DSurfaces.
300 * Set the surfaces to NULL to avoid destroying them again later
302 if(This->wineD3DTexture)
304 IWineD3DBaseTexture_Release(This->wineD3DTexture);
306 /* If it's the RenderTarget, destroy the d3ddevice */
307 else if(This->wineD3DSwapChain)
309 if((ddraw->d3d_initialized) && (This == ddraw->d3d_target)) {
310 TRACE("(%p) Destroying the render target, uninitializing D3D\n", This);
312 /* Unset any index buffer, just to be sure */
313 IWineD3DDevice_SetIndices(ddraw->wineD3DDevice, NULL, WINED3DFMT_UNKNOWN);
314 IWineD3DDevice_SetDepthStencilSurface(ddraw->wineD3DDevice, NULL);
315 IWineD3DDevice_SetVertexDeclaration(ddraw->wineD3DDevice, NULL);
316 for(i = 0; i < ddraw->numConvertedDecls; i++)
318 IWineD3DVertexDeclaration_Release(ddraw->decls[i].decl);
320 HeapFree(GetProcessHeap(), 0, ddraw->decls);
321 ddraw->numConvertedDecls = 0;
323 if(IWineD3DDevice_Uninit3D(ddraw->wineD3DDevice, D3D7CB_DestroyDepthStencilSurface, D3D7CB_DestroySwapChain) != D3D_OK)
325 /* Not good */
326 ERR("(%p) Failed to uninit 3D\n", This);
328 else
330 /* Free the d3d window if one was created */
331 if(ddraw->d3d_window != 0 && ddraw->d3d_window != ddraw->dest_window)
333 TRACE(" (%p) Destroying the hidden render window %p\n", This, ddraw->d3d_window);
334 DestroyWindow(ddraw->d3d_window);
335 ddraw->d3d_window = 0;
337 /* Unset the pointers */
340 This->wineD3DSwapChain = NULL; /* Uninit3D releases the swapchain */
341 ddraw->d3d_initialized = FALSE;
342 ddraw->d3d_target = NULL;
343 } else {
344 IWineD3DDevice_UninitGDI(ddraw->wineD3DDevice, D3D7CB_DestroySwapChain);
345 This->wineD3DSwapChain = NULL;
348 /* Reset to the default surface implementation type. This is needed if apps use
349 * non render target surfaces and expect blits to work after destroying the render
350 * target.
352 * TODO: Recreate existing offscreen surfaces
354 ddraw->ImplType = DefaultSurfaceType;
356 /* Write a trace because D3D unloading was the reason for many
357 * crashes during development.
359 TRACE("(%p) D3D unloaded\n", This);
361 else if(This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE |
362 DDSCAPS_3DDEVICE |
363 DDSCAPS_TEXTURE ) )
365 /* It's a render target, but no swapchain was created.
366 * The IParent interfaces have to be released manually.
367 * The same applies for textures without an
368 * IWineD3DTexture object attached
370 IParent *Parent;
372 for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
374 if(This->complex_array[i])
376 /* Only the topmost level can have more than 1 surfaces in the complex
377 * attachment array(Cube texture roots), for all others there is only
378 * one
380 surf = This->complex_array[i];
381 while(surf)
383 IWineD3DSurface_GetParent(surf->WineD3DSurface,
384 (IUnknown **) &Parent);
385 IParent_Release(Parent); /* For the getParent */
386 IParent_Release(Parent); /* To release it */
387 surf = surf->complex_array[0];
392 /* Now the top-level surface */
393 IWineD3DSurface_GetParent(This->WineD3DSurface,
394 (IUnknown **) &Parent);
395 IParent_Release(Parent); /* For the getParent */
396 IParent_Release(Parent); /* To release it */
399 /* The refcount test shows that the palette is detached when the surface is destroyed */
400 IDirectDrawSurface7_SetPalette((IDirectDrawSurface7 *)This, NULL);
402 /* Loop through all complex attached surfaces,
403 * and destroy them.
405 * Yet again, only the root can have more than one complexly attached surface, all the others
406 * have a total of one;
408 for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
410 if(!This->complex_array[i]) break;
412 surf = This->complex_array[i];
413 This->complex_array[i] = NULL;
414 while(surf)
416 IDirectDrawSurfaceImpl *destroy = surf;
417 surf = surf->complex_array[0]; /* Iterate through the "tree" */
418 IDirectDrawSurfaceImpl_Destroy(destroy); /* Destroy it */
422 /* Destroy the root surface.
424 IDirectDrawSurfaceImpl_Destroy(This);
426 /* Reduce the ddraw refcount */
427 if(ifaceToRelease) IUnknown_Release(ifaceToRelease);
428 LeaveCriticalSection(&ddraw_cs);
431 return ref;
434 /*****************************************************************************
435 * IDirectDrawSurface7::GetAttachedSurface
437 * Returns an attached surface with the requested caps. Surface attachment
438 * and complex surfaces are not clearly described by the MSDN or sdk,
439 * so this method is tricky and likely to contain problems.
440 * This implementation searches the complex list first, then the
441 * attachment chain.
443 * The chains are searched from This down to the last surface in the chain,
444 * not from the first element in the chain. The first surface found is
445 * returned. The MSDN says that this method fails if more than one surface
446 * matches the caps, but it is not sure if that is right. The attachment
447 * structure may not even allow two matching surfaces.
449 * The found surface is AddRef-ed before it is returned.
451 * Params:
452 * Caps: Pointer to a DDCAPS2 structure describing the caps asked for
453 * Surface: Address to store the found surface
455 * Returns:
456 * DD_OK on success
457 * DDERR_INVALIDPARAMS if Caps or Surface is NULL
458 * DDERR_NOTFOUND if no surface was found
460 *****************************************************************************/
461 static HRESULT WINAPI
462 IDirectDrawSurfaceImpl_GetAttachedSurface(IDirectDrawSurface7 *iface,
463 DDSCAPS2 *Caps,
464 IDirectDrawSurface7 **Surface)
466 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
467 IDirectDrawSurfaceImpl *surf;
468 DDSCAPS2 our_caps;
469 int i;
471 TRACE("(%p)->(%p,%p)\n", This, Caps, Surface);
472 EnterCriticalSection(&ddraw_cs);
474 if(This->version < 7)
476 /* Earlier dx apps put garbage into these members, clear them */
477 our_caps.dwCaps = Caps->dwCaps;
478 our_caps.dwCaps2 = 0;
479 our_caps.dwCaps3 = 0;
480 our_caps.dwCaps4 = 0;
482 else
484 our_caps = *Caps;
487 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 */
489 for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
491 surf = This->complex_array[i];
492 if(!surf) break;
494 if (TRACE_ON(ddraw))
496 TRACE("Surface: (%p) caps: %x,%x,%x,%x\n", surf,
497 surf->surface_desc.ddsCaps.dwCaps,
498 surf->surface_desc.ddsCaps.dwCaps2,
499 surf->surface_desc.ddsCaps.dwCaps3,
500 surf->surface_desc.ddsCaps.dwCaps4);
503 if (((surf->surface_desc.ddsCaps.dwCaps & our_caps.dwCaps) == our_caps.dwCaps) &&
504 ((surf->surface_desc.ddsCaps.dwCaps2 & our_caps.dwCaps2) == our_caps.dwCaps2)) {
506 /* MSDN: "This method fails if more than one surface is attached
507 * that matches the capabilities requested."
509 * Not sure how to test this.
512 TRACE("(%p): Returning surface %p\n", This, surf);
513 TRACE("(%p): mipmapcount=%d\n", This, surf->mipmap_level);
514 *Surface = (IDirectDrawSurface7 *)surf;
515 IDirectDrawSurface7_AddRef(*Surface);
516 LeaveCriticalSection(&ddraw_cs);
517 return DD_OK;
521 /* Next, look at the attachment chain */
522 surf = This;
524 while( (surf = surf->next_attached) )
526 if (TRACE_ON(ddraw))
528 TRACE("Surface: (%p) caps: %x,%x,%x,%x\n", surf,
529 surf->surface_desc.ddsCaps.dwCaps,
530 surf->surface_desc.ddsCaps.dwCaps2,
531 surf->surface_desc.ddsCaps.dwCaps3,
532 surf->surface_desc.ddsCaps.dwCaps4);
535 if (((surf->surface_desc.ddsCaps.dwCaps & our_caps.dwCaps) == our_caps.dwCaps) &&
536 ((surf->surface_desc.ddsCaps.dwCaps2 & our_caps.dwCaps2) == our_caps.dwCaps2)) {
538 TRACE("(%p): Returning surface %p\n", This, surf);
539 *Surface = (IDirectDrawSurface7 *)surf;
540 IDirectDrawSurface7_AddRef(*Surface);
541 LeaveCriticalSection(&ddraw_cs);
542 return DD_OK;
546 TRACE("(%p) Didn't find a valid surface\n", This);
547 LeaveCriticalSection(&ddraw_cs);
549 *Surface = NULL;
550 return DDERR_NOTFOUND;
553 /*****************************************************************************
554 * IDirectDrawSurface7::Lock
556 * Locks the surface and returns a pointer to the surface's memory
558 * Params:
559 * Rect: Rectangle to lock. If NULL, the whole surface is locked
560 * DDSD: Pointer to a DDSURFACEDESC2 which shall receive the surface's desc.
561 * Flags: Locking flags, e.g Read only or write only
562 * h: An event handle that's not used and must be NULL
564 * Returns:
565 * DD_OK on success
566 * DDERR_INVALIDPARAMS if DDSD is NULL
567 * For more details, see IWineD3DSurface::LockRect
569 *****************************************************************************/
570 static HRESULT WINAPI
571 IDirectDrawSurfaceImpl_Lock(IDirectDrawSurface7 *iface,
572 RECT *Rect,
573 DDSURFACEDESC2 *DDSD,
574 DWORD Flags,
575 HANDLE h)
577 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
578 WINED3DLOCKED_RECT LockedRect;
579 HRESULT hr;
580 TRACE("(%p)->(%p,%p,%x,%p)\n", This, Rect, DDSD, Flags, h);
582 if(!DDSD)
583 return DDERR_INVALIDPARAMS;
585 /* This->surface_desc.dwWidth and dwHeight are changeable, thus lock */
586 EnterCriticalSection(&ddraw_cs);
588 /* Should I check for the handle to be NULL?
590 * The DDLOCK flags and the D3DLOCK flags are equal
591 * for the supported values. The others are ignored by WineD3D
594 if(DDSD->dwSize != sizeof(DDSURFACEDESC) &&
595 DDSD->dwSize != sizeof(DDSURFACEDESC2))
597 WARN("Invalid structure size %d, returning DDERR_INVALIDPARAMS\n", DDERR_INVALIDPARAMS);
598 LeaveCriticalSection(&ddraw_cs);
599 return DDERR_INVALIDPARAMS;
602 /* Windows zeroes this if the rect is invalid */
603 DDSD->lpSurface = 0;
605 if (Rect)
607 if ((Rect->left < 0)
608 || (Rect->top < 0)
609 || (Rect->left > Rect->right)
610 || (Rect->top > Rect->bottom)
611 || (Rect->right > This->surface_desc.dwWidth)
612 || (Rect->bottom > This->surface_desc.dwHeight))
614 WARN("Trying to lock an invalid rectangle, returning DDERR_INVALIDPARAMS\n");
615 LeaveCriticalSection(&ddraw_cs);
616 return DDERR_INVALIDPARAMS;
620 hr = IWineD3DSurface_LockRect(This->WineD3DSurface,
621 &LockedRect,
622 Rect,
623 Flags);
624 if(hr != D3D_OK)
626 LeaveCriticalSection(&ddraw_cs);
627 switch(hr)
629 /* D3D8 and D3D9 return the general D3DERR_INVALIDCALL error, but ddraw has a more
630 * specific error. But since IWineD3DSurface::LockRect returns that error in this
631 * only occasion, keep d3d8 and d3d9 free from the return value override. There are
632 * many different places where d3d8/9 would have to catch the DDERR_SURFACEBUSY, it
633 * is much easier to do it in one place in ddraw
635 case WINED3DERR_INVALIDCALL: return DDERR_SURFACEBUSY;
636 default: return hr;
640 /* Override the memory area. The pitch should be set already. Strangely windows
641 * does not set the LPSURFACE flag on locked surfaces !?!.
642 * DDSD->dwFlags |= DDSD_LPSURFACE;
644 This->surface_desc.lpSurface = LockedRect.pBits;
645 DD_STRUCT_COPY_BYSIZE(DDSD,&(This->surface_desc));
647 TRACE("locked surface returning description :\n");
648 if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD);
650 LeaveCriticalSection(&ddraw_cs);
651 return DD_OK;
654 /*****************************************************************************
655 * IDirectDrawSurface7::Unlock
657 * Unlocks an locked surface
659 * Params:
660 * Rect: Not used by this implementation
662 * Returns:
663 * D3D_OK on success
664 * For more details, see IWineD3DSurface::UnlockRect
666 *****************************************************************************/
667 static HRESULT WINAPI
668 IDirectDrawSurfaceImpl_Unlock(IDirectDrawSurface7 *iface,
669 RECT *pRect)
671 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
672 HRESULT hr;
673 TRACE("(%p)->(%p)\n", This, pRect);
675 EnterCriticalSection(&ddraw_cs);
676 hr = IWineD3DSurface_UnlockRect(This->WineD3DSurface);
677 if(SUCCEEDED(hr))
679 This->surface_desc.lpSurface = NULL;
681 LeaveCriticalSection(&ddraw_cs);
682 return hr;
685 /*****************************************************************************
686 * IDirectDrawSurface7::Flip
688 * Flips a surface with the DDSCAPS_FLIP flag. The flip is relayed to
689 * IWineD3DSurface::Flip. Because WineD3D doesn't handle attached surfaces,
690 * the flip target is passed to WineD3D, even if the app didn't specify one
692 * Params:
693 * DestOverride: Specifies the surface that will become the new front
694 * buffer. If NULL, the current back buffer is used
695 * Flags: some DirectDraw flags, see include/ddraw.h
697 * Returns:
698 * DD_OK on success
699 * DDERR_NOTFLIPPABLE if no flip target could be found
700 * DDERR_INVALIDOBJECT if the surface isn't a front buffer
701 * For more details, see IWineD3DSurface::Flip
703 *****************************************************************************/
704 static HRESULT WINAPI
705 IDirectDrawSurfaceImpl_Flip(IDirectDrawSurface7 *iface,
706 IDirectDrawSurface7 *DestOverride,
707 DWORD Flags)
709 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
710 IDirectDrawSurfaceImpl *Override = (IDirectDrawSurfaceImpl *)DestOverride;
711 IDirectDrawSurface7 *Override7;
712 HRESULT hr;
713 TRACE("(%p)->(%p,%x)\n", This, DestOverride, Flags);
715 /* Flip has to be called from a front buffer
716 * What about overlay surfaces, AFAIK they can flip too?
718 if( !(This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_OVERLAY)) )
719 return DDERR_INVALIDOBJECT; /* Unchecked */
721 EnterCriticalSection(&ddraw_cs);
723 /* WineD3D doesn't keep track of attached surface, so find the target */
724 if(!Override)
726 DDSCAPS2 Caps;
728 memset(&Caps, 0, sizeof(Caps));
729 Caps.dwCaps |= DDSCAPS_BACKBUFFER;
730 hr = IDirectDrawSurface7_GetAttachedSurface(iface, &Caps, &Override7);
731 if(hr != DD_OK)
733 ERR("Can't find a flip target\n");
734 LeaveCriticalSection(&ddraw_cs);
735 return DDERR_NOTFLIPPABLE; /* Unchecked */
737 Override = (IDirectDrawSurfaceImpl *)Override7;
739 /* For the GetAttachedSurface */
740 IDirectDrawSurface7_Release(Override7);
743 hr = IWineD3DSurface_Flip(This->WineD3DSurface,
744 Override->WineD3DSurface,
745 Flags);
746 LeaveCriticalSection(&ddraw_cs);
747 return hr;
750 /*****************************************************************************
751 * IDirectDrawSurface7::Blt
753 * Performs a blit on the surface
755 * Params:
756 * DestRect: Destination rectangle, can be NULL
757 * SrcSurface: Source surface, can be NULL
758 * SrcRect: Source rectangle, can be NULL
759 * Flags: Blt flags
760 * DDBltFx: Some extended blt parameters, connected to the flags
762 * Returns:
763 * D3D_OK on success
764 * See IWineD3DSurface::Blt for more details
766 *****************************************************************************/
767 static HRESULT WINAPI
768 IDirectDrawSurfaceImpl_Blt(IDirectDrawSurface7 *iface,
769 RECT *DestRect,
770 IDirectDrawSurface7 *SrcSurface,
771 RECT *SrcRect,
772 DWORD Flags,
773 DDBLTFX *DDBltFx)
775 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
776 IDirectDrawSurfaceImpl *Src = (IDirectDrawSurfaceImpl *)SrcSurface;
777 HRESULT hr;
778 TRACE("(%p)->(%p,%p,%p,%x,%p)\n", This, DestRect, Src, SrcRect, Flags, DDBltFx);
780 /* Check for validity of the flags here. WineD3D Has the software-opengl selection path and would have
781 * to check at 2 places, and sometimes do double checks. This also saves the call to wined3d :-)
783 if((Flags & DDBLT_KEYSRCOVERRIDE) && (!DDBltFx || Flags & DDBLT_KEYSRC)) {
784 WARN("Invalid source color key parameters, returning DDERR_INVALIDPARAMS\n");
785 return DDERR_INVALIDPARAMS;
788 if((Flags & DDBLT_KEYDESTOVERRIDE) && (!DDBltFx || Flags & DDBLT_KEYDEST)) {
789 WARN("Invalid destination color key parameters, returning DDERR_INVALIDPARAMS\n");
790 return DDERR_INVALIDPARAMS;
793 /* Sizes can change, therefore hold the lock when testing the rectangles */
794 EnterCriticalSection(&ddraw_cs);
795 if(DestRect)
797 if(DestRect->top >= DestRect->bottom || DestRect->left >= DestRect->right ||
798 DestRect->right > This->surface_desc.dwWidth ||
799 DestRect->bottom > This->surface_desc.dwHeight)
801 WARN("Destination rectangle is invalid, returning DDERR_INVALIDRECT\n");
802 LeaveCriticalSection(&ddraw_cs);
803 return DDERR_INVALIDRECT;
806 if(Src && SrcRect)
808 if(SrcRect->top >= SrcRect->bottom || SrcRect->left >=SrcRect->right ||
809 SrcRect->right > Src->surface_desc.dwWidth ||
810 SrcRect->bottom > Src->surface_desc.dwHeight)
812 WARN("Source rectangle is invalid, returning DDERR_INVALIDRECT\n");
813 LeaveCriticalSection(&ddraw_cs);
814 return DDERR_INVALIDRECT;
818 if(Flags & DDBLT_KEYSRC && (!Src || !(Src->surface_desc.dwFlags & DDSD_CKSRCBLT))) {
819 WARN("DDBLT_KEYDEST blit without color key in surface, returning DDERR_INVALIDPARAMS\n");
820 LeaveCriticalSection(&ddraw_cs);
821 return DDERR_INVALIDPARAMS;
824 /* TODO: Check if the DDBltFx contains any ddraw surface pointers. If it does, copy the struct,
825 * and replace the ddraw surfaces with the wined3d surfaces
826 * So far no blitting operations using surfaces in the bltfx struct are supported anyway.
828 hr = IWineD3DSurface_Blt(This->WineD3DSurface,
829 DestRect,
830 Src ? Src->WineD3DSurface : NULL,
831 SrcRect,
832 Flags,
833 (WINEDDBLTFX *) DDBltFx,
834 WINED3DTEXF_POINT);
836 LeaveCriticalSection(&ddraw_cs);
837 switch(hr)
839 case WINED3DERR_NOTAVAILABLE: return DDERR_UNSUPPORTED;
840 case WINED3DERR_WRONGTEXTUREFORMAT: return DDERR_INVALIDPIXELFORMAT;
841 default: return hr;
845 /*****************************************************************************
846 * IDirectDrawSurface7::AddAttachedSurface
848 * Attaches a surface to another surface. How the surface attachments work
849 * is not totally understood yet, and this method is prone to problems.
850 * he surface that is attached is AddRef-ed.
852 * Tests with complex surfaces suggest that the surface attachments form a
853 * tree, but no method to test this has been found yet.
855 * The attachment list consists of a first surface (first_attached) and
856 * for each surface a pointer to the next attached surface (next_attached).
857 * For the first surface, and a surface that has no attachments
858 * first_attached points to the surface itself. A surface that has
859 * no successors in the chain has next_attached set to NULL.
861 * Newly attached surfaces are attached right after the root surface.
862 * If a surface is attached to a complex surface compound, it's attached to
863 * the surface that the app requested, not the complex root. See
864 * GetAttachedSurface for a description how surfaces are found.
866 * This is how the current implementation works, and it was coded by looking
867 * at the needs of the applications.
869 * So far only Z-Buffer attachments are tested, and they are activated in
870 * WineD3D. Mipmaps could be tricky to activate in WineD3D.
871 * Back buffers should work in 2D mode, but they are not tested(They can be
872 * attached in older iface versions). Rendering to the front buffer and
873 * switching between that and double buffering is not yet implemented in
874 * WineD3D, so for 3D it might have unexpected results.
876 * IDirectDrawSurfaceImpl_AddAttachedSurface is the real thing,
877 * IDirectDrawSurface7Impl_AddAttachedSurface is a wrapper around it that
878 * performs additional checks. Version 7 of this interface is much more restrictive
879 * than its predecessors.
881 * Params:
882 * Attach: Surface to attach to iface
884 * Returns:
885 * DD_OK on success
886 * DDERR_CANNOTATTACHSURFACE if the surface can't be attached for some reason
888 *****************************************************************************/
889 HRESULT WINAPI
890 IDirectDrawSurfaceImpl_AddAttachedSurface(IDirectDrawSurfaceImpl *This,
891 IDirectDrawSurfaceImpl *Surf)
893 TRACE("(%p)->(%p)\n", This, Surf);
895 if(Surf == This)
896 return DDERR_CANNOTATTACHSURFACE; /* unchecked */
898 EnterCriticalSection(&ddraw_cs);
900 /* Check if the surface is already attached somewhere */
901 if( (Surf->next_attached != NULL) ||
902 (Surf->first_attached != Surf) )
904 /* TODO: Test for the structure of the manual attachment. Is it a chain or a list?
905 * What happens if one surface is attached to 2 different surfaces?
907 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);
908 LeaveCriticalSection(&ddraw_cs);
909 return DDERR_SURFACEALREADYATTACHED;
912 /* This inserts the new surface at the 2nd position in the chain, right after the root surface */
913 Surf->next_attached = This->next_attached;
914 Surf->first_attached = This->first_attached;
915 This->next_attached = Surf;
917 /* Check if the WineD3D depth stencil needs updating */
918 if(This->ddraw->d3ddevice)
920 IDirect3DDeviceImpl_UpdateDepthStencil(This->ddraw->d3ddevice);
923 IDirectDrawSurface7_AddRef((IDirectDrawSurface7 *)Surf);
924 LeaveCriticalSection(&ddraw_cs);
925 return DD_OK;
928 static HRESULT WINAPI
929 IDirectDrawSurface7Impl_AddAttachedSurface(IDirectDrawSurface7 *iface,
930 IDirectDrawSurface7 *Attach)
932 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
933 IDirectDrawSurfaceImpl *Surf = (IDirectDrawSurfaceImpl *)Attach;
935 /* Version 7 of this interface seems to refuse everything except z buffers, as per msdn */
936 if(!(Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
939 WARN("Application tries to attach a non Z buffer surface. caps %08x\n",
940 Surf->surface_desc.ddsCaps.dwCaps);
941 return DDERR_CANNOTATTACHSURFACE;
944 return IDirectDrawSurfaceImpl_AddAttachedSurface(This,
945 Surf);
947 /*****************************************************************************
948 * IDirectDrawSurface7::DeleteAttachedSurface
950 * Removes a surface from the attachment chain. The surface's refcount
951 * is decreased by one after it has been removed
953 * Params:
954 * Flags: Some flags, not used by this implementation
955 * Attach: Surface to detach
957 * Returns:
958 * DD_OK on success
959 * DDERR_SURFACENOTATTACHED if the surface isn't attached to
961 *****************************************************************************/
962 static HRESULT WINAPI
963 IDirectDrawSurfaceImpl_DeleteAttachedSurface(IDirectDrawSurface7 *iface,
964 DWORD Flags,
965 IDirectDrawSurface7 *Attach)
967 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
968 IDirectDrawSurfaceImpl *Surf = (IDirectDrawSurfaceImpl *)Attach;
969 IDirectDrawSurfaceImpl *Prev = This;
970 TRACE("(%p)->(%08x,%p)\n", This, Flags, Surf);
972 EnterCriticalSection(&ddraw_cs);
973 if (!Surf || (Surf->first_attached != This) || (Surf == This) )
975 LeaveCriticalSection(&ddraw_cs);
976 return DDERR_CANNOTDETACHSURFACE;
979 /* Remove MIPMAPSUBLEVEL if this seemed to be one */
980 if (This->surface_desc.ddsCaps.dwCaps &
981 Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
983 Surf->surface_desc.ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
984 /* FIXME: we should probably also subtract from dwMipMapCount of this
985 * and all parent surfaces */
988 /* Find the predecessor of the detached surface */
989 while(Prev)
991 if(Prev->next_attached == Surf) break;
992 Prev = Prev->next_attached;
995 /* There must be a surface, otherwise there's a bug */
996 assert(Prev != NULL);
998 /* Unchain the surface */
999 Prev->next_attached = Surf->next_attached;
1000 Surf->next_attached = NULL;
1001 Surf->first_attached = Surf;
1003 /* Check if the WineD3D depth stencil needs updating */
1004 if(This->ddraw->d3ddevice)
1006 IDirect3DDeviceImpl_UpdateDepthStencil(This->ddraw->d3ddevice);
1009 IDirectDrawSurface7_Release(Attach);
1010 LeaveCriticalSection(&ddraw_cs);
1011 return DD_OK;
1014 /*****************************************************************************
1015 * IDirectDrawSurface7::AddOverlayDirtyRect
1017 * "This method is not currently implemented"
1019 * Params:
1020 * Rect: ?
1022 * Returns:
1023 * DDERR_UNSUPPORTED
1025 *****************************************************************************/
1026 static HRESULT WINAPI
1027 IDirectDrawSurfaceImpl_AddOverlayDirtyRect(IDirectDrawSurface7 *iface,
1028 LPRECT Rect)
1030 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1031 TRACE("(%p)->(%p)\n",This,Rect);
1033 /* MSDN says it's not implemented. I could forward it to WineD3D,
1034 * then we'd implement it, but I don't think that's a good idea
1035 * (Stefan Dösinger)
1037 #if 0
1038 return IWineD3DSurface_AddOverlayDirtyRect(This->WineD3DSurface, pRect);
1039 #endif
1040 return DDERR_UNSUPPORTED; /* unchecked */
1043 /*****************************************************************************
1044 * IDirectDrawSurface7::GetDC
1046 * Returns a GDI device context for the surface
1048 * Params:
1049 * hdc: Address of a HDC variable to store the dc to
1051 * Returns:
1052 * DD_OK on success
1053 * DDERR_INVALIDPARAMS if hdc is NULL
1054 * For details, see IWineD3DSurface::GetDC
1056 *****************************************************************************/
1057 static HRESULT WINAPI
1058 IDirectDrawSurfaceImpl_GetDC(IDirectDrawSurface7 *iface,
1059 HDC *hdc)
1061 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1062 HRESULT hr;
1063 TRACE("(%p)->(%p): Relay\n", This, hdc);
1065 if(!hdc)
1066 return DDERR_INVALIDPARAMS;
1068 EnterCriticalSection(&ddraw_cs);
1069 hr = IWineD3DSurface_GetDC(This->WineD3DSurface,
1070 hdc);
1071 LeaveCriticalSection(&ddraw_cs);
1072 switch(hr)
1074 /* Some, but not all errors set *hdc to NULL. E.g. DCALREADYCREATED does not
1075 * touch *hdc
1077 case WINED3DERR_INVALIDCALL:
1078 if(hdc) *hdc = NULL;
1079 return DDERR_INVALIDPARAMS;
1081 default: return hr;
1085 /*****************************************************************************
1086 * IDirectDrawSurface7::ReleaseDC
1088 * Releases the DC that was constructed with GetDC
1090 * Params:
1091 * hdc: HDC to release
1093 * Returns:
1094 * DD_OK on success
1095 * For more details, see IWineD3DSurface::ReleaseDC
1097 *****************************************************************************/
1098 static HRESULT WINAPI
1099 IDirectDrawSurfaceImpl_ReleaseDC(IDirectDrawSurface7 *iface,
1100 HDC hdc)
1102 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1103 HRESULT hr;
1104 TRACE("(%p)->(%p): Relay\n", This, hdc);
1106 EnterCriticalSection(&ddraw_cs);
1107 hr = IWineD3DSurface_ReleaseDC(This->WineD3DSurface, hdc);
1108 LeaveCriticalSection(&ddraw_cs);
1109 return hr;
1112 /*****************************************************************************
1113 * IDirectDrawSurface7::GetCaps
1115 * Returns the surface's caps
1117 * Params:
1118 * Caps: Address to write the caps to
1120 * Returns:
1121 * DD_OK on success
1122 * DDERR_INVALIDPARAMS if Caps is NULL
1124 *****************************************************************************/
1125 static HRESULT WINAPI
1126 IDirectDrawSurfaceImpl_GetCaps(IDirectDrawSurface7 *iface,
1127 DDSCAPS2 *Caps)
1129 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1130 TRACE("(%p)->(%p)\n",This,Caps);
1132 if(!Caps)
1133 return DDERR_INVALIDPARAMS;
1135 *Caps = This->surface_desc.ddsCaps;
1136 return DD_OK;
1139 /*****************************************************************************
1140 * IDirectDrawSurface7::SetPriority
1142 * Sets a texture priority for managed textures.
1144 * Params:
1145 * Priority: The new priority
1147 * Returns:
1148 * DD_OK on success
1149 * For more details, see IWineD3DSurface::SetPriority
1151 *****************************************************************************/
1152 static HRESULT WINAPI
1153 IDirectDrawSurfaceImpl_SetPriority(IDirectDrawSurface7 *iface, DWORD Priority)
1155 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1156 HRESULT hr;
1157 TRACE("(%p)->(%d): Relay!\n",This,Priority);
1159 EnterCriticalSection(&ddraw_cs);
1160 hr = IWineD3DSurface_SetPriority(This->WineD3DSurface, Priority);
1161 LeaveCriticalSection(&ddraw_cs);
1162 return hr;
1165 /*****************************************************************************
1166 * IDirectDrawSurface7::GetPriority
1168 * Returns the surface's priority
1170 * Params:
1171 * Priority: Address of a variable to write the priority to
1173 * Returns:
1174 * D3D_OK on success
1175 * DDERR_INVALIDPARAMS if Priority == NULL
1176 * For more details, see IWineD3DSurface::GetPriority
1178 *****************************************************************************/
1179 static HRESULT WINAPI
1180 IDirectDrawSurfaceImpl_GetPriority(IDirectDrawSurface7 *iface,
1181 DWORD *Priority)
1183 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1184 TRACE("(%p)->(%p): Relay\n",This,Priority);
1186 if(!Priority)
1188 return DDERR_INVALIDPARAMS;
1191 EnterCriticalSection(&ddraw_cs);
1192 *Priority = IWineD3DSurface_GetPriority(This->WineD3DSurface);
1193 LeaveCriticalSection(&ddraw_cs);
1194 return DD_OK;
1197 /*****************************************************************************
1198 * IDirectDrawSurface7::SetPrivateData
1200 * Stores some data in the surface that is intended for the application's
1201 * use.
1203 * Params:
1204 * tag: GUID that identifies the data
1205 * Data: Pointer to the private data
1206 * Size: Size of the private data
1207 * Flags: Some flags
1209 * Returns:
1210 * D3D_OK on success
1211 * For more details, see IWineD3DSurface::SetPrivateData
1213 *****************************************************************************/
1214 static HRESULT WINAPI
1215 IDirectDrawSurfaceImpl_SetPrivateData(IDirectDrawSurface7 *iface,
1216 REFGUID tag,
1217 void *Data,
1218 DWORD Size,
1219 DWORD Flags)
1221 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1222 HRESULT hr;
1223 TRACE("(%p)->(%s,%p,%d,%x): Relay\n", This, debugstr_guid(tag), Data, Size, Flags);
1225 EnterCriticalSection(&ddraw_cs);
1226 hr = IWineD3DSurface_SetPrivateData(This->WineD3DSurface,
1227 tag,
1228 Data,
1229 Size,
1230 Flags);
1231 LeaveCriticalSection(&ddraw_cs);
1232 switch(hr)
1234 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1235 default: return hr;
1239 /*****************************************************************************
1240 * IDirectDrawSurface7::GetPrivateData
1242 * Returns the private data set with IDirectDrawSurface7::SetPrivateData
1244 * Params:
1245 * tag: GUID of the data to return
1246 * Data: Address where to write the data to
1247 * Size: Size of the buffer at Data
1249 * Returns:
1250 * DD_OK on success
1251 * DDERR_INVALIDPARAMS if Data is NULL
1252 * For more details, see IWineD3DSurface::GetPrivateData
1254 *****************************************************************************/
1255 static HRESULT WINAPI
1256 IDirectDrawSurfaceImpl_GetPrivateData(IDirectDrawSurface7 *iface,
1257 REFGUID tag,
1258 void *Data,
1259 DWORD *Size)
1261 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1262 HRESULT hr;
1263 TRACE("(%p)->(%s,%p,%p): Relay\n", This, debugstr_guid(tag), Data, Size);
1265 if(!Data)
1266 return DDERR_INVALIDPARAMS;
1268 EnterCriticalSection(&ddraw_cs);
1269 hr = IWineD3DSurface_GetPrivateData(This->WineD3DSurface,
1270 tag,
1271 Data,
1272 Size);
1273 LeaveCriticalSection(&ddraw_cs);
1274 return hr;
1277 /*****************************************************************************
1278 * IDirectDrawSurface7::FreePrivateData
1280 * Frees private data stored in the surface
1282 * Params:
1283 * tag: Tag of the data to free
1285 * Returns:
1286 * D3D_OK on success
1287 * For more details, see IWineD3DSurface::FreePrivateData
1289 *****************************************************************************/
1290 static HRESULT WINAPI
1291 IDirectDrawSurfaceImpl_FreePrivateData(IDirectDrawSurface7 *iface,
1292 REFGUID tag)
1294 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1295 HRESULT hr;
1296 TRACE("(%p)->(%s): Relay\n", This, debugstr_guid(tag));
1298 EnterCriticalSection(&ddraw_cs);
1299 hr = IWineD3DSurface_FreePrivateData(This->WineD3DSurface, tag);
1300 LeaveCriticalSection(&ddraw_cs);
1301 return hr;
1304 /*****************************************************************************
1305 * IDirectDrawSurface7::PageLock
1307 * Prevents a sysmem surface from being paged out
1309 * Params:
1310 * Flags: Not used, must be 0(unchecked)
1312 * Returns:
1313 * DD_OK, because it's a stub
1315 *****************************************************************************/
1316 static HRESULT WINAPI
1317 IDirectDrawSurfaceImpl_PageLock(IDirectDrawSurface7 *iface,
1318 DWORD Flags)
1320 TRACE("(%p)->(%x)\n", iface, Flags);
1322 /* This is Windows memory management related - we don't need this */
1323 return DD_OK;
1326 /*****************************************************************************
1327 * IDirectDrawSurface7::PageUnlock
1329 * Allows a sysmem surface to be paged out
1331 * Params:
1332 * Flags: Not used, must be 0(unchecked)
1334 * Returns:
1335 * DD_OK, because it's a stub
1337 *****************************************************************************/
1338 static HRESULT WINAPI
1339 IDirectDrawSurfaceImpl_PageUnlock(IDirectDrawSurface7 *iface,
1340 DWORD Flags)
1342 TRACE("(%p)->(%x)\n", iface, Flags);
1344 return DD_OK;
1347 /*****************************************************************************
1348 * IDirectDrawSurface7::BltBatch
1350 * An unimplemented function
1352 * Params:
1355 * Returns:
1356 * DDERR_UNSUPPORTED
1358 *****************************************************************************/
1359 static HRESULT WINAPI IDirectDrawSurfaceImpl_BltBatch(IDirectDrawSurface7 *iface, DDBLTBATCH *Batch, DWORD Count, DWORD Flags)
1361 TRACE("(%p)->(%p,%d,%08x)\n",iface,Batch,Count,Flags);
1363 /* MSDN: "not currently implemented" */
1364 return DDERR_UNSUPPORTED;
1367 /*****************************************************************************
1368 * IDirectDrawSurface7::EnumAttachedSurfaces
1370 * Enumerates all surfaces attached to this surface
1372 * Params:
1373 * context: Pointer to pass unmodified to the callback
1374 * cb: Callback function to call for each surface
1376 * Returns:
1377 * DD_OK on success
1378 * DDERR_INVALIDPARAMS if cb is NULL
1380 *****************************************************************************/
1381 static HRESULT WINAPI
1382 IDirectDrawSurfaceImpl_EnumAttachedSurfaces(IDirectDrawSurface7 *iface,
1383 void *context,
1384 LPDDENUMSURFACESCALLBACK7 cb)
1386 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1387 IDirectDrawSurfaceImpl *surf;
1388 DDSURFACEDESC2 desc;
1389 int i;
1391 /* Attached surfaces aren't handled in WineD3D */
1392 TRACE("(%p)->(%p,%p)\n",This,context,cb);
1394 if(!cb)
1395 return DDERR_INVALIDPARAMS;
1397 EnterCriticalSection(&ddraw_cs);
1398 for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
1400 surf = This->complex_array[i];
1401 if(!surf) break;
1403 IDirectDrawSurface7_AddRef((IDirectDrawSurface7 *)surf);
1404 desc = surf->surface_desc;
1405 /* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
1406 if (cb((IDirectDrawSurface7 *)surf, &desc, context) == DDENUMRET_CANCEL)
1408 LeaveCriticalSection(&ddraw_cs);
1409 return DD_OK;
1413 for (surf = This->next_attached; surf != NULL; surf = surf->next_attached)
1415 IDirectDrawSurface7_AddRef((IDirectDrawSurface7 *)surf);
1416 desc = surf->surface_desc;
1417 /* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
1418 if (cb((IDirectDrawSurface7 *)surf, &desc, context) == DDENUMRET_CANCEL)
1420 LeaveCriticalSection(&ddraw_cs);
1421 return DD_OK;
1425 TRACE(" end of enumeration.\n");
1427 LeaveCriticalSection(&ddraw_cs);
1428 return DD_OK;
1431 /*****************************************************************************
1432 * IDirectDrawSurface7::EnumOverlayZOrders
1434 * "Enumerates the overlay surfaces on the specified destination"
1436 * Params:
1437 * Flags: DDENUMOVERLAYZ_BACKTOFRONT or DDENUMOVERLAYZ_FRONTTOBACK
1438 * context: context to pass back to the callback
1439 * cb: callback function to call for each enumerated surface
1441 * Returns:
1442 * DD_OK, because it's a stub
1444 *****************************************************************************/
1445 static HRESULT WINAPI
1446 IDirectDrawSurfaceImpl_EnumOverlayZOrders(IDirectDrawSurface7 *iface,
1447 DWORD Flags,
1448 void *context,
1449 LPDDENUMSURFACESCALLBACK7 cb)
1451 FIXME("(%p)->(%x,%p,%p): Stub!\n", iface, Flags, context, cb);
1453 return DD_OK;
1456 /*****************************************************************************
1457 * IDirectDrawSurface7::GetBltStatus
1459 * Returns the blitting status
1461 * Params:
1462 * Flags: DDGBS_CANBLT or DDGBS_ISBLTDONE
1464 * Returns:
1465 * See IWineD3DSurface::Blt
1467 *****************************************************************************/
1468 static HRESULT WINAPI
1469 IDirectDrawSurfaceImpl_GetBltStatus(IDirectDrawSurface7 *iface,
1470 DWORD Flags)
1472 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1473 HRESULT hr;
1474 TRACE("(%p)->(%x): Relay\n", This, Flags);
1476 EnterCriticalSection(&ddraw_cs);
1477 hr = IWineD3DSurface_GetBltStatus(This->WineD3DSurface, Flags);
1478 LeaveCriticalSection(&ddraw_cs);
1479 switch(hr)
1481 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1482 default: return hr;
1486 /*****************************************************************************
1487 * IDirectDrawSurface7::GetColorKey
1489 * Returns the color key assigned to the surface
1491 * Params:
1492 * Flags: Some flags
1493 * CKey: Address to store the key to
1495 * Returns:
1496 * DD_OK on success
1497 * DDERR_INVALIDPARAMS if CKey is NULL
1499 *****************************************************************************/
1500 static HRESULT WINAPI
1501 IDirectDrawSurfaceImpl_GetColorKey(IDirectDrawSurface7 *iface,
1502 DWORD Flags,
1503 DDCOLORKEY *CKey)
1505 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1506 TRACE("(%p)->(%08x,%p)\n", This, Flags, CKey);
1508 if(!CKey)
1509 return DDERR_INVALIDPARAMS;
1511 EnterCriticalSection(&ddraw_cs);
1513 switch (Flags)
1515 case DDCKEY_DESTBLT:
1516 if (!(This->surface_desc.dwFlags & DDSD_CKDESTBLT))
1518 LeaveCriticalSection(&ddraw_cs);
1519 return DDERR_NOCOLORKEY;
1521 *CKey = This->surface_desc.ddckCKDestBlt;
1522 break;
1524 case DDCKEY_DESTOVERLAY:
1525 if (!(This->surface_desc.dwFlags & DDSD_CKDESTOVERLAY))
1527 LeaveCriticalSection(&ddraw_cs);
1528 return DDERR_NOCOLORKEY;
1530 *CKey = This->surface_desc.u3.ddckCKDestOverlay;
1531 break;
1533 case DDCKEY_SRCBLT:
1534 if (!(This->surface_desc.dwFlags & DDSD_CKSRCBLT))
1536 LeaveCriticalSection(&ddraw_cs);
1537 return DDERR_NOCOLORKEY;
1539 *CKey = This->surface_desc.ddckCKSrcBlt;
1540 break;
1542 case DDCKEY_SRCOVERLAY:
1543 if (!(This->surface_desc.dwFlags & DDSD_CKSRCOVERLAY))
1545 LeaveCriticalSection(&ddraw_cs);
1546 return DDERR_NOCOLORKEY;
1548 *CKey = This->surface_desc.ddckCKSrcOverlay;
1549 break;
1551 default:
1552 LeaveCriticalSection(&ddraw_cs);
1553 return DDERR_INVALIDPARAMS;
1556 LeaveCriticalSection(&ddraw_cs);
1557 return DD_OK;
1560 /*****************************************************************************
1561 * IDirectDrawSurface7::GetFlipStatus
1563 * Returns the flipping status of the surface
1565 * Params:
1566 * Flags: DDGFS_CANFLIP of DDGFS_ISFLIPDONE
1568 * Returns:
1569 * See IWineD3DSurface::GetFlipStatus
1571 *****************************************************************************/
1572 static HRESULT WINAPI
1573 IDirectDrawSurfaceImpl_GetFlipStatus(IDirectDrawSurface7 *iface,
1574 DWORD Flags)
1576 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1577 HRESULT hr;
1578 TRACE("(%p)->(%x): Relay\n", This, Flags);
1580 EnterCriticalSection(&ddraw_cs);
1581 hr = IWineD3DSurface_GetFlipStatus(This->WineD3DSurface, Flags);
1582 LeaveCriticalSection(&ddraw_cs);
1583 switch(hr)
1585 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1586 default: return hr;
1590 /*****************************************************************************
1591 * IDirectDrawSurface7::GetOverlayPosition
1593 * Returns the display coordinates of a visible and active overlay surface
1595 * Params:
1599 * Returns:
1600 * DDERR_NOTAOVERLAYSURFACE, because it's a stub
1601 *****************************************************************************/
1602 static HRESULT WINAPI
1603 IDirectDrawSurfaceImpl_GetOverlayPosition(IDirectDrawSurface7 *iface,
1604 LONG *X,
1605 LONG *Y) {
1606 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1607 HRESULT hr;
1608 TRACE("(%p)->(%p,%p): Relay\n", This, X, Y);
1610 EnterCriticalSection(&ddraw_cs);
1611 hr = IWineD3DSurface_GetOverlayPosition(This->WineD3DSurface,
1614 LeaveCriticalSection(&ddraw_cs);
1615 return hr;
1618 /*****************************************************************************
1619 * IDirectDrawSurface7::GetPixelFormat
1621 * Returns the pixel format of the Surface
1623 * Params:
1624 * PixelFormat: Pointer to a DDPIXELFORMAT structure to which the pixel
1625 * format should be written
1627 * Returns:
1628 * DD_OK on success
1629 * DDERR_INVALIDPARAMS if PixelFormat is NULL
1631 *****************************************************************************/
1632 static HRESULT WINAPI
1633 IDirectDrawSurfaceImpl_GetPixelFormat(IDirectDrawSurface7 *iface,
1634 DDPIXELFORMAT *PixelFormat)
1636 /* What is DDERR_INVALIDSURFACETYPE for here? */
1637 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1638 TRACE("(%p)->(%p)\n",This,PixelFormat);
1640 if(!PixelFormat)
1641 return DDERR_INVALIDPARAMS;
1643 EnterCriticalSection(&ddraw_cs);
1644 DD_STRUCT_COPY_BYSIZE(PixelFormat,&This->surface_desc.u4.ddpfPixelFormat);
1645 LeaveCriticalSection(&ddraw_cs);
1647 return DD_OK;
1651 /*****************************************************************************
1652 * IDirectDrawSurface7::GetSurfaceDesc
1654 * Returns the description of this surface
1656 * Params:
1657 * DDSD: Address of a DDSURFACEDESC2 structure that is to be filled with the
1658 * surface desc
1660 * Returns:
1661 * DD_OK on success
1662 * DDERR_INVALIDPARAMS if DDSD is NULL
1664 *****************************************************************************/
1665 static HRESULT WINAPI
1666 IDirectDrawSurfaceImpl_GetSurfaceDesc(IDirectDrawSurface7 *iface,
1667 DDSURFACEDESC2 *DDSD)
1669 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1671 TRACE("(%p)->(%p)\n",This,DDSD);
1673 if(!DDSD)
1674 return DDERR_INVALIDPARAMS;
1676 if (DDSD->dwSize != sizeof(DDSURFACEDESC2))
1678 WARN("Incorrect struct size %d, returning DDERR_INVALIDPARAMS\n",DDSD->dwSize);
1679 return DDERR_INVALIDPARAMS;
1682 EnterCriticalSection(&ddraw_cs);
1683 DD_STRUCT_COPY_BYSIZE(DDSD,&This->surface_desc);
1684 TRACE("Returning surface desc:\n");
1685 if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD);
1687 LeaveCriticalSection(&ddraw_cs);
1688 return DD_OK;
1691 /*****************************************************************************
1692 * IDirectDrawSurface7::Initialize
1694 * Initializes the surface. This is a no-op in Wine
1696 * Params:
1697 * DD: Pointer to an DirectDraw interface
1698 * DDSD: Surface description for initialization
1700 * Returns:
1701 * DDERR_ALREADYINITIALIZED
1703 *****************************************************************************/
1704 static HRESULT WINAPI
1705 IDirectDrawSurfaceImpl_Initialize(IDirectDrawSurface7 *iface,
1706 IDirectDraw *DD,
1707 DDSURFACEDESC2 *DDSD)
1709 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1710 IDirectDrawImpl *ddimpl = DD ? ddraw_from_ddraw1(DD) : NULL;
1711 TRACE("(%p)->(%p,%p)\n",This,ddimpl,DDSD);
1713 return DDERR_ALREADYINITIALIZED;
1716 /*****************************************************************************
1717 * IDirectDrawSurface7::IsLost
1719 * Checks if the surface is lost
1721 * Returns:
1722 * DD_OK, if the surface is usable
1723 * DDERR_ISLOST if the surface is lost
1724 * See IWineD3DSurface::IsLost for more details
1726 *****************************************************************************/
1727 static HRESULT WINAPI
1728 IDirectDrawSurfaceImpl_IsLost(IDirectDrawSurface7 *iface)
1730 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1731 HRESULT hr;
1732 TRACE("(%p)\n", This);
1734 EnterCriticalSection(&ddraw_cs);
1735 /* We lose the surface if the implementation was changed */
1736 if(This->ImplType != This->ddraw->ImplType)
1738 /* But this shouldn't happen. When we change the implementation,
1739 * all surfaces are re-created automatically, and their content
1740 * is copied
1742 ERR(" (%p) Implementation was changed from %d to %d\n", This, This->ImplType, This->ddraw->ImplType);
1743 LeaveCriticalSection(&ddraw_cs);
1744 return DDERR_SURFACELOST;
1747 hr = IWineD3DSurface_IsLost(This->WineD3DSurface);
1748 LeaveCriticalSection(&ddraw_cs);
1749 switch(hr)
1751 /* D3D8 and 9 loose full devices, thus there's only a DEVICELOST error.
1752 * WineD3D uses the same error for surfaces
1754 case WINED3DERR_DEVICELOST: return DDERR_SURFACELOST;
1755 default: return hr;
1759 /*****************************************************************************
1760 * IDirectDrawSurface7::Restore
1762 * Restores a lost surface. This makes the surface usable again, but
1763 * doesn't reload its old contents
1765 * Returns:
1766 * DD_OK on success
1767 * See IWineD3DSurface::Restore for more details
1769 *****************************************************************************/
1770 static HRESULT WINAPI
1771 IDirectDrawSurfaceImpl_Restore(IDirectDrawSurface7 *iface)
1773 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1774 HRESULT hr;
1775 TRACE("(%p)\n", This);
1777 EnterCriticalSection(&ddraw_cs);
1778 if(This->ImplType != This->ddraw->ImplType)
1780 /* Call the recreation callback. Make sure to AddRef first */
1781 IDirectDrawSurface_AddRef(iface);
1782 IDirectDrawImpl_RecreateSurfacesCallback(iface,
1783 &This->surface_desc,
1784 NULL /* Not needed */);
1786 hr = IWineD3DSurface_Restore(This->WineD3DSurface);
1787 LeaveCriticalSection(&ddraw_cs);
1788 return hr;
1791 /*****************************************************************************
1792 * IDirectDrawSurface7::SetOverlayPosition
1794 * Changes the display coordinates of an overlay surface
1796 * Params:
1797 * X:
1798 * Y:
1800 * Returns:
1801 * DDERR_NOTAOVERLAYSURFACE, because we don't support overlays right now
1802 *****************************************************************************/
1803 static HRESULT WINAPI
1804 IDirectDrawSurfaceImpl_SetOverlayPosition(IDirectDrawSurface7 *iface,
1805 LONG X,
1806 LONG Y)
1808 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1809 HRESULT hr;
1810 TRACE("(%p)->(%d,%d): Relay\n", This, X, Y);
1812 EnterCriticalSection(&ddraw_cs);
1813 hr = IWineD3DSurface_SetOverlayPosition(This->WineD3DSurface,
1816 LeaveCriticalSection(&ddraw_cs);
1817 return hr;
1820 /*****************************************************************************
1821 * IDirectDrawSurface7::UpdateOverlay
1823 * Modifies the attributes of an overlay surface.
1825 * Params:
1826 * SrcRect: The section of the source being used for the overlay
1827 * DstSurface: Address of the surface that is overlaid
1828 * DstRect: Place of the overlay
1829 * Flags: some DDOVER_* flags
1831 * Returns:
1832 * DDERR_UNSUPPORTED, because we don't support overlays
1834 *****************************************************************************/
1835 static HRESULT WINAPI
1836 IDirectDrawSurfaceImpl_UpdateOverlay(IDirectDrawSurface7 *iface,
1837 LPRECT SrcRect,
1838 IDirectDrawSurface7 *DstSurface,
1839 LPRECT DstRect,
1840 DWORD Flags,
1841 LPDDOVERLAYFX FX)
1843 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1844 IDirectDrawSurfaceImpl *Dst = (IDirectDrawSurfaceImpl *)DstSurface;
1845 HRESULT hr;
1846 TRACE("(%p)->(%p,%p,%p,%x,%p): Relay\n", This, SrcRect, Dst, DstRect, Flags, FX);
1848 EnterCriticalSection(&ddraw_cs);
1849 hr = IWineD3DSurface_UpdateOverlay(This->WineD3DSurface,
1850 SrcRect,
1851 Dst ? Dst->WineD3DSurface : NULL,
1852 DstRect,
1853 Flags,
1854 (WINEDDOVERLAYFX *) FX);
1855 LeaveCriticalSection(&ddraw_cs);
1856 switch(hr) {
1857 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1858 case WINEDDERR_NOTAOVERLAYSURFACE: return DDERR_NOTAOVERLAYSURFACE;
1859 case WINEDDERR_OVERLAYNOTVISIBLE: return DDERR_OVERLAYNOTVISIBLE;
1860 default:
1861 return hr;
1865 /*****************************************************************************
1866 * IDirectDrawSurface7::UpdateOverlayDisplay
1868 * The DX7 sdk says that it's not implemented
1870 * Params:
1871 * Flags: ?
1873 * Returns: DDERR_UNSUPPORTED, because we don't support overlays
1875 *****************************************************************************/
1876 static HRESULT WINAPI
1877 IDirectDrawSurfaceImpl_UpdateOverlayDisplay(IDirectDrawSurface7 *iface,
1878 DWORD Flags)
1880 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1881 TRACE("(%p)->(%x)\n", This, Flags);
1882 return DDERR_UNSUPPORTED;
1885 /*****************************************************************************
1886 * IDirectDrawSurface7::UpdateOverlayZOrder
1888 * Sets an overlay's Z order
1890 * Params:
1891 * Flags: DDOVERZ_* flags
1892 * DDSRef: Defines the relative position in the overlay chain
1894 * Returns:
1895 * DDERR_NOTOVERLAYSURFACE, because we don't support overlays
1897 *****************************************************************************/
1898 static HRESULT WINAPI
1899 IDirectDrawSurfaceImpl_UpdateOverlayZOrder(IDirectDrawSurface7 *iface,
1900 DWORD Flags,
1901 IDirectDrawSurface7 *DDSRef)
1903 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1904 IDirectDrawSurfaceImpl *Ref = (IDirectDrawSurfaceImpl *)DDSRef;
1905 HRESULT hr;
1907 TRACE("(%p)->(%x,%p): Relay\n", This, Flags, Ref);
1908 EnterCriticalSection(&ddraw_cs);
1909 hr = IWineD3DSurface_UpdateOverlayZOrder(This->WineD3DSurface,
1910 Flags,
1911 Ref ? Ref->WineD3DSurface : NULL);
1912 LeaveCriticalSection(&ddraw_cs);
1913 return hr;
1916 /*****************************************************************************
1917 * IDirectDrawSurface7::GetDDInterface
1919 * Returns the IDirectDraw7 interface pointer of the DirectDraw object this
1920 * surface belongs to
1922 * Params:
1923 * DD: Address to write the interface pointer to
1925 * Returns:
1926 * DD_OK on success
1927 * DDERR_INVALIDPARAMS if DD is NULL
1929 *****************************************************************************/
1930 static HRESULT WINAPI
1931 IDirectDrawSurfaceImpl_GetDDInterface(IDirectDrawSurface7 *iface,
1932 void **DD)
1934 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1936 TRACE("(%p)->(%p)\n",This,DD);
1938 if(!DD)
1939 return DDERR_INVALIDPARAMS;
1941 switch(This->version)
1943 case 7:
1944 *DD = This->ddraw;
1945 break;
1947 case 4:
1948 *DD = &This->ddraw->IDirectDraw4_vtbl;
1949 break;
1951 case 2:
1952 *DD = &This->ddraw->IDirectDraw2_vtbl;
1953 break;
1955 case 1:
1956 *DD = &This->ddraw->IDirectDraw_vtbl;
1957 break;
1960 IUnknown_AddRef((IUnknown *)*DD);
1962 return DD_OK;
1965 /* This seems also windows implementation specific - I don't think WineD3D needs this */
1966 static HRESULT WINAPI IDirectDrawSurfaceImpl_ChangeUniquenessValue(IDirectDrawSurface7 *iface)
1968 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1969 volatile IDirectDrawSurfaceImpl* vThis = This;
1971 TRACE("(%p)\n",This);
1972 EnterCriticalSection(&ddraw_cs);
1973 /* A uniqueness value of 0 is apparently special.
1974 * This needs to be checked.
1975 * TODO: Write tests for this code and check if the volatile, interlocked stuff is really needed
1977 while (1) {
1978 DWORD old_uniqueness_value = vThis->uniqueness_value;
1979 DWORD new_uniqueness_value = old_uniqueness_value+1;
1981 if (old_uniqueness_value == 0) break;
1982 if (new_uniqueness_value == 0) new_uniqueness_value = 1;
1984 if (InterlockedCompareExchange((LONG*)&vThis->uniqueness_value,
1985 old_uniqueness_value,
1986 new_uniqueness_value)
1987 == old_uniqueness_value)
1988 break;
1991 LeaveCriticalSection(&ddraw_cs);
1992 return DD_OK;
1995 static HRESULT WINAPI IDirectDrawSurfaceImpl_GetUniquenessValue(IDirectDrawSurface7 *iface, LPDWORD pValue)
1997 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
1999 TRACE("(%p)->(%p)\n",This,pValue);
2000 EnterCriticalSection(&ddraw_cs);
2001 *pValue = This->uniqueness_value;
2002 LeaveCriticalSection(&ddraw_cs);
2003 return DD_OK;
2006 /*****************************************************************************
2007 * IDirectDrawSurface7::SetLOD
2009 * Sets the level of detail of a texture
2011 * Params:
2012 * MaxLOD: LOD to set
2014 * Returns:
2015 * DD_OK on success
2016 * DDERR_INVALIDOBJECT if the surface is invalid for this method
2018 *****************************************************************************/
2019 static HRESULT WINAPI
2020 IDirectDrawSurfaceImpl_SetLOD(IDirectDrawSurface7 *iface,
2021 DWORD MaxLOD)
2023 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
2024 HRESULT hr;
2025 TRACE("(%p)->(%d)\n", This, MaxLOD);
2027 EnterCriticalSection(&ddraw_cs);
2028 if (!(This->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE))
2030 LeaveCriticalSection(&ddraw_cs);
2031 return DDERR_INVALIDOBJECT;
2034 if(!This->wineD3DTexture)
2036 ERR("(%p) The DirectDraw texture has no WineD3DTexture!\n", This);
2037 LeaveCriticalSection(&ddraw_cs);
2038 return DDERR_INVALIDOBJECT;
2041 hr = IWineD3DBaseTexture_SetLOD(This->wineD3DTexture,
2042 MaxLOD);
2043 LeaveCriticalSection(&ddraw_cs);
2044 return hr;
2047 /*****************************************************************************
2048 * IDirectDrawSurface7::GetLOD
2050 * Returns the level of detail of a Direct3D texture
2052 * Params:
2053 * MaxLOD: Address to write the LOD to
2055 * Returns:
2056 * DD_OK on success
2057 * DDERR_INVALIDPARAMS if MaxLOD is NULL
2058 * DDERR_INVALIDOBJECT if the surface is invalid for this method
2060 *****************************************************************************/
2061 static HRESULT WINAPI
2062 IDirectDrawSurfaceImpl_GetLOD(IDirectDrawSurface7 *iface,
2063 DWORD *MaxLOD)
2065 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
2066 TRACE("(%p)->(%p)\n", This, MaxLOD);
2068 if(!MaxLOD)
2069 return DDERR_INVALIDPARAMS;
2071 EnterCriticalSection(&ddraw_cs);
2072 if (!(This->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE))
2074 LeaveCriticalSection(&ddraw_cs);
2075 return DDERR_INVALIDOBJECT;
2078 *MaxLOD = IWineD3DBaseTexture_GetLOD(This->wineD3DTexture);
2079 LeaveCriticalSection(&ddraw_cs);
2080 return DD_OK;
2083 /*****************************************************************************
2084 * IDirectDrawSurface7::BltFast
2086 * Performs a fast Blit.
2088 * Params:
2089 * dstx: The x coordinate to blit to on the destination
2090 * dsty: The y coordinate to blit to on the destination
2091 * Source: The source surface
2092 * rsrc: The source rectangle
2093 * trans: Type of transfer. Some DDBLTFAST_* flags
2095 * Returns:
2096 * DD_OK on success
2097 * For more details, see IWineD3DSurface::BltFast
2099 *****************************************************************************/
2100 static HRESULT WINAPI
2101 IDirectDrawSurfaceImpl_BltFast(IDirectDrawSurface7 *iface,
2102 DWORD dstx,
2103 DWORD dsty,
2104 IDirectDrawSurface7 *Source,
2105 RECT *rsrc,
2106 DWORD trans)
2108 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
2109 IDirectDrawSurfaceImpl *src = (IDirectDrawSurfaceImpl *)Source;
2110 HRESULT hr;
2111 TRACE("(%p)->(%d,%d,%p,%p,%d): Relay\n", This, dstx, dsty, Source, rsrc, trans);
2113 /* Source must be != NULL, This is not checked by windows. Windows happily throws a 0xc0000005
2114 * in that case
2116 if(rsrc)
2118 if(rsrc->top > rsrc->bottom || rsrc->left > rsrc->right ||
2119 rsrc->right > src->surface_desc.dwWidth ||
2120 rsrc->bottom > src->surface_desc.dwHeight)
2122 WARN("Source rectangle is invalid, returning DDERR_INVALIDRECT\n");
2123 return DDERR_INVALIDRECT;
2125 if(dstx + rsrc->right - rsrc->left > This->surface_desc.dwWidth ||
2126 dsty + rsrc->bottom - rsrc->top > This->surface_desc.dwHeight)
2128 WARN("Destination area out of bounds, returning DDERR_INVALIDRECT\n");
2129 return DDERR_INVALIDRECT;
2132 else
2134 if(dstx + src->surface_desc.dwWidth > This->surface_desc.dwWidth ||
2135 dsty + src->surface_desc.dwHeight > This->surface_desc.dwHeight)
2137 WARN("Destination area out of bounds, returning DDERR_INVALIDRECT\n");
2138 return DDERR_INVALIDRECT;
2142 EnterCriticalSection(&ddraw_cs);
2143 hr = IWineD3DSurface_BltFast(This->WineD3DSurface,
2144 dstx, dsty,
2145 src ? src->WineD3DSurface : NULL,
2146 rsrc,
2147 trans);
2148 LeaveCriticalSection(&ddraw_cs);
2149 switch(hr)
2151 case WINED3DERR_NOTAVAILABLE: return DDERR_UNSUPPORTED;
2152 case WINED3DERR_WRONGTEXTUREFORMAT: return DDERR_INVALIDPIXELFORMAT;
2153 default: return hr;
2157 /*****************************************************************************
2158 * IDirectDrawSurface7::GetClipper
2160 * Returns the IDirectDrawClipper interface of the clipper assigned to this
2161 * surface
2163 * Params:
2164 * Clipper: Address to store the interface pointer at
2166 * Returns:
2167 * DD_OK on success
2168 * DDERR_INVALIDPARAMS if Clipper is NULL
2169 * DDERR_NOCLIPPERATTACHED if there's no clipper attached
2171 *****************************************************************************/
2172 static HRESULT WINAPI
2173 IDirectDrawSurfaceImpl_GetClipper(IDirectDrawSurface7 *iface,
2174 IDirectDrawClipper **Clipper)
2176 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
2177 TRACE("(%p)->(%p)\n", This, Clipper);
2179 if(!Clipper)
2181 LeaveCriticalSection(&ddraw_cs);
2182 return DDERR_INVALIDPARAMS;
2185 EnterCriticalSection(&ddraw_cs);
2186 if(This->clipper == NULL)
2188 LeaveCriticalSection(&ddraw_cs);
2189 return DDERR_NOCLIPPERATTACHED;
2192 *Clipper = (IDirectDrawClipper *)This->clipper;
2193 IDirectDrawClipper_AddRef(*Clipper);
2194 LeaveCriticalSection(&ddraw_cs);
2195 return DD_OK;
2198 /*****************************************************************************
2199 * IDirectDrawSurface7::SetClipper
2201 * Sets a clipper for the surface
2203 * Params:
2204 * Clipper: IDirectDrawClipper interface of the clipper to set
2206 * Returns:
2207 * DD_OK on success
2209 *****************************************************************************/
2210 static HRESULT WINAPI
2211 IDirectDrawSurfaceImpl_SetClipper(IDirectDrawSurface7 *iface,
2212 IDirectDrawClipper *Clipper)
2214 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
2215 IDirectDrawClipperImpl *oldClipper = This->clipper;
2216 HWND clipWindow;
2217 HRESULT hr;
2218 TRACE("(%p)->(%p)\n",This,Clipper);
2220 EnterCriticalSection(&ddraw_cs);
2221 if ((IDirectDrawClipperImpl *)Clipper == This->clipper)
2223 LeaveCriticalSection(&ddraw_cs);
2224 return DD_OK;
2227 This->clipper = (IDirectDrawClipperImpl *)Clipper;
2229 if (Clipper != NULL)
2230 IDirectDrawClipper_AddRef(Clipper);
2231 if(oldClipper)
2232 IDirectDrawClipper_Release((IDirectDrawClipper *)oldClipper);
2234 hr = IWineD3DSurface_SetClipper(This->WineD3DSurface, This->clipper ? This->clipper->wineD3DClipper : NULL);
2236 if(This->wineD3DSwapChain) {
2237 clipWindow = NULL;
2238 if(Clipper) {
2239 IDirectDrawClipper_GetHWnd(Clipper, &clipWindow);
2242 if(clipWindow) {
2243 IWineD3DSwapChain_SetDestWindowOverride(This->wineD3DSwapChain,
2244 clipWindow);
2245 } else {
2246 IWineD3DSwapChain_SetDestWindowOverride(This->wineD3DSwapChain,
2247 This->ddraw->d3d_window);
2251 LeaveCriticalSection(&ddraw_cs);
2252 return hr;
2255 /*****************************************************************************
2256 * IDirectDrawSurface7::SetSurfaceDesc
2258 * Sets the surface description. It can override the pixel format, the surface
2259 * memory, ...
2260 * It's not really tested.
2262 * Params:
2263 * DDSD: Pointer to the new surface description to set
2264 * Flags: Some flags
2266 * Returns:
2267 * DD_OK on success
2268 * DDERR_INVALIDPARAMS if DDSD is NULL
2270 *****************************************************************************/
2271 static HRESULT WINAPI
2272 IDirectDrawSurfaceImpl_SetSurfaceDesc(IDirectDrawSurface7 *iface,
2273 DDSURFACEDESC2 *DDSD,
2274 DWORD Flags)
2276 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
2277 WINED3DFORMAT newFormat = WINED3DFMT_UNKNOWN;
2278 HRESULT hr;
2279 TRACE("(%p)->(%p,%x)\n", This, DDSD, Flags);
2281 if(!DDSD)
2282 return DDERR_INVALIDPARAMS;
2284 EnterCriticalSection(&ddraw_cs);
2285 if (DDSD->dwFlags & DDSD_PIXELFORMAT)
2287 newFormat = PixelFormat_DD2WineD3D(&DDSD->u4.ddpfPixelFormat);
2289 if(newFormat == WINED3DFMT_UNKNOWN)
2291 ERR("Requested to set an unknown pixelformat\n");
2292 LeaveCriticalSection(&ddraw_cs);
2293 return DDERR_INVALIDPARAMS;
2295 if(newFormat != PixelFormat_DD2WineD3D(&This->surface_desc.u4.ddpfPixelFormat) )
2297 hr = IWineD3DSurface_SetFormat(This->WineD3DSurface,
2298 newFormat);
2299 if(hr != DD_OK)
2301 LeaveCriticalSection(&ddraw_cs);
2302 return hr;
2306 if (DDSD->dwFlags & DDSD_CKDESTOVERLAY)
2308 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2309 DDCKEY_DESTOVERLAY,
2310 (WINEDDCOLORKEY *) &DDSD->u3.ddckCKDestOverlay);
2312 if (DDSD->dwFlags & DDSD_CKDESTBLT)
2314 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2315 DDCKEY_DESTBLT,
2316 (WINEDDCOLORKEY *) &DDSD->ddckCKDestBlt);
2318 if (DDSD->dwFlags & DDSD_CKSRCOVERLAY)
2320 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2321 DDCKEY_SRCOVERLAY,
2322 (WINEDDCOLORKEY *) &DDSD->ddckCKSrcOverlay);
2324 if (DDSD->dwFlags & DDSD_CKSRCBLT)
2326 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2327 DDCKEY_SRCBLT,
2328 (WINEDDCOLORKEY *) &DDSD->ddckCKSrcBlt);
2330 if (DDSD->dwFlags & DDSD_LPSURFACE && DDSD->lpSurface)
2332 hr = IWineD3DSurface_SetMem(This->WineD3DSurface, DDSD->lpSurface);
2333 if(hr != WINED3D_OK)
2335 /* No need for a trace here, wined3d does that for us */
2336 switch(hr)
2338 case WINED3DERR_INVALIDCALL:
2339 LeaveCriticalSection(&ddraw_cs);
2340 return DDERR_INVALIDPARAMS;
2341 default:
2342 break; /* Go on */
2347 This->surface_desc = *DDSD;
2349 LeaveCriticalSection(&ddraw_cs);
2350 return DD_OK;
2353 /*****************************************************************************
2354 * IDirectDrawSurface7::GetPalette
2356 * Returns the IDirectDrawPalette interface of the palette currently assigned
2357 * to the surface
2359 * Params:
2360 * Pal: Address to write the interface pointer to
2362 * Returns:
2363 * DD_OK on success
2364 * DDERR_INVALIDPARAMS if Pal is NULL
2366 *****************************************************************************/
2367 static HRESULT WINAPI
2368 IDirectDrawSurfaceImpl_GetPalette(IDirectDrawSurface7 *iface,
2369 IDirectDrawPalette **Pal)
2371 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
2372 IWineD3DPalette *wPal;
2373 HRESULT hr;
2374 TRACE("(%p)->(%p): Relay\n", This, Pal);
2376 if(!Pal)
2377 return DDERR_INVALIDPARAMS;
2379 EnterCriticalSection(&ddraw_cs);
2380 hr = IWineD3DSurface_GetPalette(This->WineD3DSurface, &wPal);
2381 if(hr != DD_OK)
2383 LeaveCriticalSection(&ddraw_cs);
2384 return hr;
2387 if(wPal)
2389 hr = IWineD3DPalette_GetParent(wPal, (IUnknown **) Pal);
2391 else
2393 *Pal = NULL;
2394 hr = DDERR_NOPALETTEATTACHED;
2397 LeaveCriticalSection(&ddraw_cs);
2398 return hr;
2401 /*****************************************************************************
2402 * SetColorKeyEnum
2404 * EnumAttachedSurface callback for SetColorKey. Used to set color keys
2405 * recursively in the surface tree
2407 *****************************************************************************/
2408 struct SCKContext
2410 HRESULT ret;
2411 WINEDDCOLORKEY *CKey;
2412 DWORD Flags;
2415 static HRESULT WINAPI
2416 SetColorKeyEnum(IDirectDrawSurface7 *surface,
2417 DDSURFACEDESC2 *desc,
2418 void *context)
2420 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)surface;
2421 struct SCKContext *ctx = context;
2422 HRESULT hr;
2424 hr = IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2425 ctx->Flags,
2426 ctx->CKey);
2427 if(hr != DD_OK)
2429 WARN("IWineD3DSurface_SetColorKey failed, hr = %08x\n", hr);
2430 ctx->ret = hr;
2433 IDirectDrawSurface7_EnumAttachedSurfaces(surface,
2434 context,
2435 SetColorKeyEnum);
2436 IDirectDrawSurface7_Release(surface);
2437 return DDENUMRET_OK;
2440 /*****************************************************************************
2441 * IDirectDrawSurface7::SetColorKey
2443 * Sets the color keying options for the surface. Observations showed that
2444 * in case of complex surfaces the color key has to be assigned to all
2445 * sublevels.
2447 * Params:
2448 * Flags: DDCKEY_*
2449 * CKey: The new color key
2451 * Returns:
2452 * DD_OK on success
2453 * See IWineD3DSurface::SetColorKey for details
2455 *****************************************************************************/
2456 static HRESULT WINAPI
2457 IDirectDrawSurfaceImpl_SetColorKey(IDirectDrawSurface7 *iface,
2458 DWORD Flags,
2459 DDCOLORKEY *CKey)
2461 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
2462 struct SCKContext ctx = { DD_OK, (WINEDDCOLORKEY *) CKey, Flags };
2463 TRACE("(%p)->(%x,%p)\n", This, Flags, CKey);
2465 EnterCriticalSection(&ddraw_cs);
2466 if (CKey)
2468 switch (Flags & ~DDCKEY_COLORSPACE)
2470 case DDCKEY_DESTBLT:
2471 This->surface_desc.ddckCKDestBlt = *CKey;
2472 This->surface_desc.dwFlags |= DDSD_CKDESTBLT;
2473 break;
2475 case DDCKEY_DESTOVERLAY:
2476 This->surface_desc.u3.ddckCKDestOverlay = *CKey;
2477 This->surface_desc.dwFlags |= DDSD_CKDESTOVERLAY;
2478 break;
2480 case DDCKEY_SRCOVERLAY:
2481 This->surface_desc.ddckCKSrcOverlay = *CKey;
2482 This->surface_desc.dwFlags |= DDSD_CKSRCOVERLAY;
2483 break;
2485 case DDCKEY_SRCBLT:
2486 This->surface_desc.ddckCKSrcBlt = *CKey;
2487 This->surface_desc.dwFlags |= DDSD_CKSRCBLT;
2488 break;
2490 default:
2491 LeaveCriticalSection(&ddraw_cs);
2492 return DDERR_INVALIDPARAMS;
2495 else
2497 switch (Flags & ~DDCKEY_COLORSPACE)
2499 case DDCKEY_DESTBLT:
2500 This->surface_desc.dwFlags &= ~DDSD_CKDESTBLT;
2501 break;
2503 case DDCKEY_DESTOVERLAY:
2504 This->surface_desc.dwFlags &= ~DDSD_CKDESTOVERLAY;
2505 break;
2507 case DDCKEY_SRCOVERLAY:
2508 This->surface_desc.dwFlags &= ~DDSD_CKSRCOVERLAY;
2509 break;
2511 case DDCKEY_SRCBLT:
2512 This->surface_desc.dwFlags &= ~DDSD_CKSRCBLT;
2513 break;
2515 default:
2516 LeaveCriticalSection(&ddraw_cs);
2517 return DDERR_INVALIDPARAMS;
2520 ctx.ret = IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2521 Flags,
2522 ctx.CKey);
2523 IDirectDrawSurface7_EnumAttachedSurfaces(iface,
2524 &ctx,
2525 SetColorKeyEnum);
2526 LeaveCriticalSection(&ddraw_cs);
2527 switch(ctx.ret)
2529 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
2530 default: return ctx.ret;
2534 /*****************************************************************************
2535 * IDirectDrawSurface7::SetPalette
2537 * Assigns a DirectDrawPalette object to the surface
2539 * Params:
2540 * Pal: Interface to the palette to set
2542 * Returns:
2543 * DD_OK on success
2545 *****************************************************************************/
2546 static HRESULT WINAPI
2547 IDirectDrawSurfaceImpl_SetPalette(IDirectDrawSurface7 *iface,
2548 IDirectDrawPalette *Pal)
2550 IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
2551 IDirectDrawPalette *oldPal;
2552 IDirectDrawSurfaceImpl *surf;
2553 IDirectDrawPaletteImpl *PalImpl = (IDirectDrawPaletteImpl *)Pal;
2554 HRESULT hr;
2555 TRACE("(%p)->(%p)\n", This, Pal);
2557 if (!(This->surface_desc.u4.ddpfPixelFormat.dwFlags & (DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2 |
2558 DDPF_PALETTEINDEXED4 | DDPF_PALETTEINDEXED8 | DDPF_PALETTEINDEXEDTO8))) {
2559 return DDERR_INVALIDPIXELFORMAT;
2562 /* Find the old palette */
2563 EnterCriticalSection(&ddraw_cs);
2564 hr = IDirectDrawSurface_GetPalette(iface, &oldPal);
2565 if(hr != DD_OK && hr != DDERR_NOPALETTEATTACHED)
2567 LeaveCriticalSection(&ddraw_cs);
2568 return hr;
2570 if(oldPal) IDirectDrawPalette_Release(oldPal); /* For the GetPalette */
2572 /* Set the new Palette */
2573 IWineD3DSurface_SetPalette(This->WineD3DSurface,
2574 PalImpl ? PalImpl->wineD3DPalette : NULL);
2575 /* AddRef the Palette */
2576 if(Pal) IDirectDrawPalette_AddRef(Pal);
2578 /* Release the old palette */
2579 if(oldPal) IDirectDrawPalette_Release(oldPal);
2581 /* If this is a front buffer, also update the back buffers
2582 * TODO: How do things work for palettized cube textures?
2584 if(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
2586 /* For primary surfaces the tree is just a list, so the simpler scheme fits too */
2587 DDSCAPS2 caps2 = { DDSCAPS_PRIMARYSURFACE, 0, 0, 0 };
2589 surf = This;
2590 while(1)
2592 IDirectDrawSurface7 *attach;
2593 HRESULT hr;
2594 hr = IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)surf, &caps2, &attach);
2595 if(hr != DD_OK)
2597 break;
2600 TRACE("Setting palette on %p\n", attach);
2601 IDirectDrawSurface7_SetPalette(attach,
2602 Pal);
2603 surf = (IDirectDrawSurfaceImpl *)attach;
2604 IDirectDrawSurface7_Release(attach);
2608 LeaveCriticalSection(&ddraw_cs);
2609 return DD_OK;
2612 /*****************************************************************************
2613 * The VTable
2614 *****************************************************************************/
2616 const IDirectDrawSurface7Vtbl IDirectDrawSurface7_Vtbl =
2618 /*** IUnknown ***/
2619 IDirectDrawSurfaceImpl_QueryInterface,
2620 IDirectDrawSurfaceImpl_AddRef,
2621 IDirectDrawSurfaceImpl_Release,
2622 /*** IDirectDrawSurface ***/
2623 IDirectDrawSurface7Impl_AddAttachedSurface,
2624 IDirectDrawSurfaceImpl_AddOverlayDirtyRect,
2625 IDirectDrawSurfaceImpl_Blt,
2626 IDirectDrawSurfaceImpl_BltBatch,
2627 IDirectDrawSurfaceImpl_BltFast,
2628 IDirectDrawSurfaceImpl_DeleteAttachedSurface,
2629 IDirectDrawSurfaceImpl_EnumAttachedSurfaces,
2630 IDirectDrawSurfaceImpl_EnumOverlayZOrders,
2631 IDirectDrawSurfaceImpl_Flip,
2632 IDirectDrawSurfaceImpl_GetAttachedSurface,
2633 IDirectDrawSurfaceImpl_GetBltStatus,
2634 IDirectDrawSurfaceImpl_GetCaps,
2635 IDirectDrawSurfaceImpl_GetClipper,
2636 IDirectDrawSurfaceImpl_GetColorKey,
2637 IDirectDrawSurfaceImpl_GetDC,
2638 IDirectDrawSurfaceImpl_GetFlipStatus,
2639 IDirectDrawSurfaceImpl_GetOverlayPosition,
2640 IDirectDrawSurfaceImpl_GetPalette,
2641 IDirectDrawSurfaceImpl_GetPixelFormat,
2642 IDirectDrawSurfaceImpl_GetSurfaceDesc,
2643 IDirectDrawSurfaceImpl_Initialize,
2644 IDirectDrawSurfaceImpl_IsLost,
2645 IDirectDrawSurfaceImpl_Lock,
2646 IDirectDrawSurfaceImpl_ReleaseDC,
2647 IDirectDrawSurfaceImpl_Restore,
2648 IDirectDrawSurfaceImpl_SetClipper,
2649 IDirectDrawSurfaceImpl_SetColorKey,
2650 IDirectDrawSurfaceImpl_SetOverlayPosition,
2651 IDirectDrawSurfaceImpl_SetPalette,
2652 IDirectDrawSurfaceImpl_Unlock,
2653 IDirectDrawSurfaceImpl_UpdateOverlay,
2654 IDirectDrawSurfaceImpl_UpdateOverlayDisplay,
2655 IDirectDrawSurfaceImpl_UpdateOverlayZOrder,
2656 /*** IDirectDrawSurface2 ***/
2657 IDirectDrawSurfaceImpl_GetDDInterface,
2658 IDirectDrawSurfaceImpl_PageLock,
2659 IDirectDrawSurfaceImpl_PageUnlock,
2660 /*** IDirectDrawSurface3 ***/
2661 IDirectDrawSurfaceImpl_SetSurfaceDesc,
2662 /*** IDirectDrawSurface4 ***/
2663 IDirectDrawSurfaceImpl_SetPrivateData,
2664 IDirectDrawSurfaceImpl_GetPrivateData,
2665 IDirectDrawSurfaceImpl_FreePrivateData,
2666 IDirectDrawSurfaceImpl_GetUniquenessValue,
2667 IDirectDrawSurfaceImpl_ChangeUniquenessValue,
2668 /*** IDirectDrawSurface7 ***/
2669 IDirectDrawSurfaceImpl_SetPriority,
2670 IDirectDrawSurfaceImpl_GetPriority,
2671 IDirectDrawSurfaceImpl_SetLOD,
2672 IDirectDrawSurfaceImpl_GetLOD