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 |
|
---|
33 | WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
|
---|
34 |
|
---|
35 | /* IDirect3DVolume8 IUnknown parts follow: */
|
---|
36 | static HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface, REFIID riid, LPVOID *ppobj) {
|
---|
37 | IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
|
---|
38 |
|
---|
39 | if (IsEqualGUID(riid, &IID_IUnknown)
|
---|
40 | || IsEqualGUID(riid, &IID_IDirect3DVolume8)) {
|
---|
41 | IUnknown_AddRef(iface);
|
---|
42 | *ppobj = This;
|
---|
43 | return S_OK;
|
---|
44 | }
|
---|
45 |
|
---|
46 | WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
|
---|
47 | *ppobj = NULL;
|
---|
48 | return E_NOINTERFACE;
|
---|
49 | }
|
---|
50 |
|
---|
51 | static ULONG WINAPI IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface) {
|
---|
52 | IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
|
---|
53 |
|
---|
54 | TRACE("(%p)\n", This);
|
---|
55 |
|
---|
56 | if (This->forwardReference) {
|
---|
57 | /* Forward to the containerParent */
|
---|
58 | TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
|
---|
59 | return IUnknown_AddRef(This->forwardReference);
|
---|
60 | } else {
|
---|
61 | /* No container, handle our own refcounting */
|
---|
62 | ULONG ref = InterlockedIncrement(&This->ref);
|
---|
63 | TRACE("(%p) : AddRef from %d\n", This, ref - 1);
|
---|
64 | return ref;
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 | static ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
|
---|
69 | IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
|
---|
70 |
|
---|
71 | TRACE("(%p)\n", This);
|
---|
72 |
|
---|
73 | if (This->forwardReference) {
|
---|
74 | /* Forward to the containerParent */
|
---|
75 | TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
|
---|
76 | return IUnknown_Release(This->forwardReference);
|
---|
77 | }
|
---|
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(&d3d8_cs);
|
---|
85 | IWineD3DVolume_Release(This->wineD3DVolume);
|
---|
86 | LeaveCriticalSection(&d3d8_cs);
|
---|
87 | HeapFree(GetProcessHeap(), 0, This);
|
---|
88 | }
|
---|
89 |
|
---|
90 | return ref;
|
---|
91 | }
|
---|
92 | }
|
---|
93 |
|
---|
94 | /* IDirect3DVolume8 Interface follow: */
|
---|
95 | static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, IDirect3DDevice8 **ppDevice) {
|
---|
96 | IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
|
---|
97 | IWineD3DDevice *myDevice = NULL;
|
---|
98 |
|
---|
99 | EnterCriticalSection(&d3d8_cs);
|
---|
100 | IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
|
---|
101 | IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
|
---|
102 | IWineD3DDevice_Release(myDevice);
|
---|
103 | LeaveCriticalSection(&d3d8_cs);
|
---|
104 | return D3D_OK;
|
---|
105 | }
|
---|
106 |
|
---|
107 | static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
|
---|
108 | IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
|
---|
109 | HRESULT hr;
|
---|
110 | TRACE("(%p) Relay\n", This);
|
---|
111 |
|
---|
112 | EnterCriticalSection(&d3d8_cs);
|
---|
113 | hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
|
---|
114 | LeaveCriticalSection(&d3d8_cs);
|
---|
115 | return hr;
|
---|
116 | }
|
---|
117 |
|
---|
118 | static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
|
---|
119 | IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
|
---|
120 | HRESULT hr;
|
---|
121 | TRACE("(%p) Relay\n", This);
|
---|
122 |
|
---|
123 | EnterCriticalSection(&d3d8_cs);
|
---|
124 | hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
|
---|
125 | LeaveCriticalSection(&d3d8_cs);
|
---|
126 | return hr;
|
---|
127 | }
|
---|
128 |
|
---|
129 | static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid) {
|
---|
130 | IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
|
---|
131 | HRESULT hr;
|
---|
132 | TRACE("(%p) Relay\n", This);
|
---|
133 |
|
---|
134 | EnterCriticalSection(&d3d8_cs);
|
---|
135 | hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
|
---|
136 | LeaveCriticalSection(&d3d8_cs);
|
---|
137 | return hr;
|
---|
138 | }
|
---|
139 |
|
---|
140 | static HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void **ppContainer) {
|
---|
141 | IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
|
---|
142 | HRESULT res;
|
---|
143 |
|
---|
144 | TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
|
---|
145 |
|
---|
146 | if (!This->container) return E_NOINTERFACE;
|
---|
147 |
|
---|
148 | if (!ppContainer) {
|
---|
149 | ERR("Called without a valid ppContainer.\n");
|
---|
150 | }
|
---|
151 |
|
---|
152 | res = IUnknown_QueryInterface(This->container, riid, ppContainer);
|
---|
153 |
|
---|
154 | TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
|
---|
155 |
|
---|
156 | return res;
|
---|
157 | }
|
---|
158 |
|
---|
159 | static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC *pDesc) {
|
---|
160 | IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
|
---|
161 | HRESULT hr;
|
---|
162 | WINED3DVOLUME_DESC wined3ddesc;
|
---|
163 |
|
---|
164 | TRACE("(%p) Relay\n", This);
|
---|
165 |
|
---|
166 | EnterCriticalSection(&d3d8_cs);
|
---|
167 | hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
|
---|
168 | LeaveCriticalSection(&d3d8_cs);
|
---|
169 |
|
---|
170 | if (SUCCEEDED(hr))
|
---|
171 | {
|
---|
172 | pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
|
---|
173 | pDesc->Type = wined3ddesc.Type;
|
---|
174 | pDesc->Usage = wined3ddesc.Usage;
|
---|
175 | pDesc->Pool = wined3ddesc.Pool;
|
---|
176 | pDesc->Size = wined3ddesc.Size;
|
---|
177 | pDesc->Width = wined3ddesc.Width;
|
---|
178 | pDesc->Height = wined3ddesc.Height;
|
---|
179 | pDesc->Depth = wined3ddesc.Depth;
|
---|
180 | }
|
---|
181 |
|
---|
182 | return hr;
|
---|
183 | }
|
---|
184 |
|
---|
185 | static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
|
---|
186 | IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
|
---|
187 | HRESULT hr;
|
---|
188 | TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
|
---|
189 |
|
---|
190 | EnterCriticalSection(&d3d8_cs);
|
---|
191 | hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
|
---|
192 | LeaveCriticalSection(&d3d8_cs);
|
---|
193 | return hr;
|
---|
194 | }
|
---|
195 |
|
---|
196 | static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
|
---|
197 | IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
|
---|
198 | HRESULT hr;
|
---|
199 | TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
|
---|
200 |
|
---|
201 | EnterCriticalSection(&d3d8_cs);
|
---|
202 | hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
|
---|
203 | LeaveCriticalSection(&d3d8_cs);
|
---|
204 | return hr;
|
---|
205 | }
|
---|
206 |
|
---|
207 | const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl =
|
---|
208 | {
|
---|
209 | /* IUnknown */
|
---|
210 | IDirect3DVolume8Impl_QueryInterface,
|
---|
211 | IDirect3DVolume8Impl_AddRef,
|
---|
212 | IDirect3DVolume8Impl_Release,
|
---|
213 | /* IDirect3DVolume8 */
|
---|
214 | IDirect3DVolume8Impl_GetDevice,
|
---|
215 | IDirect3DVolume8Impl_SetPrivateData,
|
---|
216 | IDirect3DVolume8Impl_GetPrivateData,
|
---|
217 | IDirect3DVolume8Impl_FreePrivateData,
|
---|
218 | IDirect3DVolume8Impl_GetContainer,
|
---|
219 | IDirect3DVolume8Impl_GetDesc,
|
---|
220 | IDirect3DVolume8Impl_LockBox,
|
---|
221 | IDirect3DVolume8Impl_UnlockBox
|
---|
222 | };
|
---|
223 |
|
---|
224 | ULONG WINAPI D3D8CB_DestroyVolume(IWineD3DVolume *pVolume) {
|
---|
225 | IDirect3DVolume8Impl* volumeParent;
|
---|
226 |
|
---|
227 | IWineD3DVolume_GetParent(pVolume, (IUnknown **) &volumeParent);
|
---|
228 | /* GetParent's AddRef was forwarded to an object in destruction.
|
---|
229 | * Releasing it here again would cause an endless recursion. */
|
---|
230 | volumeParent->forwardReference = NULL;
|
---|
231 | return IDirect3DVolume8_Release((IDirect3DVolume8*) volumeParent);
|
---|
232 | }
|
---|