VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/volume.c@ 33223

Last change on this file since 33223 was 25949, checked in by vboxsync, 15 years ago

crOpenGL: update to wine 1.1.36 and disable unnecessary fbo state poll

  • Property svn:eol-style set to native
File size: 9.0 KB
Line 
1/*
2 * IDirect3DVolume9 implementation
3 *
4 * Copyright 2002-2005 Jason Edmeades
5 * Raphael Junqueira
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22/*
23 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
24 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
25 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
26 * a choice of LGPL license versions is made available with the language indicating
27 * that LGPLv2 or any later version may be used, or where a choice of which version
28 * of the LGPL is applied is otherwise unspecified.
29 */
30
31#include "config.h"
32#include "d3d9_private.h"
33
34WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
35
36/* IDirect3DVolume9 IUnknown parts follow: */
37static HRESULT WINAPI IDirect3DVolume9Impl_QueryInterface(LPDIRECT3DVOLUME9 iface, REFIID riid, LPVOID* ppobj) {
38 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
39
40 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
41
42 if (IsEqualGUID(riid, &IID_IUnknown)
43 || IsEqualGUID(riid, &IID_IDirect3DVolume9)) {
44 IDirect3DVolume9_AddRef(iface);
45 *ppobj = This;
46 return S_OK;
47 }
48
49 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
50 *ppobj = NULL;
51 return E_NOINTERFACE;
52}
53
54static ULONG WINAPI IDirect3DVolume9Impl_AddRef(LPDIRECT3DVOLUME9 iface) {
55 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
56
57 TRACE("iface %p.\n", iface);
58
59 if (This->forwardReference) {
60 /* Forward refcounting */
61 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
62 return IUnknown_AddRef(This->forwardReference);
63 } else {
64 /* No container, handle our own refcounting */
65 ULONG ref = InterlockedIncrement(&This->ref);
66
67 TRACE("%p increasing refcount to %u.\n", iface, ref);
68
69 if (ref == 1)
70 {
71 wined3d_mutex_lock();
72 IWineD3DVolume_AddRef(This->wineD3DVolume);
73 wined3d_mutex_unlock();
74 }
75
76 return ref;
77 }
78}
79
80static ULONG WINAPI IDirect3DVolume9Impl_Release(LPDIRECT3DVOLUME9 iface) {
81 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
82
83 TRACE("iface %p.\n", iface);
84
85 if (This->forwardReference) {
86 /* Forward refcounting */
87 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
88 return IUnknown_Release(This->forwardReference);
89 } else {
90 /* No container, handle our own refcounting */
91 ULONG ref = InterlockedDecrement(&This->ref);
92
93 TRACE("%p decreasing refcount to %u.\n", iface, ref);
94
95 if (ref == 0) {
96 wined3d_mutex_lock();
97 IWineD3DVolume_Release(This->wineD3DVolume);
98 wined3d_mutex_unlock();
99 }
100
101 return ref;
102 }
103}
104
105/* IDirect3DVolume9 Interface follow: */
106static HRESULT WINAPI IDirect3DVolume9Impl_GetDevice(IDirect3DVolume9 *iface, IDirect3DDevice9 **device)
107{
108 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
109 IDirect3DResource9 *resource;
110 HRESULT hr;
111
112 TRACE("iface %p, device %p.\n", iface, device);
113
114 hr = IUnknown_QueryInterface(This->forwardReference, &IID_IDirect3DResource9, (void **)&resource);
115 if (SUCCEEDED(hr))
116 {
117 hr = IDirect3DResource9_GetDevice(resource, device);
118 IDirect3DResource9_Release(resource);
119
120 TRACE("Returning device %p.\n", *device);
121 }
122
123 return hr;
124}
125
126static HRESULT WINAPI IDirect3DVolume9Impl_SetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
127 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
128 HRESULT hr;
129
130 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
131 iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
132
133 wined3d_mutex_lock();
134
135 hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
136
137 wined3d_mutex_unlock();
138
139 return hr;
140}
141
142static HRESULT WINAPI IDirect3DVolume9Impl_GetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
143 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
144 HRESULT hr;
145
146 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
147 iface, debugstr_guid(refguid), pData, pSizeOfData);
148
149 wined3d_mutex_lock();
150
151 hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
152
153 wined3d_mutex_unlock();
154
155 return hr;
156}
157
158static HRESULT WINAPI IDirect3DVolume9Impl_FreePrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid) {
159 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
160 HRESULT hr;
161
162 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
163
164 wined3d_mutex_lock();
165
166 hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
167
168 wined3d_mutex_unlock();
169
170 return hr;
171}
172
173static HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(LPDIRECT3DVOLUME9 iface, REFIID riid, void** ppContainer) {
174 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
175 HRESULT res;
176
177 TRACE("iface %p, riid %s, container %p.\n", iface, debugstr_guid(riid), ppContainer);
178
179 if (!This->container) return E_NOINTERFACE;
180
181 if (!ppContainer) {
182 ERR("Called without a valid ppContainer.\n");
183 }
184
185 res = IUnknown_QueryInterface(This->container, riid, ppContainer);
186
187 TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
188
189 return res;
190}
191
192static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(LPDIRECT3DVOLUME9 iface, D3DVOLUME_DESC* pDesc) {
193 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
194 WINED3DVOLUME_DESC wined3ddesc;
195 HRESULT hr;
196
197 TRACE("iface %p, desc %p.\n", iface, pDesc);
198
199 wined3d_mutex_lock();
200
201 hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
202
203 wined3d_mutex_unlock();
204
205 if (SUCCEEDED(hr))
206 {
207 pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
208 pDesc->Type = wined3ddesc.Type;
209 pDesc->Usage = wined3ddesc.Usage;
210 pDesc->Pool = wined3ddesc.Pool;
211 pDesc->Width = wined3ddesc.Width;
212 pDesc->Height = wined3ddesc.Height;
213 pDesc->Depth = wined3ddesc.Depth;
214 }
215
216 return hr;
217}
218
219static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(LPDIRECT3DVOLUME9 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
220 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
221 HRESULT hr;
222
223 TRACE("iface %p, locked_box %p, box %p, flags %#x.\n",
224 iface, pLockedVolume, pBox, Flags);
225
226 wined3d_mutex_lock();
227
228 hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *)pLockedVolume,
229 (const WINED3DBOX *)pBox, Flags);
230
231 wined3d_mutex_unlock();
232
233 return hr;
234}
235
236static HRESULT WINAPI IDirect3DVolume9Impl_UnlockBox(LPDIRECT3DVOLUME9 iface) {
237 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
238 HRESULT hr;
239
240 TRACE("iface %p.\n", iface);
241
242 wined3d_mutex_lock();
243
244 hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
245
246 wined3d_mutex_unlock();
247
248 return hr;
249}
250
251static const IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl =
252{
253 /* IUnknown */
254 IDirect3DVolume9Impl_QueryInterface,
255 IDirect3DVolume9Impl_AddRef,
256 IDirect3DVolume9Impl_Release,
257 /* IDirect3DVolume9 */
258 IDirect3DVolume9Impl_GetDevice,
259 IDirect3DVolume9Impl_SetPrivateData,
260 IDirect3DVolume9Impl_GetPrivateData,
261 IDirect3DVolume9Impl_FreePrivateData,
262 IDirect3DVolume9Impl_GetContainer,
263 IDirect3DVolume9Impl_GetDesc,
264 IDirect3DVolume9Impl_LockBox,
265 IDirect3DVolume9Impl_UnlockBox
266};
267
268static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
269{
270 HeapFree(GetProcessHeap(), 0, parent);
271}
272
273static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops =
274{
275 volume_wined3d_object_destroyed,
276};
277
278HRESULT volume_init(IDirect3DVolume9Impl *volume, IDirect3DDevice9Impl *device, UINT width, UINT height,
279 UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool)
280{
281 HRESULT hr;
282
283 volume->lpVtbl = &Direct3DVolume9_Vtbl;
284 volume->ref = 1;
285
286 hr = IWineD3DDevice_CreateVolume(device->WineD3DDevice, width, height, depth, usage & WINED3DUSAGE_MASK,
287 format, pool, &volume->wineD3DVolume, (IUnknown *)volume, &d3d9_volume_wined3d_parent_ops);
288 if (FAILED(hr))
289 {
290 WARN("Failed to create wined3d volume, hr %#x.\n", hr);
291 return hr;
292 }
293
294 return D3D_OK;
295}
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