VirtualBox

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

Last change on this file since 16684 was 16477, checked in by vboxsync, 16 years ago

LGPL disclaimer by filemuncher

  • Property svn:eol-style set to native
File size: 15.0 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 HRESULT hr;
87 TRACE("(%p) Relay\n" , This);
88
89 EnterCriticalSection(&d3d9_cs);
90 hr = IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
91 LeaveCriticalSection(&d3d9_cs);
92 return hr;
93}
94
95static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
96 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
97 HRESULT hr;
98 TRACE("(%p) Relay\n", This);
99
100 EnterCriticalSection(&d3d9_cs);
101 hr = IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
102 LeaveCriticalSection(&d3d9_cs);
103 return hr;
104}
105
106static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
107 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
108 HRESULT hr;
109 TRACE("(%p) Relay\n", This);
110
111 EnterCriticalSection(&d3d9_cs);
112 hr = IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
113 LeaveCriticalSection(&d3d9_cs);
114 return hr;
115}
116
117static HRESULT WINAPI IDirect3DCubeTexture9Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid) {
118 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
119 HRESULT hr;
120 TRACE("(%p) Relay\n", This);
121
122 EnterCriticalSection(&d3d9_cs);
123 hr = IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
124 LeaveCriticalSection(&d3d9_cs);
125 return hr;
126}
127
128static DWORD WINAPI IDirect3DCubeTexture9Impl_SetPriority(LPDIRECT3DCUBETEXTURE9 iface, DWORD PriorityNew) {
129 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
130 DWORD ret;
131 TRACE("(%p) Relay\n", This);
132
133 EnterCriticalSection(&d3d9_cs);
134 ret = IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
135 LeaveCriticalSection(&d3d9_cs);
136 return ret;
137}
138
139static DWORD WINAPI IDirect3DCubeTexture9Impl_GetPriority(LPDIRECT3DCUBETEXTURE9 iface) {
140 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
141 DWORD ret;
142 TRACE("(%p) Relay\n", This);
143
144 EnterCriticalSection(&d3d9_cs);
145 ret = IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
146 LeaveCriticalSection(&d3d9_cs);
147 return ret;
148}
149
150static void WINAPI IDirect3DCubeTexture9Impl_PreLoad(LPDIRECT3DCUBETEXTURE9 iface) {
151 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
152 TRACE("(%p) Relay\n", This);
153
154 EnterCriticalSection(&d3d9_cs);
155 IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
156 LeaveCriticalSection(&d3d9_cs);
157}
158
159static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture9Impl_GetType(LPDIRECT3DCUBETEXTURE9 iface) {
160 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
161 D3DRESOURCETYPE ret;
162 TRACE("(%p) Relay\n", This);
163
164 EnterCriticalSection(&d3d9_cs);
165 ret = IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
166 LeaveCriticalSection(&d3d9_cs);
167 return ret;
168}
169
170/* IDirect3DCubeTexture9 IDirect3DBaseTexture9 Interface follow: */
171static DWORD WINAPI IDirect3DCubeTexture9Impl_SetLOD(LPDIRECT3DCUBETEXTURE9 iface, DWORD LODNew) {
172 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
173 DWORD ret;
174 TRACE("(%p) Relay\n", This);
175
176 EnterCriticalSection(&d3d9_cs);
177 ret = IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
178 LeaveCriticalSection(&d3d9_cs);
179 return ret;
180}
181
182static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLOD(LPDIRECT3DCUBETEXTURE9 iface) {
183 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
184 DWORD ret;
185 TRACE("(%p) Relay\n", This);
186
187 EnterCriticalSection(&d3d9_cs);
188 ret = IDirect3DBaseTexture9Impl_GetLOD((LPDIRECT3DBASETEXTURE9) This);
189 LeaveCriticalSection(&d3d9_cs);
190 return ret;
191}
192
193static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE9 iface) {
194 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
195 DWORD ret;
196 TRACE("(%p) Relay\n", This);
197
198 EnterCriticalSection(&d3d9_cs);
199 ret = IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
200 LeaveCriticalSection(&d3d9_cs);
201 return ret;
202}
203
204static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
205 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
206 HRESULT hr;
207 TRACE("(%p) Relay\n", This);
208
209 EnterCriticalSection(&d3d9_cs);
210 hr = IWineD3DCubeTexture_SetAutoGenFilterType(This->wineD3DCubeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
211 LeaveCriticalSection(&d3d9_cs);
212 return hr;
213}
214
215static D3DTEXTUREFILTERTYPE WINAPI IDirect3DCubeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface) {
216 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
217 D3DTEXTUREFILTERTYPE ret;
218 TRACE("(%p) Relay\n", This);
219
220 EnterCriticalSection(&d3d9_cs);
221 ret = (D3DTEXTUREFILTERTYPE) IWineD3DCubeTexture_GetAutoGenFilterType(This->wineD3DCubeTexture);
222 LeaveCriticalSection(&d3d9_cs);
223 return ret;
224}
225
226static void WINAPI IDirect3DCubeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DCUBETEXTURE9 iface) {
227 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
228 TRACE("(%p) Relay\n", This);
229
230 EnterCriticalSection(&d3d9_cs);
231 IWineD3DCubeTexture_GenerateMipSubLevels(This->wineD3DCubeTexture);
232 LeaveCriticalSection(&d3d9_cs);
233}
234
235/* IDirect3DCubeTexture9 Interface follow: */
236static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
237 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
238 WINED3DSURFACE_DESC wined3ddesc;
239 UINT tmpInt = -1;
240 HRESULT hr;
241
242 TRACE("(%p) Relay\n", This);
243
244 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
245 wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
246 wined3ddesc.Type = (WINED3DRESOURCETYPE *) &pDesc->Type;
247 wined3ddesc.Usage = &pDesc->Usage;
248 wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
249 wined3ddesc.Size = &tmpInt;
250 wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
251 wined3ddesc.MultiSampleQuality = &pDesc->MultiSampleQuality;
252 wined3ddesc.Width = &pDesc->Width;
253 wined3ddesc.Height = &pDesc->Height;
254
255 EnterCriticalSection(&d3d9_cs);
256 hr = IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
257 LeaveCriticalSection(&d3d9_cs);
258 return hr;
259}
260
261static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9** ppCubeMapSurface) {
262 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
263 HRESULT hrc = D3D_OK;
264 IWineD3DSurface *mySurface = NULL;
265
266 TRACE("(%p) Relay\n", This);
267
268 EnterCriticalSection(&d3d9_cs);
269 hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
270 if (hrc == D3D_OK && NULL != ppCubeMapSurface) {
271 IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface);
272 IWineD3DCubeTexture_Release(mySurface);
273 }
274 LeaveCriticalSection(&d3d9_cs);
275 return hrc;
276}
277
278static HRESULT WINAPI IDirect3DCubeTexture9Impl_LockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
279 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
280 HRESULT hr;
281 TRACE("(%p) Relay\n", This);
282
283 EnterCriticalSection(&d3d9_cs);
284 hr = IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
285 LeaveCriticalSection(&d3d9_cs);
286 return hr;
287}
288
289static HRESULT WINAPI IDirect3DCubeTexture9Impl_UnlockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level) {
290 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
291 HRESULT hr;
292 TRACE("(%p) Relay\n", This);
293
294 EnterCriticalSection(&d3d9_cs);
295 hr = IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level);
296 LeaveCriticalSection(&d3d9_cs);
297 return hr;
298}
299
300static HRESULT WINAPI IDirect3DCubeTexture9Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
301 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
302 HRESULT hr;
303 TRACE("(%p) Relay\n", This);
304
305 EnterCriticalSection(&d3d9_cs);
306 hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect);
307 LeaveCriticalSection(&d3d9_cs);
308 return hr;
309}
310
311
312static const IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl =
313{
314 /* IUnknown */
315 IDirect3DCubeTexture9Impl_QueryInterface,
316 IDirect3DCubeTexture9Impl_AddRef,
317 IDirect3DCubeTexture9Impl_Release,
318 /* IDirect3DResource9 */
319 IDirect3DCubeTexture9Impl_GetDevice,
320 IDirect3DCubeTexture9Impl_SetPrivateData,
321 IDirect3DCubeTexture9Impl_GetPrivateData,
322 IDirect3DCubeTexture9Impl_FreePrivateData,
323 IDirect3DCubeTexture9Impl_SetPriority,
324 IDirect3DCubeTexture9Impl_GetPriority,
325 IDirect3DCubeTexture9Impl_PreLoad,
326 IDirect3DCubeTexture9Impl_GetType,
327 /* IDirect3DBaseTexture9 */
328 IDirect3DCubeTexture9Impl_SetLOD,
329 IDirect3DCubeTexture9Impl_GetLOD,
330 IDirect3DCubeTexture9Impl_GetLevelCount,
331 IDirect3DCubeTexture9Impl_SetAutoGenFilterType,
332 IDirect3DCubeTexture9Impl_GetAutoGenFilterType,
333 IDirect3DCubeTexture9Impl_GenerateMipSubLevels,
334 IDirect3DCubeTexture9Impl_GetLevelDesc,
335 IDirect3DCubeTexture9Impl_GetCubeMapSurface,
336 IDirect3DCubeTexture9Impl_LockRect,
337 IDirect3DCubeTexture9Impl_UnlockRect,
338 IDirect3DCubeTexture9Impl_AddDirtyRect
339};
340
341
342
343
344/* IDirect3DDevice9 IDirect3DCubeTexture9 Methods follow: */
345HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9EX iface,
346 UINT EdgeLength, UINT Levels, DWORD Usage,
347 D3DFORMAT Format, D3DPOOL Pool,
348 IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) {
349
350 IDirect3DCubeTexture9Impl *object;
351 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
352 HRESULT hr = D3D_OK;
353
354 TRACE("(%p) : ELen(%d) Lvl(%d) Usage(%d) fmt(%u), Pool(%d) Shared(%p)\n", This, EdgeLength, Levels, Usage, Format, Pool, pSharedHandle);
355
356 /* Allocate the storage for the device */
357 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
358
359 if (NULL == object) {
360 FIXME("(%p) allocation of CubeTexture failed\n", This);
361 return D3DERR_OUTOFVIDEOMEMORY;
362 }
363 object->lpVtbl = &Direct3DCubeTexture9_Vtbl;
364 object->ref = 1;
365 EnterCriticalSection(&d3d9_cs);
366 hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage,
367 (WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DCubeTexture, pSharedHandle, (IUnknown*)object,
368 D3D9CB_CreateSurface);
369 LeaveCriticalSection(&d3d9_cs);
370
371 if (hr != D3D_OK){
372
373 /* free up object */
374 FIXME("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This);
375 HeapFree(GetProcessHeap(), 0, object);
376 } else {
377 IDirect3DDevice9Ex_AddRef(iface);
378 object->parentDevice = iface;
379 *ppCubeTexture = (LPDIRECT3DCUBETEXTURE9) object;
380 TRACE("(%p) : Created cube texture %p\n", This, object);
381 }
382
383 TRACE("(%p) returning %p\n",This, *ppCubeTexture);
384 return hr;
385}
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