Small compile fix
[mesa.git] / src / mesa / drivers / svga / svgamesa32.c
1 /* $Id: svgamesa32.c,v 1.8 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 "svgamesa32.h"
38
39 #if 0
40 /* this doesn't compile with GCC on RedHat 6.1 */
41 static inline int RGB2BGR32(int c)
42 {
43 asm("rorw $8, %0\n"
44 "rorl $16, %0\n"
45 "rorw $8, %0\n"
46 "shrl $8, %0\n"
47 : "=q"(c):"0"(c));
48 return c;
49 }
50 #else
51 static unsigned long RGB2BGR32(unsigned long color)
52 {
53 return (color & 0xff00)|(color>>16)|((color & 0xff)<<16);
54 }
55 #endif
56
57 static void __svga_drawpixel32(int x, int y, unsigned long c)
58 {
59 unsigned long offset;
60
61 GLint *intBuffer=(void *)SVGABuffer.DrawBuffer;
62 y = SVGAInfo->height-y-1;
63 offset = y * SVGAInfo->width + x;
64 intBuffer[offset]=c;
65 }
66
67 static unsigned long __svga_getpixel32(int x, int y)
68 {
69 unsigned long offset;
70
71 const GLint *intBuffer=(void *)SVGABuffer.ReadBuffer;
72 y = SVGAInfo->height-y-1;
73 offset = y * SVGAInfo->width + x;
74 return intBuffer[offset];
75 }
76
77 void __clear_color32( GLcontext *ctx,
78 GLubyte red, GLubyte green,
79 GLubyte blue, GLubyte alpha )
80 {
81 SVGAMesa->clear_truecolor = red<<16 | green<<8 | blue;
82 }
83
84 GLbitfield __clear32( GLcontext *ctx, GLbitfield mask, GLboolean all,
85 GLint x, GLint y, GLint width, GLint height )
86 {
87 int i,j;
88
89 if (mask & DD_FRONT_LEFT_BIT) {
90 if (all) {
91 GLint *intBuffer=(void *)SVGABuffer.FrontBuffer;
92 for (i=0;i<SVGABuffer.BufferSize / 4;i++)
93 intBuffer[i]=SVGAMesa->clear_truecolor;
94 }
95 else {
96 GLubyte *tmp = SVGABuffer.DrawBuffer;
97 SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer;
98 for (i=x;i<width;i++)
99 for (j=y;j<height;j++)
100 __svga_drawpixel32(i,j,SVGAMesa->clear_truecolor);
101 SVGABuffer.DrawBuffer = tmp;
102 }
103 }
104 if (mask & DD_BACK_LEFT_BIT) {
105 if (all) {
106 GLint *intBuffer=(void *)SVGABuffer.BackBuffer;
107 for (i=0;i<SVGABuffer.BufferSize / 4;i++)
108 intBuffer[i]=SVGAMesa->clear_truecolor;
109 }
110 else {
111 GLubyte *tmp = SVGABuffer.DrawBuffer;
112 SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer;
113 for (i=x;i<width;i++)
114 for (j=y;j<height;j++)
115 __svga_drawpixel32(i,j,SVGAMesa->clear_truecolor);
116 SVGABuffer.DrawBuffer = tmp;
117 }
118 }
119 return mask & (~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
120 }
121
122 void __write_rgba_span32( const GLcontext *ctx, GLuint n, GLint x, GLint y,
123 const GLubyte rgba[][4], const GLubyte mask[] )
124 {
125 int i;
126 if (mask) {
127 /* draw some pixels */
128 for (i=0; i<n; i++, x++) {
129 if (mask[i]) {
130 __svga_drawpixel32( x, y, RGB2BGR32(*((GLint*)rgba[i])));
131 }
132 }
133 }
134 else {
135 /* draw all pixels */
136 for (i=0; i<n; i++, x++) {
137 __svga_drawpixel32( x, y, RGB2BGR32(*((GLint*)rgba[i])));
138 }
139 }
140 }
141
142 void __write_mono_rgba_span32( const GLcontext *ctx,
143 GLuint n, GLint x, GLint y,
144 const GLchan color[4], const GLubyte mask[])
145 {
146 int i;
147 GLuint truecolor = color[RCOMP]<<16 | color[GCOMP]<<8 | color[BCOMP];
148 for (i=0; i<n; i++, x++) {
149 if (mask[i]) {
150 __svga_drawpixel32( x, y, truecolor);
151 }
152 }
153 }
154
155 void __read_rgba_span32( const GLcontext *ctx, GLuint n, GLint x, GLint y,
156 GLubyte rgba[][4] )
157 {
158 int i;
159 for (i=0; i<n; i++, x++) {
160 *((GLint*)rgba[i]) = RGB2BGR32(__svga_getpixel32( x, y ));
161 }
162 }
163
164 void __write_rgba_pixels32( const GLcontext *ctx,
165 GLuint n, const GLint x[], const GLint y[],
166 const GLubyte rgba[][4], const GLubyte mask[] )
167 {
168 int i;
169 for (i=0; i<n; i++) {
170 if (mask[i]) {
171 __svga_drawpixel32( x[i], y[i], RGB2BGR32(*((GLint*)rgba[i])));
172 }
173 }
174 }
175
176 void __write_mono_rgba_pixels32( const GLcontext *ctx,
177 GLuint n,
178 const GLint x[], const GLint y[],
179 const GLchan color[4], const GLubyte mask[] )
180 {
181 GLuint truecolor = color[RCOMP]<<16 | color[GCOMP]<<8 | color[BCOMP];
182 int i;
183 for (i=0; i<n; i++) {
184 if (mask[i]) {
185 __svga_drawpixel32( x[i], y[i], truecolor );
186 }
187 }
188 }
189
190 void __read_rgba_pixels32( const GLcontext *ctx,
191 GLuint n, const GLint x[], const GLint y[],
192 GLubyte rgba[][4], const GLubyte mask[] )
193 {
194 int i;
195 for (i=0; i<n; i++,x++) {
196 *((GLint*)rgba[i]) = RGB2BGR32(__svga_getpixel32( x[i], y[i] ));
197 }
198 }
199
200
201 #else
202
203
204 /* silence compiler warning */
205 extern void _mesa_svga32_dummy_function(void);
206 void _mesa_svga32_dummy_function(void)
207 {
208 }
209
210
211 #endif
212