hhctrl.ocx: Resize tab control in Child's WM_SIZE handler.
[wine] / dlls / d3d8 / volumetexture.c
1 /*
2  * IDirect3DVolumeTexture8 implementation
3  *
4  * Copyright 2005 Oliver Stieber
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "config.h"
22 #include "d3d8_private.h"
23
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
25
26 /* IDirect3DVolumeTexture8 IUnknown parts follow: */
27 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
28     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
29
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);
35         *ppobj = This;
36         return S_OK;
37     }
38
39     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
40     *ppobj = NULL;
41     return E_NOINTERFACE;
42 }
43
44 static ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface) {
45     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
46     ULONG ref = InterlockedIncrement(&This->ref);
47
48     TRACE("(%p) : AddRef from %d\n", This, ref - 1);
49
50     return ref;
51 }
52
53 static ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface) {
54     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
55     ULONG ref = InterlockedDecrement(&This->ref);
56
57     TRACE("(%p) : ReleaseRef to %d\n", This, ref);
58
59     if (ref == 0) {
60         IWineD3DVolumeTexture_Destroy(This->wineD3DVolumeTexture, D3D8CB_DestroyVolume);
61         IUnknown_Release(This->parentDevice);
62         HeapFree(GetProcessHeap(), 0, This);
63     }
64     return ref;
65 }
66
67 /* IDirect3DVolumeTexture8 IDirect3DResource8 Interface follow: */
68 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
69     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
70     TRACE("(%p) Relay\n", This);
71     return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
72 }
73
74 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
75     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
76     TRACE("(%p) Relay\n", This);
77     return IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
78 }
79
80 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
81     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
82     TRACE("(%p) Relay\n", This);
83     return IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
84 }
85
86 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid) {
87     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
88     TRACE("(%p) Relay\n", This);
89     return IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
90 }
91
92 static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD PriorityNew) {
93     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
94     TRACE("(%p) Relay\n", This);
95     return IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
96 }
97
98 static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE8 iface) {
99     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
100     TRACE("(%p) Relay\n", This);
101     return IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
102 }
103
104 static void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface) {
105     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
106     TRACE("(%p) Relay\n", This);
107     return IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
108 }
109
110 static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {
111     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
112     TRACE("(%p) Relay\n", This);
113     return IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
114 }
115
116 /* IDirect3DVolumeTexture8 IDirect3DBaseTexture8 Interface follow: */
117 static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew) {
118     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
119     TRACE("(%p) Relay\n", This);
120     return IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
121 }
122
123 static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface) {
124     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
125     TRACE("(%p) Relay\n", This);
126     return IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
127 }
128
129 static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface) {
130     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
131     TRACE("(%p) Relay\n", This);
132     return IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
133 }
134
135 /* IDirect3DVolumeTexture8 Interface follow: */
136 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
137     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
138     WINED3DVOLUME_DESC     wined3ddesc;
139     UINT                   tmpInt = -1;
140
141     TRACE("(%p) Relay\n", This);
142
143     /* As d3d8 and d3d8 structures differ, pass in ptrs to where data needs to go */
144     wined3ddesc.Format              = (WINED3DFORMAT *)&pDesc->Format;
145     wined3ddesc.Type                = (WINED3DRESOURCETYPE *)&pDesc->Type;
146     wined3ddesc.Usage               = &pDesc->Usage;
147     wined3ddesc.Pool                = (WINED3DPOOL *) &pDesc->Pool;
148     wined3ddesc.Size                = &tmpInt;
149     wined3ddesc.Width               = &pDesc->Width;
150     wined3ddesc.Height              = &pDesc->Height;
151     wined3ddesc.Depth               = &pDesc->Depth;
152
153     return IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
154 }
155
156 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, IDirect3DVolume8 **ppVolumeLevel) {
157     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
158     HRESULT hrc = D3D_OK;
159     IWineD3DVolume *myVolume = NULL;
160
161     TRACE("(%p) Relay\n", This);
162
163     hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
164     if (hrc == D3D_OK && NULL != ppVolumeLevel) {
165        IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
166        IWineD3DVolumeTexture_Release(myVolume);
167     }
168     return hrc;
169 }
170
171 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
172     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
173     TRACE("(%p) Relay %p %p %p %d\n", This, This->wineD3DVolumeTexture, pLockedVolume, pBox,Flags);
174     return IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
175 }
176
177 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level) {
178     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
179     TRACE("(%p) Relay %p %d\n", This, This->wineD3DVolumeTexture, Level);
180     return IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
181 }
182
183 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX *pDirtyBox) {
184     IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
185     TRACE("(%p) Relay\n", This);
186     return IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *) pDirtyBox);
187 }
188
189
190 const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl =
191 {
192     /* IUnknown */
193     IDirect3DVolumeTexture8Impl_QueryInterface,
194     IDirect3DVolumeTexture8Impl_AddRef,
195     IDirect3DVolumeTexture8Impl_Release,
196     /* IDirect3DResource8 */
197     IDirect3DVolumeTexture8Impl_GetDevice,
198     IDirect3DVolumeTexture8Impl_SetPrivateData,
199     IDirect3DVolumeTexture8Impl_GetPrivateData,
200     IDirect3DVolumeTexture8Impl_FreePrivateData,
201     IDirect3DVolumeTexture8Impl_SetPriority,
202     IDirect3DVolumeTexture8Impl_GetPriority,
203     IDirect3DVolumeTexture8Impl_PreLoad,
204     IDirect3DVolumeTexture8Impl_GetType,
205     /* IDirect3DBaseTexture8 */
206     IDirect3DVolumeTexture8Impl_SetLOD,
207     IDirect3DVolumeTexture8Impl_GetLOD,
208     IDirect3DVolumeTexture8Impl_GetLevelCount,
209     /* IDirect3DVolumeTexture8 */
210     IDirect3DVolumeTexture8Impl_GetLevelDesc,
211     IDirect3DVolumeTexture8Impl_GetVolumeLevel,
212     IDirect3DVolumeTexture8Impl_LockBox,
213     IDirect3DVolumeTexture8Impl_UnlockBox,
214     IDirect3DVolumeTexture8Impl_AddDirtyBox
215 };