Remove CVS keywords.
[mesa.git] / src / mesa / drivers / svga / svgamesa8.c
1
2 /*
3 * Mesa 3-D graphics library
4 * Version: 3.3
5 * Copyright (C) 1995-2000 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
36 #include "svgapix.h"
37 #include "svgamesa8.h"
38 #include "swrast/swrast.h"
39
40
41 static void __svga_drawpixel8(int x, int y, unsigned long c)
42 {
43 unsigned long offset;
44 y = SVGAInfo->height-y-1;
45 offset = y * SVGAInfo->linewidth + x;
46 SVGABuffer.DrawBuffer[offset]=c;
47 }
48
49 static unsigned long __svga_getpixel8(int x, int y)
50 {
51 unsigned long offset;
52 y = SVGAInfo->height-y-1;
53 offset = y * SVGAInfo->linewidth + x;
54 return SVGABuffer.ReadBuffer[offset];
55 }
56
57 void __clear_index8( GLcontext *ctx, GLuint index )
58 {
59 SVGAMesa->clear_index = index;
60 }
61
62 void __clear8( GLcontext *ctx, GLbitfield mask )
63 {
64 int i,j;
65 int x = ctx->DrawBuffer->_Xmin;
66 int y = ctx->DrawBuffer->_Ymin;
67 int width = ctx->DrawBuffer->_Xmax - x;
68 int height = ctx->DrawBuffer->_Ymax - y;
69 GLboolean all = (width == ctx->DrawBuffer->Width && height == ctx->DrawBuffer->height)
70
71 if (mask & DD_FRONT_LEFT_BIT) {
72 if (all) {
73 memset(SVGABuffer.FrontBuffer, SVGAMesa->clear_index, SVGABuffer.BufferSize);
74 }
75 else {
76 GLubyte *tmp = SVGABuffer.DrawBuffer;
77 SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer;
78 for (i=x;i<width;i++)
79 for (j=y;j<height;j++)
80 __svga_drawpixel8(i,j,SVGAMesa->clear_index);
81 SVGABuffer.DrawBuffer = tmp;
82 }
83 mask &= ~DD_FRONT_LEFT_BIT;
84 }
85 if (mask & DD_BACK_LEFT_BIT) {
86 if (all) {
87 memset(SVGABuffer.BackBuffer, SVGAMesa->clear_index, SVGABuffer.BufferSize);
88 }
89 else {
90 GLubyte *tmp = SVGABuffer.DrawBuffer;
91 SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer;
92 for (i=x;i<width;i++)
93 for (j=y;j<height;j++)
94 __svga_drawpixel8(i,j,SVGAMesa->clear_index);
95 SVGABuffer.DrawBuffer = tmp;
96 }
97 mask &= ~DD_BACK_LEFT_BIT;
98 }
99
100 if (mask)
101 _swrast_Clear( ctx, mask );
102 }
103
104 void __write_ci32_span8( const GLcontext *ctx, struct gl_renderbuffer *rb,
105 GLuint n, GLint x, GLint y,
106 const GLuint index[], const GLubyte mask[] )
107 {
108 int i;
109 for (i=0;i<n;i++,x++) {
110 if (mask[i]) {
111 __svga_drawpixel8( x, y, index[i]);
112 }
113 }
114 }
115
116 void __write_ci8_span8( const GLcontext *ctx, struct gl_renderbuffer *rb,
117 GLuint n, GLint x, GLint y,
118 const GLubyte index[], const GLubyte mask[] )
119 {
120 int i;
121
122 for (i=0;i<n;i++,x++) {
123 if (mask[i]) {
124 __svga_drawpixel8( x, y, index[i]);
125 }
126 }
127 }
128
129 void __write_mono_ci_span8( const GLcontext *ctx, struct gl_renderbuffer *rb,
130 GLuint n, GLint x, GLint y,
131 GLuint colorIndex, const GLubyte mask[] )
132 {
133 int i;
134 for (i=0;i<n;i++,x++) {
135 if (mask[i]) {
136 __svga_drawpixel8( x, y, colorIndex);
137 }
138 }
139 }
140
141 void __read_ci32_span8( const GLcontext *ctx, struct gl_renderbuffer *rb,
142 GLuint n, GLint x, GLint y, GLuint index[])
143 {
144 int i;
145 for (i=0; i<n; i++,x++) {
146 index[i] = __svga_getpixel8( x, y);
147 }
148 }
149
150 void __write_ci32_pixels8( const GLcontext *ctx, struct gl_renderbuffer *rb,
151 GLuint n, const GLint x[], const GLint y[],
152 const GLuint index[], const GLubyte mask[] )
153 {
154 int i;
155 for (i=0; i<n; i++) {
156 if (mask[i]) {
157 __svga_drawpixel8( x[i], y[i], index[i]);
158 }
159 }
160 }
161
162
163 void __write_mono_ci_pixels8( const GLcontext *ctx, struct gl_renderbuffer *rb,
164 GLuint n, const GLint x[], const GLint y[],
165 GLuint colorIndex, const GLubyte mask[] )
166 {
167 int i;
168 for (i=0; i<n; i++) {
169 if (mask[i]) {
170 __svga_drawpixel8( x[i], y[i], colorIndex);
171 }
172 }
173 }
174
175 void __read_ci32_pixels8( const GLcontext *ctx, struct gl_renderbuffer *rb,
176 GLuint n, const GLint x[], const GLint y[],
177 GLuint index[], const GLubyte mask[] )
178 {
179 int i;
180 for (i=0; i<n; i++,x++) {
181 index[i] = __svga_getpixel8( x[i], y[i]);
182 }
183 }
184
185
186 #else
187
188
189 /* silence compiler warning */
190 extern void _mesa_svga8_dummy_function(void);
191 void _mesa_svga8_dummy_function(void)
192 {
193 }
194
195
196 #endif