[PATCH] WINED3D: IWineGDISwapChainImpl_Present repaired when there is only one backbuffer
Pavel Prochazka
prochapa at inf.upol.cz
Wed May 27 07:36:01 CDT 2009
it fixes my yeasterday patch
---
dlls/wined3d/swapchain_gdi.c | 160 +++++++++++++++++++++++++++--------------
1 files changed, 105 insertions(+), 55 deletions(-)
diff --git a/dlls/wined3d/swapchain_gdi.c b/dlls/wined3d/swapchain_gdi.c
index 0d108b2..2c3fc25 100644
--- a/dlls/wined3d/swapchain_gdi.c
+++ b/dlls/wined3d/swapchain_gdi.c
@@ -175,70 +175,120 @@ static HRESULT WINAPI IWineGDISwapChainImpl_Present(IWineD3DSwapChain *iface, CO
front = (IWineD3DSurfaceImpl *) This->frontBuffer;
back = (IWineD3DSurfaceImpl *) This->backBuffer[0];
- int i=1;
-
- /*it moves all backbuffers by 1 to left form id = 1,
- the backbuffer swap to frontbuffer and frontbuffer swaps to the end of chain
- Something like this:
- ------------^
- | |
- |FrontBuffer| |BackBuffer0|BackBuffer1|Backbuffer2|....|BackbufferN|
- ^
- |---------------------------------------------------------------|
- ^
- |---------------------|
+ if(This->presentParms.BackBufferCount > 1) // I hope that will not have speed slowdowns
+ {
+ int i=1;
+
+ /*it moves all backbuffers by 1 to left form id = 1,
+ the backbuffer swap to frontbuffer and frontbuffer swaps to the end of chain
+ Something like this:
+ ------------^
+ | |
+ |FrontBuffer| |BackBuffer0|BackBuffer1|Backbuffer2|....|BackbufferN|
+ ^
+ |---------------------------------------------------------------|
+ ^
+ |---------------------|
- */
+ */
+
+ for(;i<This->presentParms.BackBufferCount-1;i++)
+ {
+ hlp1 = (IWineD3DSurfaceImpl *)This->backBuffer[i];
+ hlp2 = (IWineD3DSurfaceImpl *)This->backBuffer[i+1];
+ hlp1->hDC = hlp2->hDC;
+ hlp1->dib.DIBsection = hlp2->dib.DIBsection;
+ hlp1->dib.bitmap_data = hlp2->dib.bitmap_data;
+ hlp1->resource.allocatedMemory = hlp2->resource.allocatedMemory;
+ hlp1->dib.client_memory = hlp2->dib.client_memory;
+ }
- for(;i<This->presentParms.BackBufferCount-1;i++)
- {
+
+ //this places data from front buffer to end of backBuffer[]
hlp1 = (IWineD3DSurfaceImpl *)This->backBuffer[i];
- hlp2 = (IWineD3DSurfaceImpl *)This->backBuffer[i+1];
- hlp1->hDC = hlp2->hDC;
- hlp1->dib.DIBsection = hlp2->dib.DIBsection;
- hlp1->dib.bitmap_data = hlp2->dib.bitmap_data;
- hlp1->resource.allocatedMemory = hlp2->resource.allocatedMemory;
- hlp1->dib.client_memory = hlp2->dib.client_memory;
- }
-
- hlp1 = (IWineD3DSurfaceImpl *)This->backBuffer[i];
- hlp1->hDC = front->hDC;
- hlp1 = (IWineD3DSurfaceImpl *)This->backBuffer[i];
- hlp1->dib.DIBsection = front->dib.DIBsection;
- hlp1->dib.bitmap_data = front->dib.bitmap_data;
- hlp1->resource.allocatedMemory = front->resource.allocatedMemory;
- hlp1->dib.client_memory = front->dib.client_memory;
+ hlp1->hDC = front->hDC;
+ hlp1->dib.DIBsection = front->dib.DIBsection;
+ hlp1->dib.bitmap_data = front->dib.bitmap_data;
+ hlp1->resource.allocatedMemory = front->resource.allocatedMemory;
+ hlp1->dib.client_memory = front->dib.client_memory;
-
- /* Flip the DC */
- {
- front->hDC = back->hDC;
- }
-
- /* Flip the DIBsection */
- {
- front->dib.DIBsection = back->dib.DIBsection;
- }
-
- /* Flip the surface data */
- {
- front->dib.bitmap_data = back->dib.bitmap_data;
-
- front->resource.allocatedMemory = back->resource.allocatedMemory;
-
- if(front->resource.heapMemory) {
- ERR("GDI Surface %p has heap memory allocated\n", front);
- }
- if(back->resource.heapMemory) {
- ERR("GDI Surface %p has heap memory allocated\n", back);
- }
- }
-
- /* client_memory should not be different, but just in case */
- {
- front->dib.client_memory = back->dib.client_memory;
- }
+ //i don't know if this part is not too redundantive
+ /* Flip the DC */
+ {
+ front->hDC = back->hDC;
+ }
+
+ /* Flip the DIBsection */
+ {
+ front->dib.DIBsection = back->dib.DIBsection;
+ }
+
+ /* Flip the surface data */
+ {
+ front->dib.bitmap_data = back->dib.bitmap_data;
+
+ front->resource.allocatedMemory = back->resource.allocatedMemory;
+
+ if(front->resource.heapMemory) {
+ ERR("GDI Surface %p has heap memory allocated\n", front);
+ }
+ if(back->resource.heapMemory) {
+ ERR("GDI Surface %p has heap memory allocated\n", back);
+ }
+ }
+
+ /* client_memory should not be different, but just in case */
+ {
+ front->dib.client_memory = back->dib.client_memory;
+ }
+ }
+ else //when we have only 1 backbuffer
+ {
+ /* Flip the DC */
+ {
+ HDC tmp;
+ tmp = front->hDC;
+ front->hDC = back->hDC;
+ back->hDC = tmp;
+ }
+
+ /* Flip the DIBsection */
+ {
+ HBITMAP tmp;
+ tmp = front->dib.DIBsection;
+ front->dib.DIBsection = back->dib.DIBsection;
+ back->dib.DIBsection = tmp;
+ }
+
+ /* 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;
+
+ if(front->resource.heapMemory) {
+ ERR("GDI Surface %p has heap memory allocated\n", front);
+ }
+ if(back->resource.heapMemory) {
+ ERR("GDI Surface %p has heap memory allocated\n", back);
+ }
+ }
+
+ /* 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;
+ }
+ }
/* FPS support */
if (TRACE_ON(fps))
--
1.6.0.4
--------------020008080506030500090900--
More information about the wine-patches
mailing list