Stefan Dösinger : wined3d: Give GDI surfaces their own release implementation.

Alexandre Julliard julliard at winehq.org
Tue Sep 18 05:31:04 CDT 2007


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

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Mon Sep 17 15:04:46 2007 +0200

wined3d: Give GDI surfaces their own release implementation.

---

 dlls/wined3d/surface_gdi.c     |   41 +++++++++++++++++++++++++++++++++++++++-
 dlls/wined3d/wined3d_private.h |    1 -
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/surface_gdi.c b/dlls/wined3d/surface_gdi.c
index 9cc8a99..d23ce2a 100644
--- a/dlls/wined3d/surface_gdi.c
+++ b/dlls/wined3d/surface_gdi.c
@@ -129,6 +129,45 @@ x11_copy_to_screen(IWineD3DSurfaceImpl *This,
 }
 
 /*****************************************************************************
+ * IWineD3DSurface::Release, GDI version
+ *
+ * In general a normal COM Release method, but the GDI version doesn't have
+ * to destroy all the GL things.
+ *
+ *****************************************************************************/
+ULONG WINAPI IWineGDISurfaceImpl_Release(IWineD3DSurface *iface) {
+    IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
+    ULONG ref = InterlockedDecrement(&This->resource.ref);
+    TRACE("(%p) : Releasing from %d\n", This, ref + 1);
+    if (ref == 0) {
+        IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->resource.wineD3DDevice;
+        TRACE("(%p) : cleaning up\n", This);
+
+        if(This->Flags & SFLAG_DIBSECTION) {
+            /* Release the DC */
+            SelectObject(This->hDC, This->dib.holdbitmap);
+            DeleteDC(This->hDC);
+            /* Release the DIB section */
+            DeleteObject(This->dib.DIBsection);
+            This->dib.bitmap_data = NULL;
+            This->resource.allocatedMemory = NULL;
+        }
+        if(This->Flags & SFLAG_USERPTR) IWineD3DSurface_SetMem(iface, NULL);
+
+        HeapFree(GetProcessHeap(), 0, This->palette9);
+
+        IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
+        if(iface == device->ddraw_primary)
+            device->ddraw_primary = NULL;
+
+        TRACE("(%p) Released\n", This);
+        HeapFree(GetProcessHeap(), 0, This);
+
+    }
+    return ref;
+}
+
+/*****************************************************************************
  * IWineD3DSurface::PreLoad, GDI version
  *
  * This call is unsupported on GDI surfaces, if it's called something went
@@ -1698,7 +1737,7 @@ const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl =
     /* IUnknown */
     IWineD3DBaseSurfaceImpl_QueryInterface,
     IWineD3DBaseSurfaceImpl_AddRef,
-    IWineD3DSurfaceImpl_Release,
+    IWineGDISurfaceImpl_Release,
     /* IWineD3DResource */
     IWineD3DBaseSurfaceImpl_GetParent,
     IWineD3DBaseSurfaceImpl_GetDevice,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 1c17f2d..cd21179 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1171,7 +1171,6 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format);
 HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface);
 
-ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface);
 const void *WINAPI IWineD3DSurfaceImpl_GetData(IWineD3DSurface *iface);
 
 HRESULT WINAPI IWineGDISurfaceImpl_Blt(IWineD3DSurface *iface, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter);




More information about the wine-cvs mailing list