}
}
-/* Help! I'm just making this up!
- *
- * This should take the incoming Type, Endian pair and produce a
- * mapping from that data when examined through a (char *) pointer
- * natively, to the equivalent of what that data would look like if it
- * were presented as GL_UNSIGNED_BYTEs on a littleEndian machine... I
- * think...
- */
-static const GLubyte map_identity[6] = { 0, 1, 2, 3, 4, 5 };
-static const GLubyte map_3210[6] = { 3, 2, 1, 0, 4, 5 };
+static const GLubyte map_identity[6] = { 0, 1, 2, 3, ZERO, ONE };
+static const GLubyte map_3210[6] = { 3, 2, 1, 0, ZERO, ONE };
+/* Deal with the _REV input types:
+ */
static const GLubyte *
-type_endian_mapping( GLenum srcType )
+type_mapping( GLenum srcType )
{
switch (srcType) {
case GL_UNSIGNED_BYTE:
- if (_mesa_little_endian())
- return map_identity;
- else
- return map_3210;
- case GL_UNSIGNED_INT_8_8_8_8:
return map_identity;
- case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_8_8_8_8:
return map_3210;
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ return map_identity;
default:
return NULL;
}
}
-/* This will have to change to support GL_UNSIGNED_SHORT input types.
- * It's making my mind swim at the moment though.
+/* Mapping required if input type is
*/
static const GLubyte *
-byteswap_mapping( GLenum srcType )
+byteswap_mapping( GLboolean swapBytes,
+ GLenum srcType )
{
+ if (!swapBytes)
+ return map_identity;
+
switch (srcType) {
case GL_UNSIGNED_BYTE:
return map_identity;
const struct gl_pixelstore_attrib *srcPacking )
{
GLint srcComponents = _mesa_components_in_format(srcFormat);
- const GLubyte *srctype2ubyte_le, *swap;
+ const GLubyte *srctype2ubyte, *swap;
GLubyte map[4], src2base[6], base2rgba[6];
GLint i;
const GLint srcRowStride =
*/
compute_component_mapping(srcFormat, baseInternalFormat, src2base);
compute_component_mapping(baseInternalFormat, GL_RGBA, base2rgba);
- swap = byteswap_mapping(srcType);
- srctype2ubyte_le = type_endian_mapping(srcType);
+ swap = byteswap_mapping(srcPacking->SwapBytes, srcType);
+ srctype2ubyte = type_mapping(srcType);
for (i = 0; i < 4; i++)
- map[i] = srctype2ubyte_le[swap[src2base[base2rgba[rgba2dst[i]]]]];
+ map[i] = srctype2ubyte[swap[src2base[base2rgba[rgba2dst[i]]]]];
/* _mesa_printf("map %d %d %d %d\n", map[0], map[1], map[2], map[3]); */
}
}
else if (!ctx->_ImageTransferState &&
+ _mesa_little_endian() &&
CHAN_TYPE == GL_UNSIGNED_BYTE &&
(srcType == GL_UNSIGNED_BYTE ||
srcType == GL_UNSIGNED_INT_8_8_8_8 ||
srcAddr, srcPacking);
}
else if (!ctx->_ImageTransferState &&
+ littleEndian &&
(srcType == GL_UNSIGNED_BYTE ||
srcType == GL_UNSIGNED_INT_8_8_8_8 ||
srcType == GL_UNSIGNED_INT_8_8_8_8_REV) &&
}
}
else if (!ctx->_ImageTransferState &&
+ littleEndian &&
(srcType == GL_UNSIGNED_BYTE ||
srcType == GL_UNSIGNED_INT_8_8_8_8 ||
srcType == GL_UNSIGNED_INT_8_8_8_8_REV) &&
}
}
else if (!ctx->_ImageTransferState &&
+ littleEndian &&
srcType == GL_UNSIGNED_BYTE &&
can_swizzle(baseInternalFormat) &&
can_swizzle(srcFormat)) {
}
}
else if (!ctx->_ImageTransferState &&
+ littleEndian &&
srcType == GL_UNSIGNED_BYTE &&
can_swizzle(baseInternalFormat) &&
can_swizzle(srcFormat)) {
srcAddr, srcPacking);
}
else if (!ctx->_ImageTransferState &&
+ littleEndian &&
srcType == GL_UNSIGNED_BYTE &&
can_swizzle(baseInternalFormat) &&
can_swizzle(srcFormat)) {
srcAddr, srcPacking);
}
else if (!ctx->_ImageTransferState &&
+ _mesa_little_endian() &&
srcType == GL_UNSIGNED_BYTE &&
can_swizzle(baseInternalFormat) &&
can_swizzle(srcFormat)) {