mesa: Remove support for named parameters.
[mesa.git] / src / mesa / main / format_unpack.c
index c42bac19c722356611d2e88602b55055563ea809..7b46dfc791bb666802cc456639c12fc06f884060 100644 (file)
@@ -609,6 +609,20 @@ unpack_ARGB2101010(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 
+static void
+unpack_ABGR2101010_UINT(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] = (GLfloat)((s[i] >>  0) & 0x3ff);
+      dst[i][GCOMP] = (GLfloat)((s[i] >> 10) & 0x3ff);
+      dst[i][BCOMP] = (GLfloat)((s[i] >> 20) & 0x3ff);
+      dst[i][ACOMP] = (GLfloat)((s[i] >> 30) &  0x03);
+   }
+}
+
+
 static void
 unpack_Z24_S8(const void *src, GLfloat dst[][4], GLuint n)
 {
@@ -1499,6 +1513,7 @@ get_unpack_rgba_function(gl_format format)
       table[MESA_FORMAT_RG1616] = unpack_RG1616;
       table[MESA_FORMAT_RG1616_REV] = unpack_RG1616_REV;
       table[MESA_FORMAT_ARGB2101010] = unpack_ARGB2101010;
+      table[MESA_FORMAT_ABGR2101010_UINT] = unpack_ABGR2101010_UINT;
       table[MESA_FORMAT_Z24_S8] = unpack_Z24_S8;
       table[MESA_FORMAT_S8_Z24] = unpack_S8_Z24;
       table[MESA_FORMAT_Z16] = unpack_Z16;
@@ -1589,6 +1604,11 @@ get_unpack_rgba_function(gl_format format)
       initialized = GL_TRUE;
    }
 
+   if (table[format] == NULL) {
+      _mesa_problem(NULL, "unsupported unpack for format %s",
+                    _mesa_get_format_name(format));
+   }
+
    return table[format];
 }
 
@@ -2058,7 +2078,7 @@ _mesa_unpack_ubyte_rgba_row(gl_format format, GLuint n,
    default:
       /* get float values, convert to ubyte */
       {
-         GLfloat *tmp = (GLfloat *) malloc(n * 4 * sizeof(GLfloat));
+         GLfloat *tmp = malloc(n * 4 * sizeof(GLfloat));
          if (tmp) {
             GLuint i;
             _mesa_unpack_rgba_row(format, n, src, (GLfloat (*)[4]) tmp);
@@ -2138,6 +2158,32 @@ unpack_int_rgba_RGBA_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
    }
 }
 
+static void
+unpack_int_rgba_ARGB8888(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][RCOMP] = (GLubyte) src[i * 4 + 2];
+      dst[i][GCOMP] = (GLubyte) src[i * 4 + 1];
+      dst[i][BCOMP] = (GLubyte) src[i * 4 + 0];
+      dst[i][ACOMP] = (GLubyte) src[i * 4 + 3];
+   }
+}
+
+static void
+unpack_int_rgba_XRGB8888(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][RCOMP] = (GLubyte) src[i * 4 + 2];
+      dst[i][GCOMP] = (GLubyte) src[i * 4 + 1];
+      dst[i][BCOMP] = (GLubyte) src[i * 4 + 0];
+      dst[i][ACOMP] = (GLubyte) 0xff;
+   }
+}
+
 static void
 unpack_int_rgba_RGB_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
 {
@@ -2563,6 +2609,20 @@ unpack_int_rgba_ARGB2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n)
    }
 }
 
+static void
+unpack_int_rgba_ABGR2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      GLuint tmp = src[i];
+      dst[i][0] = (tmp >> 0) & 0x3ff;
+      dst[i][1] = (tmp >> 10) & 0x3ff;
+      dst[i][2] = (tmp >> 20) & 0x3ff;
+      dst[i][3] = (tmp >> 30) & 0x3;
+   }
+}
+
 void
 _mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
                            const void *src, GLuint dst[][4])
@@ -2590,6 +2650,14 @@ _mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
       unpack_int_rgba_RGBA_INT8(src, dst, n);
       break;
 
+   case MESA_FORMAT_ARGB8888:
+      unpack_int_rgba_ARGB8888(src, dst, n);
+      break;
+
+   case MESA_FORMAT_XRGB8888:
+      unpack_int_rgba_XRGB8888(src, dst, n);
+      break;
+
    case MESA_FORMAT_RGB_UINT32:
    case MESA_FORMAT_RGB_INT32:
       unpack_int_rgba_RGB_UINT32(src, dst, n);
@@ -2725,6 +2793,11 @@ _mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
    case MESA_FORMAT_ARGB2101010_UINT:
       unpack_int_rgba_ARGB2101010_UINT(src, dst, n);
       break;
+
+   case MESA_FORMAT_ABGR2101010_UINT:
+      unpack_int_rgba_ABGR2101010_UINT(src, dst, n);
+      break;
+
    default:
       _mesa_problem(NULL, "%s: bad format %s", __FUNCTION__,
                     _mesa_get_format_name(format));