[PATCH 3/4] wined3d: Use the pointer returned by map in wined3d_surface_getdc.

Stefan Dösinger stefan at codeweavers.com
Mon Nov 25 16:41:12 CST 2013


---
 dlls/wined3d/surface.c         | 13 ++++++-------
 dlls/wined3d/wined3d_private.h |  1 +
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 50bc6e7..dcb8ebf 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -3324,11 +3324,10 @@ HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc)
         ERR("Map failed, hr %#x.\n", hr);
         return hr;
     }
+    surface->getdc_map_mem = map.data;
 
-    /* Sync the DIB with the PBO. This can't be done earlier because Map()
-     * activates the allocatedMemory. */
-    if (surface->flags & (SFLAG_PBO | SFLAG_PIN_SYSMEM))
-        memcpy(surface->dib.bitmap_data, surface->resource.allocatedMemory, surface->resource.size);
+    if (surface->dib.bitmap_data != surface->getdc_map_mem)
+        memcpy(surface->dib.bitmap_data, surface->getdc_map_mem, surface->resource.size);
 
     if (surface->resource.format->id == WINED3DFMT_P8_UINT
             || surface->resource.format->id == WINED3DFMT_P8_UINT_A8_UNORM)
@@ -3389,11 +3388,11 @@ HRESULT CDECL wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc)
         return WINEDDERR_NODC;
     }
 
-    /* Copy the contents of the DIB over to the PBO. */
-    if ((surface->flags & (SFLAG_PBO | SFLAG_PIN_SYSMEM)) && surface->resource.allocatedMemory)
-        memcpy(surface->resource.allocatedMemory, surface->dib.bitmap_data, surface->resource.size);
+    if (surface->dib.bitmap_data != surface->getdc_map_mem)
+        memcpy(surface->getdc_map_mem, surface->dib.bitmap_data, surface->resource.size);
 
     /* We locked first, so unlock now. */
+    surface->getdc_map_mem = NULL;
     wined3d_surface_unmap(surface);
 
     surface->flags &= ~SFLAG_DCINUSE;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index d7e1c5f..5b5d01a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2204,6 +2204,7 @@ struct wined3d_surface
     /* For GetDC */
     struct wined3d_surface_dib dib;
     HDC                       hDC;
+    void                      *getdc_map_mem;
 
     /* Color keys for DDraw */
     struct wined3d_color_key dst_blt_color_key;
-- 
1.8.3.2




More information about the wine-patches mailing list