1 /* DirectDraw/Direct3D Z-Buffer stand in
3 * Copyright 2000 TransGaming Technologies Inc.
5 * This class provides a DirectDrawSurface implementation that represents
6 * a Z-Buffer surface. However it does not store an image and does not
7 * support Lock/Unlock or GetDC. It is merely a placeholder required by the
8 * Direct3D architecture.
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #define NONAMELESSUNION
32 #define NONAMELESSSTRUCT
39 #include "wine/debug.h"
41 #include "ddcomimpl.h"
42 #include "ddraw_private.h"
43 #include "d3d_private.h"
44 #include "dsurface/main.h"
45 #include "dsurface/fakezbuffer.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(ddraw
);
49 static ICOM_VTABLE(IDirectDrawSurface7
) FakeZBuffer_IDirectDrawSurface7_VTable
;
51 HRESULT
FakeZBuffer_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl
*This
,
53 const DDSURFACEDESC2
*pDDSD
)
57 assert(pDDSD
->ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
);
59 hr
= Main_DirectDrawSurface_Construct(This
, pDD
, pDDSD
);
60 if (FAILED(hr
)) return hr
;
62 ICOM_INIT_INTERFACE(This
, IDirectDrawSurface7
,
63 FakeZBuffer_IDirectDrawSurface7_VTable
);
65 This
->final_release
= FakeZBuffer_DirectDrawSurface_final_release
;
66 This
->duplicate_surface
= FakeZBuffer_DirectDrawSurface_duplicate_surface
;
72 HRESULT
FakeZBuffer_DirectDrawSurface_Create(IDirectDrawImpl
* pDD
,
73 const DDSURFACEDESC2
* pDDSD
,
74 LPDIRECTDRAWSURFACE7
* ppSurf
,
77 IDirectDrawSurfaceImpl
* This
;
79 assert(pUnkOuter
== NULL
);
81 This
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
83 + sizeof(FakeZBuffer_DirectDrawSurfaceImpl
));
84 if (This
== NULL
) return E_OUTOFMEMORY
;
86 This
->private = (FakeZBuffer_DirectDrawSurfaceImpl
*)(This
+1);
88 hr
= FakeZBuffer_DirectDrawSurface_Construct(This
, pDD
, pDDSD
);
90 HeapFree(GetProcessHeap(), 0, This
);
92 *ppSurf
= ICOM_INTERFACE(This
, IDirectDrawSurface7
);
98 FakeZBuffer_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl
* This
)
100 Main_DirectDrawSurface_final_release(This
);
104 FakeZBuffer_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl
* This
,
105 LPDIRECTDRAWSURFACE7
* ppDup
)
107 return FakeZBuffer_DirectDrawSurface_Create(This
->ddraw_owner
,
108 &This
->surface_desc
, ppDup
,
112 /* put your breakpoint/abort call here */
113 static HRESULT
cant_do_that(const char *s
)
115 FIXME("attempt to %s fake z-buffer\n", s
);
116 return DDERR_UNSUPPORTED
;
120 FakeZBuffer_DirectDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface
, LPRECT rdst
,
121 LPDIRECTDRAWSURFACE7 src
, LPRECT rsrc
,
122 DWORD dwFlags
, LPDDBLTFX lpbltfx
)
124 ICOM_THIS(IDirectDrawSurfaceImpl
,iface
);
126 if (TRACE_ON(ddraw
)) {
127 TRACE("(%p)->(%p,%p,%p,%08lx,%p)\n", This
,rdst
,src
,rsrc
,dwFlags
,lpbltfx
);
128 if (rdst
) TRACE("\tdestrect :%ldx%ld-%ldx%ld\n",rdst
->left
,rdst
->top
,rdst
->right
,rdst
->bottom
);
129 if (rsrc
) TRACE("\tsrcrect :%ldx%ld-%ldx%ld\n",rsrc
->left
,rsrc
->top
,rsrc
->right
,rsrc
->bottom
);
131 DDRAW_dump_DDBLT(dwFlags
);
132 if (dwFlags
& DDBLT_DDFX
) {
134 DDRAW_dump_DDBLTFX(lpbltfx
->dwDDFX
);
138 /* We only support the BLT with DEPTH_FILL for now */
139 if ((dwFlags
& DDBLT_DEPTHFILL
) && (This
->ddraw_owner
->d3d_private
!= NULL
)) {
140 if (This
->ddraw_owner
->current_device
!= NULL
) {
143 rect
.u1
.x1
= rdst
->left
;
144 rect
.u2
.y1
= rdst
->top
;
145 rect
.u3
.x2
= rdst
->right
;
146 rect
.u4
.y2
= rdst
->bottom
;
148 This
->ddraw_owner
->current_device
->clear(This
->ddraw_owner
->current_device
,
149 (rdst
== NULL
? 0 : 1), &rect
,
152 ((double) lpbltfx
->u5
.dwFillDepth
) / 4294967295.0,
158 return cant_do_that("blt to a");
162 FakeZBuffer_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface
, DWORD dstx
,
163 DWORD dsty
, LPDIRECTDRAWSURFACE7 src
,
164 LPRECT rsrc
, DWORD trans
)
166 ICOM_THIS(IDirectDrawSurfaceImpl
,iface
);
168 if (TRACE_ON(ddraw
)) {
169 FIXME("(%p)->(%ld,%ld,%p,%p,%08lx)\n",
170 This
,dstx
,dsty
,src
,rsrc
,trans
174 DDRAW_dump_DDBLTFAST(trans
);
176 FIXME("\tsrcrect: %ldx%ld-%ldx%ld\n",rsrc
->left
,rsrc
->top
,rsrc
->right
,rsrc
->bottom
);
178 FIXME(" srcrect: NULL\n");
181 return cant_do_that("bltfast to a");
185 FakeZBuffer_DirectDrawSurface_GetDC(LPDIRECTDRAWSURFACE7 iface
, HDC
*phDC
)
187 return cant_do_that("get a DC for a");
191 FakeZBuffer_DirectDrawSurface_ReleaseDC(LPDIRECTDRAWSURFACE7 iface
, HDC hDC
)
193 return cant_do_that("release a DC for a");
197 FakeZBuffer_DirectDrawSurface_Restore(LPDIRECTDRAWSURFACE7 iface
)
203 FakeZBuffer_DirectDrawSurface_SetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface
,
204 LPDDSURFACEDESC2 pDDSD
,
213 static ICOM_VTABLE(IDirectDrawSurface7
) FakeZBuffer_IDirectDrawSurface7_VTable
=
215 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
216 Main_DirectDrawSurface_QueryInterface
,
217 Main_DirectDrawSurface_AddRef
,
218 Main_DirectDrawSurface_Release
,
219 Main_DirectDrawSurface_AddAttachedSurface
,
220 Main_DirectDrawSurface_AddOverlayDirtyRect
,
221 FakeZBuffer_DirectDrawSurface_Blt
,
222 Main_DirectDrawSurface_BltBatch
,
223 FakeZBuffer_DirectDrawSurface_BltFast
,
224 Main_DirectDrawSurface_DeleteAttachedSurface
,
225 Main_DirectDrawSurface_EnumAttachedSurfaces
,
226 Main_DirectDrawSurface_EnumOverlayZOrders
,
227 Main_DirectDrawSurface_Flip
,
228 Main_DirectDrawSurface_GetAttachedSurface
,
229 Main_DirectDrawSurface_GetBltStatus
,
230 Main_DirectDrawSurface_GetCaps
,
231 Main_DirectDrawSurface_GetClipper
,
232 Main_DirectDrawSurface_GetColorKey
,
233 FakeZBuffer_DirectDrawSurface_GetDC
,
234 Main_DirectDrawSurface_GetFlipStatus
,
235 Main_DirectDrawSurface_GetOverlayPosition
,
236 Main_DirectDrawSurface_GetPalette
,
237 Main_DirectDrawSurface_GetPixelFormat
,
238 Main_DirectDrawSurface_GetSurfaceDesc
,
239 Main_DirectDrawSurface_Initialize
,
240 Main_DirectDrawSurface_IsLost
,
241 Main_DirectDrawSurface_Lock
,
242 FakeZBuffer_DirectDrawSurface_ReleaseDC
,
243 FakeZBuffer_DirectDrawSurface_Restore
,
244 Main_DirectDrawSurface_SetClipper
,
245 Main_DirectDrawSurface_SetColorKey
,
246 Main_DirectDrawSurface_SetOverlayPosition
,
247 Main_DirectDrawSurface_SetPalette
,
248 Main_DirectDrawSurface_Unlock
,
249 Main_DirectDrawSurface_UpdateOverlay
,
250 Main_DirectDrawSurface_UpdateOverlayDisplay
,
251 Main_DirectDrawSurface_UpdateOverlayZOrder
,
252 Main_DirectDrawSurface_GetDDInterface
,
253 Main_DirectDrawSurface_PageLock
,
254 Main_DirectDrawSurface_PageUnlock
,
255 FakeZBuffer_DirectDrawSurface_SetSurfaceDesc
,
256 Main_DirectDrawSurface_SetPrivateData
,
257 Main_DirectDrawSurface_GetPrivateData
,
258 Main_DirectDrawSurface_FreePrivateData
,
259 Main_DirectDrawSurface_GetUniquenessValue
,
260 Main_DirectDrawSurface_ChangeUniquenessValue
,
261 Main_DirectDrawSurface_SetPriority
,
262 Main_DirectDrawSurface_GetPriority
,
263 Main_DirectDrawSurface_SetLOD
,
264 Main_DirectDrawSurface_GetLOD