28cd7a42642a03b82ce952162319fa7cfecaa190
1 /* $Id: svgamesa15.c,v 1.6 2000/06/14 21:59:07 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)
37 #include "svgamesa15.h"
39 static void __svga_drawpixel15(int x
, int y
, unsigned long c
)
42 GLshort
*shortBuffer
=(void *)SVGABuffer
.DrawBuffer
;
43 y
= SVGAInfo
->height
-y
-1;
44 offset
= y
* SVGAInfo
->width
+ x
;
45 shortBuffer
[offset
]=c
;
48 static unsigned long __svga_getpixel15(int x
, int y
)
51 GLshort
*shortBuffer
=(void *)SVGABuffer
.ReadBuffer
;
52 y
= SVGAInfo
->height
-y
-1;
53 offset
= y
* SVGAInfo
->width
+ x
;
54 return shortBuffer
[offset
];
57 void __set_color15( GLcontext
*ctx
,
58 GLubyte red
, GLubyte green
,
59 GLubyte blue
, GLubyte alpha
)
61 SVGAMesa
->hicolor
=(red
>>3)<<10 | (green
>>3)<<5 | (blue
>>3);
62 /* SVGAMesa->hicolor=(red)<<10 | (green)<<5 | (blue); */
65 void __clear_color15( GLcontext
*ctx
,
66 GLubyte red
, GLubyte green
,
67 GLubyte blue
, GLubyte alpha
)
69 SVGAMesa
->clear_hicolor
=(red
>>3)<<10 | (green
>>3)<<5 | (blue
>>3);
70 /* SVGAMesa->clear_hicolor=(red)<<10 | (green)<<5 | (blue);*/
73 GLbitfield
__clear15( GLcontext
*ctx
, GLbitfield mask
, GLboolean all
,
74 GLint x
, GLint y
, GLint width
, GLint height
)
78 if (mask
& DD_FRONT_LEFT_BIT
) {
79 GLshort
*shortBuffer
=(void *)SVGABuffer
.FrontBuffer
;
81 for (i
=0;i
<SVGABuffer
.BufferSize
/ 2;i
++)
82 shortBuffer
[i
]=SVGAMesa
->clear_hicolor
;
85 GLubyte
*tmp
= SVGABuffer
.DrawBuffer
;
86 SVGABuffer
.DrawBuffer
= SVGABuffer
.FrontBuffer
;
88 for (j
=y
;j
<height
;j
++)
89 __svga_drawpixel15(i
,j
,SVGAMesa
->clear_hicolor
);
90 SVGABuffer
.DrawBuffer
= tmp
;
93 if (mask
& DD_BACK_LEFT_BIT
) {
94 GLshort
*shortBuffer
=(void *)SVGABuffer
.BackBuffer
;
96 for (i
=0;i
<SVGABuffer
.BufferSize
/ 2;i
++)
97 shortBuffer
[i
]=SVGAMesa
->clear_hicolor
;
100 GLubyte
*tmp
= SVGABuffer
.DrawBuffer
;
101 SVGABuffer
.DrawBuffer
= SVGABuffer
.BackBuffer
;
102 for (i
=x
;i
<width
;i
++)
103 for (j
=y
;j
<height
;j
++)
104 __svga_drawpixel15(i
,j
,SVGAMesa
->clear_hicolor
);
105 SVGABuffer
.DrawBuffer
= tmp
;
108 return mask
& (~(DD_FRONT_LEFT_BIT
| DD_BACK_LEFT_BIT
));
111 void __write_rgba_span15( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
112 const GLubyte rgba
[][4], const GLubyte mask
[] )
116 /* draw some pixels */
117 for (i
=0; i
<n
; i
++, x
++) {
119 __svga_drawpixel15( x
, y
, (rgba
[i
][RCOMP
]>>3)<<10 | \
120 (rgba
[i
][GCOMP
]>>3)<<5 | \
121 (rgba
[i
][BCOMP
]>>3));
126 /* draw all pixels */
127 for (i
=0; i
<n
; i
++, x
++) {
128 __svga_drawpixel15( x
, y
, (rgba
[i
][RCOMP
]>>3)<<10 | \
129 (rgba
[i
][GCOMP
]>>3)<<5 | \
130 (rgba
[i
][BCOMP
]>>3));
135 void __write_mono_rgba_span15( const GLcontext
*ctx
,
136 GLuint n
, GLint x
, GLint y
,
137 const GLubyte mask
[])
140 for (i
=0; i
<n
; i
++, x
++) {
142 __svga_drawpixel15( x
, y
, SVGAMesa
->hicolor
);
147 void __read_rgba_span15( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
151 for (i
=0; i
<n
; i
++, x
++) {
152 pix
= __svga_getpixel15( x
, y
);
153 rgba
[i
][RCOMP
] = ((pix
>>10)<<3) & 0xff;
154 rgba
[i
][GCOMP
] = ((pix
>> 5)<<3) & 0xff;
155 rgba
[i
][BCOMP
] = ((pix
)<<3) & 0xff;
159 void __write_rgba_pixels15( const GLcontext
*ctx
,
160 GLuint n
, const GLint x
[], const GLint y
[],
161 const GLubyte rgba
[][4], const GLubyte mask
[] )
164 for (i
=0; i
<n
; i
++) {
166 __svga_drawpixel15( x
[i
], y
[i
], (rgba
[i
][RCOMP
]>>3)<<10 | \
167 (rgba
[i
][GCOMP
]>>3)<<5 | \
168 (rgba
[i
][BCOMP
]>>3));
174 void __write_mono_rgba_pixels15( const GLcontext
*ctx
,
176 const GLint x
[], const GLint y
[],
177 const GLubyte mask
[] )
180 /* use current rgb color */
181 for (i
=0; i
<n
; i
++) {
183 __svga_drawpixel15( x
[i
], y
[i
], SVGAMesa
->hicolor
);
188 void __read_rgba_pixels15( const GLcontext
*ctx
,
189 GLuint n
, const GLint x
[], const GLint y
[],
190 GLubyte rgba
[][4], const GLubyte mask
[] )
193 for (i
=0; i
<n
; i
++,x
++) {
194 pix
= __svga_getpixel15( x
[i
], y
[i
] );
195 rgba
[i
][RCOMP
] = ((pix
>>10)<<3) & 0xff;
196 rgba
[i
][GCOMP
] = ((pix
>> 5)<<3) & 0xff;
197 rgba
[i
][BCOMP
] = ((pix
)<<3) & 0xff;
204 /* silence compiler warning */
205 extern void _mesa_svga15_dummy_function(void);
206 void _mesa_svga15_dummy_function(void)