Commit 20b50c00 authored by Connor McAdams's avatar Connor McAdams Committed by Alexandre Julliard

d3dx9: Use base image pointer when decompressing source image.

parent b5cd4c47
......@@ -1914,6 +1914,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
{
const struct pixel_format_desc *srcformatdesc, *destformatdesc;
struct volume src_size, dst_size, dst_size_aligned;
const BYTE *src_memory_offset = src_memory;
RECT dst_rect_temp, dst_rect_aligned;
IDirect3DSurface9 *surface;
D3DSURFACE_DESC surfdesc;
......@@ -2000,7 +2001,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
if (FAILED(hr = lock_surface(dst_surface, &dst_rect_aligned, &lockrect, &surface, TRUE)))
return hr;
src_memory = (BYTE *)src_memory + src_rect->top / srcformatdesc->block_height * src_pitch
src_memory_offset += src_rect->top / srcformatdesc->block_height * src_pitch
+ src_rect->left / srcformatdesc->block_width * srcformatdesc->block_byte_count;
if (src_format == surfdesc.Format
......@@ -2013,7 +2014,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
&& !(dst_rect->top & (destformatdesc->block_height - 1)))
{
TRACE("Simple copy.\n");
copy_pixels(src_memory, src_pitch, 0, lockrect.pBits, lockrect.Pitch, 0,
copy_pixels(src_memory_offset, src_pitch, 0, lockrect.pBits, lockrect.Pitch, 0,
&src_size, srcformatdesc);
}
else /* Stretching or format conversion. */
......@@ -2075,7 +2076,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
++ptr;
}
}
src_memory = src_uncompressed;
src_memory_offset = (BYTE *)src_uncompressed;
src_pitch = src_size.width * sizeof(DWORD);
srcformatdesc = get_format_info(D3DFMT_A8B8G8R8);
}
......@@ -2110,7 +2111,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
if ((filter & 0xf) == D3DX_FILTER_NONE)
{
convert_argb_pixels(src_memory, src_pitch, 0, &src_size, srcformatdesc,
convert_argb_pixels(src_memory_offset, src_pitch, 0, &src_size, srcformatdesc,
dst_mem, dst_pitch, 0, &dst_size, dst_format, color_key, src_palette);
}
else /* if ((filter & 0xf) == D3DX_FILTER_POINT) */
......@@ -2120,7 +2121,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
/* Always apply a point filter until D3DX_FILTER_LINEAR,
* D3DX_FILTER_TRIANGLE and D3DX_FILTER_BOX are implemented. */
point_filter_argb_pixels(src_memory, src_pitch, 0, &src_size, srcformatdesc,
point_filter_argb_pixels(src_memory_offset, src_pitch, 0, &src_size, srcformatdesc,
dst_mem, dst_pitch, 0, &dst_size, dst_format, color_key, src_palette);
}
......
......@@ -1652,12 +1652,12 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
get_surface_decompressed_readback(device, newsurf, &surface_rb);
check_readback_pixel_4bpp(&surface_rb, 0, 0, 0xff0000ff, TRUE); /* Blue block, top left. */
check_readback_pixel_4bpp(&surface_rb, 3, 3, 0xff000000, TRUE); /* Blue block, bottom right. */
check_readback_pixel_4bpp(&surface_rb, 3, 3, 0xff000000, FALSE); /* Blue block, bottom right. */
check_readback_pixel_4bpp(&surface_rb, 7, 0, 0xff00ff00, TRUE); /* Green block, top right. */
check_readback_pixel_4bpp(&surface_rb, 4, 3, 0xff000000, TRUE); /* Green block, bottom left. */
check_readback_pixel_4bpp(&surface_rb, 3, 4, 0xff000000, TRUE); /* Red block, top right. */
check_readback_pixel_4bpp(&surface_rb, 4, 3, 0xff000000, FALSE); /* Green block, bottom left. */
check_readback_pixel_4bpp(&surface_rb, 3, 4, 0xff000000, FALSE); /* Red block, top right. */
check_readback_pixel_4bpp(&surface_rb, 0, 7, 0xffff0000, TRUE); /* Red block, bottom left. */
check_readback_pixel_4bpp(&surface_rb, 4, 4, 0xff000000, TRUE); /* Black block, top left. */
check_readback_pixel_4bpp(&surface_rb, 4, 4, 0xff000000, FALSE); /* Black block, top left. */
check_readback_pixel_4bpp(&surface_rb, 7, 7, 0xff000000, TRUE); /* Black block, bottom right. */
release_surface_readback(&surface_rb);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment