=?UTF-8?Q?Stefan=20D=C3=B6singer=20?=: wined3d: Simplify wined3d_surface_set_mem.

Alexandre Julliard julliard at winehq.org
Wed Jan 8 13:41:33 CST 2014


Module: wine
Branch: master
Commit: 82666af87aaf51d2b8cf648b6d6c85154d45e346
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=82666af87aaf51d2b8cf648b6d6c85154d45e346

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Tue Jan  7 22:12:14 2014 +0100

wined3d: Simplify wined3d_surface_set_mem.

---

 dlls/wined3d/surface.c |   61 ++++++++++++++----------------------------------
 1 file changed, 18 insertions(+), 43 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 7b96a21..9b9e245 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2619,54 +2619,29 @@ 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_DIBSECTION)
     {
-        /* Do I have to copy the old surface content? */
-        if (surface->flags & SFLAG_DIBSECTION)
-        {
-            DeleteDC(surface->hDC);
-            DeleteObject(surface->dib.DIBsection);
-            surface->dib.bitmap_data = NULL;
-            surface->resource.allocatedMemory = NULL;
-            surface->hDC = NULL;
-            surface->flags &= ~SFLAG_DIBSECTION;
-        }
-        else 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);
+        DeleteDC(surface->hDC);
+        DeleteObject(surface->dib.DIBsection);
+        surface->dib.bitmap_data = NULL;
+        surface->resource.allocatedMemory = NULL;
+        surface->hDC = NULL;
+        surface->flags &= ~SFLAG_DIBSECTION;
     }
-    else if (surface->flags & SFLAG_USERPTR)
+    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);
+        wined3d_resource_free_sysmem(&surface->resource);
+        surface->resource.allocatedMemory = NULL;
+    }
 
-            surface_prepare_system_memory(surface);
-        }
+    surface->user_memory = mem;
+    surface->flags |= SFLAG_USERPTR;
+    surface_validate_location(surface, SFLAG_INSYSMEM);
+    surface_invalidate_location(surface, ~SFLAG_INSYSMEM);
 
-        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);
 
     surface->pitch = pitch;
 




More information about the wine-cvs mailing list