ReactOS 0.4.16-dev-329-g9223134
volume.c File Reference
#include "d3dx9_private.h"
Include dependency graph for volume.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3dx)
 
HRESULT WINAPI D3DXLoadVolumeFromFileA (IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const char *filename, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, D3DXIMAGE_INFO *info)
 
HRESULT WINAPI D3DXLoadVolumeFromFileW (IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const WCHAR *filename, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, D3DXIMAGE_INFO *info)
 
HRESULT WINAPI D3DXLoadVolumeFromMemory (IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_memory, D3DFORMAT src_format, UINT src_row_pitch, UINT src_slice_pitch, const PALETTEENTRY *src_palette, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key)
 
HRESULT WINAPI D3DXLoadVolumeFromFileInMemory (IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_data, UINT src_data_size, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info)
 
HRESULT WINAPI D3DXLoadVolumeFromVolume (IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, IDirect3DVolume9 *src_volume, const PALETTEENTRY *src_palette, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key)
 

Function Documentation

◆ D3DXLoadVolumeFromFileA()

HRESULT WINAPI D3DXLoadVolumeFromFileA ( IDirect3DVolume9 *  dst_volume,
const PALETTEENTRY dst_palette,
const D3DBOX dst_box,
const char filename,
const D3DBOX src_box,
DWORD  filter,
D3DCOLOR  color_key,
D3DXIMAGE_INFO info 
)

Definition at line 28 of file volume.c.

36{
37 HRESULT hr;
38 int length;
40
41 TRACE("(%p, %p, %p, %s, %p, %#x, %#x, %p)\n",
42 dst_volume, dst_palette, dst_box, debugstr_a(filename), src_box,
44
45 if (!dst_volume || !filename) return D3DERR_INVALIDCALL;
46
49 if (!filenameW) return E_OUTOFMEMORY;
50
51 hr = D3DXLoadVolumeFromFileW(dst_volume, dst_palette, dst_box, filenameW,
52 src_box, filter, color_key, info);
54
55 return hr;
56}
#define D3DERR_INVALIDCALL
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
HRESULT WINAPI D3DXLoadVolumeFromFileW(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const WCHAR *filename, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, D3DXIMAGE_INFO *info)
Definition: volume.c:58
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
const char * filename
Definition: ioapi.h:137
#define debugstr_a
Definition: kernel32.h:31
static const WCHAR filenameW[]
Definition: amstream.c:41
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ D3DXLoadVolumeFromFileInMemory()

HRESULT WINAPI D3DXLoadVolumeFromFileInMemory ( IDirect3DVolume9 *  dst_volume,
const PALETTEENTRY dst_palette,
const D3DBOX dst_box,
const void src_data,
UINT  src_data_size,
const D3DBOX src_box,
DWORD  filter,
D3DCOLOR  color_key,
D3DXIMAGE_INFO src_info 
)

Definition at line 230 of file volume.c.

239{
240 HRESULT hr;
241 D3DBOX box;
242 D3DXIMAGE_INFO image_info;
243
244 TRACE("dst_volume %p, dst_palette %p, dst_box %p, src_data %p, src_data_size %u, src_box %p, "
245 "filter %#x, color_key 0x%08x, src_info %p.\n",
246 dst_volume, dst_palette, dst_box, src_data, src_data_size, src_box,
247 filter, color_key, src_info);
248
249 if (!dst_volume || !src_data)
250 return D3DERR_INVALIDCALL;
251
252 if (FAILED(hr = D3DXGetImageInfoFromFileInMemory(src_data, src_data_size, &image_info)))
253 return hr;
254
255 if (src_box)
256 {
257 if (src_box->Right > image_info.Width
258 || src_box->Bottom > image_info.Height
259 || src_box->Back > image_info.Depth)
260 return D3DERR_INVALIDCALL;
261
262 box = *src_box;
263 }
264 else
265 {
266 box.Left = 0;
267 box.Top = 0;
268 box.Right = image_info.Width;
269 box.Bottom = image_info.Height;
270 box.Front = 0;
271 box.Back = image_info.Depth;
272
273 }
274
275 if (image_info.ImageFileFormat != D3DXIFF_DDS)
276 {
277 FIXME("File format %#x is not supported yet\n", image_info.ImageFileFormat);
278 return E_NOTIMPL;
279 }
280
281 hr = load_volume_from_dds(dst_volume, dst_palette, dst_box, src_data, &box,
282 filter, color_key, &image_info);
283 if (FAILED(hr)) return hr;
284
285 if (src_info)
286 *src_info = image_info;
287
288 return D3D_OK;
289}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define D3D_OK
Definition: d3d.h:106
HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN
Definition: surface.c:719
@ D3DXIFF_DDS
Definition: d3dx9tex.h:68
#define E_NOTIMPL
Definition: ddrawi.h:99
HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize, D3DXIMAGE_INFO *info)
Definition: surface.c:985
#define FAILED(hr)
Definition: intsafe.h:51
UINT Bottom
Definition: d3d8types.h:1014
UINT Right
Definition: d3d8types.h:1013
UINT Back
Definition: d3d8types.h:1016
D3DXIMAGE_FILEFORMAT ImageFileFormat
Definition: d3dx9tex.h:84
Definition: palette.c:468

Referenced by D3DXLoadVolumeFromFileW(), and test_D3DXLoadVolumeFromFileInMemory().

◆ D3DXLoadVolumeFromFileW()

HRESULT WINAPI D3DXLoadVolumeFromFileW ( IDirect3DVolume9 *  dst_volume,
const PALETTEENTRY dst_palette,
const D3DBOX dst_box,
const WCHAR filename,
const D3DBOX src_box,
DWORD  filter,
D3DCOLOR  color_key,
D3DXIMAGE_INFO info 
)

Definition at line 58 of file volume.c.

66{
67 HRESULT hr;
68 void *data;
69 UINT data_size;
70
71 TRACE("(%p, %p, %p, %s, %p, %#x, %#x, %p)\n",
72 dst_volume, dst_palette, dst_box, debugstr_w(filename), src_box,
74
75 if (!dst_volume || !filename) return D3DERR_INVALIDCALL;
76
77 if (FAILED(map_view_of_file(filename, &data, &data_size)))
79
80 hr = D3DXLoadVolumeFromFileInMemory(dst_volume, dst_palette, dst_box,
81 data, data_size, src_box, filter, color_key, info);
83
84 return hr;
85}
#define D3DXERR_INVALIDDATA
Definition: compiler.c:30
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:120
HRESULT WINAPI D3DXLoadVolumeFromFileInMemory(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_data, UINT src_data_size, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info)
Definition: volume.c:230
#define UnmapViewOfFile
Definition: compat.h:746
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define debugstr_w
Definition: kernel32.h:32
unsigned int UINT
Definition: ndis.h:50

Referenced by D3DXLoadVolumeFromFileA().

◆ D3DXLoadVolumeFromMemory()

HRESULT WINAPI D3DXLoadVolumeFromMemory ( IDirect3DVolume9 *  dst_volume,
const PALETTEENTRY dst_palette,
const D3DBOX dst_box,
const void src_memory,
D3DFORMAT  src_format,
UINT  src_row_pitch,
UINT  src_slice_pitch,
const PALETTEENTRY src_palette,
const D3DBOX src_box,
DWORD  filter,
D3DCOLOR  color_key 
)

Definition at line 87 of file volume.c.

98{
99 HRESULT hr;
101 D3DLOCKED_BOX locked_box;
102 struct volume dst_size, src_size;
103 const struct pixel_format_desc *src_format_desc, *dst_format_desc;
104
105 TRACE("(%p, %p, %p, %p, %#x, %u, %u, %p, %p, %x, %x)\n", dst_volume, dst_palette, dst_box,
106 src_memory, src_format, src_row_pitch, src_slice_pitch, src_palette, src_box,
108
109 if (!dst_volume || !src_memory || !src_box) return D3DERR_INVALIDCALL;
110
111 if (src_format == D3DFMT_UNKNOWN
112 || src_box->Left >= src_box->Right
113 || src_box->Top >= src_box->Bottom
114 || src_box->Front >= src_box->Back)
115 return E_FAIL;
116
117 if (filter == D3DX_DEFAULT)
119
120 IDirect3DVolume9_GetDesc(dst_volume, &desc);
121
122 src_size.width = src_box->Right - src_box->Left;
123 src_size.height = src_box->Bottom - src_box->Top;
124 src_size.depth = src_box->Back - src_box->Front;
125
126 if (!dst_box)
127 {
128 dst_size.width = desc.Width;
129 dst_size.height = desc.Height;
130 dst_size.depth = desc.Depth;
131 }
132 else
133 {
134 if (dst_box->Left >= dst_box->Right || dst_box->Right > desc.Width)
135 return D3DERR_INVALIDCALL;
136 if (dst_box->Top >= dst_box->Bottom || dst_box->Bottom > desc.Height)
137 return D3DERR_INVALIDCALL;
138 if (dst_box->Front >= dst_box->Back || dst_box->Back > desc.Depth)
139 return D3DERR_INVALIDCALL;
140
141 dst_size.width = dst_box->Right - dst_box->Left;
142 dst_size.height = dst_box->Bottom - dst_box->Top;
143 dst_size.depth = dst_box->Back - dst_box->Front;
144 }
145
146 src_format_desc = get_format_info(src_format);
147 if (src_format_desc->type == FORMAT_UNKNOWN)
148 return E_NOTIMPL;
149
150 dst_format_desc = get_format_info(desc.Format);
151 if (dst_format_desc->type == FORMAT_UNKNOWN)
152 return E_NOTIMPL;
153
154 if (desc.Format == src_format
155 && dst_size.width == src_size.width
156 && dst_size.height == src_size.height
157 && dst_size.depth == src_size.depth
158 && color_key == 0)
159 {
160 const BYTE *src_addr;
161
162 if (src_box->Left & (src_format_desc->block_width - 1)
163 || src_box->Top & (src_format_desc->block_height - 1)
164 || (src_box->Right & (src_format_desc->block_width - 1)
165 && src_size.width != desc.Width)
166 || (src_box->Bottom & (src_format_desc->block_height - 1)
167 && src_size.height != desc.Height))
168 {
169 FIXME("Source box (%u, %u, %u, %u) is misaligned\n",
170 src_box->Left, src_box->Top, src_box->Right, src_box->Bottom);
171 return E_NOTIMPL;
172 }
173
174 src_addr = src_memory;
175 src_addr += src_box->Front * src_slice_pitch;
176 src_addr += (src_box->Top / src_format_desc->block_height) * src_row_pitch;
177 src_addr += (src_box->Left / src_format_desc->block_width) * src_format_desc->block_byte_count;
178
179 hr = IDirect3DVolume9_LockBox(dst_volume, &locked_box, dst_box, 0);
180 if (FAILED(hr)) return hr;
181
182 copy_pixels(src_addr, src_row_pitch, src_slice_pitch,
183 locked_box.pBits, locked_box.RowPitch, locked_box.SlicePitch,
184 &dst_size, dst_format_desc);
185
186 IDirect3DVolume9_UnlockBox(dst_volume);
187 }
188 else
189 {
190 const BYTE *src_addr;
191
192 if (!is_conversion_from_supported(src_format_desc)
193 || !is_conversion_to_supported(dst_format_desc))
194 {
195 FIXME("Pixel format conversion is not implemented %#x -> %#x\n",
196 src_format_desc->format, dst_format_desc->format);
197 return E_NOTIMPL;
198 }
199
200 src_addr = src_memory;
201 src_addr += src_box->Front * src_slice_pitch;
202 src_addr += src_box->Top * src_row_pitch;
203 src_addr += src_box->Left * src_format_desc->bytes_per_pixel;
204
205 hr = IDirect3DVolume9_LockBox(dst_volume, &locked_box, dst_box, 0);
206 if (FAILED(hr)) return hr;
207
208 if ((filter & 0xf) == D3DX_FILTER_NONE)
209 {
210 convert_argb_pixels(src_memory, src_row_pitch, src_slice_pitch, &src_size, src_format_desc,
211 locked_box.pBits, locked_box.RowPitch, locked_box.SlicePitch, &dst_size, dst_format_desc, color_key,
212 src_palette);
213 }
214 else
215 {
216 if ((filter & 0xf) != D3DX_FILTER_POINT)
217 FIXME("Unhandled filter %#x.\n", filter);
218
219 point_filter_argb_pixels(src_addr, src_row_pitch, src_slice_pitch, &src_size, src_format_desc,
220 locked_box.pBits, locked_box.RowPitch, locked_box.SlicePitch, &dst_size, dst_format_desc, color_key,
221 src_palette);
222 }
223
224 IDirect3DVolume9_UnlockBox(dst_volume);
225 }
226
227 return D3D_OK;
228}
@ D3DFMT_UNKNOWN
Definition: d3d8types.h:601
#define IDirect3DVolume9_UnlockBox(p)
Definition: d3d9.h:392
#define IDirect3DVolume9_LockBox(p, a, b, c)
Definition: d3d9.h:391
#define IDirect3DVolume9_GetDesc(p, a)
Definition: d3d9.h:390
#define D3DX_DEFAULT
Definition: d3dx9.h:24
void copy_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *size, const struct pixel_format_desc *format) DECLSPEC_HIDDEN
Definition: surface.c:1700
static BOOL is_conversion_to_supported(const struct pixel_format_desc *format)
Definition: d3dx9_private.h:87
const struct pixel_format_desc * get_format_info(D3DFORMAT format) DECLSPEC_HIDDEN
Definition: util.c:217
void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, const struct volume *src_size, const struct pixel_format_desc *src_format, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *dst_size, const struct pixel_format_desc *dst_format, D3DCOLOR color_key, const PALETTEENTRY *palette) DECLSPEC_HIDDEN
Definition: surface.c:1839
static BOOL is_conversion_from_supported(const struct pixel_format_desc *format)
Definition: d3dx9_private.h:79
void convert_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, const struct volume *src_size, const struct pixel_format_desc *src_format, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *dst_size, const struct pixel_format_desc *dst_format, D3DCOLOR color_key, const PALETTEENTRY *palette) DECLSPEC_HIDDEN
Definition: surface.c:1731
#define D3DX_FILTER_TRIANGLE
Definition: d3dx9tex.h:30
#define D3DX_FILTER_DITHER
Definition: d3dx9tex.h:36
#define D3DX_FILTER_POINT
Definition: d3dx9tex.h:28
#define D3DX_FILTER_NONE
Definition: d3dx9tex.h:27
#define E_FAIL
Definition: ddrawi.h:102
static const WCHAR desc[]
Definition: protectdata.c:36
UINT Left
Definition: d3d8types.h:1011
UINT Top
Definition: d3d8types.h:1012
UINT Front
Definition: d3d8types.h:1015
enum format_type type
Definition: d3dx9_private.h:66
#define FORMAT_UNKNOWN
Definition: trio.c:409
unsigned char BYTE
Definition: xxhash.c:193

Referenced by D3DXLoadVolumeFromVolume(), load_volume_from_dds(), load_volume_texture_from_dds(), and test_D3DXLoadVolumeFromMemory().

◆ D3DXLoadVolumeFromVolume()

HRESULT WINAPI D3DXLoadVolumeFromVolume ( IDirect3DVolume9 *  dst_volume,
const PALETTEENTRY dst_palette,
const D3DBOX dst_box,
IDirect3DVolume9 *  src_volume,
const PALETTEENTRY src_palette,
const D3DBOX src_box,
DWORD  filter,
D3DCOLOR  color_key 
)

Definition at line 291 of file volume.c.

299{
300 HRESULT hr;
301 D3DBOX box;
303 D3DLOCKED_BOX locked_box;
304
305 TRACE("(%p, %p, %p, %p, %p, %p, %#x, %#x)\n",
306 dst_volume, dst_palette, dst_box, src_volume, src_palette, src_box,
308
309 if (!dst_volume || !src_volume) return D3DERR_INVALIDCALL;
310
311 IDirect3DVolume9_GetDesc(src_volume, &desc);
312
313 if (!src_box)
314 {
315 box.Left = box.Top = 0;
316 box.Right = desc.Width;
317 box.Bottom = desc.Height;
318 box.Front = 0;
319 box.Back = desc.Depth;
320 }
321 else box = *src_box;
322
323 hr = IDirect3DVolume9_LockBox(src_volume, &locked_box, NULL, D3DLOCK_READONLY);
324 if (FAILED(hr)) return hr;
325
326 hr = D3DXLoadVolumeFromMemory(dst_volume, dst_palette, dst_box,
327 locked_box.pBits, desc.Format, locked_box.RowPitch, locked_box.SlicePitch,
328 src_palette, &box, filter, color_key);
329
330 IDirect3DVolume9_UnlockBox(src_volume);
331 return hr;
332}
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
HRESULT WINAPI D3DXLoadVolumeFromMemory(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_memory, D3DFORMAT src_format, UINT src_row_pitch, UINT src_slice_pitch, const PALETTEENTRY *src_palette, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key)
Definition: volume.c:87

Referenced by D3DXFilterTexture().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3dx  )