[Mesa-dev] [PATCH] mesa: fix PACK_COLOR_5551(), PACK_COLOR_1555() macros

Michel Dänzer michel at daenzer.net
Mon Sep 19 23:48:42 PDT 2011


On Mon, 2011-09-19 at 18:29 -0600, Brian Paul wrote: 
> From: Brian Paul <brianp at vmware.com>
> 
> The 1-bit alpha channel was incorrectly encoded.  Previously, any non-zero
> alpha value for the ubyte alpha value would set A=1.  Instead, use the
> most significant bit of the ubyte alpha to determine the A bit.  This is
> consistent with the other channels and other OpenGL implementations.
> ---
>  src/mesa/main/colormac.h |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h
> index 0b8864a..4294f32 100644
> --- a/src/mesa/main/colormac.h
> +++ b/src/mesa/main/colormac.h
> @@ -74,11 +74,11 @@ _mesa_unclamped_float_rgba_to_ubyte(GLubyte dst[4], const GLfloat src[4])
>  
>  #define PACK_COLOR_5551( R, G, B, A )					\
>     ((((R) & 0xf8) << 8) | (((G) & 0xf8) << 3) | (((B) & 0xf8) >> 2) |	\
> -    ((A) ? 1 : 0))
> +    ((A) >> 7))
>  
>  #define PACK_COLOR_1555( A, B, G, R )					\
>     ((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) |	\
> -    ((A) ? 0x8000 : 0))
> +    (((A) & 0x80) << 8))
>  
>  #define PACK_COLOR_1555_REV( A, B, G, R )					\
>     ((((B) & 0xf8) >> 1) | (((G) & 0xc0) >> 6) | (((G) & 0x38) << 10) | (((R) & 0xf8) << 5) |	\

Reviewed-by: Michel Dänzer <michel at daenzer.net>


-- 
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer


More information about the mesa-dev mailing list