1 /* $Id: xm_line.c,v 1.7 2000/11/06 15:52:48 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * This file contains "accelerated" point, line, and triangle functions.
30 * It should be fairly easy to write new special-purpose point, line or
31 * triangle functions and hook them into this module.
35 #include "glxheader.h"
42 /* Internal swrast includes:
44 #include "swrast/s_depth.h"
45 #include "swrast/s_points.h"
46 #include "swrast/s_lines.h"
47 #include "swrast/s_context.h"
50 /**********************************************************************/
51 /*** Point rendering ***/
52 /**********************************************************************/
56 * Render an array of points into a pixmap, any pixel format.
58 static void draw_points_ANY_pixmap( GLcontext
*ctx
, SWvertex
*vert
)
60 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
61 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
62 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
63 XMesaGC gc
= xmesa
->xm_buffer
->gc2
;
65 if (xmesa
->xm_visual
->gl_visual
->RGBAflag
) {
67 const GLubyte
*color
= vert
->color
;
68 unsigned long pixel
= xmesa_color_to_pixel( xmesa
,
72 XMesaSetForeground( dpy
, gc
, pixel
);
73 x
= (GLint
) vert
->win
[0];
74 y
= FLIP( xmesa
->xm_buffer
, (GLint
) vert
->win
[1] );
75 XMesaDrawPoint( dpy
, buffer
, gc
, x
, y
);
78 /* Color index mode */
80 XMesaSetForeground( dpy
, gc
, vert
->index
);
81 x
= (GLint
) vert
->win
[0];
82 y
= FLIP( xmesa
->xm_buffer
, (GLint
) vert
->win
[1] );
83 XMesaDrawPoint( dpy
, buffer
, gc
, x
, y
);
89 /* Override the swrast point-selection function. Try to use one of
90 * our internal point functions, otherwise fall back to the standard
93 void xmesa_choose_point( GLcontext
*ctx
)
95 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
96 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
98 if (ctx
->Point
.Size
== 1.0F
&& !ctx
->Point
.SmoothFlag
99 && swrast
->_RasterMask
== 0
100 && !ctx
->Texture
._ReallyEnabled
101 && xmesa
->xm_buffer
->buffer
!= XIMAGE
) {
102 swrast
->Point
= draw_points_ANY_pixmap
;
105 _swrast_choose_point( ctx
);
111 /**********************************************************************/
112 /*** Line rendering ***/
113 /**********************************************************************/
118 * Render a line into a pixmap, any pixel format.
120 static void flat_pixmap_line( GLcontext
*ctx
,
121 SWvertex
*vert0
, SWvertex
*vert1
)
123 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
124 register int x0
, y0
, x1
, y1
;
127 if (xmesa
->xm_visual
->gl_visual
->RGBAflag
) {
128 const GLubyte
*color
= vert0
->color
;
129 pixel
= xmesa_color_to_pixel( xmesa
, color
[0], color
[1], color
[2], color
[3],
130 xmesa
->pixelformat
);
133 pixel
= vert0
->index
;
135 gc
= xmesa
->xm_buffer
->gc2
;
136 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
138 x0
= (GLint
) vert0
->win
[0];
139 y0
= FLIP( xmesa
->xm_buffer
, (GLint
) vert0
->win
[1] );
140 x1
= (GLint
) vert1
->win
[0];
141 y1
= FLIP( xmesa
->xm_buffer
, (GLint
) vert1
->win
[1] );
142 XMesaDrawLine( xmesa
->display
, xmesa
->xm_buffer
->buffer
, gc
,
149 * Draw a flat-shaded, PF_TRUECOLOR line into an XImage.
151 static void flat_TRUECOLOR_line( GLcontext
*ctx
,
152 SWvertex
*vert0
, SWvertex
*vert1
)
154 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
155 const GLubyte
*color
= vert0
->color
;
156 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
158 PACK_TRUECOLOR( pixel
, color
[0], color
[1], color
[2] );
162 #define PLOT(X,Y) XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel );
164 #include "swrast/s_linetemp.h"
170 * Draw a flat-shaded, PF_8A8B8G8R line into an XImage.
172 static void flat_8A8B8G8R_line( GLcontext
*ctx
,
173 SWvertex
*vert0
, SWvertex
*vert1
)
175 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
176 const GLubyte
*color
= vert0
->color
;
177 GLuint pixel
= PACK_8B8G8R( color
[0], color
[1], color
[2] );
179 #define PIXEL_TYPE GLuint
180 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
181 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
183 #define PLOT(X,Y) *pixelPtr = pixel;
185 #include "swrast/s_linetemp.h"
190 * Draw a flat-shaded, PF_8R8G8B line into an XImage.
192 static void flat_8R8G8B_line( GLcontext
*ctx
,
193 SWvertex
*vert0
, SWvertex
*vert1
)
195 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
196 const GLubyte
*color
= vert0
->color
;
197 GLuint pixel
= PACK_8R8G8B( color
[0], color
[1], color
[2] );
199 #define PIXEL_TYPE GLuint
200 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
201 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
203 #define PLOT(X,Y) *pixelPtr = pixel;
205 #include "swrast/s_linetemp.h"
210 * Draw a flat-shaded, PF_8R8G8B24 line into an XImage.
212 static void flat_8R8G8B24_line( GLcontext
*ctx
,
213 SWvertex
*vert0
, SWvertex
*vert1
)
215 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
216 const GLubyte
*color
= vert0
->color
;
218 #define PIXEL_TYPE bgr_t
219 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
220 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
222 #define PLOT(X,Y) { \
223 pixelPtr->r = color[RCOMP]; \
224 pixelPtr->g = color[GCOMP]; \
225 pixelPtr->b = color[BCOMP]; \
228 #include "swrast/s_linetemp.h"
233 * Draw a flat-shaded, PF_5R6G5B line into an XImage.
235 static void flat_5R6G5B_line( GLcontext
*ctx
,
236 SWvertex
*vert0
, SWvertex
*vert1
)
238 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
239 const GLubyte
*color
= vert0
->color
;
240 GLushort pixel
= PACK_5R6G5B( color
[0], color
[1], color
[2] );
242 #define PIXEL_TYPE GLushort
243 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
244 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
246 #define PLOT(X,Y) *pixelPtr = pixel;
248 #include "swrast/s_linetemp.h"
253 * Draw a flat-shaded, PF_DITHER_5R6G5B line into an XImage.
255 static void flat_DITHER_5R6G5B_line( GLcontext
*ctx
,
256 SWvertex
*vert0
, SWvertex
*vert1
)
258 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
259 const GLubyte
*color
= vert0
->color
;
261 #define PIXEL_TYPE GLushort
262 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
263 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
265 #define PLOT(X,Y) PACK_TRUEDITHER( *pixelPtr, X, Y, color[0], color[1], color[2] );
267 #include "swrast/s_linetemp.h"
273 * Draw a flat-shaded, PF_DITHER 8-bit line into an XImage.
275 static void flat_DITHER8_line( GLcontext
*ctx
,
276 SWvertex
*vert0
, SWvertex
*vert1
)
278 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
279 const GLubyte
*color
= vert0
->color
;
280 GLint r
= color
[0], g
= color
[1], b
= color
[2];
284 #define PIXEL_TYPE GLubyte
285 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
286 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
288 #define PLOT(X,Y) *pixelPtr = DITHER(X,Y,r,g,b);
290 #include "swrast/s_linetemp.h"
295 * Draw a flat-shaded, PF_LOOKUP 8-bit line into an XImage.
297 static void flat_LOOKUP8_line( GLcontext
*ctx
,
298 SWvertex
*vert0
, SWvertex
*vert1
)
300 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
301 const GLubyte
*color
= vert0
->color
;
304 pixel
= (GLubyte
) LOOKUP( color
[0], color
[1], color
[2] );
306 #define PIXEL_TYPE GLubyte
307 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
308 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
310 #define PLOT(X,Y) *pixelPtr = pixel;
312 #include "swrast/s_linetemp.h"
317 * Draw a flat-shaded, PF_HPCR line into an XImage.
319 static void flat_HPCR_line( GLcontext
*ctx
,
320 SWvertex
*vert0
, SWvertex
*vert1
)
322 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
323 const GLubyte
*color
= vert0
->color
;
324 GLint r
= color
[0], g
= color
[1], b
= color
[2];
327 #define PIXEL_TYPE GLubyte
328 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
329 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
331 #define PLOT(X,Y) *pixelPtr = (GLubyte) DITHER_HPCR(X,Y,r,g,b);
333 #include "swrast/s_linetemp.h"
339 * Draw a flat-shaded, Z-less, PF_TRUECOLOR line into an XImage.
341 static void flat_TRUECOLOR_z_line( GLcontext
*ctx
,
342 SWvertex
*vert0
, SWvertex
*vert1
)
344 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
345 const GLubyte
*color
= vert0
->color
;
346 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
348 PACK_TRUECOLOR( pixel
, color
[0], color
[1], color
[2] );
352 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
357 XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel ); \
360 #include "swrast/s_linetemp.h"
365 * Draw a flat-shaded, Z-less, PF_8A8B8G8R line into an XImage.
367 static void flat_8A8B8G8R_z_line( GLcontext
*ctx
,
368 SWvertex
*vert0
, SWvertex
*vert1
)
370 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
371 const GLubyte
*color
= vert0
->color
;
372 GLuint pixel
= PACK_8B8G8R( color
[0], color
[1], color
[2] );
375 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
376 #define PIXEL_TYPE GLuint
377 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
378 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
386 #include "swrast/s_linetemp.h"
391 * Draw a flat-shaded, Z-less, PF_8R8G8B line into an XImage.
393 static void flat_8R8G8B_z_line( GLcontext
*ctx
,
394 SWvertex
*vert0
, SWvertex
*vert1
)
396 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
397 const GLubyte
*color
= vert0
->color
;
398 GLuint pixel
= PACK_8R8G8B( color
[0], color
[1], color
[2] );
401 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
402 #define PIXEL_TYPE GLuint
403 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
404 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
412 #include "swrast/s_linetemp.h"
417 * Draw a flat-shaded, Z-less, PF_8R8G8B24 line into an XImage.
419 static void flat_8R8G8B24_z_line( GLcontext
*ctx
,
420 SWvertex
*vert0
, SWvertex
*vert1
)
422 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
423 const GLubyte
*color
= vert0
->color
;
426 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
427 #define PIXEL_TYPE bgr_t
428 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
429 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
434 pixelPtr->r = color[RCOMP]; \
435 pixelPtr->g = color[GCOMP]; \
436 pixelPtr->b = color[BCOMP]; \
439 #include "swrast/s_linetemp.h"
444 * Draw a flat-shaded, Z-less, PF_5R6G5B line into an XImage.
446 static void flat_5R6G5B_z_line( GLcontext
*ctx
,
447 SWvertex
*vert0
, SWvertex
*vert1
)
449 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
450 const GLubyte
*color
= vert0
->color
;
451 GLushort pixel
= PACK_5R6G5B( color
[0], color
[1], color
[2] );
454 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
455 #define PIXEL_TYPE GLushort
456 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
457 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
464 #include "swrast/s_linetemp.h"
469 * Draw a flat-shaded, Z-less, PF_DITHER_5R6G5B line into an XImage.
471 static void flat_DITHER_5R6G5B_z_line( GLcontext
*ctx
,
472 SWvertex
*vert0
, SWvertex
*vert1
)
474 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
475 const GLubyte
*color
= vert0
->color
;
478 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
479 #define PIXEL_TYPE GLushort
480 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
481 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
486 PACK_TRUEDITHER(*pixelPtr, X, Y, color[0], color[1], color[2]); \
488 #include "swrast/s_linetemp.h"
493 * Draw a flat-shaded, Z-less, PF_DITHER 8-bit line into an XImage.
495 static void flat_DITHER8_z_line( GLcontext
*ctx
,
496 SWvertex
*vert0
, SWvertex
*vert1
)
498 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
499 const GLubyte
*color
= vert0
->color
;
500 GLint r
= color
[0], g
= color
[1], b
= color
[2];
505 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
506 #define PIXEL_TYPE GLubyte
507 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
508 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
513 *pixelPtr = (GLubyte) DITHER( X, Y, r, g, b); \
515 #include "swrast/s_linetemp.h"
520 * Draw a flat-shaded, Z-less, PF_LOOKUP 8-bit line into an XImage.
522 static void flat_LOOKUP8_z_line( GLcontext
*ctx
,
523 SWvertex
*vert0
, SWvertex
*vert1
)
525 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
526 const GLubyte
*color
= vert0
->color
;
529 pixel
= (GLubyte
) LOOKUP( color
[0], color
[1], color
[2] );
532 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
533 #define PIXEL_TYPE GLubyte
534 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
535 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
543 #include "swrast/s_linetemp.h"
548 * Draw a flat-shaded, Z-less, PF_HPCR line into an XImage.
550 static void flat_HPCR_z_line( GLcontext
*ctx
,
551 SWvertex
*vert0
, SWvertex
*vert1
)
553 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
554 const GLubyte
*color
= vert0
->color
;
555 GLint r
= color
[0], g
= color
[1], b
= color
[2];
559 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
560 #define PIXEL_TYPE GLubyte
561 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
562 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
567 *pixelPtr = (GLubyte) DITHER_HPCR( X, Y, r, g, b); \
570 #include "swrast/s_linetemp.h"
576 * Examine ctx->Line attributes and set xmesa->xm_buffer->gc1
577 * and xmesa->xm_buffer->gc2 appropriately.
579 static void setup_x_line_options( GLcontext
*ctx
)
581 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
582 int i
, state
, state0
, new_state
, len
, offs
;
587 int line_width
, line_style
;
589 /*** Line Stipple ***/
590 if (ctx
->Line
.StippleFlag
) {
591 const int pattern
= ctx
->Line
.StipplePattern
;
594 state0
= state
= ((pattern
& 1) != 0);
596 /* Decompose the pattern */
597 for (i
=1,tbit
=2,len
=1;i
<16;++i
,tbit
=(tbit
<<1))
599 new_state
= ((tbit
& pattern
) != 0);
600 if (state
!= new_state
)
602 *dptr
++ = ctx
->Line
.StippleFactor
* len
;
609 *dptr
= ctx
->Line
.StippleFactor
* len
;
610 n_segments
= 1 + (dptr
- dashes
);
612 /* ensure an even no. of segments, or X may toggle on/off for consecutive patterns */
613 /* if (n_segments & 1) dashes [n_segments++] = 0; value of 0 not allowed in dash list */
615 /* Handle case where line style starts OFF */
622 fprintf (stderr
, "input pattern: 0x%04x, offset %d, %d segments:", pattern
, offs
, n_segments
);
623 for (i
= 0; i
< n_segments
; i
++)
624 fprintf (stderr
, " %d", dashes
[i
]);
625 fprintf (stderr
, "\n");
628 XMesaSetDashes( xmesa
->display
, xmesa
->xm_buffer
->gc1
,
629 offs
, dashes
, n_segments
);
630 XMesaSetDashes( xmesa
->display
, xmesa
->xm_buffer
->gc2
,
631 offs
, dashes
, n_segments
);
633 line_style
= LineOnOffDash
;
636 line_style
= LineSolid
;
640 line_width
= (int) (ctx
->Line
.Width
+0.5F
);
641 if (line_width
< 2) {
642 /* Use fast lines when possible */
646 /*** Set GC attributes ***/
647 XMesaSetLineAttributes( xmesa
->display
, xmesa
->xm_buffer
->gc1
,
648 line_width
, line_style
, CapButt
, JoinBevel
);
649 XMesaSetLineAttributes( xmesa
->display
, xmesa
->xm_buffer
->gc2
,
650 line_width
, line_style
, CapButt
, JoinBevel
);
651 XMesaSetFillStyle( xmesa
->display
, xmesa
->xm_buffer
->gc1
, FillSolid
);
652 XMesaSetFillStyle( xmesa
->display
, xmesa
->xm_buffer
->gc2
, FillSolid
);
657 static swrast_line_func
get_line_func( GLcontext
*ctx
)
659 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
660 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
661 int depth
= GET_VISUAL_DEPTH(xmesa
->xm_visual
);
663 (void) DitherValues
; /* silence unused var warning */
664 (void) kernel1
; /* silence unused var warning */
666 if (ctx
->Line
.SmoothFlag
) return (swrast_line_func
)NULL
;
667 if (ctx
->Texture
._ReallyEnabled
) return (swrast_line_func
)NULL
;
668 if (ctx
->Light
.ShadeModel
!=GL_FLAT
) return (swrast_line_func
)NULL
;
669 /* X line stippling doesn't match OpenGL stippling */
670 if (ctx
->Line
.StippleFlag
==GL_TRUE
) return (swrast_line_func
)NULL
;
672 if (xmesa
->xm_buffer
->buffer
==XIMAGE
673 && swrast
->_RasterMask
==DEPTH_BIT
674 && ctx
->Depth
.Func
==GL_LESS
675 && ctx
->Depth
.Mask
==GL_TRUE
676 && ctx
->Visual
.DepthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
677 && ctx
->Line
.Width
==1.0F
) {
678 switch (xmesa
->pixelformat
) {
680 return flat_TRUECOLOR_z_line
;
682 return flat_8A8B8G8R_z_line
;
684 return flat_8R8G8B_z_line
;
686 return flat_8R8G8B24_z_line
;
688 return flat_5R6G5B_z_line
;
689 case PF_DITHER_5R6G5B
:
690 return flat_DITHER_5R6G5B_z_line
;
692 return (depth
==8) ? flat_DITHER8_z_line
: (swrast_line_func
)NULL
;
694 return (depth
==8) ? flat_LOOKUP8_z_line
: (swrast_line_func
)NULL
;
696 return flat_HPCR_z_line
;
698 return (swrast_line_func
)NULL
;
701 if (xmesa
->xm_buffer
->buffer
==XIMAGE
702 && swrast
->_RasterMask
==0
703 && ctx
->Line
.Width
==1.0F
) {
704 switch (xmesa
->pixelformat
) {
706 return flat_TRUECOLOR_line
;
708 return flat_8A8B8G8R_line
;
710 return flat_8R8G8B_line
;
712 return flat_8R8G8B24_line
;
714 return flat_5R6G5B_line
;
715 case PF_DITHER_5R6G5B
:
716 return flat_DITHER_5R6G5B_line
;
718 return (depth
==8) ? flat_DITHER8_line
: (swrast_line_func
)NULL
;
720 return (depth
==8) ? flat_LOOKUP8_line
: (swrast_line_func
)NULL
;
722 return flat_HPCR_line
;
724 return (swrast_line_func
)NULL
;
728 /* XXX have to disable this because X's rasterization rules don't match
729 * software Mesa's. This causes the linehv.c conformance test to fail.
730 * In the future, we might provide a config option to enable this.
732 if (xmesa
->xm_buffer
->buffer
!=XIMAGE
&& ctx
->_RasterMask
==0) {
733 setup_x_line_options( ctx
);
734 return flat_pixmap_line
;
737 return (swrast_line_func
)NULL
;
740 /* Override for the swrast line-selection function. Try to use one
741 * of our internal line functions, otherwise fall back to the
742 * standard swrast functions.
744 void xmesa_choose_line( GLcontext
*ctx
)
746 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
748 if (!(swrast
->Line
= get_line_func( ctx
)))
749 _swrast_choose_line( ctx
);
753 #define XMESA_NEW_POINT (_NEW_POINT|_SWRAST_NEW_RASTERMASK)
754 #define XMESA_NEW_LINE (_NEW_LINE|_NEW_TEXTURE|_NEW_LIGHT|\
755 _NEW_DEPTH|_SWRAST_NEW_RASTERMASK)
756 #define XMESA_NEW_TRIANGLE (_NEW_POLYGON|_NEW_TEXTURE|_NEW_LIGHT|\
757 _SWRAST_NEW_RASTERMASK|_NEW_DEPTH)
760 /* Extend the software rasterizer with our line/point/triangle
763 void xmesa_register_swrast_functions( GLcontext
*ctx
)
765 SWcontext
*swrast
= SWRAST_CONTEXT( ctx
);
767 swrast
->choose_point
= xmesa_choose_point
;
768 swrast
->choose_line
= xmesa_choose_line
;
769 swrast
->choose_triangle
= xmesa_choose_triangle
;
771 swrast
->invalidate_point
|= XMESA_NEW_POINT
;
772 swrast
->invalidate_line
|= XMESA_NEW_LINE
;
773 swrast
->invalidate_triangle
|= XMESA_NEW_TRIANGLE
;