Alexandre Julliard | d6c0f9f | 2001-01-04 22:44:55 +0000 | [diff] [blame^] | 1 | /* DirectDraw/Direct3D Z-Buffer stand in |
| 2 | * |
| 3 | * Copyright 2000 TransGaming Technologies Inc. |
| 4 | * |
| 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. |
| 9 | */ |
| 10 | |
| 11 | #include "config.h" |
| 12 | |
| 13 | #include <stdlib.h> |
| 14 | #include <assert.h> |
| 15 | |
| 16 | #include <ddraw.h> |
| 17 | #include <d3d.h> |
| 18 | |
| 19 | #include "debugtools.h" |
| 20 | |
| 21 | #include "ddcomimpl.h" |
| 22 | #include "ddraw_private.h" |
| 23 | #include "dsurface/main.h" |
| 24 | #include "dsurface/fakezbuffer.h" |
| 25 | |
| 26 | DEFAULT_DEBUG_CHANNEL(ddraw); |
| 27 | |
| 28 | static ICOM_VTABLE(IDirectDrawSurface7) FakeZBuffer_IDirectDrawSurface7_VTable; |
| 29 | |
| 30 | HRESULT FakeZBuffer_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl *This, |
| 31 | IDirectDrawImpl *pDD, |
| 32 | const DDSURFACEDESC2 *pDDSD) |
| 33 | { |
| 34 | HRESULT hr; |
| 35 | |
| 36 | assert(pDDSD->ddsCaps.dwCaps & DDSCAPS_ZBUFFER); |
| 37 | |
| 38 | hr = Main_DirectDrawSurface_Construct(This, pDD, pDDSD); |
| 39 | if (FAILED(hr)) return hr; |
| 40 | |
| 41 | ICOM_INIT_INTERFACE(This, IDirectDrawSurface7, |
| 42 | FakeZBuffer_IDirectDrawSurface7_VTable); |
| 43 | |
| 44 | This->final_release = FakeZBuffer_DirectDrawSurface_final_release; |
| 45 | This->duplicate_surface = FakeZBuffer_DirectDrawSurface_duplicate_surface; |
| 46 | |
| 47 | return DD_OK; |
| 48 | } |
| 49 | |
| 50 | /* Not an API */ |
| 51 | HRESULT FakeZBuffer_DirectDrawSurface_Create(IDirectDrawImpl* pDD, |
| 52 | const DDSURFACEDESC2* pDDSD, |
| 53 | LPDIRECTDRAWSURFACE7* ppSurf, |
| 54 | IUnknown* pUnkOuter) |
| 55 | { |
| 56 | IDirectDrawSurfaceImpl* This; |
| 57 | HRESULT hr; |
| 58 | assert(pUnkOuter == NULL); |
| 59 | |
| 60 | This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, |
| 61 | sizeof(*This) |
| 62 | + sizeof(FakeZBuffer_DirectDrawSurfaceImpl)); |
| 63 | if (This == NULL) return E_OUTOFMEMORY; |
| 64 | |
| 65 | This->private = (FakeZBuffer_DirectDrawSurfaceImpl*)(This+1); |
| 66 | |
| 67 | hr = FakeZBuffer_DirectDrawSurface_Construct(This, pDD, pDDSD); |
| 68 | if (FAILED(hr)) |
| 69 | HeapFree(GetProcessHeap(), 0, This); |
| 70 | else |
| 71 | *ppSurf = ICOM_INTERFACE(This, IDirectDrawSurface7); |
| 72 | |
| 73 | return hr; |
| 74 | } |
| 75 | |
| 76 | void |
| 77 | FakeZBuffer_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This) |
| 78 | { |
| 79 | return Main_DirectDrawSurface_final_release(This); |
| 80 | } |
| 81 | |
| 82 | HRESULT |
| 83 | FakeZBuffer_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This, |
| 84 | LPDIRECTDRAWSURFACE7* ppDup) |
| 85 | { |
| 86 | return FakeZBuffer_DirectDrawSurface_Create(This->ddraw_owner, |
| 87 | &This->surface_desc, ppDup, |
| 88 | NULL); |
| 89 | } |
| 90 | |
| 91 | /* put your breakpoint/abort call here */ |
| 92 | static HRESULT cant_do_that(const char *s) |
| 93 | { |
| 94 | FIXME("attempt to %s fake z-buffer\n", s); |
| 95 | return DDERR_UNSUPPORTED; |
| 96 | } |
| 97 | |
| 98 | HRESULT WINAPI |
| 99 | FakeZBuffer_DirectDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rdst, |
| 100 | LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, |
| 101 | DWORD dwFlags, LPDDBLTFX lpbltfx) |
| 102 | { |
| 103 | return cant_do_that("blt to a"); |
| 104 | } |
| 105 | |
| 106 | HRESULT WINAPI |
| 107 | FakeZBuffer_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx, |
| 108 | DWORD dsty, LPDIRECTDRAWSURFACE7 src, |
| 109 | LPRECT rsrc, DWORD trans) |
| 110 | { |
| 111 | return cant_do_that("bltfast to a"); |
| 112 | } |
| 113 | |
| 114 | HRESULT WINAPI |
| 115 | FakeZBuffer_DirectDrawSurface_GetDC(LPDIRECTDRAWSURFACE7 iface, HDC *phDC) |
| 116 | { |
| 117 | return cant_do_that("get a DC for a"); |
| 118 | } |
| 119 | |
| 120 | HRESULT WINAPI |
| 121 | FakeZBuffer_DirectDrawSurface_ReleaseDC(LPDIRECTDRAWSURFACE7 iface, HDC hDC) |
| 122 | { |
| 123 | return cant_do_that("release a DC for a"); |
| 124 | } |
| 125 | |
| 126 | HRESULT WINAPI |
| 127 | FakeZBuffer_DirectDrawSurface_Restore(LPDIRECTDRAWSURFACE7 iface) |
| 128 | { |
| 129 | return DD_OK; |
| 130 | } |
| 131 | |
| 132 | HRESULT WINAPI |
| 133 | FakeZBuffer_DirectDrawSurface_SetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface, |
| 134 | LPDDSURFACEDESC2 pDDSD, |
| 135 | DWORD dwFlags) |
| 136 | { |
| 137 | /* XXX */ |
| 138 | abort(); |
| 139 | return E_FAIL; |
| 140 | } |
| 141 | |
| 142 | |
| 143 | static ICOM_VTABLE(IDirectDrawSurface7) FakeZBuffer_IDirectDrawSurface7_VTable= |
| 144 | { |
| 145 | Main_DirectDrawSurface_QueryInterface, |
| 146 | Main_DirectDrawSurface_AddRef, |
| 147 | Main_DirectDrawSurface_Release, |
| 148 | Main_DirectDrawSurface_AddAttachedSurface, |
| 149 | Main_DirectDrawSurface_AddOverlayDirtyRect, |
| 150 | FakeZBuffer_DirectDrawSurface_Blt, |
| 151 | Main_DirectDrawSurface_BltBatch, |
| 152 | FakeZBuffer_DirectDrawSurface_BltFast, |
| 153 | Main_DirectDrawSurface_DeleteAttachedSurface, |
| 154 | Main_DirectDrawSurface_EnumAttachedSurfaces, |
| 155 | Main_DirectDrawSurface_EnumOverlayZOrders, |
| 156 | Main_DirectDrawSurface_Flip, |
| 157 | Main_DirectDrawSurface_GetAttachedSurface, |
| 158 | Main_DirectDrawSurface_GetBltStatus, |
| 159 | Main_DirectDrawSurface_GetCaps, |
| 160 | Main_DirectDrawSurface_GetClipper, |
| 161 | Main_DirectDrawSurface_GetColorKey, |
| 162 | FakeZBuffer_DirectDrawSurface_GetDC, |
| 163 | Main_DirectDrawSurface_GetFlipStatus, |
| 164 | Main_DirectDrawSurface_GetOverlayPosition, |
| 165 | Main_DirectDrawSurface_GetPalette, |
| 166 | Main_DirectDrawSurface_GetPixelFormat, |
| 167 | Main_DirectDrawSurface_GetSurfaceDesc, |
| 168 | Main_DirectDrawSurface_Initialize, |
| 169 | Main_DirectDrawSurface_IsLost, |
| 170 | Main_DirectDrawSurface_Lock, |
| 171 | FakeZBuffer_DirectDrawSurface_ReleaseDC, |
| 172 | FakeZBuffer_DirectDrawSurface_Restore, |
| 173 | Main_DirectDrawSurface_SetClipper, |
| 174 | Main_DirectDrawSurface_SetColorKey, |
| 175 | Main_DirectDrawSurface_SetOverlayPosition, |
| 176 | Main_DirectDrawSurface_SetPalette, |
| 177 | Main_DirectDrawSurface_Unlock, |
| 178 | Main_DirectDrawSurface_UpdateOverlay, |
| 179 | Main_DirectDrawSurface_UpdateOverlayDisplay, |
| 180 | Main_DirectDrawSurface_UpdateOverlayZOrder, |
| 181 | Main_DirectDrawSurface_GetDDInterface, |
| 182 | Main_DirectDrawSurface_PageLock, |
| 183 | Main_DirectDrawSurface_PageUnlock, |
| 184 | FakeZBuffer_DirectDrawSurface_SetSurfaceDesc, |
| 185 | Main_DirectDrawSurface_SetPrivateData, |
| 186 | Main_DirectDrawSurface_GetPrivateData, |
| 187 | Main_DirectDrawSurface_FreePrivateData, |
| 188 | Main_DirectDrawSurface_GetUniquenessValue, |
| 189 | Main_DirectDrawSurface_ChangeUniquenessValue, |
| 190 | Main_DirectDrawSurface_SetPriority, |
| 191 | Main_DirectDrawSurface_GetPriority, |
| 192 | Main_DirectDrawSurface_SetLOD, |
| 193 | Main_DirectDrawSurface_GetLOD |
| 194 | }; |