From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/surface.c | 34 +++++++++++++++++++++++----------- dlls/d3dx9_36/tests/surface.c | 2 +- 2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 344a491765e..8b4f906dcdd 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -263,8 +263,8 @@ HRESULT lock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, D3DLO HRESULT unlock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, IDirect3DSurface9 *temp_surface, BOOL update) { + const POINT surface_point = { (surface_rect ? surface_rect->left : 0), (surface_rect ? surface_rect->top : 0) }; IDirect3DDevice9 *device; - POINT surface_point; HRESULT hr;
if (!temp_surface) @@ -274,22 +274,34 @@ HRESULT unlock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, }
hr = IDirect3DSurface9_UnlockRect(temp_surface); - if (update) + if (SUCCEEDED(hr) && update) { - if (surface_rect) + D3DSURFACE_DESC desc; + + IDirect3DSurface9_GetDesc(surface, &desc); + IDirect3DSurface9_GetDevice(surface, &device); + if (desc.MultiSampleType != D3DMULTISAMPLE_NONE) { - surface_point.x = surface_rect->left; - surface_point.y = surface_rect->top; + IDirect3DSurface9 *temp_surface2; + D3DSURFACE_DESC temp_desc; + + IDirect3DSurface9_GetDesc(temp_surface, &temp_desc); + hr = IDirect3DDevice9_CreateRenderTarget(device, temp_desc.Width, temp_desc.Height, temp_desc.Format, + D3DMULTISAMPLE_NONE, 0, FALSE, &temp_surface2, NULL); + if (SUCCEEDED(hr)) + { + hr = IDirect3DDevice9_UpdateSurface(device, temp_surface, NULL, temp_surface2, NULL); + if (SUCCEEDED(hr)) + hr = IDirect3DDevice9_StretchRect(device, temp_surface2, NULL, surface, surface_rect, D3DTEXF_NONE); + IDirect3DSurface9_Release(temp_surface2); + } } else { - surface_point.x = 0; - surface_point.y = 0; + hr = IDirect3DDevice9_UpdateSurface(device, temp_surface, NULL, surface, &surface_point); } - IDirect3DSurface9_GetDevice(surface, &device); - if (FAILED(hr = IDirect3DDevice9_UpdateSurface(device, temp_surface, NULL, surface, &surface_point))) - WARN("Updating surface failed, hr %#lx, surface %p, temp_surface %p.\n", - hr, surface, temp_surface); + if (FAILED(hr)) + WARN("Updating surface failed, hr %#lx, surface %p, temp_surface %p.\n", hr, surface, temp_surface); IDirect3DDevice9_Release(device); } IDirect3DSurface9_Release(temp_surface); diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 5290ab1d38c..772cc6cea10 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -939,7 +939,7 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) /* Can also load from memory into a multisampled render target. */ SetRect(&rect, 0, 0, 2, 2); hr = D3DXLoadSurfaceFromMemory(newsurf, NULL, NULL, pixdata, D3DFMT_A8R8G8B8, sizeof(pixdata), NULL, &rect, D3DX_FILTER_NONE, 0); - todo_wine ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#lx, expected %#lx\n", hr, D3D_OK); + ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
IDirect3DSurface9_Release(newsurf); }