d3dx9: Cleanup parameter names for D3DXLoadSurfaceFromMemory().
This commit is contained in:
parent
02cb4fe294
commit
b8f6c9cdb1
|
@ -926,16 +926,10 @@ static void point_filter_simple_data(const BYTE *src, UINT srcpitch, SIZE src_si
|
||||||
* negative values for pSrcRect are allowed as we're only looking at the width and height anyway.
|
* negative values for pSrcRect are allowed as we're only looking at the width and height anyway.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI D3DXLoadSurfaceFromMemory(LPDIRECT3DSURFACE9 pDestSurface,
|
HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
|
||||||
CONST PALETTEENTRY *pDestPalette,
|
const PALETTEENTRY *dst_palette, const RECT *dst_rect, const void *src_memory,
|
||||||
CONST RECT *pDestRect,
|
D3DFORMAT src_format, UINT src_pitch, const PALETTEENTRY *src_palette, const RECT *src_rect,
|
||||||
LPCVOID pSrcMemory,
|
DWORD filter, D3DCOLOR color_key)
|
||||||
D3DFORMAT SrcFormat,
|
|
||||||
UINT SrcPitch,
|
|
||||||
CONST PALETTEENTRY *pSrcPalette,
|
|
||||||
CONST RECT *pSrcRect,
|
|
||||||
DWORD dwFilter,
|
|
||||||
D3DCOLOR Colorkey)
|
|
||||||
{
|
{
|
||||||
CONST PixelFormatDesc *srcformatdesc, *destformatdesc;
|
CONST PixelFormatDesc *srcformatdesc, *destformatdesc;
|
||||||
D3DSURFACE_DESC surfdesc;
|
D3DSURFACE_DESC surfdesc;
|
||||||
|
@ -943,35 +937,44 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(LPDIRECT3DSURFACE9 pDestSurface,
|
||||||
SIZE src_size, dst_size;
|
SIZE src_size, dst_size;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("(%p, %p, %p, %p, %x, %u, %p, %p %u, %#x)\n", pDestSurface, pDestPalette, pDestRect, pSrcMemory,
|
TRACE("(%p, %p, %s, %p, %#x, %u, %p, %s %#x, 0x%08x)\n",
|
||||||
SrcFormat, SrcPitch, pSrcPalette, pSrcRect, dwFilter, Colorkey);
|
dst_surface, dst_palette, wine_dbgstr_rect(dst_rect), src_memory, src_format,
|
||||||
|
src_pitch, src_palette, wine_dbgstr_rect(src_rect), filter, color_key);
|
||||||
|
|
||||||
if( !pDestSurface || !pSrcMemory || !pSrcRect ) return D3DERR_INVALIDCALL;
|
if (!dst_surface || !src_memory || !src_rect)
|
||||||
if(SrcFormat == D3DFMT_UNKNOWN || pSrcRect->left >= pSrcRect->right || pSrcRect->top >= pSrcRect->bottom) return E_FAIL;
|
return D3DERR_INVALIDCALL;
|
||||||
|
if (src_format == D3DFMT_UNKNOWN
|
||||||
|
|| src_rect->left >= src_rect->right
|
||||||
|
|| src_rect->top >= src_rect->bottom)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
if(dwFilter == D3DX_DEFAULT) dwFilter = D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER;
|
if (filter == D3DX_DEFAULT)
|
||||||
|
filter = D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER;
|
||||||
|
|
||||||
IDirect3DSurface9_GetDesc(pDestSurface, &surfdesc);
|
IDirect3DSurface9_GetDesc(dst_surface, &surfdesc);
|
||||||
|
|
||||||
src_size.cx = pSrcRect->right - pSrcRect->left;
|
src_size.cx = src_rect->right - src_rect->left;
|
||||||
src_size.cy = pSrcRect->bottom - pSrcRect->top;
|
src_size.cy = src_rect->bottom - src_rect->top;
|
||||||
if (!pDestRect)
|
if (!dst_rect)
|
||||||
{
|
{
|
||||||
dst_size.cx = surfdesc.Width;
|
dst_size.cx = surfdesc.Width;
|
||||||
dst_size.cy = surfdesc.Height;
|
dst_size.cy = surfdesc.Height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(pDestRect->left > pDestRect->right || pDestRect->right > surfdesc.Width) return D3DERR_INVALIDCALL;
|
if (dst_rect->left > dst_rect->right || dst_rect->right > surfdesc.Width)
|
||||||
if(pDestRect->top > pDestRect->bottom || pDestRect->bottom > surfdesc.Height) return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
if(pDestRect->left < 0 || pDestRect->top < 0) return D3DERR_INVALIDCALL;
|
if (dst_rect->top > dst_rect->bottom || dst_rect->bottom > surfdesc.Height)
|
||||||
dst_size.cx = pDestRect->right - pDestRect->left;
|
return D3DERR_INVALIDCALL;
|
||||||
dst_size.cy = pDestRect->bottom - pDestRect->top;
|
if (dst_rect->left < 0 || dst_rect->top < 0)
|
||||||
|
return D3DERR_INVALIDCALL;
|
||||||
|
dst_size.cx = dst_rect->right - dst_rect->left;
|
||||||
|
dst_size.cy = dst_rect->bottom - dst_rect->top;
|
||||||
if (!dst_size.cx || !dst_size.cy)
|
if (!dst_size.cx || !dst_size.cy)
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
srcformatdesc = get_format_info(SrcFormat);
|
srcformatdesc = get_format_info(src_format);
|
||||||
if (srcformatdesc->type == FORMAT_UNKNOWN)
|
if (srcformatdesc->type == FORMAT_UNKNOWN)
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
|
|
||||||
|
@ -979,7 +982,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(LPDIRECT3DSURFACE9 pDestSurface,
|
||||||
if (destformatdesc->type == FORMAT_UNKNOWN)
|
if (destformatdesc->type == FORMAT_UNKNOWN)
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
|
|
||||||
if (SrcFormat == surfdesc.Format
|
if (src_format == surfdesc.Format
|
||||||
&& dst_size.cx == src_size.cx
|
&& dst_size.cx == src_size.cx
|
||||||
&& dst_size.cy == src_size.cy) /* Simple copy. */
|
&& dst_size.cy == src_size.cy) /* Simple copy. */
|
||||||
{
|
{
|
||||||
|
@ -989,33 +992,33 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(LPDIRECT3DSURFACE9 pDestSurface,
|
||||||
BYTE *dst_addr;
|
BYTE *dst_addr;
|
||||||
UINT row;
|
UINT row;
|
||||||
|
|
||||||
if (pSrcRect->left & (srcformatdesc->block_width - 1)
|
if (src_rect->left & (srcformatdesc->block_width - 1)
|
||||||
|| pSrcRect->top & (srcformatdesc->block_height - 1)
|
|| src_rect->top & (srcformatdesc->block_height - 1)
|
||||||
|| (pSrcRect->right & (srcformatdesc->block_width - 1)
|
|| (src_rect->right & (srcformatdesc->block_width - 1)
|
||||||
&& src_size.cx != surfdesc.Width)
|
&& src_size.cx != surfdesc.Width)
|
||||||
|| (pSrcRect->bottom & (srcformatdesc->block_height - 1)
|
|| (src_rect->bottom & (srcformatdesc->block_height - 1)
|
||||||
&& src_size.cy != surfdesc.Height))
|
&& src_size.cy != surfdesc.Height))
|
||||||
{
|
{
|
||||||
WARN("Source rect %s is misaligned.\n", wine_dbgstr_rect(pSrcRect));
|
WARN("Source rect %s is misaligned.\n", wine_dbgstr_rect(src_rect));
|
||||||
return D3DXERR_INVALIDDATA;
|
return D3DXERR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(hr = IDirect3DSurface9_LockRect(pDestSurface, &lockrect, pDestRect, 0)))
|
if (FAILED(hr = IDirect3DSurface9_LockRect(dst_surface, &lockrect, dst_rect, 0)))
|
||||||
return D3DXERR_INVALIDDATA;
|
return D3DXERR_INVALIDDATA;
|
||||||
|
|
||||||
src_addr = pSrcMemory;
|
src_addr = src_memory;
|
||||||
src_addr += (pSrcRect->top / srcformatdesc->block_height) * SrcPitch;
|
src_addr += (src_rect->top / srcformatdesc->block_height) * src_pitch;
|
||||||
src_addr += (pSrcRect->left / srcformatdesc->block_width) * srcformatdesc->block_byte_count;
|
src_addr += (src_rect->left / srcformatdesc->block_width) * srcformatdesc->block_byte_count;
|
||||||
dst_addr = lockrect.pBits;
|
dst_addr = lockrect.pBits;
|
||||||
|
|
||||||
for (row = 0; row < row_count; ++row)
|
for (row = 0; row < row_count; ++row)
|
||||||
{
|
{
|
||||||
memcpy(dst_addr, src_addr, row_block_count * srcformatdesc->block_byte_count);
|
memcpy(dst_addr, src_addr, row_block_count * srcformatdesc->block_byte_count);
|
||||||
src_addr += SrcPitch;
|
src_addr += src_pitch;
|
||||||
dst_addr += lockrect.Pitch;
|
dst_addr += lockrect.Pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDirect3DSurface9_UnlockRect(pDestSurface);
|
IDirect3DSurface9_UnlockRect(dst_surface);
|
||||||
}
|
}
|
||||||
else /* Stretching or format conversion. */
|
else /* Stretching or format conversion. */
|
||||||
{
|
{
|
||||||
|
@ -1028,28 +1031,26 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(LPDIRECT3DSURFACE9 pDestSurface,
|
||||||
if (destformatdesc->block_height != 1 || destformatdesc->block_width != 1)
|
if (destformatdesc->block_height != 1 || destformatdesc->block_width != 1)
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
|
|
||||||
if (FAILED(hr = IDirect3DSurface9_LockRect(pDestSurface, &lockrect, pDestRect, 0)))
|
if (FAILED(hr = IDirect3DSurface9_LockRect(dst_surface, &lockrect, dst_rect, 0)))
|
||||||
return D3DXERR_INVALIDDATA;
|
return D3DXERR_INVALIDDATA;
|
||||||
|
|
||||||
if ((dwFilter & 0xf) == D3DX_FILTER_NONE)
|
if ((filter & 0xf) == D3DX_FILTER_NONE)
|
||||||
{
|
{
|
||||||
copy_simple_data(pSrcMemory, SrcPitch, src_size, srcformatdesc,
|
copy_simple_data(src_memory, src_pitch, src_size, srcformatdesc,
|
||||||
lockrect.pBits, lockrect.Pitch, dst_size, destformatdesc,
|
lockrect.pBits, lockrect.Pitch, dst_size, destformatdesc, color_key);
|
||||||
Colorkey);
|
|
||||||
}
|
}
|
||||||
else /* if ((dwFilter & 0xf) == D3DX_FILTER_POINT) */
|
else /* if ((filter & 0xf) == D3DX_FILTER_POINT) */
|
||||||
{
|
{
|
||||||
if ((dwFilter & 0xf) != D3DX_FILTER_POINT)
|
if ((filter & 0xf) != D3DX_FILTER_POINT)
|
||||||
FIXME("Unhandled filter %#x.\n", dwFilter);
|
FIXME("Unhandled filter %#x.\n", filter);
|
||||||
|
|
||||||
/* Always apply a point filter until D3DX_FILTER_LINEAR,
|
/* Always apply a point filter until D3DX_FILTER_LINEAR,
|
||||||
* D3DX_FILTER_TRIANGLE and D3DX_FILTER_BOX are implemented. */
|
* D3DX_FILTER_TRIANGLE and D3DX_FILTER_BOX are implemented. */
|
||||||
point_filter_simple_data(pSrcMemory, SrcPitch, src_size, srcformatdesc,
|
point_filter_simple_data(src_memory, src_pitch, src_size, srcformatdesc,
|
||||||
lockrect.pBits, lockrect.Pitch, dst_size, destformatdesc,
|
lockrect.pBits, lockrect.Pitch, dst_size, destformatdesc, color_key);
|
||||||
Colorkey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IDirect3DSurface9_UnlockRect(pDestSurface);
|
IDirect3DSurface9_UnlockRect(dst_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
|
|
|
@ -163,16 +163,10 @@ HRESULT WINAPI D3DXLoadSurfaceFromSurface( LPDIRECT3DSURFACE9 destsurface,
|
||||||
DWORD filter,
|
DWORD filter,
|
||||||
D3DCOLOR colorkey);
|
D3DCOLOR colorkey);
|
||||||
|
|
||||||
HRESULT WINAPI D3DXLoadSurfaceFromMemory( LPDIRECT3DSURFACE9 destsurface,
|
HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
|
||||||
CONST PALETTEENTRY *destpalette,
|
const PALETTEENTRY *dst_palette, const RECT *dst_rect, const void *src_memory,
|
||||||
CONST RECT *destrect,
|
D3DFORMAT src_format, UINT src_pitch, const PALETTEENTRY *src_palette, const RECT *src_rect,
|
||||||
LPCVOID srcmemory,
|
DWORD filter, D3DCOLOR color_key);
|
||||||
D3DFORMAT srcformat,
|
|
||||||
UINT srcpitch,
|
|
||||||
CONST PALETTEENTRY *srcpalette,
|
|
||||||
CONST RECT *srcrect,
|
|
||||||
DWORD filter,
|
|
||||||
D3DCOLOR colorkey);
|
|
||||||
|
|
||||||
HRESULT WINAPI D3DXSaveSurfaceToFileA( LPCSTR destfile,
|
HRESULT WINAPI D3DXSaveSurfaceToFileA( LPCSTR destfile,
|
||||||
D3DXIMAGE_FILEFORMAT destformat,
|
D3DXIMAGE_FILEFORMAT destformat,
|
||||||
|
|
Loading…
Reference in New Issue