2 * IDirect3DVolumeTexture8 implementation
4 * Copyright 2005 Oliver Stieber
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.
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.
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
22 #include "d3d8_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8
);
26 /* IDirect3DVolumeTexture8 IUnknown parts follow: */
27 static HRESULT WINAPI
IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE8 iface
, REFIID riid
, LPVOID
*ppobj
) {
28 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
30 if (IsEqualGUID(riid
, &IID_IUnknown
)
31 || IsEqualGUID(riid
, &IID_IDirect3DResource8
)
32 || IsEqualGUID(riid
, &IID_IDirect3DBaseTexture8
)
33 || IsEqualGUID(riid
, &IID_IDirect3DVolumeTexture8
)) {
34 IUnknown_AddRef(iface
);
39 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
44 static ULONG WINAPI
IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface
) {
45 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
46 ULONG ref
= InterlockedIncrement(&This
->ref
);
48 TRACE("(%p) : AddRef from %d\n", This
, ref
- 1);
53 static ULONG WINAPI
IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface
) {
54 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
55 ULONG ref
= InterlockedDecrement(&This
->ref
);
57 TRACE("(%p) : ReleaseRef to %d\n", This
, ref
);
60 EnterCriticalSection(&d3d8_cs
);
61 IWineD3DVolumeTexture_Destroy(This
->wineD3DVolumeTexture
, D3D8CB_DestroyVolume
);
62 LeaveCriticalSection(&d3d8_cs
);
63 IUnknown_Release(This
->parentDevice
);
64 HeapFree(GetProcessHeap(), 0, This
);
69 /* IDirect3DVolumeTexture8 IDirect3DResource8 Interface follow: */
70 static HRESULT WINAPI
IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE8 iface
, IDirect3DDevice8
**ppDevice
) {
71 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
72 IWineD3DDevice
*wined3d_device
;
74 TRACE("(%p) Relay\n", This
);
76 EnterCriticalSection(&d3d8_cs
);
77 hr
= IWineD3DVolumeTexture_GetDevice(This
->wineD3DVolumeTexture
, &wined3d_device
);
80 IWineD3DDevice_GetParent(wined3d_device
, (IUnknown
**)ppDevice
);
81 IWineD3DDevice_Release(wined3d_device
);
83 LeaveCriticalSection(&d3d8_cs
);
87 static HRESULT WINAPI
IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface
, REFGUID refguid
, CONST
void* pData
, DWORD SizeOfData
, DWORD Flags
) {
88 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
90 TRACE("(%p) Relay\n", This
);
92 EnterCriticalSection(&d3d8_cs
);
93 hr
= IWineD3DVolumeTexture_SetPrivateData(This
->wineD3DVolumeTexture
, refguid
, pData
, SizeOfData
, Flags
);
94 LeaveCriticalSection(&d3d8_cs
);
98 static HRESULT WINAPI
IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface
, REFGUID refguid
, void *pData
, DWORD
*pSizeOfData
) {
99 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
101 TRACE("(%p) Relay\n", This
);
103 EnterCriticalSection(&d3d8_cs
);
104 hr
= IWineD3DVolumeTexture_GetPrivateData(This
->wineD3DVolumeTexture
, refguid
, pData
, pSizeOfData
);
105 LeaveCriticalSection(&d3d8_cs
);
109 static HRESULT WINAPI
IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE8 iface
, REFGUID refguid
) {
110 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
112 TRACE("(%p) Relay\n", This
);
114 EnterCriticalSection(&d3d8_cs
);
115 hr
= IWineD3DVolumeTexture_FreePrivateData(This
->wineD3DVolumeTexture
, refguid
);
116 LeaveCriticalSection(&d3d8_cs
);
120 static DWORD WINAPI
IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE8 iface
, DWORD PriorityNew
) {
121 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
123 TRACE("(%p) Relay\n", This
);
125 EnterCriticalSection(&d3d8_cs
);
126 ret
= IWineD3DVolumeTexture_SetPriority(This
->wineD3DVolumeTexture
, PriorityNew
);
127 LeaveCriticalSection(&d3d8_cs
);
131 static DWORD WINAPI
IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE8 iface
) {
132 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
134 TRACE("(%p) Relay\n", This
);
136 EnterCriticalSection(&d3d8_cs
);
137 ret
= IWineD3DVolumeTexture_GetPriority(This
->wineD3DVolumeTexture
);
138 LeaveCriticalSection(&d3d8_cs
);
142 static void WINAPI
IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface
) {
143 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
144 TRACE("(%p) Relay\n", This
);
146 EnterCriticalSection(&d3d8_cs
);
147 IWineD3DVolumeTexture_PreLoad(This
->wineD3DVolumeTexture
);
148 LeaveCriticalSection(&d3d8_cs
);
151 static D3DRESOURCETYPE WINAPI
IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface
) {
152 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
153 D3DRESOURCETYPE type
;
154 TRACE("(%p) Relay\n", This
);
156 EnterCriticalSection(&d3d8_cs
);
157 type
= IWineD3DVolumeTexture_GetType(This
->wineD3DVolumeTexture
);
158 LeaveCriticalSection(&d3d8_cs
);
162 /* IDirect3DVolumeTexture8 IDirect3DBaseTexture8 Interface follow: */
163 static DWORD WINAPI
IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface
, DWORD LODNew
) {
164 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
166 TRACE("(%p) Relay\n", This
);
168 EnterCriticalSection(&d3d8_cs
);
169 ret
= IWineD3DVolumeTexture_SetLOD(This
->wineD3DVolumeTexture
, LODNew
);
170 LeaveCriticalSection(&d3d8_cs
);
174 static DWORD WINAPI
IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface
) {
175 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
177 TRACE("(%p) Relay\n", This
);
179 EnterCriticalSection(&d3d8_cs
);
180 ret
= IWineD3DVolumeTexture_GetLOD(This
->wineD3DVolumeTexture
);
181 LeaveCriticalSection(&d3d8_cs
);
185 static DWORD WINAPI
IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface
) {
186 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
188 TRACE("(%p) Relay\n", This
);
190 EnterCriticalSection(&d3d8_cs
);
191 ret
= IWineD3DVolumeTexture_GetLevelCount(This
->wineD3DVolumeTexture
);
192 LeaveCriticalSection(&d3d8_cs
);
196 /* IDirect3DVolumeTexture8 Interface follow: */
197 static HRESULT WINAPI
IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface
, UINT Level
, D3DVOLUME_DESC
* pDesc
) {
198 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
199 WINED3DVOLUME_DESC wined3ddesc
;
203 TRACE("(%p) Relay\n", This
);
205 /* As d3d8 and d3d8 structures differ, pass in ptrs to where data needs to go */
206 wined3ddesc
.Format
= (WINED3DFORMAT
*)&pDesc
->Format
;
207 wined3ddesc
.Type
= (WINED3DRESOURCETYPE
*)&pDesc
->Type
;
208 wined3ddesc
.Usage
= &pDesc
->Usage
;
209 wined3ddesc
.Pool
= (WINED3DPOOL
*) &pDesc
->Pool
;
210 wined3ddesc
.Size
= &tmpInt
;
211 wined3ddesc
.Width
= &pDesc
->Width
;
212 wined3ddesc
.Height
= &pDesc
->Height
;
213 wined3ddesc
.Depth
= &pDesc
->Depth
;
215 EnterCriticalSection(&d3d8_cs
);
216 hr
= IWineD3DVolumeTexture_GetLevelDesc(This
->wineD3DVolumeTexture
, Level
, &wined3ddesc
);
217 LeaveCriticalSection(&d3d8_cs
);
219 if (SUCCEEDED(hr
)) pDesc
->Format
= d3dformat_from_wined3dformat(pDesc
->Format
);
224 static HRESULT WINAPI
IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface
, UINT Level
, IDirect3DVolume8
**ppVolumeLevel
) {
225 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
226 HRESULT hrc
= D3D_OK
;
227 IWineD3DVolume
*myVolume
= NULL
;
229 TRACE("(%p) Relay\n", This
);
231 EnterCriticalSection(&d3d8_cs
);
232 hrc
= IWineD3DVolumeTexture_GetVolumeLevel(This
->wineD3DVolumeTexture
, Level
, &myVolume
);
233 if (hrc
== D3D_OK
&& NULL
!= ppVolumeLevel
) {
234 IWineD3DVolumeTexture_GetParent(myVolume
, (IUnknown
**)ppVolumeLevel
);
235 IWineD3DVolumeTexture_Release(myVolume
);
237 LeaveCriticalSection(&d3d8_cs
);
241 static HRESULT WINAPI
IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface
, UINT Level
, D3DLOCKED_BOX
*pLockedVolume
, CONST D3DBOX
*pBox
, DWORD Flags
) {
242 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
244 TRACE("(%p) Relay %p %p %p %d\n", This
, This
->wineD3DVolumeTexture
, pLockedVolume
, pBox
,Flags
);
246 EnterCriticalSection(&d3d8_cs
);
247 hr
= IWineD3DVolumeTexture_LockBox(This
->wineD3DVolumeTexture
, Level
, (WINED3DLOCKED_BOX
*) pLockedVolume
, (CONST WINED3DBOX
*) pBox
, Flags
);
248 LeaveCriticalSection(&d3d8_cs
);
252 static HRESULT WINAPI
IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface
, UINT Level
) {
253 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
255 TRACE("(%p) Relay %p %d\n", This
, This
->wineD3DVolumeTexture
, Level
);
257 EnterCriticalSection(&d3d8_cs
);
258 hr
= IWineD3DVolumeTexture_UnlockBox(This
->wineD3DVolumeTexture
, Level
);
259 LeaveCriticalSection(&d3d8_cs
);
263 static HRESULT WINAPI
IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface
, CONST D3DBOX
*pDirtyBox
) {
264 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
266 TRACE("(%p) Relay\n", This
);
268 EnterCriticalSection(&d3d8_cs
);
269 hr
= IWineD3DVolumeTexture_AddDirtyBox(This
->wineD3DVolumeTexture
, (CONST WINED3DBOX
*) pDirtyBox
);
270 LeaveCriticalSection(&d3d8_cs
);
275 const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl
=
278 IDirect3DVolumeTexture8Impl_QueryInterface
,
279 IDirect3DVolumeTexture8Impl_AddRef
,
280 IDirect3DVolumeTexture8Impl_Release
,
281 /* IDirect3DResource8 */
282 IDirect3DVolumeTexture8Impl_GetDevice
,
283 IDirect3DVolumeTexture8Impl_SetPrivateData
,
284 IDirect3DVolumeTexture8Impl_GetPrivateData
,
285 IDirect3DVolumeTexture8Impl_FreePrivateData
,
286 IDirect3DVolumeTexture8Impl_SetPriority
,
287 IDirect3DVolumeTexture8Impl_GetPriority
,
288 IDirect3DVolumeTexture8Impl_PreLoad
,
289 IDirect3DVolumeTexture8Impl_GetType
,
290 /* IDirect3DBaseTexture8 */
291 IDirect3DVolumeTexture8Impl_SetLOD
,
292 IDirect3DVolumeTexture8Impl_GetLOD
,
293 IDirect3DVolumeTexture8Impl_GetLevelCount
,
294 /* IDirect3DVolumeTexture8 */
295 IDirect3DVolumeTexture8Impl_GetLevelDesc
,
296 IDirect3DVolumeTexture8Impl_GetVolumeLevel
,
297 IDirect3DVolumeTexture8Impl_LockBox
,
298 IDirect3DVolumeTexture8Impl_UnlockBox
,
299 IDirect3DVolumeTexture8Impl_AddDirtyBox