[PATCH 01/10] wined3d: Don't get rid of the user memory unless we're actually called with NULL in surface_set_mem().

Henri Verbeet hverbeet at codeweavers.com
Tue Aug 23 13:08:05 CDT 2011


In particular, some applications will call surface_set_mem() with the same
pointer to notify us the contents have changed.
---
 dlls/wined3d/surface.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 1cafe03..17edbdc 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1783,17 +1783,21 @@ static HRESULT surface_set_mem(struct wined3d_surface *surface, void *mem)
     }
     else if (surface->flags & SFLAG_USERPTR)
     {
-        /* Map and GetDC will re-create the dib section and allocated memory. */
-        surface->resource.allocatedMemory = NULL;
         /* HeapMemory should be NULL already. */
         if (surface->resource.heapMemory)
             ERR("User pointer surface has heap memory allocated.\n");
-        surface->flags &= ~(SFLAG_USERPTR | SFLAG_INSYSMEM);
 
-        if (surface->flags & SFLAG_CLIENT)
-            surface_release_client_storage(surface);
+        if (!mem)
+        {
+            surface->resource.allocatedMemory = NULL;
+            surface->flags &= ~(SFLAG_USERPTR | SFLAG_INSYSMEM);
+
+            if (surface->flags & SFLAG_CLIENT)
+                surface_release_client_storage(surface);
+
+            surface_prepare_system_memory(surface);
+        }
 
-        surface_prepare_system_memory(surface);
         surface_modify_location(surface, SFLAG_INSYSMEM, TRUE);
     }
 
-- 
1.7.3.4




More information about the wine-patches mailing list