Removed fixed.h (GLfixed now in mtypes.h, fixed-pt macros in mmath.h)
[mesa.git] / src / mesa / drivers / x11 / xm_line.c
1 /* $Id: xm_line.c,v 1.14 2001/01/02 22:02:52 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 */
60 static 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->gl_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 */
95 void 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._ReallyEnabled
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 */
126 static void flat_TRUECOLOR_line( GLcontext *ctx,
127 const SWvertex *vert0, const SWvertex *vert1 )
128 {
129 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
130 const GLubyte *color = vert0->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 */
147 static void flat_8A8B8G8R_line( GLcontext *ctx,
148 const SWvertex *vert0, const SWvertex *vert1 )
149 {
150 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
151 const GLubyte *color = vert0->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 */
167 static void flat_8R8G8B_line( GLcontext *ctx,
168 const SWvertex *vert0, const SWvertex *vert1 )
169 {
170 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
171 const GLubyte *color = vert0->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 */
187 static void flat_8R8G8B24_line( GLcontext *ctx,
188 const SWvertex *vert0, const SWvertex *vert1 )
189 {
190 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
191 const GLubyte *color = vert0->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 */
210 static void flat_5R6G5B_line( GLcontext *ctx,
211 const SWvertex *vert0, const SWvertex *vert1 )
212 {
213 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
214 const GLubyte *color = vert0->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 */
230 static 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 = vert0->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 */
250 static void flat_DITHER8_line( GLcontext *ctx,
251 const SWvertex *vert0, const SWvertex *vert1 )
252 {
253 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
254 const GLubyte *color = vert0->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 */
272 static void flat_LOOKUP8_line( GLcontext *ctx,
273 const SWvertex *vert0, const SWvertex *vert1 )
274 {
275 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
276 const GLubyte *color = vert0->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 */
294 static void flat_HPCR_line( GLcontext *ctx,
295 const SWvertex *vert0, const SWvertex *vert1 )
296 {
297 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
298 const GLubyte *color = vert0->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 */
316 static 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 = vert0->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 */
342 static 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 = vert0->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 */
368 static 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 = vert0->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 */
394 static 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 = vert0->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 */
421 static 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 = vert0->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 */
446 static 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 = vert0->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 */
470 static 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 = vert0->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 */
497 static 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 = vert0->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 */
525 static 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 = vert0->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
549 static 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._ReallyEnabled) 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
564 if (xmesa->xm_buffer->buffer==XIMAGE
565 && swrast->_RasterMask==DEPTH_BIT
566 && ctx->Depth.Func==GL_LESS
567 && ctx->Depth.Mask==GL_TRUE
568 && ctx->Visual.DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS
569 && ctx->Line.Width==1.0F) {
570 switch (xmesa->pixelformat) {
571 case PF_TRUECOLOR:
572 return flat_TRUECOLOR_z_line;
573 case PF_8A8B8G8R:
574 return flat_8A8B8G8R_z_line;
575 case PF_8R8G8B:
576 return flat_8R8G8B_z_line;
577 case PF_8R8G8B24:
578 return flat_8R8G8B24_z_line;
579 case PF_5R6G5B:
580 return flat_5R6G5B_z_line;
581 case PF_DITHER_5R6G5B:
582 return flat_DITHER_5R6G5B_z_line;
583 case PF_DITHER:
584 return (depth==8) ? flat_DITHER8_z_line : (swrast_line_func) NULL;
585 case PF_LOOKUP:
586 return (depth==8) ? flat_LOOKUP8_z_line : (swrast_line_func) NULL;
587 case PF_HPCR:
588 return flat_HPCR_z_line;
589 default:
590 return (swrast_line_func)NULL;
591 }
592 }
593 if (xmesa->xm_buffer->buffer==XIMAGE
594 && swrast->_RasterMask==0
595 && ctx->Line.Width==1.0F) {
596 switch (xmesa->pixelformat) {
597 case PF_TRUECOLOR:
598 return flat_TRUECOLOR_line;
599 case PF_8A8B8G8R:
600 return flat_8A8B8G8R_line;
601 case PF_8R8G8B:
602 return flat_8R8G8B_line;
603 case PF_8R8G8B24:
604 return flat_8R8G8B24_line;
605 case PF_5R6G5B:
606 return flat_5R6G5B_line;
607 case PF_DITHER_5R6G5B:
608 return flat_DITHER_5R6G5B_line;
609 case PF_DITHER:
610 return (depth==8) ? flat_DITHER8_line : (swrast_line_func) NULL;
611 case PF_LOOKUP:
612 return (depth==8) ? flat_LOOKUP8_line : (swrast_line_func) NULL;
613 case PF_HPCR:
614 return flat_HPCR_line;
615 default:
616 return (swrast_line_func)NULL;
617 }
618 }
619
620 return (swrast_line_func) NULL;
621 }
622
623 /* Override for the swrast line-selection function. Try to use one
624 * of our internal line functions, otherwise fall back to the
625 * standard swrast functions.
626 */
627 void xmesa_choose_line( GLcontext *ctx )
628 {
629 SWcontext *swrast = SWRAST_CONTEXT(ctx);
630
631 if (!(swrast->Line = get_line_func( ctx )))
632 _swrast_choose_line( ctx );
633 }
634
635
636 #define XMESA_NEW_POINT (_NEW_POINT | \
637 _NEW_RENDERMODE | \
638 _SWRAST_NEW_RASTERMASK)
639
640 #define XMESA_NEW_LINE (_NEW_LINE | \
641 _NEW_TEXTURE | \
642 _NEW_LIGHT | \
643 _NEW_DEPTH | \
644 _NEW_RENDERMODE | \
645 _SWRAST_NEW_RASTERMASK)
646
647 #define XMESA_NEW_TRIANGLE (_NEW_POLYGON | \
648 _NEW_TEXTURE | \
649 _NEW_LIGHT | \
650 _NEW_DEPTH | \
651 _NEW_RENDERMODE | \
652 _SWRAST_NEW_RASTERMASK)
653
654
655 /* Extend the software rasterizer with our line/point/triangle
656 * functions.
657 */
658 void xmesa_register_swrast_functions( GLcontext *ctx )
659 {
660 SWcontext *swrast = SWRAST_CONTEXT( ctx );
661
662 swrast->choose_point = xmesa_choose_point;
663 swrast->choose_line = xmesa_choose_line;
664 swrast->choose_triangle = xmesa_choose_triangle;
665
666 swrast->invalidate_point |= XMESA_NEW_POINT;
667 swrast->invalidate_line |= XMESA_NEW_LINE;
668 swrast->invalidate_triangle |= XMESA_NEW_TRIANGLE;
669 }