xm_line.c revision 8afe7de8deaf3c9613fd68b344de8c52b02b1879
1/* $Id: xm_line.c,v 1.20 2002/06/15 03:03:10 brianp Exp $ */
2
3/*
4 * Mesa 3-D graphics library
5 * Version:  3.5
6 *
7 * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
8 *
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:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
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.
25 */
26
27
28/*
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.
32 */
33
34
35#include "glxheader.h"
36#include "depth.h"
37#include "macros.h"
38#include "mmath.h"
39#include "mtypes.h"
40#include "xmesaP.h"
41
42/* Internal swrast includes:
43 */
44#include "swrast/s_depth.h"
45#include "swrast/s_points.h"
46#include "swrast/s_lines.h"
47#include "swrast/s_context.h"
48
49
50/**********************************************************************/
51/***                    Point rendering                             ***/
52/**********************************************************************/
53
54
55/*
56 * Render an array of points into a pixmap, any pixel format.
57 */
58#if 000
59/* XXX don't use this, it doesn't dither correctly */
60static void draw_points_ANY_pixmap( GLcontext *ctx, const SWvertex *vert )
61{
62   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
63   XMesaDisplay *dpy = xmesa->xm_visual->display;
64   XMesaDrawable buffer = xmesa->xm_buffer->buffer;
65   XMesaGC gc = xmesa->xm_buffer->gc;
66
67   if (xmesa->xm_visual->mesa_visual.RGBAflag) {
68      register int x, y;
69      const GLubyte *color = vert->color;
70      unsigned long pixel = xmesa_color_to_pixel( xmesa,
71						  color[0], color[1],
72						  color[2], color[3],
73						  xmesa->pixelformat);
74      XMesaSetForeground( dpy, gc, pixel );
75      x =                         (GLint) vert->win[0];
76      y = FLIP( xmesa->xm_buffer, (GLint) vert->win[1] );
77      XMesaDrawPoint( dpy, buffer, gc, x, y);
78   }
79   else {
80      /* Color index mode */
81      register int x, y;
82      XMesaSetForeground( dpy, gc, vert->index );
83      x =                         (GLint) vert->win[0];
84      y = FLIP( xmesa->xm_buffer, (GLint) vert->win[1] );
85      XMesaDrawPoint( dpy, buffer, gc, x, y);
86   }
87}
88#endif
89
90
91/* Override the swrast point-selection function.  Try to use one of
92 * our internal point functions, otherwise fall back to the standard
93 * swrast functions.
94 */
95void xmesa_choose_point( GLcontext *ctx )
96{
97#if 0
98   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
99   SWcontext *swrast = SWRAST_CONTEXT(ctx);
100
101   if (ctx->RenderMode == GL_RENDER
102       && ctx->Point.Size == 1.0F && !ctx->Point.SmoothFlag
103       && swrast->_RasterMask == 0
104       && !ctx->Texture._EnabledUnits
105       && xmesa->xm_buffer->buffer != XIMAGE) {
106      swrast->Point = draw_points_ANY_pixmap;
107   }
108   else {
109      _swrast_choose_point( ctx );
110   }
111#else
112   _swrast_choose_point( ctx );
113#endif
114}
115
116
117
118/**********************************************************************/
119/***                      Line rendering                            ***/
120/**********************************************************************/
121
122
123/*
124 * Draw a flat-shaded, PF_TRUECOLOR line into an XImage.
125 */
126static void flat_TRUECOLOR_line( GLcontext *ctx,
127                                 const SWvertex *vert0, const SWvertex *vert1 )
128{
129   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
130   const GLubyte *color = vert1->color;
131   XMesaImage *img = xmesa->xm_buffer->backimage;
132   unsigned long pixel;
133   PACK_TRUECOLOR( pixel, color[0], color[1], color[2] );
134
135#define INTERP_XY 1
136#define CLIP_HACK 1
137#define PLOT(X,Y) XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel );
138
139#include "swrast/s_linetemp.h"
140}
141
142
143
144/*
145 * Draw a flat-shaded, PF_8A8B8G8R line into an XImage.
146 */
147static void flat_8A8B8G8R_line( GLcontext *ctx,
148                                const SWvertex *vert0, const SWvertex *vert1 )
149{
150   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
151   const GLubyte *color = vert1->color;
152   GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
153
154#define PIXEL_TYPE GLuint
155#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
156#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
157#define CLIP_HACK 1
158#define PLOT(X,Y) *pixelPtr = pixel;
159
160#include "swrast/s_linetemp.h"
161}
162
163
164/*
165 * Draw a flat-shaded, PF_8R8G8B line into an XImage.
166 */
167static void flat_8R8G8B_line( GLcontext *ctx,
168                              const SWvertex *vert0, const SWvertex *vert1 )
169{
170   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
171   const GLubyte *color = vert1->color;
172   GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
173
174#define PIXEL_TYPE GLuint
175#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
176#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
177#define CLIP_HACK 1
178#define PLOT(X,Y) *pixelPtr = pixel;
179
180#include "swrast/s_linetemp.h"
181}
182
183
184/*
185 * Draw a flat-shaded, PF_8R8G8B24 line into an XImage.
186 */
187static void flat_8R8G8B24_line( GLcontext *ctx,
188                              const SWvertex *vert0, const SWvertex *vert1 )
189{
190   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
191   const GLubyte *color = vert1->color;
192
193#define PIXEL_TYPE bgr_t
194#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
195#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
196#define CLIP_HACK 1
197#define PLOT(X,Y) {			\
198      pixelPtr->r = color[RCOMP];	\
199      pixelPtr->g = color[GCOMP];	\
200      pixelPtr->b = color[BCOMP];	\
201}
202
203#include "swrast/s_linetemp.h"
204}
205
206
207/*
208 * Draw a flat-shaded, PF_5R6G5B line into an XImage.
209 */
210static void flat_5R6G5B_line( GLcontext *ctx,
211                              const SWvertex *vert0, const SWvertex *vert1 )
212{
213   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
214   const GLubyte *color = vert1->color;
215   GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] );
216
217#define PIXEL_TYPE GLushort
218#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
219#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
220#define CLIP_HACK 1
221#define PLOT(X,Y) *pixelPtr = pixel;
222
223#include "swrast/s_linetemp.h"
224}
225
226
227/*
228 * Draw a flat-shaded, PF_DITHER_5R6G5B line into an XImage.
229 */
230static void flat_DITHER_5R6G5B_line( GLcontext *ctx,
231                                     const SWvertex *vert0, const SWvertex *vert1 )
232{
233   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
234   const GLubyte *color = vert1->color;
235
236#define PIXEL_TYPE GLushort
237#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
238#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
239#define CLIP_HACK 1
240#define PLOT(X,Y) PACK_TRUEDITHER( *pixelPtr, X, Y, color[0], color[1], color[2] );
241
242#include "swrast/s_linetemp.h"
243}
244
245
246
247/*
248 * Draw a flat-shaded, PF_DITHER 8-bit line into an XImage.
249 */
250static void flat_DITHER8_line( GLcontext *ctx,
251                               const SWvertex *vert0, const SWvertex *vert1 )
252{
253   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
254   const GLubyte *color = vert1->color;
255   GLint r = color[0], g = color[1], b = color[2];
256   DITHER_SETUP;
257
258#define INTERP_XY 1
259#define PIXEL_TYPE GLubyte
260#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
261#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
262#define CLIP_HACK 1
263#define PLOT(X,Y) *pixelPtr = DITHER(X,Y,r,g,b);
264
265#include "swrast/s_linetemp.h"
266}
267
268
269/*
270 * Draw a flat-shaded, PF_LOOKUP 8-bit line into an XImage.
271 */
272static void flat_LOOKUP8_line( GLcontext *ctx,
273                               const SWvertex *vert0, const SWvertex *vert1 )
274{
275   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
276   const GLubyte *color = vert1->color;
277   GLubyte pixel;
278   LOOKUP_SETUP;
279   pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] );
280
281#define PIXEL_TYPE GLubyte
282#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
283#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
284#define CLIP_HACK 1
285#define PLOT(X,Y) *pixelPtr = pixel;
286
287#include "swrast/s_linetemp.h"
288}
289
290
291/*
292 * Draw a flat-shaded, PF_HPCR line into an XImage.
293 */
294static void flat_HPCR_line( GLcontext *ctx,
295                            const SWvertex *vert0, const SWvertex *vert1 )
296{
297   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
298   const GLubyte *color = vert1->color;
299   GLint r = color[0], g = color[1], b = color[2];
300
301#define INTERP_XY 1
302#define PIXEL_TYPE GLubyte
303#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
304#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
305#define CLIP_HACK 1
306#define PLOT(X,Y) *pixelPtr = (GLubyte) DITHER_HPCR(X,Y,r,g,b);
307
308#include "swrast/s_linetemp.h"
309}
310
311
312
313/*
314 * Draw a flat-shaded, Z-less, PF_TRUECOLOR line into an XImage.
315 */
316static void flat_TRUECOLOR_z_line( GLcontext *ctx,
317                                   const SWvertex *vert0, const SWvertex *vert1 )
318{
319   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
320   const GLubyte *color = vert1->color;
321   XMesaImage *img = xmesa->xm_buffer->backimage;
322   unsigned long pixel;
323   PACK_TRUECOLOR( pixel, color[0], color[1], color[2] );
324
325#define INTERP_XY 1
326#define INTERP_Z 1
327#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
328#define CLIP_HACK 1
329#define PLOT(X,Y)							\
330	if (Z < *zPtr) {						\
331	   *zPtr = Z;							\
332           XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel );	\
333	}
334
335#include "swrast/s_linetemp.h"
336}
337
338
339/*
340 * Draw a flat-shaded, Z-less, PF_8A8B8G8R line into an XImage.
341 */
342static void flat_8A8B8G8R_z_line( GLcontext *ctx,
343                                  const SWvertex *vert0, const SWvertex *vert1 )
344{
345   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
346   const GLubyte *color = vert1->color;
347   GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
348
349#define INTERP_Z 1
350#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
351#define PIXEL_TYPE GLuint
352#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
353#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
354#define CLIP_HACK 1
355#define PLOT(X,Y)		\
356	if (Z < *zPtr) {	\
357	   *zPtr = Z;		\
358	   *pixelPtr = pixel;	\
359	}
360
361#include "swrast/s_linetemp.h"
362}
363
364
365/*
366 * Draw a flat-shaded, Z-less, PF_8R8G8B line into an XImage.
367 */
368static void flat_8R8G8B_z_line( GLcontext *ctx,
369                                const SWvertex *vert0, const SWvertex *vert1 )
370{
371   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
372   const GLubyte *color = vert1->color;
373   GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
374
375#define INTERP_Z 1
376#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
377#define PIXEL_TYPE GLuint
378#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
379#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
380#define CLIP_HACK 1
381#define PLOT(X,Y)		\
382	if (Z < *zPtr) {	\
383	   *zPtr = Z;		\
384	   *pixelPtr = pixel;	\
385	}
386
387#include "swrast/s_linetemp.h"
388}
389
390
391/*
392 * Draw a flat-shaded, Z-less, PF_8R8G8B24 line into an XImage.
393 */
394static void flat_8R8G8B24_z_line( GLcontext *ctx,
395                                    const SWvertex *vert0, const SWvertex *vert1 )
396{
397   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
398   const GLubyte *color = vert1->color;
399
400#define INTERP_Z 1
401#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
402#define PIXEL_TYPE bgr_t
403#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
404#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
405#define CLIP_HACK 1
406#define PLOT(X,Y)			\
407	if (Z < *zPtr) {		\
408	   *zPtr = Z;			\
409           pixelPtr->r = color[RCOMP];	\
410           pixelPtr->g = color[GCOMP];	\
411           pixelPtr->b = color[BCOMP];	\
412	}
413
414#include "swrast/s_linetemp.h"
415}
416
417
418/*
419 * Draw a flat-shaded, Z-less, PF_5R6G5B line into an XImage.
420 */
421static void flat_5R6G5B_z_line( GLcontext *ctx,
422                                const SWvertex *vert0, const SWvertex *vert1 )
423{
424   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
425   const GLubyte *color = vert1->color;
426   GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] );
427
428#define INTERP_Z 1
429#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
430#define PIXEL_TYPE GLushort
431#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
432#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
433#define CLIP_HACK 1
434#define PLOT(X,Y)		\
435	if (Z < *zPtr) {	\
436	   *zPtr = Z;		\
437	   *pixelPtr = pixel;	\
438	}
439#include "swrast/s_linetemp.h"
440}
441
442
443/*
444 * Draw a flat-shaded, Z-less, PF_DITHER_5R6G5B line into an XImage.
445 */
446static void flat_DITHER_5R6G5B_z_line( GLcontext *ctx,
447                                       const SWvertex *vert0, const SWvertex *vert1 )
448{
449   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
450   const GLubyte *color = vert1->color;
451
452#define INTERP_Z 1
453#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
454#define PIXEL_TYPE GLushort
455#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
456#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
457#define CLIP_HACK 1
458#define PLOT(X,Y)		\
459	if (Z < *zPtr) {	\
460	   *zPtr = Z;		\
461	   PACK_TRUEDITHER(*pixelPtr, X, Y, color[0], color[1], color[2]); \
462	}
463#include "swrast/s_linetemp.h"
464}
465
466
467/*
468 * Draw a flat-shaded, Z-less, PF_DITHER 8-bit line into an XImage.
469 */
470static void flat_DITHER8_z_line( GLcontext *ctx,
471                                 const SWvertex *vert0, const SWvertex *vert1 )
472{
473   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
474   const GLubyte *color = vert1->color;
475   GLint r = color[0], g = color[1], b = color[2];
476   DITHER_SETUP;
477
478#define INTERP_XY 1
479#define INTERP_Z 1
480#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
481#define PIXEL_TYPE GLubyte
482#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
483#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
484#define CLIP_HACK 1
485#define PLOT(X,Y)						\
486	if (Z < *zPtr) {					\
487	   *zPtr = Z;						\
488	   *pixelPtr = (GLubyte) DITHER( X, Y, r, g, b);	\
489	}
490#include "swrast/s_linetemp.h"
491}
492
493
494/*
495 * Draw a flat-shaded, Z-less, PF_LOOKUP 8-bit line into an XImage.
496 */
497static void flat_LOOKUP8_z_line( GLcontext *ctx,
498                                 const SWvertex *vert0, const SWvertex *vert1 )
499{
500   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
501   const GLubyte *color = vert1->color;
502   GLubyte pixel;
503   LOOKUP_SETUP;
504   pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] );
505
506#define INTERP_Z 1
507#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
508#define PIXEL_TYPE GLubyte
509#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
510#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
511#define CLIP_HACK 1
512#define PLOT(X,Y)		\
513	if (Z < *zPtr) {	\
514	   *zPtr = Z;		\
515	   *pixelPtr = pixel;	\
516	}
517
518#include "swrast/s_linetemp.h"
519}
520
521
522/*
523 * Draw a flat-shaded, Z-less, PF_HPCR line into an XImage.
524 */
525static void flat_HPCR_z_line( GLcontext *ctx,
526                              const SWvertex *vert0, const SWvertex *vert1 )
527{
528   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
529   const GLubyte *color = vert1->color;
530   GLint r = color[0], g = color[1], b = color[2];
531
532#define INTERP_XY 1
533#define INTERP_Z 1
534#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
535#define PIXEL_TYPE GLubyte
536#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
537#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
538#define CLIP_HACK 1
539#define PLOT(X,Y)						\
540	if (Z < *zPtr) {					\
541	   *zPtr = Z;						\
542	   *pixelPtr = (GLubyte) DITHER_HPCR( X, Y, r, g, b);	\
543	}
544
545#include "swrast/s_linetemp.h"
546}
547
548
549static swrast_line_func get_line_func( GLcontext *ctx )
550{
551   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
552   SWcontext *swrast = SWRAST_CONTEXT(ctx);
553   int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
554
555   (void) DitherValues;  /* silence unused var warning */
556   (void) kernel1;  /* silence unused var warning */
557
558   if (ctx->RenderMode != GL_RENDER)      return (swrast_line_func) NULL;
559   if (ctx->Line.SmoothFlag)              return (swrast_line_func) NULL;
560   if (ctx->Texture._EnabledUnits)        return (swrast_line_func) NULL;
561   if (ctx->Light.ShadeModel != GL_FLAT)  return (swrast_line_func) NULL;
562   if (ctx->Line.StippleFlag)             return (swrast_line_func) NULL;
563   if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_line_func) NULL;
564
565   if (xmesa->xm_buffer->buffer==XIMAGE
566       && swrast->_RasterMask==DEPTH_BIT
567       && ctx->Depth.Func==GL_LESS
568       && ctx->Depth.Mask==GL_TRUE
569       && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
570       && ctx->Line.Width==1.0F) {
571      switch (xmesa->pixelformat) {
572         case PF_TRUECOLOR:
573            return flat_TRUECOLOR_z_line;
574         case PF_8A8B8G8R:
575            return flat_8A8B8G8R_z_line;
576         case PF_8R8G8B:
577            return flat_8R8G8B_z_line;
578         case PF_8R8G8B24:
579            return flat_8R8G8B24_z_line;
580         case PF_5R6G5B:
581            return flat_5R6G5B_z_line;
582         case PF_DITHER_5R6G5B:
583            return flat_DITHER_5R6G5B_z_line;
584         case PF_DITHER:
585            return (depth==8) ? flat_DITHER8_z_line : (swrast_line_func) NULL;
586         case PF_LOOKUP:
587            return (depth==8) ? flat_LOOKUP8_z_line : (swrast_line_func) NULL;
588         case PF_HPCR:
589            return flat_HPCR_z_line;
590         default:
591            return (swrast_line_func)NULL;
592      }
593   }
594   if (xmesa->xm_buffer->buffer==XIMAGE
595       && swrast->_RasterMask==0
596       && ctx->Line.Width==1.0F) {
597      switch (xmesa->pixelformat) {
598         case PF_TRUECOLOR:
599            return flat_TRUECOLOR_line;
600         case PF_8A8B8G8R:
601            return flat_8A8B8G8R_line;
602         case PF_8R8G8B:
603            return flat_8R8G8B_line;
604         case PF_8R8G8B24:
605            return flat_8R8G8B24_line;
606         case PF_5R6G5B:
607            return flat_5R6G5B_line;
608         case PF_DITHER_5R6G5B:
609            return flat_DITHER_5R6G5B_line;
610         case PF_DITHER:
611            return (depth==8) ? flat_DITHER8_line : (swrast_line_func) NULL;
612         case PF_LOOKUP:
613            return (depth==8) ? flat_LOOKUP8_line : (swrast_line_func) NULL;
614         case PF_HPCR:
615            return flat_HPCR_line;
616	 default:
617	    return (swrast_line_func)NULL;
618      }
619   }
620
621   return (swrast_line_func) NULL;
622}
623
624/* Override for the swrast line-selection function.  Try to use one
625 * of our internal line functions, otherwise fall back to the
626 * standard swrast functions.
627 */
628void xmesa_choose_line( GLcontext *ctx )
629{
630   SWcontext *swrast = SWRAST_CONTEXT(ctx);
631
632   if (!(swrast->Line = get_line_func( ctx )))
633      _swrast_choose_line( ctx );
634}
635