VirtualBox

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

Last change on this file since 29775 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: 14.6 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
42 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
43
44 if (IsEqualGUID(riid, &IID_IUnknown)
45 || IsEqualGUID(riid, &IID_IDirect3DResource9)
46 || IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)
47 || IsEqualGUID(riid, &IID_IDirect3DCubeTexture9)) {
48 IDirect3DCubeTexture9_AddRef(iface);
49 *ppobj = This;
50 return S_OK;
51 }
52
53 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
54 *ppobj = NULL;
55 return E_NOINTERFACE;
56}
57
58static ULONG WINAPI IDirect3DCubeTexture9Impl_AddRef(LPDIRECT3DCUBETEXTURE9 iface) {
59 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
60 ULONG ref = InterlockedIncrement(&This->ref);
61
62 TRACE("%p increasing refcount to %u.\n", iface, ref);
63
64 if (ref == 1)
65 {
66 IDirect3DDevice9Ex_AddRef(This->parentDevice);
67 wined3d_mutex_lock();
68 IWineD3DCubeTexture_AddRef(This->wineD3DCubeTexture);
69 wined3d_mutex_unlock();
70 }
71
72 return ref;
73}
74
75static ULONG WINAPI IDirect3DCubeTexture9Impl_Release(LPDIRECT3DCUBETEXTURE9 iface) {
76 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
77 ULONG ref = InterlockedDecrement(&This->ref);
78
79 TRACE("%p decreasing refcount to %u.\n", iface, ref);
80
81 if (ref == 0) {
82 IDirect3DDevice9Ex *parentDevice = This->parentDevice;
83
84 TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
85
86 wined3d_mutex_lock();
87 IWineD3DCubeTexture_Release(This->wineD3DCubeTexture);
88 wined3d_mutex_unlock();
89
90 /* Release the device last, as it may cause the device to be destroyed. */
91 IDirect3DDevice9Ex_Release(parentDevice);
92 }
93 return ref;
94}
95
96/* IDirect3DCubeTexture9 IDirect3DResource9 Interface follow: */
97static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetDevice(IDirect3DCubeTexture9 *iface, IDirect3DDevice9 **device)
98{
99 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
100
101 TRACE("iface %p, device %p.\n", iface, device);
102
103 *device = (IDirect3DDevice9 *)This->parentDevice;
104 IDirect3DDevice9_AddRef(*device);
105
106 TRACE("Returning device %p.\n", *device);
107
108 return D3D_OK;
109}
110
111static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
112 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
113 HRESULT hr;
114
115 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
116 iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
117
118 wined3d_mutex_lock();
119 hr = IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
120 wined3d_mutex_unlock();
121
122 return hr;
123}
124
125static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
126 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
127 HRESULT hr;
128
129 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
130 iface, debugstr_guid(refguid), pData, pSizeOfData);
131
132 wined3d_mutex_lock();
133 hr = IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
134 wined3d_mutex_unlock();
135
136 return hr;
137}
138
139static HRESULT WINAPI IDirect3DCubeTexture9Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid) {
140 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
141 HRESULT hr;
142
143 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
144
145 wined3d_mutex_lock();
146 hr = IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
147 wined3d_mutex_unlock();
148
149 return hr;
150}
151
152static DWORD WINAPI IDirect3DCubeTexture9Impl_SetPriority(LPDIRECT3DCUBETEXTURE9 iface, DWORD PriorityNew) {
153 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
154 DWORD ret;
155
156 TRACE("iface %p, priority %u.\n", iface, PriorityNew);
157
158 wined3d_mutex_lock();
159 ret = IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
160 wined3d_mutex_unlock();
161
162 return ret;
163}
164
165static DWORD WINAPI IDirect3DCubeTexture9Impl_GetPriority(LPDIRECT3DCUBETEXTURE9 iface) {
166 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
167 DWORD ret;
168
169 TRACE("iface %p.\n", iface);
170
171 wined3d_mutex_lock();
172 ret = IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
173 wined3d_mutex_unlock();
174
175 return ret;
176}
177
178static void WINAPI IDirect3DCubeTexture9Impl_PreLoad(LPDIRECT3DCUBETEXTURE9 iface) {
179 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
180
181 TRACE("iface %p.\n", iface);
182
183 wined3d_mutex_lock();
184 IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
185 wined3d_mutex_unlock();
186}
187
188static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture9Impl_GetType(LPDIRECT3DCUBETEXTURE9 iface) {
189 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
190 D3DRESOURCETYPE ret;
191
192 TRACE("iface %p.\n", iface);
193
194 wined3d_mutex_lock();
195 ret = IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
196 wined3d_mutex_unlock();
197
198 return ret;
199}
200
201/* IDirect3DCubeTexture9 IDirect3DBaseTexture9 Interface follow: */
202static DWORD WINAPI IDirect3DCubeTexture9Impl_SetLOD(LPDIRECT3DCUBETEXTURE9 iface, DWORD LODNew) {
203 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
204 DWORD ret;
205
206 TRACE("iface %p, lod %u.\n", iface, LODNew);
207
208 wined3d_mutex_lock();
209 ret = IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
210 wined3d_mutex_unlock();
211
212 return ret;
213}
214
215static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLOD(LPDIRECT3DCUBETEXTURE9 iface) {
216 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
217 DWORD ret;
218
219 TRACE("iface %p.\n", iface);
220
221 wined3d_mutex_lock();
222 ret = IWineD3DCubeTexture_GetLOD(This->wineD3DCubeTexture);
223 wined3d_mutex_unlock();
224
225 return ret;
226}
227
228static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE9 iface) {
229 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
230 DWORD ret;
231
232 TRACE("iface %p.\n", iface);
233
234 wined3d_mutex_lock();
235 ret = IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
236 wined3d_mutex_unlock();
237
238 return ret;
239}
240
241static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
242 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
243 HRESULT hr;
244
245 TRACE("iface %p, filter_type %#x.\n", iface, FilterType);
246
247 wined3d_mutex_lock();
248 hr = IWineD3DCubeTexture_SetAutoGenFilterType(This->wineD3DCubeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
249 wined3d_mutex_unlock();
250
251 return hr;
252}
253
254static D3DTEXTUREFILTERTYPE WINAPI IDirect3DCubeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface) {
255 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
256 D3DTEXTUREFILTERTYPE ret;
257
258 TRACE("iface %p.\n", iface);
259
260 wined3d_mutex_lock();
261 ret = (D3DTEXTUREFILTERTYPE) IWineD3DCubeTexture_GetAutoGenFilterType(This->wineD3DCubeTexture);
262 wined3d_mutex_unlock();
263
264 return ret;
265}
266
267static void WINAPI IDirect3DCubeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DCUBETEXTURE9 iface) {
268 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
269
270 TRACE("iface %p.\n", iface);
271
272 wined3d_mutex_lock();
273 IWineD3DCubeTexture_GenerateMipSubLevels(This->wineD3DCubeTexture);
274 wined3d_mutex_unlock();
275}
276
277/* IDirect3DCubeTexture9 Interface follow: */
278static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
279 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
280 WINED3DSURFACE_DESC wined3ddesc;
281 HRESULT hr;
282
283 TRACE("iface %p, level %u, desc %p.\n", iface, Level, pDesc);
284
285 wined3d_mutex_lock();
286 hr = IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
287 wined3d_mutex_unlock();
288
289 if (SUCCEEDED(hr))
290 {
291 pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
292 pDesc->Type = wined3ddesc.resource_type;
293 pDesc->Usage = wined3ddesc.usage;
294 pDesc->Pool = wined3ddesc.pool;
295 pDesc->MultiSampleType = wined3ddesc.multisample_type;
296 pDesc->MultiSampleQuality = wined3ddesc.multisample_quality;
297 pDesc->Width = wined3ddesc.width;
298 pDesc->Height = wined3ddesc.height;
299 }
300
301 return hr;
302}
303
304static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9** ppCubeMapSurface) {
305 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
306 HRESULT hrc = D3D_OK;
307 IWineD3DSurface *mySurface = NULL;
308
309 TRACE("iface %p, face %#x, level %u, surface %p.\n", iface, FaceType, Level, ppCubeMapSurface);
310
311 wined3d_mutex_lock();
312 hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
313 if (hrc == D3D_OK && NULL != ppCubeMapSurface) {
314 IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface);
315 IWineD3DCubeTexture_Release(mySurface);
316 }
317 wined3d_mutex_unlock();
318
319 return hrc;
320}
321
322static HRESULT WINAPI IDirect3DCubeTexture9Impl_LockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
323 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
324 HRESULT hr;
325
326 TRACE("iface %p, face %#x, level %u, locked_rect %p, rect %p, flags %#x.\n",
327 iface, FaceType, Level, pLockedRect, pRect, Flags);
328
329 wined3d_mutex_lock();
330 hr = IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
331 wined3d_mutex_unlock();
332
333 return hr;
334}
335
336static HRESULT WINAPI IDirect3DCubeTexture9Impl_UnlockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level) {
337 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
338 HRESULT hr;
339
340 TRACE("iface %p, face %#x, level %u.\n", iface, FaceType, Level);
341
342 wined3d_mutex_lock();
343 hr = IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level);
344 wined3d_mutex_unlock();
345
346 return hr;
347}
348
349static HRESULT WINAPI IDirect3DCubeTexture9Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
350 IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
351 HRESULT hr;
352
353 TRACE("iface %p, face %#x, dirty_rect %p.\n", iface, FaceType, pDirtyRect);
354
355 wined3d_mutex_lock();
356 hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect);
357 wined3d_mutex_unlock();
358
359 return hr;
360}
361
362
363static const IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl =
364{
365 /* IUnknown */
366 IDirect3DCubeTexture9Impl_QueryInterface,
367 IDirect3DCubeTexture9Impl_AddRef,
368 IDirect3DCubeTexture9Impl_Release,
369 /* IDirect3DResource9 */
370 IDirect3DCubeTexture9Impl_GetDevice,
371 IDirect3DCubeTexture9Impl_SetPrivateData,
372 IDirect3DCubeTexture9Impl_GetPrivateData,
373 IDirect3DCubeTexture9Impl_FreePrivateData,
374 IDirect3DCubeTexture9Impl_SetPriority,
375 IDirect3DCubeTexture9Impl_GetPriority,
376 IDirect3DCubeTexture9Impl_PreLoad,
377 IDirect3DCubeTexture9Impl_GetType,
378 /* IDirect3DBaseTexture9 */
379 IDirect3DCubeTexture9Impl_SetLOD,
380 IDirect3DCubeTexture9Impl_GetLOD,
381 IDirect3DCubeTexture9Impl_GetLevelCount,
382 IDirect3DCubeTexture9Impl_SetAutoGenFilterType,
383 IDirect3DCubeTexture9Impl_GetAutoGenFilterType,
384 IDirect3DCubeTexture9Impl_GenerateMipSubLevels,
385 IDirect3DCubeTexture9Impl_GetLevelDesc,
386 IDirect3DCubeTexture9Impl_GetCubeMapSurface,
387 IDirect3DCubeTexture9Impl_LockRect,
388 IDirect3DCubeTexture9Impl_UnlockRect,
389 IDirect3DCubeTexture9Impl_AddDirtyRect
390};
391
392static void STDMETHODCALLTYPE cubetexture_wined3d_object_destroyed(void *parent)
393{
394 HeapFree(GetProcessHeap(), 0, parent);
395}
396
397static const struct wined3d_parent_ops d3d9_cubetexture_wined3d_parent_ops =
398{
399 cubetexture_wined3d_object_destroyed,
400};
401
402HRESULT cubetexture_init(IDirect3DCubeTexture9Impl *texture, IDirect3DDevice9Impl *device,
403 UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
404{
405 HRESULT hr;
406
407 texture->lpVtbl = &Direct3DCubeTexture9_Vtbl;
408 texture->ref = 1;
409
410 wined3d_mutex_lock();
411 hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length, levels, usage,
412 wined3dformat_from_d3dformat(format), pool, &texture->wineD3DCubeTexture,
413 (IUnknown *)texture, &d3d9_cubetexture_wined3d_parent_ops);
414 wined3d_mutex_unlock();
415 if (FAILED(hr))
416 {
417 WARN("Failed to create wined3d cube texture, hr %#x.\n", hr);
418 return hr;
419 }
420
421 texture->parentDevice = (IDirect3DDevice9Ex *)device;
422 IDirect3DDevice9Ex_AddRef(texture->parentDevice);
423
424 return D3D_OK;
425}
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