diff options
author | Chia-I Wu <[email protected]> | 2011-11-22 15:05:25 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2011-11-27 12:43:24 +0800 |
commit | d4fcf67a3ac78c29448000486dadc2b4b1b2a56d (patch) | |
tree | de68969c78428e72aef94a30adcd94c389bc56c4 /src/mesa/main/format_unpack.c | |
parent | 6baa5f10c04641960e0bedce664d0a5cf39e8954 (diff) |
mesa: add MESA_FORMAT_RGBX8888 and MESA_FORMAT_RGBX8888_REV
MESA_FORMAT_RGBX8888_REV is one of the opaque pixel formats used on Android.
Thanks to texture-from-pixmap, drivers may actually see texture images with
this format on Android.
MESA_FORMAT_RGBX8888 is added only for completeness.
Reviewed-by: Brian Paul <[email protected]>
[olv: Move the new formats after MESA_FORMAT_ARGB8888_REV in gl_format. I
accidentally moved them to the wrong place when preparing the patch.]
Diffstat (limited to 'src/mesa/main/format_unpack.c')
-rw-r--r-- | src/mesa/main/format_unpack.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c index 080392f2bca..2f051dfa4bc 100644 --- a/src/mesa/main/format_unpack.c +++ b/src/mesa/main/format_unpack.c @@ -113,6 +113,32 @@ unpack_ARGB8888_REV(const void *src, GLfloat dst[][4], GLuint n) } static void +unpack_RGBX8888(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLuint *s = ((const GLuint *) src); + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = UBYTE_TO_FLOAT( (s[i] >> 24) ); + dst[i][GCOMP] = UBYTE_TO_FLOAT( (s[i] >> 16) & 0xff ); + dst[i][BCOMP] = UBYTE_TO_FLOAT( (s[i] >> 8) & 0xff ); + dst[i][ACOMP] = 1.0f; + } +} + +static void +unpack_RGBX8888_REV(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLuint *s = ((const GLuint *) src); + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = UBYTE_TO_FLOAT( (s[i] ) & 0xff ); + dst[i][GCOMP] = UBYTE_TO_FLOAT( (s[i] >> 8) & 0xff ); + dst[i][BCOMP] = UBYTE_TO_FLOAT( (s[i] >> 16) & 0xff ); + dst[i][ACOMP] = 1.0f; + } +} + +static void unpack_XRGB8888(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); @@ -1405,6 +1431,8 @@ get_unpack_rgba_function(gl_format format) table[MESA_FORMAT_RGBA8888_REV] = unpack_RGBA8888_REV; table[MESA_FORMAT_ARGB8888] = unpack_ARGB8888; table[MESA_FORMAT_ARGB8888_REV] = unpack_ARGB8888_REV; + table[MESA_FORMAT_RGBX8888] = unpack_RGBX8888; + table[MESA_FORMAT_RGBX8888_REV] = unpack_RGBX8888_REV; table[MESA_FORMAT_XRGB8888] = unpack_XRGB8888; table[MESA_FORMAT_XRGB8888_REV] = unpack_XRGB8888_REV; table[MESA_FORMAT_RGB888] = unpack_RGB888; |