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
;
202 TRACE("(%p) Relay\n", This
);
204 EnterCriticalSection(&d3d8_cs
);
205 hr
= IWineD3DVolumeTexture_GetLevelDesc(This
->wineD3DVolumeTexture
, Level
, &wined3ddesc
);
206 LeaveCriticalSection(&d3d8_cs
);
210 pDesc
->Format
= d3dformat_from_wined3dformat(wined3ddesc
.Format
);
211 pDesc
->Type
= wined3ddesc
.Type
;
212 pDesc
->Usage
= wined3ddesc
.Usage
;
213 pDesc
->Pool
= wined3ddesc
.Pool
;
214 pDesc
->Size
= wined3ddesc
.Size
;
215 pDesc
->Width
= wined3ddesc
.Width
;
216 pDesc
->Height
= wined3ddesc
.Height
;
217 pDesc
->Depth
= wined3ddesc
.Depth
;
223 static HRESULT WINAPI
IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface
, UINT Level
, IDirect3DVolume8
**ppVolumeLevel
) {
224 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
225 HRESULT hrc
= D3D_OK
;
226 IWineD3DVolume
*myVolume
= NULL
;
228 TRACE("(%p) Relay\n", This
);
230 EnterCriticalSection(&d3d8_cs
);
231 hrc
= IWineD3DVolumeTexture_GetVolumeLevel(This
->wineD3DVolumeTexture
, Level
, &myVolume
);
232 if (hrc
== D3D_OK
&& NULL
!= ppVolumeLevel
) {
233 IWineD3DVolumeTexture_GetParent(myVolume
, (IUnknown
**)ppVolumeLevel
);
234 IWineD3DVolumeTexture_Release(myVolume
);
236 LeaveCriticalSection(&d3d8_cs
);
240 static HRESULT WINAPI
IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface
, UINT Level
, D3DLOCKED_BOX
*pLockedVolume
, CONST D3DBOX
*pBox
, DWORD Flags
) {
241 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
243 TRACE("(%p) Relay %p %p %p %d\n", This
, This
->wineD3DVolumeTexture
, pLockedVolume
, pBox
,Flags
);
245 EnterCriticalSection(&d3d8_cs
);
246 hr
= IWineD3DVolumeTexture_LockBox(This
->wineD3DVolumeTexture
, Level
, (WINED3DLOCKED_BOX
*) pLockedVolume
, (CONST WINED3DBOX
*) pBox
, Flags
);
247 LeaveCriticalSection(&d3d8_cs
);
251 static HRESULT WINAPI
IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface
, UINT Level
) {
252 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
254 TRACE("(%p) Relay %p %d\n", This
, This
->wineD3DVolumeTexture
, Level
);
256 EnterCriticalSection(&d3d8_cs
);
257 hr
= IWineD3DVolumeTexture_UnlockBox(This
->wineD3DVolumeTexture
, Level
);
258 LeaveCriticalSection(&d3d8_cs
);
262 static HRESULT WINAPI
IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface
, CONST D3DBOX
*pDirtyBox
) {
263 IDirect3DVolumeTexture8Impl
*This
= (IDirect3DVolumeTexture8Impl
*)iface
;
265 TRACE("(%p) Relay\n", This
);
267 EnterCriticalSection(&d3d8_cs
);
268 hr
= IWineD3DVolumeTexture_AddDirtyBox(This
->wineD3DVolumeTexture
, (CONST WINED3DBOX
*) pDirtyBox
);
269 LeaveCriticalSection(&d3d8_cs
);
274 const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl
=
277 IDirect3DVolumeTexture8Impl_QueryInterface
,
278 IDirect3DVolumeTexture8Impl_AddRef
,
279 IDirect3DVolumeTexture8Impl_Release
,
280 /* IDirect3DResource8 */
281 IDirect3DVolumeTexture8Impl_GetDevice
,
282 IDirect3DVolumeTexture8Impl_SetPrivateData
,
283 IDirect3DVolumeTexture8Impl_GetPrivateData
,
284 IDirect3DVolumeTexture8Impl_FreePrivateData
,
285 IDirect3DVolumeTexture8Impl_SetPriority
,
286 IDirect3DVolumeTexture8Impl_GetPriority
,
287 IDirect3DVolumeTexture8Impl_PreLoad
,
288 IDirect3DVolumeTexture8Impl_GetType
,
289 /* IDirect3DBaseTexture8 */
290 IDirect3DVolumeTexture8Impl_SetLOD
,
291 IDirect3DVolumeTexture8Impl_GetLOD
,
292 IDirect3DVolumeTexture8Impl_GetLevelCount
,
293 /* IDirect3DVolumeTexture8 */
294 IDirect3DVolumeTexture8Impl_GetLevelDesc
,
295 IDirect3DVolumeTexture8Impl_GetVolumeLevel
,
296 IDirect3DVolumeTexture8Impl_LockBox
,
297 IDirect3DVolumeTexture8Impl_UnlockBox
,
298 IDirect3DVolumeTexture8Impl_AddDirtyBox