VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/d3d8/volume.c@ 69362

Last change on this file since 69362 was 48345, checked in by vboxsync, 11 years ago

header fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.3 KB
Line 
1/*
2 * IDirect3DVolume8 implementation
3 *
4 * Copyright 2005 Oliver Stieber
5 *
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.
10 *
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.
15 *
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
19 */
20
21/*
22 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
23 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
24 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
25 * a choice of LGPL license versions is made available with the language indicating
26 * that LGPLv2 or any later version may be used, or where a choice of which version
27 * of the LGPL is applied is otherwise unspecified.
28 */
29
30#include "config.h"
31#include "d3d8_private.h"
32
33WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
34
35static inline struct d3d8_volume *impl_from_IDirect3DVolume8(IDirect3DVolume8 *iface)
36{
37 return CONTAINING_RECORD(iface, struct d3d8_volume, IDirect3DVolume8_iface);
38}
39
40static HRESULT WINAPI d3d8_volume_QueryInterface(IDirect3DVolume8 *iface, REFIID riid, void **out)
41{
42 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), out);
43
44 if (IsEqualGUID(riid, &IID_IDirect3DVolume8)
45 || IsEqualGUID(riid, &IID_IUnknown))
46 {
47 IDirect3DVolume8_AddRef(iface);
48 *out = iface;
49 return S_OK;
50 }
51
52 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
53
54 *out = NULL;
55 return E_NOINTERFACE;
56}
57
58static ULONG WINAPI d3d8_volume_AddRef(IDirect3DVolume8 *iface)
59{
60 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
61
62 TRACE("iface %p.\n", iface);
63
64 if (volume->forwardReference)
65 {
66 /* Forward to the containerParent */
67 TRACE("Forwarding to %p,\n", volume->forwardReference);
68 return IUnknown_AddRef(volume->forwardReference);
69 }
70 else
71 {
72 /* No container, handle our own refcounting */
73 ULONG ref = InterlockedIncrement(&volume->refcount);
74
75 TRACE("%p increasing refcount to %u.\n", iface, ref);
76
77 if (ref == 1)
78 {
79 wined3d_mutex_lock();
80 wined3d_volume_incref(volume->wined3d_volume);
81 wined3d_mutex_unlock();
82 }
83
84 return ref;
85 }
86}
87
88static ULONG WINAPI d3d8_volume_Release(IDirect3DVolume8 *iface)
89{
90 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
91
92 TRACE("iface %p.\n", iface);
93
94 if (volume->forwardReference)
95 {
96 /* Forward to the containerParent */
97 TRACE("Forwarding to %p.\n", volume->forwardReference);
98 return IUnknown_Release(volume->forwardReference);
99 }
100 else
101 {
102 /* No container, handle our own refcounting */
103 ULONG ref = InterlockedDecrement(&volume->refcount);
104
105 TRACE("%p decreasing refcount to %u.\n", iface, ref);
106
107 if (!ref)
108 {
109 wined3d_mutex_lock();
110 wined3d_volume_decref(volume->wined3d_volume);
111 wined3d_mutex_unlock();
112 }
113
114 return ref;
115 }
116}
117
118static HRESULT WINAPI d3d8_volume_GetDevice(IDirect3DVolume8 *iface, IDirect3DDevice8 **device)
119{
120 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
121 IDirect3DResource8 *resource;
122 HRESULT hr;
123
124 TRACE("iface %p, device %p.\n", iface, device);
125
126 hr = IUnknown_QueryInterface(volume->forwardReference, &IID_IDirect3DResource8, (void **)&resource);
127 if (SUCCEEDED(hr))
128 {
129 hr = IDirect3DResource8_GetDevice(resource, device);
130 IDirect3DResource8_Release(resource);
131
132 TRACE("Returning device %p.\n", *device);
133 }
134
135 return hr;
136}
137
138static HRESULT WINAPI d3d8_volume_SetPrivateData(IDirect3DVolume8 *iface, REFGUID guid,
139 const void *data, DWORD data_size, DWORD flags)
140{
141 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
142 struct wined3d_resource *resource;
143 HRESULT hr;
144
145 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
146 iface, debugstr_guid(guid), data, data_size, flags);
147
148 wined3d_mutex_lock();
149 resource = wined3d_volume_get_resource(volume->wined3d_volume);
150 hr = wined3d_resource_set_private_data(resource, guid, data, data_size, flags);
151 wined3d_mutex_unlock();
152
153 return hr;
154}
155
156static HRESULT WINAPI d3d8_volume_GetPrivateData(IDirect3DVolume8 *iface, REFGUID guid,
157 void *data, DWORD *data_size)
158{
159 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
160 struct wined3d_resource *resource;
161 HRESULT hr;
162
163 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
164 iface, debugstr_guid(guid), data, data_size);
165
166 wined3d_mutex_lock();
167 resource = wined3d_volume_get_resource(volume->wined3d_volume);
168 hr = wined3d_resource_get_private_data(resource, guid, data, data_size);
169 wined3d_mutex_unlock();
170
171 return hr;
172}
173
174static HRESULT WINAPI d3d8_volume_FreePrivateData(IDirect3DVolume8 *iface, REFGUID guid)
175{
176 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
177 struct wined3d_resource *resource;
178 HRESULT hr;
179
180 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
181
182 wined3d_mutex_lock();
183 resource = wined3d_volume_get_resource(volume->wined3d_volume);
184 hr = wined3d_resource_free_private_data(resource, guid);
185 wined3d_mutex_unlock();
186
187 return hr;
188}
189
190static HRESULT WINAPI d3d8_volume_GetContainer(IDirect3DVolume8 *iface, REFIID riid, void **container)
191{
192 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
193 HRESULT res;
194
195 TRACE("iface %p, riid %s, container %p.\n",
196 iface, debugstr_guid(riid), container);
197
198 if (!volume->container)
199 return E_NOINTERFACE;
200
201 res = IUnknown_QueryInterface(volume->container, riid, container);
202
203 TRACE("Returning %p.\n", *container);
204
205 return res;
206}
207
208static HRESULT WINAPI d3d8_volume_GetDesc(IDirect3DVolume8 *iface, D3DVOLUME_DESC *desc)
209{
210 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
211 struct wined3d_resource_desc wined3d_desc;
212 struct wined3d_resource *wined3d_resource;
213
214 TRACE("iface %p, desc %p.\n", iface, desc);
215
216 wined3d_mutex_lock();
217 wined3d_resource = wined3d_volume_get_resource(volume->wined3d_volume);
218 wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
219 wined3d_mutex_unlock();
220
221 desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
222 desc->Type = wined3d_desc.resource_type;
223 desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
224 desc->Pool = wined3d_desc.pool;
225 desc->Size = wined3d_desc.size;
226 desc->Width = wined3d_desc.width;
227 desc->Height = wined3d_desc.height;
228 desc->Depth = wined3d_desc.depth;
229
230 return D3D_OK;
231}
232
233static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface,
234 D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags)
235{
236 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
237 struct wined3d_map_desc map_desc;
238 HRESULT hr;
239
240 TRACE("iface %p, locked_box %p, box %p, flags %#x.\n",
241 iface, locked_box, box, flags);
242
243 wined3d_mutex_lock();
244 hr = wined3d_volume_map(volume->wined3d_volume, &map_desc, (const struct wined3d_box *)box, flags);
245 wined3d_mutex_unlock();
246
247 locked_box->RowPitch = map_desc.row_pitch;
248 locked_box->SlicePitch = map_desc.slice_pitch;
249 locked_box->pBits = map_desc.data;
250
251 return hr;
252}
253
254static HRESULT WINAPI d3d8_volume_UnlockBox(IDirect3DVolume8 *iface)
255{
256 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
257 HRESULT hr;
258
259 TRACE("iface %p.\n", iface);
260
261 wined3d_mutex_lock();
262 hr = wined3d_volume_unmap(volume->wined3d_volume);
263 wined3d_mutex_unlock();
264
265 return hr;
266}
267
268static const IDirect3DVolume8Vtbl d3d8_volume_vtbl =
269{
270 /* IUnknown */
271 d3d8_volume_QueryInterface,
272 d3d8_volume_AddRef,
273 d3d8_volume_Release,
274 /* IDirect3DVolume8 */
275 d3d8_volume_GetDevice,
276 d3d8_volume_SetPrivateData,
277 d3d8_volume_GetPrivateData,
278 d3d8_volume_FreePrivateData,
279 d3d8_volume_GetContainer,
280 d3d8_volume_GetDesc,
281 d3d8_volume_LockBox,
282 d3d8_volume_UnlockBox,
283};
284
285static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
286{
287 HeapFree(GetProcessHeap(), 0, parent);
288}
289
290static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops =
291{
292 volume_wined3d_object_destroyed,
293};
294
295HRESULT volume_init(struct d3d8_volume *volume, struct d3d8_device *device, UINT width, UINT height,
296 UINT depth, DWORD usage, enum wined3d_format_id format, enum wined3d_pool pool)
297{
298 HRESULT hr;
299
300 volume->IDirect3DVolume8_iface.lpVtbl = &d3d8_volume_vtbl;
301 volume->refcount = 1;
302
303 hr = wined3d_volume_create(device->wined3d_device, width, height, depth, usage,
304 format, pool, volume, &d3d8_volume_wined3d_parent_ops, &volume->wined3d_volume);
305 if (FAILED(hr))
306 {
307 WARN("Failed to create wined3d volume, hr %#x.\n", hr);
308 return hr;
309 }
310
311 return D3D_OK;
312}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette