1 /* $Id: svgamesa8.c,v 1.8 2001/02/06 00:03:48 brianp Exp $ */
4 * Mesa 3-D graphics library
6 * Copyright (C) 1995-2000 Brian Paul
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.
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.
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.
25 * SVGA driver for Mesa.
26 * Original author: Brian Paul
27 * Additional authors: Slawomir Szczyrba <steev@hot.pl> (Mesa 3.2)
38 #include "svgamesa8.h"
39 #include "swrast/swrast.h"
42 static void __svga_drawpixel8(int x
, int y
, unsigned long c
)
45 y
= SVGAInfo
->height
-y
-1;
46 offset
= y
* SVGAInfo
->linewidth
+ x
;
47 SVGABuffer
.DrawBuffer
[offset
]=c
;
50 static unsigned long __svga_getpixel8(int x
, int y
)
53 y
= SVGAInfo
->height
-y
-1;
54 offset
= y
* SVGAInfo
->linewidth
+ x
;
55 return SVGABuffer
.ReadBuffer
[offset
];
58 void __clear_index8( GLcontext
*ctx
, GLuint index
)
60 SVGAMesa
->clear_index
= index
;
63 void __clear8( GLcontext
*ctx
, GLbitfield mask
, GLboolean all
,
64 GLint x
, GLint y
, GLint width
, GLint height
)
68 if (mask
& DD_FRONT_LEFT_BIT
) {
70 memset(SVGABuffer
.FrontBuffer
, SVGAMesa
->clear_index
, SVGABuffer
.BufferSize
);
73 GLubyte
*tmp
= SVGABuffer
.DrawBuffer
;
74 SVGABuffer
.DrawBuffer
= SVGABuffer
.FrontBuffer
;
76 for (j
=y
;j
<height
;j
++)
77 __svga_drawpixel8(i
,j
,SVGAMesa
->clear_index
);
78 SVGABuffer
.DrawBuffer
= tmp
;
80 mask
&= ~DD_FRONT_LEFT_BIT
;
82 if (mask
& DD_BACK_LEFT_BIT
) {
84 memset(SVGABuffer
.BackBuffer
, SVGAMesa
->clear_index
, SVGABuffer
.BufferSize
);
87 GLubyte
*tmp
= SVGABuffer
.DrawBuffer
;
88 SVGABuffer
.DrawBuffer
= SVGABuffer
.BackBuffer
;
90 for (j
=y
;j
<height
;j
++)
91 __svga_drawpixel8(i
,j
,SVGAMesa
->clear_index
);
92 SVGABuffer
.DrawBuffer
= tmp
;
94 mask
&= ~DD_BACK_LEFT_BIT
;
98 _swrast_Clear( ctx
, mask
, all
, x
, y
, width
, height
);
101 void __write_ci32_span8( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
102 const GLuint index
[], const GLubyte mask
[] )
105 for (i
=0;i
<n
;i
++,x
++) {
107 __svga_drawpixel8( x
, y
, index
[i
]);
112 void __write_ci8_span8( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
113 const GLubyte index
[], const GLubyte mask
[] )
117 for (i
=0;i
<n
;i
++,x
++) {
119 __svga_drawpixel8( x
, y
, index
[i
]);
124 void __write_mono_ci_span8( const GLcontext
*ctx
, GLuint n
,
126 GLuint colorIndex
, const GLubyte mask
[] )
129 for (i
=0;i
<n
;i
++,x
++) {
131 __svga_drawpixel8( x
, y
, colorIndex
);
136 void __read_ci32_span8( const GLcontext
*ctx
,
137 GLuint n
, GLint x
, GLint y
, GLuint index
[])
140 for (i
=0; i
<n
; i
++,x
++) {
141 index
[i
] = __svga_getpixel8( x
, y
);
145 void __write_ci32_pixels8( const GLcontext
*ctx
,
146 GLuint n
, const GLint x
[], const GLint y
[],
147 const GLuint index
[], const GLubyte mask
[] )
150 for (i
=0; i
<n
; i
++) {
152 __svga_drawpixel8( x
[i
], y
[i
], index
[i
]);
158 void __write_mono_ci_pixels8( const GLcontext
*ctx
, GLuint n
,
159 const GLint x
[], const GLint y
[],
160 GLuint colorIndex
, const GLubyte mask
[] )
163 for (i
=0; i
<n
; i
++) {
165 __svga_drawpixel8( x
[i
], y
[i
], colorIndex
);
170 void __read_ci32_pixels8( const GLcontext
*ctx
,
171 GLuint n
, const GLint x
[], const GLint y
[],
172 GLuint index
[], const GLubyte mask
[] )
175 for (i
=0; i
<n
; i
++,x
++) {
176 index
[i
] = __svga_getpixel8( x
[i
], y
[i
]);
184 /* silence compiler warning */
185 extern void _mesa_svga8_dummy_function(void);
186 void _mesa_svga8_dummy_function(void)