wined3d: Support color keyed WINED3DFMT_B8G8R8A8_UNORM surfaces.

Color keying and alpha channels aren't mutually exclusive.
oldstable
Henri Verbeet 2012-02-28 19:48:40 +01:00 committed by Alexandre Julliard
parent 07f583478e
commit 9c25758656
3 changed files with 30 additions and 6 deletions

View File

@ -538,12 +538,7 @@ static void state_alpha(struct wined3d_context *context, const struct wined3d_st
struct wined3d_surface *surf = surface_from_resource(texture->sub_resources[0]);
if (surf->CKeyFlags & WINEDDSD_CKSRCBLT)
{
/* The surface conversion does not do color keying conversion for surfaces that have an alpha
* channel on their own. Likewise, the alpha test shouldn't be set up for color keying if the
* surface has alpha bits */
if (!surf->resource.format->alpha_mask) enable_ckey = TRUE;
}
enable_ckey = TRUE;
}
}

View File

@ -4554,6 +4554,14 @@ HRESULT d3dfmt_get_conv(const struct wined3d_surface *surface, BOOL need_alpha_c
}
break;
case WINED3DFMT_B8G8R8A8_UNORM:
if (colorkey_active)
{
*conversion_type = WINED3D_CT_CK_ARGB32;
format->conv_byte_count = 4;
}
break;
default:
break;
}
@ -4765,6 +4773,26 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI
}
break;
case WINED3D_CT_CK_ARGB32:
{
unsigned int x, y;
for (y = 0; y < height; ++y)
{
source = src + pitch * y;
dest = dst + outpitch * y;
for (x = 0; x < width; ++x)
{
DWORD color = *(const DWORD *)source;
if (color_in_range(&surface->src_blt_color_key, color))
color &= ~0xff000000;
*(DWORD*)dest = color;
source += 4;
dest += 4;
}
}
}
break;
default:
ERR("Unsupported conversion type %#x.\n", conversion_type);
}

View File

@ -2192,6 +2192,7 @@ enum wined3d_conversion_type
WINED3D_CT_CK_5551,
WINED3D_CT_CK_RGB24,
WINED3D_CT_RGB32_888,
WINED3D_CT_CK_ARGB32,
};
HRESULT d3dfmt_get_conv(const struct wined3d_surface *surface, BOOL need_alpha_ck, BOOL use_texturing,