Mesa (master): mesa: rewrite, simplify some of the logic in _mesa_format_matches_format_and_type()

Brian Paul brianp at kemper.freedesktop.org
Sat Jan 28 01:25:36 UTC 2012


Module: Mesa
Branch: master
Commit: 952ca0785236729b69e154b3b48783fc4d9a5526
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=952ca0785236729b69e154b3b48783fc4d9a5526

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Jan 26 20:01:11 2012 -0700

mesa: rewrite, simplify some of the logic in _mesa_format_matches_format_and_type()

In preparation for adding GL_PACK/UNPACK_SWAP_BYTES support.

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/mesa/main/formats.c |   37 ++++++++++++++++++++++++++++---------
 1 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index d11b167..834d4c8 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -2543,21 +2543,40 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
       return GL_FALSE;
 
    case MESA_FORMAT_RGBA8888:
-      return ((format == GL_RGBA && (type == GL_UNSIGNED_INT_8_8_8_8 ||
-				     (type == GL_UNSIGNED_BYTE && !littleEndian))) ||
-	      (format == GL_ABGR_EXT && (type == GL_UNSIGNED_INT_8_8_8_8_REV ||
-					 (type == GL_UNSIGNED_BYTE && littleEndian))));
+      if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8)
+         return GL_TRUE;
+
+      if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && !littleEndian)
+         return GL_TRUE;
+
+      if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8_REV)
+         return GL_TRUE;
+
+      if (format == GL_ABGR_EXT && type == GL_UNSIGNED_BYTE && littleEndian)
+         return GL_TRUE;
+
+      return GL_FALSE;
 
    case MESA_FORMAT_RGBA8888_REV:
-      return ((format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8_REV));
+      return format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8_REV;
 
    case MESA_FORMAT_ARGB8888:
-      return ((format == GL_BGRA && (type == GL_UNSIGNED_INT_8_8_8_8_REV ||
-				     (type == GL_UNSIGNED_BYTE && littleEndian))));
+      if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV)
+         return GL_TRUE;
+
+      if (format == GL_BGRA && type == GL_UNSIGNED_BYTE && littleEndian)
+         return GL_TRUE;
+
+      return GL_FALSE;
 
    case MESA_FORMAT_ARGB8888_REV:
-      return ((format == GL_BGRA && (type == GL_UNSIGNED_INT_8_8_8_8 ||
-				     (type == GL_UNSIGNED_BYTE && !littleEndian))));
+      if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8)
+         return GL_TRUE;
+
+      if (format == GL_BGRA && type == GL_UNSIGNED_BYTE && !littleEndian)
+         return GL_TRUE;
+
+      return GL_FALSE;
 
    case MESA_FORMAT_RGBX8888:
    case MESA_FORMAT_RGBX8888_REV:




More information about the mesa-commit mailing list