Remove CVS keywords.
[mesa.git] / src / mesa / drivers / svga / svgamesa15.c
1
2 /*
3 * Mesa 3-D graphics library
4 * Version: 5.0
5 * Copyright (C) 1995-2002 Brian Paul
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the Free
19 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22
23 /*
24 * SVGA driver for Mesa.
25 * Original author: Brian Paul
26 * Additional authors: Slawomir Szczyrba <steev@hot.pl> (Mesa 3.2)
27 */
28
29 #ifdef HAVE_CONFIG_H
30 #include "conf.h"
31 #endif
32
33 #ifdef SVGA
34
35 #include "svgapix.h"
36 #include "svgamesa15.h"
37 #include "swrast/swrast.h"
38
39
40 static void __svga_drawpixel15(int x, int y, unsigned long c)
41 {
42 unsigned long offset;
43 GLshort *shortBuffer=(void *)SVGABuffer.DrawBuffer;
44 y = SVGAInfo->height-y-1;
45 offset = y * SVGAInfo->width + x;
46 shortBuffer[offset]=c;
47 }
48
49 static unsigned long __svga_getpixel15(int x, int y)
50 {
51 unsigned long offset;
52 GLshort *shortBuffer=(void *)SVGABuffer.ReadBuffer;
53 y = SVGAInfo->height-y-1;
54 offset = y * SVGAInfo->width + x;
55 return shortBuffer[offset];
56 }
57
58 void __clear_color15( GLcontext *ctx, const GLfloat color[4] )
59 {
60 GLubyte col[3];
61 CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]);
62 CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]);
63 CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]);
64 SVGAMesa->clear_hicolor=(col[0]>>3)<<10 | (col[1]>>3)<<5 | (col[2]>>3);
65 /* SVGAMesa->clear_hicolor=(red)<<10 | (green)<<5 | (blue);*/
66 }
67
68 void __clear15( GLcontext *ctx, GLbitfield mask )
69 {
70 int i, j;
71 int x = ctx->DrawBuffer->_Xmin;
72 int y = ctx->DrawBuffer->_Ymin;
73 int width = ctx->DrawBuffer->_Xmax - x;
74 int height = ctx->DrawBuffer->_Ymax - y;
75 GLboolean all = (width == ctx->DrawBuffer->Width && height == ctx->DrawBuffer->height)
76
77 if (mask & DD_FRONT_LEFT_BIT) {
78 GLshort *shortBuffer=(void *)SVGABuffer.FrontBuffer;
79 if (all) {
80 for (i=0;i<SVGABuffer.BufferSize / 2;i++)
81 shortBuffer[i]=SVGAMesa->clear_hicolor;
82 }
83 else {
84 GLubyte *tmp = SVGABuffer.DrawBuffer;
85 SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer;
86 for (i=x;i<width;i++)
87 for (j=y;j<height;j++)
88 __svga_drawpixel15(i,j,SVGAMesa->clear_hicolor);
89 SVGABuffer.DrawBuffer = tmp;
90 }
91 mask &= ~DD_FRONT_LEFT_BIT;
92 }
93 if (mask & DD_BACK_LEFT_BIT) {
94 GLshort *shortBuffer=(void *)SVGABuffer.BackBuffer;
95 if (all) {
96 for (i=0;i<SVGABuffer.BufferSize / 2;i++)
97 shortBuffer[i]=SVGAMesa->clear_hicolor;
98 }
99 else {
100 GLubyte *tmp = SVGABuffer.DrawBuffer;
101 SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer;
102 for (i=x;i<width;i++)
103 for (j=y;j<height;j++)
104 __svga_drawpixel15(i,j,SVGAMesa->clear_hicolor);
105 SVGABuffer.DrawBuffer = tmp;
106 }
107 mask &= ~DD_BACK_LEFT_BIT;
108 }
109
110 if (mask)
111 _swrast_Clear( ctx, mask );
112 }
113
114 void __write_rgba_span15( const GLcontext *ctx, GLuint n, GLint x, GLint y,
115 const GLubyte rgba[][4], const GLubyte mask[] )
116 {
117 int i;
118 if (mask) {
119 /* draw some pixels */
120 for (i=0; i<n; i++, x++) {
121 if (mask[i]) {
122 __svga_drawpixel15( x, y, (rgba[i][RCOMP]>>3)<<10 | \
123 (rgba[i][GCOMP]>>3)<<5 | \
124 (rgba[i][BCOMP]>>3));
125 }
126 }
127 }
128 else {
129 /* draw all pixels */
130 for (i=0; i<n; i++, x++) {
131 __svga_drawpixel15( x, y, (rgba[i][RCOMP]>>3)<<10 | \
132 (rgba[i][GCOMP]>>3)<<5 | \
133 (rgba[i][BCOMP]>>3));
134 }
135 }
136 }
137
138 void __write_mono_rgba_span15( const GLcontext *ctx,
139 GLuint n, GLint x, GLint y,
140 const GLchan color[4], const GLubyte mask[])
141 {
142 GLushort hicolor = (color[RCOMP] >> 3) << 10 |
143 (color[GCOMP] >> 3) << 5 |
144 (color[BCOMP] >> 3);
145 int i;
146 for (i=0; i<n; i++, x++) {
147 if (mask[i]) {
148 __svga_drawpixel15( x, y, hicolor);
149 }
150 }
151 }
152
153 void __read_rgba_span15( const GLcontext *ctx, GLuint n, GLint x, GLint y,
154 GLubyte rgba[][4] )
155 {
156 int i,pix;
157 for (i=0; i<n; i++, x++) {
158 pix = __svga_getpixel15( x, y);
159 rgba[i][RCOMP] = ((pix>>10)<<3) & 0xff;
160 rgba[i][GCOMP] = ((pix>> 5)<<3) & 0xff;
161 rgba[i][BCOMP] = ((pix )<<3) & 0xff;
162 }
163 }
164
165 void __write_rgba_pixels15( const GLcontext *ctx,
166 GLuint n, const GLint x[], const GLint y[],
167 const GLubyte rgba[][4], const GLubyte mask[] )
168 {
169 int i;
170 for (i=0; i<n; i++) {
171 if (mask[i]) {
172 __svga_drawpixel15( x[i], y[i], (rgba[i][RCOMP]>>3)<<10 | \
173 (rgba[i][GCOMP]>>3)<<5 | \
174 (rgba[i][BCOMP]>>3));
175 }
176 }
177 }
178
179
180 void __write_mono_rgba_pixels15( const GLcontext *ctx,
181 GLuint n,
182 const GLint x[], const GLint y[],
183 const GLchan color[4], const GLubyte mask[] )
184 {
185 GLushort hicolor = (color[RCOMP] >> 3) << 10 |
186 (color[GCOMP] >> 3) << 5 |
187 (color[BCOMP] >> 3);
188 int i;
189 /* use current rgb color */
190 for (i=0; i<n; i++) {
191 if (mask[i]) {
192 __svga_drawpixel15( x[i], y[i], hicolor );
193 }
194 }
195 }
196
197 void __read_rgba_pixels15( const GLcontext *ctx,
198 GLuint n, const GLint x[], const GLint y[],
199 GLubyte rgba[][4], const GLubyte mask[] )
200 {
201 int i,pix;
202 for (i=0; i<n; i++,x++) {
203 pix = __svga_getpixel15( x[i], y[i] );
204 rgba[i][RCOMP] = ((pix>>10)<<3) & 0xff;
205 rgba[i][GCOMP] = ((pix>> 5)<<3) & 0xff;
206 rgba[i][BCOMP] = ((pix )<<3) & 0xff;
207 }
208 }
209
210 #else
211
212
213 /* silence compiler warning */
214 extern void _mesa_svga15_dummy_function(void);
215 void _mesa_svga15_dummy_function(void)
216 {
217 }
218
219
220 #endif