mesa: Add a _mesa_is_format_color_format helper
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 26 Aug 2014 21:26:44 +0000 (14:26 -0700)
committerIago Toral Quiroga <itoral@igalia.com>
Mon, 12 Jan 2015 10:20:28 +0000 (11:20 +0100)
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mesa/main/formats.c
src/mesa/main/formats.h

index b10b628..6eb80fb 100644 (file)
@@ -472,6 +472,25 @@ _mesa_is_format_integer(mesa_format format)
    return (info->DataType == GL_INT || info->DataType == GL_UNSIGNED_INT);
 }
 
+
+/**
+ * Return true if the given format is a color format.
+ */
+GLenum
+_mesa_is_format_color_format(mesa_format format)
+{
+   const struct gl_format_info *info = _mesa_get_format_info(format);
+   switch (info->BaseFormat) {
+   case GL_DEPTH_COMPONENT:
+   case GL_STENCIL_INDEX:
+   case GL_DEPTH_STENCIL:
+      return false;
+   default:
+      return true;
+   }
+}
+
+
 /**
  * Return color encoding for given format.
  * \return GL_LINEAR or GL_SRGB
index dd07c35..4f83208 100644 (file)
@@ -625,6 +625,9 @@ _mesa_is_format_integer(mesa_format format);
 extern bool
 _mesa_is_format_etc2(mesa_format format);
 
+GLenum
+_mesa_is_format_color_format(mesa_format format);
+
 extern GLenum
 _mesa_get_format_color_encoding(mesa_format format);