1 /* $Id: xm_line.c,v 1.5 2000/10/31 18:09:46 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"
47 /**********************************************************************/
48 /*** Point rendering ***/
49 /**********************************************************************/
53 * Render an array of points into a pixmap, any pixel format.
55 static void draw_points_ANY_pixmap( GLcontext
*ctx
, GLuint first
, GLuint last
)
57 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
58 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
59 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
60 XMesaGC gc
= xmesa
->xm_buffer
->gc2
;
61 struct vertex_buffer
*VB
= ctx
->VB
;
64 if (xmesa
->xm_visual
->gl_visual
->RGBAflag
) {
66 for (i
=first
;i
<=last
;i
++) {
67 if (VB
->ClipMask
[i
]==0) {
69 const GLubyte
*color
= VB
->ColorPtr
->data
[i
];
70 unsigned long pixel
= xmesa_color_to_pixel( xmesa
,
71 color
[0], color
[1], color
[2], color
[3], xmesa
->pixelformat
);
72 XMesaSetForeground( dpy
, gc
, pixel
);
73 x
= (GLint
) VB
->Win
.data
[i
][0];
74 y
= FLIP( xmesa
->xm_buffer
, (GLint
) VB
->Win
.data
[i
][1] );
75 XMesaDrawPoint( dpy
, buffer
, gc
, x
, y
);
80 /* Color index mode */
81 for (i
=first
;i
<=last
;i
++) {
82 if (VB
->ClipMask
[i
]==0) {
84 XMesaSetForeground( dpy
, gc
, VB
->IndexPtr
->data
[i
] );
85 x
= (GLint
) VB
->Win
.data
[i
][0];
86 y
= FLIP( xmesa
->xm_buffer
, (GLint
) VB
->Win
.data
[i
][1] );
87 XMesaDrawPoint( dpy
, buffer
, gc
, x
, y
);
96 * Analyze context state to see if we can provide a fast points drawing
97 * function, like those in points.c. Otherwise, return NULL.
99 points_func
xmesa_get_points_func( GLcontext
*ctx
)
101 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
103 if (ctx
->Point
.Size
==1.0F
&& !ctx
->Point
.SmoothFlag
&& ctx
->RasterMask
==0
104 && !ctx
->Texture
.ReallyEnabled
) {
105 if (xmesa
->xm_buffer
->buffer
==XIMAGE
) {
106 return (points_func
) NULL
; /*draw_points_ximage;*/
109 return draw_points_ANY_pixmap
;
113 return (points_func
) NULL
;
119 /**********************************************************************/
120 /*** Line rendering ***/
121 /**********************************************************************/
126 * Render a line into a pixmap, any pixel format.
128 static void flat_pixmap_line( GLcontext
*ctx
,
129 GLuint vert0
, GLuint vert1
, GLuint pv
)
131 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
132 struct vertex_buffer
*VB
= ctx
->VB
;
133 register int x0
, y0
, x1
, y1
;
136 if (xmesa
->xm_visual
->gl_visual
->RGBAflag
) {
137 const GLubyte
*color
= VB
->ColorPtr
->data
[pv
];
138 pixel
= xmesa_color_to_pixel( xmesa
, color
[0], color
[1], color
[2], color
[3],
139 xmesa
->pixelformat
);
142 pixel
= VB
->IndexPtr
->data
[pv
];
144 gc
= xmesa
->xm_buffer
->gc2
;
145 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
147 x0
= (GLint
) VB
->Win
.data
[vert0
][0];
148 y0
= FLIP( xmesa
->xm_buffer
, (GLint
) VB
->Win
.data
[vert0
][1] );
149 x1
= (GLint
) VB
->Win
.data
[vert1
][0];
150 y1
= FLIP( xmesa
->xm_buffer
, (GLint
) VB
->Win
.data
[vert1
][1] );
151 XMesaDrawLine( xmesa
->display
, xmesa
->xm_buffer
->buffer
, gc
,
158 * Draw a flat-shaded, PF_TRUECOLOR line into an XImage.
160 static void flat_TRUECOLOR_line( GLcontext
*ctx
,
161 GLuint vert0
, GLuint vert1
, GLuint pv
)
163 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
164 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
165 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
167 PACK_TRUECOLOR( pixel
, color
[0], color
[1], color
[2] );
171 #define PLOT(X,Y) XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel );
173 #include "swrast/s_linetemp.h"
179 * Draw a flat-shaded, PF_8A8B8G8R line into an XImage.
181 static void flat_8A8B8G8R_line( GLcontext
*ctx
,
182 GLuint vert0
, GLuint vert1
, GLuint pv
)
184 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
185 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
186 GLuint pixel
= PACK_8B8G8R( color
[0], color
[1], color
[2] );
188 #define PIXEL_TYPE GLuint
189 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
190 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
192 #define PLOT(X,Y) *pixelPtr = pixel;
194 #include "swrast/s_linetemp.h"
199 * Draw a flat-shaded, PF_8R8G8B line into an XImage.
201 static void flat_8R8G8B_line( GLcontext
*ctx
,
202 GLuint vert0
, GLuint vert1
, GLuint pv
)
204 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
205 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
206 GLuint pixel
= PACK_8R8G8B( color
[0], color
[1], color
[2] );
208 #define PIXEL_TYPE GLuint
209 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
210 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
212 #define PLOT(X,Y) *pixelPtr = pixel;
214 #include "swrast/s_linetemp.h"
219 * Draw a flat-shaded, PF_8R8G8B24 line into an XImage.
221 static void flat_8R8G8B24_line( GLcontext
*ctx
,
222 GLuint vert0
, GLuint vert1
, GLuint pv
)
224 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
225 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
227 #define PIXEL_TYPE bgr_t
228 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
229 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
231 #define PLOT(X,Y) { \
232 pixelPtr->r = color[RCOMP]; \
233 pixelPtr->g = color[GCOMP]; \
234 pixelPtr->b = color[BCOMP]; \
237 #include "swrast/s_linetemp.h"
242 * Draw a flat-shaded, PF_5R6G5B line into an XImage.
244 static void flat_5R6G5B_line( GLcontext
*ctx
,
245 GLuint vert0
, GLuint vert1
, GLuint pv
)
247 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
248 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
249 GLushort pixel
= PACK_5R6G5B( color
[0], color
[1], color
[2] );
251 #define PIXEL_TYPE GLushort
252 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
253 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
255 #define PLOT(X,Y) *pixelPtr = pixel;
257 #include "swrast/s_linetemp.h"
262 * Draw a flat-shaded, PF_DITHER_5R6G5B line into an XImage.
264 static void flat_DITHER_5R6G5B_line( GLcontext
*ctx
,
265 GLuint vert0
, GLuint vert1
, GLuint pv
)
267 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
268 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
270 #define PIXEL_TYPE GLushort
271 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
272 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
274 #define PLOT(X,Y) PACK_TRUEDITHER( *pixelPtr, X, Y, color[0], color[1], color[2] );
276 #include "swrast/s_linetemp.h"
282 * Draw a flat-shaded, PF_DITHER 8-bit line into an XImage.
284 static void flat_DITHER8_line( GLcontext
*ctx
,
285 GLuint vert0
, GLuint vert1
, GLuint pv
)
287 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
288 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
289 GLint r
= color
[0], g
= color
[1], b
= color
[2];
293 #define PIXEL_TYPE GLubyte
294 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
295 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
297 #define PLOT(X,Y) *pixelPtr = DITHER(X,Y,r,g,b);
299 #include "swrast/s_linetemp.h"
304 * Draw a flat-shaded, PF_LOOKUP 8-bit line into an XImage.
306 static void flat_LOOKUP8_line( GLcontext
*ctx
,
307 GLuint vert0
, GLuint vert1
, GLuint pv
)
309 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
310 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
313 pixel
= (GLubyte
) LOOKUP( color
[0], color
[1], color
[2] );
315 #define PIXEL_TYPE GLubyte
316 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
317 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
319 #define PLOT(X,Y) *pixelPtr = pixel;
321 #include "swrast/s_linetemp.h"
326 * Draw a flat-shaded, PF_HPCR line into an XImage.
328 static void flat_HPCR_line( GLcontext
*ctx
,
329 GLuint vert0
, GLuint vert1
, GLuint pv
)
331 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
332 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
333 GLint r
= color
[0], g
= color
[1], b
= color
[2];
336 #define PIXEL_TYPE GLubyte
337 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
338 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
340 #define PLOT(X,Y) *pixelPtr = (GLubyte) DITHER_HPCR(X,Y,r,g,b);
342 #include "swrast/s_linetemp.h"
348 * Draw a flat-shaded, Z-less, PF_TRUECOLOR line into an XImage.
350 static void flat_TRUECOLOR_z_line( GLcontext
*ctx
,
351 GLuint vert0
, GLuint vert1
, GLuint pv
)
353 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
354 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
355 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
357 PACK_TRUECOLOR( pixel
, color
[0], color
[1], color
[2] );
361 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
366 XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel ); \
369 #include "swrast/s_linetemp.h"
374 * Draw a flat-shaded, Z-less, PF_8A8B8G8R line into an XImage.
376 static void flat_8A8B8G8R_z_line( GLcontext
*ctx
,
377 GLuint vert0
, GLuint vert1
, GLuint pv
)
379 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
380 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
381 GLuint pixel
= PACK_8B8G8R( color
[0], color
[1], color
[2] );
384 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
385 #define PIXEL_TYPE GLuint
386 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
387 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
395 #include "swrast/s_linetemp.h"
400 * Draw a flat-shaded, Z-less, PF_8R8G8B line into an XImage.
402 static void flat_8R8G8B_z_line( GLcontext
*ctx
,
403 GLuint vert0
, GLuint vert1
, GLuint pv
)
405 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
406 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
407 GLuint pixel
= PACK_8R8G8B( color
[0], color
[1], color
[2] );
410 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
411 #define PIXEL_TYPE GLuint
412 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
413 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
421 #include "swrast/s_linetemp.h"
426 * Draw a flat-shaded, Z-less, PF_8R8G8B24 line into an XImage.
428 static void flat_8R8G8B24_z_line( GLcontext
*ctx
,
429 GLuint vert0
, GLuint vert1
, GLuint pv
)
431 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
432 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
435 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
436 #define PIXEL_TYPE bgr_t
437 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
438 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
443 pixelPtr->r = color[RCOMP]; \
444 pixelPtr->g = color[GCOMP]; \
445 pixelPtr->b = color[BCOMP]; \
448 #include "swrast/s_linetemp.h"
453 * Draw a flat-shaded, Z-less, PF_5R6G5B line into an XImage.
455 static void flat_5R6G5B_z_line( GLcontext
*ctx
,
456 GLuint vert0
, GLuint vert1
, GLuint pv
)
458 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
459 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
460 GLushort pixel
= PACK_5R6G5B( color
[0], color
[1], color
[2] );
463 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
464 #define PIXEL_TYPE GLushort
465 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
466 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
473 #include "swrast/s_linetemp.h"
478 * Draw a flat-shaded, Z-less, PF_DITHER_5R6G5B line into an XImage.
480 static void flat_DITHER_5R6G5B_z_line( GLcontext
*ctx
,
481 GLuint vert0
, GLuint vert1
, GLuint pv
)
483 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
484 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
487 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
488 #define PIXEL_TYPE GLushort
489 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
490 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
495 PACK_TRUEDITHER(*pixelPtr, X, Y, color[0], color[1], color[2]); \
497 #include "swrast/s_linetemp.h"
502 * Draw a flat-shaded, Z-less, PF_DITHER 8-bit line into an XImage.
504 static void flat_DITHER8_z_line( GLcontext
*ctx
,
505 GLuint vert0
, GLuint vert1
, GLuint pv
)
507 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
508 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
509 GLint r
= color
[0], g
= color
[1], b
= color
[2];
514 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
515 #define PIXEL_TYPE GLubyte
516 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
517 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
522 *pixelPtr = (GLubyte) DITHER( X, Y, r, g, b); \
524 #include "swrast/s_linetemp.h"
529 * Draw a flat-shaded, Z-less, PF_LOOKUP 8-bit line into an XImage.
531 static void flat_LOOKUP8_z_line( GLcontext
*ctx
,
532 GLuint vert0
, GLuint vert1
, GLuint pv
)
534 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
535 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
538 pixel
= (GLubyte
) LOOKUP( color
[0], color
[1], color
[2] );
541 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
542 #define PIXEL_TYPE GLubyte
543 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
544 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
552 #include "swrast/s_linetemp.h"
557 * Draw a flat-shaded, Z-less, PF_HPCR line into an XImage.
559 static void flat_HPCR_z_line( GLcontext
*ctx
,
560 GLuint vert0
, GLuint vert1
, GLuint pv
)
562 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
563 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
564 GLint r
= color
[0], g
= color
[1], b
= color
[2];
568 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
569 #define PIXEL_TYPE GLubyte
570 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
571 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
576 *pixelPtr = (GLubyte) DITHER_HPCR( X, Y, r, g, b); \
579 #include "swrast/s_linetemp.h"
585 * Examine ctx->Line attributes and set xmesa->xm_buffer->gc1
586 * and xmesa->xm_buffer->gc2 appropriately.
588 static void setup_x_line_options( GLcontext
*ctx
)
590 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
591 int i
, state
, state0
, new_state
, len
, offs
;
596 int line_width
, line_style
;
598 /*** Line Stipple ***/
599 if (ctx
->Line
.StippleFlag
) {
600 const int pattern
= ctx
->Line
.StipplePattern
;
603 state0
= state
= ((pattern
& 1) != 0);
605 /* Decompose the pattern */
606 for (i
=1,tbit
=2,len
=1;i
<16;++i
,tbit
=(tbit
<<1))
608 new_state
= ((tbit
& pattern
) != 0);
609 if (state
!= new_state
)
611 *dptr
++ = ctx
->Line
.StippleFactor
* len
;
618 *dptr
= ctx
->Line
.StippleFactor
* len
;
619 n_segments
= 1 + (dptr
- dashes
);
621 /* ensure an even no. of segments, or X may toggle on/off for consecutive patterns */
622 /* if (n_segments & 1) dashes [n_segments++] = 0; value of 0 not allowed in dash list */
624 /* Handle case where line style starts OFF */
631 fprintf (stderr
, "input pattern: 0x%04x, offset %d, %d segments:", pattern
, offs
, n_segments
);
632 for (i
= 0; i
< n_segments
; i
++)
633 fprintf (stderr
, " %d", dashes
[i
]);
634 fprintf (stderr
, "\n");
637 XMesaSetDashes( xmesa
->display
, xmesa
->xm_buffer
->gc1
,
638 offs
, dashes
, n_segments
);
639 XMesaSetDashes( xmesa
->display
, xmesa
->xm_buffer
->gc2
,
640 offs
, dashes
, n_segments
);
642 line_style
= LineOnOffDash
;
645 line_style
= LineSolid
;
649 line_width
= (int) (ctx
->Line
.Width
+0.5F
);
650 if (line_width
< 2) {
651 /* Use fast lines when possible */
655 /*** Set GC attributes ***/
656 XMesaSetLineAttributes( xmesa
->display
, xmesa
->xm_buffer
->gc1
,
657 line_width
, line_style
, CapButt
, JoinBevel
);
658 XMesaSetLineAttributes( xmesa
->display
, xmesa
->xm_buffer
->gc2
,
659 line_width
, line_style
, CapButt
, JoinBevel
);
660 XMesaSetFillStyle( xmesa
->display
, xmesa
->xm_buffer
->gc1
, FillSolid
);
661 XMesaSetFillStyle( xmesa
->display
, xmesa
->xm_buffer
->gc2
, FillSolid
);
668 * Analyze context state to see if we can provide a fast line drawing
669 * function, like those in lines.c. Otherwise, return NULL.
671 line_func
xmesa_get_line_func( GLcontext
*ctx
)
673 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
674 int depth
= GET_VISUAL_DEPTH(xmesa
->xm_visual
);
676 (void) DitherValues
; /* silence unused var warning */
677 (void) kernel1
; /* silence unused var warning */
679 if (ctx
->Line
.SmoothFlag
) return (line_func
)NULL
;
680 if (ctx
->Texture
.ReallyEnabled
) return (line_func
)NULL
;
681 if (ctx
->Light
.ShadeModel
!=GL_FLAT
) return (line_func
)NULL
;
682 /* X line stippling doesn't match OpenGL stippling */
683 if (ctx
->Line
.StippleFlag
==GL_TRUE
) return (line_func
)NULL
;
685 if (xmesa
->xm_buffer
->buffer
==XIMAGE
686 && ctx
->RasterMask
==DEPTH_BIT
687 && ctx
->Depth
.Func
==GL_LESS
688 && ctx
->Depth
.Mask
==GL_TRUE
689 && ctx
->Visual
.DepthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
690 && ctx
->Line
.Width
==1.0F
) {
691 switch (xmesa
->pixelformat
) {
693 return flat_TRUECOLOR_z_line
;
695 return flat_8A8B8G8R_z_line
;
697 return flat_8R8G8B_z_line
;
699 return flat_8R8G8B24_z_line
;
701 return flat_5R6G5B_z_line
;
702 case PF_DITHER_5R6G5B
:
703 return flat_DITHER_5R6G5B_z_line
;
705 return (depth
==8) ? flat_DITHER8_z_line
: (line_func
)NULL
;
707 return (depth
==8) ? flat_LOOKUP8_z_line
: (line_func
)NULL
;
709 return flat_HPCR_z_line
;
711 return (line_func
)NULL
;
714 if (xmesa
->xm_buffer
->buffer
==XIMAGE
715 && ctx
->RasterMask
==0
716 && ctx
->Line
.Width
==1.0F
) {
717 switch (xmesa
->pixelformat
) {
719 return flat_TRUECOLOR_line
;
721 return flat_8A8B8G8R_line
;
723 return flat_8R8G8B_line
;
725 return flat_8R8G8B24_line
;
727 return flat_5R6G5B_line
;
728 case PF_DITHER_5R6G5B
:
729 return flat_DITHER_5R6G5B_line
;
731 return (depth
==8) ? flat_DITHER8_line
: (line_func
)NULL
;
733 return (depth
==8) ? flat_LOOKUP8_line
: (line_func
)NULL
;
735 return flat_HPCR_line
;
737 return (line_func
)NULL
;
741 /* XXX have to disable this because X's rasterization rules don't match
742 * software Mesa's. This causes the linehv.c conformance test to fail.
743 * In the future, we might provide a config option to enable this.
745 if (xmesa
->xm_buffer
->buffer
!=XIMAGE
&& ctx
->RasterMask
==0) {
746 setup_x_line_options( ctx
);
747 return flat_pixmap_line
;
750 return (line_func
)NULL
;