Commit e95ffacd authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

ddraw: Make SetColorKey handle case where dwColorSpaceHighValue < dwColorSpaceLowValue + tests.

parent 6a5bd0c2
......@@ -2429,31 +2429,37 @@ IDirectDrawSurfaceImpl_SetColorKey(IDirectDrawSurface7 *iface,
DDCOLORKEY *CKey)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
struct SCKContext ctx = { DD_OK, (WINEDDCOLORKEY *) CKey, Flags };
DDCOLORKEY FixedCKey;
struct SCKContext ctx = { DD_OK, (WINEDDCOLORKEY *) (CKey ? &FixedCKey : NULL), Flags };
TRACE("(%p)->(%x,%p)\n", This, Flags, CKey);
EnterCriticalSection(&ddraw_cs);
if (CKey)
{
FixedCKey = *CKey;
/* Handle case where dwColorSpaceHighValue < dwColorSpaceLowValue */
if (FixedCKey.dwColorSpaceHighValue < FixedCKey.dwColorSpaceLowValue)
FixedCKey.dwColorSpaceHighValue = FixedCKey.dwColorSpaceLowValue;
switch (Flags & ~DDCKEY_COLORSPACE)
{
case DDCKEY_DESTBLT:
This->surface_desc.ddckCKDestBlt = *CKey;
This->surface_desc.ddckCKDestBlt = FixedCKey;
This->surface_desc.dwFlags |= DDSD_CKDESTBLT;
break;
case DDCKEY_DESTOVERLAY:
This->surface_desc.u3.ddckCKDestOverlay = *CKey;
This->surface_desc.u3.ddckCKDestOverlay = FixedCKey;
This->surface_desc.dwFlags |= DDSD_CKDESTOVERLAY;
break;
case DDCKEY_SRCOVERLAY:
This->surface_desc.ddckCKSrcOverlay = *CKey;
This->surface_desc.ddckCKSrcOverlay = FixedCKey;
This->surface_desc.dwFlags |= DDSD_CKSRCOVERLAY;
break;
case DDCKEY_SRCBLT:
This->surface_desc.ddckCKSrcBlt = *CKey;
This->surface_desc.ddckCKSrcBlt = FixedCKey;
This->surface_desc.dwFlags |= DDSD_CKSRCBLT;
break;
......
......@@ -325,6 +325,37 @@ static void SrcColorKey32BlitTest(void)
ok(ddsd.ddckCKSrcBlt.dwColorSpaceLowValue == 0x00FF00 && ddsd.ddckCKSrcBlt.dwColorSpaceHighValue == 0x00FF00,
"GetSurfaceDesc does not return the colorkey set with SetColorKey\n");
/* Test SetColorKey with dwColorSpaceHighValue < dwColorSpaceLowValue */
DDColorKey.dwColorSpaceLowValue = 0x0000FF;
DDColorKey.dwColorSpaceHighValue = 0x000000;
IDirectDrawSurface_SetColorKey(lpSrc, DDCKEY_SRCBLT, &DDColorKey);
DDColorKey.dwColorSpaceLowValue = 0;
DDColorKey.dwColorSpaceHighValue = 0;
IDirectDrawSurface_GetColorKey(lpSrc, DDCKEY_SRCBLT, &DDColorKey);
ok(DDColorKey.dwColorSpaceLowValue == 0x0000FF && DDColorKey.dwColorSpaceHighValue == 0x0000FF,
"GetColorKey does not return the colorkey set with SetColorKey (%x %x)\n", DDColorKey.dwColorSpaceLowValue, DDColorKey.dwColorSpaceHighValue);
DDColorKey.dwColorSpaceLowValue = 0x0000FF;
DDColorKey.dwColorSpaceHighValue = 0x000001;
IDirectDrawSurface_SetColorKey(lpSrc, DDCKEY_SRCBLT, &DDColorKey);
DDColorKey.dwColorSpaceLowValue = 0;
DDColorKey.dwColorSpaceHighValue = 0;
IDirectDrawSurface_GetColorKey(lpSrc, DDCKEY_SRCBLT, &DDColorKey);
ok(DDColorKey.dwColorSpaceLowValue == 0x0000FF && DDColorKey.dwColorSpaceHighValue == 0x0000FF,
"GetColorKey does not return the colorkey set with SetColorKey (%x %x)\n", DDColorKey.dwColorSpaceLowValue, DDColorKey.dwColorSpaceHighValue);
DDColorKey.dwColorSpaceLowValue = 0x0000FF;
DDColorKey.dwColorSpaceHighValue = 0x0000FE;
IDirectDrawSurface_SetColorKey(lpSrc, DDCKEY_SRCBLT, &DDColorKey);
DDColorKey.dwColorSpaceLowValue = 0;
DDColorKey.dwColorSpaceHighValue = 0;
IDirectDrawSurface_GetColorKey(lpSrc, DDCKEY_SRCBLT, &DDColorKey);
ok(DDColorKey.dwColorSpaceLowValue == 0x0000FF && DDColorKey.dwColorSpaceHighValue == 0x0000FF,
"GetColorKey does not return the colorkey set with SetColorKey (%x %x)\n", DDColorKey.dwColorSpaceLowValue, DDColorKey.dwColorSpaceHighValue);
IDirectDrawSurface_Release(lpSrc);
IDirectDrawSurface_Release(lpDst);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment