From 43fda1f4f0d4b88003b2ac1ff092aa9ba8783b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Mon, 28 May 2007 21:21:43 +0200 Subject: [PATCH] wined3d: Only swap system memory resources of front and back buffer if they have the same size. --- dlls/wined3d/swapchain.c | 95 +++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 45 deletions(-) diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 18d9b3d0e81..262eb7f24c6 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -321,52 +321,57 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO BOOL frontuptodate = front->Flags & SFLAG_INSYSMEM; BOOL backuptodate = back->Flags & SFLAG_INSYSMEM; - /* Flip the DC */ - { - HDC tmp; - tmp = front->hDC; - front->hDC = back->hDC; - back->hDC = tmp; + if(front->resource.size == back->resource.size) { + /* Flip the DC */ + { + HDC tmp; + tmp = front->hDC; + front->hDC = back->hDC; + back->hDC = tmp; + } + + /* Flip the DIBsection */ + { + HBITMAP tmp; + BOOL hasDib = front->Flags & SFLAG_DIBSECTION; + tmp = front->dib.DIBsection; + front->dib.DIBsection = back->dib.DIBsection; + back->dib.DIBsection = tmp; + + if(back->Flags & SFLAG_DIBSECTION) front->Flags |= SFLAG_DIBSECTION; + else front->Flags &= ~SFLAG_DIBSECTION; + if(hasDib) back->Flags |= SFLAG_DIBSECTION; + else back->Flags &= ~SFLAG_DIBSECTION; + } + + /* Flip the surface data */ + { + void* tmp; + + tmp = front->dib.bitmap_data; + front->dib.bitmap_data = back->dib.bitmap_data; + back->dib.bitmap_data = tmp; + + tmp = front->resource.allocatedMemory; + front->resource.allocatedMemory = back->resource.allocatedMemory; + back->resource.allocatedMemory = tmp; + } + + /* client_memory should not be different, but just in case */ + { + BOOL tmp; + tmp = front->dib.client_memory; + front->dib.client_memory = back->dib.client_memory; + back->dib.client_memory = tmp; + } + if(frontuptodate) back->Flags |= SFLAG_INSYSMEM; + else back->Flags &= ~SFLAG_INSYSMEM; + if(backuptodate) front->Flags |= SFLAG_INSYSMEM; + else front->Flags &= ~SFLAG_INSYSMEM; + } else { + back->Flags &= ~SFLAG_INSYSMEM; + front->Flags &= ~SFLAG_INSYSMEM; } - - /* Flip the DIBsection */ - { - HBITMAP tmp; - BOOL hasDib = front->Flags & SFLAG_DIBSECTION; - tmp = front->dib.DIBsection; - front->dib.DIBsection = back->dib.DIBsection; - back->dib.DIBsection = tmp; - - if(back->Flags & SFLAG_DIBSECTION) front->Flags |= SFLAG_DIBSECTION; - else front->Flags &= ~SFLAG_DIBSECTION; - if(hasDib) back->Flags |= SFLAG_DIBSECTION; - else back->Flags &= ~SFLAG_DIBSECTION; - } - - /* Flip the surface data */ - { - void* tmp; - - tmp = front->dib.bitmap_data; - front->dib.bitmap_data = back->dib.bitmap_data; - back->dib.bitmap_data = tmp; - - tmp = front->resource.allocatedMemory; - front->resource.allocatedMemory = back->resource.allocatedMemory; - back->resource.allocatedMemory = tmp; - } - - /* client_memory should not be different, but just in case */ - { - BOOL tmp; - tmp = front->dib.client_memory; - front->dib.client_memory = back->dib.client_memory; - back->dib.client_memory = tmp; - } - if(frontuptodate) back->Flags |= SFLAG_INSYSMEM; - else back->Flags &= ~SFLAG_INSYSMEM; - if(backuptodate) front->Flags |= SFLAG_INSYSMEM; - else front->Flags &= ~SFLAG_INSYSMEM; } TRACE("returning\n");