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