Henri Verbeet : wined3d: Introduce surface_cleanup().
Alexandre Julliard
julliard at winehq.org
Mon Jun 15 07:59:06 CDT 2009
Module: wine
Branch: master
Commit: 32613eb628fc50f28baf912610738001fbe5ffd9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=32613eb628fc50f28baf912610738001fbe5ffd9
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Mon Jun 15 09:06:49 2009 +0200
wined3d: Introduce surface_cleanup().
---
dlls/wined3d/surface.c | 112 +++++++++++++++++++++++++++---------------------
1 files changed, 63 insertions(+), 49 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 116cff0..a3ecf29 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -34,6 +34,64 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
WINE_DECLARE_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
+static void surface_cleanup(IWineD3DSurfaceImpl *This)
+{
+ IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
+ renderbuffer_entry_t *entry, *entry2;
+
+ TRACE("(%p) : Cleaning up.\n", This);
+
+ /* Need a context to destroy the texture. Use the currently active render
+ * target, but only if the primary render target exists. Otherwise
+ * lastActiveRenderTarget is garbage. When destroying the primary render
+ * target, Uninit3D() will activate a context before doing anything. */
+ if (device->render_targets && device->render_targets[0])
+ {
+ ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
+ }
+
+ ENTER_GL();
+
+ if (This->glDescription.textureName)
+ {
+ /* Release the OpenGL texture. */
+ TRACE("Deleting texture %u.\n", This->glDescription.textureName);
+ glDeleteTextures(1, &This->glDescription.textureName);
+ }
+
+ if (This->Flags & SFLAG_PBO)
+ {
+ /* Delete the PBO. */
+ GL_EXTCALL(glDeleteBuffersARB(1, &This->pbo));
+ }
+
+ LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &This->renderbuffers, renderbuffer_entry_t, entry)
+ {
+ GL_EXTCALL(glDeleteRenderbuffersEXT(1, &entry->id));
+ HeapFree(GetProcessHeap(), 0, entry);
+ }
+
+ LEAVE_GL();
+
+ 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);
+}
+
static void surface_force_reload(IWineD3DSurface *iface)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
@@ -540,59 +598,15 @@ static ULONG WINAPI IWineD3DSurfaceImpl_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;
- renderbuffer_entry_t *entry, *entry2;
- TRACE("(%p) : cleaning up\n", This);
-
- /* Need a context to destroy the texture. Use the currently active render target, but only if
- * the primary render target exists. Otherwise lastActiveRenderTarget is garbage, see above.
- * When destroying the primary rt, Uninit3D will activate a context before doing anything
- */
- if(device->render_targets && device->render_targets[0]) {
- ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
- }
-
- ENTER_GL();
- if (This->glDescription.textureName != 0) { /* release the openGL texture.. */
- TRACE("Deleting texture %d\n", This->glDescription.textureName);
- glDeleteTextures(1, &This->glDescription.textureName);
- }
-
- if(This->Flags & SFLAG_PBO) {
- /* Delete the PBO */
- GL_EXTCALL(glDeleteBuffersARB(1, &This->pbo));
- }
- LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &This->renderbuffers, renderbuffer_entry_t, entry) {
- GL_EXTCALL(glDeleteRenderbuffersEXT(1, &entry->id));
- HeapFree(GetProcessHeap(), 0, entry);
- }
- LEAVE_GL();
-
- 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);
-
- resource_cleanup((IWineD3DResource *)iface);
-
- if(This->overlay_dest) {
- list_remove(&This->overlay_entry);
- }
+ if (!ref)
+ {
+ surface_cleanup(This);
- TRACE("(%p) Released\n", This);
+ TRACE("(%p) Released.\n", This);
HeapFree(GetProcessHeap(), 0, This);
-
}
+
return ref;
}
More information about the wine-cvs
mailing list