Fixed header dependencies to be fully compatible with the Windows
[wine/multimedia.git] / dlls / ddraw / dsurface / fakezbuffer.c
blobcf858c83aa844b46383ef7f122916d89e7458204
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
25 #include "config.h"
27 #include <stdarg.h>
28 #include <stdlib.h>
29 #include <assert.h>
31 #define NONAMELESSUNION
32 #define NONAMELESSSTRUCT
33 #include "windef.h"
34 #include "winbase.h"
35 #include "wingdi.h"
36 #include "ddraw.h"
37 #include "d3d.h"
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,
52 IDirectDrawImpl *pDD,
53 const DDSURFACEDESC2 *pDDSD)
55 HRESULT hr;
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;
68 return DD_OK;
71 /* Not an API */
72 HRESULT FakeZBuffer_DirectDrawSurface_Create(IDirectDrawImpl* pDD,
73 const DDSURFACEDESC2* pDDSD,
74 LPDIRECTDRAWSURFACE7* ppSurf,
75 IUnknown* pUnkOuter)
77 IDirectDrawSurfaceImpl* This;
78 HRESULT hr;
79 assert(pUnkOuter == NULL);
81 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
82 sizeof(*This)
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);
89 if (FAILED(hr))
90 HeapFree(GetProcessHeap(), 0, This);
91 else
92 *ppSurf = ICOM_INTERFACE(This, IDirectDrawSurface7);
94 return hr;
97 void
98 FakeZBuffer_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This)
100 Main_DirectDrawSurface_final_release(This);
103 HRESULT
104 FakeZBuffer_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
105 LPDIRECTDRAWSURFACE7* ppDup)
107 return FakeZBuffer_DirectDrawSurface_Create(This->ddraw_owner,
108 &This->surface_desc, ppDup,
109 NULL);
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;
119 HRESULT WINAPI
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);
130 TRACE("\tflags: ");
131 DDRAW_dump_DDBLT(dwFlags);
132 if (dwFlags & DDBLT_DDFX) {
133 TRACE("\tblitfx: ");
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) {
141 D3DRECT rect;
142 if (rdst) {
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,
150 D3DCLEAR_ZBUFFER,
151 0x00000000,
152 ((double) lpbltfx->u5.dwFillDepth) / 4294967295.0,
153 0x00000000);
154 return DD_OK;
158 return cant_do_that("blt to a");
161 HRESULT WINAPI
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
172 FIXME("\ttrans:");
173 if (FIXME_ON(ddraw))
174 DDRAW_dump_DDBLTFAST(trans);
175 if (rsrc)
176 FIXME("\tsrcrect: %ldx%ld-%ldx%ld\n",rsrc->left,rsrc->top,rsrc->right,rsrc->bottom);
177 else
178 FIXME(" srcrect: NULL\n");
181 return cant_do_that("bltfast to a");
184 HRESULT WINAPI
185 FakeZBuffer_DirectDrawSurface_GetDC(LPDIRECTDRAWSURFACE7 iface, HDC *phDC)
187 return cant_do_that("get a DC for a");
190 HRESULT WINAPI
191 FakeZBuffer_DirectDrawSurface_ReleaseDC(LPDIRECTDRAWSURFACE7 iface, HDC hDC)
193 return cant_do_that("release a DC for a");
196 HRESULT WINAPI
197 FakeZBuffer_DirectDrawSurface_Restore(LPDIRECTDRAWSURFACE7 iface)
199 return DD_OK;
202 HRESULT WINAPI
203 FakeZBuffer_DirectDrawSurface_SetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface,
204 LPDDSURFACEDESC2 pDDSD,
205 DWORD dwFlags)
207 /* XXX */
208 abort();
209 return E_FAIL;
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