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
27 #include "wine/port.h"
35 #define NONAMELESSUNION
41 #include "wine/exception.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)
65 * riid: The interface id queried for
66 * obj: Address to write the pointer to
70 * E_NOINTERFACE if the requested interface wasn't found
72 *****************************************************************************/
74 IDirectDrawSurfaceImpl_QueryInterface(IDirectDrawSurface7 *iface,
78 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
80 /* According to COM docs, if the QueryInterface fails, obj should be set to NULL */
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);
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);
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);
112 else if( IsEqualGUID(riid, &IID_D3DDEVICE_WineD3D) ||
113 IsEqualGUID(riid, &IID_IDirect3DHALDevice) )
115 IDirect3DDevice7 *d3d;
117 /* Call into IDirect3D7 for creation */
118 IDirect3D7_CreateDevice(ICOM_INTERFACE(This->ddraw, IDirect3D7),
120 ICOM_INTERFACE(This, IDirectDrawSurface7),
123 *obj = COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice7, IDirect3DDevice, d3d);
124 TRACE("(%p) Returning IDirect3DDevice interface at %p\n", This, *obj);
128 else if (IsEqualGUID( &IID_IDirect3DTexture, riid ) ||
129 IsEqualGUID( &IID_IDirect3DTexture2, riid ))
131 if (IsEqualGUID( &IID_IDirect3DTexture, riid ))
133 *obj = ICOM_INTERFACE(This, IDirect3DTexture);
134 TRACE(" returning Direct3DTexture interface at %p.\n", *obj);
138 *obj = ICOM_INTERFACE(This, IDirect3DTexture2);
139 TRACE(" returning Direct3DTexture2 interface at %p.\n", *obj);
141 IUnknown_AddRef( (IUnknown *) *obj);
145 ERR("No interface\n");
146 return E_NOINTERFACE;
149 /*****************************************************************************
150 * IDirectDrawSurface7::AddRef
152 * A normal addref implementation
157 *****************************************************************************/
159 IDirectDrawSurfaceImpl_AddRef(IDirectDrawSurface7 *iface)
161 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
162 ULONG refCount = InterlockedIncrement(&This->ref);
164 TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
168 /*****************************************************************************
169 * IDirectDrawSurfaceImpl_Destroy
171 * A helper function for IDirectDrawSurface7::Release
173 * Frees the surface, regardless of its refcount.
174 * See IDirectDrawSurface7::Release for more information
177 * This: Surface to free
179 *****************************************************************************/
180 static void IDirectDrawSurfaceImpl_Destroy(IDirectDrawSurfaceImpl *This)
182 TRACE("(%p)\n", This);
184 /* Check the refcount and give a warning */
187 /* This can happen when a complex surface is destroyed,
188 * because the 2nd surface was addref()ed when the app
189 * called GetAttachedSurface
191 WARN("(%p): Destroying surface with refount %d\n", This, This->ref);
194 /* Check for attached surfaces and detach them */
195 if(This->first_attached != This)
197 /* Well, this shouldn't happen: The surface being attached is addref()ed
198 * in AddAttachedSurface, so it shouldn't be released until DeleteAttachedSurface
199 * is called, because the refcount is held. It looks like the app released()
200 * it often enough to force this
202 IDirectDrawSurface7 *root = ICOM_INTERFACE(This->first_attached, IDirectDrawSurface7);
203 IDirectDrawSurface7 *detach = ICOM_INTERFACE(This, IDirectDrawSurface7);
205 FIXME("(%p) Freeing a surface that is attached to surface %p\n", This, This->first_attached);
207 /* The refcount will drop to -1 here */
208 if(IDirectDrawSurface7_DeleteAttachedSurface(root, 0, detach) != DD_OK)
210 ERR("(%p) DeleteAttachedSurface failed!\n", This);
214 while(This->next_attached != NULL)
216 IDirectDrawSurface7 *root = ICOM_INTERFACE(This, IDirectDrawSurface7);
217 IDirectDrawSurface7 *detach = ICOM_INTERFACE(This->next_attached, IDirectDrawSurface7);
219 if(IDirectDrawSurface7_DeleteAttachedSurface(root, 0, detach) != DD_OK)
221 ERR("(%p) DeleteAttachedSurface failed!\n", This);
226 /* Now destroy the surface. Wait: It could have been released if we are a texture */
227 if(This->WineD3DSurface)
228 IWineD3DSurface_Release(This->WineD3DSurface);
230 /* Having a texture handle set implies that the device still exists */
233 This->ddraw->d3ddevice->Handles[This->Handle - 1].ptr = NULL;
234 This->ddraw->d3ddevice->Handles[This->Handle - 1].type = DDrawHandle_Unknown;
237 /* Reduce the ddraw surface count */
238 InterlockedDecrement(&This->ddraw->surfaces);
239 list_remove(&This->surface_list_entry);
241 HeapFree(GetProcessHeap(), 0, This);
244 /*****************************************************************************
245 * IDirectDrawSurface7::Release
247 * Reduces the surface's refcount by 1. If the refcount falls to 0, the
248 * surface is destroyed.
250 * Destroying the surface is a bit tricky. For the connection between
251 * WineD3DSurfaces and DirectDrawSurfaces see IDirectDraw7::CreateSurface
252 * It has a nice graph explaining the connection.
254 * What happens here is basically this:
255 * When a surface is destroyed, its WineD3DSurface is released,
256 * and the refcount of the DirectDraw interface is reduced by 1. If it has
257 * complex surfaces attached to it, then these surfaces are destroyed too,
258 * regardless of their refcount. If any surface being destroyed has another
259 * surface attached to it (with a "soft" attachment, not complex), then
260 * this surface is detached with DeleteAttachedSurface.
262 * When the surface is a texture, the WineD3DTexture is released.
263 * If the surface is the Direct3D render target, then the D3D
264 * capabilities of the WineD3DDevice are uninitialized, which causes the
265 * swapchain to be released.
267 * When a complex sublevel falls to ref zero, then this is ignored.
272 *****************************************************************************/
274 IDirectDrawSurfaceImpl_Release(IDirectDrawSurface7 *iface)
276 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
278 TRACE("(%p) : Releasing from %d\n", This, This->ref);
279 ref = InterlockedDecrement(&This->ref);
284 IDirectDrawSurfaceImpl *surf;
285 IDirectDrawImpl *ddraw;
286 IUnknown *ifaceToRelease = This->ifaceToRelease;
289 /* Complex attached surfaces are destroyed implicitely when the root is released */
290 if(!This->is_complex_root)
292 WARN("(%p) Attempt to destroy a surface that is not a complex root\n", This);
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( (ddraw->d3d_initialized) && (This == ddraw->d3d_target))
309 TRACE("(%p) Destroying the render target, uninitializing D3D\n", This);
311 /* Unset any index buffer, just to be sure */
312 IWineD3DDevice_SetIndices(ddraw->wineD3DDevice, NULL, 0);
313 IWineD3DDevice_SetDepthStencilSurface(ddraw->wineD3DDevice, NULL);
315 if(IWineD3DDevice_Uninit3D(ddraw->wineD3DDevice, D3D7CB_DestroyDepthStencilSurface, D3D7CB_DestroySwapChain) != D3D_OK)
318 ERR("(%p) Failed to uninit 3D\n", This);
322 /* Free the d3d window if one was created */
323 if(ddraw->d3d_window != 0)
325 TRACE(" (%p) Destroying the hidden render window %p\n", This, ddraw->d3d_window);
326 DestroyWindow(ddraw->d3d_window);
327 ddraw->d3d_window = 0;
329 /* Unset the pointers */
332 ddraw->d3d_initialized = FALSE;
333 ddraw->d3d_target = NULL;
335 /* Write a trace because D3D unloading was the reason for many
336 * crashes during development.
338 TRACE("(%p) D3D unloaded\n", This);
340 else if(This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE |
344 /* It's a render target, but no swapchain was created.
345 * The IParent interfaces have to be released manually.
346 * The same applies for textures without an
347 * IWineD3DTexture object attached
351 for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
353 if(This->complex_array[i])
355 /* Only the topmost level can have more than 1 surfaces in the complex
356 * attachment array(Cube texture roots), for all others there is only
359 surf = This->complex_array[i];
362 IWineD3DSurface_GetParent(surf->WineD3DSurface,
363 (IUnknown **) &Parent);
364 IParent_Release(Parent); /* For the getParent */
365 IParent_Release(Parent); /* To release it */
366 surf = surf->complex_array[0];
371 /* Now the top-level surface */
372 IWineD3DSurface_GetParent(This->WineD3DSurface,
373 (IUnknown **) &Parent);
374 IParent_Release(Parent); /* For the getParent */
375 IParent_Release(Parent); /* To release it */
378 /* The refcount test shows that the palette is detached when the surface is destroyed */
379 IDirectDrawSurface7_SetPalette(ICOM_INTERFACE(This, IDirectDrawSurface7),
382 /* Loop through all complex attached surfaces,
385 * Yet again, only the root can have more than one complexly attached surface, all the others
386 * have a total of one;
388 for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
390 if(!This->complex_array[i]) break;
392 surf = This->complex_array[i];
393 This->complex_array[i] = NULL;
396 IDirectDrawSurfaceImpl *destroy = surf;
397 surf = surf->complex_array[0]; /* Iterate through the "tree" */
398 IDirectDrawSurfaceImpl_Destroy(destroy); /* Destroy it */
402 /* Destroy the root surface.
404 IDirectDrawSurfaceImpl_Destroy(This);
406 /* Reduce the ddraw refcount */
407 if(ifaceToRelease) IUnknown_Release(ifaceToRelease);
413 /*****************************************************************************
414 * IDirectDrawSurface7::GetAttachedSurface
416 * Returns an attached surface with the requested caps. Surface attachment
417 * and complex surfaces are not clearly described by the MSDN or sdk,
418 * so this method is tricky and likely to contain problems.
419 * This implementation searches the complex list first, then the
422 * The chains are searched from This down to the last surface in the chain,
423 * not from the first element in the chain. The first surface found is
424 * returned. The MSDN says that this method fails if more than one surface
425 * matches the caps, but it is not sure if that is right. The attachment
426 * structure may not even allow two matching surfaces.
428 * The found surface is AddRef-ed before it is returned.
431 * Caps: Pointer to a DDCAPS2 structure describing the caps asked for
432 * Surface: Address to store the found surface
436 * DDERR_INVALIDPARAMS if Caps or Surface is NULL
437 * DDERR_NOTFOUND if no surface was found
439 *****************************************************************************/
440 static HRESULT WINAPI
441 IDirectDrawSurfaceImpl_GetAttachedSurface(IDirectDrawSurface7 *iface,
443 IDirectDrawSurface7 **Surface)
445 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
446 IDirectDrawSurfaceImpl *surf;
450 TRACE("(%p)->(%p,%p)\n", This, Caps, Surface);
454 if(This->version < 7)
456 /* Earlier dx apps put garbage into these members, clear them */
457 our_caps.dwCaps2 = 0;
458 our_caps.dwCaps3 = 0;
459 our_caps.dwCaps4 = 0;
462 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 */
464 for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
466 surf = This->complex_array[i];
471 TRACE("Surface: (%p) caps: %x,%x,%x,%x\n", surf,
472 surf->surface_desc.ddsCaps.dwCaps,
473 surf->surface_desc.ddsCaps.dwCaps2,
474 surf->surface_desc.ddsCaps.dwCaps3,
475 surf->surface_desc.ddsCaps.dwCaps4);
478 if (((surf->surface_desc.ddsCaps.dwCaps & our_caps.dwCaps) == our_caps.dwCaps) &&
479 ((surf->surface_desc.ddsCaps.dwCaps2 & our_caps.dwCaps2) == our_caps.dwCaps2)) {
481 /* MSDN: "This method fails if more than one surface is attached
482 * that matches the capabilities requested."
484 * Not sure how to test this.
487 TRACE("(%p): Returning surface %p\n", This, surf);
488 TRACE("(%p): mipmapcount=%d\n", This, surf->mipmap_level);
489 *Surface = ICOM_INTERFACE(surf, IDirectDrawSurface7);
490 IDirectDrawSurface7_AddRef(*Surface);
495 /* Next, look at the attachment chain */
498 while( (surf = surf->next_attached) )
502 TRACE("Surface: (%p) caps: %x,%x,%x,%x\n", surf,
503 surf->surface_desc.ddsCaps.dwCaps,
504 surf->surface_desc.ddsCaps.dwCaps2,
505 surf->surface_desc.ddsCaps.dwCaps3,
506 surf->surface_desc.ddsCaps.dwCaps4);
509 if (((surf->surface_desc.ddsCaps.dwCaps & our_caps.dwCaps) == our_caps.dwCaps) &&
510 ((surf->surface_desc.ddsCaps.dwCaps2 & our_caps.dwCaps2) == our_caps.dwCaps2)) {
512 TRACE("(%p): Returning surface %p\n", This, surf);
513 *Surface = ICOM_INTERFACE(surf, IDirectDrawSurface7);
514 IDirectDrawSurface7_AddRef(*Surface);
519 TRACE("(%p) Didn't find a valid surface\n", This);
520 return DDERR_NOTFOUND;
523 /*****************************************************************************
524 * IDirectDrawSurface7::Lock
526 * Locks the surface and returns a pointer to the surface's memory
529 * Rect: Rectangle to lock. If NULL, the whole surface is locked
530 * DDSD: Pointer to a DDSURFACEDESC2 which shall receive the surface's desc.
531 * Flags: Locking flags, e.g Read only or write only
532 * h: An event handle that's not used and must be NULL
536 * DDERR_INVALIDPARAMS if DDSD is NULL
537 * For more details, see IWineD3DSurface::LockRect
539 *****************************************************************************/
540 static HRESULT WINAPI
541 IDirectDrawSurfaceImpl_Lock(IDirectDrawSurface7 *iface,
543 DDSURFACEDESC2 *DDSD,
547 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
548 WINED3DLOCKED_RECT LockedRect;
550 TRACE("(%p)->(%p,%p,%x,%p)\n", This, Rect, DDSD, Flags, h);
553 return DDERR_INVALIDPARAMS;
555 /* Should I check for the handle to be NULL?
557 * The DDLOCK flags and the D3DLOCK flags are equal
558 * for the supported values. The others are ignored by WineD3D
561 /* Hmm. Anarchy online passes an uninitialized surface descriptor,
562 * that means it doesn't have dwSize set. Init it to some sane
565 if(DDSD->dwSize <= sizeof(DDSURFACEDESC))
567 DDSD->dwSize = sizeof(DDSURFACEDESC);
571 DDSD->dwSize = sizeof(DDSURFACEDESC2);
574 DD_STRUCT_COPY_BYSIZE(DDSD,&(This->surface_desc));
575 hr = IWineD3DSurface_LockRect(This->WineD3DSurface,
579 if(hr != D3D_OK) return hr;
581 /* Override the memory area and the pitch */
582 DDSD->dwFlags |= DDSD_LPSURFACE;
583 DDSD->lpSurface = LockedRect.pBits;
584 DDSD->dwFlags |= DDSD_PITCH;
585 DDSD->u1.lPitch = LockedRect.Pitch;
587 TRACE("locked surface returning description :\n");
588 if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD);
593 /*****************************************************************************
594 * IDirectDrawSurface7::Unlock
596 * Unlocks an locked surface
599 * Rect: Not used by this implementation
603 * For more details, see IWineD3DSurface::UnlockRect
605 *****************************************************************************/
606 static HRESULT WINAPI
607 IDirectDrawSurfaceImpl_Unlock(IDirectDrawSurface7 *iface,
610 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
611 TRACE("(%p)->(%p)\n", This, pRect);
613 return IWineD3DSurface_UnlockRect(This->WineD3DSurface);
616 /*****************************************************************************
617 * IDirectDrawSurface7::Flip
619 * Flips a surface with the DDSCAPS_FLIP flag. The flip is relayed to
620 * IWineD3DSurface::Flip. Because WineD3D doesn't handle attached surfaces,
621 * the flip target is passed to WineD3D, even if the app didn't specify one
624 * DestOverride: Specifies the surface that will become the new front
625 * buffer. If NULL, the current back buffer is used
626 * Flags: some DirectDraw flags, see include/ddraw.h
630 * DDERR_NOTFLIPPABLE if no flip target could be found
631 * DDERR_INVALIDOBJECT if the surface isn't a front buffer
632 * For more details, see IWineD3DSurface::Flip
634 *****************************************************************************/
635 static HRESULT WINAPI
636 IDirectDrawSurfaceImpl_Flip(IDirectDrawSurface7 *iface,
637 IDirectDrawSurface7 *DestOverride,
640 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
641 IDirectDrawSurfaceImpl *Override = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DestOverride);
642 IDirectDrawSurface7 *Override7;
644 TRACE("(%p)->(%p,%x)\n", This, DestOverride, Flags);
646 /* Flip has to be called from a front buffer
647 * What about overlay surfaces, AFAIK they can flip too?
649 if( !(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER) )
650 return DDERR_INVALIDOBJECT; /* Unckecked */
652 /* WineD3D doesn't keep track of attached surface, so find the target */
657 memset(&Caps, 0, sizeof(Caps));
658 Caps.dwCaps |= DDSCAPS_BACKBUFFER;
659 hr = IDirectDrawSurface7_GetAttachedSurface(iface, &Caps, &Override7);
662 ERR("Can't find a flip target\n");
663 return DDERR_NOTFLIPPABLE; /* Unchecked */
665 Override = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Override7);
667 /* For the GetAttachedSurface */
668 IDirectDrawSurface7_Release(Override7);
671 return IWineD3DSurface_Flip(This->WineD3DSurface,
672 Override->WineD3DSurface,
676 /*****************************************************************************
677 * IDirectDrawSurface7::Blt
679 * Performs a blit on the surface
682 * DestRect: Destination rectangle, can be NULL
683 * SrcSurface: Source surface, can be NULL
684 * SrcRect: Source rectange, can be NULL
686 * DDBltFx: Some extended blt parameters, connected to the flags
690 * See IWineD3DSurface::Blt for more details
692 *****************************************************************************/
693 static HRESULT WINAPI
694 IDirectDrawSurfaceImpl_Blt(IDirectDrawSurface7 *iface,
696 IDirectDrawSurface7 *SrcSurface,
701 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
703 IDirectDrawSurfaceImpl *Src = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, SrcSurface);
704 TRACE("(%p)->(%p,%p,%p,%x,%p)\n", This, DestRect, Src, SrcRect, Flags, DDBltFx);
706 /* Check for validity of the flags here. WineD3D Has the software-opengl selection path and would have
707 * to check at 2 places, and sometimes do double checks. This also saves the call to wined3d :-)
709 if((Flags & DDBLT_KEYSRCOVERRIDE) && (!DDBltFx || Flags & DDBLT_KEYSRC)) {
710 WARN("Invalid source color key parameters, returning DDERR_INVALIDPARAMS\n");
711 return DDERR_INVALIDPARAMS;
714 if((Flags & DDBLT_KEYDESTOVERRIDE) && (!DDBltFx || Flags & DDBLT_KEYDEST)) {
715 WARN("Invalid destination color key parameters, returning DDERR_INVALIDPARAMS\n");
716 return DDERR_INVALIDPARAMS;
719 if(Flags & DDBLT_KEYSRC && (!Src || !(Src->surface_desc.dwFlags & DDSD_CKSRCBLT))) {
720 WARN("DDBLT_KEYDEST blit without color key in surface, returning DDERR_INVALIDPARAMS\n");
721 return DDERR_INVALIDPARAMS;
724 /* TODO: Check if the DDBltFx contains any ddraw surface pointers. If it does, copy the struct,
725 * and replace the ddraw surfaces with the wined3d surfaces
726 * So far no blitting operations using surfaces in the bltfx struct are supported anyway.
728 hr = IWineD3DSurface_Blt(This->WineD3DSurface,
730 Src ? Src->WineD3DSurface : NULL,
733 (WINEDDBLTFX *) DDBltFx,
737 case WINED3DERR_NOTAVAILABLE: return DDERR_UNSUPPORTED;
738 case WINED3DERR_WRONGTEXTUREFORMAT: return DDERR_INVALIDPIXELFORMAT;
743 /*****************************************************************************
744 * IDirectDrawSurface7::AddAttachedSurface
746 * Attaches a surface to another surface. How the surface attachments work
747 * is not totally understood yet, and this method is prone to problems.
748 * he surface that is attached is AddRef-ed.
750 * Tests with complex surfaces suggest that the surface attachments form a
751 * tree, but no method to test this has been found yet.
753 * The attachment list consists of a first surface (first_attached) and
754 * for each surface a pointer to the next attached surface (next_attached).
755 * For the first surface, and a surface that has no attachments
756 * first_attached points to the surface itself. A surface that has
757 * no successors in the chain has next_attached set to NULL.
759 * Newly attached surfaces are attached right after the root surface.
760 * If a surface is attached to a complex surface compound, it's attached to
761 * the surface that the app requested, not the complex root. See
762 * GetAttachedSurface for a description how surfaces are found.
764 * This is how the current implementation works, and it was coded by looking
765 * at the needs of the applications.
767 * So far only Z-Buffer attachments are tested, and they are activated in
768 * WineD3D. Mipmaps could be tricky to activate in WineD3D.
769 * Back buffers should work in 2D mode, but they are not tested(Not sure if
770 * they can be attached at all). Rendering to the primary surface and
771 * switching between that and double buffering is not yet implemented in
772 * WineD3D, so for 3D it might have unexpected results.
775 * Attach: Surface to attach to iface
779 * DDERR_CANNOTATTACHSURFACE if the surface can't be attached for some reason
781 *****************************************************************************/
782 static HRESULT WINAPI
783 IDirectDrawSurfaceImpl_AddAttachedSurface(IDirectDrawSurface7 *iface,
784 IDirectDrawSurface7 *Attach)
786 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
787 IDirectDrawSurfaceImpl *Surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Attach);
788 TRACE("(%p)->(%p)\n", This, Surf);
790 /* Should I make sure to add it to the first complex surface? */
793 return DDERR_CANNOTATTACHSURFACE; /* unchecked */
795 /* MSDN: Only Z buffer surfaces can be attached. An old comment said that apparently
796 * mipmaps and back buffers can be attached too, although our tests say no.
798 if(!(Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
800 /* Write a fixme until we know for sure what is going on */
801 FIXME("Application tries to attach a non Z buffer surface. caps %08x\n",
802 Surf->surface_desc.ddsCaps.dwCaps);
803 return DDERR_CANNOTATTACHSURFACE;
806 /* Set MIPMAPSUBLEVEL if this seems to be one */
807 if (This->surface_desc.ddsCaps.dwCaps &
808 Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
810 Surf->surface_desc.ddsCaps.dwCaps2 |= DDSCAPS2_MIPMAPSUBLEVEL;
811 /* FIXME: we should probably also add to dwMipMapCount of this
812 * and all parent surfaces (update create_texture if you do) */
815 /* Check if the surface is already attached somewhere */
816 if( (Surf->next_attached != NULL) ||
817 (Surf->first_attached != Surf) )
819 ERR("(%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);
820 return DDERR_CANNOTATTACHSURFACE;
823 /* This inserts the new surface at the 2nd position in the chain, right after the root surface */
824 Surf->next_attached = This->next_attached;
825 Surf->first_attached = This->first_attached;
826 This->next_attached = Surf;
828 /* Check if the WineD3D depth stencil needs updating */
829 if(This->ddraw->d3ddevice)
831 IDirect3DDeviceImpl_UpdateDepthStencil(This->ddraw->d3ddevice);
835 * "This method increments the reference count of the surface being attached."
837 IDirectDrawSurface7_AddRef(Attach);
841 /*****************************************************************************
842 * IDirectDrawSurface7::DeleteAttachedSurface
844 * Removes a surface from the attachment chain. The surface's refcount
845 * is decreased by one after it has been removed
848 * Flags: Some flags, not used by this implementation
849 * Attach: Surface to detach
853 * DDERR_SURFACENOTATTACHED if the surface isn't attached to
855 *****************************************************************************/
856 static HRESULT WINAPI
857 IDirectDrawSurfaceImpl_DeleteAttachedSurface(IDirectDrawSurface7 *iface,
859 IDirectDrawSurface7 *Attach)
861 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
862 IDirectDrawSurfaceImpl *Surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Attach);
863 IDirectDrawSurfaceImpl *Prev = This;
864 TRACE("(%p)->(%08x,%p)\n", This, Flags, Surf);
866 if (!Surf || (Surf->first_attached != This) || (Surf == This) )
867 return DDERR_SURFACENOTATTACHED; /* unchecked */
869 /* Remove MIPMAPSUBLEVEL if this seemed to be one */
870 if (This->surface_desc.ddsCaps.dwCaps &
871 Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
873 Surf->surface_desc.ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
874 /* FIXME: we should probably also subtract from dwMipMapCount of this
875 * and all parent surfaces */
878 /* Find the predecessor of the detached surface */
881 if(Prev->next_attached == Surf) break;
882 Prev = Prev->next_attached;
885 /* There must be a surface, otherwise there's a bug */
886 assert(Prev != NULL);
888 /* Unchain the surface */
889 Prev->next_attached = Surf->next_attached;
890 Surf->next_attached = NULL;
891 Surf->first_attached = Surf;
893 /* Check if the WineD3D depth stencil needs updating */
894 if(This->ddraw->d3ddevice)
896 IDirect3DDeviceImpl_UpdateDepthStencil(This->ddraw->d3ddevice);
899 IDirectDrawSurface7_Release(Attach);
903 /*****************************************************************************
904 * IDirectDrawSurface7::AddOverlayDirtyRect
906 * "This method is not currently implemented"
914 *****************************************************************************/
915 static HRESULT WINAPI
916 IDirectDrawSurfaceImpl_AddOverlayDirtyRect(IDirectDrawSurface7 *iface,
919 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
920 TRACE("(%p)->(%p)\n",This,Rect);
922 /* MSDN says it's not implemented. I could forward it to WineD3D,
923 * then we'd implement it, but I don't think that's a good idea
927 return IWineD3DSurface_AddOverlayDirtyRect(This->WineD3DSurface, pRect);
929 return DDERR_UNSUPPORTED; /* unchecked */
932 /*****************************************************************************
933 * IDirectDrawSurface7::GetDC
935 * Returns a GDI device context for the surface
938 * hdc: Address of a HDC variable to store the dc to
942 * DDERR_INVALIDPARAMS if hdc is NULL
943 * For details, see IWineD3DSurface::GetDC
945 *****************************************************************************/
946 static HRESULT WINAPI
947 IDirectDrawSurfaceImpl_GetDC(IDirectDrawSurface7 *iface,
950 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
951 TRACE("(%p)->(%p): Relay\n", This, hdc);
954 return DDERR_INVALIDPARAMS;
956 return IWineD3DSurface_GetDC(This->WineD3DSurface,
960 /*****************************************************************************
961 * IDirectDrawSurface7::ReleaseDC
963 * Releases the DC that was constructed with GetDC
966 * hdc: HDC to release
970 * For more details, see IWineD3DSurface::ReleaseDC
972 *****************************************************************************/
973 static HRESULT WINAPI
974 IDirectDrawSurfaceImpl_ReleaseDC(IDirectDrawSurface7 *iface,
977 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
978 TRACE("(%p)->(%p): Relay\n", This, hdc);
980 return IWineD3DSurface_ReleaseDC(This->WineD3DSurface, hdc);
983 /*****************************************************************************
984 * IDirectDrawSurface7::GetCaps
986 * Returns the surface's caps
989 * Caps: Address to write the caps to
993 * DDERR_INVALIDPARAMS if Caps is NULL
995 *****************************************************************************/
996 static HRESULT WINAPI
997 IDirectDrawSurfaceImpl_GetCaps(IDirectDrawSurface7 *iface,
1000 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1001 TRACE("(%p)->(%p)\n",This,Caps);
1004 return DDERR_INVALIDPARAMS;
1006 *Caps = This->surface_desc.ddsCaps;
1010 /*****************************************************************************
1011 * IDirectDrawSurface7::SetPriority
1013 * Sets a texture priority for managed textures.
1016 * Priority: The new priority
1020 * For more details, see IWineD3DSurface::SetPriority
1022 *****************************************************************************/
1023 static HRESULT WINAPI
1024 IDirectDrawSurfaceImpl_SetPriority(IDirectDrawSurface7 *iface, DWORD Priority)
1026 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1027 TRACE("(%p)->(%d): Relay!\n",This,Priority);
1029 return IWineD3DSurface_SetPriority(This->WineD3DSurface, Priority);
1032 /*****************************************************************************
1033 * IDirectDrawSurface7::GetPriority
1035 * Returns the surface's priority
1038 * Priority: Address of a variable to write the priority to
1042 * DDERR_INVALIDPARAMS if Priority == NULL
1043 * For more details, see IWineD3DSurface::GetPriority
1045 *****************************************************************************/
1046 static HRESULT WINAPI
1047 IDirectDrawSurfaceImpl_GetPriority(IDirectDrawSurface7 *iface,
1050 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1051 TRACE("(%p)->(%p): Relay\n",This,Priority);
1054 return DDERR_INVALIDPARAMS;
1056 *Priority = IWineD3DSurface_GetPriority(This->WineD3DSurface);
1060 /*****************************************************************************
1061 * IDirectDrawSurface7::SetPrivateData
1063 * Stores some data in the surface that is intended for the application's
1067 * tag: GUID that identifies the data
1068 * Data: Pointer to the private data
1069 * Size: Size of the private data
1074 * For more details, see IWineD3DSurface::SetPrivateData
1076 *****************************************************************************/
1077 static HRESULT WINAPI
1078 IDirectDrawSurfaceImpl_SetPrivateData(IDirectDrawSurface7 *iface,
1084 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1085 TRACE("(%p)->(%s,%p,%d,%x): Relay\n", This, debugstr_guid(tag), Data, Size, Flags);
1087 return IWineD3DSurface_SetPrivateData(This->WineD3DSurface,
1094 /*****************************************************************************
1095 * IDirectDrawSurface7::GetPrivateData
1097 * Returns the private data set with IDirectDrawSurface7::SetPrivateData
1100 * tag: GUID of the data to return
1101 * Data: Address where to write the data to
1102 * Size: Size of the buffer at Data
1106 * DDERR_INVALIDPARAMS if Data is NULL
1107 * For more details, see IWineD3DSurface::GetPrivateData
1109 *****************************************************************************/
1110 static HRESULT WINAPI
1111 IDirectDrawSurfaceImpl_GetPrivateData(IDirectDrawSurface7 *iface,
1116 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1117 TRACE("(%p)->(%s,%p,%p): Relay\n", This, debugstr_guid(tag), Data, Size);
1120 return DDERR_INVALIDPARAMS;
1122 return IWineD3DSurface_GetPrivateData(This->WineD3DSurface,
1128 /*****************************************************************************
1129 * IDirectDrawSurface7::FreePrivateData
1131 * Frees private data stored in the surface
1134 * tag: Tag of the data to free
1138 * For more details, see IWineD3DSurface::FreePrivateData
1140 *****************************************************************************/
1141 static HRESULT WINAPI
1142 IDirectDrawSurfaceImpl_FreePrivateData(IDirectDrawSurface7 *iface,
1145 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1146 TRACE("(%p)->(%s): Relay\n", This, debugstr_guid(tag));
1148 return IWineD3DSurface_FreePrivateData(This->WineD3DSurface, tag);
1151 /*****************************************************************************
1152 * IDirectDrawSurface7::PageLock
1154 * Prevents a sysmem surface from being paged out
1157 * Flags: Not used, must be 0(unchecked)
1160 * DD_OK, because it's a stub
1162 *****************************************************************************/
1163 static HRESULT WINAPI
1164 IDirectDrawSurfaceImpl_PageLock(IDirectDrawSurface7 *iface,
1167 TRACE("(%p)->(%x)\n", iface, Flags);
1169 /* This is Windows memory management related - we don't need this */
1173 /*****************************************************************************
1174 * IDirectDrawSurface7::PageUnlock
1176 * Allows a sysmem surface to be paged out
1179 * Flags: Not used, must be 0(unckeched)
1182 * DD_OK, because it's a stub
1184 *****************************************************************************/
1185 static HRESULT WINAPI
1186 IDirectDrawSurfaceImpl_PageUnlock(IDirectDrawSurface7 *iface,
1189 TRACE("(%p)->(%x)\n", iface, Flags);
1194 /*****************************************************************************
1195 * IDirectDrawSurface7::BltBatch
1197 * An unimplemented function
1205 *****************************************************************************/
1206 static HRESULT WINAPI IDirectDrawSurfaceImpl_BltBatch(IDirectDrawSurface7 *iface, DDBLTBATCH *Batch, DWORD Count, DWORD Flags)
1208 TRACE("(%p)->(%p,%d,%08x)\n",iface,Batch,Count,Flags);
1210 /* MSDN: "not currently implemented" */
1211 return DDERR_UNSUPPORTED;
1214 /*****************************************************************************
1215 * IDirectDrawSurface7::EnumAttachedSurfaces
1217 * Enumerates all surfaces attached to this surface
1220 * context: Pointer to pass unmodified to the callback
1221 * cb: Callback function to call for each surface
1225 * DDERR_INVALIDPARAMS if cb is NULL
1227 *****************************************************************************/
1228 static HRESULT WINAPI
1229 IDirectDrawSurfaceImpl_EnumAttachedSurfaces(IDirectDrawSurface7 *iface,
1231 LPDDENUMSURFACESCALLBACK7 cb)
1233 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1234 IDirectDrawSurfaceImpl *surf;
1235 DDSURFACEDESC2 desc;
1238 /* Attached surfaces aren't handled in WineD3D */
1239 TRACE("(%p)->(%p,%p)\n",This,context,cb);
1242 return DDERR_INVALIDPARAMS;
1244 for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
1246 surf = This->complex_array[i];
1249 IDirectDrawSurface7_AddRef(ICOM_INTERFACE(surf, IDirectDrawSurface7));
1250 desc = surf->surface_desc;
1251 /* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
1252 if (cb(ICOM_INTERFACE(surf, IDirectDrawSurface7), &desc, context) == DDENUMRET_CANCEL)
1256 for (surf = This->next_attached; surf != NULL; surf = surf->next_attached)
1258 IDirectDrawSurface7_AddRef(ICOM_INTERFACE(surf, IDirectDrawSurface7));
1259 desc = surf->surface_desc;
1260 /* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
1261 if (cb( ICOM_INTERFACE(surf, IDirectDrawSurface7), &desc, context) == DDENUMRET_CANCEL)
1265 TRACE(" end of enumeration.\n");
1270 /*****************************************************************************
1271 * IDirectDrawSurface7::EnumOverlayZOrders
1273 * "Enumerates the overlay surfaces on the specified destination"
1276 * Flags: DDENUMOVERLAYZ_BACKTOFRONT or DDENUMOVERLAYZ_FRONTTOBACK
1277 * context: context to pass back to the callback
1278 * cb: callback function to call for each enumerated surface
1281 * DD_OK, because it's a stub
1283 *****************************************************************************/
1284 static HRESULT WINAPI
1285 IDirectDrawSurfaceImpl_EnumOverlayZOrders(IDirectDrawSurface7 *iface,
1288 LPDDENUMSURFACESCALLBACK7 cb)
1290 FIXME("(%p)->(%x,%p,%p): Stub!\n", iface, Flags, context, cb);
1295 /*****************************************************************************
1296 * IDirectDrawSurface7::GetBltStatus
1298 * Returns the blitting status
1301 * Flags: DDGBS_CANBLT or DDGBS_ISBLTDONE
1304 * See IWineD3DSurface::Blt
1306 *****************************************************************************/
1307 static HRESULT WINAPI
1308 IDirectDrawSurfaceImpl_GetBltStatus(IDirectDrawSurface7 *iface,
1311 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1313 TRACE("(%p)->(%x): Relay\n", This, Flags);
1315 hr = IWineD3DSurface_GetBltStatus(This->WineD3DSurface, Flags);
1318 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1323 /*****************************************************************************
1324 * IDirectDrawSurface7::GetColorKey
1326 * Returns the color key assigned to the surface
1330 * CKey: Address to store the key to
1334 * DDERR_INVALIDPARAMS if CKey is NULL
1336 *****************************************************************************/
1337 static HRESULT WINAPI
1338 IDirectDrawSurfaceImpl_GetColorKey(IDirectDrawSurface7 *iface,
1342 /* There is a DDERR_NOCOLORKEY error, but how do we know if a color key
1343 * isn't there? That's like saying that an int isn't there. (Which MS
1344 * has done in other docs.) */
1345 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1346 TRACE("(%p)->(%08x,%p)\n", This, Flags, CKey);
1349 return DDERR_INVALIDPARAMS;
1353 case DDCKEY_DESTBLT:
1354 *CKey = This->surface_desc.ddckCKDestBlt;
1357 case DDCKEY_DESTOVERLAY:
1358 *CKey = This->surface_desc.u3.ddckCKDestOverlay;
1362 *CKey = This->surface_desc.ddckCKSrcBlt;
1365 case DDCKEY_SRCOVERLAY:
1366 *CKey = This->surface_desc.ddckCKSrcOverlay;
1370 return DDERR_INVALIDPARAMS;
1376 /*****************************************************************************
1377 * IDirectDrawSurface7::GetFlipStatus
1379 * Returns the flipping status of the surface
1382 * Flags: DDGFS_CANFLIP of DDGFS_ISFLIPDONE
1385 * See IWineD3DSurface::GetFlipStatus
1387 *****************************************************************************/
1388 static HRESULT WINAPI
1389 IDirectDrawSurfaceImpl_GetFlipStatus(IDirectDrawSurface7 *iface,
1392 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1394 TRACE("(%p)->(%x): Relay\n", This, Flags);
1396 hr = IWineD3DSurface_GetFlipStatus(This->WineD3DSurface, Flags);
1399 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1404 /*****************************************************************************
1405 * IDirectDrawSurface7::GetOverlayPosition
1407 * Returns the display coordinates of a visible and active overlay surface
1414 * DDERR_NOTAOVERLAYSURFACE, because it's a stub
1415 *****************************************************************************/
1416 static HRESULT WINAPI
1417 IDirectDrawSurfaceImpl_GetOverlayPosition(IDirectDrawSurface7 *iface,
1420 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1421 TRACE("(%p)->(%p,%p): Relay\n", This, X, Y);
1423 return IWineD3DSurface_GetOverlayPosition(This->WineD3DSurface,
1428 /*****************************************************************************
1429 * IDirectDrawSurface7::GetPixelFormat
1431 * Returns the pixel format of the Surface
1434 * PixelFormat: Pointer to a DDPIXELFORMAT structure to which the pixel
1435 * format should be written
1439 * DDERR_INVALIDPARAMS if PixelFormat is NULL
1441 *****************************************************************************/
1442 static HRESULT WINAPI
1443 IDirectDrawSurfaceImpl_GetPixelFormat(IDirectDrawSurface7 *iface,
1444 DDPIXELFORMAT *PixelFormat)
1446 /* What is DDERR_INVALIDSURFACETYPE for here? */
1447 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1448 TRACE("(%p)->(%p)\n",This,PixelFormat);
1451 return DDERR_INVALIDPARAMS;
1453 DD_STRUCT_COPY_BYSIZE(PixelFormat,&This->surface_desc.u4.ddpfPixelFormat);
1459 /*****************************************************************************
1460 * IDirectDrawSurface7::GetSurfaceDesc
1462 * Returns the description of this surface
1465 * DDSD: Address of a DDSURFACEDESC2 structure that is to be filled with the
1470 * DDERR_INVALIDPARAMS if DDSD is NULL
1472 *****************************************************************************/
1473 static HRESULT WINAPI
1474 IDirectDrawSurfaceImpl_GetSurfaceDesc(IDirectDrawSurface7 *iface,
1475 DDSURFACEDESC2 *DDSD)
1477 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1479 TRACE("(%p)->(%p)\n",This,DDSD);
1482 return DDERR_INVALIDPARAMS;
1484 if ((DDSD->dwSize < sizeof(DDSURFACEDESC)) ||
1485 (DDSD->dwSize > sizeof(DDSURFACEDESC2)))
1487 ERR("Impossible/Strange struct size %d.\n",DDSD->dwSize);
1488 return DDERR_GENERIC;
1491 DD_STRUCT_COPY_BYSIZE(DDSD,&This->surface_desc);
1492 TRACE("Returning surface desc:\n");
1493 if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD);
1498 /*****************************************************************************
1499 * IDirectDrawSurface7::Initialize
1501 * Initializes the surface. This is a no-op in Wine
1504 * DD: Pointer to an DirectDraw interface
1505 * DDSD: Surface description for initialization
1508 * DDERR_ALREADYINITIALIZED
1510 *****************************************************************************/
1511 static HRESULT WINAPI
1512 IDirectDrawSurfaceImpl_Initialize(IDirectDrawSurface7 *iface,
1514 DDSURFACEDESC2 *DDSD)
1516 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1517 IDirectDrawImpl *ddimpl = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, DD);
1518 TRACE("(%p)->(%p,%p)\n",This,ddimpl,DDSD);
1520 return DDERR_ALREADYINITIALIZED;
1523 /*****************************************************************************
1524 * IDirectDrawSurface7::IsLost
1526 * Checks if the surface is lost
1529 * DD_OK, if the surface is useable
1530 * DDERR_ISLOST if the surface is lost
1531 * See IWineD3DSurface::IsLost for more details
1533 *****************************************************************************/
1534 static HRESULT WINAPI
1535 IDirectDrawSurfaceImpl_IsLost(IDirectDrawSurface7 *iface)
1537 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1539 TRACE("(%p)\n", This);
1541 /* We lose the surface if the implementation was changed */
1542 if(This->ImplType != This->ddraw->ImplType)
1544 /* But this shouldn't happen. When we change the implementation,
1545 * all surfaces are re-created automatically, and their content
1548 ERR(" (%p) Implementation was changed from %d to %d\n", This, This->ImplType, This->ddraw->ImplType);
1549 return DDERR_SURFACELOST;
1552 hr = IWineD3DSurface_IsLost(This->WineD3DSurface);
1555 /* D3D8 and 9 loose full devices, thus there's only a DEVICELOST error.
1556 * WineD3D uses the same error for surfaces
1558 case WINED3DERR_DEVICELOST: return DDERR_SURFACELOST;
1563 /*****************************************************************************
1564 * IDirectDrawSurface7::Restore
1566 * Restores a lost surface. This makes the surface usable again, but
1567 * doesn't reload its old contents
1571 * See IWineD3DSurface::Restore for more details
1573 *****************************************************************************/
1574 static HRESULT WINAPI
1575 IDirectDrawSurfaceImpl_Restore(IDirectDrawSurface7 *iface)
1577 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1578 TRACE("(%p)\n", This);
1580 if(This->ImplType != This->ddraw->ImplType)
1582 /* Call the recreation callback. Make sure to AddRef first */
1583 IDirectDrawSurface_AddRef(iface);
1584 IDirectDrawImpl_RecreateSurfacesCallback(iface,
1585 &This->surface_desc,
1586 NULL /* Not needed */);
1588 return IWineD3DSurface_Restore(This->WineD3DSurface);
1591 /*****************************************************************************
1592 * IDirectDrawSurface7::SetOverlayPosition
1594 * Changes the display coordinates of an overlay surface
1601 * DDERR_NOTAOVERLAYSURFACE, because we don't support overlays right now
1602 *****************************************************************************/
1603 static HRESULT WINAPI
1604 IDirectDrawSurfaceImpl_SetOverlayPosition(IDirectDrawSurface7 *iface,
1608 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1609 TRACE("(%p)->(%d,%d): Relay\n", This, X, Y);
1611 return IWineD3DSurface_SetOverlayPosition(This->WineD3DSurface,
1616 /*****************************************************************************
1617 * IDirectDrawSurface7::UpdateOverlay
1619 * Modifies the attributes of an overlay surface.
1622 * SrcRect: The section of the source being used for the overlay
1623 * DstSurface: Address of the surface that is overlaid
1624 * DstRect: Place of the overlay
1625 * Flags: some DDOVER_* flags
1628 * DDERR_UNSUPPORTED, because we don't support overlays
1630 *****************************************************************************/
1631 static HRESULT WINAPI
1632 IDirectDrawSurfaceImpl_UpdateOverlay(IDirectDrawSurface7 *iface,
1634 IDirectDrawSurface7 *DstSurface,
1639 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1640 IDirectDrawSurfaceImpl *Dst = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DstSurface);
1641 TRACE("(%p)->(%p,%p,%p,%x,%p): Relay\n", This, SrcRect, Dst, DstRect, Flags, FX);
1643 return IWineD3DSurface_UpdateOverlay(This->WineD3DSurface,
1645 Dst ? Dst->WineD3DSurface : NULL,
1648 (WINEDDOVERLAYFX *) FX);
1651 /*****************************************************************************
1652 * IDirectDrawSurface7::UpdateOverlayDisplay
1654 * The DX7 sdk says that it's not implemented
1659 * Returns: DDERR_UNSUPPORTED, because we don't support overlays
1661 *****************************************************************************/
1662 static HRESULT WINAPI
1663 IDirectDrawSurfaceImpl_UpdateOverlayDisplay(IDirectDrawSurface7 *iface,
1666 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1667 TRACE("(%p)->(%x)\n", This, Flags);
1668 return DDERR_UNSUPPORTED;
1671 /*****************************************************************************
1672 * IDirectDrawSurface7::UpdateOverlayZOrder
1674 * Sets an overlay's Z order
1677 * Flags: DDOVERZ_* flags
1678 * DDSRef: Defines the relative position in the overlay chain
1681 * DDERR_NOTOVERLAYSURFACE, because we don't support overlays
1683 *****************************************************************************/
1684 static HRESULT WINAPI
1685 IDirectDrawSurfaceImpl_UpdateOverlayZOrder(IDirectDrawSurface7 *iface,
1687 IDirectDrawSurface7 *DDSRef)
1689 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1690 IDirectDrawSurfaceImpl *Ref = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DDSRef);
1692 TRACE("(%p)->(%x,%p): Relay\n", This, Flags, Ref);
1693 return IWineD3DSurface_UpdateOverlayZOrder(This->WineD3DSurface,
1695 Ref ? Ref->WineD3DSurface : NULL);
1698 /*****************************************************************************
1699 * IDirectDrawSurface7::GetDDInterface
1701 * Returns the IDirectDraw7 interface pointer of the DirectDraw object this
1702 * surface belongs to
1705 * DD: Address to write the interface pointer to
1709 * DDERR_INVALIDPARAMS if DD is NULL
1711 *****************************************************************************/
1712 static HRESULT WINAPI
1713 IDirectDrawSurfaceImpl_GetDDInterface(IDirectDrawSurface7 *iface,
1716 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1718 TRACE("(%p)->(%p)\n",This,DD);
1721 return DDERR_INVALIDPARAMS;
1723 switch(This->version)
1726 *((IDirectDraw7 **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw7);
1727 IDirectDraw7_AddRef(*(IDirectDraw7 **) DD);
1731 *((IDirectDraw4 **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw4);
1732 IDirectDraw4_AddRef(*(IDirectDraw4 **) DD);
1736 *((IDirectDraw2 **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw2);
1737 IDirectDraw_AddRef( *(IDirectDraw2 **) DD);
1741 *((IDirectDraw **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw);
1742 IDirectDraw_AddRef( *(IDirectDraw **) DD);
1750 /* This seems also windows implementation specific - I don't think WineD3D needs this */
1751 static HRESULT WINAPI IDirectDrawSurfaceImpl_ChangeUniquenessValue(IDirectDrawSurface7 *iface)
1753 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1754 volatile IDirectDrawSurfaceImpl* vThis = This;
1756 TRACE("(%p)\n",This);
1757 /* A uniqueness value of 0 is apparently special.
1758 * This needs to be checked. */
1760 DWORD old_uniqueness_value = vThis->uniqueness_value;
1761 DWORD new_uniqueness_value = old_uniqueness_value+1;
1763 if (old_uniqueness_value == 0) break;
1764 if (new_uniqueness_value == 0) new_uniqueness_value = 1;
1766 if (InterlockedCompareExchange((LONG*)&vThis->uniqueness_value,
1767 old_uniqueness_value,
1768 new_uniqueness_value)
1769 == old_uniqueness_value)
1776 static HRESULT WINAPI IDirectDrawSurfaceImpl_GetUniquenessValue(IDirectDrawSurface7 *iface, LPDWORD pValue)
1778 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1780 TRACE("(%p)->(%p)\n",This,pValue);
1781 *pValue = This->uniqueness_value;
1785 /*****************************************************************************
1786 * IDirectDrawSurface7::SetLOD
1788 * Sets the level of detail of a texture
1791 * MaxLOD: LOD to set
1795 * DDERR_INVALIDOBJECT if the surface is invalid for this method
1797 *****************************************************************************/
1798 static HRESULT WINAPI
1799 IDirectDrawSurfaceImpl_SetLOD(IDirectDrawSurface7 *iface,
1802 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1803 TRACE("(%p)->(%d)\n", This, MaxLOD);
1805 if (!(This->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE))
1806 return DDERR_INVALIDOBJECT;
1808 if(!This->wineD3DTexture)
1810 ERR("(%p) The DirectDraw texture has no WineD3DTexture!\n", This);
1811 return DDERR_INVALIDOBJECT;
1814 return IWineD3DBaseTexture_SetLOD(This->wineD3DTexture,
1818 /*****************************************************************************
1819 * IDirectDrawSurface7::GetLOD
1821 * Returns the level of detail of a Direct3D texture
1824 * MaxLOD: Address to write the LOD to
1828 * DDERR_INVALIDPARAMS if MaxLOD is NULL
1829 * DDERR_INVALIDOBJECT if the surface is invalid for this method
1831 *****************************************************************************/
1832 static HRESULT WINAPI
1833 IDirectDrawSurfaceImpl_GetLOD(IDirectDrawSurface7 *iface,
1836 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1837 TRACE("(%p)->(%p)\n", This, MaxLOD);
1840 return DDERR_INVALIDPARAMS;
1842 if (!(This->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE))
1843 return DDERR_INVALIDOBJECT;
1845 *MaxLOD = IWineD3DBaseTexture_GetLOD(This->wineD3DTexture);
1849 /*****************************************************************************
1850 * IDirectDrawSurface7::BltFast
1852 * Performs a fast Blit.
1855 * dstx: The x coordinate to blit to on the destination
1856 * dsty: The y coordinate to blit to on the destination
1857 * Source: The source surface
1858 * rsrc: The source rectangle
1859 * trans: Type of transfer. Some DDBLTFAST_* flags
1863 * For more details, see IWineD3DSurface::BltFast
1865 *****************************************************************************/
1866 static HRESULT WINAPI
1867 IDirectDrawSurfaceImpl_BltFast(IDirectDrawSurface7 *iface,
1870 IDirectDrawSurface7 *Source,
1874 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1876 IDirectDrawSurfaceImpl *src = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Source);
1877 TRACE("(%p)->(%d,%d,%p,%p,%d): Relay\n", This, dstx, dsty, Source, rsrc, trans);
1879 hr = IWineD3DSurface_BltFast(This->WineD3DSurface,
1881 src ? src->WineD3DSurface : NULL,
1886 case WINED3DERR_NOTAVAILABLE: return DDERR_UNSUPPORTED;
1887 case WINED3DERR_WRONGTEXTUREFORMAT: return DDERR_INVALIDPIXELFORMAT;
1892 /*****************************************************************************
1893 * IDirectDrawSurface7::GetClipper
1895 * Returns the IDirectDrawClipper interface of the clipper assigned to this
1899 * Clipper: Address to store the interface pointer at
1903 * DDERR_INVALIDPARAMS if Clipper is NULL
1904 * DDERR_NOCLIPPERATTACHED if there's no clipper attached
1906 *****************************************************************************/
1907 static HRESULT WINAPI
1908 IDirectDrawSurfaceImpl_GetClipper(IDirectDrawSurface7 *iface,
1909 IDirectDrawClipper **Clipper)
1911 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1912 TRACE("(%p)->(%p)\n", This, Clipper);
1915 return DDERR_INVALIDPARAMS;
1917 if(This->clipper == NULL)
1918 return DDERR_NOCLIPPERATTACHED;
1920 *Clipper = ICOM_INTERFACE(This->clipper, IDirectDrawClipper);
1921 IDirectDrawClipper_AddRef(*Clipper);
1925 /*****************************************************************************
1926 * IDirectDrawSurface7::SetClipper
1928 * Sets a clipper for the surface
1931 * Clipper: IDirectDrawClipper interface of the clipper to set
1936 *****************************************************************************/
1937 static HRESULT WINAPI
1938 IDirectDrawSurfaceImpl_SetClipper(IDirectDrawSurface7 *iface,
1939 IDirectDrawClipper *Clipper)
1941 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1942 IDirectDrawClipperImpl *oldClipper = This->clipper;
1944 TRACE("(%p)->(%p)\n",This,Clipper);
1945 if (ICOM_OBJECT(IDirectDrawClipperImpl, IDirectDrawClipper, Clipper) == This->clipper)
1948 This->clipper = ICOM_OBJECT(IDirectDrawClipperImpl, IDirectDrawClipper, Clipper);
1950 if (Clipper != NULL)
1951 IDirectDrawClipper_AddRef(Clipper);
1953 IDirectDrawClipper_Release(ICOM_INTERFACE(oldClipper, IDirectDrawClipper));
1958 /*****************************************************************************
1959 * IDirectDrawSurface7::SetSurfaceDesc
1961 * Sets the surface description. It can override the pixel format, the surface
1963 * It's not really tested.
1966 * DDSD: Pointer to the new surface description to set
1971 * DDERR_INVALIDPARAMS if DDSD is NULL
1973 *****************************************************************************/
1974 static HRESULT WINAPI
1975 IDirectDrawSurfaceImpl_SetSurfaceDesc(IDirectDrawSurface7 *iface,
1976 DDSURFACEDESC2 *DDSD,
1979 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1980 WINED3DFORMAT newFormat = WINED3DFMT_UNKNOWN;
1982 TRACE("(%p)->(%p,%x)\n", This, DDSD, Flags);
1985 return DDERR_INVALIDPARAMS;
1987 if (DDSD->dwFlags & DDSD_LPSURFACE && DDSD->lpSurface)
1989 ERR("Setting the surface memory isn't supported yet\n");
1990 return DDERR_INVALIDPARAMS;
1993 if (DDSD->dwFlags & DDSD_PIXELFORMAT)
1995 newFormat = PixelFormat_DD2WineD3D(&DDSD->u4.ddpfPixelFormat);
1997 if(newFormat == WINED3DFMT_UNKNOWN)
1999 ERR("Requested to set an unknown pixelformat\n");
2000 return DDERR_INVALIDPARAMS;
2002 if(newFormat != PixelFormat_DD2WineD3D(&This->surface_desc.u4.ddpfPixelFormat) )
2004 hr = IWineD3DSurface_SetFormat(This->WineD3DSurface,
2006 if(hr != DD_OK) return hr;
2009 if (DDSD->dwFlags & DDSD_CKDESTOVERLAY)
2011 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2013 (WINEDDCOLORKEY *) &DDSD->u3.ddckCKDestOverlay);
2015 if (DDSD->dwFlags & DDSD_CKDESTBLT)
2017 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2019 (WINEDDCOLORKEY *) &DDSD->ddckCKDestBlt);
2021 if (DDSD->dwFlags & DDSD_CKSRCOVERLAY)
2023 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2025 (WINEDDCOLORKEY *) &DDSD->ddckCKSrcOverlay);
2027 if (DDSD->dwFlags & DDSD_CKSRCBLT)
2029 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2031 (WINEDDCOLORKEY *) &DDSD->ddckCKSrcBlt);
2033 if (DDSD->dwFlags & DDSD_LPSURFACE)
2035 hr = IWineD3DSurface_SetMem(This->WineD3DSurface, DDSD->lpSurface);
2036 if(hr != WINED3D_OK)
2038 /* No need for a trace here, wined3d does that for us */
2043 This->surface_desc = *DDSD;
2048 /*****************************************************************************
2049 * IDirectDrawSurface7::GetPalette
2051 * Returns the IDirectDrawPalette interface of the palette currently assigned
2055 * Pal: Address to write the interface pointer to
2059 * DDERR_INVALIDPARAMS if Pal is NULL
2061 *****************************************************************************/
2062 static HRESULT WINAPI
2063 IDirectDrawSurfaceImpl_GetPalette(IDirectDrawSurface7 *iface,
2064 IDirectDrawPalette **Pal)
2066 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2067 IWineD3DPalette *wPal;
2069 TRACE("(%p)->(%p): Relay\n", This, Pal);
2072 return DDERR_INVALIDPARAMS;
2074 hr = IWineD3DSurface_GetPalette(This->WineD3DSurface, &wPal);
2075 if(hr != DD_OK) return hr;
2079 hr = IWineD3DPalette_GetParent(wPal, (IUnknown **) Pal);
2084 hr = DDERR_NOPALETTEATTACHED;
2090 /*****************************************************************************
2093 * EnumAttachedSurface callback for SetColorKey. Used to set color keys
2094 * recursively in the surface tree
2096 *****************************************************************************/
2100 WINEDDCOLORKEY *CKey;
2104 static HRESULT WINAPI
2105 SetColorKeyEnum(IDirectDrawSurface7 *surface,
2106 DDSURFACEDESC2 *desc,
2109 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, surface);
2110 struct SCKContext *ctx = context;
2113 hr = IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2118 WARN("IWineD3DSurface_SetColorKey failed, hr = %08x\n", hr);
2122 IDirectDrawSurface7_EnumAttachedSurfaces(surface,
2125 IDirectDrawSurface7_Release(surface);
2126 return DDENUMRET_OK;
2129 /*****************************************************************************
2130 * IDirectDrawSurface7::SetColorKey
2132 * Sets the color keying options for the surface. Observations showed that
2133 * in case of complex surfaces the color key has to be assigned to all
2138 * CKey: The new color key
2142 * See IWineD3DSurface::SetColorKey for details
2144 *****************************************************************************/
2145 static HRESULT WINAPI
2146 IDirectDrawSurfaceImpl_SetColorKey(IDirectDrawSurface7 *iface,
2150 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2151 struct SCKContext ctx = { DD_OK, (WINEDDCOLORKEY *) CKey, Flags };
2152 TRACE("(%p)->(%x,%p)\n", This, Flags, CKey);
2156 switch (Flags & ~DDCKEY_COLORSPACE)
2158 case DDCKEY_DESTBLT:
2159 This->surface_desc.ddckCKDestBlt = *CKey;
2160 This->surface_desc.dwFlags |= DDSD_CKDESTBLT;
2163 case DDCKEY_DESTOVERLAY:
2164 This->surface_desc.u3.ddckCKDestOverlay = *CKey;
2165 This->surface_desc.dwFlags |= DDSD_CKDESTOVERLAY;
2168 case DDCKEY_SRCOVERLAY:
2169 This->surface_desc.ddckCKSrcOverlay = *CKey;
2170 This->surface_desc.dwFlags |= DDSD_CKSRCOVERLAY;
2174 This->surface_desc.ddckCKSrcBlt = *CKey;
2175 This->surface_desc.dwFlags |= DDSD_CKSRCBLT;
2179 return DDERR_INVALIDPARAMS;
2184 switch (Flags & ~DDCKEY_COLORSPACE)
2186 case DDCKEY_DESTBLT:
2187 This->surface_desc.dwFlags &= ~DDSD_CKDESTBLT;
2190 case DDCKEY_DESTOVERLAY:
2191 This->surface_desc.dwFlags &= ~DDSD_CKDESTOVERLAY;
2194 case DDCKEY_SRCOVERLAY:
2195 This->surface_desc.dwFlags &= ~DDSD_CKSRCOVERLAY;
2199 This->surface_desc.dwFlags &= ~DDSD_CKSRCBLT;
2203 return DDERR_INVALIDPARAMS;
2206 ctx.ret = IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2209 IDirectDrawSurface7_EnumAttachedSurfaces(iface,
2214 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
2215 default: return ctx.ret;
2219 /*****************************************************************************
2220 * IDirectDrawSurface7::SetPalette
2222 * Assigns a DirectDrawPalette object to the surface
2225 * Pal: Interface to the palette to set
2230 *****************************************************************************/
2231 static HRESULT WINAPI
2232 IDirectDrawSurfaceImpl_SetPalette(IDirectDrawSurface7 *iface,
2233 IDirectDrawPalette *Pal)
2235 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2236 IDirectDrawPalette *oldPal;
2237 IDirectDrawSurfaceImpl *surf;
2238 IDirectDrawPaletteImpl *PalImpl = ICOM_OBJECT(IDirectDrawPaletteImpl, IDirectDrawPalette, Pal);
2240 TRACE("(%p)->(%p)\n", This, Pal);
2242 /* Find the old palette */
2243 hr = IDirectDrawSurface_GetPalette(iface, &oldPal);
2244 if(hr != DD_OK && hr != DDERR_NOPALETTEATTACHED) return hr;
2245 if(oldPal) IDirectDrawPalette_Release(oldPal); /* For the GetPalette */
2247 /* Set the new Palette */
2248 IWineD3DSurface_SetPalette(This->WineD3DSurface,
2249 PalImpl ? PalImpl->wineD3DPalette : NULL);
2250 /* AddRef the Palette */
2251 if(Pal) IDirectDrawPalette_AddRef(Pal);
2253 /* Release the old palette */
2254 if(oldPal) IDirectDrawPalette_Release(oldPal);
2256 /* If this is a front buffer, also update the back buffers
2257 * TODO: How do things work for palettized cube textures?
2259 if(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
2261 /* For primary surfaces the tree is just a list, so the simpler scheme fits too */
2262 DDSCAPS2 caps2 = { DDSCAPS_PRIMARYSURFACE, 0, 0, 0 };
2267 IDirectDrawSurface7 *attach;
2269 hr = IDirectDrawSurface7_GetAttachedSurface(ICOM_INTERFACE(surf, IDirectDrawSurface7),
2276 TRACE("Setting palette on %p\n", attach);
2277 IDirectDrawSurface7_SetPalette(attach,
2279 surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, attach);
2280 IDirectDrawSurface7_Release(attach);
2287 /*****************************************************************************
2289 *****************************************************************************/
2291 const IDirectDrawSurface7Vtbl IDirectDrawSurface7_Vtbl =
2294 IDirectDrawSurfaceImpl_QueryInterface,
2295 IDirectDrawSurfaceImpl_AddRef,
2296 IDirectDrawSurfaceImpl_Release,
2297 /*** IDirectDrawSurface ***/
2298 IDirectDrawSurfaceImpl_AddAttachedSurface,
2299 IDirectDrawSurfaceImpl_AddOverlayDirtyRect,
2300 IDirectDrawSurfaceImpl_Blt,
2301 IDirectDrawSurfaceImpl_BltBatch,
2302 IDirectDrawSurfaceImpl_BltFast,
2303 IDirectDrawSurfaceImpl_DeleteAttachedSurface,
2304 IDirectDrawSurfaceImpl_EnumAttachedSurfaces,
2305 IDirectDrawSurfaceImpl_EnumOverlayZOrders,
2306 IDirectDrawSurfaceImpl_Flip,
2307 IDirectDrawSurfaceImpl_GetAttachedSurface,
2308 IDirectDrawSurfaceImpl_GetBltStatus,
2309 IDirectDrawSurfaceImpl_GetCaps,
2310 IDirectDrawSurfaceImpl_GetClipper,
2311 IDirectDrawSurfaceImpl_GetColorKey,
2312 IDirectDrawSurfaceImpl_GetDC,
2313 IDirectDrawSurfaceImpl_GetFlipStatus,
2314 IDirectDrawSurfaceImpl_GetOverlayPosition,
2315 IDirectDrawSurfaceImpl_GetPalette,
2316 IDirectDrawSurfaceImpl_GetPixelFormat,
2317 IDirectDrawSurfaceImpl_GetSurfaceDesc,
2318 IDirectDrawSurfaceImpl_Initialize,
2319 IDirectDrawSurfaceImpl_IsLost,
2320 IDirectDrawSurfaceImpl_Lock,
2321 IDirectDrawSurfaceImpl_ReleaseDC,
2322 IDirectDrawSurfaceImpl_Restore,
2323 IDirectDrawSurfaceImpl_SetClipper,
2324 IDirectDrawSurfaceImpl_SetColorKey,
2325 IDirectDrawSurfaceImpl_SetOverlayPosition,
2326 IDirectDrawSurfaceImpl_SetPalette,
2327 IDirectDrawSurfaceImpl_Unlock,
2328 IDirectDrawSurfaceImpl_UpdateOverlay,
2329 IDirectDrawSurfaceImpl_UpdateOverlayDisplay,
2330 IDirectDrawSurfaceImpl_UpdateOverlayZOrder,
2331 /*** IDirectDrawSurface2 ***/
2332 IDirectDrawSurfaceImpl_GetDDInterface,
2333 IDirectDrawSurfaceImpl_PageLock,
2334 IDirectDrawSurfaceImpl_PageUnlock,
2335 /*** IDirectDrawSurface3 ***/
2336 IDirectDrawSurfaceImpl_SetSurfaceDesc,
2337 /*** IDirectDrawSurface4 ***/
2338 IDirectDrawSurfaceImpl_SetPrivateData,
2339 IDirectDrawSurfaceImpl_GetPrivateData,
2340 IDirectDrawSurfaceImpl_FreePrivateData,
2341 IDirectDrawSurfaceImpl_GetUniquenessValue,
2342 IDirectDrawSurfaceImpl_ChangeUniquenessValue,
2343 /*** IDirectDrawSurface7 ***/
2344 IDirectDrawSurfaceImpl_SetPriority,
2345 IDirectDrawSurfaceImpl_GetPriority,
2346 IDirectDrawSurfaceImpl_SetLOD,
2347 IDirectDrawSurfaceImpl_GetLOD