1 /* $Id: xm_line.c,v 1.6 2000/11/05 18:26:12 keithw 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 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
97 if (ctx
->Point
.Size
==1.0F
&& !ctx
->Point
.SmoothFlag
98 && swrast
->_RasterMask
==0
99 && !ctx
->Texture
._ReallyEnabled
) {
100 swrast
->Point
= draw_points_ANY_pixmap
;
103 _swrast_choose_point( ctx
);
109 /**********************************************************************/
110 /*** Line rendering ***/
111 /**********************************************************************/
116 * Render a line into a pixmap, any pixel format.
118 static void flat_pixmap_line( GLcontext
*ctx
,
119 SWvertex
*vert0
, SWvertex
*vert1
)
121 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
122 register int x0
, y0
, x1
, y1
;
125 if (xmesa
->xm_visual
->gl_visual
->RGBAflag
) {
126 const GLubyte
*color
= vert0
->color
;
127 pixel
= xmesa_color_to_pixel( xmesa
, color
[0], color
[1], color
[2], color
[3],
128 xmesa
->pixelformat
);
131 pixel
= vert0
->index
;
133 gc
= xmesa
->xm_buffer
->gc2
;
134 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
136 x0
= (GLint
) vert0
->win
[0];
137 y0
= FLIP( xmesa
->xm_buffer
, (GLint
) vert0
->win
[1] );
138 x1
= (GLint
) vert1
->win
[0];
139 y1
= FLIP( xmesa
->xm_buffer
, (GLint
) vert1
->win
[1] );
140 XMesaDrawLine( xmesa
->display
, xmesa
->xm_buffer
->buffer
, gc
,
147 * Draw a flat-shaded, PF_TRUECOLOR line into an XImage.
149 static void flat_TRUECOLOR_line( GLcontext
*ctx
,
150 SWvertex
*vert0
, SWvertex
*vert1
)
152 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
153 const GLubyte
*color
= vert0
->color
;
154 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
156 PACK_TRUECOLOR( pixel
, color
[0], color
[1], color
[2] );
160 #define PLOT(X,Y) XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel );
162 #include "swrast/s_linetemp.h"
168 * Draw a flat-shaded, PF_8A8B8G8R line into an XImage.
170 static void flat_8A8B8G8R_line( GLcontext
*ctx
,
171 SWvertex
*vert0
, SWvertex
*vert1
)
173 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
174 const GLubyte
*color
= vert0
->color
;
175 GLuint pixel
= PACK_8B8G8R( color
[0], color
[1], color
[2] );
177 #define PIXEL_TYPE GLuint
178 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
179 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
181 #define PLOT(X,Y) *pixelPtr = pixel;
183 #include "swrast/s_linetemp.h"
188 * Draw a flat-shaded, PF_8R8G8B line into an XImage.
190 static void flat_8R8G8B_line( GLcontext
*ctx
,
191 SWvertex
*vert0
, SWvertex
*vert1
)
193 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
194 const GLubyte
*color
= vert0
->color
;
195 GLuint pixel
= PACK_8R8G8B( color
[0], color
[1], color
[2] );
197 #define PIXEL_TYPE GLuint
198 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
199 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
201 #define PLOT(X,Y) *pixelPtr = pixel;
203 #include "swrast/s_linetemp.h"
208 * Draw a flat-shaded, PF_8R8G8B24 line into an XImage.
210 static void flat_8R8G8B24_line( GLcontext
*ctx
,
211 SWvertex
*vert0
, SWvertex
*vert1
)
213 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
214 const GLubyte
*color
= vert0
->color
;
216 #define PIXEL_TYPE bgr_t
217 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
218 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
220 #define PLOT(X,Y) { \
221 pixelPtr->r = color[RCOMP]; \
222 pixelPtr->g = color[GCOMP]; \
223 pixelPtr->b = color[BCOMP]; \
226 #include "swrast/s_linetemp.h"
231 * Draw a flat-shaded, PF_5R6G5B line into an XImage.
233 static void flat_5R6G5B_line( GLcontext
*ctx
,
234 SWvertex
*vert0
, SWvertex
*vert1
)
236 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
237 const GLubyte
*color
= vert0
->color
;
238 GLushort pixel
= PACK_5R6G5B( color
[0], color
[1], color
[2] );
240 #define PIXEL_TYPE GLushort
241 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
242 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
244 #define PLOT(X,Y) *pixelPtr = pixel;
246 #include "swrast/s_linetemp.h"
251 * Draw a flat-shaded, PF_DITHER_5R6G5B line into an XImage.
253 static void flat_DITHER_5R6G5B_line( GLcontext
*ctx
,
254 SWvertex
*vert0
, SWvertex
*vert1
)
256 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
257 const GLubyte
*color
= vert0
->color
;
259 #define PIXEL_TYPE GLushort
260 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
261 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
263 #define PLOT(X,Y) PACK_TRUEDITHER( *pixelPtr, X, Y, color[0], color[1], color[2] );
265 #include "swrast/s_linetemp.h"
271 * Draw a flat-shaded, PF_DITHER 8-bit line into an XImage.
273 static void flat_DITHER8_line( GLcontext
*ctx
,
274 SWvertex
*vert0
, SWvertex
*vert1
)
276 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
277 const GLubyte
*color
= vert0
->color
;
278 GLint r
= color
[0], g
= color
[1], b
= color
[2];
282 #define PIXEL_TYPE GLubyte
283 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
284 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
286 #define PLOT(X,Y) *pixelPtr = DITHER(X,Y,r,g,b);
288 #include "swrast/s_linetemp.h"
293 * Draw a flat-shaded, PF_LOOKUP 8-bit line into an XImage.
295 static void flat_LOOKUP8_line( GLcontext
*ctx
,
296 SWvertex
*vert0
, SWvertex
*vert1
)
298 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
299 const GLubyte
*color
= vert0
->color
;
302 pixel
= (GLubyte
) LOOKUP( color
[0], color
[1], color
[2] );
304 #define PIXEL_TYPE GLubyte
305 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
306 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
308 #define PLOT(X,Y) *pixelPtr = pixel;
310 #include "swrast/s_linetemp.h"
315 * Draw a flat-shaded, PF_HPCR line into an XImage.
317 static void flat_HPCR_line( GLcontext
*ctx
,
318 SWvertex
*vert0
, SWvertex
*vert1
)
320 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
321 const GLubyte
*color
= vert0
->color
;
322 GLint r
= color
[0], g
= color
[1], b
= color
[2];
325 #define PIXEL_TYPE GLubyte
326 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
327 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
329 #define PLOT(X,Y) *pixelPtr = (GLubyte) DITHER_HPCR(X,Y,r,g,b);
331 #include "swrast/s_linetemp.h"
337 * Draw a flat-shaded, Z-less, PF_TRUECOLOR line into an XImage.
339 static void flat_TRUECOLOR_z_line( GLcontext
*ctx
,
340 SWvertex
*vert0
, SWvertex
*vert1
)
342 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
343 const GLubyte
*color
= vert0
->color
;
344 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
346 PACK_TRUECOLOR( pixel
, color
[0], color
[1], color
[2] );
350 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
355 XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel ); \
358 #include "swrast/s_linetemp.h"
363 * Draw a flat-shaded, Z-less, PF_8A8B8G8R line into an XImage.
365 static void flat_8A8B8G8R_z_line( GLcontext
*ctx
,
366 SWvertex
*vert0
, SWvertex
*vert1
)
368 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
369 const GLubyte
*color
= vert0
->color
;
370 GLuint pixel
= PACK_8B8G8R( color
[0], color
[1], color
[2] );
373 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
374 #define PIXEL_TYPE GLuint
375 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
376 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
384 #include "swrast/s_linetemp.h"
389 * Draw a flat-shaded, Z-less, PF_8R8G8B line into an XImage.
391 static void flat_8R8G8B_z_line( GLcontext
*ctx
,
392 SWvertex
*vert0
, SWvertex
*vert1
)
394 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
395 const GLubyte
*color
= vert0
->color
;
396 GLuint pixel
= PACK_8R8G8B( color
[0], color
[1], color
[2] );
399 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
400 #define PIXEL_TYPE GLuint
401 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
402 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
410 #include "swrast/s_linetemp.h"
415 * Draw a flat-shaded, Z-less, PF_8R8G8B24 line into an XImage.
417 static void flat_8R8G8B24_z_line( GLcontext
*ctx
,
418 SWvertex
*vert0
, SWvertex
*vert1
)
420 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
421 const GLubyte
*color
= vert0
->color
;
424 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
425 #define PIXEL_TYPE bgr_t
426 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
427 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
432 pixelPtr->r = color[RCOMP]; \
433 pixelPtr->g = color[GCOMP]; \
434 pixelPtr->b = color[BCOMP]; \
437 #include "swrast/s_linetemp.h"
442 * Draw a flat-shaded, Z-less, PF_5R6G5B line into an XImage.
444 static void flat_5R6G5B_z_line( GLcontext
*ctx
,
445 SWvertex
*vert0
, SWvertex
*vert1
)
447 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
448 const GLubyte
*color
= vert0
->color
;
449 GLushort pixel
= PACK_5R6G5B( color
[0], color
[1], color
[2] );
452 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
453 #define PIXEL_TYPE GLushort
454 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
455 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
462 #include "swrast/s_linetemp.h"
467 * Draw a flat-shaded, Z-less, PF_DITHER_5R6G5B line into an XImage.
469 static void flat_DITHER_5R6G5B_z_line( GLcontext
*ctx
,
470 SWvertex
*vert0
, SWvertex
*vert1
)
472 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
473 const GLubyte
*color
= vert0
->color
;
476 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
477 #define PIXEL_TYPE GLushort
478 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
479 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
484 PACK_TRUEDITHER(*pixelPtr, X, Y, color[0], color[1], color[2]); \
486 #include "swrast/s_linetemp.h"
491 * Draw a flat-shaded, Z-less, PF_DITHER 8-bit line into an XImage.
493 static void flat_DITHER8_z_line( GLcontext
*ctx
,
494 SWvertex
*vert0
, SWvertex
*vert1
)
496 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
497 const GLubyte
*color
= vert0
->color
;
498 GLint r
= color
[0], g
= color
[1], b
= color
[2];
503 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
504 #define PIXEL_TYPE GLubyte
505 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
506 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
511 *pixelPtr = (GLubyte) DITHER( X, Y, r, g, b); \
513 #include "swrast/s_linetemp.h"
518 * Draw a flat-shaded, Z-less, PF_LOOKUP 8-bit line into an XImage.
520 static void flat_LOOKUP8_z_line( GLcontext
*ctx
,
521 SWvertex
*vert0
, SWvertex
*vert1
)
523 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
524 const GLubyte
*color
= vert0
->color
;
527 pixel
= (GLubyte
) LOOKUP( color
[0], color
[1], color
[2] );
530 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
531 #define PIXEL_TYPE GLubyte
532 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
533 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
541 #include "swrast/s_linetemp.h"
546 * Draw a flat-shaded, Z-less, PF_HPCR line into an XImage.
548 static void flat_HPCR_z_line( GLcontext
*ctx
,
549 SWvertex
*vert0
, SWvertex
*vert1
)
551 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
552 const GLubyte
*color
= vert0
->color
;
553 GLint r
= color
[0], g
= color
[1], b
= color
[2];
557 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
558 #define PIXEL_TYPE GLubyte
559 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
560 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
565 *pixelPtr = (GLubyte) DITHER_HPCR( X, Y, r, g, b); \
568 #include "swrast/s_linetemp.h"
574 * Examine ctx->Line attributes and set xmesa->xm_buffer->gc1
575 * and xmesa->xm_buffer->gc2 appropriately.
577 static void setup_x_line_options( GLcontext
*ctx
)
579 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
580 int i
, state
, state0
, new_state
, len
, offs
;
585 int line_width
, line_style
;
587 /*** Line Stipple ***/
588 if (ctx
->Line
.StippleFlag
) {
589 const int pattern
= ctx
->Line
.StipplePattern
;
592 state0
= state
= ((pattern
& 1) != 0);
594 /* Decompose the pattern */
595 for (i
=1,tbit
=2,len
=1;i
<16;++i
,tbit
=(tbit
<<1))
597 new_state
= ((tbit
& pattern
) != 0);
598 if (state
!= new_state
)
600 *dptr
++ = ctx
->Line
.StippleFactor
* len
;
607 *dptr
= ctx
->Line
.StippleFactor
* len
;
608 n_segments
= 1 + (dptr
- dashes
);
610 /* ensure an even no. of segments, or X may toggle on/off for consecutive patterns */
611 /* if (n_segments & 1) dashes [n_segments++] = 0; value of 0 not allowed in dash list */
613 /* Handle case where line style starts OFF */
620 fprintf (stderr
, "input pattern: 0x%04x, offset %d, %d segments:", pattern
, offs
, n_segments
);
621 for (i
= 0; i
< n_segments
; i
++)
622 fprintf (stderr
, " %d", dashes
[i
]);
623 fprintf (stderr
, "\n");
626 XMesaSetDashes( xmesa
->display
, xmesa
->xm_buffer
->gc1
,
627 offs
, dashes
, n_segments
);
628 XMesaSetDashes( xmesa
->display
, xmesa
->xm_buffer
->gc2
,
629 offs
, dashes
, n_segments
);
631 line_style
= LineOnOffDash
;
634 line_style
= LineSolid
;
638 line_width
= (int) (ctx
->Line
.Width
+0.5F
);
639 if (line_width
< 2) {
640 /* Use fast lines when possible */
644 /*** Set GC attributes ***/
645 XMesaSetLineAttributes( xmesa
->display
, xmesa
->xm_buffer
->gc1
,
646 line_width
, line_style
, CapButt
, JoinBevel
);
647 XMesaSetLineAttributes( xmesa
->display
, xmesa
->xm_buffer
->gc2
,
648 line_width
, line_style
, CapButt
, JoinBevel
);
649 XMesaSetFillStyle( xmesa
->display
, xmesa
->xm_buffer
->gc1
, FillSolid
);
650 XMesaSetFillStyle( xmesa
->display
, xmesa
->xm_buffer
->gc2
, FillSolid
);
655 static swrast_line_func
get_line_func( GLcontext
*ctx
)
657 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
658 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
659 int depth
= GET_VISUAL_DEPTH(xmesa
->xm_visual
);
661 (void) DitherValues
; /* silence unused var warning */
662 (void) kernel1
; /* silence unused var warning */
664 if (ctx
->Line
.SmoothFlag
) return (swrast_line_func
)NULL
;
665 if (ctx
->Texture
._ReallyEnabled
) return (swrast_line_func
)NULL
;
666 if (ctx
->Light
.ShadeModel
!=GL_FLAT
) return (swrast_line_func
)NULL
;
667 /* X line stippling doesn't match OpenGL stippling */
668 if (ctx
->Line
.StippleFlag
==GL_TRUE
) return (swrast_line_func
)NULL
;
670 if (xmesa
->xm_buffer
->buffer
==XIMAGE
671 && swrast
->_RasterMask
==DEPTH_BIT
672 && ctx
->Depth
.Func
==GL_LESS
673 && ctx
->Depth
.Mask
==GL_TRUE
674 && ctx
->Visual
.DepthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
675 && ctx
->Line
.Width
==1.0F
) {
676 switch (xmesa
->pixelformat
) {
678 return flat_TRUECOLOR_z_line
;
680 return flat_8A8B8G8R_z_line
;
682 return flat_8R8G8B_z_line
;
684 return flat_8R8G8B24_z_line
;
686 return flat_5R6G5B_z_line
;
687 case PF_DITHER_5R6G5B
:
688 return flat_DITHER_5R6G5B_z_line
;
690 return (depth
==8) ? flat_DITHER8_z_line
: (swrast_line_func
)NULL
;
692 return (depth
==8) ? flat_LOOKUP8_z_line
: (swrast_line_func
)NULL
;
694 return flat_HPCR_z_line
;
696 return (swrast_line_func
)NULL
;
699 if (xmesa
->xm_buffer
->buffer
==XIMAGE
700 && swrast
->_RasterMask
==0
701 && ctx
->Line
.Width
==1.0F
) {
702 switch (xmesa
->pixelformat
) {
704 return flat_TRUECOLOR_line
;
706 return flat_8A8B8G8R_line
;
708 return flat_8R8G8B_line
;
710 return flat_8R8G8B24_line
;
712 return flat_5R6G5B_line
;
713 case PF_DITHER_5R6G5B
:
714 return flat_DITHER_5R6G5B_line
;
716 return (depth
==8) ? flat_DITHER8_line
: (swrast_line_func
)NULL
;
718 return (depth
==8) ? flat_LOOKUP8_line
: (swrast_line_func
)NULL
;
720 return flat_HPCR_line
;
722 return (swrast_line_func
)NULL
;
726 /* XXX have to disable this because X's rasterization rules don't match
727 * software Mesa's. This causes the linehv.c conformance test to fail.
728 * In the future, we might provide a config option to enable this.
730 if (xmesa
->xm_buffer
->buffer
!=XIMAGE
&& ctx
->_RasterMask
==0) {
731 setup_x_line_options( ctx
);
732 return flat_pixmap_line
;
735 return (swrast_line_func
)NULL
;
738 /* Override for the swrast line-selection function. Try to use one
739 * of our internal line functions, otherwise fall back to the
740 * standard swrast functions.
742 void xmesa_choose_line( GLcontext
*ctx
)
744 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
746 if (!(swrast
->Line
= get_line_func( ctx
)))
747 _swrast_choose_line( ctx
);
751 #define XMESA_NEW_POINT (_NEW_POINT|_SWRAST_NEW_RASTERMASK)
752 #define XMESA_NEW_LINE (_NEW_LINE|_NEW_TEXTURE|_NEW_LIGHT|\
753 _NEW_DEPTH|_SWRAST_NEW_RASTERMASK)
754 #define XMESA_NEW_TRIANGLE (_NEW_POLYGON|_NEW_TEXTURE|_NEW_LIGHT|\
755 _SWRAST_NEW_RASTERMASK|_NEW_DEPTH)
758 /* Extend the software rasterizer with our line/point/triangle
761 void xmesa_register_swrast_functions( GLcontext
*ctx
)
763 SWcontext
*swrast
= SWRAST_CONTEXT( ctx
);
765 swrast
->choose_point
= xmesa_choose_point
;
766 swrast
->choose_line
= xmesa_choose_line
;
767 swrast
->choose_triangle
= xmesa_choose_triangle
;
769 swrast
->invalidate_point
|= XMESA_NEW_POINT
;
770 swrast
->invalidate_line
|= XMESA_NEW_LINE
;
771 swrast
->invalidate_triangle
|= XMESA_NEW_TRIANGLE
;