mesa: rewrite, simplify some of the logic in _mesa_format_matches_format_and_type()
authorBrian Paul <brianp@vmware.com>
Fri, 27 Jan 2012 03:01:11 +0000 (20:01 -0700)
committerBrian Paul <brianp@vmware.com>
Sat, 28 Jan 2012 01:21:44 +0000 (18:21 -0700)
In preparation for adding GL_PACK/UNPACK_SWAP_BYTES support.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/formats.c

index d11b167f9006ab79462512b3c2900b73fe8879b2..834d4c81ffba5c3a36836871f3619ead0ae5024b 100644 (file)
@@ -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: