VirtualBox

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

Last change on this file since 20612 was 19678, checked in by vboxsync, 16 years ago

opengl: update wine to 1.1.21, add d3d9.dll to build list

  • Property svn:eol-style set to native
File size: 8.5 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 if (IsEqualGUID(riid, &IID_IUnknown)
41 || IsEqualGUID(riid, &IID_IDirect3DVolume9)) {
42 IDirect3DVolume9_AddRef(iface);
43 *ppobj = This;
44 return S_OK;
45 }
46
47 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
48 *ppobj = NULL;
49 return E_NOINTERFACE;
50}
51
52static ULONG WINAPI IDirect3DVolume9Impl_AddRef(LPDIRECT3DVOLUME9 iface) {
53 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
54
55 TRACE("(%p)\n", This);
56
57 if (This->forwardReference) {
58 /* Forward refcounting */
59 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
60 return IUnknown_AddRef(This->forwardReference);
61 } else {
62 /* No container, handle our own refcounting */
63 ULONG ref = InterlockedIncrement(&This->ref);
64 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
65 return ref;
66 }
67}
68
69static ULONG WINAPI IDirect3DVolume9Impl_Release(LPDIRECT3DVOLUME9 iface) {
70 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
71
72 TRACE("(%p)\n", This);
73
74 if (This->forwardReference) {
75 /* Forward refcounting */
76 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
77 return IUnknown_Release(This->forwardReference);
78 } else {
79 /* No container, handle our own refcounting */
80 ULONG ref = InterlockedDecrement(&This->ref);
81 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
82
83 if (ref == 0) {
84 EnterCriticalSection(&d3d9_cs);
85 IWineD3DVolume_Release(This->wineD3DVolume);
86 LeaveCriticalSection(&d3d9_cs);
87 HeapFree(GetProcessHeap(), 0, This);
88 }
89
90 return ref;
91 }
92}
93
94/* IDirect3DVolume9 Interface follow: */
95static HRESULT WINAPI IDirect3DVolume9Impl_GetDevice(LPDIRECT3DVOLUME9 iface, IDirect3DDevice9** ppDevice) {
96 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
97 IWineD3DDevice *myDevice = NULL;
98
99 TRACE("iface %p, ppDevice %p\n", iface, ppDevice);
100
101 EnterCriticalSection(&d3d9_cs);
102
103 IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
104 IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
105 IWineD3DDevice_Release(myDevice);
106
107 LeaveCriticalSection(&d3d9_cs);
108
109 return D3D_OK;
110}
111
112static HRESULT WINAPI IDirect3DVolume9Impl_SetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
113 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
114 HRESULT hr;
115
116 TRACE("(%p) Relay\n", This);
117
118 EnterCriticalSection(&d3d9_cs);
119
120 hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
121
122 LeaveCriticalSection(&d3d9_cs);
123
124 return hr;
125}
126
127static HRESULT WINAPI IDirect3DVolume9Impl_GetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
128 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
129 HRESULT hr;
130
131 TRACE("(%p) Relay\n", This);
132
133 EnterCriticalSection(&d3d9_cs);
134
135 hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
136
137 LeaveCriticalSection(&d3d9_cs);
138
139 return hr;
140}
141
142static HRESULT WINAPI IDirect3DVolume9Impl_FreePrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid) {
143 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
144 HRESULT hr;
145
146 TRACE("(%p) Relay\n", This);
147
148 EnterCriticalSection(&d3d9_cs);
149
150 hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
151
152 LeaveCriticalSection(&d3d9_cs);
153
154 return hr;
155}
156
157static HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(LPDIRECT3DVOLUME9 iface, REFIID riid, void** ppContainer) {
158 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
159 HRESULT res;
160
161 TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
162
163 if (!This->container) return E_NOINTERFACE;
164
165 if (!ppContainer) {
166 ERR("Called without a valid ppContainer.\n");
167 }
168
169 res = IUnknown_QueryInterface(This->container, riid, ppContainer);
170
171 TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
172
173 return res;
174}
175
176static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(LPDIRECT3DVOLUME9 iface, D3DVOLUME_DESC* pDesc) {
177 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
178 WINED3DVOLUME_DESC wined3ddesc;
179 UINT tmpInt = -1;
180 WINED3DFORMAT format;
181 HRESULT hr;
182
183 TRACE("(%p) Relay\n", This);
184
185 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
186 wined3ddesc.Format = &format;
187 wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
188 wined3ddesc.Usage = &pDesc->Usage;
189 wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
190 wined3ddesc.Size = &tmpInt;
191 wined3ddesc.Width = &pDesc->Width;
192 wined3ddesc.Height = &pDesc->Height;
193 wined3ddesc.Depth = &pDesc->Depth;
194
195 EnterCriticalSection(&d3d9_cs);
196
197 hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
198
199 LeaveCriticalSection(&d3d9_cs);
200
201 if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(format);
202
203 return hr;
204}
205
206static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(LPDIRECT3DVOLUME9 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
207 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
208 HRESULT hr;
209
210 TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
211
212 EnterCriticalSection(&d3d9_cs);
213
214 hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *)pLockedVolume,
215 (const WINED3DBOX *)pBox, Flags);
216
217 LeaveCriticalSection(&d3d9_cs);
218
219 return hr;
220}
221
222static HRESULT WINAPI IDirect3DVolume9Impl_UnlockBox(LPDIRECT3DVOLUME9 iface) {
223 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
224 HRESULT hr;
225
226 TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
227
228 EnterCriticalSection(&d3d9_cs);
229
230 hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
231
232 LeaveCriticalSection(&d3d9_cs);
233
234 return hr;
235}
236
237const IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl =
238{
239 /* IUnknown */
240 IDirect3DVolume9Impl_QueryInterface,
241 IDirect3DVolume9Impl_AddRef,
242 IDirect3DVolume9Impl_Release,
243 /* IDirect3DVolume9 */
244 IDirect3DVolume9Impl_GetDevice,
245 IDirect3DVolume9Impl_SetPrivateData,
246 IDirect3DVolume9Impl_GetPrivateData,
247 IDirect3DVolume9Impl_FreePrivateData,
248 IDirect3DVolume9Impl_GetContainer,
249 IDirect3DVolume9Impl_GetDesc,
250 IDirect3DVolume9Impl_LockBox,
251 IDirect3DVolume9Impl_UnlockBox
252};
253
254ULONG WINAPI D3D9CB_DestroyVolume(IWineD3DVolume *pVolume) {
255 IDirect3DVolume9Impl* volumeParent;
256
257 IWineD3DVolume_GetParent(pVolume, (IUnknown **) &volumeParent);
258 /* GetParent's AddRef was forwarded to an object in destruction.
259 * Releasing it here again would cause an endless recursion. */
260 volumeParent->forwardReference = NULL;
261 return IDirect3DVolume9_Release((IDirect3DVolume9*) volumeParent);
262}
Note: See TracBrowser for help on using the repository browser.

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