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