ReactOS 0.4.17-dev-966-gf06eace
volume.c
Go to the documentation of this file.
1/*
2 * IDirect3DVolume8 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 "d3d8_private.h"
22
24
25static inline struct d3d8_volume *impl_from_IDirect3DVolume8(IDirect3DVolume8 *iface)
26{
28}
29
30static HRESULT WINAPI d3d8_volume_QueryInterface(IDirect3DVolume8 *iface, REFIID riid, void **out)
31{
32 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
33
34 if (IsEqualGUID(riid, &IID_IDirect3DVolume8)
36 {
38 *out = iface;
39 return S_OK;
40 }
41
42 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
43
44 *out = NULL;
45 return E_NOINTERFACE;
46}
47
48static ULONG WINAPI d3d8_volume_AddRef(IDirect3DVolume8 *iface)
49{
51
52 TRACE("iface %p.\n", iface);
53 TRACE("Forwarding to %p.\n", volume->texture);
54
55 return IDirect3DBaseTexture8_AddRef(&volume->texture->IDirect3DBaseTexture8_iface);
56}
57
58static ULONG WINAPI d3d8_volume_Release(IDirect3DVolume8 *iface)
59{
61
62 TRACE("iface %p.\n", iface);
63 TRACE("Forwarding to %p.\n", volume->texture);
64
65 return IDirect3DBaseTexture8_Release(&volume->texture->IDirect3DBaseTexture8_iface);
66}
67
68static HRESULT WINAPI d3d8_volume_GetDevice(IDirect3DVolume8 *iface, IDirect3DDevice8 **device)
69{
71
72 TRACE("iface %p, device %p.\n", iface, device);
73
74 return IDirect3DBaseTexture8_GetDevice(&volume->texture->IDirect3DBaseTexture8_iface, device);
75}
76
77static HRESULT WINAPI d3d8_volume_SetPrivateData(IDirect3DVolume8 *iface, REFGUID guid,
78 const void *data, DWORD data_size, DWORD flags)
79{
81 TRACE("iface %p, guid %s, data %p, data_size %lu, flags %#lx.\n",
82 iface, debugstr_guid(guid), data, data_size, flags);
83
84 return d3d8_resource_set_private_data(&volume->resource, guid, data, data_size, flags);
85}
86
87static HRESULT WINAPI d3d8_volume_GetPrivateData(IDirect3DVolume8 *iface, REFGUID guid,
88 void *data, DWORD *data_size)
89{
91 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
92 iface, debugstr_guid(guid), data, data_size);
93
94 return d3d8_resource_get_private_data(&volume->resource, guid, data, data_size);
95}
96
97static HRESULT WINAPI d3d8_volume_FreePrivateData(IDirect3DVolume8 *iface, REFGUID guid)
98{
100 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
101
102 return d3d8_resource_free_private_data(&volume->resource, guid);
103}
104
105static HRESULT WINAPI d3d8_volume_GetContainer(IDirect3DVolume8 *iface, REFIID riid, void **container)
106{
108
109 TRACE("iface %p, riid %s, container %p.\n", iface, debugstr_guid(riid), container);
110
111 return IDirect3DBaseTexture8_QueryInterface(&volume->texture->IDirect3DBaseTexture8_iface, riid, container);
112}
113
114static HRESULT WINAPI d3d8_volume_GetDesc(IDirect3DVolume8 *iface, D3DVOLUME_DESC *desc)
115{
117 struct wined3d_sub_resource_desc wined3d_desc;
118
119 TRACE("iface %p, desc %p.\n", iface, desc);
120
122 wined3d_texture_get_sub_resource_desc(volume->wined3d_texture, volume->sub_resource_idx, &wined3d_desc);
124
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;
133
134 return D3D_OK;
135}
136
137static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface,
138 D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags)
139{
141 struct wined3d_map_desc map_desc;
142 HRESULT hr;
143
144 TRACE("iface %p, locked_box %p, box %p, flags %#lx.\n", iface, locked_box, box, flags);
145
147 volume->sub_resource_idx, &map_desc, (const struct wined3d_box *)box,
149 map_desc.data = NULL;
150
151 locked_box->RowPitch = map_desc.row_pitch;
152 locked_box->SlicePitch = map_desc.slice_pitch;
153 locked_box->pBits = map_desc.data;
154
155 if (hr == E_INVALIDARG)
156 return D3DERR_INVALIDCALL;
157 return hr;
158}
159
160static HRESULT WINAPI d3d8_volume_UnlockBox(IDirect3DVolume8 *iface)
161{
163 HRESULT hr;
164
165 TRACE("iface %p.\n", iface);
166
167 hr = wined3d_resource_unmap(wined3d_texture_get_resource(volume->wined3d_texture), volume->sub_resource_idx);
168
169 if (hr == WINEDDERR_NOTLOCKED)
170 return D3DERR_INVALIDCALL;
171 return hr;
172}
173
174static const IDirect3DVolume8Vtbl d3d8_volume_vtbl =
175{
176 /* IUnknown */
180 /* IDirect3DVolume8 */
189};
190
192{
193 struct d3d8_volume *volume = parent;
194 d3d8_resource_cleanup(&volume->resource);
195 free(volume);
196}
197
199{
201};
202
204 unsigned int sub_resource_idx, const struct wined3d_parent_ops **parent_ops)
205{
206 volume->IDirect3DVolume8_iface.lpVtbl = &d3d8_volume_vtbl;
207 d3d8_resource_init(&volume->resource);
208 volume->resource.refcount = 0;
210 volume->wined3d_texture = wined3d_texture;
211 volume->sub_resource_idx = sub_resource_idx;
212
213 *parent_ops = &d3d8_volume_wined3d_parent_ops;
214}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
#define D3DERR_INVALIDCALL
Definition: d3d10_private.h:42
HRESULT d3d8_resource_get_private_data(struct d3d8_resource *resource, const GUID *guid, void *data, DWORD *data_size)
Definition: d3d8_main.c:172
void d3d8_resource_cleanup(struct d3d8_resource *resource)
Definition: d3d8_main.c:149
void d3d8_resource_init(struct d3d8_resource *resource)
Definition: d3d8_main.c:210
HRESULT d3d8_resource_set_private_data(struct d3d8_resource *resource, const GUID *guid, const void *data, DWORD data_size, DWORD flags)
Definition: d3d8_main.c:216
HRESULT d3d8_resource_free_private_data(struct d3d8_resource *resource, const GUID *guid)
Definition: d3d8_main.c:154
static DWORD d3dusage_from_wined3dusage(unsigned int wined3d_usage, unsigned int bind_flags)
Definition: d3d8_private.h:305
D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format)
Definition: device.c:33
unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags, unsigned int usage)
Definition: device.c:135
static D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned int usage)
Definition: d3d8_private.h:315
@ D3DRTYPE_VOLUME
Definition: d3d8types.h:811
#define D3D_OK
Definition: d3d.h:106
#define E_INVALIDARG
Definition: ddrawi.h:101
#define free
Definition: debug_ros.c:5
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
Definition: volume.c:191
void volume_init(struct d3d8_volume *volume, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, const struct wined3d_parent_ops **parent_ops)
Definition: volume.c:203
static HRESULT WINAPI d3d8_volume_GetDevice(IDirect3DVolume8 *iface, IDirect3DDevice8 **device)
Definition: volume.c:68
static HRESULT WINAPI d3d8_volume_GetContainer(IDirect3DVolume8 *iface, REFIID riid, void **container)
Definition: volume.c:105
static ULONG WINAPI d3d8_volume_AddRef(IDirect3DVolume8 *iface)
Definition: volume.c:48
static HRESULT WINAPI d3d8_volume_SetPrivateData(IDirect3DVolume8 *iface, REFGUID guid, const void *data, DWORD data_size, DWORD flags)
Definition: volume.c:77
static HRESULT WINAPI d3d8_volume_GetPrivateData(IDirect3DVolume8 *iface, REFGUID guid, void *data, DWORD *data_size)
Definition: volume.c:87
static const IDirect3DVolume8Vtbl d3d8_volume_vtbl
Definition: volume.c:174
static HRESULT WINAPI d3d8_volume_GetDesc(IDirect3DVolume8 *iface, D3DVOLUME_DESC *desc)
Definition: volume.c:114
static struct d3d8_volume * impl_from_IDirect3DVolume8(IDirect3DVolume8 *iface)
Definition: volume.c:25
static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface, D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags)
Definition: volume.c:137
static HRESULT WINAPI d3d8_volume_QueryInterface(IDirect3DVolume8 *iface, REFIID riid, void **out)
Definition: volume.c:30
static HRESULT WINAPI d3d8_volume_FreePrivateData(IDirect3DVolume8 *iface, REFGUID guid)
Definition: volume.c:97
static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops
Definition: volume.c:198
static ULONG WINAPI d3d8_volume_Release(IDirect3DVolume8 *iface)
Definition: volume.c:58
static HRESULT WINAPI d3d8_volume_UnlockBox(IDirect3DVolume8 *iface)
Definition: volume.c:160
HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
Definition: resource.c:304
HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, uint32_t flags)
Definition: resource.c:295
void *CDECL wined3d_texture_get_parent(const struct wined3d_texture *texture)
Definition: texture.c:1690
HRESULT CDECL wined3d_texture_get_sub_resource_desc(const struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_sub_resource_desc *desc)
Definition: texture.c:4055
struct wined3d_resource *CDECL wined3d_texture_get_resource(struct wined3d_texture *texture)
Definition: texture.c:1649
GUID guid
Definition: version.c:147
r parent
Definition: btrfs.c:3010
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define IDirect3DBaseTexture8_QueryInterface(p, a, b)
Definition: d3d8.h:540
#define IDirect3DBaseTexture8_GetDevice(p, a)
Definition: d3d8.h:544
#define IDirect3DBaseTexture8_AddRef(p)
Definition: d3d8.h:541
#define IDirect3DVolume8_AddRef(p)
Definition: d3d8.h:218
#define IDirect3DBaseTexture8_Release(p)
Definition: d3d8.h:542
#define TRACE(s)
Definition: solgame.cpp:4
Definition: scsiwmi.h:51
Definition: palette.c:466
IDirect3DVolume8 IDirect3DVolume8_iface
Definition: d3d8_private.h:165
Definition: devices.h:37
enum wined3d_format_id format
Definition: wined3d.h:1806
unsigned int bind_flags
Definition: wined3d.h:1810
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define WINAPI
Definition: msvc.h:6
#define WINEDDERR_NOTLOCKED
Definition: wined3d.h:46
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539
#define E_NOINTERFACE
Definition: winerror.h:3479