cmd: DIR command outputs free space for the path.
[wine.git] / dlls / d3d8 / volume.c
blob2774195075eb8f433f2cab4ebec921ae993900fb
1 /*
2 * IDirect3DVolume8 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
21 #include "d3d8_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
25 static inline struct d3d8_volume *impl_from_IDirect3DVolume8(IDirect3DVolume8 *iface)
27 return CONTAINING_RECORD(iface, struct d3d8_volume, IDirect3DVolume8_iface);
30 static HRESULT WINAPI d3d8_volume_QueryInterface(IDirect3DVolume8 *iface, REFIID riid, void **out)
32 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
34 if (IsEqualGUID(riid, &IID_IDirect3DVolume8)
35 || IsEqualGUID(riid, &IID_IUnknown))
37 IDirect3DVolume8_AddRef(iface);
38 *out = iface;
39 return S_OK;
42 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
44 *out = NULL;
45 return E_NOINTERFACE;
48 static ULONG WINAPI d3d8_volume_AddRef(IDirect3DVolume8 *iface)
50 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
52 TRACE("iface %p.\n", iface);
53 TRACE("Forwarding to %p.\n", volume->texture);
55 return IDirect3DBaseTexture8_AddRef(&volume->texture->IDirect3DBaseTexture8_iface);
58 static ULONG WINAPI d3d8_volume_Release(IDirect3DVolume8 *iface)
60 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
62 TRACE("iface %p.\n", iface);
63 TRACE("Forwarding to %p.\n", volume->texture);
65 return IDirect3DBaseTexture8_Release(&volume->texture->IDirect3DBaseTexture8_iface);
68 static HRESULT WINAPI d3d8_volume_GetDevice(IDirect3DVolume8 *iface, IDirect3DDevice8 **device)
70 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
72 TRACE("iface %p, device %p.\n", iface, device);
74 return IDirect3DBaseTexture8_GetDevice(&volume->texture->IDirect3DBaseTexture8_iface, device);
77 static HRESULT WINAPI d3d8_volume_SetPrivateData(IDirect3DVolume8 *iface, REFGUID guid,
78 const void *data, DWORD data_size, DWORD flags)
80 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
81 TRACE("iface %p, guid %s, data %p, data_size %lu, flags %#lx.\n",
82 iface, debugstr_guid(guid), data, data_size, flags);
84 return d3d8_resource_set_private_data(&volume->resource, guid, data, data_size, flags);
87 static HRESULT WINAPI d3d8_volume_GetPrivateData(IDirect3DVolume8 *iface, REFGUID guid,
88 void *data, DWORD *data_size)
90 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
91 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
92 iface, debugstr_guid(guid), data, data_size);
94 return d3d8_resource_get_private_data(&volume->resource, guid, data, data_size);
97 static HRESULT WINAPI d3d8_volume_FreePrivateData(IDirect3DVolume8 *iface, REFGUID guid)
99 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
100 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
102 return d3d8_resource_free_private_data(&volume->resource, guid);
105 static HRESULT WINAPI d3d8_volume_GetContainer(IDirect3DVolume8 *iface, REFIID riid, void **container)
107 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
109 TRACE("iface %p, riid %s, container %p.\n", iface, debugstr_guid(riid), container);
111 return IDirect3DBaseTexture8_QueryInterface(&volume->texture->IDirect3DBaseTexture8_iface, riid, container);
114 static HRESULT WINAPI d3d8_volume_GetDesc(IDirect3DVolume8 *iface, D3DVOLUME_DESC *desc)
116 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
117 struct wined3d_sub_resource_desc wined3d_desc;
119 TRACE("iface %p, desc %p.\n", iface, desc);
121 wined3d_mutex_lock();
122 wined3d_texture_get_sub_resource_desc(volume->wined3d_texture, volume->sub_resource_idx, &wined3d_desc);
123 wined3d_mutex_unlock();
125 desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
126 desc->Type = D3DRTYPE_VOLUME;
127 desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage, wined3d_desc.bind_flags);
128 desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
129 desc->Size = wined3d_desc.size;
130 desc->Width = wined3d_desc.width;
131 desc->Height = wined3d_desc.height;
132 desc->Depth = wined3d_desc.depth;
134 return D3D_OK;
137 static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface,
138 D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags)
140 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
141 struct wined3d_map_desc map_desc;
142 HRESULT hr;
144 TRACE("iface %p, locked_box %p, box %p, flags %#lx.\n", iface, locked_box, box, flags);
146 if (FAILED(hr = wined3d_resource_map(wined3d_texture_get_resource(volume->wined3d_texture),
147 volume->sub_resource_idx, &map_desc, (const struct wined3d_box *)box,
148 wined3dmapflags_from_d3dmapflags(flags, 0))))
149 map_desc.data = NULL;
151 locked_box->RowPitch = map_desc.row_pitch;
152 locked_box->SlicePitch = map_desc.slice_pitch;
153 locked_box->pBits = map_desc.data;
155 if (hr == E_INVALIDARG)
156 return D3DERR_INVALIDCALL;
157 return hr;
160 static HRESULT WINAPI d3d8_volume_UnlockBox(IDirect3DVolume8 *iface)
162 struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface);
163 HRESULT hr;
165 TRACE("iface %p.\n", iface);
167 hr = wined3d_resource_unmap(wined3d_texture_get_resource(volume->wined3d_texture), volume->sub_resource_idx);
169 if (hr == WINEDDERR_NOTLOCKED)
170 return D3DERR_INVALIDCALL;
171 return hr;
174 static const IDirect3DVolume8Vtbl d3d8_volume_vtbl =
176 /* IUnknown */
177 d3d8_volume_QueryInterface,
178 d3d8_volume_AddRef,
179 d3d8_volume_Release,
180 /* IDirect3DVolume8 */
181 d3d8_volume_GetDevice,
182 d3d8_volume_SetPrivateData,
183 d3d8_volume_GetPrivateData,
184 d3d8_volume_FreePrivateData,
185 d3d8_volume_GetContainer,
186 d3d8_volume_GetDesc,
187 d3d8_volume_LockBox,
188 d3d8_volume_UnlockBox,
191 static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
193 struct d3d8_volume *volume = parent;
194 d3d8_resource_cleanup(&volume->resource);
195 heap_free(volume);
198 static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops =
200 volume_wined3d_object_destroyed,
203 void volume_init(struct d3d8_volume *volume, struct wined3d_texture *wined3d_texture,
204 unsigned int sub_resource_idx, const struct wined3d_parent_ops **parent_ops)
206 volume->IDirect3DVolume8_iface.lpVtbl = &d3d8_volume_vtbl;
207 d3d8_resource_init(&volume->resource);
208 volume->resource.refcount = 0;
209 volume->texture = wined3d_texture_get_parent(wined3d_texture);
210 volume->wined3d_texture = wined3d_texture;
211 volume->sub_resource_idx = sub_resource_idx;
213 *parent_ops = &d3d8_volume_wined3d_parent_ops;