2 * Copyright 2008 Stefan Dösinger for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "wine/debug.h"
29 #include "ddrawex_private.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(ddrawex
);
33 /******************************************************************************
34 * Helper functions for COM management
35 ******************************************************************************/
36 static IDirectDrawSurfaceImpl
*impl_from_dds3(IDirectDrawSurface3
*iface
)
38 if(!iface
) return NULL
;
39 return (IDirectDrawSurfaceImpl
*)((char*)iface
- FIELD_OFFSET(IDirectDrawSurfaceImpl
, IDirectDrawSurface3_Vtbl
));
41 static IDirectDrawSurface3
*dds3_from_impl(IDirectDrawSurfaceImpl
*This
)
43 if(!This
) return NULL
;
44 return (IDirectDrawSurface3
*) &This
->IDirectDrawSurface3_Vtbl
;
47 static IDirectDrawSurfaceImpl
*impl_from_dds4(IDirectDrawSurface4
*iface
)
49 if(!iface
) return NULL
;
50 return (IDirectDrawSurfaceImpl
*)((char*)iface
- FIELD_OFFSET(IDirectDrawSurfaceImpl
, IDirectDrawSurface4_Vtbl
));
52 static IDirectDrawSurface4
*dds4_from_impl(IDirectDrawSurfaceImpl
*This
)
54 if(!This
) return NULL
;
55 return (IDirectDrawSurface4
*) &This
->IDirectDrawSurface4_Vtbl
;
59 IDirectDrawSurface4Impl_QueryInterface(IDirectDrawSurface4
*iface
,
63 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
65 /* According to COM docs, if the QueryInterface fails, obj should be set to NULL */
69 return DDERR_INVALIDPARAMS
;
71 TRACE("(%p)->(%s,%p)\n",This
,debugstr_guid(riid
),obj
);
72 if (IsEqualGUID(riid
, &IID_IUnknown
)
73 || IsEqualGUID(riid
, &IID_IDirectDrawSurface4
) )
75 *obj
= dds4_from_impl(This
);
76 IDirectDrawSurface4_AddRef((IDirectDrawSurface4
*) *obj
);
77 TRACE("(%p) returning IDirectDrawSurface4 interface at %p\n", This
, *obj
);
80 else if( IsEqualGUID(riid
, &IID_IDirectDrawSurface3
)
81 || IsEqualGUID(riid
, &IID_IDirectDrawSurface2
)
82 || IsEqualGUID(riid
, &IID_IDirectDrawSurface
) )
84 *obj
= dds3_from_impl(This
);
85 IDirectDrawSurface3_AddRef((IDirectDrawSurface3
*) *obj
);
86 TRACE("(%p) returning IDirectDrawSurface3 interface at %p\n", This
, *obj
);
89 else if( IsEqualGUID(riid
, &IID_IDirectDrawGammaControl
) )
91 FIXME("Implement IDirectDrawGammaControl in ddrawex\n");
93 else if( IsEqualGUID(riid
, &IID_IDirect3DHALDevice
)||
94 IsEqualGUID(riid
, &IID_IDirect3DRGBDevice
) )
96 /* Most likely not supported */
97 FIXME("Test IDirect3DDevice in ddrawex\n");
99 else if (IsEqualGUID( &IID_IDirect3DTexture
, riid
) ||
100 IsEqualGUID( &IID_IDirect3DTexture2
, riid
))
102 FIXME("Implement IDirect3dTexture in ddrawex\n");
106 WARN("No interface\n");
109 return E_NOINTERFACE
;
112 static HRESULT WINAPI
113 IDirectDrawSurface3Impl_QueryInterface(IDirectDrawSurface3
*iface
,
117 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
118 TRACE("(%p)->(%s,%p): Thunking to IDirectDrawSurface4\n",This
,debugstr_guid(riid
),obj
);
119 return IDirectDrawSurface4_QueryInterface(dds4_from_impl(This
), riid
, obj
);
123 IDirectDrawSurface4Impl_AddRef(IDirectDrawSurface4
*iface
)
125 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
126 ULONG ref
= InterlockedIncrement(&This
->ref
);
128 TRACE("(%p) : incrementing refcount from %u.\n", This
, ref
- 1);
134 IDirectDrawSurface3Impl_AddRef(IDirectDrawSurface3
*iface
)
136 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
137 TRACE("(%p): Thunking to IDirectDrawSurface4\n", This
);
138 return IDirectDrawSurface4_AddRef(dds4_from_impl(This
));
142 IDirectDrawSurface4Impl_Release(IDirectDrawSurface4
*iface
)
144 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
145 ULONG ref
= InterlockedDecrement(&This
->ref
);
147 TRACE("(%p) : decrementing refcount to %u.\n", This
, ref
);
151 TRACE("Destroying object\n");
152 IDirectDrawSurface4_FreePrivateData(This
->parent
, &IID_DDrawexPriv
);
153 IDirectDrawSurface4_Release(This
->parent
);
154 HeapFree(GetProcessHeap(), 0, This
);
160 IDirectDrawSurface3Impl_Release(IDirectDrawSurface3
*iface
)
162 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
163 TRACE("(%p): Thunking to IDirectDrawSurface4\n", This
);
164 return IDirectDrawSurface4_Release(dds4_from_impl(This
));
167 static HRESULT WINAPI
168 IDirectDrawSurface4Impl_AddAttachedSurface(IDirectDrawSurface4
*iface
,
169 IDirectDrawSurface4
*Attach_iface
)
171 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
172 IDirectDrawSurfaceImpl
*attach
= impl_from_dds4(Attach_iface
);
173 TRACE("(%p)->(%p)\n", This
, attach
);
174 return IDirectDrawSurface4_AddAttachedSurface(This
->parent
, attach
->parent
);
177 static HRESULT WINAPI
178 IDirectDrawSurface3Impl_AddAttachedSurface(IDirectDrawSurface3
*iface
,
179 IDirectDrawSurface3
*Attach_iface
)
181 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
182 IDirectDrawSurfaceImpl
*attach
= impl_from_dds3(Attach_iface
);
183 TRACE("(%p)->(%p): Thunking to IDirectDrawSurface4\n", This
, attach
);
184 return IDirectDrawSurface4_AddAttachedSurface(dds4_from_impl(This
), dds4_from_impl(attach
));
187 static HRESULT WINAPI
188 IDirectDrawSurface4Impl_AddOverlayDirtyRect(IDirectDrawSurface4
*iface
,
191 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
192 TRACE("(%p)->(%p)\n", This
, Rect
);
193 return IDirectDrawSurface4_AddOverlayDirtyRect(This
->parent
, Rect
);
196 static HRESULT WINAPI
197 IDirectDrawSurface3Impl_AddOverlayDirtyRect(IDirectDrawSurface3
*iface
,
200 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
201 TRACE("(%p)->(%p): Thunking to IDirectDrawSurface4\n", This
, Rect
);
202 return IDirectDrawSurface4_AddOverlayDirtyRect(dds4_from_impl(This
), Rect
);
205 static HRESULT WINAPI
206 IDirectDrawSurface4Impl_Blt(IDirectDrawSurface4
*iface
,
208 IDirectDrawSurface4
*SrcSurface
,
213 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
214 IDirectDrawSurfaceImpl
*Src
= impl_from_dds4(SrcSurface
);
215 TRACE("(%p)->(%p,%p,%p,0x%08x,%p)\n", This
, DestRect
, Src
, SrcRect
, Flags
, DDBltFx
);
216 return IDirectDrawSurface4_Blt(This
->parent
, DestRect
, Src
? Src
->parent
: NULL
,
217 SrcRect
, Flags
, DDBltFx
);
220 static HRESULT WINAPI
221 IDirectDrawSurface3Impl_Blt(IDirectDrawSurface3
*iface
,
223 IDirectDrawSurface3
*SrcSurface
,
228 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
229 IDirectDrawSurfaceImpl
*Src
= impl_from_dds3(SrcSurface
);
230 TRACE("(%p)->(%p,%p,%p,0x%08x,%p): Thunking to IDirectDrawSurface4\n", This
, DestRect
, Src
, SrcRect
, Flags
, DDBltFx
);
231 return IDirectDrawSurface4_Blt(dds4_from_impl(This
), DestRect
, dds4_from_impl(Src
),
232 SrcRect
, Flags
, DDBltFx
);
235 static HRESULT WINAPI
236 IDirectDrawSurface4Impl_BltBatch(IDirectDrawSurface4
*iface
,
241 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
242 TRACE("(%p)->(%p,%u,0x%08x)\n", This
, Batch
, Count
, Flags
);
243 return IDirectDrawSurface4_BltBatch(This
->parent
, Batch
, Count
, Flags
);
246 static HRESULT WINAPI
247 IDirectDrawSurface3Impl_BltBatch(IDirectDrawSurface3
*iface
,
252 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
253 TRACE("(%p)->(%p,%u,0x%08x): Thunking to IDirectDrawSurface4\n", This
, Batch
, Count
, Flags
);
254 return IDirectDrawSurface4_BltBatch(dds4_from_impl(This
), Batch
, Count
, Flags
);
257 static HRESULT WINAPI
258 IDirectDrawSurface4Impl_BltFast(IDirectDrawSurface4
*iface
,
261 IDirectDrawSurface4
*Source
,
265 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
266 IDirectDrawSurfaceImpl
*Src
= impl_from_dds4(Source
);
267 TRACE("(%p)->(%u,%u,%p,%p,0x%08x)\n", This
, dstx
, dsty
, Src
, rsrc
, trans
);
268 return IDirectDrawSurface4_BltFast(This
->parent
, dstx
, dsty
, Src
? Src
->parent
: NULL
,
272 static HRESULT WINAPI
273 IDirectDrawSurface3Impl_BltFast(IDirectDrawSurface3
*iface
,
276 IDirectDrawSurface3
*Source
,
280 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
281 IDirectDrawSurfaceImpl
*Src
= impl_from_dds3(Source
);
282 TRACE("(%p)->(%u,%u,%p,%p,0x%08x): Thunking to IDirectDrawSurface4\n", This
, dstx
, dsty
, Src
, rsrc
, trans
);
283 return IDirectDrawSurface4_BltFast(dds4_from_impl(This
), dstx
, dsty
, dds4_from_impl(Src
),
287 static HRESULT WINAPI
288 IDirectDrawSurface4Impl_DeleteAttachedSurface(IDirectDrawSurface4
*iface
,
290 IDirectDrawSurface4
*Attach
)
292 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
293 IDirectDrawSurfaceImpl
*Att
= impl_from_dds4(Attach
);
294 TRACE("(%p)->(0x%08x,%p)\n", This
, Flags
, Att
);
295 return IDirectDrawSurface4_DeleteAttachedSurface(This
->parent
, Flags
,
296 Att
? Att
->parent
: NULL
);
299 static HRESULT WINAPI
300 IDirectDrawSurface3Impl_DeleteAttachedSurface(IDirectDrawSurface3
*iface
,
302 IDirectDrawSurface3
*Attach
)
304 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
305 IDirectDrawSurfaceImpl
*Att
= impl_from_dds3(Attach
);
306 TRACE("(%p)->(0x%08x,%p): Thunking to IDirectDrawSurface4\n", This
, Flags
, Att
);
307 return IDirectDrawSurface4_DeleteAttachedSurface(dds4_from_impl(This
), Flags
,
308 dds4_from_impl(Att
));
311 struct enumsurfaces_wrap
313 LPDDENUMSURFACESCALLBACK2 orig_cb
;
317 static HRESULT WINAPI
318 enumsurfaces_wrap_cb(IDirectDrawSurface4
*surf
, DDSURFACEDESC2
*desc
, void *vctx
)
320 struct enumsurfaces_wrap
*ctx
= vctx
;
321 IDirectDrawSurface4
*outer
= dds_get_outer(surf
);
323 TRACE("Returning outer surface %p for inner surface %p\n", outer
, surf
);
324 IDirectDrawSurface4_AddRef(outer
);
325 IDirectDrawSurface4_Release(surf
);
326 return ctx
->orig_cb(outer
, desc
, vctx
);
329 static HRESULT WINAPI
330 IDirectDrawSurface4Impl_EnumAttachedSurfaces(IDirectDrawSurface4
*iface
,
332 LPDDENUMSURFACESCALLBACK2 cb
)
334 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
335 struct enumsurfaces_wrap ctx
;
336 TRACE("(%p)->(%p,%p)\n", This
, context
, cb
);
339 ctx
.orig_ctx
= context
;
340 return IDirectDrawSurface4_EnumAttachedSurfaces(This
->parent
, &ctx
, enumsurfaces_wrap_cb
);
343 struct enumsurfaces_thunk
345 LPDDENUMSURFACESCALLBACK orig_cb
;
349 static HRESULT WINAPI
350 enumsurfaces_thunk_cb(IDirectDrawSurface4
*surf
, DDSURFACEDESC2
*desc2
, void *vctx
)
352 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(surf
);
353 struct enumsurfaces_thunk
*ctx
= vctx
;
356 TRACE("Thunking back to IDirectDrawSurface3\n");
357 IDirectDrawSurface3_AddRef(dds3_from_impl(This
));
358 IDirectDrawSurface3_Release(surf
);
359 DDSD2_to_DDSD(desc2
, &desc
);
360 return ctx
->orig_cb((IDirectDrawSurface
*) dds3_from_impl(This
), &desc
, ctx
->orig_ctx
);
363 static HRESULT WINAPI
364 IDirectDrawSurface3Impl_EnumAttachedSurfaces(IDirectDrawSurface3
*iface
,
366 LPDDENUMSURFACESCALLBACK cb
)
368 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
369 struct enumsurfaces_thunk ctx
;
370 TRACE("(%p)->(%p,%p): Thunking to IDirectDraw4\n", This
, context
, cb
);
373 ctx
.orig_ctx
= context
;
374 return IDirectDrawSurface4_EnumAttachedSurfaces(dds4_from_impl(This
), &ctx
, enumsurfaces_thunk_cb
);
377 static HRESULT WINAPI
378 IDirectDrawSurface4Impl_EnumOverlayZOrders(IDirectDrawSurface4
*iface
,
381 LPDDENUMSURFACESCALLBACK2 cb
)
383 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
384 struct enumsurfaces_wrap ctx
;
385 TRACE("(%p)->(0x%08x,%p,%p)\n", This
, Flags
, context
, cb
);
388 ctx
.orig_ctx
= context
;
389 return IDirectDrawSurface4_EnumOverlayZOrders(This
->parent
, Flags
, &ctx
, enumsurfaces_wrap_cb
);
392 static HRESULT WINAPI
393 IDirectDrawSurface3Impl_EnumOverlayZOrders(IDirectDrawSurface3
*iface
,
396 LPDDENUMSURFACESCALLBACK cb
)
398 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
399 struct enumsurfaces_thunk ctx
;
400 TRACE("(%p)->(0x%08x,%p,%p): Thunking to IDirectDraw4\n", This
, Flags
, context
, cb
);
403 ctx
.orig_ctx
= context
;
404 return IDirectDrawSurface4_EnumOverlayZOrders(dds4_from_impl(This
), Flags
, &ctx
, enumsurfaces_thunk_cb
);
407 static HRESULT WINAPI
408 IDirectDrawSurface4Impl_Flip(IDirectDrawSurface4
*iface
,
409 IDirectDrawSurface4
*DestOverride
,
412 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
413 IDirectDrawSurfaceImpl
*Dest
= impl_from_dds4(DestOverride
);
414 TRACE("(%p)->(%p,0x%08x)\n", This
, Dest
, Flags
);
415 return IDirectDrawSurface4_Flip(This
->parent
, Dest
? Dest
->parent
: NULL
, Flags
);
418 static HRESULT WINAPI
419 IDirectDrawSurface3Impl_Flip(IDirectDrawSurface3
*iface
,
420 IDirectDrawSurface3
*DestOverride
,
423 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
424 IDirectDrawSurfaceImpl
*Dest
= impl_from_dds3(DestOverride
);
425 TRACE("(%p)->(%p,0x%08x): Thunking to IDirectDrawSurface4\n", This
, Dest
, Flags
);
426 return IDirectDrawSurface4_Flip(dds4_from_impl(This
), dds4_from_impl(Dest
), Flags
);
429 static HRESULT WINAPI
430 IDirectDrawSurface4Impl_GetAttachedSurface(IDirectDrawSurface4
*iface
,
432 IDirectDrawSurface4
**Surface
)
434 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
435 IDirectDrawSurface4
*inner
= NULL
;
437 TRACE("(%p)->(%p,%p)\n", This
, Caps
, Surface
);
439 hr
= IDirectDrawSurface4_GetAttachedSurface(dds4_from_impl(This
), Caps
, &inner
);
442 *Surface
= dds_get_outer(inner
);
443 IDirectDrawSurface4_AddRef(*Surface
);
444 IDirectDrawSurface4_Release(inner
);
453 static HRESULT WINAPI
454 IDirectDrawSurface3Impl_GetAttachedSurface(IDirectDrawSurface3
*iface
,
456 IDirectDrawSurface3
**Surface
)
458 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
459 IDirectDrawSurface4
*surf4
;
462 TRACE("(%p)->(%p,%p): Thunking to IDirectDrawSurface4\n", This
, Caps
, Surface
);
464 memset(&caps2
, 0, sizeof(caps2
));
465 caps2
.dwCaps
= Caps
->dwCaps
;
466 hr
= IDirectDrawSurface4_GetAttachedSurface(dds4_from_impl(This
), &caps2
, &surf4
);
469 IDirectDrawSurface4_QueryInterface(surf4
, &IID_IDirectDrawSurface3
, (void **) Surface
);
470 IDirectDrawSurface4_Release(surf4
);
479 static HRESULT WINAPI
480 IDirectDrawSurface4Impl_GetBltStatus(IDirectDrawSurface4
*iface
,
483 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
484 TRACE("(%p)->(0x%08x)\n", This
, Flags
);
485 return IDirectDrawSurface4_GetBltStatus(This
->parent
, Flags
);
488 static HRESULT WINAPI
489 IDirectDrawSurface3Impl_GetBltStatus(IDirectDrawSurface3
*iface
,
492 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
493 TRACE("(%p)->(0x%08x): Thunking to IDirectDrawSurface4\n", This
, Flags
);
494 return IDirectDrawSurface4_GetBltStatus(dds4_from_impl(This
), Flags
);
497 static HRESULT WINAPI
498 IDirectDrawSurface4Impl_GetCaps(IDirectDrawSurface4
*iface
,
501 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
502 TRACE("(%p)->(%p)\n", This
, Caps
);
503 return IDirectDrawSurface4_GetCaps(This
->parent
, Caps
);
506 static HRESULT WINAPI
507 IDirectDrawSurface3Impl_GetCaps(IDirectDrawSurface3
*iface
,
510 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
513 TRACE("(%p)->(%p): Thunking to IDirectDrawSurface4\n", This
, Caps
);
515 memset(&caps2
, 0, sizeof(caps2
));
516 memset(Caps
, 0, sizeof(*Caps
));
517 hr
= IDirectDrawSurface4_GetCaps(dds4_from_impl(This
), &caps2
);
518 Caps
->dwCaps
= caps2
.dwCaps
;
522 static HRESULT WINAPI
523 IDirectDrawSurface4Impl_GetClipper(IDirectDrawSurface4
*iface
,
524 IDirectDrawClipper
**Clipper
)
526 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
527 TRACE("(%p)->(%p)\n", This
, Clipper
);
528 return IDirectDrawSurface4_GetClipper(This
->parent
, Clipper
);
531 static HRESULT WINAPI
532 IDirectDrawSurface3Impl_GetClipper(IDirectDrawSurface3
*iface
,
533 IDirectDrawClipper
**Clipper
)
535 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
536 TRACE("(%p)->(%p): Thunking to IDirectDrawSurface4\n", This
, Clipper
);
537 return IDirectDrawSurface4_GetClipper(dds4_from_impl(This
), Clipper
);
540 static HRESULT WINAPI
541 IDirectDrawSurface4Impl_GetColorKey(IDirectDrawSurface4
*iface
,
545 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
546 TRACE("(%p)->(0x%08x,%p)\n", This
, Flags
, CKey
);
547 return IDirectDrawSurface4_GetColorKey(This
->parent
, Flags
, CKey
);
550 static HRESULT WINAPI
551 IDirectDrawSurface3Impl_GetColorKey(IDirectDrawSurface3
*iface
,
555 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
556 TRACE("(%p)->(0x%08x,%p): Thunking to IDirectDrawSurface4\n", This
, Flags
, CKey
);
557 return IDirectDrawSurface4_GetColorKey(dds4_from_impl(This
), Flags
, CKey
);
560 static HRESULT WINAPI
561 IDirectDrawSurface4Impl_GetDC(IDirectDrawSurface4
*iface
,
564 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
565 TRACE("(%p)->(%p)\n", This
, hdc
);
566 if(This
->permanent_dc
)
568 TRACE("Returning stored dc %p\n", This
->hdc
);
574 return IDirectDrawSurface4_GetDC(This
->parent
, hdc
);
578 static HRESULT WINAPI
579 IDirectDrawSurface3Impl_GetDC(IDirectDrawSurface3
*iface
,
582 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
583 TRACE("(%p)->(%p): Thunking to IDirectDrawSurface4\n", This
, hdc
);
584 return IDirectDrawSurface4_GetDC(dds4_from_impl(This
), hdc
);
587 static HRESULT WINAPI
588 IDirectDrawSurface4Impl_GetFlipStatus(IDirectDrawSurface4
*iface
,
591 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
592 TRACE("(%p)->(0x%08x)\n", This
, Flags
);
593 return IDirectDrawSurface4_GetFlipStatus(This
->parent
, Flags
);
596 static HRESULT WINAPI
597 IDirectDrawSurface3Impl_GetFlipStatus(IDirectDrawSurface3
*iface
,
600 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
601 TRACE("(%p)->(0x%08x): Thunking to IDirectDrawSurface4\n", This
, Flags
);
602 return IDirectDrawSurface4_GetFlipStatus(dds4_from_impl(This
), Flags
);
605 static HRESULT WINAPI
606 IDirectDrawSurface4Impl_GetOverlayPosition(IDirectDrawSurface4
*iface
,
610 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
611 TRACE("(%p)->(%p,%p)\n", This
, X
, Y
);
612 return IDirectDrawSurface4_GetOverlayPosition(This
->parent
, X
, Y
);
615 static HRESULT WINAPI
616 IDirectDrawSurface3Impl_GetOverlayPosition(IDirectDrawSurface3
*iface
,
620 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
621 TRACE("(%p)->(%p,%p): Thunking to IDirectDrawSurface4\n", This
, X
, Y
);
622 return IDirectDrawSurface4_GetOverlayPosition(dds4_from_impl(This
), X
, Y
);
625 static HRESULT WINAPI
626 IDirectDrawSurface4Impl_GetPalette(IDirectDrawSurface4
*iface
,
627 IDirectDrawPalette
**Pal
)
629 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
630 TRACE("(%p)->(%p)\n", This
, Pal
);
631 return IDirectDrawSurface4_GetPalette(This
->parent
, Pal
);
634 static HRESULT WINAPI
635 IDirectDrawSurface3Impl_GetPalette(IDirectDrawSurface3
*iface
,
636 IDirectDrawPalette
**Pal
)
638 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
639 TRACE("(%p)->(%p): Thunking to IDirectDrawSurface4\n", This
, Pal
);
640 return IDirectDrawSurface4_GetPalette(dds4_from_impl(This
), Pal
);
643 static HRESULT WINAPI
644 IDirectDrawSurface4Impl_GetPixelFormat(IDirectDrawSurface4
*iface
,
645 DDPIXELFORMAT
*PixelFormat
)
647 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
648 TRACE("(%p)->(%p)\n", This
, PixelFormat
);
649 return IDirectDrawSurface4_GetPixelFormat(This
->parent
, PixelFormat
);
652 static HRESULT WINAPI
653 IDirectDrawSurface3Impl_GetPixelFormat(IDirectDrawSurface3
*iface
,
654 DDPIXELFORMAT
*PixelFormat
)
656 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
657 TRACE("(%p)->(%p): Thunking to IDirectDrawSurface4\n", This
, PixelFormat
);
658 return IDirectDrawSurface4_GetPixelFormat(dds4_from_impl(This
), PixelFormat
);
661 static HRESULT WINAPI
662 IDirectDrawSurface4Impl_GetSurfaceDesc(IDirectDrawSurface4
*iface
,
663 DDSURFACEDESC2
*DDSD
)
665 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
667 TRACE("(%p)->(%p)\n", This
, DDSD
);
668 hr
= IDirectDrawSurface4_GetSurfaceDesc(This
->parent
, DDSD
);
670 if(SUCCEEDED(hr
) && This
->permanent_dc
)
672 DDSD
->ddsCaps
.dwCaps
|= DDSCAPS_VIDEOMEMORY
;
673 DDSD
->ddsCaps
.dwCaps
&= ~DDSCAPS_OWNDC
;
679 static HRESULT WINAPI
680 IDirectDrawSurface3Impl_GetSurfaceDesc(IDirectDrawSurface3
*iface
,
683 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
684 DDSURFACEDESC2 ddsd2
;
686 TRACE("(%p)->(%p): Thunking to IDirectDrawSurface4\n", This
, DDSD
);
688 memset(&ddsd2
, 0, sizeof(ddsd2
));
689 ddsd2
.dwSize
= sizeof(ddsd2
);
690 hr
= IDirectDrawSurface4_GetSurfaceDesc(dds4_from_impl(This
), &ddsd2
);
691 DDSD2_to_DDSD(&ddsd2
, DDSD
);
695 static HRESULT WINAPI
696 IDirectDrawSurface4Impl_Initialize(IDirectDrawSurface4
*iface
,
698 DDSURFACEDESC2
*DDSD
)
700 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
701 IDirectDraw4
*outer_DD4
;
702 IDirectDraw4
*inner_DD4
;
703 IDirectDraw
*inner_DD
;
705 TRACE("(%p)->(%p,%p)\n", This
, DD
, DDSD
);
707 IDirectDraw_QueryInterface(DD
, &IID_IDirectDraw4
, (void **) &outer_DD4
);
708 inner_DD4
= dd_get_inner(outer_DD4
);
709 IDirectDraw4_Release(outer_DD4
);
710 IDirectDraw4_QueryInterface(inner_DD4
, &IID_IDirectDraw4
, (void **) &inner_DD
);
711 hr
= IDirectDrawSurface4_Initialize(This
->parent
, inner_DD
, DDSD
);
712 IDirectDraw_Release(inner_DD
);
716 static HRESULT WINAPI
717 IDirectDrawSurface3Impl_Initialize(IDirectDrawSurface3
*iface
,
721 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
722 DDSURFACEDESC2 ddsd2
;
723 TRACE("(%p)->(%p,%p): Thunking to IDirectDrawSurface4\n", This
, DD
, DDSD
);
724 DDSD_to_DDSD2(DDSD
, &ddsd2
);
725 return IDirectDrawSurface4_Initialize(dds4_from_impl(This
), DD
, &ddsd2
);
728 static HRESULT WINAPI
729 IDirectDrawSurface4Impl_IsLost(IDirectDrawSurface4
*iface
)
731 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
732 TRACE("(%p)\n", This
);
733 return IDirectDrawSurface4_IsLost(This
->parent
);
736 static HRESULT WINAPI
737 IDirectDrawSurface3Impl_IsLost(IDirectDrawSurface3
*iface
)
739 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
740 TRACE("(%p): Thunking to IDirectDrawSurface4\n", This
);
741 return IDirectDrawSurface4_IsLost(dds4_from_impl(This
));
744 static HRESULT WINAPI
745 IDirectDrawSurface4Impl_Lock(IDirectDrawSurface4
*iface
,
747 DDSURFACEDESC2
*DDSD
,
751 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
753 TRACE("(%p)->(%p,%p,0x%08x,%p)\n", This
, Rect
, DDSD
, Flags
, h
);
754 hr
= IDirectDrawSurface4_Lock(This
->parent
, Rect
, DDSD
, Flags
, h
);
756 if(SUCCEEDED(hr
) && This
->permanent_dc
)
758 DDSD
->ddsCaps
.dwCaps
|= DDSCAPS_VIDEOMEMORY
;
759 DDSD
->ddsCaps
.dwCaps
&= ~DDSCAPS_OWNDC
;
765 static HRESULT WINAPI
766 IDirectDrawSurface3Impl_Lock(IDirectDrawSurface3
*iface
,
772 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
773 DDSURFACEDESC2 ddsd2
;
775 TRACE("(%p)->(%p,%p,0x%08x,%p): Thunking to IDirectDrawSurface4\n", This
, Rect
, DDSD
, Flags
, h
);
776 memset(&ddsd2
, 0, sizeof(ddsd2
));
777 ddsd2
.dwSize
= sizeof(ddsd2
);
778 hr
= IDirectDrawSurface4_Lock(dds4_from_impl(This
), Rect
, &ddsd2
, Flags
, h
);
779 DDSD2_to_DDSD(&ddsd2
, DDSD
);
783 static HRESULT WINAPI
784 IDirectDrawSurface4Impl_ReleaseDC(IDirectDrawSurface4
*iface
,
787 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
788 TRACE("(%p)->(%p)\n", This
, hdc
);
789 if(This
->permanent_dc
)
791 TRACE("Surface has a permanent DC, not doing anything\n");
796 return IDirectDrawSurface4_ReleaseDC(This
->parent
, hdc
);
800 static HRESULT WINAPI
801 IDirectDrawSurface3Impl_ReleaseDC(IDirectDrawSurface3
*iface
,
804 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
805 TRACE("(%p)->(%p): Thunking to IDirectDrawSurface4\n", This
, hdc
);
806 return IDirectDrawSurface4_ReleaseDC(dds4_from_impl(This
), hdc
);
809 static HRESULT WINAPI
810 IDirectDrawSurface4Impl_Restore(IDirectDrawSurface4
*iface
)
812 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
813 TRACE("(%p)\n", This
);
814 return IDirectDrawSurface4_Restore(This
->parent
);
817 static HRESULT WINAPI
818 IDirectDrawSurface3Impl_Restore(IDirectDrawSurface3
*iface
)
820 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
821 TRACE("(%p): Thunking to IDirectDrawSurface4\n", This
);
822 return IDirectDrawSurface4_Restore(dds4_from_impl(This
));
825 static HRESULT WINAPI
826 IDirectDrawSurface4Impl_SetClipper(IDirectDrawSurface4
*iface
,
827 IDirectDrawClipper
*Clipper
)
829 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
830 TRACE("(%p)->(%p)\n", This
, Clipper
);
831 return IDirectDrawSurface4_SetClipper(This
->parent
, Clipper
);
834 static HRESULT WINAPI
835 IDirectDrawSurface3Impl_SetClipper(IDirectDrawSurface3
*iface
,
836 IDirectDrawClipper
*Clipper
)
838 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
839 TRACE("(%p)->(%p): Thunking to IDirectDrawSurface4\n", This
, Clipper
);
840 return IDirectDrawSurface4_SetClipper(dds4_from_impl(This
), Clipper
);
843 static HRESULT WINAPI
844 IDirectDrawSurface4Impl_SetColorKey(IDirectDrawSurface4
*iface
,
848 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
849 TRACE("(%p)->(0x%08x,%p)\n", This
, Flags
, CKey
);
850 return IDirectDrawSurface4_SetColorKey(This
->parent
, Flags
, CKey
);
853 static HRESULT WINAPI
854 IDirectDrawSurface3Impl_SetColorKey(IDirectDrawSurface3
*iface
,
858 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
859 TRACE("(%p)->(0x%08x,%p): Thunking to IDirectDrawSurface4\n", This
, Flags
, CKey
);
860 return IDirectDrawSurface4_SetColorKey(dds4_from_impl(This
), Flags
, CKey
);
863 static HRESULT WINAPI
864 IDirectDrawSurface4Impl_SetOverlayPosition(IDirectDrawSurface4
*iface
,
868 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
869 TRACE("(%p)->(%u,%u)\n", This
, X
, Y
);
870 return IDirectDrawSurface4_SetOverlayPosition(This
->parent
, X
, Y
);
873 static HRESULT WINAPI
874 IDirectDrawSurface3Impl_SetOverlayPosition(IDirectDrawSurface3
*iface
,
878 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
879 TRACE("(%p)->(%u,%u): Thunking to IDirectDrawSurface4\n", This
, X
, Y
);
880 return IDirectDrawSurface4_SetOverlayPosition(dds4_from_impl(This
), X
, Y
);
883 static HRESULT WINAPI
884 IDirectDrawSurface4Impl_SetPalette(IDirectDrawSurface4
*iface
,
885 IDirectDrawPalette
*Pal
)
887 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
888 TRACE("(%p)->(%p)\n", This
, Pal
);
889 return IDirectDrawSurface4_SetPalette(This
->parent
, Pal
);
892 static HRESULT WINAPI
893 IDirectDrawSurface3Impl_SetPalette(IDirectDrawSurface3
*iface
,
894 IDirectDrawPalette
*Pal
)
896 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
897 TRACE("(%p)->(%p): Thunking to IDirectDrawSurface4\n", This
, Pal
);
898 return IDirectDrawSurface4_SetPalette(dds4_from_impl(This
), Pal
);
901 static HRESULT WINAPI
902 IDirectDrawSurface4Impl_Unlock(IDirectDrawSurface4
*iface
,
905 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
906 TRACE("(%p)->(%p)\n", This
, pRect
);
907 return IDirectDrawSurface4_Unlock(This
->parent
, pRect
);
910 static HRESULT WINAPI
911 IDirectDrawSurface3Impl_Unlock(IDirectDrawSurface3
*iface
,
914 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
915 TRACE("(%p)->(%p): Thunking to IDirectDrawSurface4\n", This
, data
);
916 return IDirectDrawSurface4_Unlock(dds4_from_impl(This
), NULL
);
919 static HRESULT WINAPI
920 IDirectDrawSurface4Impl_UpdateOverlay(IDirectDrawSurface4
*iface
,
922 IDirectDrawSurface4
*DstSurface
,
927 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
928 IDirectDrawSurfaceImpl
*Dst
= impl_from_dds4(DstSurface
);
929 TRACE("(%p)->(%p,%p,%p,0x%08x,%p)\n", This
, SrcRect
, Dst
, DstRect
, Flags
, FX
);
930 return IDirectDrawSurface4_UpdateOverlay(This
->parent
, SrcRect
, Dst
? Dst
->parent
: NULL
,
934 static HRESULT WINAPI
935 IDirectDrawSurface3Impl_UpdateOverlay(IDirectDrawSurface3
*iface
,
937 IDirectDrawSurface3
*DstSurface
,
942 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
943 IDirectDrawSurfaceImpl
*Dst
= impl_from_dds3(DstSurface
);
944 TRACE("(%p)->(%p,%p,%p,0x%08x,%p): Thunking to IDirectDrawSurface4\n", This
, SrcRect
, Dst
, DstRect
, Flags
, FX
);
945 return IDirectDrawSurface4_UpdateOverlay(dds4_from_impl(This
), SrcRect
, dds4_from_impl(Dst
),
949 static HRESULT WINAPI
950 IDirectDrawSurface4Impl_UpdateOverlayDisplay(IDirectDrawSurface4
*iface
,
953 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
954 TRACE("(%p)->(0x%08x)\n", This
, Flags
);
955 return IDirectDrawSurface4_UpdateOverlayDisplay(This
->parent
, Flags
);
958 static HRESULT WINAPI
959 IDirectDrawSurface3Impl_UpdateOverlayDisplay(IDirectDrawSurface3
*iface
,
962 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
963 TRACE("(%p)->(0x%08x): Thunking to IDirectDrawSurface4\n", This
, Flags
);
964 return IDirectDrawSurface4_UpdateOverlayDisplay(dds4_from_impl(This
), Flags
);
967 static HRESULT WINAPI
968 IDirectDrawSurface4Impl_UpdateOverlayZOrder(IDirectDrawSurface4
*iface
,
970 IDirectDrawSurface4
*DDSRef
)
972 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
973 IDirectDrawSurfaceImpl
*Ref
= impl_from_dds4(DDSRef
);
974 TRACE("(%p)->(0x%08x,%p)\n", This
, Flags
, Ref
);
975 return IDirectDrawSurface4_UpdateOverlayZOrder(This
->parent
, Flags
, Ref
? Ref
->parent
: NULL
);
978 static HRESULT WINAPI
979 IDirectDrawSurface3Impl_UpdateOverlayZOrder(IDirectDrawSurface3
*iface
,
981 IDirectDrawSurface3
*DDSRef
)
983 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
984 IDirectDrawSurfaceImpl
*Ref
= impl_from_dds3(DDSRef
);
985 TRACE("(%p)->(0x%08x,%p): Thunking to IDirectDrawSurface4\n", This
, Flags
, Ref
);
986 return IDirectDrawSurface4_UpdateOverlayZOrder(dds4_from_impl(This
), Flags
, dds4_from_impl(Ref
));
989 static HRESULT WINAPI
990 IDirectDrawSurface4Impl_GetDDInterface(IDirectDrawSurface4
*iface
,
993 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
994 FIXME("(%p)->(%p)\n", This
, DD
);
995 /* This has to be implemented in ddrawex, DDraw's interface can't be used because it is pretty
996 * hard to tell which version of the DD interface is returned
1002 static HRESULT WINAPI
1003 IDirectDrawSurface3Impl_GetDDInterface(IDirectDrawSurface3
*iface
,
1006 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
1007 FIXME("(%p)->(%p)\n", This
, DD
);
1008 /* A thunk it pretty pointless because of the same reason relaying to ddraw.dll works badly
1014 static HRESULT WINAPI
1015 IDirectDrawSurface4Impl_PageLock(IDirectDrawSurface4
*iface
,
1018 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
1019 TRACE("(%p)->(%x)\n", iface
, Flags
);
1020 return IDirectDrawSurface4_PageLock(This
->parent
, Flags
);
1023 static HRESULT WINAPI
1024 IDirectDrawSurface3Impl_PageLock(IDirectDrawSurface3
*iface
,
1027 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
1028 TRACE("(%p)->(%x): Thunking to IDirectDrawSurface4\n", iface
, Flags
);
1029 return IDirectDrawSurface4_PageLock(dds4_from_impl(This
), Flags
);
1032 static HRESULT WINAPI
1033 IDirectDrawSurface4Impl_PageUnlock(IDirectDrawSurface4
*iface
,
1036 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
1037 TRACE("(%p)->(%x)\n", iface
, Flags
);
1038 return IDirectDrawSurface4_PageUnlock(This
->parent
, Flags
);
1041 static HRESULT WINAPI
1042 IDirectDrawSurface3Impl_PageUnlock(IDirectDrawSurface3
*iface
,
1045 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
1046 TRACE("(%p)->(%x): Thunking to IDirectDrawSurface4\n", iface
, Flags
);
1047 return IDirectDrawSurface4_PageUnlock(dds4_from_impl(This
), Flags
);
1050 static HRESULT WINAPI
1051 IDirectDrawSurface4Impl_SetSurfaceDesc(IDirectDrawSurface4
*iface
,
1052 DDSURFACEDESC2
*DDSD
,
1055 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
1056 TRACE("(%p)->(%p,0x%08x)\n", This
, DDSD
, Flags
);
1057 return IDirectDrawSurface4_SetSurfaceDesc(This
->parent
, DDSD
, Flags
);
1060 static HRESULT WINAPI
1061 IDirectDrawSurface3Impl_SetSurfaceDesc(IDirectDrawSurface3
*iface
,
1062 DDSURFACEDESC
*DDSD
,
1065 IDirectDrawSurfaceImpl
*This
= impl_from_dds3(iface
);
1066 DDSURFACEDESC2 ddsd
;
1067 TRACE("(%p)->(%p,0x%08x): Thunking to IDirectDrawSurface4\n", This
, DDSD
, Flags
);
1069 DDSD_to_DDSD2(DDSD
, &ddsd
);
1070 return IDirectDrawSurface4_SetSurfaceDesc(dds4_from_impl(This
), &ddsd
, Flags
);
1073 static HRESULT WINAPI
1074 IDirectDrawSurface4Impl_SetPrivateData(IDirectDrawSurface4
*iface
,
1080 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
1081 TRACE("(%p)->(%s,%p,%u,0x%08x)\n", iface
, debugstr_guid(tag
), Data
, Size
, Flags
);
1083 /* To completely avoid this we'd have to clone the private data API in ddrawex */
1084 if(IsEqualGUID(&IID_DDrawexPriv
, tag
)) {
1085 FIXME("Application uses ddrawex's private guid\n");
1088 return IDirectDrawSurface4_SetPrivateData(This
->parent
, tag
, Data
, Size
, Flags
);
1091 static HRESULT WINAPI
1092 IDirectDrawSurface4Impl_GetPrivateData(IDirectDrawSurface4
*iface
,
1097 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
1098 TRACE("(%p)->(%s,%p,%p)\n", iface
, debugstr_guid(tag
), Data
, Size
);
1100 /* To completely avoid this we'd have to clone the private data API in ddrawex */
1101 if(IsEqualGUID(&IID_DDrawexPriv
, tag
)) {
1102 FIXME("Application uses ddrawex's private guid\n");
1105 return IDirectDrawSurface4_GetPrivateData(This
->parent
, tag
, Data
, Size
);
1108 static HRESULT WINAPI
1109 IDirectDrawSurface4Impl_FreePrivateData(IDirectDrawSurface4
*iface
,
1112 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
1113 TRACE("(%p)->(%s)\n", iface
, debugstr_guid(tag
));
1115 /* To completely avoid this we'd have to clone the private data API in ddrawex */
1116 if(IsEqualGUID(&IID_DDrawexPriv
, tag
)) {
1117 FIXME("Application uses ddrawex's private guid\n");
1120 return IDirectDrawSurface4_FreePrivateData(This
->parent
, tag
);
1123 static HRESULT WINAPI
1124 IDirectDrawSurface4Impl_GetUniquenessValue(IDirectDrawSurface4
*iface
,
1127 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
1128 TRACE("(%p)->(%p)\n", This
, pValue
);
1129 return IDirectDrawSurface4_GetUniquenessValue(This
->parent
, pValue
);
1132 static HRESULT WINAPI
1133 IDirectDrawSurface4Impl_ChangeUniquenessValue(IDirectDrawSurface4
*iface
)
1135 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
1136 TRACE("(%p)\n", This
);
1137 return IDirectDrawSurface4_ChangeUniquenessValue(This
->parent
);
1140 const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl
=
1143 IDirectDrawSurface3Impl_QueryInterface
,
1144 IDirectDrawSurface3Impl_AddRef
,
1145 IDirectDrawSurface3Impl_Release
,
1146 /* IDirectDrawSurface */
1147 IDirectDrawSurface3Impl_AddAttachedSurface
,
1148 IDirectDrawSurface3Impl_AddOverlayDirtyRect
,
1149 IDirectDrawSurface3Impl_Blt
,
1150 IDirectDrawSurface3Impl_BltBatch
,
1151 IDirectDrawSurface3Impl_BltFast
,
1152 IDirectDrawSurface3Impl_DeleteAttachedSurface
,
1153 IDirectDrawSurface3Impl_EnumAttachedSurfaces
,
1154 IDirectDrawSurface3Impl_EnumOverlayZOrders
,
1155 IDirectDrawSurface3Impl_Flip
,
1156 IDirectDrawSurface3Impl_GetAttachedSurface
,
1157 IDirectDrawSurface3Impl_GetBltStatus
,
1158 IDirectDrawSurface3Impl_GetCaps
,
1159 IDirectDrawSurface3Impl_GetClipper
,
1160 IDirectDrawSurface3Impl_GetColorKey
,
1161 IDirectDrawSurface3Impl_GetDC
,
1162 IDirectDrawSurface3Impl_GetFlipStatus
,
1163 IDirectDrawSurface3Impl_GetOverlayPosition
,
1164 IDirectDrawSurface3Impl_GetPalette
,
1165 IDirectDrawSurface3Impl_GetPixelFormat
,
1166 IDirectDrawSurface3Impl_GetSurfaceDesc
,
1167 IDirectDrawSurface3Impl_Initialize
,
1168 IDirectDrawSurface3Impl_IsLost
,
1169 IDirectDrawSurface3Impl_Lock
,
1170 IDirectDrawSurface3Impl_ReleaseDC
,
1171 IDirectDrawSurface3Impl_Restore
,
1172 IDirectDrawSurface3Impl_SetClipper
,
1173 IDirectDrawSurface3Impl_SetColorKey
,
1174 IDirectDrawSurface3Impl_SetOverlayPosition
,
1175 IDirectDrawSurface3Impl_SetPalette
,
1176 IDirectDrawSurface3Impl_Unlock
,
1177 IDirectDrawSurface3Impl_UpdateOverlay
,
1178 IDirectDrawSurface3Impl_UpdateOverlayDisplay
,
1179 IDirectDrawSurface3Impl_UpdateOverlayZOrder
,
1180 /* IDirectDrawSurface 2 */
1181 IDirectDrawSurface3Impl_GetDDInterface
,
1182 IDirectDrawSurface3Impl_PageLock
,
1183 IDirectDrawSurface3Impl_PageUnlock
,
1184 /* IDirectDrawSurface 3 */
1185 IDirectDrawSurface3Impl_SetSurfaceDesc
1188 const IDirectDrawSurface4Vtbl IDirectDrawSurface4_Vtbl
=
1191 IDirectDrawSurface4Impl_QueryInterface
,
1192 IDirectDrawSurface4Impl_AddRef
,
1193 IDirectDrawSurface4Impl_Release
,
1194 /*** IDirectDrawSurface ***/
1195 IDirectDrawSurface4Impl_AddAttachedSurface
,
1196 IDirectDrawSurface4Impl_AddOverlayDirtyRect
,
1197 IDirectDrawSurface4Impl_Blt
,
1198 IDirectDrawSurface4Impl_BltBatch
,
1199 IDirectDrawSurface4Impl_BltFast
,
1200 IDirectDrawSurface4Impl_DeleteAttachedSurface
,
1201 IDirectDrawSurface4Impl_EnumAttachedSurfaces
,
1202 IDirectDrawSurface4Impl_EnumOverlayZOrders
,
1203 IDirectDrawSurface4Impl_Flip
,
1204 IDirectDrawSurface4Impl_GetAttachedSurface
,
1205 IDirectDrawSurface4Impl_GetBltStatus
,
1206 IDirectDrawSurface4Impl_GetCaps
,
1207 IDirectDrawSurface4Impl_GetClipper
,
1208 IDirectDrawSurface4Impl_GetColorKey
,
1209 IDirectDrawSurface4Impl_GetDC
,
1210 IDirectDrawSurface4Impl_GetFlipStatus
,
1211 IDirectDrawSurface4Impl_GetOverlayPosition
,
1212 IDirectDrawSurface4Impl_GetPalette
,
1213 IDirectDrawSurface4Impl_GetPixelFormat
,
1214 IDirectDrawSurface4Impl_GetSurfaceDesc
,
1215 IDirectDrawSurface4Impl_Initialize
,
1216 IDirectDrawSurface4Impl_IsLost
,
1217 IDirectDrawSurface4Impl_Lock
,
1218 IDirectDrawSurface4Impl_ReleaseDC
,
1219 IDirectDrawSurface4Impl_Restore
,
1220 IDirectDrawSurface4Impl_SetClipper
,
1221 IDirectDrawSurface4Impl_SetColorKey
,
1222 IDirectDrawSurface4Impl_SetOverlayPosition
,
1223 IDirectDrawSurface4Impl_SetPalette
,
1224 IDirectDrawSurface4Impl_Unlock
,
1225 IDirectDrawSurface4Impl_UpdateOverlay
,
1226 IDirectDrawSurface4Impl_UpdateOverlayDisplay
,
1227 IDirectDrawSurface4Impl_UpdateOverlayZOrder
,
1228 /*** IDirectDrawSurface2 ***/
1229 IDirectDrawSurface4Impl_GetDDInterface
,
1230 IDirectDrawSurface4Impl_PageLock
,
1231 IDirectDrawSurface4Impl_PageUnlock
,
1232 /*** IDirectDrawSurface3 ***/
1233 IDirectDrawSurface4Impl_SetSurfaceDesc
,
1234 /*** IDirectDrawSurface4 ***/
1235 IDirectDrawSurface4Impl_SetPrivateData
,
1236 IDirectDrawSurface4Impl_GetPrivateData
,
1237 IDirectDrawSurface4Impl_FreePrivateData
,
1238 IDirectDrawSurface4Impl_GetUniquenessValue
,
1239 IDirectDrawSurface4Impl_ChangeUniquenessValue
,
1244 * Given a surface from ddraw.dll it retrieves the pointer to the ddrawex.dll wrapper around it
1247 * inner: ddraw.dll surface to retrieve the outer surface from
1250 * The surface wrapper. If there is none yet, a new one is created
1252 IDirectDrawSurface4
*dds_get_outer(IDirectDrawSurface4
*inner
)
1254 IDirectDrawSurface4
*outer
= NULL
;
1255 DWORD size
= sizeof(outer
);
1257 if(!inner
) return NULL
;
1259 hr
= IDirectDrawSurface4_GetPrivateData(inner
,
1263 if(FAILED(hr
) || outer
== NULL
)
1265 IDirectDrawSurfaceImpl
*impl
;
1267 TRACE("Creating new ddrawex surface wrapper for surface %p\n", inner
);
1268 impl
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*impl
));
1270 impl
->IDirectDrawSurface3_Vtbl
= &IDirectDrawSurface3_Vtbl
;
1271 impl
->IDirectDrawSurface4_Vtbl
= &IDirectDrawSurface4_Vtbl
;
1272 IDirectDrawSurface4_AddRef(inner
);
1273 impl
->parent
= inner
;
1275 outer
= dds4_from_impl(impl
);
1277 hr
= IDirectDrawSurface4_SetPrivateData(inner
,
1284 ERR("IDirectDrawSurface4_SetPrivateData failed\n");
1291 IDirectDrawSurface4
*dds_get_inner(IDirectDrawSurface4
*outer
)
1293 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(outer
);
1294 if(This
== NULL
) return NULL
;
1295 return This
->parent
;
1298 HRESULT
prepare_permanent_dc(IDirectDrawSurface4
*iface
)
1300 IDirectDrawSurfaceImpl
*This
= impl_from_dds4(iface
);
1302 This
->permanent_dc
= TRUE
;
1304 hr
= IDirectDrawSurface4_GetDC(This
->parent
, &This
->hdc
);
1305 if(FAILED(hr
)) return hr
;
1306 hr
= IDirectDrawSurface4_ReleaseDC(This
->parent
, This
->hdc
);