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