wined3d: Store color keys in textures instead of in surfaces.

This commit is contained in:
Henri Verbeet 2014-01-09 12:17:00 +01:00 committed by Alexandre Julliard
parent d412eb568e
commit 4710c4b51a
10 changed files with 139 additions and 139 deletions

View File

@ -4611,7 +4611,8 @@ static HRESULT WINAPI ddraw_surface7_SetColorKey(IDirectDrawSurface7 *iface, DWO
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
} }
ctx.ret = wined3d_surface_set_color_key(This->wined3d_surface, Flags, ctx.color_key); if (This->wined3d_texture)
ctx.ret = wined3d_texture_set_color_key(This->wined3d_texture, Flags, ctx.color_key);
ddraw_surface7_EnumAttachedSurfaces(iface, &ctx, SetColorKeyEnum); ddraw_surface7_EnumAttachedSurfaces(iface, &ctx, SetColorKeyEnum);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
@ -5897,6 +5898,19 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
root->is_complex_root = TRUE; root->is_complex_root = TRUE;
texture->root = root; texture->root = root;
if (desc->dwFlags & DDSD_CKDESTOVERLAY)
wined3d_texture_set_color_key(wined3d_texture, DDCKEY_DESTOVERLAY,
(struct wined3d_color_key *)&desc->u3.ddckCKDestOverlay);
if (desc->dwFlags & DDSD_CKDESTBLT)
wined3d_texture_set_color_key(wined3d_texture, DDCKEY_DESTBLT,
(struct wined3d_color_key *)&desc->ddckCKDestBlt);
if (desc->dwFlags & DDSD_CKSRCOVERLAY)
wined3d_texture_set_color_key(wined3d_texture, DDCKEY_SRCOVERLAY,
(struct wined3d_color_key *)&desc->ddckCKSrcOverlay);
if (desc->dwFlags & DDSD_CKSRCBLT)
wined3d_texture_set_color_key(wined3d_texture, DDCKEY_SRCBLT,
(struct wined3d_color_key *)&desc->ddckCKSrcBlt);
for (i = 0; i < layers; ++i) for (i = 0; i < layers; ++i)
{ {
attach = &root->complex_array[layers - 1 - i]; attach = &root->complex_array[layers - 1 - i];
@ -5987,6 +6001,19 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
last->wined3d_texture = wined3d_texture; last->wined3d_texture = wined3d_texture;
texture->root = last; texture->root = last;
if (desc->dwFlags & DDSD_CKDESTOVERLAY)
wined3d_texture_set_color_key(wined3d_texture, DDCKEY_DESTOVERLAY,
(struct wined3d_color_key *)&desc->u3.ddckCKDestOverlay);
if (desc->dwFlags & DDSD_CKDESTBLT)
wined3d_texture_set_color_key(wined3d_texture, DDCKEY_DESTBLT,
(struct wined3d_color_key *)&desc->ddckCKDestBlt);
if (desc->dwFlags & DDSD_CKSRCOVERLAY)
wined3d_texture_set_color_key(wined3d_texture, DDCKEY_SRCOVERLAY,
(struct wined3d_color_key *)&desc->ddckCKSrcOverlay);
if (desc->dwFlags & DDSD_CKSRCBLT)
wined3d_texture_set_color_key(wined3d_texture, DDCKEY_SRCBLT,
(struct wined3d_color_key *)&desc->ddckCKSrcBlt);
*attach = last; *attach = last;
attach = &last->complex_array[0]; attach = &last->complex_array[0];
} }
@ -6070,26 +6097,6 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, s
surface->surface_desc.u1.lPitch = wined3d_surface_get_pitch(wined3d_surface); surface->surface_desc.u1.lPitch = wined3d_surface_get_pitch(wined3d_surface);
} }
if (desc->dwFlags & DDSD_CKDESTOVERLAY)
{
wined3d_surface_set_color_key(wined3d_surface, DDCKEY_DESTOVERLAY,
(struct wined3d_color_key *)&desc->u3.ddckCKDestOverlay);
}
if (desc->dwFlags & DDSD_CKDESTBLT)
{
wined3d_surface_set_color_key(wined3d_surface, DDCKEY_DESTBLT,
(struct wined3d_color_key *)&desc->ddckCKDestBlt);
}
if (desc->dwFlags & DDSD_CKSRCOVERLAY)
{
wined3d_surface_set_color_key(wined3d_surface, DDCKEY_SRCOVERLAY,
(struct wined3d_color_key *)&desc->ddckCKSrcOverlay);
}
if (desc->dwFlags & DDSD_CKSRCBLT)
{
wined3d_surface_set_color_key(wined3d_surface, DDCKEY_SRCBLT,
(struct wined3d_color_key *)&desc->ddckCKSrcBlt);
}
if (desc->dwFlags & DDSD_LPSURFACE) if (desc->dwFlags & DDSD_LPSURFACE)
{ {
UINT pitch = 0; UINT pitch = 0;

View File

@ -7116,7 +7116,7 @@ static void upload_palette(const struct wined3d_surface *surface, struct wined3d
struct wined3d_device *device = surface->resource.device; struct wined3d_device *device = surface->resource.device;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct arbfp_blit_priv *priv = device->blit_priv; struct arbfp_blit_priv *priv = device->blit_priv;
BOOL colorkey = (surface->CKeyFlags & WINEDDSD_CKSRCBLT) != 0; BOOL colorkey = !!(surface->container->color_key_flags & WINEDDSD_CKSRCBLT);
d3dfmt_p8_init_palette(surface, table, colorkey); d3dfmt_p8_init_palette(surface, table, colorkey);

View File

@ -603,7 +603,7 @@ static void device_load_logo(struct wined3d_device *device, const char *filename
color_key.color_space_low_value = 0; color_key.color_space_low_value = 0;
color_key.color_space_high_value = 0; color_key.color_space_high_value = 0;
wined3d_surface_set_color_key(surface, WINEDDCKEY_SRCBLT, &color_key); wined3d_texture_set_color_key(device->logo_texture, WINEDDCKEY_SRCBLT, &color_key);
} }
else else
{ {

View File

@ -531,19 +531,15 @@ static void state_alpha(struct wined3d_context *context, const struct wined3d_st
TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id); TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
/* Find out if the texture on the first stage has a ckey set /* Find out if the texture on the first stage has a ckey set. The alpha
* The alpha state func reads the texture settings, even though alpha and texture are not grouped * state func reads the texture settings, even though alpha and texture
* together. This is to avoid making a huge alpha+texture+texture stage+ckey block due to the hardly * are not grouped together. This is to avoid making a huge alpha +
* used WINED3D_RS_COLORKEYENABLE state(which is d3d <= 3 only). The texture function will call alpha * texture + texture stage + ckey block due to the hardly used
* in case it finds some texture+colorkeyenable combination which needs extra care. * WINED3D_RS_COLORKEYENABLE state(which is d3d <= 3 only). The texture
*/ * function will call alpha in case it finds some texture + colorkeyenable
if (state->textures[0]) * combination which needs extra care. */
{ if (state->textures[0] && (state->textures[0]->color_key_flags & WINEDDSD_CKSRCBLT))
struct wined3d_surface *surface = surface_from_resource(state->textures[0]->sub_resources[0]); enable_ckey = TRUE;
if (surface->CKeyFlags & WINEDDSD_CKSRCBLT)
enable_ckey = TRUE;
}
if (enable_ckey || context->last_was_ckey) if (enable_ckey || context->last_was_ckey)
context_apply_state(context, state, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP)); context_apply_state(context, state, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP));
@ -3220,9 +3216,7 @@ void tex_alphaop(struct wined3d_context *context, const struct wined3d_state *st
if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB) if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB)
{ {
struct wined3d_surface *surf = surface_from_resource(texture->sub_resources[0]); if (texture->color_key_flags & WINEDDSD_CKSRCBLT && !texture->resource.format->alpha_size)
if (surf->CKeyFlags & WINEDDSD_CKSRCBLT && !surf->resource.format->alpha_size)
{ {
/* Color keying needs to pass alpha values from the texture through to have the alpha test work /* Color keying needs to pass alpha values from the texture through to have the alpha test work
* properly. On the other hand applications can still use texture combiners apparently. This code * properly. On the other hand applications can still use texture combiners apparently. This code

View File

@ -1814,7 +1814,7 @@ static void surface_upload_data(struct wined3d_surface *surface, const struct wi
static HRESULT d3dfmt_get_conv(const struct wined3d_surface *surface, BOOL need_alpha_ck, BOOL use_texturing, static HRESULT d3dfmt_get_conv(const struct wined3d_surface *surface, BOOL need_alpha_ck, BOOL use_texturing,
struct wined3d_format *format, enum wined3d_conversion_type *conversion_type) struct wined3d_format *format, enum wined3d_conversion_type *conversion_type)
{ {
BOOL colorkey_active = need_alpha_ck && (surface->CKeyFlags & WINEDDSD_CKSRCBLT); BOOL colorkey_active = need_alpha_ck && (surface->container->color_key_flags & WINEDDSD_CKSRCBLT);
const struct wined3d_device *device = surface->resource.device; const struct wined3d_device *device = surface->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
BOOL blit_supported = FALSE; BOOL blit_supported = FALSE;
@ -2269,13 +2269,15 @@ void surface_load(struct wined3d_surface *surface, BOOL srgb)
if (surface->resource.pool == WINED3D_POOL_SCRATCH) if (surface->resource.pool == WINED3D_POOL_SCRATCH)
ERR("Not supported on scratch surfaces.\n"); ERR("Not supported on scratch surfaces.\n");
ck_changed = !(surface->flags & SFLAG_GLCKEY) != !(surface->CKeyFlags & WINEDDSD_CKSRCBLT); ck_changed = !(surface->flags & SFLAG_GLCKEY) != !(surface->container->color_key_flags & WINEDDSD_CKSRCBLT);
/* Reload if either the texture and sysmem have different ideas about the /* Reload if either the texture and sysmem have different ideas about the
* color key, or the actual key values changed. */ * color key, or the actual key values changed. */
if (ck_changed || ((surface->CKeyFlags & WINEDDSD_CKSRCBLT) if (ck_changed || ((surface->container->color_key_flags & WINEDDSD_CKSRCBLT)
&& (surface->gl_color_key.color_space_low_value != surface->src_blt_color_key.color_space_low_value && (surface->gl_color_key.color_space_low_value
|| surface->gl_color_key.color_space_high_value != surface->src_blt_color_key.color_space_high_value))) != surface->container->src_blt_color_key.color_space_low_value
|| surface->gl_color_key.color_space_high_value
!= surface->container->src_blt_color_key.color_space_high_value)))
{ {
TRACE("Reloading because of color keying\n"); TRACE("Reloading because of color keying\n");
/* To perform the color key conversion we need a sysmem copy of /* To perform the color key conversion we need a sysmem copy of
@ -2511,68 +2513,6 @@ void CDECL wined3d_surface_set_palette(struct wined3d_surface *surface, struct w
surface->surface_ops->surface_realize_palette(surface); surface->surface_ops->surface_realize_palette(surface);
} }
HRESULT CDECL wined3d_surface_set_color_key(struct wined3d_surface *surface,
DWORD flags, const struct wined3d_color_key *color_key)
{
TRACE("surface %p, flags %#x, color_key %p.\n", surface, flags, color_key);
if (flags & WINEDDCKEY_COLORSPACE)
{
FIXME(" colorkey value not supported (%08x) !\n", flags);
return WINED3DERR_INVALIDCALL;
}
/* Dirtify the surface, but only if a key was changed. */
if (color_key)
{
switch (flags & ~WINEDDCKEY_COLORSPACE)
{
case WINEDDCKEY_DESTBLT:
surface->dst_blt_color_key = *color_key;
surface->CKeyFlags |= WINEDDSD_CKDESTBLT;
break;
case WINEDDCKEY_DESTOVERLAY:
surface->dst_overlay_color_key = *color_key;
surface->CKeyFlags |= WINEDDSD_CKDESTOVERLAY;
break;
case WINEDDCKEY_SRCOVERLAY:
surface->src_overlay_color_key = *color_key;
surface->CKeyFlags |= WINEDDSD_CKSRCOVERLAY;
break;
case WINEDDCKEY_SRCBLT:
surface->src_blt_color_key = *color_key;
surface->CKeyFlags |= WINEDDSD_CKSRCBLT;
break;
}
}
else
{
switch (flags & ~WINEDDCKEY_COLORSPACE)
{
case WINEDDCKEY_DESTBLT:
surface->CKeyFlags &= ~WINEDDSD_CKDESTBLT;
break;
case WINEDDCKEY_DESTOVERLAY:
surface->CKeyFlags &= ~WINEDDSD_CKDESTOVERLAY;
break;
case WINEDDCKEY_SRCOVERLAY:
surface->CKeyFlags &= ~WINEDDSD_CKSRCOVERLAY;
break;
case WINEDDCKEY_SRCBLT:
surface->CKeyFlags &= ~WINEDDSD_CKSRCBLT;
break;
}
}
return WINED3D_OK;
}
struct wined3d_palette * CDECL wined3d_surface_get_palette(const struct wined3d_surface *surface) struct wined3d_palette * CDECL wined3d_surface_get_palette(const struct wined3d_surface *surface)
{ {
TRACE("surface %p.\n", surface); TRACE("surface %p.\n", surface);
@ -3721,7 +3661,7 @@ void d3dfmt_p8_init_palette(const struct wined3d_surface *surface, BYTE table[25
* alpha component of pixels that should be masked away is set to 0. */ * alpha component of pixels that should be masked away is set to 0. */
if (index_in_alpha) if (index_in_alpha)
table[i][3] = i; table[i][3] = i;
else if (colorkey && color_in_range(&surface->src_blt_color_key, i)) else if (colorkey && color_in_range(&surface->container->src_blt_color_key, i))
table[i][3] = 0x00; table[i][3] = 0x00;
else if (pal->flags & WINED3D_PALETTE_ALPHA) else if (pal->flags & WINED3D_PALETTE_ALPHA)
table[i][3] = pal->palents[i].peFlags; table[i][3] = pal->palents[i].peFlags;
@ -3796,7 +3736,7 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI
for (x = 0; x < width; x++ ) { for (x = 0; x < width; x++ ) {
WORD color = *Source++; WORD color = *Source++;
*Dest = ((color & 0xffc0) | ((color & 0x1f) << 1)); *Dest = ((color & 0xffc0) | ((color & 0x1f) << 1));
if (!color_in_range(&surface->src_blt_color_key, color)) if (!color_in_range(&surface->container->src_blt_color_key, color))
*Dest |= 0x0001; *Dest |= 0x0001;
Dest++; Dest++;
} }
@ -3817,7 +3757,7 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI
for (x = 0; x < width; x++ ) { for (x = 0; x < width; x++ ) {
WORD color = *Source++; WORD color = *Source++;
*Dest = color; *Dest = color;
if (!color_in_range(&surface->src_blt_color_key, color)) if (!color_in_range(&surface->container->src_blt_color_key, color))
*Dest |= (1 << 15); *Dest |= (1 << 15);
else else
*Dest &= ~(1 << 15); *Dest &= ~(1 << 15);
@ -3838,7 +3778,7 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
DWORD color = ((DWORD)source[0] << 16) + ((DWORD)source[1] << 8) + (DWORD)source[2] ; DWORD color = ((DWORD)source[0] << 16) + ((DWORD)source[1] << 8) + (DWORD)source[2] ;
DWORD dstcolor = color << 8; DWORD dstcolor = color << 8;
if (!color_in_range(&surface->src_blt_color_key, color)) if (!color_in_range(&surface->container->src_blt_color_key, color))
dstcolor |= 0xff; dstcolor |= 0xff;
*(DWORD*)dest = dstcolor; *(DWORD*)dest = dstcolor;
source += 3; source += 3;
@ -3859,7 +3799,7 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
DWORD color = 0xffffff & *(const DWORD*)source; DWORD color = 0xffffff & *(const DWORD*)source;
DWORD dstcolor = color << 8; DWORD dstcolor = color << 8;
if (!color_in_range(&surface->src_blt_color_key, color)) if (!color_in_range(&surface->container->src_blt_color_key, color))
dstcolor |= 0xff; dstcolor |= 0xff;
*(DWORD*)dest = dstcolor; *(DWORD*)dest = dstcolor;
source += 4; source += 4;
@ -3879,7 +3819,7 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI
for (x = 0; x < width; ++x) for (x = 0; x < width; ++x)
{ {
DWORD color = *(const DWORD *)source; DWORD color = *(const DWORD *)source;
if (color_in_range(&surface->src_blt_color_key, color)) if (color_in_range(&surface->container->src_blt_color_key, color))
color &= ~0xff000000; color &= ~0xff000000;
*(DWORD*)dest = color; *(DWORD*)dest = color;
source += 4; source += 4;
@ -4422,7 +4362,7 @@ static void surface_blt_to_drawable(const struct wined3d_device *device,
* away have alpha set to 0. */ * away have alpha set to 0. */
if (swapchain_is_p8(context->swapchain)) if (swapchain_is_p8(context->swapchain))
gl_info->gl_ops.gl.p_glAlphaFunc(GL_NOTEQUAL, gl_info->gl_ops.gl.p_glAlphaFunc(GL_NOTEQUAL,
(float)src_surface->src_blt_color_key.color_space_low_value / 256.0f); (float)src_surface->container->src_blt_color_key.color_space_low_value / 256.0f);
else else
gl_info->gl_ops.gl.p_glAlphaFunc(GL_NOTEQUAL, 0.0f); gl_info->gl_ops.gl.p_glAlphaFunc(GL_NOTEQUAL, 0.0f);
checkGLcall("glAlphaFunc"); checkGLcall("glAlphaFunc");
@ -4598,8 +4538,8 @@ static HRESULT surface_blt_special(struct wined3d_surface *dst_surface, const RE
else if (src_surface) else if (src_surface)
{ {
/* Blit from offscreen surface to render target */ /* Blit from offscreen surface to render target */
struct wined3d_color_key old_blt_key = src_surface->src_blt_color_key; struct wined3d_color_key old_blt_key = src_surface->container->src_blt_color_key;
DWORD oldCKeyFlags = src_surface->CKeyFlags; DWORD old_color_key_flags = src_surface->container->color_key_flags;
TRACE("Blt from surface %p to rendertarget %p\n", src_surface, dst_surface); TRACE("Blt from surface %p to rendertarget %p\n", src_surface, dst_surface);
@ -4625,21 +4565,21 @@ static HRESULT surface_blt_special(struct wined3d_surface *dst_surface, const RE
else if (flags & WINEDDBLT_KEYSRCOVERRIDE) else if (flags & WINEDDBLT_KEYSRCOVERRIDE)
{ {
/* Use color key from DDBltFx */ /* Use color key from DDBltFx */
src_surface->CKeyFlags |= WINEDDSD_CKSRCBLT; src_surface->container->color_key_flags |= WINEDDSD_CKSRCBLT;
src_surface->src_blt_color_key = DDBltFx->ddckSrcColorkey; src_surface->container->src_blt_color_key = DDBltFx->ddckSrcColorkey;
} }
else else
{ {
/* Do not use color key */ /* Do not use color key */
src_surface->CKeyFlags &= ~WINEDDSD_CKSRCBLT; src_surface->container->color_key_flags &= ~WINEDDSD_CKSRCBLT;
} }
surface_blt_to_drawable(device, filter, flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE), surface_blt_to_drawable(device, filter, flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE),
src_surface, src_rect, dst_surface, dst_rect); src_surface, src_rect, dst_surface, dst_rect);
/* Restore the color key parameters */ /* Restore the color key parameters */
src_surface->CKeyFlags = oldCKeyFlags; src_surface->container->color_key_flags = old_color_key_flags;
src_surface->src_blt_color_key = old_blt_key; src_surface->container->src_blt_color_key = old_blt_key;
surface_validate_location(dst_surface, dst_surface->draw_binding); surface_validate_location(dst_surface, dst_surface->draw_binding);
surface_invalidate_location(dst_surface, ~dst_surface->draw_binding); surface_invalidate_location(dst_surface, ~dst_surface->draw_binding);
@ -5071,10 +5011,10 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
surface_prepare_texture(surface, context, srgb); surface_prepare_texture(surface, context, srgb);
wined3d_texture_bind_and_dirtify(surface->container, context, srgb); wined3d_texture_bind_and_dirtify(surface->container, context, srgb);
if (surface->CKeyFlags & WINEDDSD_CKSRCBLT) if (surface->container->color_key_flags & WINEDDSD_CKSRCBLT)
{ {
surface->flags |= SFLAG_GLCKEY; surface->flags |= SFLAG_GLCKEY;
surface->gl_color_key = surface->src_blt_color_key; surface->gl_color_key = surface->container->src_blt_color_key;
} }
else surface->flags &= ~SFLAG_GLCKEY; else surface->flags &= ~SFLAG_GLCKEY;
@ -5806,8 +5746,8 @@ do { \
/* The color keying flags are checked for correctness in ddraw */ /* The color keying flags are checked for correctness in ddraw */
if (flags & WINEDDBLT_KEYSRC) if (flags & WINEDDBLT_KEYSRC)
{ {
keylow = src_surface->src_blt_color_key.color_space_low_value; keylow = src_surface->container->src_blt_color_key.color_space_low_value;
keyhigh = src_surface->src_blt_color_key.color_space_high_value; keyhigh = src_surface->container->src_blt_color_key.color_space_high_value;
} }
else if (flags & WINEDDBLT_KEYSRCOVERRIDE) else if (flags & WINEDDBLT_KEYSRCOVERRIDE)
{ {
@ -5818,8 +5758,8 @@ do { \
if (flags & WINEDDBLT_KEYDEST) if (flags & WINEDDBLT_KEYDEST)
{ {
/* Destination color keys are taken from the source surface! */ /* Destination color keys are taken from the source surface! */
destkeylow = src_surface->dst_blt_color_key.color_space_low_value; destkeylow = src_surface->container->dst_blt_color_key.color_space_low_value;
destkeyhigh = src_surface->dst_blt_color_key.color_space_high_value; destkeyhigh = src_surface->container->dst_blt_color_key.color_space_high_value;
} }
else if (flags & WINEDDBLT_KEYDESTOVERRIDE) else if (flags & WINEDDBLT_KEYDESTOVERRIDE)
{ {

View File

@ -623,6 +623,67 @@ enum wined3d_texture_filter_type CDECL wined3d_texture_get_autogen_filter_type(c
return texture->filter_type; return texture->filter_type;
} }
HRESULT CDECL wined3d_texture_set_color_key(struct wined3d_texture *texture,
DWORD flags, const struct wined3d_color_key *color_key)
{
TRACE("texture %p, flags %#x, color_key %p.\n", texture, flags, color_key);
if (flags & WINEDDCKEY_COLORSPACE)
{
FIXME("Unhandled flags %#x.\n", flags);
return WINED3DERR_INVALIDCALL;
}
if (color_key)
{
switch (flags & ~WINEDDCKEY_COLORSPACE)
{
case WINEDDCKEY_DESTBLT:
texture->dst_blt_color_key = *color_key;
texture->color_key_flags |= WINEDDSD_CKDESTBLT;
break;
case WINEDDCKEY_DESTOVERLAY:
texture->dst_overlay_color_key = *color_key;
texture->color_key_flags |= WINEDDSD_CKDESTOVERLAY;
break;
case WINEDDCKEY_SRCOVERLAY:
texture->src_overlay_color_key = *color_key;
texture->color_key_flags |= WINEDDSD_CKSRCOVERLAY;
break;
case WINEDDCKEY_SRCBLT:
texture->src_blt_color_key = *color_key;
texture->color_key_flags |= WINEDDSD_CKSRCBLT;
break;
}
}
else
{
switch (flags & ~WINEDDCKEY_COLORSPACE)
{
case WINEDDCKEY_DESTBLT:
texture->color_key_flags &= ~WINEDDSD_CKDESTBLT;
break;
case WINEDDCKEY_DESTOVERLAY:
texture->color_key_flags &= ~WINEDDSD_CKDESTOVERLAY;
break;
case WINEDDCKEY_SRCOVERLAY:
texture->color_key_flags &= ~WINEDDSD_CKSRCOVERLAY;
break;
case WINEDDCKEY_SRCBLT:
texture->color_key_flags &= ~WINEDDSD_CKSRCBLT;
break;
}
}
return WINED3D_OK;
}
void CDECL wined3d_texture_generate_mipmaps(struct wined3d_texture *texture) void CDECL wined3d_texture_generate_mipmaps(struct wined3d_texture *texture)
{ {
/* TODO: Implement filters using GL_SGI_generate_mipmaps. */ /* TODO: Implement filters using GL_SGI_generate_mipmaps. */

View File

@ -3324,9 +3324,7 @@ void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d
if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB) if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB)
{ {
struct wined3d_surface *surf = surface_from_resource(texture->sub_resources[0]); if (texture->color_key_flags & WINEDDSD_CKSRCBLT && !texture->resource.format->alpha_size)
if (surf->CKeyFlags & WINEDDSD_CKSRCBLT && !surf->resource.format->alpha_size)
{ {
if (aop == WINED3D_TOP_DISABLE) if (aop == WINED3D_TOP_DISABLE)
{ {

View File

@ -222,7 +222,6 @@
@ cdecl wined3d_surface_preload(ptr) @ cdecl wined3d_surface_preload(ptr)
@ cdecl wined3d_surface_releasedc(ptr ptr) @ cdecl wined3d_surface_releasedc(ptr ptr)
@ cdecl wined3d_surface_restore(ptr) @ cdecl wined3d_surface_restore(ptr)
@ cdecl wined3d_surface_set_color_key(ptr long ptr)
@ cdecl wined3d_surface_set_overlay_position(ptr long long) @ cdecl wined3d_surface_set_overlay_position(ptr long long)
@ cdecl wined3d_surface_set_palette(ptr ptr) @ cdecl wined3d_surface_set_palette(ptr ptr)
@ cdecl wined3d_surface_set_priority(ptr long) @ cdecl wined3d_surface_set_priority(ptr long)
@ -260,6 +259,7 @@
@ cdecl wined3d_texture_incref(ptr) @ cdecl wined3d_texture_incref(ptr)
@ cdecl wined3d_texture_preload(ptr) @ cdecl wined3d_texture_preload(ptr)
@ cdecl wined3d_texture_set_autogen_filter_type(ptr long) @ cdecl wined3d_texture_set_autogen_filter_type(ptr long)
@ cdecl wined3d_texture_set_color_key(ptr long ptr)
@ cdecl wined3d_texture_set_lod(ptr long) @ cdecl wined3d_texture_set_lod(ptr long)
@ cdecl wined3d_texture_set_priority(ptr long) @ cdecl wined3d_texture_set_priority(ptr long)

View File

@ -2082,6 +2082,13 @@ struct wined3d_texture
const struct min_lookup *min_mip_lookup; const struct min_lookup *min_mip_lookup;
const GLenum *mag_lookup; const GLenum *mag_lookup;
GLenum target; GLenum target;
/* Color keys for DDraw */
struct wined3d_color_key dst_blt_color_key;
struct wined3d_color_key src_blt_color_key;
struct wined3d_color_key dst_overlay_color_key;
struct wined3d_color_key src_overlay_color_key;
DWORD color_key_flags;
}; };
static inline struct wined3d_texture *wined3d_texture_from_resource(struct wined3d_resource *resource) static inline struct wined3d_texture *wined3d_texture_from_resource(struct wined3d_resource *resource)
@ -2212,13 +2219,6 @@ struct wined3d_surface
HDC hDC; HDC hDC;
void *getdc_map_mem; void *getdc_map_mem;
/* Color keys for DDraw */
struct wined3d_color_key dst_blt_color_key;
struct wined3d_color_key src_blt_color_key;
struct wined3d_color_key dst_overlay_color_key;
struct wined3d_color_key src_overlay_color_key;
DWORD CKeyFlags;
struct wined3d_color_key gl_color_key; struct wined3d_color_key gl_color_key;
struct list renderbuffers; struct list renderbuffers;

View File

@ -2311,8 +2311,6 @@ HRESULT __cdecl wined3d_surface_map(struct wined3d_surface *surface,
void __cdecl wined3d_surface_preload(struct wined3d_surface *surface); void __cdecl wined3d_surface_preload(struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc); HRESULT __cdecl wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc);
HRESULT __cdecl wined3d_surface_restore(struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_restore(struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_set_color_key(struct wined3d_surface *surface,
DWORD flags, const struct wined3d_color_key *color_key);
HRESULT __cdecl wined3d_surface_set_overlay_position(struct wined3d_surface *surface, LONG x, LONG y); HRESULT __cdecl wined3d_surface_set_overlay_position(struct wined3d_surface *surface, LONG x, LONG y);
void __cdecl wined3d_surface_set_palette(struct wined3d_surface *surface, struct wined3d_palette *palette); void __cdecl wined3d_surface_set_palette(struct wined3d_surface *surface, struct wined3d_palette *palette);
DWORD __cdecl wined3d_surface_set_priority(struct wined3d_surface *surface, DWORD new_priority); DWORD __cdecl wined3d_surface_set_priority(struct wined3d_surface *surface, DWORD new_priority);
@ -2370,6 +2368,8 @@ ULONG __cdecl wined3d_texture_incref(struct wined3d_texture *texture);
void __cdecl wined3d_texture_preload(struct wined3d_texture *texture); void __cdecl wined3d_texture_preload(struct wined3d_texture *texture);
HRESULT __cdecl wined3d_texture_set_autogen_filter_type(struct wined3d_texture *texture, HRESULT __cdecl wined3d_texture_set_autogen_filter_type(struct wined3d_texture *texture,
enum wined3d_texture_filter_type filter_type); enum wined3d_texture_filter_type filter_type);
HRESULT __cdecl wined3d_texture_set_color_key(struct wined3d_texture *texture,
DWORD flags, const struct wined3d_color_key *color_key);
DWORD __cdecl wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod); DWORD __cdecl wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod);
DWORD __cdecl wined3d_texture_set_priority(struct wined3d_texture *texture, DWORD priority); DWORD __cdecl wined3d_texture_set_priority(struct wined3d_texture *texture, DWORD priority);