From 4c87bc0c410f3d40e8c612fdb7a02aa18d6af667 Mon Sep 17 00:00:00 2001 From: Roderick Colenbrander Date: Wed, 14 Apr 2010 14:19:18 +0200 Subject: [PATCH] wined3d: Move A4L4 conversion to the formats table. --- dlls/wined3d/surface.c | 27 --------------------------- dlls/wined3d/utils.c | 27 +++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 40921d6617e..667478dff5a 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -2223,15 +2223,6 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ } break; - case WINED3DFMT_L4A4_UNORM: - /* WINED3DFMT_L4A4_UNORM exists as an internal gl format, but for some reason there is not - * format+type combination to load it. Thus convert it to A8L8, then load it - * with A4L4 internal, but A8L8 format+type - */ - *convert = CONVERT_A4L4; - desc->conv_byte_count = 2; - break; - default: break; } @@ -2475,24 +2466,6 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI } break; - case CONVERT_A4L4: - { - unsigned int x, y; - const unsigned char *Source; - unsigned char *Dest; - for(y = 0; y < height; y++) { - Source = src + y * pitch; - Dest = dst + y * outpitch; - for (x = 0; x < width; x++ ) { - unsigned char color = (*Source++); - /* A */ Dest[1] = (color & 0xf0) << 0; - /* L */ Dest[0] = (color & 0x0f) << 4; - Dest += 2; - } - } - break; - } - default: ERR("Unsupported conversion type %#x.\n", convert); } diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index abe377058fa..5ebf92d713a 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -241,6 +241,29 @@ struct wined3d_format_texture_info void (*convert)(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height); }; +static void convert_l4a4_unorm(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height) +{ + /* WINED3DFMT_L4A4_UNORM exists as an internal gl format, but for some reason there is not + * format+type combination to load it. Thus convert it to A8L8, then load it + * with A4L4 internal, but A8L8 format+type + */ + unsigned int x, y; + const unsigned char *Source; + unsigned char *Dest; + UINT outpitch = pitch * 2; + + for(y = 0; y < height; y++) { + Source = src + y * pitch; + Dest = dst + y * outpitch; + for (x = 0; x < width; x++ ) { + unsigned char color = (*Source++); + /* A */ Dest[1] = (color & 0xf0) << 0; + /* L */ Dest[0] = (color & 0x0f) << 4; + Dest += 2; + } + } +} + static void convert_r5g5_snorm_l6_unorm(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height) { unsigned int x, y; @@ -703,9 +726,9 @@ static const struct wined3d_format_texture_info format_texture_info[] = WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, WINED3D_GL_EXT_NONE, NULL}, {WINED3DFMT_L4A4_UNORM, GL_LUMINANCE4_ALPHA4, GL_LUMINANCE4_ALPHA4, 0, - GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 0, + GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 2, 0, - WINED3D_GL_EXT_NONE, NULL}, + WINED3D_GL_EXT_NONE, &convert_l4a4_unorm}, /* Bump mapping stuff */ {WINED3DFMT_R8G8_SNORM, GL_RGB8, GL_RGB8, 0, GL_BGR, GL_UNSIGNED_BYTE, 3,