1 /* $Id: svgamesa15.c,v 1.7 2000/11/14 17:40:14 brianp Exp $ */
4 * Mesa 3-D graphics library
6 * Copyright (C) 1995-2000 Brian Paul
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * SVGA driver for Mesa.
26 * Original author: Brian Paul
27 * Additional authors: Slawomir Szczyrba <steev@hot.pl> (Mesa 3.2)
37 #include "svgamesa15.h"
39 static void __svga_drawpixel15(int x
, int y
, unsigned long c
)
42 GLshort
*shortBuffer
=(void *)SVGABuffer
.DrawBuffer
;
43 y
= SVGAInfo
->height
-y
-1;
44 offset
= y
* SVGAInfo
->width
+ x
;
45 shortBuffer
[offset
]=c
;
48 static unsigned long __svga_getpixel15(int x
, int y
)
51 GLshort
*shortBuffer
=(void *)SVGABuffer
.ReadBuffer
;
52 y
= SVGAInfo
->height
-y
-1;
53 offset
= y
* SVGAInfo
->width
+ x
;
54 return shortBuffer
[offset
];
57 void __clear_color15( GLcontext
*ctx
,
58 GLubyte red
, GLubyte green
,
59 GLubyte blue
, GLubyte alpha
)
61 SVGAMesa
->clear_hicolor
=(red
>>3)<<10 | (green
>>3)<<5 | (blue
>>3);
62 /* SVGAMesa->clear_hicolor=(red)<<10 | (green)<<5 | (blue);*/
65 GLbitfield
__clear15( GLcontext
*ctx
, GLbitfield mask
, GLboolean all
,
66 GLint x
, GLint y
, GLint width
, GLint height
)
70 if (mask
& DD_FRONT_LEFT_BIT
) {
71 GLshort
*shortBuffer
=(void *)SVGABuffer
.FrontBuffer
;
73 for (i
=0;i
<SVGABuffer
.BufferSize
/ 2;i
++)
74 shortBuffer
[i
]=SVGAMesa
->clear_hicolor
;
77 GLubyte
*tmp
= SVGABuffer
.DrawBuffer
;
78 SVGABuffer
.DrawBuffer
= SVGABuffer
.FrontBuffer
;
80 for (j
=y
;j
<height
;j
++)
81 __svga_drawpixel15(i
,j
,SVGAMesa
->clear_hicolor
);
82 SVGABuffer
.DrawBuffer
= tmp
;
85 if (mask
& DD_BACK_LEFT_BIT
) {
86 GLshort
*shortBuffer
=(void *)SVGABuffer
.BackBuffer
;
88 for (i
=0;i
<SVGABuffer
.BufferSize
/ 2;i
++)
89 shortBuffer
[i
]=SVGAMesa
->clear_hicolor
;
92 GLubyte
*tmp
= SVGABuffer
.DrawBuffer
;
93 SVGABuffer
.DrawBuffer
= SVGABuffer
.BackBuffer
;
95 for (j
=y
;j
<height
;j
++)
96 __svga_drawpixel15(i
,j
,SVGAMesa
->clear_hicolor
);
97 SVGABuffer
.DrawBuffer
= tmp
;
100 return mask
& (~(DD_FRONT_LEFT_BIT
| DD_BACK_LEFT_BIT
));
103 void __write_rgba_span15( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
104 const GLubyte rgba
[][4], const GLubyte mask
[] )
108 /* draw some pixels */
109 for (i
=0; i
<n
; i
++, x
++) {
111 __svga_drawpixel15( x
, y
, (rgba
[i
][RCOMP
]>>3)<<10 | \
112 (rgba
[i
][GCOMP
]>>3)<<5 | \
113 (rgba
[i
][BCOMP
]>>3));
118 /* draw all pixels */
119 for (i
=0; i
<n
; i
++, x
++) {
120 __svga_drawpixel15( x
, y
, (rgba
[i
][RCOMP
]>>3)<<10 | \
121 (rgba
[i
][GCOMP
]>>3)<<5 | \
122 (rgba
[i
][BCOMP
]>>3));
127 void __write_mono_rgba_span15( const GLcontext
*ctx
,
128 GLuint n
, GLint x
, GLint y
,
129 const GLchan color
[4], const GLubyte mask
[])
131 GLushort hicolor
= (color
[RCOMP
] >> 3) << 10 |
132 (color
[GCOMP
] >> 3) << 5 |
135 for (i
=0; i
<n
; i
++, x
++) {
137 __svga_drawpixel15( x
, y
, hicolor
);
142 void __read_rgba_span15( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
146 for (i
=0; i
<n
; i
++, x
++) {
147 pix
= __svga_getpixel15( x
, y
);
148 rgba
[i
][RCOMP
] = ((pix
>>10)<<3) & 0xff;
149 rgba
[i
][GCOMP
] = ((pix
>> 5)<<3) & 0xff;
150 rgba
[i
][BCOMP
] = ((pix
)<<3) & 0xff;
154 void __write_rgba_pixels15( const GLcontext
*ctx
,
155 GLuint n
, const GLint x
[], const GLint y
[],
156 const GLubyte rgba
[][4], const GLubyte mask
[] )
159 for (i
=0; i
<n
; i
++) {
161 __svga_drawpixel15( x
[i
], y
[i
], (rgba
[i
][RCOMP
]>>3)<<10 | \
162 (rgba
[i
][GCOMP
]>>3)<<5 | \
163 (rgba
[i
][BCOMP
]>>3));
169 void __write_mono_rgba_pixels15( const GLcontext
*ctx
,
171 const GLint x
[], const GLint y
[],
172 const GLchan color
[4], const GLubyte mask
[] )
174 GLushort hicolor
= (color
[RCOMP
] >> 3) << 10 |
175 (color
[GCOMP
] >> 3) << 5 |
178 /* use current rgb color */
179 for (i
=0; i
<n
; i
++) {
181 __svga_drawpixel15( x
[i
], y
[i
], hicolor
);
186 void __read_rgba_pixels15( const GLcontext
*ctx
,
187 GLuint n
, const GLint x
[], const GLint y
[],
188 GLubyte rgba
[][4], const GLubyte mask
[] )
191 for (i
=0; i
<n
; i
++,x
++) {
192 pix
= __svga_getpixel15( x
[i
], y
[i
] );
193 rgba
[i
][RCOMP
] = ((pix
>>10)<<3) & 0xff;
194 rgba
[i
][GCOMP
] = ((pix
>> 5)<<3) & 0xff;
195 rgba
[i
][BCOMP
] = ((pix
)<<3) & 0xff;
202 /* silence compiler warning */
203 extern void _mesa_svga15_dummy_function(void);
204 void _mesa_svga15_dummy_function(void)