- Plug a bunch of memory leaks.
[wine] / dlls / d3d8 / volumetexture.c
1 /*
2  * IDirect3DVolumeTexture8 implementation
3  *
4  * Copyright 2002 Jason Edmeades
5  *
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.
10  *
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.
15  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winuser.h"
25 #include "wingdi.h"
26 #include "wine/debug.h"
27
28 #include "d3d8_private.h"
29
30 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
31
32 /* IDirect3DVolumeTexture8 IUnknown parts follow: */
33 HRESULT WINAPI IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE8 iface,REFIID riid,LPVOID *ppobj)
34 {
35     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
36
37     TRACE("(%p) : QueryInterface\n", This);
38     if (IsEqualGUID(riid, &IID_IUnknown)
39         || IsEqualGUID(riid, &IID_IClassFactory)) {
40         IDirect3DVolumeTexture8Impl_AddRef(iface);
41         *ppobj = This;
42         return D3D_OK;
43     }
44
45     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
46     return E_NOINTERFACE;
47 }
48
49 ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface) {
50     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
51     TRACE("(%p) : AddRef from %ld\n", This, This->ref);
52     return ++(This->ref);
53 }
54
55 ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface) {
56     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
57     ULONG ref = --This->ref;
58     int   i;
59
60     TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
61     if (ref == 0) {
62         for (i=0; i<This->levels; i++) {
63             if (This->volumes[i] != NULL) {
64                 TRACE("(%p) : Releasing volume %p\n", This, This->volumes[i]);
65                 IDirect3DVolume8Impl_Release((LPDIRECT3DVOLUME8) This->volumes[i]);
66             }
67         }
68         HeapFree(GetProcessHeap(), 0, This);
69     }
70     return ref;
71 }
72
73 /* IDirect3DVolumeTexture8 IDirect3DResource8 Interface follow: */
74 HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE8 iface, IDirect3DDevice8** ppDevice) {
75     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
76     TRACE("(%p) : returning %p\n", This, This->Device);
77     *ppDevice = (LPDIRECT3DDEVICE8) This->Device;
78     return D3D_OK;
79 }
80 HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
81     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
82     FIXME("(%p) : stub\n", This);    return D3D_OK;
83 }
84 HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
85     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
86     FIXME("(%p) : stub\n", This);    return D3D_OK;
87 }
88 HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid) {
89     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
90     FIXME("(%p) : stub\n", This);    return D3D_OK;
91 }
92 DWORD    WINAPI        IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD PriorityNew) {
93     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
94     FIXME("(%p) : stub\n", This);    return D3D_OK;
95 }
96 DWORD    WINAPI        IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE8 iface) {
97     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
98     FIXME("(%p) : stub\n", This);    return D3D_OK;
99 }
100 void     WINAPI        IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface) {
101     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
102     FIXME("(%p) : stub\n", This);
103 }
104 D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {
105     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
106     TRACE("(%p) : returning %d\n", This, This->ResourceType);
107     return This->ResourceType;
108 }
109
110 /* IDirect3DVolumeTexture8 (Inherited from IDirect3DBaseTexture8) */
111 DWORD    WINAPI        IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew) {
112     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
113     FIXME("(%p) : stub\n", This);    return D3D_OK;
114 }
115 DWORD    WINAPI        IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface) {
116     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
117     FIXME("(%p) : stub\n", This);    return D3D_OK;
118 }
119 DWORD    WINAPI        IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface) {
120     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
121     TRACE("(%p) : returning %d\n", This, This->levels);
122     return This->levels;
123 }
124
125 /* IDirect3DVolumeTexture8 */
126 HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level,D3DVOLUME_DESC *pDesc) {
127     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
128     if (Level < This->levels) {
129         TRACE("(%p) Level (%d)\n", This, Level);
130         return IDirect3DVolume8Impl_GetDesc((LPDIRECT3DVOLUME8)This->volumes[Level], pDesc);
131     } else {
132         FIXME("(%p) Level (%d)\n", This, Level);
133     }
134     return D3D_OK;
135 }
136 HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level,IDirect3DVolume8** ppVolumeLevel) {
137     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
138     IDirect3DVolume8Impl_AddRef((LPDIRECT3DVOLUME8)This->volumes[Level]);
139     *ppVolumeLevel = (LPDIRECT3DVOLUME8)This->volumes[Level];
140     TRACE("(%p) : returning %p for level %d\n", This, *ppVolumeLevel, Level);
141     return D3D_OK;
142 }
143 HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) {
144     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
145     TRACE("(%p) Level (%d)\n", This, Level);
146     if (Level < This->levels) {
147         return IDirect3DVolume8Impl_LockBox((LPDIRECT3DVOLUME8)This->volumes[Level], pLockedVolume, pBox, Flags);
148     } else {
149         FIXME("Volume Levels seems too high?!!\n");
150     }
151     return D3D_OK;
152 }
153 HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level) {
154     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
155     This->Dirty = TRUE;
156     TRACE("(%p) : stub\n", This);
157     return D3D_OK;
158 }
159 HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX* pDirtyBox) {
160     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
161     This->Dirty = TRUE;
162     FIXME("(%p) : stub\n", This);    return D3D_OK;
163 }
164
165
166 ICOM_VTABLE(IDirect3DVolumeTexture8) Direct3DVolumeTexture8_Vtbl =
167 {
168     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
169     IDirect3DVolumeTexture8Impl_QueryInterface,
170     IDirect3DVolumeTexture8Impl_AddRef,
171     IDirect3DVolumeTexture8Impl_Release,
172     IDirect3DVolumeTexture8Impl_GetDevice,
173     IDirect3DVolumeTexture8Impl_SetPrivateData,
174     IDirect3DVolumeTexture8Impl_GetPrivateData,
175     IDirect3DVolumeTexture8Impl_FreePrivateData,
176     IDirect3DVolumeTexture8Impl_SetPriority,
177     IDirect3DVolumeTexture8Impl_GetPriority,
178     IDirect3DVolumeTexture8Impl_PreLoad,
179     IDirect3DVolumeTexture8Impl_GetType,
180     IDirect3DVolumeTexture8Impl_SetLOD,
181     IDirect3DVolumeTexture8Impl_GetLOD,
182     IDirect3DVolumeTexture8Impl_GetLevelCount,
183     IDirect3DVolumeTexture8Impl_GetLevelDesc,
184     IDirect3DVolumeTexture8Impl_GetVolumeLevel,
185     IDirect3DVolumeTexture8Impl_LockBox,
186     IDirect3DVolumeTexture8Impl_UnlockBox,
187     IDirect3DVolumeTexture8Impl_AddDirtyBox
188 };