urlmon: Recognize <body> tag in FindMimeFromData function.
[wine/multimedia.git] / dlls / d3d8 / volume.c
blobadd35ad7cdeb6f29ba85d641bfd981e913044230
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 struct d3d8_volume *impl_from_IDirect3DVolume8(IDirect3DVolume8 *iface)
28 return CONTAINING_RECORD(iface, struct d3d8_volume, IDirect3DVolume8_iface);
31 static HRESULT WINAPI d3d8_volume_QueryInterface(IDirect3DVolume8 *iface, REFIID riid, void **out)
33 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), out);
35 if (IsEqualGUID(riid, &IID_IDirect3DVolume8)
36 || IsEqualGUID(riid, &IID_IUnknown))
38 IDirect3DVolume8_AddRef(iface);
39 *out = iface;
40 return S_OK;
43 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
45 *out = NULL;
46 return E_NOINTERFACE;
49 static ULONG WINAPI d3d8_volume_AddRef(IDirect3DVolume8 *iface)
51 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
53 TRACE("iface %p.\n", iface);
55 if (volume->forwardReference)
57 /* Forward to the containerParent */
58 TRACE("Forwarding to %p,\n", volume->forwardReference);
59 return IUnknown_AddRef(volume->forwardReference);
61 else
63 /* No container, handle our own refcounting */
64 ULONG ref = InterlockedIncrement(&volume->resource.refcount);
66 TRACE("%p increasing refcount to %u.\n", iface, ref);
68 if (ref == 1)
70 wined3d_mutex_lock();
71 wined3d_volume_incref(volume->wined3d_volume);
72 wined3d_mutex_unlock();
75 return ref;
79 static ULONG WINAPI d3d8_volume_Release(IDirect3DVolume8 *iface)
81 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
83 TRACE("iface %p.\n", iface);
85 if (volume->forwardReference)
87 /* Forward to the containerParent */
88 TRACE("Forwarding to %p.\n", volume->forwardReference);
89 return IUnknown_Release(volume->forwardReference);
91 else
93 /* No container, handle our own refcounting */
94 ULONG ref = InterlockedDecrement(&volume->resource.refcount);
96 TRACE("%p decreasing refcount to %u.\n", iface, ref);
98 if (!ref)
100 wined3d_mutex_lock();
101 wined3d_volume_decref(volume->wined3d_volume);
102 wined3d_mutex_unlock();
105 return ref;
109 static HRESULT WINAPI d3d8_volume_GetDevice(IDirect3DVolume8 *iface, IDirect3DDevice8 **device)
111 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
112 IDirect3DResource8 *resource;
113 HRESULT hr;
115 TRACE("iface %p, device %p.\n", iface, device);
117 hr = IUnknown_QueryInterface(volume->forwardReference, &IID_IDirect3DResource8, (void **)&resource);
118 if (SUCCEEDED(hr))
120 hr = IDirect3DResource8_GetDevice(resource, device);
121 IDirect3DResource8_Release(resource);
123 TRACE("Returning device %p.\n", *device);
126 return hr;
129 static HRESULT WINAPI d3d8_volume_SetPrivateData(IDirect3DVolume8 *iface, REFGUID guid,
130 const void *data, DWORD data_size, DWORD flags)
132 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
133 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
134 iface, debugstr_guid(guid), data, data_size, flags);
136 return d3d8_resource_set_private_data(&volume->resource, guid, data, data_size, flags);
139 static HRESULT WINAPI d3d8_volume_GetPrivateData(IDirect3DVolume8 *iface, REFGUID guid,
140 void *data, DWORD *data_size)
142 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
143 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
144 iface, debugstr_guid(guid), data, data_size);
146 return d3d8_resource_get_private_data(&volume->resource, guid, data, data_size);
149 static HRESULT WINAPI d3d8_volume_FreePrivateData(IDirect3DVolume8 *iface, REFGUID guid)
151 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
152 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
154 return d3d8_resource_free_private_data(&volume->resource, guid);
157 static HRESULT WINAPI d3d8_volume_GetContainer(IDirect3DVolume8 *iface, REFIID riid, void **container)
159 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
160 HRESULT res;
162 TRACE("iface %p, riid %s, container %p.\n",
163 iface, debugstr_guid(riid), container);
165 if (!volume->container)
166 return E_NOINTERFACE;
168 res = IUnknown_QueryInterface(volume->container, riid, container);
170 TRACE("Returning %p.\n", *container);
172 return res;
175 static HRESULT WINAPI d3d8_volume_GetDesc(IDirect3DVolume8 *iface, D3DVOLUME_DESC *desc)
177 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
178 struct wined3d_resource_desc wined3d_desc;
179 struct wined3d_resource *wined3d_resource;
181 TRACE("iface %p, desc %p.\n", iface, desc);
183 wined3d_mutex_lock();
184 wined3d_resource = wined3d_volume_get_resource(volume->wined3d_volume);
185 wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
186 wined3d_mutex_unlock();
188 desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
189 desc->Type = wined3d_desc.resource_type;
190 desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
191 desc->Pool = wined3d_desc.pool;
192 desc->Size = wined3d_desc.size;
193 desc->Width = wined3d_desc.width;
194 desc->Height = wined3d_desc.height;
195 desc->Depth = wined3d_desc.depth;
197 return D3D_OK;
200 static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface,
201 D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags)
203 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
204 struct wined3d_map_desc map_desc;
205 HRESULT hr;
207 TRACE("iface %p, locked_box %p, box %p, flags %#x.\n",
208 iface, locked_box, box, flags);
210 wined3d_mutex_lock();
211 hr = wined3d_volume_map(volume->wined3d_volume, &map_desc, (const struct wined3d_box *)box, flags);
212 wined3d_mutex_unlock();
214 locked_box->RowPitch = map_desc.row_pitch;
215 locked_box->SlicePitch = map_desc.slice_pitch;
216 locked_box->pBits = map_desc.data;
218 return hr;
221 static HRESULT WINAPI d3d8_volume_UnlockBox(IDirect3DVolume8 *iface)
223 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
224 HRESULT hr;
226 TRACE("iface %p.\n", iface);
228 wined3d_mutex_lock();
229 hr = wined3d_volume_unmap(volume->wined3d_volume);
230 wined3d_mutex_unlock();
232 return hr;
235 static const IDirect3DVolume8Vtbl d3d8_volume_vtbl =
237 /* IUnknown */
238 d3d8_volume_QueryInterface,
239 d3d8_volume_AddRef,
240 d3d8_volume_Release,
241 /* IDirect3DVolume8 */
242 d3d8_volume_GetDevice,
243 d3d8_volume_SetPrivateData,
244 d3d8_volume_GetPrivateData,
245 d3d8_volume_FreePrivateData,
246 d3d8_volume_GetContainer,
247 d3d8_volume_GetDesc,
248 d3d8_volume_LockBox,
249 d3d8_volume_UnlockBox,
252 static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
254 struct d3d8_volume *volume = parent;
255 d3d8_resource_cleanup(&volume->resource);
256 HeapFree(GetProcessHeap(), 0, volume);
259 static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops =
261 volume_wined3d_object_destroyed,
264 void volume_init(struct d3d8_volume *volume, struct wined3d_volume *wined3d_volume,
265 const struct wined3d_parent_ops **parent_ops)
267 volume->IDirect3DVolume8_iface.lpVtbl = &d3d8_volume_vtbl;
268 d3d8_resource_init(&volume->resource);
269 wined3d_volume_incref(wined3d_volume);
270 volume->wined3d_volume = wined3d_volume;
272 *parent_ops = &d3d8_volume_wined3d_parent_ops;