summaryrefslogtreecommitdiff
path: root/src/mesa/main/colormac.h
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-05-12 01:50:30 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-05-12 01:50:30 +0000
commita156b49800c1419785d0709b78ef0d35e6dab5df (patch)
tree3831a74900723783b3117e2f1604ff3ebd9797c5 /src/mesa/main/colormac.h
parent939f6a724e991a9f994c6e2fffe96c5971a1f749 (diff)
Added big-endian texture formats.
Moved CI->RGBA palette lookup into texel fetch function.
Diffstat (limited to 'src/mesa/main/colormac.h')
-rw-r--r--src/mesa/main/colormac.h86
1 files changed, 31 insertions, 55 deletions
diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h
index cf89a818f6..9b67fa19e4 100644
--- a/src/mesa/main/colormac.h
+++ b/src/mesa/main/colormac.h
@@ -1,13 +1,8 @@
-/**
- * \file colormac.h
- * Color-related macros
- */
-
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -28,6 +23,11 @@
*/
+/**
+ * \file colormac.h
+ * Color-related macros
+ */
+
#ifndef COLORMAC_H
#define COLORMAC_H
@@ -174,66 +174,42 @@ do { \
/**
- * \name Generic color packing macros
+ * \name Generic color packing macros. All inputs should be GLubytes.
*
- * \todo We may move these into texutil.h at some point.
+ * \todo We may move these into texstore.h at some point.
*/
/*@{*/
-#define PACK_COLOR_8888( a, b, c, d ) \
- (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
-
-#define PACK_COLOR_888( a, b, c ) \
- (((a) << 16) | ((b) << 8) | (c))
-
-#define PACK_COLOR_565( a, b, c ) \
- ((((a) & 0xf8) << 8) | (((b) & 0xfc) << 3) | (((c) & 0xf8) >> 3))
-
-#define PACK_COLOR_1555( a, b, c, d ) \
- ((((b) & 0xf8) << 7) | (((c) & 0xf8) << 2) | (((d) & 0xf8) >> 3) | \
- ((a) ? 0x8000 : 0))
-
-#define PACK_COLOR_4444( a, b, c, d ) \
- ((((a) & 0xf0) << 8) | (((b) & 0xf0) << 4) | ((c) & 0xf0) | ((d) >> 4))
-
-#define PACK_COLOR_88( a, b ) \
- (((a) << 8) | (b))
-
-#define PACK_COLOR_332( a, b, c ) \
- (((a) & 0xe0) | (((b) & 0xe0) >> 3) | (((c) & 0xc0) >> 6))
-
-
-#ifdef MESA_BIG_ENDIAN
-
-#define PACK_COLOR_8888_LE( a, b, c, d ) PACK_COLOR_8888( d, c, b, a )
-
-#define PACK_COLOR_565_LE( a, b, c ) \
- (((a) & 0xf8) | (((b) & 0xe0) >> 5) | (((b) & 0x1c) << 11) | \
- (((c) & 0xf8) << 5))
-
-#define PACK_COLOR_1555_LE( a, b, c, d ) \
- ((((b) & 0xf8) >> 1) | (((c) & 0xc0) >> 6) | (((c) & 0x38) << 10) | \
- (((d) & 0xf8) << 5) | ((a) ? 0x80 : 0))
-
-#define PACK_COLOR_4444_LE( a, b, c, d ) PACK_COLOR_4444( c, d, a, b )
-
-#define PACK_COLOR_88_LE( a, b ) PACK_COLOR_88( b, a )
+#define PACK_COLOR_8888( R, G, B, A ) \
+ (((R) << 24) | ((G) << 16) | ((B) << 8) | (A))
-#else /* little endian */
+#define PACK_COLOR_888( R, G, B ) \
+ (((R) << 16) | ((G) << 8) | (B))
-#define PACK_COLOR_8888_LE( a, b, c, d ) PACK_COLOR_8888( a, b, c, d )
+#define PACK_COLOR_565( R, G, B ) \
+ ((((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | (((B) & 0xf8) >> 3))
-#define PACK_COLOR_565_LE( a, b, c ) PACK_COLOR_565( a, b, c )
+#define PACK_COLOR_1555( A, B, G, R ) \
+ ((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \
+ ((A) ? 0x8000 : 0))
-#define PACK_COLOR_1555_LE( a, b, c, d ) PACK_COLOR_1555( a, b, c, d )
+#define PACK_COLOR_5551( R, G, B, A ) \
+ ((((B) & 0xf8) << 8) | \
+ (((G) & 0xf8) << 3) | \
+ (((R) & 0xf8) >> 2) | \
+ (((A) & 0x80) >> 7))
-#define PACK_COLOR_4444_LE( a, b, c, d ) PACK_COLOR_4444( a, b, c, d )
+#define PACK_COLOR_4444( R, G, B, A ) \
+ ((((R) & 0xf0) << 8) | (((G) & 0xf0) << 4) | ((B) & 0xf0) | ((A) >> 4))
-#define PACK_COLOR_88_LE( a, b ) PACK_COLOR_88( a, b )
+#define PACK_COLOR_88( L, A ) \
+ (((L) << 8) | (A))
-#endif /* endianness */
+#define PACK_COLOR_332( R, G, B ) \
+ (((R) & 0xe0) | (((G) & 0xe0) >> 3) | (((B) & 0xc0) >> 6))
-/*@}*/
+#define PACK_COLOR_233( B, G, R ) \
+ (((B) & 0xc0) | (((G) & 0xe0) >> 2) | (((R) & 0xe0) >> 5))
#endif /* COLORMAC_H */