ntdll/tests: Add acceptable status codes for Win7.
[wine/wine-gecko.git] / dlls / d3d8 / volume.c
blob4a7066c6f772cdcef9b6bae220e4c645096d7763
1 /*
2 * IDirect3DVolume8 implementation
4 * Copyright 2005 Oliver Stieber
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "d3d8_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
26 /* IDirect3DVolume8 IUnknown parts follow: */
27 static HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface, REFIID riid, LPVOID *ppobj) {
28 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
30 if (IsEqualGUID(riid, &IID_IUnknown)
31 || IsEqualGUID(riid, &IID_IDirect3DVolume8)) {
32 IUnknown_AddRef(iface);
33 *ppobj = This;
34 return S_OK;
37 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
38 *ppobj = NULL;
39 return E_NOINTERFACE;
42 static ULONG WINAPI IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface) {
43 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
45 TRACE("(%p)\n", This);
47 if (This->forwardReference) {
48 /* Forward to the containerParent */
49 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
50 return IUnknown_AddRef(This->forwardReference);
51 } else {
52 /* No container, handle our own refcounting */
53 ULONG ref = InterlockedIncrement(&This->ref);
54 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
55 return ref;
59 static ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
60 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
62 TRACE("(%p)\n", This);
64 if (This->forwardReference) {
65 /* Forward to the containerParent */
66 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
67 return IUnknown_Release(This->forwardReference);
69 else {
70 /* No container, handle our own refcounting */
71 ULONG ref = InterlockedDecrement(&This->ref);
72 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
74 if (ref == 0) {
75 EnterCriticalSection(&d3d8_cs);
76 IWineD3DVolume_Release(This->wineD3DVolume);
77 LeaveCriticalSection(&d3d8_cs);
78 HeapFree(GetProcessHeap(), 0, This);
81 return ref;
85 /* IDirect3DVolume8 Interface follow: */
86 static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, IDirect3DDevice8 **ppDevice) {
87 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
88 IWineD3DDevice *myDevice = NULL;
90 EnterCriticalSection(&d3d8_cs);
91 IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
92 IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
93 IWineD3DDevice_Release(myDevice);
94 LeaveCriticalSection(&d3d8_cs);
95 return D3D_OK;
98 static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
99 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
100 HRESULT hr;
101 TRACE("(%p) Relay\n", This);
103 EnterCriticalSection(&d3d8_cs);
104 hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
105 LeaveCriticalSection(&d3d8_cs);
106 return hr;
109 static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
110 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
111 HRESULT hr;
112 TRACE("(%p) Relay\n", This);
114 EnterCriticalSection(&d3d8_cs);
115 hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
116 LeaveCriticalSection(&d3d8_cs);
117 return hr;
120 static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid) {
121 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
122 HRESULT hr;
123 TRACE("(%p) Relay\n", This);
125 EnterCriticalSection(&d3d8_cs);
126 hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
127 LeaveCriticalSection(&d3d8_cs);
128 return hr;
131 static HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void **ppContainer) {
132 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
133 HRESULT res;
135 TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
137 if (!This->container) return E_NOINTERFACE;
139 if (!ppContainer) {
140 ERR("Called without a valid ppContainer.\n");
143 res = IUnknown_QueryInterface(This->container, riid, ppContainer);
145 TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
147 return res;
150 static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC *pDesc) {
151 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
152 HRESULT hr;
153 WINED3DVOLUME_DESC wined3ddesc;
155 TRACE("(%p) Relay\n", This);
157 EnterCriticalSection(&d3d8_cs);
158 hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
159 LeaveCriticalSection(&d3d8_cs);
161 if (SUCCEEDED(hr))
163 pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
164 pDesc->Type = wined3ddesc.Type;
165 pDesc->Usage = wined3ddesc.Usage;
166 pDesc->Pool = wined3ddesc.Pool;
167 pDesc->Size = wined3ddesc.Size;
168 pDesc->Width = wined3ddesc.Width;
169 pDesc->Height = wined3ddesc.Height;
170 pDesc->Depth = wined3ddesc.Depth;
173 return hr;
176 static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
177 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
178 HRESULT hr;
179 TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
181 EnterCriticalSection(&d3d8_cs);
182 hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
183 LeaveCriticalSection(&d3d8_cs);
184 return hr;
187 static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
188 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
189 HRESULT hr;
190 TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
192 EnterCriticalSection(&d3d8_cs);
193 hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
194 LeaveCriticalSection(&d3d8_cs);
195 return hr;
198 const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl =
200 /* IUnknown */
201 IDirect3DVolume8Impl_QueryInterface,
202 IDirect3DVolume8Impl_AddRef,
203 IDirect3DVolume8Impl_Release,
204 /* IDirect3DVolume8 */
205 IDirect3DVolume8Impl_GetDevice,
206 IDirect3DVolume8Impl_SetPrivateData,
207 IDirect3DVolume8Impl_GetPrivateData,
208 IDirect3DVolume8Impl_FreePrivateData,
209 IDirect3DVolume8Impl_GetContainer,
210 IDirect3DVolume8Impl_GetDesc,
211 IDirect3DVolume8Impl_LockBox,
212 IDirect3DVolume8Impl_UnlockBox
215 ULONG WINAPI D3D8CB_DestroyVolume(IWineD3DVolume *pVolume) {
216 IDirect3DVolume8Impl* volumeParent;
218 IWineD3DVolume_GetParent(pVolume, (IUnknown **) &volumeParent);
219 /* GetParent's AddRef was forwarded to an object in destruction.
220 * Releasing it here again would cause an endless recursion. */
221 volumeParent->forwardReference = NULL;
222 return IDirect3DVolume8_Release((IDirect3DVolume8*) volumeParent);