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);
556 || (Rect->left > Rect->right)
557 || (Rect->top > Rect->bottom)
558 || (Rect->right > This->surface_desc.dwWidth)
559 || (Rect->bottom > This->surface_desc.dwHeight))
561 WARN("Trying to lock an invalid rectangle, returning DDERR_INVALIDPARAMS\n");
562 return DDERR_INVALIDPARAMS;
567 return DDERR_INVALIDPARAMS;
569 /* Should I check for the handle to be NULL?
571 * The DDLOCK flags and the D3DLOCK flags are equal
572 * for the supported values. The others are ignored by WineD3D
575 /* Hmm. Anarchy online passes an uninitialized surface descriptor,
576 * that means it doesn't have dwSize set. Init it to some sane
579 if(DDSD->dwSize <= sizeof(DDSURFACEDESC))
581 DDSD->dwSize = sizeof(DDSURFACEDESC);
585 DDSD->dwSize = sizeof(DDSURFACEDESC2);
588 DD_STRUCT_COPY_BYSIZE(DDSD,&(This->surface_desc));
589 hr = IWineD3DSurface_LockRect(This->WineD3DSurface,
593 if(hr != D3D_OK) return hr;
595 /* Override the memory area. The pitch should be set already. Strangely windows
596 * does not set the LPSURFACE flag on locked surfaces !?!.
597 * DDSD->dwFlags |= DDSD_LPSURFACE;
599 DDSD->lpSurface = LockedRect.pBits;
601 TRACE("locked surface returning description :\n");
602 if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD);
607 /*****************************************************************************
608 * IDirectDrawSurface7::Unlock
610 * Unlocks an locked surface
613 * Rect: Not used by this implementation
617 * For more details, see IWineD3DSurface::UnlockRect
619 *****************************************************************************/
620 static HRESULT WINAPI
621 IDirectDrawSurfaceImpl_Unlock(IDirectDrawSurface7 *iface,
624 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
625 TRACE("(%p)->(%p)\n", This, pRect);
627 return IWineD3DSurface_UnlockRect(This->WineD3DSurface);
630 /*****************************************************************************
631 * IDirectDrawSurface7::Flip
633 * Flips a surface with the DDSCAPS_FLIP flag. The flip is relayed to
634 * IWineD3DSurface::Flip. Because WineD3D doesn't handle attached surfaces,
635 * the flip target is passed to WineD3D, even if the app didn't specify one
638 * DestOverride: Specifies the surface that will become the new front
639 * buffer. If NULL, the current back buffer is used
640 * Flags: some DirectDraw flags, see include/ddraw.h
644 * DDERR_NOTFLIPPABLE if no flip target could be found
645 * DDERR_INVALIDOBJECT if the surface isn't a front buffer
646 * For more details, see IWineD3DSurface::Flip
648 *****************************************************************************/
649 static HRESULT WINAPI
650 IDirectDrawSurfaceImpl_Flip(IDirectDrawSurface7 *iface,
651 IDirectDrawSurface7 *DestOverride,
654 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
655 IDirectDrawSurfaceImpl *Override = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DestOverride);
656 IDirectDrawSurface7 *Override7;
658 TRACE("(%p)->(%p,%x)\n", This, DestOverride, Flags);
660 /* Flip has to be called from a front buffer
661 * What about overlay surfaces, AFAIK they can flip too?
663 if( !(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER) )
664 return DDERR_INVALIDOBJECT; /* Unckecked */
666 /* WineD3D doesn't keep track of attached surface, so find the target */
671 memset(&Caps, 0, sizeof(Caps));
672 Caps.dwCaps |= DDSCAPS_BACKBUFFER;
673 hr = IDirectDrawSurface7_GetAttachedSurface(iface, &Caps, &Override7);
676 ERR("Can't find a flip target\n");
677 return DDERR_NOTFLIPPABLE; /* Unchecked */
679 Override = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Override7);
681 /* For the GetAttachedSurface */
682 IDirectDrawSurface7_Release(Override7);
685 return IWineD3DSurface_Flip(This->WineD3DSurface,
686 Override->WineD3DSurface,
690 /*****************************************************************************
691 * IDirectDrawSurface7::Blt
693 * Performs a blit on the surface
696 * DestRect: Destination rectangle, can be NULL
697 * SrcSurface: Source surface, can be NULL
698 * SrcRect: Source rectange, can be NULL
700 * DDBltFx: Some extended blt parameters, connected to the flags
704 * See IWineD3DSurface::Blt for more details
706 *****************************************************************************/
707 static HRESULT WINAPI
708 IDirectDrawSurfaceImpl_Blt(IDirectDrawSurface7 *iface,
710 IDirectDrawSurface7 *SrcSurface,
715 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
717 IDirectDrawSurfaceImpl *Src = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, SrcSurface);
718 TRACE("(%p)->(%p,%p,%p,%x,%p)\n", This, DestRect, Src, SrcRect, Flags, DDBltFx);
720 /* Check for validity of the flags here. WineD3D Has the software-opengl selection path and would have
721 * to check at 2 places, and sometimes do double checks. This also saves the call to wined3d :-)
723 if((Flags & DDBLT_KEYSRCOVERRIDE) && (!DDBltFx || Flags & DDBLT_KEYSRC)) {
724 WARN("Invalid source color key parameters, returning DDERR_INVALIDPARAMS\n");
725 return DDERR_INVALIDPARAMS;
728 if((Flags & DDBLT_KEYDESTOVERRIDE) && (!DDBltFx || Flags & DDBLT_KEYDEST)) {
729 WARN("Invalid destination color key parameters, returning DDERR_INVALIDPARAMS\n");
730 return DDERR_INVALIDPARAMS;
733 if(Flags & DDBLT_KEYSRC && (!Src || !(Src->surface_desc.dwFlags & DDSD_CKSRCBLT))) {
734 WARN("DDBLT_KEYDEST blit without color key in surface, returning DDERR_INVALIDPARAMS\n");
735 return DDERR_INVALIDPARAMS;
738 /* TODO: Check if the DDBltFx contains any ddraw surface pointers. If it does, copy the struct,
739 * and replace the ddraw surfaces with the wined3d surfaces
740 * So far no blitting operations using surfaces in the bltfx struct are supported anyway.
742 hr = IWineD3DSurface_Blt(This->WineD3DSurface,
744 Src ? Src->WineD3DSurface : NULL,
747 (WINEDDBLTFX *) DDBltFx,
751 case WINED3DERR_NOTAVAILABLE: return DDERR_UNSUPPORTED;
752 case WINED3DERR_WRONGTEXTUREFORMAT: return DDERR_INVALIDPIXELFORMAT;
757 /*****************************************************************************
758 * IDirectDrawSurface7::AddAttachedSurface
760 * Attaches a surface to another surface. How the surface attachments work
761 * is not totally understood yet, and this method is prone to problems.
762 * he surface that is attached is AddRef-ed.
764 * Tests with complex surfaces suggest that the surface attachments form a
765 * tree, but no method to test this has been found yet.
767 * The attachment list consists of a first surface (first_attached) and
768 * for each surface a pointer to the next attached surface (next_attached).
769 * For the first surface, and a surface that has no attachments
770 * first_attached points to the surface itself. A surface that has
771 * no successors in the chain has next_attached set to NULL.
773 * Newly attached surfaces are attached right after the root surface.
774 * If a surface is attached to a complex surface compound, it's attached to
775 * the surface that the app requested, not the complex root. See
776 * GetAttachedSurface for a description how surfaces are found.
778 * This is how the current implementation works, and it was coded by looking
779 * at the needs of the applications.
781 * So far only Z-Buffer attachments are tested, and they are activated in
782 * WineD3D. Mipmaps could be tricky to activate in WineD3D.
783 * Back buffers should work in 2D mode, but they are not tested(Not sure if
784 * they can be attached at all). Rendering to the primary surface and
785 * switching between that and double buffering is not yet implemented in
786 * WineD3D, so for 3D it might have unexpected results.
789 * Attach: Surface to attach to iface
793 * DDERR_CANNOTATTACHSURFACE if the surface can't be attached for some reason
795 *****************************************************************************/
796 static HRESULT WINAPI
797 IDirectDrawSurfaceImpl_AddAttachedSurface(IDirectDrawSurface7 *iface,
798 IDirectDrawSurface7 *Attach)
800 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
801 IDirectDrawSurfaceImpl *Surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Attach);
802 TRACE("(%p)->(%p)\n", This, Surf);
804 /* Should I make sure to add it to the first complex surface? */
807 return DDERR_CANNOTATTACHSURFACE; /* unchecked */
809 /* MSDN: Only Z buffer surfaces can be attached. An old comment said that apparently
810 * mipmaps and back buffers can be attached too, although our tests say no.
812 if(!(Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
814 /* Write a fixme until we know for sure what is going on */
815 FIXME("Application tries to attach a non Z buffer surface. caps %08x\n",
816 Surf->surface_desc.ddsCaps.dwCaps);
817 return DDERR_CANNOTATTACHSURFACE;
820 /* Set MIPMAPSUBLEVEL if this seems to be one */
821 if (This->surface_desc.ddsCaps.dwCaps &
822 Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
824 Surf->surface_desc.ddsCaps.dwCaps2 |= DDSCAPS2_MIPMAPSUBLEVEL;
825 /* FIXME: we should probably also add to dwMipMapCount of this
826 * and all parent surfaces (update create_texture if you do) */
829 /* Check if the surface is already attached somewhere */
830 if( (Surf->next_attached != NULL) ||
831 (Surf->first_attached != Surf) )
833 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);
834 return DDERR_CANNOTATTACHSURFACE;
837 /* This inserts the new surface at the 2nd position in the chain, right after the root surface */
838 Surf->next_attached = This->next_attached;
839 Surf->first_attached = This->first_attached;
840 This->next_attached = Surf;
842 /* Check if the WineD3D depth stencil needs updating */
843 if(This->ddraw->d3ddevice)
845 IDirect3DDeviceImpl_UpdateDepthStencil(This->ddraw->d3ddevice);
849 * "This method increments the reference count of the surface being attached."
851 IDirectDrawSurface7_AddRef(Attach);
855 /*****************************************************************************
856 * IDirectDrawSurface7::DeleteAttachedSurface
858 * Removes a surface from the attachment chain. The surface's refcount
859 * is decreased by one after it has been removed
862 * Flags: Some flags, not used by this implementation
863 * Attach: Surface to detach
867 * DDERR_SURFACENOTATTACHED if the surface isn't attached to
869 *****************************************************************************/
870 static HRESULT WINAPI
871 IDirectDrawSurfaceImpl_DeleteAttachedSurface(IDirectDrawSurface7 *iface,
873 IDirectDrawSurface7 *Attach)
875 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
876 IDirectDrawSurfaceImpl *Surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Attach);
877 IDirectDrawSurfaceImpl *Prev = This;
878 TRACE("(%p)->(%08x,%p)\n", This, Flags, Surf);
880 if (!Surf || (Surf->first_attached != This) || (Surf == This) )
881 return DDERR_SURFACENOTATTACHED; /* unchecked */
883 /* Remove MIPMAPSUBLEVEL if this seemed to be one */
884 if (This->surface_desc.ddsCaps.dwCaps &
885 Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
887 Surf->surface_desc.ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
888 /* FIXME: we should probably also subtract from dwMipMapCount of this
889 * and all parent surfaces */
892 /* Find the predecessor of the detached surface */
895 if(Prev->next_attached == Surf) break;
896 Prev = Prev->next_attached;
899 /* There must be a surface, otherwise there's a bug */
900 assert(Prev != NULL);
902 /* Unchain the surface */
903 Prev->next_attached = Surf->next_attached;
904 Surf->next_attached = NULL;
905 Surf->first_attached = Surf;
907 /* Check if the WineD3D depth stencil needs updating */
908 if(This->ddraw->d3ddevice)
910 IDirect3DDeviceImpl_UpdateDepthStencil(This->ddraw->d3ddevice);
913 IDirectDrawSurface7_Release(Attach);
917 /*****************************************************************************
918 * IDirectDrawSurface7::AddOverlayDirtyRect
920 * "This method is not currently implemented"
928 *****************************************************************************/
929 static HRESULT WINAPI
930 IDirectDrawSurfaceImpl_AddOverlayDirtyRect(IDirectDrawSurface7 *iface,
933 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
934 TRACE("(%p)->(%p)\n",This,Rect);
936 /* MSDN says it's not implemented. I could forward it to WineD3D,
937 * then we'd implement it, but I don't think that's a good idea
941 return IWineD3DSurface_AddOverlayDirtyRect(This->WineD3DSurface, pRect);
943 return DDERR_UNSUPPORTED; /* unchecked */
946 /*****************************************************************************
947 * IDirectDrawSurface7::GetDC
949 * Returns a GDI device context for the surface
952 * hdc: Address of a HDC variable to store the dc to
956 * DDERR_INVALIDPARAMS if hdc is NULL
957 * For details, see IWineD3DSurface::GetDC
959 *****************************************************************************/
960 static HRESULT WINAPI
961 IDirectDrawSurfaceImpl_GetDC(IDirectDrawSurface7 *iface,
964 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
965 TRACE("(%p)->(%p): Relay\n", This, hdc);
968 return DDERR_INVALIDPARAMS;
970 return IWineD3DSurface_GetDC(This->WineD3DSurface,
974 /*****************************************************************************
975 * IDirectDrawSurface7::ReleaseDC
977 * Releases the DC that was constructed with GetDC
980 * hdc: HDC to release
984 * For more details, see IWineD3DSurface::ReleaseDC
986 *****************************************************************************/
987 static HRESULT WINAPI
988 IDirectDrawSurfaceImpl_ReleaseDC(IDirectDrawSurface7 *iface,
991 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
992 TRACE("(%p)->(%p): Relay\n", This, hdc);
994 return IWineD3DSurface_ReleaseDC(This->WineD3DSurface, hdc);
997 /*****************************************************************************
998 * IDirectDrawSurface7::GetCaps
1000 * Returns the surface's caps
1003 * Caps: Address to write the caps to
1007 * DDERR_INVALIDPARAMS if Caps is NULL
1009 *****************************************************************************/
1010 static HRESULT WINAPI
1011 IDirectDrawSurfaceImpl_GetCaps(IDirectDrawSurface7 *iface,
1014 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1015 TRACE("(%p)->(%p)\n",This,Caps);
1018 return DDERR_INVALIDPARAMS;
1020 *Caps = This->surface_desc.ddsCaps;
1024 /*****************************************************************************
1025 * IDirectDrawSurface7::SetPriority
1027 * Sets a texture priority for managed textures.
1030 * Priority: The new priority
1034 * For more details, see IWineD3DSurface::SetPriority
1036 *****************************************************************************/
1037 static HRESULT WINAPI
1038 IDirectDrawSurfaceImpl_SetPriority(IDirectDrawSurface7 *iface, DWORD Priority)
1040 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1041 TRACE("(%p)->(%d): Relay!\n",This,Priority);
1043 return IWineD3DSurface_SetPriority(This->WineD3DSurface, Priority);
1046 /*****************************************************************************
1047 * IDirectDrawSurface7::GetPriority
1049 * Returns the surface's priority
1052 * Priority: Address of a variable to write the priority to
1056 * DDERR_INVALIDPARAMS if Priority == NULL
1057 * For more details, see IWineD3DSurface::GetPriority
1059 *****************************************************************************/
1060 static HRESULT WINAPI
1061 IDirectDrawSurfaceImpl_GetPriority(IDirectDrawSurface7 *iface,
1064 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1065 TRACE("(%p)->(%p): Relay\n",This,Priority);
1068 return DDERR_INVALIDPARAMS;
1070 *Priority = IWineD3DSurface_GetPriority(This->WineD3DSurface);
1074 /*****************************************************************************
1075 * IDirectDrawSurface7::SetPrivateData
1077 * Stores some data in the surface that is intended for the application's
1081 * tag: GUID that identifies the data
1082 * Data: Pointer to the private data
1083 * Size: Size of the private data
1088 * For more details, see IWineD3DSurface::SetPrivateData
1090 *****************************************************************************/
1091 static HRESULT WINAPI
1092 IDirectDrawSurfaceImpl_SetPrivateData(IDirectDrawSurface7 *iface,
1098 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1099 TRACE("(%p)->(%s,%p,%d,%x): Relay\n", This, debugstr_guid(tag), Data, Size, Flags);
1101 return IWineD3DSurface_SetPrivateData(This->WineD3DSurface,
1108 /*****************************************************************************
1109 * IDirectDrawSurface7::GetPrivateData
1111 * Returns the private data set with IDirectDrawSurface7::SetPrivateData
1114 * tag: GUID of the data to return
1115 * Data: Address where to write the data to
1116 * Size: Size of the buffer at Data
1120 * DDERR_INVALIDPARAMS if Data is NULL
1121 * For more details, see IWineD3DSurface::GetPrivateData
1123 *****************************************************************************/
1124 static HRESULT WINAPI
1125 IDirectDrawSurfaceImpl_GetPrivateData(IDirectDrawSurface7 *iface,
1130 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1131 TRACE("(%p)->(%s,%p,%p): Relay\n", This, debugstr_guid(tag), Data, Size);
1134 return DDERR_INVALIDPARAMS;
1136 return IWineD3DSurface_GetPrivateData(This->WineD3DSurface,
1142 /*****************************************************************************
1143 * IDirectDrawSurface7::FreePrivateData
1145 * Frees private data stored in the surface
1148 * tag: Tag of the data to free
1152 * For more details, see IWineD3DSurface::FreePrivateData
1154 *****************************************************************************/
1155 static HRESULT WINAPI
1156 IDirectDrawSurfaceImpl_FreePrivateData(IDirectDrawSurface7 *iface,
1159 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1160 TRACE("(%p)->(%s): Relay\n", This, debugstr_guid(tag));
1162 return IWineD3DSurface_FreePrivateData(This->WineD3DSurface, tag);
1165 /*****************************************************************************
1166 * IDirectDrawSurface7::PageLock
1168 * Prevents a sysmem surface from being paged out
1171 * Flags: Not used, must be 0(unchecked)
1174 * DD_OK, because it's a stub
1176 *****************************************************************************/
1177 static HRESULT WINAPI
1178 IDirectDrawSurfaceImpl_PageLock(IDirectDrawSurface7 *iface,
1181 TRACE("(%p)->(%x)\n", iface, Flags);
1183 /* This is Windows memory management related - we don't need this */
1187 /*****************************************************************************
1188 * IDirectDrawSurface7::PageUnlock
1190 * Allows a sysmem surface to be paged out
1193 * Flags: Not used, must be 0(unckeched)
1196 * DD_OK, because it's a stub
1198 *****************************************************************************/
1199 static HRESULT WINAPI
1200 IDirectDrawSurfaceImpl_PageUnlock(IDirectDrawSurface7 *iface,
1203 TRACE("(%p)->(%x)\n", iface, Flags);
1208 /*****************************************************************************
1209 * IDirectDrawSurface7::BltBatch
1211 * An unimplemented function
1219 *****************************************************************************/
1220 static HRESULT WINAPI IDirectDrawSurfaceImpl_BltBatch(IDirectDrawSurface7 *iface, DDBLTBATCH *Batch, DWORD Count, DWORD Flags)
1222 TRACE("(%p)->(%p,%d,%08x)\n",iface,Batch,Count,Flags);
1224 /* MSDN: "not currently implemented" */
1225 return DDERR_UNSUPPORTED;
1228 /*****************************************************************************
1229 * IDirectDrawSurface7::EnumAttachedSurfaces
1231 * Enumerates all surfaces attached to this surface
1234 * context: Pointer to pass unmodified to the callback
1235 * cb: Callback function to call for each surface
1239 * DDERR_INVALIDPARAMS if cb is NULL
1241 *****************************************************************************/
1242 static HRESULT WINAPI
1243 IDirectDrawSurfaceImpl_EnumAttachedSurfaces(IDirectDrawSurface7 *iface,
1245 LPDDENUMSURFACESCALLBACK7 cb)
1247 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1248 IDirectDrawSurfaceImpl *surf;
1249 DDSURFACEDESC2 desc;
1252 /* Attached surfaces aren't handled in WineD3D */
1253 TRACE("(%p)->(%p,%p)\n",This,context,cb);
1256 return DDERR_INVALIDPARAMS;
1258 for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
1260 surf = This->complex_array[i];
1263 IDirectDrawSurface7_AddRef(ICOM_INTERFACE(surf, IDirectDrawSurface7));
1264 desc = surf->surface_desc;
1265 /* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
1266 if (cb(ICOM_INTERFACE(surf, IDirectDrawSurface7), &desc, context) == DDENUMRET_CANCEL)
1270 for (surf = This->next_attached; surf != NULL; surf = surf->next_attached)
1272 IDirectDrawSurface7_AddRef(ICOM_INTERFACE(surf, IDirectDrawSurface7));
1273 desc = surf->surface_desc;
1274 /* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
1275 if (cb( ICOM_INTERFACE(surf, IDirectDrawSurface7), &desc, context) == DDENUMRET_CANCEL)
1279 TRACE(" end of enumeration.\n");
1284 /*****************************************************************************
1285 * IDirectDrawSurface7::EnumOverlayZOrders
1287 * "Enumerates the overlay surfaces on the specified destination"
1290 * Flags: DDENUMOVERLAYZ_BACKTOFRONT or DDENUMOVERLAYZ_FRONTTOBACK
1291 * context: context to pass back to the callback
1292 * cb: callback function to call for each enumerated surface
1295 * DD_OK, because it's a stub
1297 *****************************************************************************/
1298 static HRESULT WINAPI
1299 IDirectDrawSurfaceImpl_EnumOverlayZOrders(IDirectDrawSurface7 *iface,
1302 LPDDENUMSURFACESCALLBACK7 cb)
1304 FIXME("(%p)->(%x,%p,%p): Stub!\n", iface, Flags, context, cb);
1309 /*****************************************************************************
1310 * IDirectDrawSurface7::GetBltStatus
1312 * Returns the blitting status
1315 * Flags: DDGBS_CANBLT or DDGBS_ISBLTDONE
1318 * See IWineD3DSurface::Blt
1320 *****************************************************************************/
1321 static HRESULT WINAPI
1322 IDirectDrawSurfaceImpl_GetBltStatus(IDirectDrawSurface7 *iface,
1325 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1327 TRACE("(%p)->(%x): Relay\n", This, Flags);
1329 hr = IWineD3DSurface_GetBltStatus(This->WineD3DSurface, Flags);
1332 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1337 /*****************************************************************************
1338 * IDirectDrawSurface7::GetColorKey
1340 * Returns the color key assigned to the surface
1344 * CKey: Address to store the key to
1348 * DDERR_INVALIDPARAMS if CKey is NULL
1350 *****************************************************************************/
1351 static HRESULT WINAPI
1352 IDirectDrawSurfaceImpl_GetColorKey(IDirectDrawSurface7 *iface,
1356 /* There is a DDERR_NOCOLORKEY error, but how do we know if a color key
1357 * isn't there? That's like saying that an int isn't there. (Which MS
1358 * has done in other docs.) */
1359 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1360 TRACE("(%p)->(%08x,%p)\n", This, Flags, CKey);
1363 return DDERR_INVALIDPARAMS;
1367 case DDCKEY_DESTBLT:
1368 *CKey = This->surface_desc.ddckCKDestBlt;
1371 case DDCKEY_DESTOVERLAY:
1372 *CKey = This->surface_desc.u3.ddckCKDestOverlay;
1376 *CKey = This->surface_desc.ddckCKSrcBlt;
1379 case DDCKEY_SRCOVERLAY:
1380 *CKey = This->surface_desc.ddckCKSrcOverlay;
1384 return DDERR_INVALIDPARAMS;
1390 /*****************************************************************************
1391 * IDirectDrawSurface7::GetFlipStatus
1393 * Returns the flipping status of the surface
1396 * Flags: DDGFS_CANFLIP of DDGFS_ISFLIPDONE
1399 * See IWineD3DSurface::GetFlipStatus
1401 *****************************************************************************/
1402 static HRESULT WINAPI
1403 IDirectDrawSurfaceImpl_GetFlipStatus(IDirectDrawSurface7 *iface,
1406 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1408 TRACE("(%p)->(%x): Relay\n", This, Flags);
1410 hr = IWineD3DSurface_GetFlipStatus(This->WineD3DSurface, Flags);
1413 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1418 /*****************************************************************************
1419 * IDirectDrawSurface7::GetOverlayPosition
1421 * Returns the display coordinates of a visible and active overlay surface
1428 * DDERR_NOTAOVERLAYSURFACE, because it's a stub
1429 *****************************************************************************/
1430 static HRESULT WINAPI
1431 IDirectDrawSurfaceImpl_GetOverlayPosition(IDirectDrawSurface7 *iface,
1434 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1435 TRACE("(%p)->(%p,%p): Relay\n", This, X, Y);
1437 return IWineD3DSurface_GetOverlayPosition(This->WineD3DSurface,
1442 /*****************************************************************************
1443 * IDirectDrawSurface7::GetPixelFormat
1445 * Returns the pixel format of the Surface
1448 * PixelFormat: Pointer to a DDPIXELFORMAT structure to which the pixel
1449 * format should be written
1453 * DDERR_INVALIDPARAMS if PixelFormat is NULL
1455 *****************************************************************************/
1456 static HRESULT WINAPI
1457 IDirectDrawSurfaceImpl_GetPixelFormat(IDirectDrawSurface7 *iface,
1458 DDPIXELFORMAT *PixelFormat)
1460 /* What is DDERR_INVALIDSURFACETYPE for here? */
1461 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1462 TRACE("(%p)->(%p)\n",This,PixelFormat);
1465 return DDERR_INVALIDPARAMS;
1467 DD_STRUCT_COPY_BYSIZE(PixelFormat,&This->surface_desc.u4.ddpfPixelFormat);
1473 /*****************************************************************************
1474 * IDirectDrawSurface7::GetSurfaceDesc
1476 * Returns the description of this surface
1479 * DDSD: Address of a DDSURFACEDESC2 structure that is to be filled with the
1484 * DDERR_INVALIDPARAMS if DDSD is NULL
1486 *****************************************************************************/
1487 static HRESULT WINAPI
1488 IDirectDrawSurfaceImpl_GetSurfaceDesc(IDirectDrawSurface7 *iface,
1489 DDSURFACEDESC2 *DDSD)
1491 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1493 TRACE("(%p)->(%p)\n",This,DDSD);
1496 return DDERR_INVALIDPARAMS;
1498 if ((DDSD->dwSize < sizeof(DDSURFACEDESC)) ||
1499 (DDSD->dwSize > sizeof(DDSURFACEDESC2)))
1501 ERR("Impossible/Strange struct size %d.\n",DDSD->dwSize);
1502 return DDERR_GENERIC;
1505 DD_STRUCT_COPY_BYSIZE(DDSD,&This->surface_desc);
1506 TRACE("Returning surface desc:\n");
1507 if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD);
1512 /*****************************************************************************
1513 * IDirectDrawSurface7::Initialize
1515 * Initializes the surface. This is a no-op in Wine
1518 * DD: Pointer to an DirectDraw interface
1519 * DDSD: Surface description for initialization
1522 * DDERR_ALREADYINITIALIZED
1524 *****************************************************************************/
1525 static HRESULT WINAPI
1526 IDirectDrawSurfaceImpl_Initialize(IDirectDrawSurface7 *iface,
1528 DDSURFACEDESC2 *DDSD)
1530 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1531 IDirectDrawImpl *ddimpl = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, DD);
1532 TRACE("(%p)->(%p,%p)\n",This,ddimpl,DDSD);
1534 return DDERR_ALREADYINITIALIZED;
1537 /*****************************************************************************
1538 * IDirectDrawSurface7::IsLost
1540 * Checks if the surface is lost
1543 * DD_OK, if the surface is useable
1544 * DDERR_ISLOST if the surface is lost
1545 * See IWineD3DSurface::IsLost for more details
1547 *****************************************************************************/
1548 static HRESULT WINAPI
1549 IDirectDrawSurfaceImpl_IsLost(IDirectDrawSurface7 *iface)
1551 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1553 TRACE("(%p)\n", This);
1555 /* We lose the surface if the implementation was changed */
1556 if(This->ImplType != This->ddraw->ImplType)
1558 /* But this shouldn't happen. When we change the implementation,
1559 * all surfaces are re-created automatically, and their content
1562 ERR(" (%p) Implementation was changed from %d to %d\n", This, This->ImplType, This->ddraw->ImplType);
1563 return DDERR_SURFACELOST;
1566 hr = IWineD3DSurface_IsLost(This->WineD3DSurface);
1569 /* D3D8 and 9 loose full devices, thus there's only a DEVICELOST error.
1570 * WineD3D uses the same error for surfaces
1572 case WINED3DERR_DEVICELOST: return DDERR_SURFACELOST;
1577 /*****************************************************************************
1578 * IDirectDrawSurface7::Restore
1580 * Restores a lost surface. This makes the surface usable again, but
1581 * doesn't reload its old contents
1585 * See IWineD3DSurface::Restore for more details
1587 *****************************************************************************/
1588 static HRESULT WINAPI
1589 IDirectDrawSurfaceImpl_Restore(IDirectDrawSurface7 *iface)
1591 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1592 TRACE("(%p)\n", This);
1594 if(This->ImplType != This->ddraw->ImplType)
1596 /* Call the recreation callback. Make sure to AddRef first */
1597 IDirectDrawSurface_AddRef(iface);
1598 IDirectDrawImpl_RecreateSurfacesCallback(iface,
1599 &This->surface_desc,
1600 NULL /* Not needed */);
1602 return IWineD3DSurface_Restore(This->WineD3DSurface);
1605 /*****************************************************************************
1606 * IDirectDrawSurface7::SetOverlayPosition
1608 * Changes the display coordinates of an overlay surface
1615 * DDERR_NOTAOVERLAYSURFACE, because we don't support overlays right now
1616 *****************************************************************************/
1617 static HRESULT WINAPI
1618 IDirectDrawSurfaceImpl_SetOverlayPosition(IDirectDrawSurface7 *iface,
1622 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1623 TRACE("(%p)->(%d,%d): Relay\n", This, X, Y);
1625 return IWineD3DSurface_SetOverlayPosition(This->WineD3DSurface,
1630 /*****************************************************************************
1631 * IDirectDrawSurface7::UpdateOverlay
1633 * Modifies the attributes of an overlay surface.
1636 * SrcRect: The section of the source being used for the overlay
1637 * DstSurface: Address of the surface that is overlaid
1638 * DstRect: Place of the overlay
1639 * Flags: some DDOVER_* flags
1642 * DDERR_UNSUPPORTED, because we don't support overlays
1644 *****************************************************************************/
1645 static HRESULT WINAPI
1646 IDirectDrawSurfaceImpl_UpdateOverlay(IDirectDrawSurface7 *iface,
1648 IDirectDrawSurface7 *DstSurface,
1653 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1654 IDirectDrawSurfaceImpl *Dst = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DstSurface);
1655 TRACE("(%p)->(%p,%p,%p,%x,%p): Relay\n", This, SrcRect, Dst, DstRect, Flags, FX);
1657 return IWineD3DSurface_UpdateOverlay(This->WineD3DSurface,
1659 Dst ? Dst->WineD3DSurface : NULL,
1662 (WINEDDOVERLAYFX *) FX);
1665 /*****************************************************************************
1666 * IDirectDrawSurface7::UpdateOverlayDisplay
1668 * The DX7 sdk says that it's not implemented
1673 * Returns: DDERR_UNSUPPORTED, because we don't support overlays
1675 *****************************************************************************/
1676 static HRESULT WINAPI
1677 IDirectDrawSurfaceImpl_UpdateOverlayDisplay(IDirectDrawSurface7 *iface,
1680 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1681 TRACE("(%p)->(%x)\n", This, Flags);
1682 return DDERR_UNSUPPORTED;
1685 /*****************************************************************************
1686 * IDirectDrawSurface7::UpdateOverlayZOrder
1688 * Sets an overlay's Z order
1691 * Flags: DDOVERZ_* flags
1692 * DDSRef: Defines the relative position in the overlay chain
1695 * DDERR_NOTOVERLAYSURFACE, because we don't support overlays
1697 *****************************************************************************/
1698 static HRESULT WINAPI
1699 IDirectDrawSurfaceImpl_UpdateOverlayZOrder(IDirectDrawSurface7 *iface,
1701 IDirectDrawSurface7 *DDSRef)
1703 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1704 IDirectDrawSurfaceImpl *Ref = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DDSRef);
1706 TRACE("(%p)->(%x,%p): Relay\n", This, Flags, Ref);
1707 return IWineD3DSurface_UpdateOverlayZOrder(This->WineD3DSurface,
1709 Ref ? Ref->WineD3DSurface : NULL);
1712 /*****************************************************************************
1713 * IDirectDrawSurface7::GetDDInterface
1715 * Returns the IDirectDraw7 interface pointer of the DirectDraw object this
1716 * surface belongs to
1719 * DD: Address to write the interface pointer to
1723 * DDERR_INVALIDPARAMS if DD is NULL
1725 *****************************************************************************/
1726 static HRESULT WINAPI
1727 IDirectDrawSurfaceImpl_GetDDInterface(IDirectDrawSurface7 *iface,
1730 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1732 TRACE("(%p)->(%p)\n",This,DD);
1735 return DDERR_INVALIDPARAMS;
1737 switch(This->version)
1740 *((IDirectDraw7 **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw7);
1741 IDirectDraw7_AddRef(*(IDirectDraw7 **) DD);
1745 *((IDirectDraw4 **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw4);
1746 IDirectDraw4_AddRef(*(IDirectDraw4 **) DD);
1750 *((IDirectDraw2 **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw2);
1751 IDirectDraw_AddRef( *(IDirectDraw2 **) DD);
1755 *((IDirectDraw **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw);
1756 IDirectDraw_AddRef( *(IDirectDraw **) DD);
1764 /* This seems also windows implementation specific - I don't think WineD3D needs this */
1765 static HRESULT WINAPI IDirectDrawSurfaceImpl_ChangeUniquenessValue(IDirectDrawSurface7 *iface)
1767 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1768 volatile IDirectDrawSurfaceImpl* vThis = This;
1770 TRACE("(%p)\n",This);
1771 /* A uniqueness value of 0 is apparently special.
1772 * This needs to be checked. */
1774 DWORD old_uniqueness_value = vThis->uniqueness_value;
1775 DWORD new_uniqueness_value = old_uniqueness_value+1;
1777 if (old_uniqueness_value == 0) break;
1778 if (new_uniqueness_value == 0) new_uniqueness_value = 1;
1780 if (InterlockedCompareExchange((LONG*)&vThis->uniqueness_value,
1781 old_uniqueness_value,
1782 new_uniqueness_value)
1783 == old_uniqueness_value)
1790 static HRESULT WINAPI IDirectDrawSurfaceImpl_GetUniquenessValue(IDirectDrawSurface7 *iface, LPDWORD pValue)
1792 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1794 TRACE("(%p)->(%p)\n",This,pValue);
1795 *pValue = This->uniqueness_value;
1799 /*****************************************************************************
1800 * IDirectDrawSurface7::SetLOD
1802 * Sets the level of detail of a texture
1805 * MaxLOD: LOD to set
1809 * DDERR_INVALIDOBJECT if the surface is invalid for this method
1811 *****************************************************************************/
1812 static HRESULT WINAPI
1813 IDirectDrawSurfaceImpl_SetLOD(IDirectDrawSurface7 *iface,
1816 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1817 TRACE("(%p)->(%d)\n", This, MaxLOD);
1819 if (!(This->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE))
1820 return DDERR_INVALIDOBJECT;
1822 if(!This->wineD3DTexture)
1824 ERR("(%p) The DirectDraw texture has no WineD3DTexture!\n", This);
1825 return DDERR_INVALIDOBJECT;
1828 return IWineD3DBaseTexture_SetLOD(This->wineD3DTexture,
1832 /*****************************************************************************
1833 * IDirectDrawSurface7::GetLOD
1835 * Returns the level of detail of a Direct3D texture
1838 * MaxLOD: Address to write the LOD to
1842 * DDERR_INVALIDPARAMS if MaxLOD is NULL
1843 * DDERR_INVALIDOBJECT if the surface is invalid for this method
1845 *****************************************************************************/
1846 static HRESULT WINAPI
1847 IDirectDrawSurfaceImpl_GetLOD(IDirectDrawSurface7 *iface,
1850 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1851 TRACE("(%p)->(%p)\n", This, MaxLOD);
1854 return DDERR_INVALIDPARAMS;
1856 if (!(This->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE))
1857 return DDERR_INVALIDOBJECT;
1859 *MaxLOD = IWineD3DBaseTexture_GetLOD(This->wineD3DTexture);
1863 /*****************************************************************************
1864 * IDirectDrawSurface7::BltFast
1866 * Performs a fast Blit.
1869 * dstx: The x coordinate to blit to on the destination
1870 * dsty: The y coordinate to blit to on the destination
1871 * Source: The source surface
1872 * rsrc: The source rectangle
1873 * trans: Type of transfer. Some DDBLTFAST_* flags
1877 * For more details, see IWineD3DSurface::BltFast
1879 *****************************************************************************/
1880 static HRESULT WINAPI
1881 IDirectDrawSurfaceImpl_BltFast(IDirectDrawSurface7 *iface,
1884 IDirectDrawSurface7 *Source,
1888 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1890 IDirectDrawSurfaceImpl *src = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Source);
1891 TRACE("(%p)->(%d,%d,%p,%p,%d): Relay\n", This, dstx, dsty, Source, rsrc, trans);
1893 hr = IWineD3DSurface_BltFast(This->WineD3DSurface,
1895 src ? src->WineD3DSurface : NULL,
1900 case WINED3DERR_NOTAVAILABLE: return DDERR_UNSUPPORTED;
1901 case WINED3DERR_WRONGTEXTUREFORMAT: return DDERR_INVALIDPIXELFORMAT;
1906 /*****************************************************************************
1907 * IDirectDrawSurface7::GetClipper
1909 * Returns the IDirectDrawClipper interface of the clipper assigned to this
1913 * Clipper: Address to store the interface pointer at
1917 * DDERR_INVALIDPARAMS if Clipper is NULL
1918 * DDERR_NOCLIPPERATTACHED if there's no clipper attached
1920 *****************************************************************************/
1921 static HRESULT WINAPI
1922 IDirectDrawSurfaceImpl_GetClipper(IDirectDrawSurface7 *iface,
1923 IDirectDrawClipper **Clipper)
1925 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1926 TRACE("(%p)->(%p)\n", This, Clipper);
1929 return DDERR_INVALIDPARAMS;
1931 if(This->clipper == NULL)
1932 return DDERR_NOCLIPPERATTACHED;
1934 *Clipper = ICOM_INTERFACE(This->clipper, IDirectDrawClipper);
1935 IDirectDrawClipper_AddRef(*Clipper);
1939 /*****************************************************************************
1940 * IDirectDrawSurface7::SetClipper
1942 * Sets a clipper for the surface
1945 * Clipper: IDirectDrawClipper interface of the clipper to set
1950 *****************************************************************************/
1951 static HRESULT WINAPI
1952 IDirectDrawSurfaceImpl_SetClipper(IDirectDrawSurface7 *iface,
1953 IDirectDrawClipper *Clipper)
1955 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1956 IDirectDrawClipperImpl *oldClipper = This->clipper;
1958 TRACE("(%p)->(%p)\n",This,Clipper);
1959 if (ICOM_OBJECT(IDirectDrawClipperImpl, IDirectDrawClipper, Clipper) == This->clipper)
1962 This->clipper = ICOM_OBJECT(IDirectDrawClipperImpl, IDirectDrawClipper, Clipper);
1964 if (Clipper != NULL)
1965 IDirectDrawClipper_AddRef(Clipper);
1967 IDirectDrawClipper_Release(ICOM_INTERFACE(oldClipper, IDirectDrawClipper));
1972 /*****************************************************************************
1973 * IDirectDrawSurface7::SetSurfaceDesc
1975 * Sets the surface description. It can override the pixel format, the surface
1977 * It's not really tested.
1980 * DDSD: Pointer to the new surface description to set
1985 * DDERR_INVALIDPARAMS if DDSD is NULL
1987 *****************************************************************************/
1988 static HRESULT WINAPI
1989 IDirectDrawSurfaceImpl_SetSurfaceDesc(IDirectDrawSurface7 *iface,
1990 DDSURFACEDESC2 *DDSD,
1993 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1994 WINED3DFORMAT newFormat = WINED3DFMT_UNKNOWN;
1996 TRACE("(%p)->(%p,%x)\n", This, DDSD, Flags);
1999 return DDERR_INVALIDPARAMS;
2001 if (DDSD->dwFlags & DDSD_LPSURFACE && DDSD->lpSurface)
2003 ERR("Setting the surface memory isn't supported yet\n");
2004 return DDERR_INVALIDPARAMS;
2007 if (DDSD->dwFlags & DDSD_PIXELFORMAT)
2009 newFormat = PixelFormat_DD2WineD3D(&DDSD->u4.ddpfPixelFormat);
2011 if(newFormat == WINED3DFMT_UNKNOWN)
2013 ERR("Requested to set an unknown pixelformat\n");
2014 return DDERR_INVALIDPARAMS;
2016 if(newFormat != PixelFormat_DD2WineD3D(&This->surface_desc.u4.ddpfPixelFormat) )
2018 hr = IWineD3DSurface_SetFormat(This->WineD3DSurface,
2020 if(hr != DD_OK) return hr;
2023 if (DDSD->dwFlags & DDSD_CKDESTOVERLAY)
2025 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2027 (WINEDDCOLORKEY *) &DDSD->u3.ddckCKDestOverlay);
2029 if (DDSD->dwFlags & DDSD_CKDESTBLT)
2031 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2033 (WINEDDCOLORKEY *) &DDSD->ddckCKDestBlt);
2035 if (DDSD->dwFlags & DDSD_CKSRCOVERLAY)
2037 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2039 (WINEDDCOLORKEY *) &DDSD->ddckCKSrcOverlay);
2041 if (DDSD->dwFlags & DDSD_CKSRCBLT)
2043 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2045 (WINEDDCOLORKEY *) &DDSD->ddckCKSrcBlt);
2047 if (DDSD->dwFlags & DDSD_LPSURFACE)
2049 hr = IWineD3DSurface_SetMem(This->WineD3DSurface, DDSD->lpSurface);
2050 if(hr != WINED3D_OK)
2052 /* No need for a trace here, wined3d does that for us */
2057 This->surface_desc = *DDSD;
2062 /*****************************************************************************
2063 * IDirectDrawSurface7::GetPalette
2065 * Returns the IDirectDrawPalette interface of the palette currently assigned
2069 * Pal: Address to write the interface pointer to
2073 * DDERR_INVALIDPARAMS if Pal is NULL
2075 *****************************************************************************/
2076 static HRESULT WINAPI
2077 IDirectDrawSurfaceImpl_GetPalette(IDirectDrawSurface7 *iface,
2078 IDirectDrawPalette **Pal)
2080 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2081 IWineD3DPalette *wPal;
2083 TRACE("(%p)->(%p): Relay\n", This, Pal);
2086 return DDERR_INVALIDPARAMS;
2088 hr = IWineD3DSurface_GetPalette(This->WineD3DSurface, &wPal);
2089 if(hr != DD_OK) return hr;
2093 hr = IWineD3DPalette_GetParent(wPal, (IUnknown **) Pal);
2098 hr = DDERR_NOPALETTEATTACHED;
2104 /*****************************************************************************
2107 * EnumAttachedSurface callback for SetColorKey. Used to set color keys
2108 * recursively in the surface tree
2110 *****************************************************************************/
2114 WINEDDCOLORKEY *CKey;
2118 static HRESULT WINAPI
2119 SetColorKeyEnum(IDirectDrawSurface7 *surface,
2120 DDSURFACEDESC2 *desc,
2123 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, surface);
2124 struct SCKContext *ctx = context;
2127 hr = IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2132 WARN("IWineD3DSurface_SetColorKey failed, hr = %08x\n", hr);
2136 IDirectDrawSurface7_EnumAttachedSurfaces(surface,
2139 IDirectDrawSurface7_Release(surface);
2140 return DDENUMRET_OK;
2143 /*****************************************************************************
2144 * IDirectDrawSurface7::SetColorKey
2146 * Sets the color keying options for the surface. Observations showed that
2147 * in case of complex surfaces the color key has to be assigned to all
2152 * CKey: The new color key
2156 * See IWineD3DSurface::SetColorKey for details
2158 *****************************************************************************/
2159 static HRESULT WINAPI
2160 IDirectDrawSurfaceImpl_SetColorKey(IDirectDrawSurface7 *iface,
2164 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2165 struct SCKContext ctx = { DD_OK, (WINEDDCOLORKEY *) CKey, Flags };
2166 TRACE("(%p)->(%x,%p)\n", This, Flags, CKey);
2170 switch (Flags & ~DDCKEY_COLORSPACE)
2172 case DDCKEY_DESTBLT:
2173 This->surface_desc.ddckCKDestBlt = *CKey;
2174 This->surface_desc.dwFlags |= DDSD_CKDESTBLT;
2177 case DDCKEY_DESTOVERLAY:
2178 This->surface_desc.u3.ddckCKDestOverlay = *CKey;
2179 This->surface_desc.dwFlags |= DDSD_CKDESTOVERLAY;
2182 case DDCKEY_SRCOVERLAY:
2183 This->surface_desc.ddckCKSrcOverlay = *CKey;
2184 This->surface_desc.dwFlags |= DDSD_CKSRCOVERLAY;
2188 This->surface_desc.ddckCKSrcBlt = *CKey;
2189 This->surface_desc.dwFlags |= DDSD_CKSRCBLT;
2193 return DDERR_INVALIDPARAMS;
2198 switch (Flags & ~DDCKEY_COLORSPACE)
2200 case DDCKEY_DESTBLT:
2201 This->surface_desc.dwFlags &= ~DDSD_CKDESTBLT;
2204 case DDCKEY_DESTOVERLAY:
2205 This->surface_desc.dwFlags &= ~DDSD_CKDESTOVERLAY;
2208 case DDCKEY_SRCOVERLAY:
2209 This->surface_desc.dwFlags &= ~DDSD_CKSRCOVERLAY;
2213 This->surface_desc.dwFlags &= ~DDSD_CKSRCBLT;
2217 return DDERR_INVALIDPARAMS;
2220 ctx.ret = IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2223 IDirectDrawSurface7_EnumAttachedSurfaces(iface,
2228 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
2229 default: return ctx.ret;
2233 /*****************************************************************************
2234 * IDirectDrawSurface7::SetPalette
2236 * Assigns a DirectDrawPalette object to the surface
2239 * Pal: Interface to the palette to set
2244 *****************************************************************************/
2245 static HRESULT WINAPI
2246 IDirectDrawSurfaceImpl_SetPalette(IDirectDrawSurface7 *iface,
2247 IDirectDrawPalette *Pal)
2249 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2250 IDirectDrawPalette *oldPal;
2251 IDirectDrawSurfaceImpl *surf;
2252 IDirectDrawPaletteImpl *PalImpl = ICOM_OBJECT(IDirectDrawPaletteImpl, IDirectDrawPalette, Pal);
2254 TRACE("(%p)->(%p)\n", This, Pal);
2256 /* Find the old palette */
2257 hr = IDirectDrawSurface_GetPalette(iface, &oldPal);
2258 if(hr != DD_OK && hr != DDERR_NOPALETTEATTACHED) return hr;
2259 if(oldPal) IDirectDrawPalette_Release(oldPal); /* For the GetPalette */
2261 /* Set the new Palette */
2262 IWineD3DSurface_SetPalette(This->WineD3DSurface,
2263 PalImpl ? PalImpl->wineD3DPalette : NULL);
2264 /* AddRef the Palette */
2265 if(Pal) IDirectDrawPalette_AddRef(Pal);
2267 /* Release the old palette */
2268 if(oldPal) IDirectDrawPalette_Release(oldPal);
2270 /* If this is a front buffer, also update the back buffers
2271 * TODO: How do things work for palettized cube textures?
2273 if(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
2275 /* For primary surfaces the tree is just a list, so the simpler scheme fits too */
2276 DDSCAPS2 caps2 = { DDSCAPS_PRIMARYSURFACE, 0, 0, 0 };
2281 IDirectDrawSurface7 *attach;
2283 hr = IDirectDrawSurface7_GetAttachedSurface(ICOM_INTERFACE(surf, IDirectDrawSurface7),
2290 TRACE("Setting palette on %p\n", attach);
2291 IDirectDrawSurface7_SetPalette(attach,
2293 surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, attach);
2294 IDirectDrawSurface7_Release(attach);
2301 /*****************************************************************************
2303 *****************************************************************************/
2305 const IDirectDrawSurface7Vtbl IDirectDrawSurface7_Vtbl =
2308 IDirectDrawSurfaceImpl_QueryInterface,
2309 IDirectDrawSurfaceImpl_AddRef,
2310 IDirectDrawSurfaceImpl_Release,
2311 /*** IDirectDrawSurface ***/
2312 IDirectDrawSurfaceImpl_AddAttachedSurface,
2313 IDirectDrawSurfaceImpl_AddOverlayDirtyRect,
2314 IDirectDrawSurfaceImpl_Blt,
2315 IDirectDrawSurfaceImpl_BltBatch,
2316 IDirectDrawSurfaceImpl_BltFast,
2317 IDirectDrawSurfaceImpl_DeleteAttachedSurface,
2318 IDirectDrawSurfaceImpl_EnumAttachedSurfaces,
2319 IDirectDrawSurfaceImpl_EnumOverlayZOrders,
2320 IDirectDrawSurfaceImpl_Flip,
2321 IDirectDrawSurfaceImpl_GetAttachedSurface,
2322 IDirectDrawSurfaceImpl_GetBltStatus,
2323 IDirectDrawSurfaceImpl_GetCaps,
2324 IDirectDrawSurfaceImpl_GetClipper,
2325 IDirectDrawSurfaceImpl_GetColorKey,
2326 IDirectDrawSurfaceImpl_GetDC,
2327 IDirectDrawSurfaceImpl_GetFlipStatus,
2328 IDirectDrawSurfaceImpl_GetOverlayPosition,
2329 IDirectDrawSurfaceImpl_GetPalette,
2330 IDirectDrawSurfaceImpl_GetPixelFormat,
2331 IDirectDrawSurfaceImpl_GetSurfaceDesc,
2332 IDirectDrawSurfaceImpl_Initialize,
2333 IDirectDrawSurfaceImpl_IsLost,
2334 IDirectDrawSurfaceImpl_Lock,
2335 IDirectDrawSurfaceImpl_ReleaseDC,
2336 IDirectDrawSurfaceImpl_Restore,
2337 IDirectDrawSurfaceImpl_SetClipper,
2338 IDirectDrawSurfaceImpl_SetColorKey,
2339 IDirectDrawSurfaceImpl_SetOverlayPosition,
2340 IDirectDrawSurfaceImpl_SetPalette,
2341 IDirectDrawSurfaceImpl_Unlock,
2342 IDirectDrawSurfaceImpl_UpdateOverlay,
2343 IDirectDrawSurfaceImpl_UpdateOverlayDisplay,
2344 IDirectDrawSurfaceImpl_UpdateOverlayZOrder,
2345 /*** IDirectDrawSurface2 ***/
2346 IDirectDrawSurfaceImpl_GetDDInterface,
2347 IDirectDrawSurfaceImpl_PageLock,
2348 IDirectDrawSurfaceImpl_PageUnlock,
2349 /*** IDirectDrawSurface3 ***/
2350 IDirectDrawSurfaceImpl_SetSurfaceDesc,
2351 /*** IDirectDrawSurface4 ***/
2352 IDirectDrawSurfaceImpl_SetPrivateData,
2353 IDirectDrawSurfaceImpl_GetPrivateData,
2354 IDirectDrawSurfaceImpl_FreePrivateData,
2355 IDirectDrawSurfaceImpl_GetUniquenessValue,
2356 IDirectDrawSurfaceImpl_ChangeUniquenessValue,
2357 /*** IDirectDrawSurface7 ***/
2358 IDirectDrawSurfaceImpl_SetPriority,
2359 IDirectDrawSurfaceImpl_GetPriority,
2360 IDirectDrawSurfaceImpl_SetLOD,
2361 IDirectDrawSurfaceImpl_GetLOD