VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/cubetexture.c@ 21731

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

crOpenGL: update to wine 1.1.26

  • Property svn:eol-style set to native
File size: 14.8 KB
Line 
1/*
2 * IDirect3DCubeTexture9 implementation
3 *
4 * Copyright 2002-2005 Jason Edmeades
5 * Copyright 2002-2005 Raphael Junqueira
6 * Copyright 2005 Oliver Stieber
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23/*
24 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
25 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
26 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
27 * a choice of LGPL license versions is made available with the language indicating
28 * that LGPLv2 or any later version may be used, or where a choice of which version
29 * of the LGPL is applied is otherwise unspecified.
30 */
31
32#include "config.h"
33#include "d3d9_private.h"
34
35WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
36
37
38/* IDirect3DCubeTexture9 IUnknown parts follow: */
39static HRESULT WINAPI IDirect3DCubeTexture9Impl_QueryInterface(LPDIRECT3DCUBETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
40 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
41 if (IsEqualGUID(riid, &IID_IUnknown)
42 || IsEqualGUID(riid, &IID_IDirect3DResource9)
43 || IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)
44 || IsEqualGUID(riid, &IID_IDirect3DCubeTexture9)) {
45 IDirect3DCubeTexture9_AddRef(iface);
46 *ppobj = This;
47 return S_OK;
48 }
49
50 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
51 *ppobj = NULL;
52 return E_NOINTERFACE;
53}
54
55static ULONG WINAPI IDirect3DCubeTexture9Impl_AddRef(LPDIRECT3DCUBETEXTURE9 iface) {
56 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
57 ULONG ref = InterlockedIncrement(&This->ref);
58
59 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
60
61 return ref;
62}
63
64static ULONG WINAPI IDirect3DCubeTexture9Impl_Release(LPDIRECT3DCUBETEXTURE9 iface) {
65 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
66 ULONG ref = InterlockedDecrement(&This->ref);
67
68 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
69
70 if (ref == 0) {
71 TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
72
73 EnterCriticalSection(&d3d9_cs);
74 IWineD3DCubeTexture_Destroy(This->wineD3DCubeTexture, D3D9CB_DestroySurface);
75 IDirect3DDevice9Ex_Release(This->parentDevice);
76 LeaveCriticalSection(&d3d9_cs);
77
78 HeapFree(GetProcessHeap(), 0, This);
79 }
80 return ref;
81}
82
83/* IDirect3DCubeTexture9 IDirect3DResource9 Interface follow: */
84static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetDevice(LPDIRECT3DCUBETEXTURE9 iface, IDirect3DDevice9** ppDevice) {
85 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
86 IWineD3DDevice *wined3d_device;
87 HRESULT hr;
88 TRACE("(%p) Relay\n" , This);
89
90 EnterCriticalSection(&d3d9_cs);
91 hr = IWineD3DCubeTexture_GetDevice(This->wineD3DCubeTexture, &wined3d_device);
92 if (SUCCEEDED(hr))
93 {
94 IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
95 IWineD3DDevice_Release(wined3d_device);
96 }
97 LeaveCriticalSection(&d3d9_cs);
98 return hr;
99}
100
101static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
102 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
103 HRESULT hr;
104 TRACE("(%p) Relay\n", This);
105
106 EnterCriticalSection(&d3d9_cs);
107 hr = IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
108 LeaveCriticalSection(&d3d9_cs);
109 return hr;
110}
111
112static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
113 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
114 HRESULT hr;
115 TRACE("(%p) Relay\n", This);
116
117 EnterCriticalSection(&d3d9_cs);
118 hr = IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
119 LeaveCriticalSection(&d3d9_cs);
120 return hr;
121}
122
123static HRESULT WINAPI IDirect3DCubeTexture9Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid) {
124 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
125 HRESULT hr;
126 TRACE("(%p) Relay\n", This);
127
128 EnterCriticalSection(&d3d9_cs);
129 hr = IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
130 LeaveCriticalSection(&d3d9_cs);
131 return hr;
132}
133
134static DWORD WINAPI IDirect3DCubeTexture9Impl_SetPriority(LPDIRECT3DCUBETEXTURE9 iface, DWORD PriorityNew) {
135 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
136 DWORD ret;
137 TRACE("(%p) Relay\n", This);
138
139 EnterCriticalSection(&d3d9_cs);
140 ret = IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
141 LeaveCriticalSection(&d3d9_cs);
142 return ret;
143}
144
145static DWORD WINAPI IDirect3DCubeTexture9Impl_GetPriority(LPDIRECT3DCUBETEXTURE9 iface) {
146 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
147 DWORD ret;
148 TRACE("(%p) Relay\n", This);
149
150 EnterCriticalSection(&d3d9_cs);
151 ret = IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
152 LeaveCriticalSection(&d3d9_cs);
153 return ret;
154}
155
156static void WINAPI IDirect3DCubeTexture9Impl_PreLoad(LPDIRECT3DCUBETEXTURE9 iface) {
157 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
158 TRACE("(%p) Relay\n", This);
159
160 EnterCriticalSection(&d3d9_cs);
161 IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
162 LeaveCriticalSection(&d3d9_cs);
163}
164
165static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture9Impl_GetType(LPDIRECT3DCUBETEXTURE9 iface) {
166 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
167 D3DRESOURCETYPE ret;
168 TRACE("(%p) Relay\n", This);
169
170 EnterCriticalSection(&d3d9_cs);
171 ret = IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
172 LeaveCriticalSection(&d3d9_cs);
173 return ret;
174}
175
176/* IDirect3DCubeTexture9 IDirect3DBaseTexture9 Interface follow: */
177static DWORD WINAPI IDirect3DCubeTexture9Impl_SetLOD(LPDIRECT3DCUBETEXTURE9 iface, DWORD LODNew) {
178 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
179 DWORD ret;
180 TRACE("(%p) Relay\n", This);
181
182 EnterCriticalSection(&d3d9_cs);
183 ret = IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
184 LeaveCriticalSection(&d3d9_cs);
185 return ret;
186}
187
188static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLOD(LPDIRECT3DCUBETEXTURE9 iface) {
189 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
190 DWORD ret;
191 TRACE("(%p) Relay\n", This);
192
193 EnterCriticalSection(&d3d9_cs);
194 ret = IWineD3DCubeTexture_GetLOD(This->wineD3DCubeTexture);
195 LeaveCriticalSection(&d3d9_cs);
196 return ret;
197}
198
199static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE9 iface) {
200 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
201 DWORD ret;
202 TRACE("(%p) Relay\n", This);
203
204 EnterCriticalSection(&d3d9_cs);
205 ret = IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
206 LeaveCriticalSection(&d3d9_cs);
207 return ret;
208}
209
210static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
211 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
212 HRESULT hr;
213 TRACE("(%p) Relay\n", This);
214
215 EnterCriticalSection(&d3d9_cs);
216 hr = IWineD3DCubeTexture_SetAutoGenFilterType(This->wineD3DCubeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
217 LeaveCriticalSection(&d3d9_cs);
218 return hr;
219}
220
221static D3DTEXTUREFILTERTYPE WINAPI IDirect3DCubeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface) {
222 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
223 D3DTEXTUREFILTERTYPE ret;
224 TRACE("(%p) Relay\n", This);
225
226 EnterCriticalSection(&d3d9_cs);
227 ret = (D3DTEXTUREFILTERTYPE) IWineD3DCubeTexture_GetAutoGenFilterType(This->wineD3DCubeTexture);
228 LeaveCriticalSection(&d3d9_cs);
229 return ret;
230}
231
232static void WINAPI IDirect3DCubeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DCUBETEXTURE9 iface) {
233 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
234 TRACE("(%p) Relay\n", This);
235
236 EnterCriticalSection(&d3d9_cs);
237 IWineD3DCubeTexture_GenerateMipSubLevels(This->wineD3DCubeTexture);
238 LeaveCriticalSection(&d3d9_cs);
239}
240
241/* IDirect3DCubeTexture9 Interface follow: */
242static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
243 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
244 WINED3DSURFACE_DESC wined3ddesc;
245 HRESULT hr;
246
247 TRACE("(%p) Relay\n", This);
248
249 EnterCriticalSection(&d3d9_cs);
250 hr = IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
251 LeaveCriticalSection(&d3d9_cs);
252
253 if (SUCCEEDED(hr))
254 {
255 pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
256 pDesc->Type = wined3ddesc.resource_type;
257 pDesc->Usage = wined3ddesc.usage;
258 pDesc->Pool = wined3ddesc.pool;
259 pDesc->MultiSampleType = wined3ddesc.multisample_type;
260 pDesc->MultiSampleQuality = wined3ddesc.multisample_quality;
261 pDesc->Width = wined3ddesc.width;
262 pDesc->Height = wined3ddesc.height;
263 }
264
265 return hr;
266}
267
268static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9** ppCubeMapSurface) {
269 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
270 HRESULT hrc = D3D_OK;
271 IWineD3DSurface *mySurface = NULL;
272
273 TRACE("(%p) Relay\n", This);
274
275 EnterCriticalSection(&d3d9_cs);
276 hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
277 if (hrc == D3D_OK && NULL != ppCubeMapSurface) {
278 IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface);
279 IWineD3DCubeTexture_Release(mySurface);
280 }
281 LeaveCriticalSection(&d3d9_cs);
282 return hrc;
283}
284
285static HRESULT WINAPI IDirect3DCubeTexture9Impl_LockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
286 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
287 HRESULT hr;
288 TRACE("(%p) Relay\n", This);
289
290 EnterCriticalSection(&d3d9_cs);
291 hr = IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
292 LeaveCriticalSection(&d3d9_cs);
293 return hr;
294}
295
296static HRESULT WINAPI IDirect3DCubeTexture9Impl_UnlockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level) {
297 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
298 HRESULT hr;
299 TRACE("(%p) Relay\n", This);
300
301 EnterCriticalSection(&d3d9_cs);
302 hr = IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level);
303 LeaveCriticalSection(&d3d9_cs);
304 return hr;
305}
306
307static HRESULT WINAPI IDirect3DCubeTexture9Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
308 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
309 HRESULT hr;
310 TRACE("(%p) Relay\n", This);
311
312 EnterCriticalSection(&d3d9_cs);
313 hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect);
314 LeaveCriticalSection(&d3d9_cs);
315 return hr;
316}
317
318
319static const IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl =
320{
321 /* IUnknown */
322 IDirect3DCubeTexture9Impl_QueryInterface,
323 IDirect3DCubeTexture9Impl_AddRef,
324 IDirect3DCubeTexture9Impl_Release,
325 /* IDirect3DResource9 */
326 IDirect3DCubeTexture9Impl_GetDevice,
327 IDirect3DCubeTexture9Impl_SetPrivateData,
328 IDirect3DCubeTexture9Impl_GetPrivateData,
329 IDirect3DCubeTexture9Impl_FreePrivateData,
330 IDirect3DCubeTexture9Impl_SetPriority,
331 IDirect3DCubeTexture9Impl_GetPriority,
332 IDirect3DCubeTexture9Impl_PreLoad,
333 IDirect3DCubeTexture9Impl_GetType,
334 /* IDirect3DBaseTexture9 */
335 IDirect3DCubeTexture9Impl_SetLOD,
336 IDirect3DCubeTexture9Impl_GetLOD,
337 IDirect3DCubeTexture9Impl_GetLevelCount,
338 IDirect3DCubeTexture9Impl_SetAutoGenFilterType,
339 IDirect3DCubeTexture9Impl_GetAutoGenFilterType,
340 IDirect3DCubeTexture9Impl_GenerateMipSubLevels,
341 IDirect3DCubeTexture9Impl_GetLevelDesc,
342 IDirect3DCubeTexture9Impl_GetCubeMapSurface,
343 IDirect3DCubeTexture9Impl_LockRect,
344 IDirect3DCubeTexture9Impl_UnlockRect,
345 IDirect3DCubeTexture9Impl_AddDirtyRect
346};
347
348
349
350
351/* IDirect3DDevice9 IDirect3DCubeTexture9 Methods follow: */
352HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9EX iface,
353 UINT EdgeLength, UINT Levels, DWORD Usage,
354 D3DFORMAT Format, D3DPOOL Pool,
355 IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) {
356
357 IDirect3DCubeTexture9Impl *object;
358 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
359 HRESULT hr = D3D_OK;
360
361 TRACE("(%p) : ELen(%d) Lvl(%d) Usage(%d) fmt(%u), Pool(%d) Shared(%p)\n", This, EdgeLength, Levels, Usage, Format, Pool, pSharedHandle);
362
363 /* Allocate the storage for the device */
364 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
365
366 if (NULL == object) {
367 ERR("(%p) allocation of CubeTexture failed\n", This);
368 return D3DERR_OUTOFVIDEOMEMORY;
369 }
370 object->lpVtbl = &Direct3DCubeTexture9_Vtbl;
371 object->ref = 1;
372 EnterCriticalSection(&d3d9_cs);
373 hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage,
374 wined3dformat_from_d3dformat(Format), Pool, &object->wineD3DCubeTexture, (IUnknown *)object);
375 LeaveCriticalSection(&d3d9_cs);
376
377 if (hr != D3D_OK){
378
379 /* free up object */
380 WARN("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This);
381 HeapFree(GetProcessHeap(), 0, object);
382 } else {
383 IDirect3DDevice9Ex_AddRef(iface);
384 object->parentDevice = iface;
385 *ppCubeTexture = (LPDIRECT3DCUBETEXTURE9) object;
386 TRACE("(%p) : Created cube texture %p\n", This, object);
387 }
388
389 TRACE("(%p) returning %p\n",This, *ppCubeTexture);
390 return hr;
391}
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