volumetexture.c 11.1 KB
Newer Older
1 2 3
/*
 * IDirect3DVolumeTexture8 implementation
 *
4
 * Copyright 2005 Oliver Stieber
5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 23
#include "d3d8_private.h"

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 32 33 34
    || IsEqualGUID(riid, &IID_IDirect3DResource8)
    || IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
    || IsEqualGUID(riid, &IID_IDirect3DVolumeTexture8)) {
        IUnknown_AddRef(iface);
35
        *ppobj = This;
H. Verbeet's avatar
H. Verbeet committed
36
        return S_OK;
37 38
    }

39
    WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
H. Verbeet's avatar
H. Verbeet committed
40
    *ppobj = NULL;
41 42 43
    return E_NOINTERFACE;
}

44
static ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface) {
45
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
46 47
    ULONG ref = InterlockedIncrement(&This->ref);

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
        EnterCriticalSection(&d3d8_cs);
61
        IWineD3DVolumeTexture_Destroy(This->wineD3DVolumeTexture, D3D8CB_DestroyVolume);
62
        LeaveCriticalSection(&d3d8_cs);
63
        IUnknown_Release(This->parentDevice);
64
        HeapFree(GetProcessHeap(), 0, This);
65
    }
66 67 68 69
    return ref;
}

/* IDirect3DVolumeTexture8 IDirect3DResource8 Interface follow: */
70
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
71
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
72
    HRESULT hr;
73
    TRACE("(%p) Relay\n", This);
74 75 76 77 78

    EnterCriticalSection(&d3d8_cs);
    hr = IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
    LeaveCriticalSection(&d3d8_cs);
    return hr;
79
}
80

81
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
82
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
83
    HRESULT hr;
84
    TRACE("(%p) Relay\n", This);
85 86 87 88 89

    EnterCriticalSection(&d3d8_cs);
    hr = IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
    LeaveCriticalSection(&d3d8_cs);
    return hr;
90
}
91

92
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
93
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
94
    HRESULT hr;
95
    TRACE("(%p) Relay\n", This);
96 97 98 99 100

    EnterCriticalSection(&d3d8_cs);
    hr = IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
    LeaveCriticalSection(&d3d8_cs);
    return hr;
101
}
102

103
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid) {
104
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
105
    HRESULT hr;
106
    TRACE("(%p) Relay\n", This);
107 108 109 110 111

    EnterCriticalSection(&d3d8_cs);
    hr = IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
    LeaveCriticalSection(&d3d8_cs);
    return hr;
112
}
113

114
static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD PriorityNew) {
115
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
116
    DWORD ret;
117
    TRACE("(%p) Relay\n", This);
118 119 120 121 122

    EnterCriticalSection(&d3d8_cs);
    ret = IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
    LeaveCriticalSection(&d3d8_cs);
    return ret;
123
}
124

125
static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE8 iface) {
126
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
127
    DWORD ret;
128
    TRACE("(%p) Relay\n", This);
129 130 131 132 133

    EnterCriticalSection(&d3d8_cs);
    ret = IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
    LeaveCriticalSection(&d3d8_cs);
    return ret;
134
}
135

136
static void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface) {
137 138
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
    TRACE("(%p) Relay\n", This);
139 140

    EnterCriticalSection(&d3d8_cs);
141
    IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
142
    LeaveCriticalSection(&d3d8_cs);
143
}
144

145
static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {
146
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
147
    D3DRESOURCETYPE type;
148
    TRACE("(%p) Relay\n", This);
149 150 151 152 153

    EnterCriticalSection(&d3d8_cs);
    type = IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
    LeaveCriticalSection(&d3d8_cs);
    return type;
154 155
}

156
/* IDirect3DVolumeTexture8 IDirect3DBaseTexture8 Interface follow: */
157
static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew) {
158
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
159
    DWORD ret;
160
    TRACE("(%p) Relay\n", This);
161 162 163 164 165

    EnterCriticalSection(&d3d8_cs);
    ret = IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
    LeaveCriticalSection(&d3d8_cs);
    return ret;
166
}
167

168
static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface) {
169
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
170
    DWORD ret;
171
    TRACE("(%p) Relay\n", This);
172 173 174 175 176

    EnterCriticalSection(&d3d8_cs);
    ret = IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
    LeaveCriticalSection(&d3d8_cs);
    return ret;
177
}
178

179
static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface) {
180
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
181
    DWORD ret;
182
    TRACE("(%p) Relay\n", This);
183 184 185 186 187

    EnterCriticalSection(&d3d8_cs);
    ret = IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
    LeaveCriticalSection(&d3d8_cs);
    return ret;
188 189
}

190
/* IDirect3DVolumeTexture8 Interface follow: */
191
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
192
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
193 194
    WINED3DVOLUME_DESC     wined3ddesc;
    UINT                   tmpInt = -1;
195
    HRESULT hr;
196 197 198 199 200

    TRACE("(%p) Relay\n", This);

    /* As d3d8 and d3d8 structures differ, pass in ptrs to where data needs to go */
    wined3ddesc.Format              = (WINED3DFORMAT *)&pDesc->Format;
201
    wined3ddesc.Type                = (WINED3DRESOURCETYPE *)&pDesc->Type;
202
    wined3ddesc.Usage               = &pDesc->Usage;
203
    wined3ddesc.Pool                = (WINED3DPOOL *) &pDesc->Pool;
204 205 206 207 208
    wined3ddesc.Size                = &tmpInt;
    wined3ddesc.Width               = &pDesc->Width;
    wined3ddesc.Height              = &pDesc->Height;
    wined3ddesc.Depth               = &pDesc->Depth;

209 210 211 212
    EnterCriticalSection(&d3d8_cs);
    hr = IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
    LeaveCriticalSection(&d3d8_cs);
    return hr;
213
}
214

215
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, IDirect3DVolume8 **ppVolumeLevel) {
216
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
217 218
    HRESULT hrc = D3D_OK;
    IWineD3DVolume *myVolume = NULL;
219

220 221
    TRACE("(%p) Relay\n", This);

222
    EnterCriticalSection(&d3d8_cs);
223 224 225 226 227
    hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
    if (hrc == D3D_OK && NULL != ppVolumeLevel) {
       IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
       IWineD3DVolumeTexture_Release(myVolume);
    }
228
    LeaveCriticalSection(&d3d8_cs);
229
    return hrc;
230
}
231

232
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
233
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
234
    HRESULT hr;
235
    TRACE("(%p) Relay %p %p %p %d\n", This, This->wineD3DVolumeTexture, pLockedVolume, pBox,Flags);
236 237 238 239 240

    EnterCriticalSection(&d3d8_cs);
    hr = IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
    LeaveCriticalSection(&d3d8_cs);
    return hr;
241
}
242

243
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level) {
244
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
245
    HRESULT hr;
246
    TRACE("(%p) Relay %p %d\n", This, This->wineD3DVolumeTexture, Level);
247 248 249 250 251

    EnterCriticalSection(&d3d8_cs);
    hr = IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
    LeaveCriticalSection(&d3d8_cs);
    return hr;
252
}
253

254
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX *pDirtyBox) {
255
    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
256
    HRESULT hr;
257
    TRACE("(%p) Relay\n", This);
258 259 260 261 262

    EnterCriticalSection(&d3d8_cs);
    hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *) pDirtyBox);
    LeaveCriticalSection(&d3d8_cs);
    return hr;
263 264 265
}


266
const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl =
267
{
268
    /* IUnknown */
269 270 271
    IDirect3DVolumeTexture8Impl_QueryInterface,
    IDirect3DVolumeTexture8Impl_AddRef,
    IDirect3DVolumeTexture8Impl_Release,
272
    /* IDirect3DResource8 */
273 274 275 276 277 278 279 280
    IDirect3DVolumeTexture8Impl_GetDevice,
    IDirect3DVolumeTexture8Impl_SetPrivateData,
    IDirect3DVolumeTexture8Impl_GetPrivateData,
    IDirect3DVolumeTexture8Impl_FreePrivateData,
    IDirect3DVolumeTexture8Impl_SetPriority,
    IDirect3DVolumeTexture8Impl_GetPriority,
    IDirect3DVolumeTexture8Impl_PreLoad,
    IDirect3DVolumeTexture8Impl_GetType,
281
    /* IDirect3DBaseTexture8 */
282 283 284
    IDirect3DVolumeTexture8Impl_SetLOD,
    IDirect3DVolumeTexture8Impl_GetLOD,
    IDirect3DVolumeTexture8Impl_GetLevelCount,
285
    /* IDirect3DVolumeTexture8 */
286 287 288 289 290 291
    IDirect3DVolumeTexture8Impl_GetLevelDesc,
    IDirect3DVolumeTexture8Impl_GetVolumeLevel,
    IDirect3DVolumeTexture8Impl_LockBox,
    IDirect3DVolumeTexture8Impl_UnlockBox,
    IDirect3DVolumeTexture8Impl_AddDirtyBox
};