mesa: fix asst. issues in _mesa_texstore_argb8888()
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 10 Oct 2008 22:30:43 +0000 (16:30 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 10 Oct 2008 22:34:08 +0000 (16:34 -0600)
If we shift bytes into the texel word (or use the PACK_COLOR_8888 macro),
we don't have to worry about big vs. little endian.  See comments about
texel formats in texformat.h.
Remove an unneeded/incorrect else-if clause that produced wrong results
on big-endian systems.

src/mesa/main/texstore.c

index 56f5b2ebaa1fb2f9bfcefe91600fc3b901050f59..75b14c2bf0616564808a1751bd4a246662712337 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.1
+ * Version:  7.3
  *
  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  *
@@ -1536,10 +1536,10 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
          for (row = 0; row < srcHeight; row++) {
             GLuint *d4 = (GLuint *) dstRow;
             for (col = 0; col < srcWidth; col++) {
-               d4[col] = ((0xff                    << 24) |
-                          (srcRow[col * 3 + RCOMP] << 16) |
-                          (srcRow[col * 3 + GCOMP] <<  8) |
-                          (srcRow[col * 3 + BCOMP] <<  0));
+               d4[col] = PACK_COLOR_8888(0xff,
+                                         srcRow[col * 3 + RCOMP],
+                                         srcRow[col * 3 + GCOMP],
+                                         srcRow[col * 3 + BCOMP]);
             }
             dstRow += dstRowStride;
             srcRow += srcRowStride;
@@ -1551,8 +1551,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
            dstFormat == &_mesa_texformat_argb8888 &&
             srcFormat == GL_RGBA &&
            baseInternalFormat == GL_RGBA &&
-            srcType == GL_UNSIGNED_BYTE &&
-            littleEndian) {
+            srcType == GL_UNSIGNED_BYTE) {
       /* same as above case, but src data has alpha too */
       GLint img, row, col;
       /* For some reason, streaming copies to write-combined regions
@@ -1573,39 +1572,10 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
          for (row = 0; row < srcHeight; row++) {
             GLuint *d4 = (GLuint *) dstRow;
             for (col = 0; col < srcWidth; col++) {
-               d4[col] = ((srcRow[col * 4 + ACOMP] << 24) |
-                          (srcRow[col * 4 + RCOMP] << 16) |
-                          (srcRow[col * 4 + GCOMP] <<  8) |
-                          (srcRow[col * 4 + BCOMP] <<  0));
-            }
-            dstRow += dstRowStride;
-            srcRow += srcRowStride;
-         }
-      }
-   }
-   else if (!ctx->_ImageTransferState &&
-            !srcPacking->SwapBytes &&
-           dstFormat == &_mesa_texformat_argb8888 &&
-            srcFormat == GL_RGBA &&
-           baseInternalFormat == GL_RGBA &&
-            srcType == GL_UNSIGNED_BYTE) {
-
-      GLint img, row, col;
-      for (img = 0; img < srcDepth; img++) {
-         const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
-                                                 srcWidth, srcFormat, srcType);
-         GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
-                  srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
-         GLubyte *dstRow = (GLubyte *) dstAddr
-            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
-            + dstYoffset * dstRowStride
-            + dstXoffset * dstFormat->TexelBytes;
-         for (row = 0; row < srcHeight; row++) {
-            for (col = 0; col < srcWidth; col++) {
-               dstRow[col * 4 + 0] = srcRow[col * 4 + BCOMP];
-               dstRow[col * 4 + 1] = srcRow[col * 4 + GCOMP];
-               dstRow[col * 4 + 2] = srcRow[col * 4 + RCOMP];
-               dstRow[col * 4 + 3] = srcRow[col * 4 + ACOMP];
+               d4[col] = PACK_COLOR_8888(srcRow[col * 4 + ACOMP],
+                                         srcRow[col * 4 + RCOMP],
+                                         srcRow[col * 4 + GCOMP],
+                                         srcRow[col * 4 + BCOMP]);
             }
             dstRow += dstRowStride;
             srcRow += srcRowStride;