wininet: Support the Cache-Control max-age directive for setting url cache entry...
[wine/testsucceed.git] / dlls / d3d8 / volume.c
blob3fd67da99cacc263841219b4f56c89e7451383f9
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 static inline IDirect3DVolume8Impl *impl_from_IDirect3DVolume8(IDirect3DVolume8 *iface)
28 return CONTAINING_RECORD(iface, IDirect3DVolume8Impl, IDirect3DVolume8_iface);
31 static HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(IDirect3DVolume8 *iface, REFIID riid,
32 void **ppobj)
34 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
36 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
38 if (IsEqualGUID(riid, &IID_IUnknown)
39 || IsEqualGUID(riid, &IID_IDirect3DVolume8)) {
40 IUnknown_AddRef(iface);
41 *ppobj = This;
42 return S_OK;
45 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
46 *ppobj = NULL;
47 return E_NOINTERFACE;
50 static ULONG WINAPI IDirect3DVolume8Impl_AddRef(IDirect3DVolume8 *iface)
52 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
54 TRACE("iface %p.\n", iface);
56 if (This->forwardReference) {
57 /* Forward to the containerParent */
58 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
59 return IUnknown_AddRef(This->forwardReference);
60 } else {
61 /* No container, handle our own refcounting */
62 ULONG ref = InterlockedIncrement(&This->ref);
64 TRACE("%p increasing refcount to %u.\n", iface, ref);
66 if (ref == 1)
68 wined3d_mutex_lock();
69 IWineD3DVolume_AddRef(This->wineD3DVolume);
70 wined3d_mutex_unlock();
73 return ref;
77 static ULONG WINAPI IDirect3DVolume8Impl_Release(IDirect3DVolume8 *iface)
79 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
81 TRACE("iface %p.\n", iface);
83 if (This->forwardReference) {
84 /* Forward to the containerParent */
85 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
86 return IUnknown_Release(This->forwardReference);
88 else {
89 /* No container, handle our own refcounting */
90 ULONG ref = InterlockedDecrement(&This->ref);
92 TRACE("%p decreasing refcount to %u.\n", iface, ref);
94 if (ref == 0) {
95 wined3d_mutex_lock();
96 IWineD3DVolume_Release(This->wineD3DVolume);
97 wined3d_mutex_unlock();
100 return ref;
104 static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(IDirect3DVolume8 *iface,
105 IDirect3DDevice8 **device)
107 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
108 IDirect3DResource8 *resource;
109 HRESULT hr;
111 TRACE("iface %p, device %p.\n", iface, device);
113 hr = IUnknown_QueryInterface(This->forwardReference, &IID_IDirect3DResource8, (void **)&resource);
114 if (SUCCEEDED(hr))
116 hr = IDirect3DResource8_GetDevice(resource, device);
117 IDirect3DResource8_Release(resource);
119 TRACE("Returning device %p.\n", *device);
122 return hr;
125 static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(IDirect3DVolume8 *iface, REFGUID refguid,
126 const void *pData, DWORD SizeOfData, DWORD Flags)
128 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
129 HRESULT hr;
131 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
132 iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
134 wined3d_mutex_lock();
135 hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
136 wined3d_mutex_unlock();
138 return hr;
141 static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(IDirect3DVolume8 *iface, REFGUID refguid,
142 void *pData, DWORD *pSizeOfData)
144 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
145 HRESULT hr;
147 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
148 iface, debugstr_guid(refguid), pData, pSizeOfData);
150 wined3d_mutex_lock();
151 hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
152 wined3d_mutex_unlock();
154 return hr;
157 static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(IDirect3DVolume8 *iface, REFGUID refguid)
159 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
160 HRESULT hr;
162 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
164 wined3d_mutex_lock();
165 hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
166 wined3d_mutex_unlock();
168 return hr;
171 static HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(IDirect3DVolume8 *iface, REFIID riid,
172 void **ppContainer)
174 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
175 HRESULT res;
177 TRACE("iface %p, riid %s, container %p.\n",
178 iface, debugstr_guid(riid), ppContainer);
180 if (!This->container) return E_NOINTERFACE;
182 res = IUnknown_QueryInterface(This->container, riid, ppContainer);
184 TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
186 return res;
189 static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(IDirect3DVolume8 *iface, D3DVOLUME_DESC *pDesc)
191 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
192 WINED3DVOLUME_DESC wined3ddesc;
194 TRACE("iface %p, desc %p.\n", iface, pDesc);
196 wined3d_mutex_lock();
197 IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
198 wined3d_mutex_unlock();
200 pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
201 pDesc->Type = wined3ddesc.Type;
202 pDesc->Usage = wined3ddesc.Usage;
203 pDesc->Pool = wined3ddesc.Pool;
204 pDesc->Size = wined3ddesc.Size;
205 pDesc->Width = wined3ddesc.Width;
206 pDesc->Height = wined3ddesc.Height;
207 pDesc->Depth = wined3ddesc.Depth;
209 return D3D_OK;
212 static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(IDirect3DVolume8 *iface,
213 D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox, DWORD Flags)
215 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
216 HRESULT hr;
218 TRACE("iface %p, locked_box %p, box %p, flags %#x.\n",
219 iface, pLockedVolume, pBox, Flags);
221 wined3d_mutex_lock();
222 hr = IWineD3DVolume_Map(This->wineD3DVolume, (WINED3DLOCKED_BOX *)pLockedVolume,
223 (const WINED3DBOX *)pBox, Flags);
224 wined3d_mutex_unlock();
226 return hr;
229 static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(IDirect3DVolume8 *iface)
231 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
232 HRESULT hr;
234 TRACE("iface %p.\n", iface);
236 wined3d_mutex_lock();
237 hr = IWineD3DVolume_Unmap(This->wineD3DVolume);
238 wined3d_mutex_unlock();
240 return hr;
243 static const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl =
245 /* IUnknown */
246 IDirect3DVolume8Impl_QueryInterface,
247 IDirect3DVolume8Impl_AddRef,
248 IDirect3DVolume8Impl_Release,
249 /* IDirect3DVolume8 */
250 IDirect3DVolume8Impl_GetDevice,
251 IDirect3DVolume8Impl_SetPrivateData,
252 IDirect3DVolume8Impl_GetPrivateData,
253 IDirect3DVolume8Impl_FreePrivateData,
254 IDirect3DVolume8Impl_GetContainer,
255 IDirect3DVolume8Impl_GetDesc,
256 IDirect3DVolume8Impl_LockBox,
257 IDirect3DVolume8Impl_UnlockBox
260 static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
262 HeapFree(GetProcessHeap(), 0, parent);
265 static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops =
267 volume_wined3d_object_destroyed,
270 HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device, UINT width, UINT height,
271 UINT depth, DWORD usage, enum wined3d_format_id format, WINED3DPOOL pool)
273 HRESULT hr;
275 volume->IDirect3DVolume8_iface.lpVtbl = &Direct3DVolume8_Vtbl;
276 volume->ref = 1;
278 hr = IWineD3DDevice_CreateVolume(device->WineD3DDevice, width, height, depth, usage,
279 format, pool, volume, &d3d8_volume_wined3d_parent_ops, &volume->wineD3DVolume);
280 if (FAILED(hr))
282 WARN("Failed to create wined3d volume, hr %#x.\n", hr);
283 return hr;
286 return D3D_OK;