VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/volume.c@ 30705

Last change on this file since 30705 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 * 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 * Sun 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, Sun 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
35/* IDirect3DVolume8 IUnknown parts follow: */
36static HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface, REFIID riid, LPVOID *ppobj) {
37 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
38
39 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
40
41 if (IsEqualGUID(riid, &IID_IUnknown)
42 || IsEqualGUID(riid, &IID_IDirect3DVolume8)) {
43 IUnknown_AddRef(iface);
44 *ppobj = This;
45 return S_OK;
46 }
47
48 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
49 *ppobj = NULL;
50 return E_NOINTERFACE;
51}
52
53static ULONG WINAPI IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface) {
54 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
55
56 TRACE("iface %p.\n", iface);
57
58 if (This->forwardReference) {
59 /* Forward to the containerParent */
60 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
61 return IUnknown_AddRef(This->forwardReference);
62 } else {
63 /* No container, handle our own refcounting */
64 ULONG ref = InterlockedIncrement(&This->ref);
65
66 TRACE("%p increasing refcount to %u.\n", iface, ref);
67
68 if (ref == 1)
69 {
70 wined3d_mutex_lock();
71 IWineD3DVolume_AddRef(This->wineD3DVolume);
72 wined3d_mutex_unlock();
73 }
74
75 return ref;
76 }
77}
78
79static ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
80 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
81
82 TRACE("iface %p.\n", iface);
83
84 if (This->forwardReference) {
85 /* Forward to the containerParent */
86 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
87 return IUnknown_Release(This->forwardReference);
88 }
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/* IDirect3DVolume8 Interface follow: */
106static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(IDirect3DVolume8 *iface, IDirect3DDevice8 **device)
107{
108 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
109 IDirect3DResource8 *resource;
110 HRESULT hr;
111
112 TRACE("iface %p, device %p.\n", iface, device);
113
114 hr = IUnknown_QueryInterface(This->forwardReference, &IID_IDirect3DResource8, (void **)&resource);
115 if (SUCCEEDED(hr))
116 {
117 hr = IDirect3DResource8_GetDevice(resource, device);
118 IDirect3DResource8_Release(resource);
119
120 TRACE("Returning device %p.\n", *device);
121 }
122
123 return hr;
124}
125
126static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
127 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)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 hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
135 wined3d_mutex_unlock();
136
137 return hr;
138}
139
140static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
141 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
142 HRESULT hr;
143
144 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
145 iface, debugstr_guid(refguid), pData, pSizeOfData);
146
147 wined3d_mutex_lock();
148 hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
149 wined3d_mutex_unlock();
150
151 return hr;
152}
153
154static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid) {
155 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
156 HRESULT hr;
157
158 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
159
160 wined3d_mutex_lock();
161 hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
162 wined3d_mutex_unlock();
163
164 return hr;
165}
166
167static HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void **ppContainer) {
168 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
169 HRESULT res;
170
171 TRACE("iface %p, riid %s, container %p.\n",
172 iface, debugstr_guid(riid), ppContainer);
173
174 if (!This->container) return E_NOINTERFACE;
175
176 if (!ppContainer) {
177 ERR("Called without a valid ppContainer.\n");
178 }
179
180 res = IUnknown_QueryInterface(This->container, riid, ppContainer);
181
182 TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
183
184 return res;
185}
186
187static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC *pDesc) {
188 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
189 HRESULT hr;
190 WINED3DVOLUME_DESC wined3ddesc;
191
192 TRACE("iface %p, desc %p.\n", iface, pDesc);
193
194 wined3d_mutex_lock();
195 hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
196 wined3d_mutex_unlock();
197
198 if (SUCCEEDED(hr))
199 {
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;
208 }
209
210 return hr;
211}
212
213static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
214 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
215 HRESULT hr;
216
217 TRACE("iface %p, locked_box %p, box %p, flags %#x.\n",
218 iface, pLockedVolume, pBox, Flags);
219
220 wined3d_mutex_lock();
221 hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
222 wined3d_mutex_unlock();
223
224 return hr;
225}
226
227static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
228 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
229 HRESULT hr;
230
231 TRACE("iface %p.\n", iface);
232
233 wined3d_mutex_lock();
234 hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
235 wined3d_mutex_unlock();
236
237 return hr;
238}
239
240static const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl =
241{
242 /* IUnknown */
243 IDirect3DVolume8Impl_QueryInterface,
244 IDirect3DVolume8Impl_AddRef,
245 IDirect3DVolume8Impl_Release,
246 /* IDirect3DVolume8 */
247 IDirect3DVolume8Impl_GetDevice,
248 IDirect3DVolume8Impl_SetPrivateData,
249 IDirect3DVolume8Impl_GetPrivateData,
250 IDirect3DVolume8Impl_FreePrivateData,
251 IDirect3DVolume8Impl_GetContainer,
252 IDirect3DVolume8Impl_GetDesc,
253 IDirect3DVolume8Impl_LockBox,
254 IDirect3DVolume8Impl_UnlockBox
255};
256
257static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
258{
259 HeapFree(GetProcessHeap(), 0, parent);
260}
261
262static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops =
263{
264 volume_wined3d_object_destroyed,
265};
266
267HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device, UINT width, UINT height,
268 UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool)
269{
270 HRESULT hr;
271
272 volume->lpVtbl = &Direct3DVolume8_Vtbl;
273 volume->ref = 1;
274
275 hr = IWineD3DDevice_CreateVolume(device->WineD3DDevice, width, height, depth, usage,
276 format, pool, &volume->wineD3DVolume, (IUnknown *)volume, &d3d8_volume_wined3d_parent_ops);
277 if (FAILED(hr))
278 {
279 WARN("Failed to create wined3d volume, hr %#x.\n", hr);
280 return hr;
281 }
282
283 return D3D_OK;
284}
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