54053b8b31593cb347c731137b7ecb7e6e965da8
[mesa.git] / src / mesa / drivers / dri / r128 / r128_tex.h
1 /* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.h,v 1.7 2002/02/22 21:44:58 dawes Exp $ */
2 /**************************************************************************
3
4 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
5 Cedar Park, Texas.
6 All Rights Reserved.
7
8 Permission is hereby granted, free of charge, to any person obtaining a
9 copy of this software and associated documentation files (the "Software"),
10 to deal in the Software without restriction, including without limitation
11 on the rights to use, copy, modify, merge, publish, distribute, sub
12 license, and/or sell copies of the Software, and to permit persons to whom
13 the Software is furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice (including the next
16 paragraph) shall be included in all copies or substantial portions of the
17 Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
22 ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
23 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25 USE OR OTHER DEALINGS IN THE SOFTWARE.
26
27 **************************************************************************/
28
29 /*
30 * Authors:
31 * Gareth Hughes <gareth@valinux.com>
32 * Kevin E. Martin <martin@valinux.com>
33 *
34 */
35
36 #ifndef __R128_TEX_H__
37 #define __R128_TEX_H__
38
39 extern void r128UpdateTextureState( GLcontext *ctx );
40
41 extern void r128UploadTexImages( r128ContextPtr rmesa, r128TexObjPtr t );
42
43 extern void r128DestroyTexObj( r128ContextPtr rmesa, r128TexObjPtr t );
44
45 extern void r128InitTextureFuncs( struct dd_function_table *functions );
46
47
48 /* ================================================================
49 * Color conversion macros:
50 */
51
52 #define R128PACKCOLOR332( r, g, b ) \
53 (((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
54
55 #define R128PACKCOLOR1555( r, g, b, a ) \
56 ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
57 ((a) ? 0x8000 : 0))
58
59 #define R128PACKCOLOR565( r, g, b ) \
60 ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
61
62 #define R128PACKCOLOR888( r, g, b ) \
63 (((r) << 16) | ((g) << 8) | (b))
64
65 #define R128PACKCOLOR8888( r, g, b, a ) \
66 (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
67
68 #define R128PACKCOLOR4444( r, g, b, a ) \
69 ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
70
71 static __inline__ u_int32_t r128PackColor( GLuint cpp,
72 GLubyte r, GLubyte g,
73 GLubyte b, GLubyte a )
74 {
75 switch ( cpp ) {
76 case 2:
77 return R128PACKCOLOR565( r, g, b );
78 case 4:
79 return R128PACKCOLOR8888( r, g, b, a );
80 default:
81 return 0;
82 }
83 }
84
85 #endif /* __R128_TEX_H__ */