Module: wine Branch: refs/heads/master Commit: 3127d6401a789c7db5675a1682feb845016835b2 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=3127d6401a789c7db5675a16...
Author: Roderick Colenbrander thunderbird2k@gmx.net Date: Wed Jul 26 23:19:04 2006 +0200
wined3d: BltFast/BltOverride color keying.
---
dlls/wined3d/surface.c | 40 +++++++++++++++++++++++++++++++++------- 1 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 8a5a8a8..00d68c2 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1635,13 +1635,13 @@ static HRESULT WINAPI IWineD3DSurfaceImp if (This->Flags & SFLAG_DIRTY) { TRACE("Reloading because surface is dirty\n"); } else if(/* Reload: gl texture has ck, now no ckey is set OR */ - (This->Flags & SFLAG_GLCKEY && !(This->CKeyFlags & DDSD_CKSRCBLT)) || + ((This->Flags & SFLAG_GLCKEY) && (!(This->CKeyFlags & DDSD_CKSRCBLT))) || /* Reload: vice versa OR */ - (!(This->Flags & SFLAG_GLCKEY) && !This->CKeyFlags & DDSD_CKSRCBLT) || + ((!(This->Flags & SFLAG_GLCKEY)) && (This->CKeyFlags & DDSD_CKSRCBLT)) || /* Also reload: Color key is active AND the color key has changed */ - (This->CKeyFlags & DDSD_CKSRCBLT) && ( - This->glCKey.dwColorSpaceLowValue != This->SrcBltCKey.dwColorSpaceLowValue || - This->glCKey.dwColorSpaceHighValue != This->SrcBltCKey.dwColorSpaceHighValue)) { + ((This->CKeyFlags & DDSD_CKSRCBLT) && ( + (This->glCKey.dwColorSpaceLowValue != This->SrcBltCKey.dwColorSpaceLowValue) || + (This->glCKey.dwColorSpaceHighValue != This->SrcBltCKey.dwColorSpaceHighValue)))) { TRACE("Reloading because of color keying\n"); } else { TRACE("surface isn't dirty\n"); @@ -2304,6 +2304,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOv ( swapchain->backBuffer && (IWineD3DSurface *) Src != swapchain->backBuffer[0]) ) ) { float glTexCoord[4]; DWORD oldCKey; + DDCOLORKEY oldBltCKey = {0,0}; GLint oldLight, oldFog, oldDepth, oldBlend, oldCull, oldAlpha; GLint alphafunc; GLclampf alpharef; @@ -2345,6 +2346,16 @@ static HRESULT IWineD3DSurfaceImpl_BltOv Src->CKeyFlags &= ~DDSD_CKSRCBLT; }
+ /* Color keying */ + if(Flags & DDBLT_KEYDEST) { + oldBltCKey = This->SrcBltCKey; + /* Temporary replace the source color key with the destination one. We do this because the color conversion code which + * is in the end called from LoadTexture works with the source color. At the end of this function we restore the color key. + */ + This->SrcBltCKey = This->DestBltCKey; + } else if (Flags & DDBLT_KEYSRC) + oldBltCKey = This->SrcBltCKey; + /* Now load the surface */ IWineD3DSurface_PreLoad((IWineD3DSurface *) Src);
@@ -2506,11 +2517,15 @@ static HRESULT IWineD3DSurfaceImpl_BltOv glDrawBuffer(oldDraw); }
- /* Restore the color key */ + /* Restore the color key flags */ if(oldCKey != Src->CKeyFlags) { Src->CKeyFlags = oldCKey; }
+ /* Restore the old color key */ + if (Flags & (DDBLT_KEYSRC | DDBLT_KEYDEST)) + This->SrcBltCKey = oldBltCKey; + LEAVE_GL();
/* TODO: If the surface is locked often, perform the Blt in software on the memory instead */ @@ -2759,6 +2774,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_BltFa ( srcImpl && (srcImpl->resource.usage & WINED3DUSAGE_RENDERTARGET) )) {
RECT SrcRect, DstRect; + DWORD Flags=0;
if(rsrc) { SrcRect.left = rsrc->left; @@ -2777,7 +2793,17 @@ HRESULT WINAPI IWineD3DSurfaceImpl_BltFa DstRect.right = dstx + SrcRect.right - SrcRect.left; DstRect.bottom = dsty + SrcRect.bottom - SrcRect.top;
- if(IWineD3DSurfaceImpl_BltOverride(This, &DstRect, Source, &SrcRect, 0, NULL) == WINED3D_OK) return WINED3D_OK; + /* Convert BltFast flags into Btl ones because it is called from SurfaceImpl_Blt aswell */ + if(trans & DDBLTFAST_SRCCOLORKEY) + Flags |= DDBLT_KEYSRC; + if(trans & DDBLTFAST_DESTCOLORKEY) + Flags |= DDBLT_KEYDEST; + if(trans & DDBLTFAST_WAIT) + Flags |= DDBLT_WAIT; + if(trans & DDBLTFAST_DONOTWAIT) + Flags |= DDBLT_DONOTWAIT; + + if(IWineD3DSurfaceImpl_BltOverride(This, &DstRect, Source, &SrcRect, Flags, NULL) == WINED3D_OK) return WINED3D_OK; }