Commit 9c257586 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Support color keyed WINED3DFMT_B8G8R8A8_UNORM surfaces.

Color keying and alpha channels aren't mutually exclusive.
parent 07f58347
......@@ -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;
}
}
......
......@@ -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);
}
......
......@@ -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,
......
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