diff options
Diffstat (limited to 'src/mesa/main/texformat_tmp.h')
-rw-r--r-- | src/mesa/main/texformat_tmp.h | 94 |
1 files changed, 93 insertions, 1 deletions
diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h index 7a91e6393c6..8345cfc185c 100644 --- a/src/mesa/main/texformat_tmp.h +++ b/src/mesa/main/texformat_tmp.h @@ -1,4 +1,4 @@ -/* $Id: texformat_tmp.h,v 1.4 2002/05/09 20:51:05 keithw Exp $ */ +/* $Id: texformat_tmp.h,v 1.5 2002/06/15 02:38:16 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -284,6 +284,98 @@ static void FETCH(ci8)( const struct gl_texture_image *texImage, } +/* big-endian */ + +static void FETCH(abgr8888)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texel ) +{ + const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); + GLchan *rgba = (GLchan *) texel; + rgba[RCOMP] = UBYTE_TO_CHAN( src[3] ); + rgba[GCOMP] = UBYTE_TO_CHAN( src[2] ); + rgba[BCOMP] = UBYTE_TO_CHAN( src[1] ); + rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); +} + +static void FETCH(bgra8888)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texel ) +{ + const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); + GLchan *rgba = (GLchan *) texel; + rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); + rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); + rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); + rgba[ACOMP] = UBYTE_TO_CHAN( src[3] ); +} + +static void FETCH(bgr888)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texel ) +{ + const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 ); + GLchan *rgba = (GLchan *) texel; + rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); + rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); + rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); + rgba[ACOMP] = CHAN_MAX; +} + +static void FETCH(bgr565)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texel ) +{ + const GLushort *src = USHORT_SRC( texImage, i, j, k ); + GLchan *rgba = (GLchan *) texel; GLushort s = *src; + rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 ); + rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc ); + rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 ); + rgba[ACOMP] = CHAN_MAX; +} + +static void FETCH(bgra4444)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texel ) +{ + const GLushort *src = USHORT_SRC( texImage, i, j, k ); + GLchan *rgba = (GLchan *) texel; GLushort s = *src; + rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf ); + rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf ); + rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf ); + rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf ); +} + +static void FETCH(bgra5551)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texel ) +{ + const GLushort *src = USHORT_SRC( texImage, i, j, k ); + GLchan *rgba = (GLchan *) texel; GLushort s = *src; + rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f ); + rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f ); + rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f ); + rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 ); +} + +static void FETCH(la88)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texel ) +{ + const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 ); + GLchan *rgba = (GLchan *) texel; + rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); + rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); + rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); + rgba[ACOMP] = UBYTE_TO_CHAN( src[1] ); +} + +static void FETCH(bgr233)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texel ) +{ + const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); + GLchan *rgba = (GLchan *) texel; GLubyte s = *src; + rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 ); + rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 ); + rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 ); + rgba[ACOMP] = CHAN_MAX; +} + + + #undef CHAN_SRC #undef UBYTE_SRC #undef USHORT_SRC |