Merge branch 'mesa_7_7_branch'
[mesa.git] / src / mesa / main / texstore.c
index f43e216bc5357663c5fa754200a86be77b48be99..fcd0a56d76aabf45a78a28ddd0034b2d27462725 100644 (file)
@@ -263,7 +263,7 @@ compute_component_mapping(GLenum inFormat, GLenum outFormat,
    map[ZERO] = ZERO;
    map[ONE] = ONE;   
 
-/*
+#if 0
    _mesa_printf("from %x/%s to %x/%s map %d %d %d %d %d %d\n",
                inFormat, _mesa_lookup_enum_by_nr(inFormat),
                outFormat, _mesa_lookup_enum_by_nr(outFormat),
@@ -273,7 +273,7 @@ compute_component_mapping(GLenum inFormat, GLenum outFormat,
                map[3], 
                map[4], 
                map[5]); 
-*/
+#endif
 }
 
 
@@ -1410,7 +1410,8 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
 
    ASSERT(dstFormat == MESA_FORMAT_ARGB8888 ||
           dstFormat == MESA_FORMAT_ARGB8888_REV ||
-          dstFormat == MESA_FORMAT_XRGB8888);
+          dstFormat == MESA_FORMAT_XRGB8888 ||
+          dstFormat == MESA_FORMAT_XRGB8888_REV );
    ASSERT(texelBytes == 4);
 
    if (!ctx->_ImageTransferState &&
@@ -1431,7 +1432,8 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
    }
    else if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
-       dstFormat == MESA_FORMAT_ARGB8888_REV &&
+       (dstFormat == MESA_FORMAT_ARGB8888_REV ||
+        dstFormat == MESA_FORMAT_XRGB8888_REV) &&
        baseInternalFormat == GL_RGBA &&
        srcFormat == GL_BGRA &&
        ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
@@ -1524,7 +1526,8 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
        */
       if ((littleEndian && dstFormat == MESA_FORMAT_ARGB8888) ||
           (littleEndian && dstFormat == MESA_FORMAT_XRGB8888) ||
-         (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV)) {
+         (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) ||
+         (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV)) {
         dstmap[3] = 3;         /* alpha */
         dstmap[2] = 0;         /* red */
         dstmap[1] = 1;         /* green */
@@ -1533,6 +1536,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
       else {
         assert((littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) ||
                (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888) ||
+               (littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV) ||
                (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888));
         dstmap[3] = 2;
         dstmap[2] = 1;
@@ -2193,18 +2197,22 @@ _mesa_texstore_al1616(TEXSTORE_PARAMS)
             GLuint *dstUI = (GLuint *) dstRow;
             if (dstFormat == MESA_FORMAT_AL1616) {
                for (col = 0; col < srcWidth; col++) {
-                  /* src[0] is luminance, src[1] is alpha */
-                 dstUI[col] = PACK_COLOR_88( FLOAT_TO_USHORT(src[1]),
-                                             FLOAT_TO_USHORT(src[0]) );
-                 src += 2;
+                 GLushort l, a;
+
+                 UNCLAMPED_FLOAT_TO_USHORT(l, src[0]);
+                 UNCLAMPED_FLOAT_TO_USHORT(a, src[1]);
+                 dstUI[col] = PACK_COLOR_1616(a, l);
+                 src += 2;
                }
             }
             else {
                for (col = 0; col < srcWidth; col++) {
-                  /* src[0] is luminance, src[1] is alpha */
-                 dstUI[col] = PACK_COLOR_1616_REV( FLOAT_TO_UBYTE(src[1]),
-                                                  FLOAT_TO_UBYTE(src[0]) );
-                 src += 2;
+                 GLushort l, a;
+
+                 UNCLAMPED_FLOAT_TO_USHORT(l, src[0]);
+                 UNCLAMPED_FLOAT_TO_USHORT(a, src[1]);
+                 dstUI[col] = PACK_COLOR_1616_REV(a, l);
+                 src += 2;
                }
             }
             dstRow += dstRowStride;
@@ -3121,7 +3129,7 @@ _mesa_texstore_sla8(TEXSTORE_PARAMS)
  * Table mapping MESA_FORMAT_8 to _mesa_texstore_*()
  * XXX this is somewhat temporary.
  */
-const static struct {
+static const struct {
    gl_format Name;
    StoreTexImageFunc Store;
 }
@@ -3133,6 +3141,7 @@ texstore_funcs[MESA_FORMAT_COUNT] =
    { MESA_FORMAT_ARGB8888, _mesa_texstore_argb8888 },
    { MESA_FORMAT_ARGB8888_REV, _mesa_texstore_argb8888 },
    { MESA_FORMAT_XRGB8888, _mesa_texstore_argb8888 },
+   { MESA_FORMAT_XRGB8888_REV, _mesa_texstore_argb8888 },
    { MESA_FORMAT_RGB888, _mesa_texstore_rgb888 },
    { MESA_FORMAT_BGR888, _mesa_texstore_bgr888 },
    { MESA_FORMAT_RGB565, _mesa_texstore_rgb565 },