[PATCH 2/5] wined3d: Create the DIB section for DDSCAPS_OWNDC surfaces on initialization.

Henri Verbeet hverbeet at codeweavers.com
Mon Oct 31 13:48:12 CDT 2011


---
 dlls/ddraw/surface.c   |    3 +++
 dlls/wined3d/surface.c |   11 +++++++++++
 include/wine/wined3d.h |    1 +
 3 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 3860959..567d086 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -5273,6 +5273,9 @@ HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddr
     if (desc->ddsCaps.dwCaps & DDSCAPS_ZBUFFER)
         usage |= WINED3DUSAGE_DEPTHSTENCIL;
 
+    if (desc->ddsCaps.dwCaps & DDSCAPS_OWNDC)
+        usage |= WINED3DUSAGE_OWNDC;
+
     if (desc->ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)
     {
         pool = WINED3DPOOL_SYSTEMMEM;
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 4f4f331..7361391 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -7305,6 +7305,17 @@ static HRESULT surface_init(struct wined3d_surface *surface, WINED3DSURFTYPE sur
         return hr;
     }
 
+    /* Similar to lockable rendertargets above, creating the DIB section
+     * during surface initialization prevents the sysmem pointer from changing
+     * after a wined3d_surface_getdc() call. */
+    if ((usage & WINED3DUSAGE_OWNDC) && !surface->hDC
+            && SUCCEEDED(surface_create_dib_section(surface)))
+    {
+        HeapFree(GetProcessHeap(), 0, surface->resource.heapMemory);
+        surface->resource.heapMemory = NULL;
+        surface->resource.allocatedMemory = surface->dib.bitmap_data;
+    }
+
     return hr;
 }
 
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index a921f87..f3bb3dc 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -847,6 +847,7 @@ enum wined3d_sysval_semantic
 #define WINED3DUSAGE_AUTOGENMIPMAP                              0x00000400
 #define WINED3DUSAGE_DMAP                                       0x00004000
 #define WINED3DUSAGE_MASK                                       0x00004fff
+#define WINED3DUSAGE_OWNDC                                      0x20000000
 #define WINED3DUSAGE_STATICDECL                                 0x40000000
 #define WINED3DUSAGE_OVERLAY                                    0x80000000
 
-- 
1.7.3.4




More information about the wine-patches mailing list