[PATCH 5/5] wined3d: Simplify wined3d_surface_set_mem.

Stefan Dösinger stefan at codeweavers.com
Fri Dec 13 05:30:16 CST 2013


---
 dlls/wined3d/surface.c | 45 ++++++++-------------------------------------
 1 file changed, 8 insertions(+), 37 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 4eb37ba..e7438c1 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2628,46 +2628,17 @@ HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem
         return WINED3DERR_INVALIDCALL;
     }
 
-    if (mem && mem != surface->user_memory)
-    {
-        if (!(surface->flags & SFLAG_USERPTR))
-        {
-            wined3d_resource_free_sysmem(&surface->resource);
-            surface->resource.allocatedMemory = NULL;
-        }
-        surface->user_memory = mem;
-        surface->flags |= SFLAG_USERPTR;
-
-        /* Now the surface memory is most up do date. Invalidate drawable and texture. */
-        surface_validate_location(surface, SFLAG_INSYSMEM);
-        surface_invalidate_location(surface, ~SFLAG_INSYSMEM);
-
-        /* For client textures OpenGL has to be notified. */
-        if (surface->flags & SFLAG_CLIENT)
-            surface_release_client_storage(surface);
-    }
-    else if (surface->flags & SFLAG_USERPTR)
-    {
-        /* heap_memory should be NULL already. */
-        if (surface->resource.heap_memory)
-            ERR("User pointer surface has heap memory allocated.\n");
-
-        if (!mem)
-        {
-            surface->user_memory = NULL;
-            surface->flags &= ~(SFLAG_USERPTR | SFLAG_INSYSMEM);
-
-            if (surface->flags & SFLAG_CLIENT)
-                surface_release_client_storage(surface);
-
-            surface_prepare_system_memory(surface);
-        }
+    if (surface->user_memory == mem && surface->pitch == pitch)
+        return WINED3D_OK;
 
-        surface_validate_location(surface, SFLAG_INSYSMEM);
-        surface_invalidate_location(surface, ~SFLAG_INSYSMEM);
-    }
+    wined3d_resource_free_sysmem(&surface->resource);
+    surface->resource.allocatedMemory = NULL;
 
     surface->pitch = pitch;
+    surface->user_memory = mem;
+    surface->flags |= SFLAG_USERPTR;
+    surface_validate_location(surface, SFLAG_INSYSMEM);
+    surface_invalidate_location(surface, ~SFLAG_INSYSMEM);
 
     return WINED3D_OK;
 }
-- 
1.8.3.2




More information about the wine-patches mailing list