=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: d3d8: Return D3D_OK from UnlockRect() for not locked textures.

Alexandre Julliard julliard at winehq.org
Tue Feb 28 03:45:56 CST 2017


Module: wine
Branch: oldstable
Commit: 72dc44f8a3de83fb034a423802506cd23e9261fc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=72dc44f8a3de83fb034a423802506cd23e9261fc

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Fri Jan 13 12:53:46 2017 +0100

d3d8: Return D3D_OK from UnlockRect() for not locked textures.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 8f8c2a8ade8d8b2c61c5f1614aa477900d6ab449)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/d3d8/surface.c      | 11 ++++++++---
 dlls/d3d8/tests/device.c |  3 +--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c
index ec263b1..5348841 100644
--- a/dlls/d3d8/surface.c
+++ b/dlls/d3d8/surface.c
@@ -273,11 +273,16 @@ static HRESULT WINAPI d3d8_surface_UnlockRect(IDirect3DSurface8 *iface)
     hr = wined3d_resource_unmap(wined3d_texture_get_resource(surface->wined3d_texture), surface->sub_resource_idx);
     wined3d_mutex_unlock();
 
-    switch(hr)
+    if (hr == WINEDDERR_NOTLOCKED)
     {
-        case WINEDDERR_NOTLOCKED:       return D3DERR_INVALIDCALL;
-        default:                        return hr;
+        D3DRESOURCETYPE type;
+        if (surface->texture)
+            type = IDirect3DBaseTexture8_GetType(&surface->texture->IDirect3DBaseTexture8_iface);
+        else
+            type = D3DRTYPE_SURFACE;
+        hr = type == D3DRTYPE_TEXTURE ? D3D_OK : D3DERR_INVALIDCALL;
     }
+    return hr;
 }
 
 static const IDirect3DSurface8Vtbl d3d8_surface_vtbl =
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index 7b14068..0d85d3e 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -4712,7 +4712,6 @@ static void test_lockrect_invalid(void)
         ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
         expected_hr = resources[r].type == D3DRTYPE_TEXTURE ? D3D_OK : D3DERR_INVALIDCALL;
         hr = IDirect3DSurface8_UnlockRect(surface);
-        todo_wine_if(resources[r].type == D3DRTYPE_TEXTURE)
         ok(hr == expected_hr, "Got hr %#x, expected %#x, type %s.\n", hr, expected_hr, resources[r].name);
 
         for (i = 0; i < (sizeof(valid) / sizeof(*valid)); ++i)
@@ -4858,7 +4857,7 @@ static void test_lockrect_invalid(void)
             hr = IDirect3DTexture8_UnlockRect(texture, 0);
             ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x, type %s.\n", hr, resources[r].name);
             hr = IDirect3DTexture8_UnlockRect(texture, 0);
-            todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
+            ok(hr == D3D_OK, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
 
             hr = IDirect3DTexture8_LockRect(texture, 0, &locked_rect, &valid[0], 0);
             ok(hr == D3D_OK, "Got unexpected hr %#x for rect [%d, %d]->[%d, %d], type %s.\n",




More information about the wine-cvs mailing list