[PATCH] WineD3D: Implement overlay flipping=0A=
Stefan Doesinger
stefan at codeweavers.com
Thu Jul 24 11:38:51 CDT 2008
=0A=
---=0A=
dlls/ddraw/surface.c | 2 +-=0A=
dlls/wined3d/surface.c | 89 =
+++++++++++++++++++++++++++++++++++++++-=0A=
dlls/wined3d/swapchain.c | 72 +--------------------------------=0A=
dlls/wined3d/wined3d_private.h | 2 +=0A=
4 files changed, 91 insertions(+), 74 deletions(-)=0A=
=0A=
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c=0A=
index bc25218..1cf4d57 100644=0A=
--- a/dlls/ddraw/surface.c=0A=
+++ b/dlls/ddraw/surface.c=0A=
@@ -710,7 +710,7 @@ IDirectDrawSurfaceImpl_Flip(IDirectDrawSurface7 =
*iface,=0A=
/* Flip has to be called from a front buffer=0A=
* What about overlay surfaces, AFAIK they can flip too?=0A=
*/=0A=
- if( !(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER) )=0A=
+ if( !(This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | =
DDSCAPS_OVERLAY)) )=0A=
return DDERR_INVALIDOBJECT; /* Unchecked */=0A=
=0A=
EnterCriticalSection(&ddraw_cs);=0A=
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c=0A=
index 42ce5d1..1ea221c 100644=0A=
--- a/dlls/wined3d/surface.c=0A=
+++ b/dlls/wined3d/surface.c=0A=
@@ -2622,14 +2622,99 @@ HRESULT WINAPI =
IWineD3DSurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {=0A=
return WINED3D_OK;=0A=
}=0A=
=0A=
+void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl =
*back) {=0A=
+=0A=
+ /* Flip the surface contents */=0A=
+ /* Flip the DC */=0A=
+ {=0A=
+ HDC tmp;=0A=
+ tmp =3D front->hDC;=0A=
+ front->hDC =3D back->hDC;=0A=
+ back->hDC =3D tmp;=0A=
+ }=0A=
+=0A=
+ /* Flip the DIBsection */=0A=
+ {=0A=
+ HBITMAP tmp;=0A=
+ BOOL hasDib =3D front->Flags & SFLAG_DIBSECTION;=0A=
+ tmp =3D front->dib.DIBsection;=0A=
+ front->dib.DIBsection =3D back->dib.DIBsection;=0A=
+ back->dib.DIBsection =3D tmp;=0A=
+=0A=
+ if(back->Flags & SFLAG_DIBSECTION) front->Flags |=3D =
SFLAG_DIBSECTION;=0A=
+ else front->Flags &=3D ~SFLAG_DIBSECTION;=0A=
+ if(hasDib) back->Flags |=3D SFLAG_DIBSECTION;=0A=
+ else back->Flags &=3D ~SFLAG_DIBSECTION;=0A=
+ }=0A=
+=0A=
+ /* Flip the surface data */=0A=
+ {=0A=
+ void* tmp;=0A=
+=0A=
+ tmp =3D front->dib.bitmap_data;=0A=
+ front->dib.bitmap_data =3D back->dib.bitmap_data;=0A=
+ back->dib.bitmap_data =3D tmp;=0A=
+=0A=
+ tmp =3D front->resource.allocatedMemory;=0A=
+ front->resource.allocatedMemory =3D =
back->resource.allocatedMemory;=0A=
+ back->resource.allocatedMemory =3D tmp;=0A=
+=0A=
+ tmp =3D front->resource.heapMemory;=0A=
+ front->resource.heapMemory =3D back->resource.heapMemory;=0A=
+ back->resource.heapMemory =3D tmp;=0A=
+ }=0A=
+=0A=
+ /* Flip the PBO */=0A=
+ {=0A=
+ GLuint tmp_pbo =3D front->pbo;=0A=
+ front->pbo =3D back->pbo;=0A=
+ back->pbo =3D tmp_pbo;=0A=
+ }=0A=
+=0A=
+ /* client_memory should not be different, but just in case */=0A=
+ {=0A=
+ BOOL tmp;=0A=
+ tmp =3D front->dib.client_memory;=0A=
+ front->dib.client_memory =3D back->dib.client_memory;=0A=
+ back->dib.client_memory =3D tmp;=0A=
+ }=0A=
+=0A=
+ /* Flip the opengl texture */=0A=
+ {=0A=
+ glDescriptor tmp_desc =3D back->glDescription;=0A=
+ back->glDescription =3D front->glDescription;=0A=
+ front->glDescription =3D tmp_desc;=0A=
+ }=0A=
+=0A=
+ {=0A=
+ DWORD tmp_flags =3D back->Flags;=0A=
+ back->Flags =3D front->Flags;=0A=
+ front->Flags =3D tmp_flags;=0A=
+ }=0A=
+}=0A=
+=0A=
static HRESULT WINAPI IWineD3DSurfaceImpl_Flip(IWineD3DSurface *iface, =
IWineD3DSurface *override, DWORD Flags) {=0A=
IWineD3DSurfaceImpl *This =3D (IWineD3DSurfaceImpl *)iface;=0A=
IWineD3DSwapChainImpl *swapchain =3D NULL;=0A=
HRESULT hr;=0A=
TRACE("(%p)->(%p,%x)\n", This, override, Flags);=0A=
=0A=
- /* Flipping is only supported on RenderTargets */=0A=
- if( !(This->resource.usage & WINED3DUSAGE_RENDERTARGET) ) return =
WINEDDERR_NOTFLIPPABLE;=0A=
+ /* Flipping is only supported on RenderTargets and overlays*/=0A=
+ if( !(This->resource.usage & (WINED3DUSAGE_RENDERTARGET | =
WINED3DUSAGE_OVERLAY)) ) {=0A=
+ WARN("Tried to flip a non-render target, non-overlay =
surface\n");=0A=
+ return WINEDDERR_NOTFLIPPABLE;=0A=
+ }=0A=
+=0A=
+ if(This->resource.usage & WINED3DUSAGE_OVERLAY) {=0A=
+ flip_surface(This, (IWineD3DSurfaceImpl *) override);=0A=
+=0A=
+ /* Update the overlay if it is visible */=0A=
+ if(This->overlay_dest) {=0A=
+ return IWineD3DSurface_DrawOverlay((IWineD3DSurface *) =
This);=0A=
+ } else {=0A=
+ return WINED3D_OK;=0A=
+ }=0A=
+ }=0A=
=0A=
if(override) {=0A=
/* DDraw sets this for the X11 surfaces, so don't confuse the =
user =0A=
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c=0A=
index e564a81..77655d0 100644=0A=
--- a/dlls/wined3d/swapchain.c=0A=
+++ b/dlls/wined3d/swapchain.c=0A=
@@ -307,79 +307,9 @@ static HRESULT WINAPI =
IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO=0A=
/* Both memory copies of the surfaces are ok, flip them around =
too instead of dirtifying */=0A=
IWineD3DSurfaceImpl *front =3D (IWineD3DSurfaceImpl *) =
This->frontBuffer;=0A=
IWineD3DSurfaceImpl *back =3D (IWineD3DSurfaceImpl *) =
This->backBuffer[0];=0A=
- BOOL frontuptodate =3D front->Flags & SFLAG_INSYSMEM;=0A=
- BOOL backuptodate =3D back->Flags & SFLAG_INSYSMEM;=0A=
=0A=
if(front->resource.size =3D=3D back->resource.size) {=0A=
- /* Flip the DC */=0A=
- {=0A=
- HDC tmp;=0A=
- tmp =3D front->hDC;=0A=
- front->hDC =3D back->hDC;=0A=
- back->hDC =3D tmp;=0A=
- }=0A=
-=0A=
- /* Flip the DIBsection */=0A=
- {=0A=
- HBITMAP tmp;=0A=
- BOOL hasDib =3D front->Flags & SFLAG_DIBSECTION;=0A=
- tmp =3D front->dib.DIBsection;=0A=
- front->dib.DIBsection =3D back->dib.DIBsection;=0A=
- back->dib.DIBsection =3D tmp;=0A=
-=0A=
- if(back->Flags & SFLAG_DIBSECTION) front->Flags |=3D =
SFLAG_DIBSECTION;=0A=
- else front->Flags &=3D ~SFLAG_DIBSECTION;=0A=
- if(hasDib) back->Flags |=3D SFLAG_DIBSECTION;=0A=
- else back->Flags &=3D ~SFLAG_DIBSECTION;=0A=
- }=0A=
-=0A=
- /* Flip the surface data */=0A=
- {=0A=
- void* tmp;=0A=
-=0A=
- tmp =3D front->dib.bitmap_data;=0A=
- front->dib.bitmap_data =3D back->dib.bitmap_data;=0A=
- back->dib.bitmap_data =3D tmp;=0A=
-=0A=
- tmp =3D front->resource.allocatedMemory;=0A=
- front->resource.allocatedMemory =3D =
back->resource.allocatedMemory;=0A=
- back->resource.allocatedMemory =3D tmp;=0A=
-=0A=
- tmp =3D front->resource.heapMemory;=0A=
- front->resource.heapMemory =3D =
back->resource.heapMemory;=0A=
- back->resource.heapMemory =3D tmp;=0A=
- }=0A=
-=0A=
- /* Flip the PBO */=0A=
- {=0A=
- DWORD tmp_flags =3D front->Flags;=0A=
-=0A=
- GLuint tmp_pbo =3D front->pbo;=0A=
- front->pbo =3D back->pbo;=0A=
- back->pbo =3D tmp_pbo;=0A=
-=0A=
- if(back->Flags & SFLAG_PBO)=0A=
- front->Flags |=3D SFLAG_PBO;=0A=
- else=0A=
- front->Flags &=3D ~SFLAG_PBO;=0A=
-=0A=
- if(tmp_flags & SFLAG_PBO)=0A=
- back->Flags |=3D SFLAG_PBO;=0A=
- else=0A=
- back->Flags &=3D ~SFLAG_PBO;=0A=
- }=0A=
-=0A=
- /* client_memory should not be different, but just in case =
*/=0A=
- {=0A=
- BOOL tmp;=0A=
- tmp =3D front->dib.client_memory;=0A=
- front->dib.client_memory =3D back->dib.client_memory;=0A=
- back->dib.client_memory =3D tmp;=0A=
- }=0A=
- if(frontuptodate) back->Flags |=3D SFLAG_INSYSMEM;=0A=
- else back->Flags &=3D ~SFLAG_INSYSMEM;=0A=
- if(backuptodate) front->Flags |=3D SFLAG_INSYSMEM;=0A=
- else front->Flags &=3D ~SFLAG_INSYSMEM;=0A=
+ flip_surface(front, back);=0A=
} else {=0A=
IWineD3DSurface_ModifyLocation((IWineD3DSurface *) front, =
SFLAG_INDRAWABLE, TRUE);=0A=
IWineD3DSurface_ModifyLocation((IWineD3DSurface *) back, =
SFLAG_INDRAWABLE, TRUE);=0A=
diff --git a/dlls/wined3d/wined3d_private.h =
b/dlls/wined3d/wined3d_private.h=0A=
index f253d41..27d070e 100644=0A=
--- a/dlls/wined3d/wined3d_private.h=0A=
+++ b/dlls/wined3d/wined3d_private.h=0A=
@@ -1379,6 +1379,8 @@ void =
get_drawable_size_backbuffer(IWineD3DSurfaceImpl *This, UINT *width, =
UINT *=0A=
void get_drawable_size_pbuffer(IWineD3DSurfaceImpl *This, UINT *width, =
UINT *height);=0A=
void get_drawable_size_fbo(IWineD3DSurfaceImpl *This, UINT *width, UINT =
*height);=0A=
=0A=
+void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl =
*back);=0A=
+=0A=
/* Surface flags: */=0A=
#define SFLAG_OVERSIZE 0x00000001 /* Surface is bigger than gl =
size, blts only */=0A=
#define SFLAG_CONVERTED 0x00000002 /* Converted for color keying or =
Palettized */=0A=
-- =0A=
1.5.4.5=0A=
=0A=
------=_NextPart_000_0029_01C8F640.8D8AE8D0--
More information about the wine-patches
mailing list