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 IWineD3DTexture_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 we attach a back buffer to the primary */
829 if(Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER &&
830 This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
832 IWineD3DDevice_SetDepthStencilSurface(This->ddraw->wineD3DDevice,
833 Surf->WineD3DSurface);
837 * "This method increments the reference count of the surface being attached."
839 IDirectDrawSurface7_AddRef(Attach);
843 /*****************************************************************************
844 * IDirectDrawSurface7::DeleteAttachedSurface
846 * Removes a surface from the attachment chain. The surface's refcount
847 * is decreased by one after it has been removed
850 * Flags: Some flags, not used by this implementation
851 * Attach: Surface to detach
855 * DDERR_SURFACENOTATTACHED if the surface isn't attached to
857 *****************************************************************************/
858 static HRESULT WINAPI
859 IDirectDrawSurfaceImpl_DeleteAttachedSurface(IDirectDrawSurface7 *iface,
861 IDirectDrawSurface7 *Attach)
863 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
864 IDirectDrawSurfaceImpl *Surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Attach);
865 IDirectDrawSurfaceImpl *Prev = This;
866 TRACE("(%p)->(%08x,%p)\n", This, Flags, Surf);
868 if (!Surf || (Surf->first_attached != This) || (Surf == This) )
869 return DDERR_SURFACENOTATTACHED; /* unchecked */
871 /* Remove MIPMAPSUBLEVEL if this seemed to be one */
872 if (This->surface_desc.ddsCaps.dwCaps &
873 Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
875 Surf->surface_desc.ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
876 /* FIXME: we should probably also subtract from dwMipMapCount of this
877 * and all parent surfaces */
880 /* Find the predecessor of the detached surface */
883 if(Prev->next_attached == Surf) break;
884 Prev = Prev->next_attached;
887 /* There must be a surface, otherwise there's a bug */
888 assert(Prev != NULL);
890 /* Unchain the surface */
891 Prev->next_attached = Surf->next_attached;
892 Surf->next_attached = NULL;
893 Surf->first_attached = Surf;
895 /* Check if we attach a back buffer to the primary */
896 if(Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER &&
897 This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
899 IWineD3DDevice_SetDepthStencilSurface(This->ddraw->wineD3DDevice,
903 IDirectDrawSurface7_Release(Attach);
907 /*****************************************************************************
908 * IDirectDrawSurface7::AddOverlayDirtyRect
910 * "This method is not currently implemented"
918 *****************************************************************************/
919 static HRESULT WINAPI
920 IDirectDrawSurfaceImpl_AddOverlayDirtyRect(IDirectDrawSurface7 *iface,
923 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
924 TRACE("(%p)->(%p)\n",This,Rect);
926 /* MSDN says it's not implemented. I could forward it to WineD3D,
927 * then we'd implement it, but I don't think that's a good idea
931 return IWineD3DSurface_AddOverlayDirtyRect(This->WineD3DSurface, pRect);
933 return DDERR_UNSUPPORTED; /* unchecked */
936 /*****************************************************************************
937 * IDirectDrawSurface7::GetDC
939 * Returns a GDI device context for the surface
942 * hdc: Address of a HDC variable to store the dc to
946 * DDERR_INVALIDPARAMS if hdc is NULL
947 * For details, see IWineD3DSurface::GetDC
949 *****************************************************************************/
950 static HRESULT WINAPI
951 IDirectDrawSurfaceImpl_GetDC(IDirectDrawSurface7 *iface,
954 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
955 TRACE("(%p)->(%p): Relay\n", This, hdc);
958 return DDERR_INVALIDPARAMS;
960 return IWineD3DSurface_GetDC(This->WineD3DSurface,
964 /*****************************************************************************
965 * IDirectDrawSurface7::ReleaseDC
967 * Releases the DC that was constructed with GetDC
970 * hdc: HDC to release
974 * For more details, see IWineD3DSurface::ReleaseDC
976 *****************************************************************************/
977 static HRESULT WINAPI
978 IDirectDrawSurfaceImpl_ReleaseDC(IDirectDrawSurface7 *iface,
981 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
982 TRACE("(%p)->(%p): Relay\n", This, hdc);
984 return IWineD3DSurface_ReleaseDC(This->WineD3DSurface, hdc);
987 /*****************************************************************************
988 * IDirectDrawSurface7::GetCaps
990 * Returns the surface's caps
993 * Caps: Address to write the caps to
997 * DDERR_INVALIDPARAMS if Caps is NULL
999 *****************************************************************************/
1000 static HRESULT WINAPI
1001 IDirectDrawSurfaceImpl_GetCaps(IDirectDrawSurface7 *iface,
1004 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1005 TRACE("(%p)->(%p)\n",This,Caps);
1008 return DDERR_INVALIDPARAMS;
1010 *Caps = This->surface_desc.ddsCaps;
1014 /*****************************************************************************
1015 * IDirectDrawSurface7::SetPriority
1017 * Sets a texture priority for managed textures.
1020 * Priority: The new priority
1024 * For more details, see IWineD3DSurface::SetPriority
1026 *****************************************************************************/
1027 static HRESULT WINAPI
1028 IDirectDrawSurfaceImpl_SetPriority(IDirectDrawSurface7 *iface, DWORD Priority)
1030 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1031 TRACE("(%p)->(%d): Relay!\n",This,Priority);
1033 return IWineD3DSurface_SetPriority(This->WineD3DSurface, Priority);
1036 /*****************************************************************************
1037 * IDirectDrawSurface7::GetPriority
1039 * Returns the surface's priority
1042 * Priority: Address of a variable to write the priority to
1046 * DDERR_INVALIDPARAMS if Priority == NULL
1047 * For more details, see IWineD3DSurface::GetPriority
1049 *****************************************************************************/
1050 static HRESULT WINAPI
1051 IDirectDrawSurfaceImpl_GetPriority(IDirectDrawSurface7 *iface,
1054 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1055 TRACE("(%p)->(%p): Relay\n",This,Priority);
1058 return DDERR_INVALIDPARAMS;
1060 *Priority = IWineD3DSurface_GetPriority(This->WineD3DSurface);
1064 /*****************************************************************************
1065 * IDirectDrawSurface7::SetPrivateData
1067 * Stores some data in the surface that is intended for the application's
1071 * tag: GUID that identifies the data
1072 * Data: Pointer to the private data
1073 * Size: Size of the private data
1078 * For more details, see IWineD3DSurface::SetPrivateData
1080 *****************************************************************************/
1081 static HRESULT WINAPI
1082 IDirectDrawSurfaceImpl_SetPrivateData(IDirectDrawSurface7 *iface,
1088 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1089 TRACE("(%p)->(%s,%p,%d,%x): Relay\n", This, debugstr_guid(tag), Data, Size, Flags);
1091 return IWineD3DSurface_SetPrivateData(This->WineD3DSurface,
1098 /*****************************************************************************
1099 * IDirectDrawSurface7::GetPrivateData
1101 * Returns the private data set with IDirectDrawSurface7::SetPrivateData
1104 * tag: GUID of the data to return
1105 * Data: Address where to write the data to
1106 * Size: Size of the buffer at Data
1110 * DDERR_INVALIDPARAMS if Data is NULL
1111 * For more details, see IWineD3DSurface::GetPrivateData
1113 *****************************************************************************/
1114 static HRESULT WINAPI
1115 IDirectDrawSurfaceImpl_GetPrivateData(IDirectDrawSurface7 *iface,
1120 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1121 TRACE("(%p)->(%s,%p,%p): Relay\n", This, debugstr_guid(tag), Data, Size);
1124 return DDERR_INVALIDPARAMS;
1126 return IWineD3DSurface_GetPrivateData(This->WineD3DSurface,
1132 /*****************************************************************************
1133 * IDirectDrawSurface7::FreePrivateData
1135 * Frees private data stored in the surface
1138 * tag: Tag of the data to free
1142 * For more details, see IWineD3DSurface::FreePrivateData
1144 *****************************************************************************/
1145 static HRESULT WINAPI
1146 IDirectDrawSurfaceImpl_FreePrivateData(IDirectDrawSurface7 *iface,
1149 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1150 TRACE("(%p)->(%s): Relay\n", This, debugstr_guid(tag));
1152 return IWineD3DSurface_FreePrivateData(This->WineD3DSurface, tag);
1155 /*****************************************************************************
1156 * IDirectDrawSurface7::PageLock
1158 * Prevents a sysmem surface from being paged out
1161 * Flags: Not used, must be 0(unchecked)
1164 * DD_OK, because it's a stub
1166 *****************************************************************************/
1167 static HRESULT WINAPI
1168 IDirectDrawSurfaceImpl_PageLock(IDirectDrawSurface7 *iface,
1171 TRACE("(%p)->(%x)\n", iface, Flags);
1173 /* This is Windows memory management related - we don't need this */
1177 /*****************************************************************************
1178 * IDirectDrawSurface7::PageUnlock
1180 * Allows a sysmem surface to be paged out
1183 * Flags: Not used, must be 0(unckeched)
1186 * DD_OK, because it's a stub
1188 *****************************************************************************/
1189 static HRESULT WINAPI
1190 IDirectDrawSurfaceImpl_PageUnlock(IDirectDrawSurface7 *iface,
1193 TRACE("(%p)->(%x)\n", iface, Flags);
1198 /*****************************************************************************
1199 * IDirectDrawSurface7::BltBatch
1201 * An unimplemented function
1209 *****************************************************************************/
1210 static HRESULT WINAPI IDirectDrawSurfaceImpl_BltBatch(IDirectDrawSurface7 *iface, DDBLTBATCH *Batch, DWORD Count, DWORD Flags)
1212 TRACE("(%p)->(%p,%d,%08x)\n",iface,Batch,Count,Flags);
1214 /* MSDN: "not currently implemented" */
1215 return DDERR_UNSUPPORTED;
1218 /*****************************************************************************
1219 * IDirectDrawSurface7::EnumAttachedSurfaces
1221 * Enumerates all surfaces attached to this surface
1224 * context: Pointer to pass unmodified to the callback
1225 * cb: Callback function to call for each surface
1229 * DDERR_INVALIDPARAMS if cb is NULL
1231 *****************************************************************************/
1232 static HRESULT WINAPI
1233 IDirectDrawSurfaceImpl_EnumAttachedSurfaces(IDirectDrawSurface7 *iface,
1235 LPDDENUMSURFACESCALLBACK7 cb)
1237 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1238 IDirectDrawSurfaceImpl *surf;
1239 DDSURFACEDESC2 desc;
1242 /* Attached surfaces aren't handled in WineD3D */
1243 TRACE("(%p)->(%p,%p)\n",This,context,cb);
1246 return DDERR_INVALIDPARAMS;
1248 for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
1250 surf = This->complex_array[i];
1253 IDirectDrawSurface7_AddRef(ICOM_INTERFACE(surf, IDirectDrawSurface7));
1254 desc = surf->surface_desc;
1255 /* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
1256 if (cb(ICOM_INTERFACE(surf, IDirectDrawSurface7), &desc, context) == DDENUMRET_CANCEL)
1260 for (surf = This->next_attached; surf != NULL; surf = surf->next_attached)
1262 IDirectDrawSurface7_AddRef(ICOM_INTERFACE(surf, IDirectDrawSurface7));
1263 desc = surf->surface_desc;
1264 /* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
1265 if (cb( ICOM_INTERFACE(surf, IDirectDrawSurface7), &desc, context) == DDENUMRET_CANCEL)
1269 TRACE(" end of enumeration.\n");
1274 /*****************************************************************************
1275 * IDirectDrawSurface7::EnumOverlayZOrders
1277 * "Enumerates the overlay surfaces on the specified destination"
1280 * Flags: DDENUMOVERLAYZ_BACKTOFRONT or DDENUMOVERLAYZ_FRONTTOBACK
1281 * context: context to pass back to the callback
1282 * cb: callback function to call for each enumerated surface
1285 * DD_OK, because it's a stub
1287 *****************************************************************************/
1288 static HRESULT WINAPI
1289 IDirectDrawSurfaceImpl_EnumOverlayZOrders(IDirectDrawSurface7 *iface,
1292 LPDDENUMSURFACESCALLBACK7 cb)
1294 FIXME("(%p)->(%x,%p,%p): Stub!\n", iface, Flags, context, cb);
1299 /*****************************************************************************
1300 * IDirectDrawSurface7::GetBltStatus
1302 * Returns the blitting status
1305 * Flags: DDGBS_CANBLT or DDGBS_ISBLTDONE
1308 * See IWineD3DSurface::Blt
1310 *****************************************************************************/
1311 static HRESULT WINAPI
1312 IDirectDrawSurfaceImpl_GetBltStatus(IDirectDrawSurface7 *iface,
1315 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1317 TRACE("(%p)->(%x): Relay\n", This, Flags);
1319 hr = IWineD3DSurface_GetBltStatus(This->WineD3DSurface, Flags);
1322 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1327 /*****************************************************************************
1328 * IDirectDrawSurface7::GetColorKey
1330 * Returns the color key assigned to the surface
1334 * CKey: Address to store the key to
1338 * DDERR_INVALIDPARAMS if CKey is NULL
1340 *****************************************************************************/
1341 static HRESULT WINAPI
1342 IDirectDrawSurfaceImpl_GetColorKey(IDirectDrawSurface7 *iface,
1346 /* There is a DDERR_NOCOLORKEY error, but how do we know if a color key
1347 * isn't there? That's like saying that an int isn't there. (Which MS
1348 * has done in other docs.) */
1349 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1350 TRACE("(%p)->(%08x,%p)\n", This, Flags, CKey);
1353 return DDERR_INVALIDPARAMS;
1357 case DDCKEY_DESTBLT:
1358 *CKey = This->surface_desc.ddckCKDestBlt;
1361 case DDCKEY_DESTOVERLAY:
1362 *CKey = This->surface_desc.u3.ddckCKDestOverlay;
1366 *CKey = This->surface_desc.ddckCKSrcBlt;
1369 case DDCKEY_SRCOVERLAY:
1370 *CKey = This->surface_desc.ddckCKSrcOverlay;
1374 return DDERR_INVALIDPARAMS;
1380 /*****************************************************************************
1381 * IDirectDrawSurface7::GetFlipStatus
1383 * Returns the flipping status of the surface
1386 * Flags: DDGFS_CANFLIP of DDGFS_ISFLIPDONE
1389 * See IWineD3DSurface::GetFlipStatus
1391 *****************************************************************************/
1392 static HRESULT WINAPI
1393 IDirectDrawSurfaceImpl_GetFlipStatus(IDirectDrawSurface7 *iface,
1396 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1398 TRACE("(%p)->(%x): Relay\n", This, Flags);
1400 hr = IWineD3DSurface_GetFlipStatus(This->WineD3DSurface, Flags);
1403 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1408 /*****************************************************************************
1409 * IDirectDrawSurface7::GetOverlayPosition
1411 * Returns the display coordinates of a visible and active overlay surface
1418 * DDERR_NOTAOVERLAYSURFACE, because it's a stub
1419 *****************************************************************************/
1420 static HRESULT WINAPI
1421 IDirectDrawSurfaceImpl_GetOverlayPosition(IDirectDrawSurface7 *iface,
1424 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1425 TRACE("(%p)->(%p,%p): Relay\n", This, X, Y);
1427 return IWineD3DSurface_GetOverlayPosition(This->WineD3DSurface,
1432 /*****************************************************************************
1433 * IDirectDrawSurface7::GetPixelFormat
1435 * Returns the pixel format of the Surface
1438 * PixelFormat: Pointer to a DDPIXELFORMAT structure to which the pixel
1439 * format should be written
1443 * DDERR_INVALIDPARAMS if PixelFormat is NULL
1445 *****************************************************************************/
1446 static HRESULT WINAPI
1447 IDirectDrawSurfaceImpl_GetPixelFormat(IDirectDrawSurface7 *iface,
1448 DDPIXELFORMAT *PixelFormat)
1450 /* What is DDERR_INVALIDSURFACETYPE for here? */
1451 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1452 TRACE("(%p)->(%p)\n",This,PixelFormat);
1455 return DDERR_INVALIDPARAMS;
1457 DD_STRUCT_COPY_BYSIZE(PixelFormat,&This->surface_desc.u4.ddpfPixelFormat);
1463 /*****************************************************************************
1464 * IDirectDrawSurface7::GetSurfaceDesc
1466 * Returns the description of this surface
1469 * DDSD: Address of a DDSURFACEDESC2 structure that is to be filled with the
1474 * DDERR_INVALIDPARAMS if DDSD is NULL
1476 *****************************************************************************/
1477 static HRESULT WINAPI
1478 IDirectDrawSurfaceImpl_GetSurfaceDesc(IDirectDrawSurface7 *iface,
1479 DDSURFACEDESC2 *DDSD)
1481 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1483 TRACE("(%p)->(%p)\n",This,DDSD);
1486 return DDERR_INVALIDPARAMS;
1488 if ((DDSD->dwSize < sizeof(DDSURFACEDESC)) ||
1489 (DDSD->dwSize > sizeof(DDSURFACEDESC2)))
1491 ERR("Impossible/Strange struct size %d.\n",DDSD->dwSize);
1492 return DDERR_GENERIC;
1495 DD_STRUCT_COPY_BYSIZE(DDSD,&This->surface_desc);
1496 TRACE("Returning surface desc:\n");
1497 if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD);
1502 /*****************************************************************************
1503 * IDirectDrawSurface7::Initialize
1505 * Initializes the surface. This is a no-op in Wine
1508 * DD: Pointer to an DirectDraw interface
1509 * DDSD: Surface description for initialization
1512 * DDERR_ALREADYINITIALIZED
1514 *****************************************************************************/
1515 static HRESULT WINAPI
1516 IDirectDrawSurfaceImpl_Initialize(IDirectDrawSurface7 *iface,
1518 DDSURFACEDESC2 *DDSD)
1520 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1521 IDirectDrawImpl *ddimpl = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, DD);
1522 TRACE("(%p)->(%p,%p)\n",This,ddimpl,DDSD);
1524 return DDERR_ALREADYINITIALIZED;
1527 /*****************************************************************************
1528 * IDirectDrawSurface7::IsLost
1530 * Checks if the surface is lost
1533 * DD_OK, if the surface is useable
1534 * DDERR_ISLOST if the surface is lost
1535 * See IWineD3DSurface::IsLost for more details
1537 *****************************************************************************/
1538 static HRESULT WINAPI
1539 IDirectDrawSurfaceImpl_IsLost(IDirectDrawSurface7 *iface)
1541 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1543 TRACE("(%p)\n", This);
1545 /* We lose the surface if the implementation was changed */
1546 if(This->ImplType != This->ddraw->ImplType)
1548 /* But this shouldn't happen. When we change the implementation,
1549 * all surfaces are re-created automatically, and their content
1552 ERR(" (%p) Implementation was changed from %d to %d\n", This, This->ImplType, This->ddraw->ImplType);
1553 return DDERR_SURFACELOST;
1556 hr = IWineD3DSurface_IsLost(This->WineD3DSurface);
1559 /* D3D8 and 9 loose full devices, thus there's only a DEVICELOST error.
1560 * WineD3D uses the same error for surfaces
1562 case WINED3DERR_DEVICELOST: return DDERR_SURFACELOST;
1567 /*****************************************************************************
1568 * IDirectDrawSurface7::Restore
1570 * Restores a lost surface. This makes the surface usable again, but
1571 * doesn't reload its old contents
1575 * See IWineD3DSurface::Restore for more details
1577 *****************************************************************************/
1578 static HRESULT WINAPI
1579 IDirectDrawSurfaceImpl_Restore(IDirectDrawSurface7 *iface)
1581 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1582 TRACE("(%p)\n", This);
1584 if(This->ImplType != This->ddraw->ImplType)
1586 /* Call the recreation callback. Make sure to AddRef first */
1587 IDirectDrawSurface_AddRef(iface);
1588 IDirectDrawImpl_RecreateSurfacesCallback(iface,
1589 &This->surface_desc,
1590 NULL /* Not needed */);
1592 return IWineD3DSurface_Restore(This->WineD3DSurface);
1595 /*****************************************************************************
1596 * IDirectDrawSurface7::SetOverlayPosition
1598 * Changes the display coordinates of an overlay surface
1605 * DDERR_NOTAOVERLAYSURFACE, because we don't support overlays right now
1606 *****************************************************************************/
1607 static HRESULT WINAPI
1608 IDirectDrawSurfaceImpl_SetOverlayPosition(IDirectDrawSurface7 *iface,
1612 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1613 TRACE("(%p)->(%d,%d): Relay\n", This, X, Y);
1615 return IWineD3DSurface_SetOverlayPosition(This->WineD3DSurface,
1620 /*****************************************************************************
1621 * IDirectDrawSurface7::UpdateOverlay
1623 * Modifies the attributes of an overlay surface.
1626 * SrcRect: The section of the source being used for the overlay
1627 * DstSurface: Address of the surface that is overlaid
1628 * DstRect: Place of the overlay
1629 * Flags: some DDOVER_* flags
1632 * DDERR_UNSUPPORTED, because we don't support overlays
1634 *****************************************************************************/
1635 static HRESULT WINAPI
1636 IDirectDrawSurfaceImpl_UpdateOverlay(IDirectDrawSurface7 *iface,
1638 IDirectDrawSurface7 *DstSurface,
1643 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1644 IDirectDrawSurfaceImpl *Dst = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DstSurface);
1645 TRACE("(%p)->(%p,%p,%p,%x,%p): Relay\n", This, SrcRect, Dst, DstRect, Flags, FX);
1647 return IWineD3DSurface_UpdateOverlay(This->WineD3DSurface,
1649 Dst ? Dst->WineD3DSurface : NULL,
1652 (WINEDDOVERLAYFX *) FX);
1655 /*****************************************************************************
1656 * IDirectDrawSurface7::UpdateOverlayDisplay
1658 * The DX7 sdk says that it's not implemented
1663 * Returns: DDERR_UNSUPPORTED, because we don't support overlays
1665 *****************************************************************************/
1666 static HRESULT WINAPI
1667 IDirectDrawSurfaceImpl_UpdateOverlayDisplay(IDirectDrawSurface7 *iface,
1670 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1671 TRACE("(%p)->(%x)\n", This, Flags);
1672 return DDERR_UNSUPPORTED;
1675 /*****************************************************************************
1676 * IDirectDrawSurface7::UpdateOverlayZOrder
1678 * Sets an overlay's Z order
1681 * Flags: DDOVERZ_* flags
1682 * DDSRef: Defines the relative position in the overlay chain
1685 * DDERR_NOTOVERLAYSURFACE, because we don't support overlays
1687 *****************************************************************************/
1688 static HRESULT WINAPI
1689 IDirectDrawSurfaceImpl_UpdateOverlayZOrder(IDirectDrawSurface7 *iface,
1691 IDirectDrawSurface7 *DDSRef)
1693 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1694 IDirectDrawSurfaceImpl *Ref = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DDSRef);
1696 TRACE("(%p)->(%x,%p): Relay\n", This, Flags, Ref);
1697 return IWineD3DSurface_UpdateOverlayZOrder(This->WineD3DSurface,
1699 Ref ? Ref->WineD3DSurface : NULL);
1702 /*****************************************************************************
1703 * IDirectDrawSurface7::GetDDInterface
1705 * Returns the IDirectDraw7 interface pointer of the DirectDraw object this
1706 * surface belongs to
1709 * DD: Address to write the interface pointer to
1713 * DDERR_INVALIDPARAMS if DD is NULL
1715 *****************************************************************************/
1716 static HRESULT WINAPI
1717 IDirectDrawSurfaceImpl_GetDDInterface(IDirectDrawSurface7 *iface,
1720 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1722 TRACE("(%p)->(%p)\n",This,DD);
1725 return DDERR_INVALIDPARAMS;
1727 switch(This->version)
1730 *((IDirectDraw7 **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw7);
1731 IDirectDraw7_AddRef(*(IDirectDraw7 **) DD);
1735 *((IDirectDraw4 **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw4);
1736 IDirectDraw4_AddRef(*(IDirectDraw4 **) DD);
1740 *((IDirectDraw2 **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw2);
1741 IDirectDraw_AddRef( *(IDirectDraw2 **) DD);
1745 *((IDirectDraw **) DD) = ICOM_INTERFACE(This->ddraw, IDirectDraw);
1746 IDirectDraw_AddRef( *(IDirectDraw **) DD);
1754 /* This seems also windows implementation specific - I don't think WineD3D needs this */
1755 static HRESULT WINAPI IDirectDrawSurfaceImpl_ChangeUniquenessValue(IDirectDrawSurface7 *iface)
1757 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1758 volatile IDirectDrawSurfaceImpl* vThis = This;
1760 TRACE("(%p)\n",This);
1761 /* A uniqueness value of 0 is apparently special.
1762 * This needs to be checked. */
1764 DWORD old_uniqueness_value = vThis->uniqueness_value;
1765 DWORD new_uniqueness_value = old_uniqueness_value+1;
1767 if (old_uniqueness_value == 0) break;
1768 if (new_uniqueness_value == 0) new_uniqueness_value = 1;
1770 if (InterlockedCompareExchange((LONG*)&vThis->uniqueness_value,
1771 old_uniqueness_value,
1772 new_uniqueness_value)
1773 == old_uniqueness_value)
1780 static HRESULT WINAPI IDirectDrawSurfaceImpl_GetUniquenessValue(IDirectDrawSurface7 *iface, LPDWORD pValue)
1782 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1784 TRACE("(%p)->(%p)\n",This,pValue);
1785 *pValue = This->uniqueness_value;
1789 /*****************************************************************************
1790 * IDirectDrawSurface7::SetLOD
1792 * Sets the level of detail of a texture
1795 * MaxLOD: LOD to set
1799 * DDERR_INVALIDOBJECT if the surface is invalid for this method
1801 *****************************************************************************/
1802 static HRESULT WINAPI
1803 IDirectDrawSurfaceImpl_SetLOD(IDirectDrawSurface7 *iface,
1806 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1807 TRACE("(%p)->(%d)\n", This, MaxLOD);
1809 if (!(This->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE))
1810 return DDERR_INVALIDOBJECT;
1812 if(!This->wineD3DTexture)
1814 ERR("(%p) The DirectDraw texture has no WineD3DTexture!\n", This);
1815 return DDERR_INVALIDOBJECT;
1818 return IWineD3DTexture_SetLOD(This->wineD3DTexture,
1822 /*****************************************************************************
1823 * IDirectDrawSurface7::GetLOD
1825 * Returns the level of detail of a Direct3D texture
1828 * MaxLOD: Address to write the LOD to
1832 * DDERR_INVALIDPARAMS if MaxLOD is NULL
1833 * DDERR_INVALIDOBJECT if the surface is invalid for this method
1835 *****************************************************************************/
1836 static HRESULT WINAPI
1837 IDirectDrawSurfaceImpl_GetLOD(IDirectDrawSurface7 *iface,
1840 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1841 TRACE("(%p)->(%p)\n", This, MaxLOD);
1844 return DDERR_INVALIDPARAMS;
1846 if (!(This->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE))
1847 return DDERR_INVALIDOBJECT;
1849 *MaxLOD = IWineD3DTexture_GetLOD(This->wineD3DTexture);
1853 /*****************************************************************************
1854 * IDirectDrawSurface7::BltFast
1856 * Performs a fast Blit.
1859 * dstx: The x coordinate to blit to on the destination
1860 * dsty: The y coordinate to blit to on the destination
1861 * Source: The source surface
1862 * rsrc: The source rectangle
1863 * trans: Type of transfer. Some DDBLTFAST_* flags
1867 * For more details, see IWineD3DSurface::BltFast
1869 *****************************************************************************/
1870 static HRESULT WINAPI
1871 IDirectDrawSurfaceImpl_BltFast(IDirectDrawSurface7 *iface,
1874 IDirectDrawSurface7 *Source,
1878 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1880 IDirectDrawSurfaceImpl *src = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Source);
1881 TRACE("(%p)->(%d,%d,%p,%p,%d): Relay\n", This, dstx, dsty, Source, rsrc, trans);
1883 hr = IWineD3DSurface_BltFast(This->WineD3DSurface,
1885 src ? src->WineD3DSurface : NULL,
1890 case WINED3DERR_NOTAVAILABLE: return DDERR_UNSUPPORTED;
1891 case WINED3DERR_WRONGTEXTUREFORMAT: return DDERR_INVALIDPIXELFORMAT;
1896 /*****************************************************************************
1897 * IDirectDrawSurface7::GetClipper
1899 * Returns the IDirectDrawClipper interface of the clipper assigned to this
1903 * Clipper: Address to store the interface pointer at
1907 * DDERR_INVALIDPARAMS if Clipper is NULL
1908 * DDERR_NOCLIPPERATTACHED if there's no clipper attached
1910 *****************************************************************************/
1911 static HRESULT WINAPI
1912 IDirectDrawSurfaceImpl_GetClipper(IDirectDrawSurface7 *iface,
1913 IDirectDrawClipper **Clipper)
1915 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1916 TRACE("(%p)->(%p)\n", This, Clipper);
1919 return DDERR_INVALIDPARAMS;
1921 if(This->clipper == NULL)
1922 return DDERR_NOCLIPPERATTACHED;
1924 *Clipper = ICOM_INTERFACE(This->clipper, IDirectDrawClipper);
1925 IDirectDrawClipper_AddRef(*Clipper);
1929 /*****************************************************************************
1930 * IDirectDrawSurface7::SetClipper
1932 * Sets a clipper for the surface
1935 * Clipper: IDirectDrawClipper interface of the clipper to set
1940 *****************************************************************************/
1941 static HRESULT WINAPI
1942 IDirectDrawSurfaceImpl_SetClipper(IDirectDrawSurface7 *iface,
1943 IDirectDrawClipper *Clipper)
1945 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1946 IDirectDrawClipperImpl *oldClipper = This->clipper;
1948 TRACE("(%p)->(%p)\n",This,Clipper);
1949 if (ICOM_OBJECT(IDirectDrawClipperImpl, IDirectDrawClipper, Clipper) == This->clipper)
1952 This->clipper = ICOM_OBJECT(IDirectDrawClipperImpl, IDirectDrawClipper, Clipper);
1954 if (Clipper != NULL)
1955 IDirectDrawClipper_AddRef(Clipper);
1957 IDirectDrawClipper_Release(ICOM_INTERFACE(oldClipper, IDirectDrawClipper));
1962 /*****************************************************************************
1963 * IDirectDrawSurface7::SetSurfaceDesc
1965 * Sets the surface description. It can override the pixel format, the surface
1967 * It's not really tested.
1970 * DDSD: Pointer to the new surface description to set
1975 * DDERR_INVALIDPARAMS if DDSD is NULL
1977 *****************************************************************************/
1978 static HRESULT WINAPI
1979 IDirectDrawSurfaceImpl_SetSurfaceDesc(IDirectDrawSurface7 *iface,
1980 DDSURFACEDESC2 *DDSD,
1983 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
1984 WINED3DFORMAT newFormat = WINED3DFMT_UNKNOWN;
1986 TRACE("(%p)->(%p,%x)\n", This, DDSD, Flags);
1989 return DDERR_INVALIDPARAMS;
1991 if (DDSD->dwFlags & DDSD_LPSURFACE && DDSD->lpSurface)
1993 ERR("Setting the surface memory isn't supported yet\n");
1994 return DDERR_INVALIDPARAMS;
1997 if (DDSD->dwFlags & DDSD_PIXELFORMAT)
1999 newFormat = PixelFormat_DD2WineD3D(&DDSD->u4.ddpfPixelFormat);
2001 if(newFormat == WINED3DFMT_UNKNOWN)
2003 ERR("Requested to set an unknown pixelformat\n");
2004 return DDERR_INVALIDPARAMS;
2006 if(newFormat != PixelFormat_DD2WineD3D(&This->surface_desc.u4.ddpfPixelFormat) )
2008 hr = IWineD3DSurface_SetFormat(This->WineD3DSurface,
2010 if(hr != DD_OK) return hr;
2013 if (DDSD->dwFlags & DDSD_CKDESTOVERLAY)
2015 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2017 (WINEDDCOLORKEY *) &DDSD->u3.ddckCKDestOverlay);
2019 if (DDSD->dwFlags & DDSD_CKDESTBLT)
2021 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2023 (WINEDDCOLORKEY *) &DDSD->ddckCKDestBlt);
2025 if (DDSD->dwFlags & DDSD_CKSRCOVERLAY)
2027 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2029 (WINEDDCOLORKEY *) &DDSD->ddckCKSrcOverlay);
2031 if (DDSD->dwFlags & DDSD_CKSRCBLT)
2033 IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2035 (WINEDDCOLORKEY *) &DDSD->ddckCKSrcBlt);
2037 if (DDSD->dwFlags & DDSD_LPSURFACE)
2039 hr = IWineD3DSurface_SetMem(This->WineD3DSurface, DDSD->lpSurface);
2040 if(hr != WINED3D_OK)
2042 /* No need for a trace here, wined3d does that for us */
2047 This->surface_desc = *DDSD;
2052 /*****************************************************************************
2053 * IDirectDrawSurface7::GetPalette
2055 * Returns the IDirectDrawPalette interface of the palette currently assigned
2059 * Pal: Address to write the interface pointer to
2063 * DDERR_INVALIDPARAMS if Pal is NULL
2065 *****************************************************************************/
2066 static HRESULT WINAPI
2067 IDirectDrawSurfaceImpl_GetPalette(IDirectDrawSurface7 *iface,
2068 IDirectDrawPalette **Pal)
2070 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2071 IWineD3DPalette *wPal;
2073 TRACE("(%p)->(%p): Relay\n", This, Pal);
2076 return DDERR_INVALIDPARAMS;
2078 hr = IWineD3DSurface_GetPalette(This->WineD3DSurface, &wPal);
2079 if(hr != DD_OK) return hr;
2083 hr = IWineD3DPalette_GetParent(wPal, (IUnknown **) Pal);
2088 hr = DDERR_NOPALETTEATTACHED;
2094 /*****************************************************************************
2097 * EnumAttachedSurface callback for SetColorKey. Used to set color keys
2098 * recursively in the surface tree
2100 *****************************************************************************/
2104 WINEDDCOLORKEY *CKey;
2108 static HRESULT WINAPI
2109 SetColorKeyEnum(IDirectDrawSurface7 *surface,
2110 DDSURFACEDESC2 *desc,
2113 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, surface);
2114 struct SCKContext *ctx = context;
2117 hr = IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2122 WARN("IWineD3DSurface_SetColorKey failed, hr = %08x\n", hr);
2126 IDirectDrawSurface7_EnumAttachedSurfaces(surface,
2129 IDirectDrawSurface7_Release(surface);
2130 return DDENUMRET_OK;
2133 /*****************************************************************************
2134 * IDirectDrawSurface7::SetColorKey
2136 * Sets the color keying options for the surface. Observations showed that
2137 * in case of complex surfaces the color key has to be assigned to all
2142 * CKey: The new color key
2146 * See IWineD3DSurface::SetColorKey for details
2148 *****************************************************************************/
2149 static HRESULT WINAPI
2150 IDirectDrawSurfaceImpl_SetColorKey(IDirectDrawSurface7 *iface,
2154 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2155 struct SCKContext ctx = { DD_OK, (WINEDDCOLORKEY *) CKey, Flags };
2156 TRACE("(%p)->(%x,%p)\n", This, Flags, CKey);
2160 switch (Flags & ~DDCKEY_COLORSPACE)
2162 case DDCKEY_DESTBLT:
2163 This->surface_desc.ddckCKDestBlt = *CKey;
2164 This->surface_desc.dwFlags |= DDSD_CKDESTBLT;
2167 case DDCKEY_DESTOVERLAY:
2168 This->surface_desc.u3.ddckCKDestOverlay = *CKey;
2169 This->surface_desc.dwFlags |= DDSD_CKDESTOVERLAY;
2172 case DDCKEY_SRCOVERLAY:
2173 This->surface_desc.ddckCKSrcOverlay = *CKey;
2174 This->surface_desc.dwFlags |= DDSD_CKSRCOVERLAY;
2178 This->surface_desc.ddckCKSrcBlt = *CKey;
2179 This->surface_desc.dwFlags |= DDSD_CKSRCBLT;
2183 return DDERR_INVALIDPARAMS;
2188 switch (Flags & ~DDCKEY_COLORSPACE)
2190 case DDCKEY_DESTBLT:
2191 This->surface_desc.dwFlags &= ~DDSD_CKDESTBLT;
2194 case DDCKEY_DESTOVERLAY:
2195 This->surface_desc.dwFlags &= ~DDSD_CKDESTOVERLAY;
2198 case DDCKEY_SRCOVERLAY:
2199 This->surface_desc.dwFlags &= ~DDSD_CKSRCOVERLAY;
2203 This->surface_desc.dwFlags &= ~DDSD_CKSRCBLT;
2207 return DDERR_INVALIDPARAMS;
2210 ctx.ret = IWineD3DSurface_SetColorKey(This->WineD3DSurface,
2213 IDirectDrawSurface7_EnumAttachedSurfaces(iface,
2218 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
2219 default: return ctx.ret;
2223 /*****************************************************************************
2224 * IDirectDrawSurface7::SetPalette
2226 * Assigns a DirectDrawPalette object to the surface
2229 * Pal: Interface to the palette to set
2234 *****************************************************************************/
2235 static HRESULT WINAPI
2236 IDirectDrawSurfaceImpl_SetPalette(IDirectDrawSurface7 *iface,
2237 IDirectDrawPalette *Pal)
2239 ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
2240 IDirectDrawPalette *oldPal;
2241 IDirectDrawSurfaceImpl *surf;
2242 IDirectDrawPaletteImpl *PalImpl = ICOM_OBJECT(IDirectDrawPaletteImpl, IDirectDrawPalette, Pal);
2244 TRACE("(%p)->(%p)\n", This, Pal);
2246 /* Find the old palette */
2247 hr = IDirectDrawSurface_GetPalette(iface, &oldPal);
2248 if(hr != DD_OK && hr != DDERR_NOPALETTEATTACHED) return hr;
2249 if(oldPal) IDirectDrawPalette_Release(oldPal); /* For the GetPalette */
2251 /* Set the new Palette */
2252 IWineD3DSurface_SetPalette(This->WineD3DSurface,
2253 PalImpl ? PalImpl->wineD3DPalette : NULL);
2254 /* AddRef the Palette */
2255 if(Pal) IDirectDrawPalette_AddRef(Pal);
2257 /* Release the old palette */
2258 if(oldPal) IDirectDrawPalette_Release(oldPal);
2260 /* If this is a front buffer, also update the back buffers
2261 * TODO: How do things work for palettized cube textures?
2263 if(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
2265 /* For primary surfaces the tree is just a list, so the simpler scheme fits too */
2266 DDSCAPS2 caps2 = { DDSCAPS_PRIMARYSURFACE, 0, 0, 0 };
2271 IDirectDrawSurface7 *attach;
2273 hr = IDirectDrawSurface7_GetAttachedSurface(ICOM_INTERFACE(surf, IDirectDrawSurface7),
2280 TRACE("Setting palette on %p\n", attach);
2281 IDirectDrawSurface7_SetPalette(attach,
2283 surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, attach);
2284 IDirectDrawSurface7_Release(attach);
2291 /*****************************************************************************
2293 *****************************************************************************/
2295 const IDirectDrawSurface7Vtbl IDirectDrawSurface7_Vtbl =
2298 IDirectDrawSurfaceImpl_QueryInterface,
2299 IDirectDrawSurfaceImpl_AddRef,
2300 IDirectDrawSurfaceImpl_Release,
2301 /*** IDirectDrawSurface ***/
2302 IDirectDrawSurfaceImpl_AddAttachedSurface,
2303 IDirectDrawSurfaceImpl_AddOverlayDirtyRect,
2304 IDirectDrawSurfaceImpl_Blt,
2305 IDirectDrawSurfaceImpl_BltBatch,
2306 IDirectDrawSurfaceImpl_BltFast,
2307 IDirectDrawSurfaceImpl_DeleteAttachedSurface,
2308 IDirectDrawSurfaceImpl_EnumAttachedSurfaces,
2309 IDirectDrawSurfaceImpl_EnumOverlayZOrders,
2310 IDirectDrawSurfaceImpl_Flip,
2311 IDirectDrawSurfaceImpl_GetAttachedSurface,
2312 IDirectDrawSurfaceImpl_GetBltStatus,
2313 IDirectDrawSurfaceImpl_GetCaps,
2314 IDirectDrawSurfaceImpl_GetClipper,
2315 IDirectDrawSurfaceImpl_GetColorKey,
2316 IDirectDrawSurfaceImpl_GetDC,
2317 IDirectDrawSurfaceImpl_GetFlipStatus,
2318 IDirectDrawSurfaceImpl_GetOverlayPosition,
2319 IDirectDrawSurfaceImpl_GetPalette,
2320 IDirectDrawSurfaceImpl_GetPixelFormat,
2321 IDirectDrawSurfaceImpl_GetSurfaceDesc,
2322 IDirectDrawSurfaceImpl_Initialize,
2323 IDirectDrawSurfaceImpl_IsLost,
2324 IDirectDrawSurfaceImpl_Lock,
2325 IDirectDrawSurfaceImpl_ReleaseDC,
2326 IDirectDrawSurfaceImpl_Restore,
2327 IDirectDrawSurfaceImpl_SetClipper,
2328 IDirectDrawSurfaceImpl_SetColorKey,
2329 IDirectDrawSurfaceImpl_SetOverlayPosition,
2330 IDirectDrawSurfaceImpl_SetPalette,
2331 IDirectDrawSurfaceImpl_Unlock,
2332 IDirectDrawSurfaceImpl_UpdateOverlay,
2333 IDirectDrawSurfaceImpl_UpdateOverlayDisplay,
2334 IDirectDrawSurfaceImpl_UpdateOverlayZOrder,
2335 /*** IDirectDrawSurface2 ***/
2336 IDirectDrawSurfaceImpl_GetDDInterface,
2337 IDirectDrawSurfaceImpl_PageLock,
2338 IDirectDrawSurfaceImpl_PageUnlock,
2339 /*** IDirectDrawSurface3 ***/
2340 IDirectDrawSurfaceImpl_SetSurfaceDesc,
2341 /*** IDirectDrawSurface4 ***/
2342 IDirectDrawSurfaceImpl_SetPrivateData,
2343 IDirectDrawSurfaceImpl_GetPrivateData,
2344 IDirectDrawSurfaceImpl_FreePrivateData,
2345 IDirectDrawSurfaceImpl_GetUniquenessValue,
2346 IDirectDrawSurfaceImpl_ChangeUniquenessValue,
2347 /*** IDirectDrawSurface7 ***/
2348 IDirectDrawSurfaceImpl_SetPriority,
2349 IDirectDrawSurfaceImpl_GetPriority,
2350 IDirectDrawSurfaceImpl_SetLOD,
2351 IDirectDrawSurfaceImpl_GetLOD