[PATCH 6/6] d3dx9: Use {lock|unlock}_surface() in D3DXLoadSurfaceFromMemory().

Paul Gofman gofmanp at gmail.com
Mon Jan 14 06:12:27 CST 2019


Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
 dlls/d3dx9_36/surface.c | 37 +++++--------------------------------
 1 file changed, 5 insertions(+), 32 deletions(-)

diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index 3f00d80080..3f3f9dfb66 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -1825,8 +1825,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
         DWORD filter, D3DCOLOR color_key)
 {
     const struct pixel_format_desc *srcformatdesc, *destformatdesc;
-    IDirect3DSurface9 *surface = dst_surface;
-    IDirect3DDevice9 *device;
+    IDirect3DSurface9 *surface;
     D3DSURFACE_DESC surfdesc;
     D3DLOCKED_RECT lockrect;
     struct volume src_size, dst_size;
@@ -1886,25 +1885,8 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
         return E_NOTIMPL;
     }
 
-    if (surfdesc.Pool == D3DPOOL_DEFAULT && !(surfdesc.Usage & D3DUSAGE_DYNAMIC))
-    {
-        IDirect3DSurface9_GetDevice(dst_surface, &device);
-        hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, surfdesc.Width,
-                surfdesc.Height, surfdesc.Format, D3DPOOL_SYSTEMMEM, &surface, NULL);
-        IDirect3DDevice9_Release(device);
-        if (FAILED(hr))
-        {
-            WARN("Failed to create staging surface, hr %#x.\n", hr);
-            return D3DERR_INVALIDCALL;
-        }
-    }
-
-    if (FAILED(IDirect3DSurface9_LockRect(surface, &lockrect, dst_rect, 0)))
-    {
-        if (surface != dst_surface)
-            IDirect3DSurface9_Release(surface);
-        return D3DXERR_INVALIDDATA;
-    }
+    if (FAILED(hr = lock_surface(dst_surface, &lockrect, &surface, TRUE)))
+        return D3DERR_INVALIDCALL;
 
     if (src_format == surfdesc.Format
             && dst_size.width == src_size.width
@@ -1955,17 +1937,8 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
 
     hr = D3D_OK;
 done:
-    IDirect3DSurface9_UnlockRect(surface);
-    if (surface != dst_surface)
-    {
-        if (SUCCEEDED(hr))
-        {
-            IDirect3DSurface9_GetDevice(dst_surface, &device);
-            hr = IDirect3DDevice9_UpdateSurface(device, surface, NULL, dst_surface, NULL);
-            IDirect3DDevice9_Release(device);
-        }
-        IDirect3DSurface9_Release(surface);
-    }
+    if (FAILED(unlock_surface(dst_surface, &lockrect, surface, SUCCEEDED(hr))))
+        return D3DERR_INVALIDCALL;
 
     return hr;
 }
-- 
2.20.1




More information about the wine-devel mailing list