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