Commit 50b59552 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Use floating point colors in the blitter's color_fill functions.

parent 9956ea70
...@@ -7172,7 +7172,8 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_ ...@@ -7172,7 +7172,8 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_
return WINED3D_OK; return WINED3D_OK;
} }
static HRESULT arbfp_blit_color_fill(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD fill_color) static HRESULT arbfp_blit_color_fill(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface,
const RECT *dst_rect, const WINED3DCOLORVALUE *color)
{ {
FIXME("Color filling not implemented by arbfp_blit\n"); FIXME("Color filling not implemented by arbfp_blit\n");
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
......
...@@ -984,58 +984,56 @@ void surface_add_dirty_rect(IWineD3DSurfaceImpl *surface, const RECT *dirty_rect ...@@ -984,58 +984,56 @@ void surface_add_dirty_rect(IWineD3DSurfaceImpl *surface, const RECT *dirty_rect
} }
} }
static BOOL surface_convert_color_to_argb(IWineD3DSurfaceImpl *This, DWORD color, DWORD *argb_color) static BOOL surface_convert_color_to_float(IWineD3DSurfaceImpl *surface, DWORD color, WINED3DCOLORVALUE *float_color)
{ {
IWineD3DDeviceImpl *device = This->resource.device; const struct wined3d_format_desc *format = surface->resource.format_desc;
IWineD3DDeviceImpl *device = surface->resource.device;
switch(This->resource.format_desc->format) switch (format->format)
{ {
case WINED3DFMT_P8_UINT: case WINED3DFMT_P8_UINT:
if (surface->palette)
{ {
DWORD alpha; float_color->r = surface->palette->palents[color].peRed / 255.0f;
float_color->g = surface->palette->palents[color].peGreen / 255.0f;
if (primary_render_target_is_p8(device)) float_color->b = surface->palette->palents[color].peBlue / 255.0f;
alpha = color << 24;
else
alpha = 0xFF000000;
if (This->palette) {
*argb_color = (alpha |
(This->palette->palents[color].peRed << 16) |
(This->palette->palents[color].peGreen << 8) |
(This->palette->palents[color].peBlue));
} else {
*argb_color = alpha;
}
} }
else
{
float_color->r = 0.0f;
float_color->g = 0.0f;
float_color->b = 0.0f;
}
float_color->a = primary_render_target_is_p8(device) ? color / 255.0f : 1.0f;
break; break;
case WINED3DFMT_B5G6R5_UNORM: case WINED3DFMT_B5G6R5_UNORM:
{ float_color->r = ((color >> 11) & 0x1f) / 31.0f;
if (color == 0xFFFF) { float_color->g = ((color >> 5) & 0x3f) / 63.0f;
*argb_color = 0xFFFFFFFF; float_color->b = (color & 0x1f) / 31.0f;
} else { float_color->a = 1.0f;
*argb_color = ((0xFF000000) |
((color & 0xF800) << 8) |
((color & 0x07E0) << 5) |
((color & 0x001F) << 3));
}
}
break; break;
case WINED3DFMT_B8G8R8_UNORM: case WINED3DFMT_B8G8R8_UNORM:
case WINED3DFMT_B8G8R8X8_UNORM: case WINED3DFMT_B8G8R8X8_UNORM:
*argb_color = 0xFF000000 | color; float_color->r = D3DCOLOR_R(color);
float_color->g = D3DCOLOR_G(color);
float_color->b = D3DCOLOR_B(color);
float_color->a = 1.0f;
break; break;
case WINED3DFMT_B8G8R8A8_UNORM: case WINED3DFMT_B8G8R8A8_UNORM:
*argb_color = color; float_color->r = D3DCOLOR_R(color);
float_color->g = D3DCOLOR_G(color);
float_color->b = D3DCOLOR_B(color);
float_color->a = D3DCOLOR_A(color);
break; break;
default: default:
ERR("Unhandled conversion from %s to ARGB!\n", debug_d3dformat(This->resource.format_desc->format)); ERR("Unhandled conversion from %s to floating point.\n", debug_d3dformat(format->format));
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
...@@ -3720,35 +3718,33 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface, ...@@ -3720,35 +3718,33 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
surface_modify_location(dst_surface, SFLAG_INDRAWABLE, TRUE); surface_modify_location(dst_surface, SFLAG_INDRAWABLE, TRUE);
return WINED3D_OK; return WINED3D_OK;
} else { }
else
{
/* Source-Less Blit to render target */ /* Source-Less Blit to render target */
if (Flags & WINEDDBLT_COLORFILL) { if (Flags & WINEDDBLT_COLORFILL)
DWORD color; {
WINED3DCOLORVALUE color;
TRACE("Colorfill\n"); TRACE("Colorfill\n");
/* The color as given in the Blt function is in the format of the frame-buffer... /* The color as given in the Blt function is in the surface format. */
* 'clear' expect it in ARGB format => we need to do some conversion :-) if (!surface_convert_color_to_float(dst_surface, DDBltFx->u5.dwFillColor, &color))
*/
if (!surface_convert_color_to_argb(dst_surface, DDBltFx->u5.dwFillColor, &color))
{
/* The color conversion function already prints an error, so need to do it here */
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
}
if (ffp_blit.blit_supported(&device->adapter->gl_info, BLIT_OP_COLOR_FILL, if (ffp_blit.blit_supported(&device->adapter->gl_info, BLIT_OP_COLOR_FILL,
NULL, 0, 0, NULL, NULL, 0, 0, NULL,
&dst_rect, dst_surface->resource.usage, dst_surface->resource.pool, &dst_rect, dst_surface->resource.usage, dst_surface->resource.pool,
dst_surface->resource.format_desc)) dst_surface->resource.format_desc))
{ {
return ffp_blit.color_fill(device, dst_surface, &dst_rect, color); return ffp_blit.color_fill(device, dst_surface, &dst_rect, &color);
} }
else if (cpu_blit.blit_supported(&device->adapter->gl_info, BLIT_OP_COLOR_FILL, else if (cpu_blit.blit_supported(&device->adapter->gl_info, BLIT_OP_COLOR_FILL,
NULL, 0, 0, NULL, NULL, 0, 0, NULL,
&dst_rect, dst_surface->resource.usage, dst_surface->resource.pool, &dst_rect, dst_surface->resource.usage, dst_surface->resource.pool,
dst_surface->resource.format_desc)) dst_surface->resource.format_desc))
{ {
return cpu_blit.color_fill(device, dst_surface, &dst_rect, color); return cpu_blit.color_fill(device, dst_surface, &dst_rect, &color);
} }
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
...@@ -4869,14 +4865,13 @@ static BOOL ffp_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_ ...@@ -4869,14 +4865,13 @@ static BOOL ffp_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_
return FALSE; return FALSE;
} }
static HRESULT ffp_blit_color_fill(IWineD3DDeviceImpl *device, static HRESULT ffp_blit_color_fill(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface,
IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD color) const RECT *dst_rect, const WINED3DCOLORVALUE *color)
{ {
const WINED3DCOLORVALUE c = {D3DCOLOR_R(color), D3DCOLOR_G(color), D3DCOLOR_B(color), D3DCOLOR_A(color)};
const RECT draw_rect = {0, 0, dst_surface->currentDesc.Width, dst_surface->currentDesc.Height}; const RECT draw_rect = {0, 0, dst_surface->currentDesc.Width, dst_surface->currentDesc.Height};
return device_clear_render_targets(device, 1 /* rt_count */, &dst_surface, 1 /* rect_count */, return device_clear_render_targets(device, 1 /* rt_count */, &dst_surface, 1 /* rect_count */,
dst_rect, &draw_rect, WINED3DCLEAR_TARGET, &c, 0.0f /* depth */, 0 /* stencil */); dst_rect, &draw_rect, WINED3DCLEAR_TARGET, color, 0.0f /* depth */, 0 /* stencil */);
} }
const struct blit_shader ffp_blit = { const struct blit_shader ffp_blit = {
...@@ -4923,15 +4918,14 @@ static BOOL cpu_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_ ...@@ -4923,15 +4918,14 @@ static BOOL cpu_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_
return FALSE; return FALSE;
} }
static HRESULT cpu_blit_color_fill(IWineD3DDeviceImpl *device, static HRESULT cpu_blit_color_fill(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface,
IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD color) const RECT *dst_rect, const WINED3DCOLORVALUE *color)
{ {
const WINED3DCOLORVALUE c = {D3DCOLOR_R(color), D3DCOLOR_G(color), D3DCOLOR_B(color), D3DCOLOR_A(color)};
WINEDDBLTFX BltFx; WINEDDBLTFX BltFx;
memset(&BltFx, 0, sizeof(BltFx)); memset(&BltFx, 0, sizeof(BltFx));
BltFx.dwSize = sizeof(BltFx); BltFx.dwSize = sizeof(BltFx);
BltFx.u5.dwFillColor = wined3d_format_convert_from_float(dst_surface->resource.format_desc, &c); BltFx.u5.dwFillColor = wined3d_format_convert_from_float(dst_surface->resource.format_desc, color);
return IWineD3DBaseSurfaceImpl_Blt((IWineD3DSurface*)dst_surface, dst_rect, return IWineD3DBaseSurfaceImpl_Blt((IWineD3DSurface*)dst_surface, dst_rect,
NULL, NULL, WINEDDBLT_COLORFILL, &BltFx, WINED3DTEXF_POINT); NULL, NULL, WINEDDBLT_COLORFILL, &BltFx, WINED3DTEXF_POINT);
} }
......
...@@ -1143,7 +1143,8 @@ struct blit_shader ...@@ -1143,7 +1143,8 @@ struct blit_shader
BOOL (*blit_supported)(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op, BOOL (*blit_supported)(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool, const struct wined3d_format_desc *src_format_desc, const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool, const struct wined3d_format_desc *src_format_desc,
const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool, const struct wined3d_format_desc *dst_format_desc); const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool, const struct wined3d_format_desc *dst_format_desc);
HRESULT (*color_fill)(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD fill_color); HRESULT (*color_fill)(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface,
const RECT *dst_rect, const WINED3DCOLORVALUE *color);
}; };
extern const struct blit_shader ffp_blit DECLSPEC_HIDDEN; extern const struct blit_shader ffp_blit DECLSPEC_HIDDEN;
......
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