3 * Mesa 3-D graphics library
5 * Copyright (C) 1995-2000 Brian Paul
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.
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.
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.
24 * SVGA driver for Mesa.
25 * Original author: Brian Paul
26 * Additional authors: Slawomir Szczyrba <steev@hot.pl> (Mesa 3.2)
37 #include "svgamesa8.h"
38 #include "swrast/swrast.h"
41 static void __svga_drawpixel8(int x
, int y
, unsigned long c
)
44 y
= SVGAInfo
->height
-y
-1;
45 offset
= y
* SVGAInfo
->linewidth
+ x
;
46 SVGABuffer
.DrawBuffer
[offset
]=c
;
49 static unsigned long __svga_getpixel8(int x
, int y
)
52 y
= SVGAInfo
->height
-y
-1;
53 offset
= y
* SVGAInfo
->linewidth
+ x
;
54 return SVGABuffer
.ReadBuffer
[offset
];
57 void __clear_index8( GLcontext
*ctx
, GLuint index
)
59 SVGAMesa
->clear_index
= index
;
62 void __clear8( GLcontext
*ctx
, GLbitfield mask
)
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
)
71 if (mask
& DD_FRONT_LEFT_BIT
) {
73 memset(SVGABuffer
.FrontBuffer
, SVGAMesa
->clear_index
, SVGABuffer
.BufferSize
);
76 GLubyte
*tmp
= SVGABuffer
.DrawBuffer
;
77 SVGABuffer
.DrawBuffer
= SVGABuffer
.FrontBuffer
;
79 for (j
=y
;j
<height
;j
++)
80 __svga_drawpixel8(i
,j
,SVGAMesa
->clear_index
);
81 SVGABuffer
.DrawBuffer
= tmp
;
83 mask
&= ~DD_FRONT_LEFT_BIT
;
85 if (mask
& DD_BACK_LEFT_BIT
) {
87 memset(SVGABuffer
.BackBuffer
, SVGAMesa
->clear_index
, SVGABuffer
.BufferSize
);
90 GLubyte
*tmp
= SVGABuffer
.DrawBuffer
;
91 SVGABuffer
.DrawBuffer
= SVGABuffer
.BackBuffer
;
93 for (j
=y
;j
<height
;j
++)
94 __svga_drawpixel8(i
,j
,SVGAMesa
->clear_index
);
95 SVGABuffer
.DrawBuffer
= tmp
;
97 mask
&= ~DD_BACK_LEFT_BIT
;
101 _swrast_Clear( ctx
, mask
);
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
[] )
109 for (i
=0;i
<n
;i
++,x
++) {
111 __svga_drawpixel8( x
, y
, index
[i
]);
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
[] )
122 for (i
=0;i
<n
;i
++,x
++) {
124 __svga_drawpixel8( x
, y
, index
[i
]);
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
[] )
134 for (i
=0;i
<n
;i
++,x
++) {
136 __svga_drawpixel8( x
, y
, colorIndex
);
141 void __read_ci32_span8( const GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
142 GLuint n
, GLint x
, GLint y
, GLuint index
[])
145 for (i
=0; i
<n
; i
++,x
++) {
146 index
[i
] = __svga_getpixel8( x
, y
);
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
[] )
155 for (i
=0; i
<n
; i
++) {
157 __svga_drawpixel8( x
[i
], y
[i
], index
[i
]);
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
[] )
168 for (i
=0; i
<n
; i
++) {
170 __svga_drawpixel8( x
[i
], y
[i
], colorIndex
);
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
[] )
180 for (i
=0; i
<n
; i
++,x
++) {
181 index
[i
] = __svga_getpixel8( x
[i
], y
[i
]);
189 /* silence compiler warning */
190 extern void _mesa_svga8_dummy_function(void);
191 void _mesa_svga8_dummy_function(void)