Small compile fix
[mesa.git] / src / mesa / drivers / svga / svgamesa15.c
1 /* $Id: svgamesa15.c,v 1.7 2000/11/14 17:40:14 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 * Copyright (C) 1995-2000 Brian Paul
7 *
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.
12 *
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.
17 *
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.
21 */
22
23
24 /*
25 * SVGA driver for Mesa.
26 * Original author: Brian Paul
27 * Additional authors: Slawomir Szczyrba <steev@hot.pl> (Mesa 3.2)
28 */
29
30 #ifdef HAVE_CONFIG_H
31 #include "conf.h"
32 #endif
33
34 #ifdef SVGA
35
36 #include "svgapix.h"
37 #include "svgamesa15.h"
38
39 static void __svga_drawpixel15(int x, int y, unsigned long c)
40 {
41 unsigned long offset;
42 GLshort *shortBuffer=(void *)SVGABuffer.DrawBuffer;
43 y = SVGAInfo->height-y-1;
44 offset = y * SVGAInfo->width + x;
45 shortBuffer[offset]=c;
46 }
47
48 static unsigned long __svga_getpixel15(int x, int y)
49 {
50 unsigned long offset;
51 GLshort *shortBuffer=(void *)SVGABuffer.ReadBuffer;
52 y = SVGAInfo->height-y-1;
53 offset = y * SVGAInfo->width + x;
54 return shortBuffer[offset];
55 }
56
57 void __clear_color15( GLcontext *ctx,
58 GLubyte red, GLubyte green,
59 GLubyte blue, GLubyte alpha )
60 {
61 SVGAMesa->clear_hicolor=(red>>3)<<10 | (green>>3)<<5 | (blue>>3);
62 /* SVGAMesa->clear_hicolor=(red)<<10 | (green)<<5 | (blue);*/
63 }
64
65 GLbitfield __clear15( GLcontext *ctx, GLbitfield mask, GLboolean all,
66 GLint x, GLint y, GLint width, GLint height )
67 {
68 int i, j;
69
70 if (mask & DD_FRONT_LEFT_BIT) {
71 GLshort *shortBuffer=(void *)SVGABuffer.FrontBuffer;
72 if (all) {
73 for (i=0;i<SVGABuffer.BufferSize / 2;i++)
74 shortBuffer[i]=SVGAMesa->clear_hicolor;
75 }
76 else {
77 GLubyte *tmp = SVGABuffer.DrawBuffer;
78 SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer;
79 for (i=x;i<width;i++)
80 for (j=y;j<height;j++)
81 __svga_drawpixel15(i,j,SVGAMesa->clear_hicolor);
82 SVGABuffer.DrawBuffer = tmp;
83 }
84 }
85 if (mask & DD_BACK_LEFT_BIT) {
86 GLshort *shortBuffer=(void *)SVGABuffer.BackBuffer;
87 if (all) {
88 for (i=0;i<SVGABuffer.BufferSize / 2;i++)
89 shortBuffer[i]=SVGAMesa->clear_hicolor;
90 }
91 else {
92 GLubyte *tmp = SVGABuffer.DrawBuffer;
93 SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer;
94 for (i=x;i<width;i++)
95 for (j=y;j<height;j++)
96 __svga_drawpixel15(i,j,SVGAMesa->clear_hicolor);
97 SVGABuffer.DrawBuffer = tmp;
98 }
99 }
100 return mask & (~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
101 }
102
103 void __write_rgba_span15( const GLcontext *ctx, GLuint n, GLint x, GLint y,
104 const GLubyte rgba[][4], const GLubyte mask[] )
105 {
106 int i;
107 if (mask) {
108 /* draw some pixels */
109 for (i=0; i<n; i++, x++) {
110 if (mask[i]) {
111 __svga_drawpixel15( x, y, (rgba[i][RCOMP]>>3)<<10 | \
112 (rgba[i][GCOMP]>>3)<<5 | \
113 (rgba[i][BCOMP]>>3));
114 }
115 }
116 }
117 else {
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));
123 }
124 }
125 }
126
127 void __write_mono_rgba_span15( const GLcontext *ctx,
128 GLuint n, GLint x, GLint y,
129 const GLchan color[4], const GLubyte mask[])
130 {
131 GLushort hicolor = (color[RCOMP] >> 3) << 10 |
132 (color[GCOMP] >> 3) << 5 |
133 (color[BCOMP] >> 3);
134 int i;
135 for (i=0; i<n; i++, x++) {
136 if (mask[i]) {
137 __svga_drawpixel15( x, y, hicolor);
138 }
139 }
140 }
141
142 void __read_rgba_span15( const GLcontext *ctx, GLuint n, GLint x, GLint y,
143 GLubyte rgba[][4] )
144 {
145 int i,pix;
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;
151 }
152 }
153
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[] )
157 {
158 int i;
159 for (i=0; i<n; i++) {
160 if (mask[i]) {
161 __svga_drawpixel15( x[i], y[i], (rgba[i][RCOMP]>>3)<<10 | \
162 (rgba[i][GCOMP]>>3)<<5 | \
163 (rgba[i][BCOMP]>>3));
164 }
165 }
166 }
167
168
169 void __write_mono_rgba_pixels15( const GLcontext *ctx,
170 GLuint n,
171 const GLint x[], const GLint y[],
172 const GLchan color[4], const GLubyte mask[] )
173 {
174 GLushort hicolor = (color[RCOMP] >> 3) << 10 |
175 (color[GCOMP] >> 3) << 5 |
176 (color[BCOMP] >> 3);
177 int i;
178 /* use current rgb color */
179 for (i=0; i<n; i++) {
180 if (mask[i]) {
181 __svga_drawpixel15( x[i], y[i], hicolor );
182 }
183 }
184 }
185
186 void __read_rgba_pixels15( const GLcontext *ctx,
187 GLuint n, const GLint x[], const GLint y[],
188 GLubyte rgba[][4], const GLubyte mask[] )
189 {
190 int i,pix;
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;
196 }
197 }
198
199 #else
200
201
202 /* silence compiler warning */
203 extern void _mesa_svga15_dummy_function(void);
204 void _mesa_svga15_dummy_function(void)
205 {
206 }
207
208
209 #endif