/***************************************************************************** * 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 = 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; }
void surface_gdi_cleanup(IWineD3DSurfaceImpl *This) { 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((IWineD3DSurface *)This, NULL); if (This->overlay_dest) list_remove(&This->overlay_entry); HeapFree(GetProcessHeap(), 0, This->palette9); resource_cleanup((IWineD3DResource *)This); }