Matteo Bruni : d3dx9: Handle non-zero source rect position in D3DXLoadSurfaceFromMemory().
Alexandre Julliard
julliard at winehq.org
Mon Apr 20 15:01:48 CDT 2020
Module: wine
Branch: oldstable
Commit: a709cfe061a53d55c43e81fc7a06c679309e825e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=a709cfe061a53d55c43e81fc7a06c679309e825e
Author: Matteo Bruni <mbruni at codeweavers.com>
Date: Fri Sep 27 20:40:02 2019 +0200
d3dx9: Handle non-zero source rect position in D3DXLoadSurfaceFromMemory().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=41936
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 88d8ae383932ad1c292c74da7dcc19f00d8423f7)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/d3dx9_36/surface.c | 3 +++
dlls/d3dx9_36/tests/surface.c | 11 +++++++++++
2 files changed, 14 insertions(+)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index d921b89ab8..3f9e8d7979 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -1911,6 +1911,9 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
if (FAILED(hr = lock_surface(dst_surface, dst_rect, &lockrect, &surface, TRUE)))
return hr;
+ src_memory = (BYTE *)src_memory + src_rect->top / srcformatdesc->block_height * src_pitch
+ + src_rect->left / srcformatdesc->block_width * srcformatdesc->block_byte_count;
+
if (src_format == surfdesc.Format
&& dst_size.width == src_size.width
&& dst_size.height == src_size.height
diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c
index a844e52193..e60ab6712e 100644
--- a/dlls/d3dx9_36/tests/surface.c
+++ b/dlls/d3dx9_36/tests/surface.c
@@ -881,8 +881,19 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
check_release((IUnknown*)surf, 0);
+ SetRect(&rect, 1, 1, 2, 2);
+ hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 1, 1, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surf, NULL);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a8b8g8r8,
+ D3DFMT_A8R8G8B8, 8, NULL, &rect, D3DX_FILTER_NONE, 0);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
+ check_pixel_4bpp(&lockrect, 0, 0, 0x8dc32bf6);
+ IDirect3DSurface9_UnlockRect(surf);
+ check_release((IUnknown *)surf, 0);
/* test color conversion */
+ SetRect(&rect, 0, 0, 2, 2);
/* A8R8G8B8 */
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 2, 2, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surf, NULL);
if(FAILED(hr)) skip("Failed to create a surface (%#x)\n", hr);
More information about the wine-cvs
mailing list