Roderick Colenbrander : wined3d: Fix a bug in BtlFast which was uncovered by the 32-bit dibsection support.
Alexandre Julliard
julliard at winehq.org
Thu Dec 17 10:37:08 CST 2009
Module: wine
Branch: master
Commit: 6d8c4572efae3b7e8e64100504c10270b2168079
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6d8c4572efae3b7e8e64100504c10270b2168079
Author: Roderick Colenbrander <thunderbird2k at gmail.com>
Date: Sat Nov 14 16:30:25 2009 +0100
wined3d: Fix a bug in BtlFast which was uncovered by the 32-bit dibsection support.
---
dlls/ddraw/tests/dsurface.c | 34 ++++++++++++++++++++++++++++++++++
dlls/wined3d/surface_base.c | 10 +++++++++-
2 files changed, 43 insertions(+), 1 deletions(-)
diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c
index ab0408b..d53d6a0 100644
--- a/dlls/ddraw/tests/dsurface.c
+++ b/dlls/ddraw/tests/dsurface.c
@@ -304,6 +304,40 @@ static void SrcColorKey32BlitTest(void)
rc = IDirectDrawSurface_Unlock(lpDst, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
+ /* Below we repeat the same test as above but now using BltFast instead of Blt. Before
+ * we can carry out the test we need to restore the color of the destination surface.
+ */
+ rc = IDirectDrawSurface_Lock(lpDst, NULL, &ddsd2, DDLOCK_WAIT, NULL);
+ ok(rc==DD_OK,"Lock returned: %x\n",rc);
+ lpData = ddsd2.lpSurface;
+ lpData[0] = 0xCCCCCCCC;
+ lpData[1] = 0xCCCCCCCC;
+ lpData[2] = 0xCCCCCCCC;
+ lpData[3] = 0xCCCCCCCC;
+ rc = IDirectDrawSurface_Unlock(lpDst, NULL);
+ ok(rc==DD_OK,"Unlock returned: %x\n",rc);
+
+ IDirectDrawSurface_BltFast(lpDst, 0, 0, lpSrc, NULL, DDBLTFAST_SRCCOLORKEY);
+
+ rc = IDirectDrawSurface_Lock(lpDst, NULL, &ddsd2, DDLOCK_WAIT, NULL);
+ ok(rc==DD_OK,"Lock returned: %x\n",rc);
+ ok((ddsd2.dwFlags & DDSD_LPSURFACE) == 0, "Surface desc has LPSURFACE Flags set\n");
+ lpData = ddsd2.lpSurface;
+ /* Different behavior on some drivers / windows versions. Some versions ignore the X channel when
+ * color keying, but copy it to the destination surface. Others apply it for color keying, but
+ * do not copy it into the destination surface.
+ */
+ if(lpData[0]==0x00010203) {
+ trace("X channel was not copied into the destination surface\n");
+ ok((lpData[0]==0x00010203)&&(lpData[1]==0x00010203)&&(lpData[2]==0x00FF00FF)&&(lpData[3]==0xCCCCCCCC),
+ "Destination data after blitting is not correct\n");
+ } else {
+ ok((lpData[0]==0x77010203)&&(lpData[1]==0x00010203)&&(lpData[2]==0xCCCCCCCC)&&(lpData[3]==0xCCCCCCCC),
+ "Destination data after blitting is not correct\n");
+ }
+ rc = IDirectDrawSurface_Unlock(lpDst, NULL);
+ ok(rc==DD_OK,"Unlock returned: %x\n",rc);
+
/* Also test SetColorKey */
IDirectDrawSurface_GetColorKey(lpSrc, DDCKEY_SRCBLT, &DDColorKey);
ok(DDColorKey.dwColorSpaceLowValue == 0xFF00FF && DDColorKey.dwColorSpaceHighValue == 0xFF00FF,
diff --git a/dlls/wined3d/surface_base.c b/dlls/wined3d/surface_base.c
index c737f99..dc29ad2 100644
--- a/dlls/wined3d/surface_base.c
+++ b/dlls/wined3d/surface_base.c
@@ -1695,6 +1695,14 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dst
if (trans & (WINEDDBLTFAST_SRCCOLORKEY | WINEDDBLTFAST_DESTCOLORKEY))
{
DWORD keylow, keyhigh;
+ DWORD mask = Src->resource.format_desc->red_mask |
+ Src->resource.format_desc->green_mask |
+ Src->resource.format_desc->blue_mask;
+
+ /* For some 8-bit formats like L8 and P8 color masks don't make sense */
+ if(!mask && bpp==1)
+ mask = 0xff;
+
TRACE("Color keyed copy\n");
if (trans & WINEDDBLTFAST_SRCCOLORKEY)
{
@@ -1716,7 +1724,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dst
for (y = 0; y < h; y++) { \
for (x = 0; x < w; x++) { \
tmp = s[x]; \
- if (tmp < keylow || tmp > keyhigh) d[x] = tmp; \
+ if ((tmp & mask) < keylow || (tmp & mask) > keyhigh) d[x] = tmp; \
} \
s = (const type *)((const BYTE *)s + slock.Pitch); \
d = (type *)((BYTE *)d + dlock.Pitch); \
More information about the wine-cvs
mailing list