1 /* $Id: svgamesa8.c,v 1.7 2000/11/14 17:40:14 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"
40 static void __svga_drawpixel8(int x
, int y
, unsigned long c
)
43 y
= SVGAInfo
->height
-y
-1;
44 offset
= y
* SVGAInfo
->linewidth
+ x
;
45 SVGABuffer
.DrawBuffer
[offset
]=c
;
48 static unsigned long __svga_getpixel8(int x
, int y
)
51 y
= SVGAInfo
->height
-y
-1;
52 offset
= y
* SVGAInfo
->linewidth
+ x
;
53 return SVGABuffer
.ReadBuffer
[offset
];
56 void __clear_index8( GLcontext
*ctx
, GLuint index
)
58 SVGAMesa
->clear_index
= index
;
61 GLbitfield
__clear8( GLcontext
*ctx
, GLbitfield mask
, GLboolean all
,
62 GLint x
, GLint y
, GLint width
, GLint height
)
66 if (mask
& DD_FRONT_LEFT_BIT
) {
68 memset(SVGABuffer
.FrontBuffer
, SVGAMesa
->clear_index
, SVGABuffer
.BufferSize
);
71 GLubyte
*tmp
= SVGABuffer
.DrawBuffer
;
72 SVGABuffer
.DrawBuffer
= SVGABuffer
.FrontBuffer
;
74 for (j
=y
;j
<height
;j
++)
75 __svga_drawpixel8(i
,j
,SVGAMesa
->clear_index
);
76 SVGABuffer
.DrawBuffer
= tmp
;
79 if (mask
& DD_BACK_LEFT_BIT
) {
81 memset(SVGABuffer
.BackBuffer
, SVGAMesa
->clear_index
, SVGABuffer
.BufferSize
);
84 GLubyte
*tmp
= SVGABuffer
.DrawBuffer
;
85 SVGABuffer
.DrawBuffer
= SVGABuffer
.BackBuffer
;
87 for (j
=y
;j
<height
;j
++)
88 __svga_drawpixel8(i
,j
,SVGAMesa
->clear_index
);
89 SVGABuffer
.DrawBuffer
= tmp
;
92 return mask
& (~(DD_FRONT_LEFT_BIT
| DD_BACK_LEFT_BIT
));
95 void __write_ci32_span8( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
96 const GLuint index
[], const GLubyte mask
[] )
99 for (i
=0;i
<n
;i
++,x
++) {
101 __svga_drawpixel8( x
, y
, index
[i
]);
106 void __write_ci8_span8( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
107 const GLubyte index
[], const GLubyte mask
[] )
111 for (i
=0;i
<n
;i
++,x
++) {
113 __svga_drawpixel8( x
, y
, index
[i
]);
118 void __write_mono_ci_span8( const GLcontext
*ctx
, GLuint n
,
120 GLuint colorIndex
, const GLubyte mask
[] )
123 for (i
=0;i
<n
;i
++,x
++) {
125 __svga_drawpixel8( x
, y
, colorIndex
);
130 void __read_ci32_span8( const GLcontext
*ctx
,
131 GLuint n
, GLint x
, GLint y
, GLuint index
[])
134 for (i
=0; i
<n
; i
++,x
++) {
135 index
[i
] = __svga_getpixel8( x
, y
);
139 void __write_ci32_pixels8( const GLcontext
*ctx
,
140 GLuint n
, const GLint x
[], const GLint y
[],
141 const GLuint index
[], const GLubyte mask
[] )
144 for (i
=0; i
<n
; i
++) {
146 __svga_drawpixel8( x
[i
], y
[i
], index
[i
]);
152 void __write_mono_ci_pixels8( const GLcontext
*ctx
, GLuint n
,
153 const GLint x
[], const GLint y
[],
154 GLuint colorIndex
, const GLubyte mask
[] )
157 for (i
=0; i
<n
; i
++) {
159 __svga_drawpixel8( x
[i
], y
[i
], colorIndex
);
164 void __read_ci32_pixels8( const GLcontext
*ctx
,
165 GLuint n
, const GLint x
[], const GLint y
[],
166 GLuint index
[], const GLubyte mask
[] )
169 for (i
=0; i
<n
; i
++,x
++) {
170 index
[i
] = __svga_getpixel8( x
[i
], y
[i
]);
178 /* silence compiler warning */
179 extern void _mesa_svga8_dummy_function(void);
180 void _mesa_svga8_dummy_function(void)