2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
24 /* $XFree86: xc/extras/Mesa/src/X/xm_span.c,v 1.3 2002/02/27 21:07:54 tsi Exp $ */
26 #include "glxheader.h"
31 #include "extensions.h"
38 #include "swrast/swrast.h"
42 * The following functions are used to trap XGetImage() calls which
43 * generate BadMatch errors if the drawable isn't mapped.
47 static int caught_xgetimage_error
= 0;
48 static int (*old_xerror_handler
)( XMesaDisplay
*dpy
, XErrorEvent
*ev
);
49 static unsigned long xgetimage_serial
;
52 * This is the error handler which will be called if XGetImage fails.
54 static int xgetimage_error_handler( XMesaDisplay
*dpy
, XErrorEvent
*ev
)
56 if (ev
->serial
==xgetimage_serial
&& ev
->error_code
==BadMatch
) {
57 /* caught the expected error */
58 caught_xgetimage_error
= 0;
61 /* call the original X error handler, if any. otherwise ignore */
62 if (old_xerror_handler
) {
63 (*old_xerror_handler
)( dpy
, ev
);
71 * Call this right before XGetImage to setup error trap.
73 static void catch_xgetimage_errors( XMesaDisplay
*dpy
)
75 xgetimage_serial
= NextRequest( dpy
);
76 old_xerror_handler
= XSetErrorHandler( xgetimage_error_handler
);
77 caught_xgetimage_error
= 0;
82 * Call this right after XGetImage to check if an error occured.
84 static int check_xgetimage_errors( void )
86 /* restore old handler */
87 (void) XSetErrorHandler( old_xerror_handler
);
88 /* return 0=no error, 1=error caught */
89 return caught_xgetimage_error
;
95 * Read a pixel from an X drawable.
97 static unsigned long read_pixel( XMesaDisplay
*dpy
,
98 XMesaDrawable d
, int x
, int y
)
101 #ifndef XFree86Server
102 XMesaImage
*pixel
= NULL
;
105 catch_xgetimage_errors( dpy
);
106 pixel
= XGetImage( dpy
, d
, x
, y
, 1, 1, AllPlanes
, ZPixmap
);
107 error
= check_xgetimage_errors();
108 if (pixel
&& !error
) {
109 p
= XMesaGetPixel( pixel
, 0, 0 );
115 XMesaDestroyImage( pixel
);
118 (*dpy
->GetImage
)(d
, x
, y
, 1, 1, ZPixmap
, ~0L, (pointer
)&p
);
126 * The Mesa library needs to be able to draw pixels in a number of ways:
127 * 1. RGB vs Color Index
128 * 2. as horizontal spans (polygons, images) vs random locations (points,
130 * 3. different color per-pixel or same color for all pixels
132 * Furthermore, the X driver needs to support rendering to 3 possible
133 * "buffers", usually one, but sometimes two at a time:
134 * 1. The front buffer as an X window
135 * 2. The back buffer as a Pixmap
136 * 3. The back buffer as an XImage
138 * Finally, if the back buffer is an XImage, we can avoid using XPutPixel and
139 * optimize common cases such as 24-bit and 8-bit modes.
141 * By multiplication, there's at least 48 possible combinations of the above.
143 * Below are implementations of the most commonly used combinations. They are
144 * accessed through function pointers which get initialized here and are used
145 * directly from the Mesa library. The 8 function pointers directly correspond
146 * to the first 3 cases listed above.
149 * The function naming convention is:
151 * write_[span|pixels]_[mono]_[format]_[pixmap|ximage]
153 * New functions optimized for specific cases can be added without too much
154 * trouble. An example might be the 24-bit TrueColor mode 8A8R8G8B which is
155 * found on IBM RS/6000 X servers.
161 /**********************************************************************/
162 /*** Write COLOR SPAN functions ***/
163 /**********************************************************************/
166 #define RGBA_SPAN_ARGS const GLcontext *ctx, \
167 GLuint n, GLint x, GLint y, \
168 CONST GLubyte rgba[][4], const GLubyte mask[]
170 #define RGB_SPAN_ARGS const GLcontext *ctx, \
171 GLuint n, GLint x, GLint y, \
172 CONST GLubyte rgb[][3], const GLubyte mask[]
175 /* NOTE: if mask==NULL, draw all pixels */
179 * Write a span of PF_TRUECOLOR pixels to a pixmap.
181 static void write_span_TRUECOLOR_pixmap( RGBA_SPAN_ARGS
)
183 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
184 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
185 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
186 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
189 y
= FLIP(xmesa
->xm_buffer
, y
);
191 for (i
=0;i
<n
;i
++,x
++) {
194 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
195 XMesaSetForeground( dpy
, gc
, p
);
196 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
201 /* draw all pixels */
202 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
205 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
206 XMesaPutPixel( rowimg
, i
, 0, p
);
208 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
214 * Write a span of PF_TRUECOLOR pixels to a pixmap.
216 static void write_span_rgb_TRUECOLOR_pixmap( RGB_SPAN_ARGS
)
218 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
219 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
220 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
221 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
223 y
= FLIP(xmesa
->xm_buffer
, y
);
225 for (i
=0;i
<n
;i
++,x
++) {
228 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
229 XMesaSetForeground( dpy
, gc
, p
);
230 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
235 /* draw all pixels */
236 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
239 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
240 XMesaPutPixel( rowimg
, i
, 0, p
);
242 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
248 * Write a span of PF_TRUEDITHER pixels to a pixmap.
250 static void write_span_TRUEDITHER_pixmap( RGBA_SPAN_ARGS
)
252 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
253 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
254 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
255 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
257 y
= FLIP(xmesa
->xm_buffer
, y
);
259 for (i
=0;i
<n
;i
++,x
++) {
262 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
263 XMesaSetForeground( dpy
, gc
, p
);
264 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
269 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
272 PACK_TRUEDITHER(p
, x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
273 XMesaPutPixel( rowimg
, i
, 0, p
);
275 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
281 * Write a span of PF_TRUEDITHER pixels to a pixmap (no alpha).
283 static void write_span_rgb_TRUEDITHER_pixmap( RGB_SPAN_ARGS
)
285 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
286 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
287 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
288 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
290 y
= FLIP(xmesa
->xm_buffer
, y
);
292 for (i
=0;i
<n
;i
++,x
++) {
295 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
296 XMesaSetForeground( dpy
, gc
, p
);
297 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
302 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
305 PACK_TRUEDITHER(p
, x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
306 XMesaPutPixel( rowimg
, i
, 0, p
);
308 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
315 * Write a span of PF_8A8B8G8R pixels to a pixmap.
317 static void write_span_8A8B8G8R_pixmap( RGBA_SPAN_ARGS
)
319 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
320 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
321 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
322 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
324 y
= FLIP(xmesa
->xm_buffer
, y
);
326 for (i
=0;i
<n
;i
++,x
++) {
328 XMesaSetForeground( dpy
, gc
,
329 PACK_8A8B8G8R(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
]) );
330 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
335 /* draw all pixels */
336 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
337 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
339 *ptr4
++ = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
341 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
347 * Write a span of PF_8A8B8G8R pixels to a pixmap (no alpha).
349 static void write_span_rgb_8A8B8G8R_pixmap( RGB_SPAN_ARGS
)
351 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
352 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
353 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
354 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
356 y
= FLIP(xmesa
->xm_buffer
, y
);
358 for (i
=0;i
<n
;i
++,x
++) {
360 XMesaSetForeground( dpy
, gc
,
361 PACK_8B8G8R(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
362 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
367 /* draw all pixels */
368 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
369 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
371 *ptr4
++ = PACK_8B8G8R(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
373 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
379 * Write a span of PF_8R8G8B pixels to a pixmap.
381 static void write_span_8R8G8B_pixmap( RGBA_SPAN_ARGS
)
383 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
384 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
385 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
386 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
388 y
= FLIP(xmesa
->xm_buffer
, y
);
390 for (i
=0;i
<n
;i
++,x
++) {
392 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
393 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
398 /* draw all pixels */
399 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
400 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
402 *ptr4
++ = PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
404 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
410 * Write a span of PF_8R8G8B24 pixels to a pixmap.
412 static void write_span_8R8G8B24_pixmap( RGBA_SPAN_ARGS
)
414 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
415 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
416 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
417 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
418 y
= FLIP(xmesa
->xm_buffer
, y
);
421 for (i
=0;i
<n
;i
++,x
++) {
423 XMesaSetForeground( dpy
, gc
,
424 PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
425 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
430 /* draw all pixels */
431 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
432 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
433 register GLuint pixel
;
434 static const GLuint shift
[4] = {0, 8, 16, 24};
435 register GLuint i
= 0;
438 pixel
= rgba
[i
][BCOMP
] /* << shift[0]*/;
439 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
440 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
441 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
444 pixel
= rgba
[i
][GCOMP
] /* << shift[0]*/;
445 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
446 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
447 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
450 pixel
= rgba
[i
++][RCOMP
]/* << shift[0]*/;
451 pixel
|= rgba
[i
][BCOMP
] << shift
[1];
452 pixel
|= rgba
[i
][GCOMP
] << shift
[2];
453 pixel
|= rgba
[i
++][RCOMP
] << shift
[3];
461 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
462 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
463 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
464 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
467 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
468 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
469 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
470 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
472 pixel
= 0xffffff00 & *ptr4
;
473 pixel
|= rgba
[i
][RCOMP
] /*<< shift[0]*/;
478 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
479 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
480 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
481 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
483 pixel
= 0xffff0000 & *ptr4
;
484 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
485 pixel
|= rgba
[i
][RCOMP
] << shift
[1];
489 pixel
= 0xff000000 & *ptr4
;
490 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
491 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
492 pixel
|= rgba
[i
][RCOMP
] << shift
[2];
498 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
504 * Write a span of PF_8R8G8B pixels to a pixmap (no alpha).
506 static void write_span_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS
)
508 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
509 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
510 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
511 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
513 y
= FLIP(xmesa
->xm_buffer
, y
);
515 for (i
=0;i
<n
;i
++,x
++) {
517 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
518 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
523 /* draw all pixels */
524 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
525 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
527 *ptr4
++ = PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
529 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
535 * Write a span of PF_8R8G8B24 pixels to a pixmap (no alpha).
537 static void write_span_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS
)
539 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
540 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
541 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
542 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
543 y
= FLIP(xmesa
->xm_buffer
, y
);
546 for (i
=0;i
<n
;i
++,x
++) {
548 XMesaSetForeground( dpy
, gc
,
549 PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
550 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
555 /* draw all pixels */
556 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
557 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
558 register GLuint pixel
;
559 static const GLuint shift
[4] = {0, 8, 16, 24};
561 register GLuint i
= 0;
564 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
565 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
566 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
567 pixel
|= rgb
[i
][BCOMP
] <<shift
[3];
571 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
572 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
573 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
574 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
578 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
579 pixel
|= rgb
[i
][BCOMP
] << shift
[1];
580 pixel
|= rgb
[i
][GCOMP
] << shift
[2];
581 pixel
|= rgb
[i
++][RCOMP
] << shift
[3];
588 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
589 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
590 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
591 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
594 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
595 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
596 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
597 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
601 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
606 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
607 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
608 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
609 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
613 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
614 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
620 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
621 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
622 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
628 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
634 * Write a span of PF_5R6G5B pixels to a pixmap.
636 static void write_span_5R6G5B_pixmap( RGBA_SPAN_ARGS
)
638 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
639 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
640 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
641 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
643 y
= FLIP(xmesa
->xm_buffer
, y
);
645 for (i
=0;i
<n
;i
++,x
++) {
647 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
648 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
653 /* draw all pixels */
654 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
655 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
657 ptr2
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
659 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
665 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap.
667 static void write_span_DITHER_5R6G5B_pixmap( RGBA_SPAN_ARGS
)
669 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
670 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
671 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
672 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
674 y
= FLIP(xmesa
->xm_buffer
, y
);
676 for (i
=0;i
<n
;i
++,x
++) {
679 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
680 XMesaSetForeground( dpy
, gc
, p
);
681 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
686 /* draw all pixels */
687 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
688 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
690 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
692 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
698 * Write a span of PF_5R6G5B pixels to a pixmap (no alpha).
700 static void write_span_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS
)
702 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
703 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
704 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
705 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
707 y
= FLIP(xmesa
->xm_buffer
, y
);
709 for (i
=0;i
<n
;i
++,x
++) {
711 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
712 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
717 /* draw all pixels */
718 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
719 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
721 ptr2
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
723 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
729 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap (no alpha).
731 static void write_span_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS
)
733 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
734 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
735 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
736 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
738 y
= FLIP(xmesa
->xm_buffer
, y
);
740 for (i
=0;i
<n
;i
++,x
++) {
743 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
744 XMesaSetForeground( dpy
, gc
, p
);
745 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
750 /* draw all pixels */
751 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
752 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
754 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
756 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
763 * Write a span of PF_DITHER pixels to a pixmap.
765 static void write_span_DITHER_pixmap( RGBA_SPAN_ARGS
)
767 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
768 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
769 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
770 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
773 y
= FLIP(xmesa
->xm_buffer
, y
);
775 for (i
=0;i
<n
;i
++,x
++) {
777 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
778 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
783 /* draw all pixels */
784 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
786 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
788 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
794 * Write a span of PF_DITHER pixels to a pixmap (no alpha).
796 static void write_span_rgb_DITHER_pixmap( RGB_SPAN_ARGS
)
798 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
799 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
800 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
801 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
804 y
= FLIP(xmesa
->xm_buffer
, y
);
806 for (i
=0;i
<n
;i
++,x
++) {
808 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
809 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
814 /* draw all pixels */
815 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
817 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
819 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
825 * Write a span of PF_1BIT pixels to a pixmap.
827 static void write_span_1BIT_pixmap( RGBA_SPAN_ARGS
)
829 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
830 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
831 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
832 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
835 y
= FLIP(xmesa
->xm_buffer
, y
);
837 for (i
=0;i
<n
;i
++,x
++) {
839 XMesaSetForeground( dpy
, gc
,
840 DITHER_1BIT( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
841 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
846 /* draw all pixels */
847 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
849 XMesaPutPixel( rowimg
, i
, 0,
850 DITHER_1BIT( x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
852 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
858 * Write a span of PF_1BIT pixels to a pixmap (no alpha).
860 static void write_span_rgb_1BIT_pixmap( RGB_SPAN_ARGS
)
862 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
863 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
864 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
865 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
868 y
= FLIP(xmesa
->xm_buffer
, y
);
870 for (i
=0;i
<n
;i
++,x
++) {
872 XMesaSetForeground( dpy
, gc
,
873 DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
874 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
879 /* draw all pixels */
880 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
882 XMesaPutPixel( rowimg
, i
, 0,
883 DITHER_1BIT(x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
885 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
891 * Write a span of PF_HPCR pixels to a pixmap.
893 static void write_span_HPCR_pixmap( RGBA_SPAN_ARGS
)
895 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
896 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
897 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
898 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
900 y
= FLIP(xmesa
->xm_buffer
, y
);
902 for (i
=0;i
<n
;i
++,x
++) {
904 XMesaSetForeground( dpy
, gc
,
905 DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
906 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
911 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
912 register GLubyte
*ptr
= (GLubyte
*) xmesa
->xm_buffer
->rowimage
->data
;
914 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
916 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
922 * Write a span of PF_HPCR pixels to a pixmap (no alpha).
924 static void write_span_rgb_HPCR_pixmap( RGB_SPAN_ARGS
)
926 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
927 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
928 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
929 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
931 y
= FLIP(xmesa
->xm_buffer
, y
);
933 for (i
=0;i
<n
;i
++,x
++) {
935 XMesaSetForeground( dpy
, gc
,
936 DITHER_HPCR(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
937 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
942 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
943 register GLubyte
*ptr
= (GLubyte
*) xmesa
->xm_buffer
->rowimage
->data
;
945 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
947 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
953 * Write a span of PF_LOOKUP pixels to a pixmap.
955 static void write_span_LOOKUP_pixmap( RGBA_SPAN_ARGS
)
957 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
958 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
959 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
960 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
963 y
= FLIP(xmesa
->xm_buffer
, y
);
965 for (i
=0;i
<n
;i
++,x
++) {
967 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
968 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
973 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
975 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
977 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
983 * Write a span of PF_LOOKUP pixels to a pixmap (no alpha).
985 static void write_span_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS
)
987 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
988 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
989 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
990 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
993 y
= FLIP(xmesa
->xm_buffer
, y
);
995 for (i
=0;i
<n
;i
++,x
++) {
997 XMesaSetForeground( dpy
, gc
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
998 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1003 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1005 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1007 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1014 * Write a span of PF_GRAYSCALE pixels to a pixmap.
1016 static void write_span_GRAYSCALE_pixmap( RGBA_SPAN_ARGS
)
1018 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1019 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1020 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
1021 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
1023 y
= FLIP(xmesa
->xm_buffer
, y
);
1025 for (i
=0;i
<n
;i
++,x
++) {
1027 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1028 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1033 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1035 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
1037 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1043 * Write a span of PF_GRAYSCALE pixels to a pixmap (no alpha).
1045 static void write_span_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS
)
1047 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1048 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1049 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
1050 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
1052 y
= FLIP(xmesa
->xm_buffer
, y
);
1054 for (i
=0;i
<n
;i
++,x
++) {
1056 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1057 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1062 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1064 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1066 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1072 * Write a span of PF_TRUECOLOR pixels to an XImage.
1074 static void write_span_TRUECOLOR_ximage( RGBA_SPAN_ARGS
)
1076 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1077 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1079 y
= FLIP(xmesa
->xm_buffer
, y
);
1081 for (i
=0;i
<n
;i
++,x
++) {
1084 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1085 XMesaPutPixel( img
, x
, y
, p
);
1090 /* draw all pixels */
1091 for (i
=0;i
<n
;i
++,x
++) {
1093 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1094 XMesaPutPixel( img
, x
, y
, p
);
1101 * Write a span of PF_TRUECOLOR pixels to an XImage (no alpha).
1103 static void write_span_rgb_TRUECOLOR_ximage( RGB_SPAN_ARGS
)
1105 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1106 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1108 y
= FLIP(xmesa
->xm_buffer
, y
);
1110 for (i
=0;i
<n
;i
++,x
++) {
1113 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1114 XMesaPutPixel( img
, x
, y
, p
);
1119 /* draw all pixels */
1120 for (i
=0;i
<n
;i
++,x
++) {
1122 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1123 XMesaPutPixel( img
, x
, y
, p
);
1130 * Write a span of PF_TRUEDITHER pixels to an XImage.
1132 static void write_span_TRUEDITHER_ximage( RGBA_SPAN_ARGS
)
1134 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1135 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1137 y
= FLIP(xmesa
->xm_buffer
, y
);
1139 for (i
=0;i
<n
;i
++,x
++) {
1142 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1143 XMesaPutPixel( img
, x
, y
, p
);
1148 /* draw all pixels */
1149 for (i
=0;i
<n
;i
++,x
++) {
1151 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1152 XMesaPutPixel( img
, x
, y
, p
);
1159 * Write a span of PF_TRUEDITHER pixels to an XImage (no alpha).
1161 static void write_span_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS
)
1163 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1164 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1166 y
= FLIP(xmesa
->xm_buffer
, y
);
1168 for (i
=0;i
<n
;i
++,x
++) {
1171 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1172 XMesaPutPixel( img
, x
, y
, p
);
1177 /* draw all pixels */
1178 for (i
=0;i
<n
;i
++,x
++) {
1180 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1181 XMesaPutPixel( img
, x
, y
, p
);
1188 * Write a span of PF_8A8B8G8R-format pixels to an ximage.
1190 static void write_span_8A8B8G8R_ximage( RGBA_SPAN_ARGS
)
1192 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1194 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1198 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1203 /* draw all pixels */
1205 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1212 * Write a span of PF_8A8B8G8R-format pixels to an ximage (no alpha).
1214 static void write_span_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS
)
1216 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1218 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1222 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1227 /* draw all pixels */
1229 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1236 * Write a span of PF_8R8G8B-format pixels to an ximage.
1238 static void write_span_8R8G8B_ximage( RGBA_SPAN_ARGS
)
1240 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1242 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1246 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1252 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1259 * Write a span of PF_8R8G8B24-format pixels to an ximage.
1261 static void write_span_8R8G8B24_ximage( RGBA_SPAN_ARGS
)
1263 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1265 register GLubyte
*ptr
= (GLubyte
*) PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
1269 GLuint
*ptr4
= (GLuint
*) ptr
;
1270 register GLuint pixel
= *ptr4
;
1271 switch (3 & (int)(ptr
- (GLubyte
*)ptr4
)) {
1273 pixel
&= 0xff000000;
1274 pixel
|= rgba
[i
][BCOMP
];
1275 pixel
|= rgba
[i
][GCOMP
] << 8;
1276 pixel
|= rgba
[i
][RCOMP
] << 16;
1280 pixel
&= 0x00ffffff;
1281 pixel
|= rgba
[i
][BCOMP
] << 24;
1283 pixel
= *ptr4
&& 0xffff0000;
1284 pixel
|= rgba
[i
][GCOMP
];
1285 pixel
|= rgba
[i
][RCOMP
] << 8;
1289 pixel
&= 0x0000ffff;
1290 pixel
|= rgba
[i
][BCOMP
] << 16;
1291 pixel
|= rgba
[i
][GCOMP
] << 24;
1293 pixel
= *ptr4
&& 0xffffff00;
1294 pixel
|= rgba
[i
][RCOMP
];
1298 pixel
&= 0x000000ff;
1299 pixel
|= rgba
[i
][BCOMP
] << 8;
1300 pixel
|= rgba
[i
][GCOMP
] << 16;
1301 pixel
|= rgba
[i
][RCOMP
] << 24;
1310 /* write all pixels */
1312 GLuint
*ptr4
= (GLuint
*) ptr
;
1313 register GLuint pixel
= *ptr4
;
1314 int index
= (int)(ptr
- (GLubyte
*)ptr4
);
1315 register GLuint i
= 0;
1320 pixel
&= 0x00ffffff;
1321 pixel
|= rgba
[i
][BCOMP
] << 24;
1323 pixel
= *ptr4
&& 0xffff0000;
1324 pixel
|= rgba
[i
][GCOMP
];
1325 pixel
|= rgba
[i
++][RCOMP
] << 8;
1330 pixel
&= 0x0000ffff;
1331 pixel
|= rgba
[i
][BCOMP
] << 16;
1332 pixel
|= rgba
[i
][GCOMP
] << 24;
1334 pixel
= *ptr4
&& 0xffffff00;
1335 pixel
|= rgba
[i
++][RCOMP
];
1340 pixel
&= 0x000000ff;
1341 pixel
|= rgba
[i
][BCOMP
] << 8;
1342 pixel
|= rgba
[i
][GCOMP
] << 16;
1343 pixel
|= rgba
[i
++][RCOMP
] << 24;
1350 pixel
= rgba
[i
][BCOMP
];
1351 pixel
|= rgba
[i
][GCOMP
] << 8;
1352 pixel
|= rgba
[i
++][RCOMP
] << 16;
1353 pixel
|= rgba
[i
][BCOMP
] << 24;
1355 pixel
= rgba
[i
][GCOMP
];
1356 pixel
|= rgba
[i
++][RCOMP
] << 8;
1357 pixel
|= rgba
[i
][BCOMP
] << 16;
1358 pixel
|= rgba
[i
][GCOMP
] << 24;
1360 pixel
= rgba
[i
++][RCOMP
];
1361 pixel
|= rgba
[i
][BCOMP
] << 8;
1362 pixel
|= rgba
[i
][GCOMP
] << 16;
1363 pixel
|= rgba
[i
++][RCOMP
] << 24;
1371 pixel
= *ptr4
& 0xff000000;
1372 pixel
|= rgba
[i
][BCOMP
];
1373 pixel
|= rgba
[i
][GCOMP
] << 8;
1374 pixel
|= rgba
[i
][RCOMP
] << 16;
1378 pixel
= rgba
[i
][BCOMP
];
1379 pixel
|= rgba
[i
][GCOMP
] << 8;
1380 pixel
|= rgba
[i
++][RCOMP
] << 16;
1381 pixel
|= rgba
[i
][BCOMP
] << 24;
1383 pixel
= *ptr4
& 0xffff0000;
1384 pixel
|= rgba
[i
][GCOMP
];
1385 pixel
|= rgba
[i
][RCOMP
] << 8;
1389 pixel
= rgba
[i
][BCOMP
];
1390 pixel
|= rgba
[i
][GCOMP
] << 8;
1391 pixel
|= rgba
[i
++][RCOMP
] << 16;
1392 pixel
|= rgba
[i
][BCOMP
] << 24;
1394 pixel
= rgba
[i
][GCOMP
];
1395 pixel
|= rgba
[i
++][RCOMP
] << 8;
1396 pixel
|= rgba
[i
][BCOMP
] << 16;
1397 pixel
|= rgba
[i
][GCOMP
] << 24;
1399 pixel
= *ptr4
& 0xffffff00;
1400 pixel
|= rgba
[i
][RCOMP
];
1409 * Write a span of PF_8R8G8B-format pixels to an ximage (no alpha).
1411 static void write_span_rgb_8R8G8B_ximage( RGB_SPAN_ARGS
)
1413 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1415 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1419 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1424 /* draw all pixels */
1426 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1433 * Write a span of PF_8R8G8B24-format pixels to an ximage (no alpha).
1435 static void write_span_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS
)
1437 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1439 register GLubyte
*ptr
= (GLubyte
*) PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
1443 *ptr
++ = rgb
[i
][BCOMP
];
1444 *ptr
++ = rgb
[i
][GCOMP
];
1445 *ptr
++ = rgb
[i
][RCOMP
];
1453 /* draw all pixels */
1455 *ptr
++ = rgb
[i
][BCOMP
];
1456 *ptr
++ = rgb
[i
][GCOMP
];
1457 *ptr
++ = rgb
[i
][RCOMP
];
1464 * Write a span of PF_5R6G5B-format pixels to an ximage.
1466 static void write_span_5R6G5B_ximage( RGBA_SPAN_ARGS
)
1468 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1470 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1474 ptr
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1479 /* draw all pixels */
1480 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1481 GLuint
*ptr32
= (GLuint
*) ptr
;
1482 GLuint extraPixel
= (n
& 1);
1484 for (i
= 0; i
< n
; i
+= 2) {
1486 p0
= PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1487 p1
= PACK_5R6G5B(rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
]);
1488 *ptr32
++ = (p1
<< 16) | p0
;
1491 ptr
[n
] = PACK_5R6G5B(rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1494 for (i
= 0; i
< n
; i
++) {
1495 ptr
[i
] = PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1503 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage.
1505 static void write_span_DITHER_5R6G5B_ximage( RGBA_SPAN_ARGS
)
1507 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1509 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1510 const GLint y2
= FLIP(xmesa
->xm_buffer
, y
);
1512 for (i
=0;i
<n
;i
++,x
++) {
1514 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1519 /* draw all pixels */
1520 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1521 GLuint
*ptr32
= (GLuint
*) ptr
;
1522 GLuint extraPixel
= (n
& 1);
1524 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1526 PACK_TRUEDITHER( p0
, x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1527 PACK_TRUEDITHER( p1
, x
+1, y2
, rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
] );
1528 *ptr32
++ = (p1
<< 16) | p0
;
1531 PACK_TRUEDITHER( ptr
[n
], x
+n
, y2
, rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1534 for (i
= 0; i
< n
; i
++, x
++) {
1535 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1543 * Write a span of PF_5R6G5B-format pixels to an ximage (no alpha).
1545 static void write_span_rgb_5R6G5B_ximage( RGB_SPAN_ARGS
)
1547 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1549 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1553 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1558 /* draw all pixels */
1559 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1560 GLuint
*ptr32
= (GLuint
*) ptr
;
1561 GLuint extraPixel
= (n
& 1);
1563 for (i
= 0; i
< n
; i
+= 2) {
1565 p0
= PACK_5R6G5B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1566 p1
= PACK_5R6G5B(rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
]);
1567 *ptr32
++ = (p1
<< 16) | p0
;
1570 ptr
[n
] = PACK_5R6G5B(rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1574 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1582 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage (no alpha).
1584 static void write_span_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS
)
1586 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1588 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1590 for (i
=0;i
<n
;i
++,x
++) {
1592 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1597 /* draw all pixels */
1598 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1599 GLuint
*ptr32
= (GLuint
*) ptr
;
1600 GLuint extraPixel
= (n
& 1);
1602 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1604 PACK_TRUEDITHER( p0
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1605 PACK_TRUEDITHER( p1
, x
+1, y
, rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
] );
1606 *ptr32
++ = (p1
<< 16) | p0
;
1609 PACK_TRUEDITHER( ptr
[n
], x
+n
, y
, rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1612 for (i
=0;i
<n
;i
++,x
++) {
1613 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1621 * Write a span of PF_DITHER pixels to an XImage.
1623 static void write_span_DITHER_ximage( RGBA_SPAN_ARGS
)
1625 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1626 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1628 int yy
= FLIP(xmesa
->xm_buffer
, y
);
1631 for (i
=0;i
<n
;i
++,x
++) {
1633 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1638 /* draw all pixels */
1639 for (i
=0;i
<n
;i
++,x
++) {
1640 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1647 * Write a span of PF_DITHER pixels to an XImage (no alpha).
1649 static void write_span_rgb_DITHER_ximage( RGB_SPAN_ARGS
)
1651 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1652 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1654 int yy
= FLIP(xmesa
->xm_buffer
, y
);
1657 for (i
=0;i
<n
;i
++,x
++) {
1659 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1664 /* draw all pixels */
1665 for (i
=0;i
<n
;i
++,x
++) {
1666 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1674 * Write a span of 8-bit PF_DITHER pixels to an XImage.
1676 static void write_span_DITHER8_ximage( RGBA_SPAN_ARGS
)
1678 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1680 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1683 for (i
=0;i
<n
;i
++,x
++) {
1685 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1690 for (i
=0;i
<n
;i
++,x
++) {
1691 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1697 static void write_span_rgb_DITHER8_ximage( RGB_SPAN_ARGS
)
1699 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1701 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1704 for (i
=0;i
<n
;i
++,x
++) {
1706 ptr
[i
] = (GLubyte
) XDITHER( x
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
1711 const GLubyte
*data
= (GLubyte
*) rgb
;
1712 for (i
=0;i
<n
;i
++,x
++) {
1713 /*ptr[i] = XDITHER( x, rgb[i][0], rgb[i][1], rgb[i][2] );*/
1714 ptr
[i
] = (GLubyte
) XDITHER( x
, data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
1722 * Write a span of PF_1BIT pixels to an XImage.
1724 static void write_span_1BIT_ximage( RGBA_SPAN_ARGS
)
1726 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1727 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1730 y
= FLIP(xmesa
->xm_buffer
, y
);
1732 for (i
=0;i
<n
;i
++,x
++) {
1734 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]));
1739 for (i
=0;i
<n
;i
++,x
++) {
1740 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
1747 * Write a span of PF_1BIT pixels to an XImage (no alpha).
1749 static void write_span_rgb_1BIT_ximage( RGB_SPAN_ARGS
)
1751 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1752 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1755 y
= FLIP(xmesa
->xm_buffer
, y
);
1757 for (i
=0;i
<n
;i
++,x
++) {
1759 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]));
1764 for (i
=0;i
<n
;i
++,x
++) {
1765 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
1772 * Write a span of PF_HPCR pixels to an XImage.
1774 static void write_span_HPCR_ximage( RGBA_SPAN_ARGS
)
1776 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1778 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1780 for (i
=0;i
<n
;i
++,x
++) {
1782 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1787 /* draw all pixels */
1788 for (i
=0;i
<n
;i
++,x
++) {
1789 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1796 * Write a span of PF_HPCR pixels to an XImage (no alpha).
1798 static void write_span_rgb_HPCR_ximage( RGB_SPAN_ARGS
)
1800 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1802 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1804 for (i
=0;i
<n
;i
++,x
++) {
1806 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1811 /* draw all pixels */
1812 for (i
=0;i
<n
;i
++,x
++) {
1813 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1820 * Write a span of PF_LOOKUP pixels to an XImage.
1822 static void write_span_LOOKUP_ximage( RGBA_SPAN_ARGS
)
1824 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1825 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1828 y
= FLIP(xmesa
->xm_buffer
, y
);
1830 for (i
=0;i
<n
;i
++,x
++) {
1832 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1837 /* draw all pixels */
1838 for (i
=0;i
<n
;i
++,x
++) {
1839 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1846 * Write a span of PF_LOOKUP pixels to an XImage (no alpha).
1848 static void write_span_rgb_LOOKUP_ximage( RGB_SPAN_ARGS
)
1850 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1851 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1854 y
= FLIP(xmesa
->xm_buffer
, y
);
1856 for (i
=0;i
<n
;i
++,x
++) {
1858 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1863 /* draw all pixels */
1864 for (i
=0;i
<n
;i
++,x
++) {
1865 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1872 * Write a span of 8-bit PF_LOOKUP pixels to an XImage.
1874 static void write_span_LOOKUP8_ximage( RGBA_SPAN_ARGS
)
1876 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1878 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1881 for (i
=0;i
<n
;i
++,x
++) {
1883 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1888 /* draw all pixels */
1889 for (i
=0;i
<n
;i
++,x
++) {
1890 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1896 static void write_rgb_LOOKUP8_ximage( const GLcontext
*ctx
,
1897 GLuint n
, GLint x
, GLint y
,
1898 CONST GLubyte rgb
[][3],
1899 const GLubyte mask
[] )
1901 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1903 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1906 for (i
=0;i
<n
;i
++,x
++) {
1908 ptr
[i
] = (GLubyte
) LOOKUP( rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
1913 /* draw all pixels */
1914 const GLubyte
*data
= (GLubyte
*) rgb
;
1915 for (i
=0;i
<n
;i
++,x
++) {
1916 /*ptr[i] = LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );*/
1917 ptr
[i
] = (GLubyte
) LOOKUP( data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
1924 * Write a span of PF_GRAYSCALE pixels to an XImage.
1926 static void write_span_GRAYSCALE_ximage( RGBA_SPAN_ARGS
)
1928 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1929 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1931 y
= FLIP(xmesa
->xm_buffer
, y
);
1933 for (i
=0;i
<n
;i
++,x
++) {
1935 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1940 /* draw all pixels */
1941 for (i
=0;i
<n
;i
++,x
++) {
1942 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1949 * Write a span of PF_GRAYSCALE pixels to an XImage (no alpha).
1951 static void write_span_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS
)
1953 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1954 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1956 y
= FLIP(xmesa
->xm_buffer
, y
);
1958 for (i
=0;i
<n
;i
++,x
++) {
1960 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1965 /* draw all pixels */
1966 for (i
=0;i
<n
;i
++,x
++) {
1967 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1974 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage.
1976 static void write_span_GRAYSCALE8_ximage( RGBA_SPAN_ARGS
)
1978 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1980 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1984 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1989 /* draw all pixels */
1991 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1998 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage (no alpha).
2000 static void write_span_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS
)
2002 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2004 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
2008 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2013 /* draw all pixels */
2015 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2023 /**********************************************************************/
2024 /*** Write COLOR PIXEL functions ***/
2025 /**********************************************************************/
2028 #define RGBA_PIXEL_ARGS const GLcontext *ctx, \
2029 GLuint n, const GLint x[], const GLint y[], \
2030 CONST GLubyte rgba[][4], const GLubyte mask[]
2034 * Write an array of PF_TRUECOLOR pixels to a pixmap.
2036 static void write_pixels_TRUECOLOR_pixmap( RGBA_PIXEL_ARGS
)
2038 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2039 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2040 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2041 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2046 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2047 XMesaSetForeground( dpy
, gc
, p
);
2048 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2055 * Write an array of PF_TRUEDITHER pixels to a pixmap.
2057 static void write_pixels_TRUEDITHER_pixmap( RGBA_PIXEL_ARGS
)
2059 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2060 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2061 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2062 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2067 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2068 XMesaSetForeground( dpy
, gc
, p
);
2069 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2076 * Write an array of PF_8A8B8G8R pixels to a pixmap.
2078 static void write_pixels_8A8B8G8R_pixmap( RGBA_PIXEL_ARGS
)
2080 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2081 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2082 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2083 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2087 XMesaSetForeground( dpy
, gc
,
2088 PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] ));
2089 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2096 * Write an array of PF_8R8G8B pixels to a pixmap.
2098 static void write_pixels_8R8G8B_pixmap( RGBA_PIXEL_ARGS
)
2100 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2101 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2102 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2103 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2107 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2108 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2115 * Write an array of PF_8R8G8B24 pixels to a pixmap.
2117 static void write_pixels_8R8G8B24_pixmap( RGBA_PIXEL_ARGS
)
2119 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2120 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2121 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2122 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2126 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2127 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2134 * Write an array of PF_5R6G5B pixels to a pixmap.
2136 static void write_pixels_5R6G5B_pixmap( RGBA_PIXEL_ARGS
)
2138 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2139 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2140 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2141 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2145 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2146 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2153 * Write an array of PF_DITHER_5R6G5B pixels to a pixmap.
2155 static void write_pixels_DITHER_5R6G5B_pixmap( RGBA_PIXEL_ARGS
)
2157 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2158 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2159 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2160 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2165 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2166 XMesaSetForeground( dpy
, gc
, p
);
2167 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2174 * Write an array of PF_DITHER pixels to a pixmap.
2176 static void write_pixels_DITHER_pixmap( RGBA_PIXEL_ARGS
)
2178 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2179 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2180 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2181 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2186 XMesaSetForeground( dpy
, gc
,
2187 DITHER(x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2188 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2195 * Write an array of PF_1BIT pixels to a pixmap.
2197 static void write_pixels_1BIT_pixmap( RGBA_PIXEL_ARGS
)
2199 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2200 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2201 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2202 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2207 XMesaSetForeground( dpy
, gc
,
2208 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2209 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2216 * Write an array of PF_HPCR pixels to a pixmap.
2218 static void write_pixels_HPCR_pixmap( RGBA_PIXEL_ARGS
)
2220 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2221 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2222 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2223 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2227 XMesaSetForeground( dpy
, gc
,
2228 DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2229 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2236 * Write an array of PF_LOOKUP pixels to a pixmap.
2238 static void write_pixels_LOOKUP_pixmap( RGBA_PIXEL_ARGS
)
2240 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2241 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2242 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2243 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2248 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2249 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2256 * Write an array of PF_GRAYSCALE pixels to a pixmap.
2258 static void write_pixels_GRAYSCALE_pixmap( RGBA_PIXEL_ARGS
)
2260 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2261 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2262 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2263 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2267 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2268 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2275 * Write an array of PF_TRUECOLOR pixels to an ximage.
2277 static void write_pixels_TRUECOLOR_ximage( RGBA_PIXEL_ARGS
)
2279 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2280 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2285 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2286 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
2293 * Write an array of PF_TRUEDITHER pixels to an XImage.
2295 static void write_pixels_TRUEDITHER_ximage( RGBA_PIXEL_ARGS
)
2297 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2298 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2303 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2304 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
2311 * Write an array of PF_8A8B8G8R pixels to an ximage.
2313 static void write_pixels_8A8B8G8R_ximage( RGBA_PIXEL_ARGS
)
2315 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2319 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2320 *ptr
= PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
2327 * Write an array of PF_8R8G8B pixels to an ximage.
2329 static void write_pixels_8R8G8B_ximage( RGBA_PIXEL_ARGS
)
2331 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2335 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2336 *ptr
= PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2343 * Write an array of PF_8R8G8B24 pixels to an ximage.
2345 static void write_pixels_8R8G8B24_ximage( RGBA_PIXEL_ARGS
)
2347 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2351 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2352 ptr
->r
= rgba
[i
][RCOMP
];
2353 ptr
->g
= rgba
[i
][GCOMP
];
2354 ptr
->b
= rgba
[i
][BCOMP
];
2361 * Write an array of PF_5R6G5B pixels to an ximage.
2363 static void write_pixels_5R6G5B_ximage( RGBA_PIXEL_ARGS
)
2365 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2369 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2370 *ptr
= PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2377 * Write an array of PF_DITHER_5R6G5B pixels to an ximage.
2379 static void write_pixels_DITHER_5R6G5B_ximage( RGBA_PIXEL_ARGS
)
2381 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2385 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2386 PACK_TRUEDITHER( *ptr
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2393 * Write an array of PF_DITHER pixels to an XImage.
2395 static void write_pixels_DITHER_ximage( RGBA_PIXEL_ARGS
)
2397 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2398 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2403 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2404 DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2411 * Write an array of 8-bit PF_DITHER pixels to an XImage.
2413 static void write_pixels_DITHER8_ximage( RGBA_PIXEL_ARGS
)
2415 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2420 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2421 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2428 * Write an array of PF_1BIT pixels to an XImage.
2430 static void write_pixels_1BIT_ximage( RGBA_PIXEL_ARGS
)
2432 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2433 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2438 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2439 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2446 * Write an array of PF_HPCR pixels to an XImage.
2448 static void write_pixels_HPCR_ximage( RGBA_PIXEL_ARGS
)
2450 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2454 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2455 *ptr
= (GLubyte
) DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2462 * Write an array of PF_LOOKUP pixels to an XImage.
2464 static void write_pixels_LOOKUP_ximage( RGBA_PIXEL_ARGS
)
2466 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2467 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2472 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), LOOKUP(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2479 * Write an array of 8-bit PF_LOOKUP pixels to an XImage.
2481 static void write_pixels_LOOKUP8_ximage( RGBA_PIXEL_ARGS
)
2483 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2488 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2489 *ptr
= (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2496 * Write an array of PF_GRAYSCALE pixels to an XImage.
2498 static void write_pixels_GRAYSCALE_ximage( RGBA_PIXEL_ARGS
)
2500 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2501 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2505 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2506 GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2513 * Write an array of 8-bit PF_GRAYSCALE pixels to an XImage.
2515 static void write_pixels_GRAYSCALE8_ximage( RGBA_PIXEL_ARGS
)
2517 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2521 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2522 *ptr
= (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2530 /**********************************************************************/
2531 /*** Write MONO COLOR SPAN functions ***/
2532 /**********************************************************************/
2534 #define MONO_SPAN_ARGS const GLcontext *ctx, \
2535 GLuint n, GLint x, GLint y, const GLchan color[4], \
2536 const GLubyte mask[]
2540 * Write a span of identical pixels to a pixmap.
2542 static void write_span_mono_pixmap( MONO_SPAN_ARGS
)
2544 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2545 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2546 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2547 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2548 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2549 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2551 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
2552 y
= FLIP(xmesa
->xm_buffer
, y
);
2554 /* New code contributed by Jeff Epler and cleaned up by Keith
2557 for (i
= 0; i
< n
; ) {
2560 /* Identify and emit contiguous rendered pixels
2562 while (i
< n
&& (!mask
|| mask
[i
]))
2566 XMesaFillRectangle( dpy
, buffer
, gc
,
2567 (int)(x
+start
), (int) y
,
2570 /* Eat up non-rendered pixels
2572 while (i
< n
&& !mask
[i
])
2579 static void write_span_mono_index_pixmap( const GLcontext
*ctx
, GLuint n
,
2580 GLint x
, GLint y
, GLuint colorIndex
,
2581 const GLubyte mask
[] )
2583 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2584 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2585 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2586 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2588 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
2589 y
= FLIP(xmesa
->xm_buffer
, y
);
2591 for (i
= 0 ; i
< n
;) {
2594 /* Identify and emit contiguous rendered pixels
2596 while (i
< n
&& mask
[i
])
2600 XMesaFillRectangle( dpy
, buffer
, gc
,
2601 (int)(x
+start
), (int) y
,
2604 /* Eat up non-rendered pixels
2606 while (i
< n
&& !mask
[i
])
2614 * Write a span of PF_TRUEDITHER pixels to a pixmap.
2616 static void write_span_mono_TRUEDITHER_pixmap( MONO_SPAN_ARGS
)
2618 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2619 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2620 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2621 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2622 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2624 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2625 for (i
=0;i
<n
;i
++,x
++) {
2628 PACK_TRUEDITHER(p
, x
, yy
, r
, g
, b
);
2629 XMesaSetForeground( dpy
, gc
, p
);
2630 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2637 * Write a span of PF_DITHER pixels to a pixmap.
2639 static void write_span_mono_DITHER_pixmap( MONO_SPAN_ARGS
)
2641 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2642 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2643 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2644 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2645 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2647 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2649 for (i
=0;i
<n
;i
++,x
++) {
2651 XMesaSetForeground( dpy
, gc
, XDITHER( x
, r
, g
, b
) );
2652 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2659 * Write a span of PF_1BIT pixels to a pixmap.
2661 static void write_span_mono_1BIT_pixmap( MONO_SPAN_ARGS
)
2663 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2664 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2665 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2666 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2667 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2670 y
= FLIP(xmesa
->xm_buffer
, y
);
2671 for (i
=0;i
<n
;i
++,x
++) {
2673 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
, y
, r
, g
, b
) );
2674 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
2681 * Write a span of identical pixels to an XImage.
2683 static void write_span_mono_ximage( MONO_SPAN_ARGS
)
2685 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2686 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2688 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2689 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2690 y
= FLIP(xmesa
->xm_buffer
, y
);
2691 for (i
=0;i
<n
;i
++,x
++) {
2693 XMesaPutPixel( img
, x
, y
, pixel
);
2699 static void write_span_mono_index_ximage( const GLcontext
*ctx
, GLuint n
,
2702 const GLubyte mask
[] )
2704 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2705 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2707 y
= FLIP(xmesa
->xm_buffer
, y
);
2708 for (i
=0;i
<n
;i
++,x
++) {
2710 XMesaPutPixel( img
, x
, y
, colorIndex
);
2717 * Write a span of identical PF_TRUEDITHER pixels to an XImage.
2719 static void write_span_mono_TRUEDITHER_ximage( MONO_SPAN_ARGS
)
2721 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2722 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2723 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2725 y
= FLIP(xmesa
->xm_buffer
, y
);
2729 PACK_TRUEDITHER( p
, x
+i
, y
, r
, g
, b
);
2730 XMesaPutPixel( img
, x
+i
, y
, p
);
2737 * Write a span of identical 8A8B8G8R pixels to an XImage.
2739 static void write_span_mono_8A8B8G8R_ximage( MONO_SPAN_ARGS
)
2741 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2743 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2744 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2745 ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
2755 * Write a span of identical 8R8G8B pixels to an XImage.
2757 static void write_span_mono_8R8G8B_ximage( MONO_SPAN_ARGS
)
2759 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2760 const GLuint pixel
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2761 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
2764 if (!mask
|| mask
[i
]) {
2772 * Write a span of identical 8R8G8B pixels to an XImage.
2774 static void write_span_mono_8R8G8B24_ximage( MONO_SPAN_ARGS
)
2776 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2777 const GLubyte r
= color
[RCOMP
];
2778 const GLubyte g
= color
[GCOMP
];
2779 const GLubyte b
= color
[BCOMP
];
2781 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
2793 * Write a span of identical DITHER pixels to an XImage.
2795 static void write_span_mono_DITHER_ximage( MONO_SPAN_ARGS
)
2797 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2798 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2799 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2800 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2803 for (i
=0;i
<n
;i
++,x
++) {
2805 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, r
, g
, b
) );
2812 * Write a span of identical 8-bit DITHER pixels to an XImage.
2814 static void write_span_mono_DITHER8_ximage( MONO_SPAN_ARGS
)
2816 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2817 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2818 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2821 for (i
=0;i
<n
;i
++,x
++) {
2823 ptr
[i
] = (GLubyte
) XDITHER( x
, r
, g
, b
);
2830 * Write a span of identical 8-bit LOOKUP pixels to an XImage.
2832 static void write_span_mono_LOOKUP8_ximage( MONO_SPAN_ARGS
)
2834 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2836 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2839 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2849 * Write a span of identical PF_1BIT pixels to an XImage.
2851 static void write_span_mono_1BIT_ximage( MONO_SPAN_ARGS
)
2853 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2854 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2855 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2858 y
= FLIP(xmesa
->xm_buffer
, y
);
2859 for (i
=0;i
<n
;i
++,x
++) {
2861 XMesaPutPixel( img
, x
, y
, DITHER_1BIT( x
, y
, r
, g
, b
) );
2868 * Write a span of identical HPCR pixels to an XImage.
2870 static void write_span_mono_HPCR_ximage( MONO_SPAN_ARGS
)
2872 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2873 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2874 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2876 for (i
=0;i
<n
;i
++,x
++) {
2878 ptr
[i
] = DITHER_HPCR( x
, y
, r
, g
, b
);
2885 * Write a span of identical 8-bit GRAYSCALE pixels to an XImage.
2887 static void write_span_mono_GRAYSCALE8_ximage( MONO_SPAN_ARGS
)
2889 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2890 const GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2891 GLubyte
*ptr
= (GLubyte
*) PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2903 * Write a span of identical PF_DITHER_5R6G5B pixels to an XImage.
2905 static void write_span_mono_DITHER_5R6G5B_ximage( MONO_SPAN_ARGS
)
2907 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2908 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
2909 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2911 y
= FLIP(xmesa
->xm_buffer
, y
);
2914 PACK_TRUEDITHER(ptr
[i
], x
+i
, y
, r
, g
, b
);
2921 /**********************************************************************/
2922 /*** Write MONO COLOR PIXELS functions ***/
2923 /**********************************************************************/
2925 #define MONO_PIXEL_ARGS const GLcontext *ctx, \
2926 GLuint n, const GLint x[], const GLint y[], \
2927 const GLchan color[4], const GLubyte mask[]
2930 * Write an array of identical pixels to a pixmap.
2932 static void write_pixels_mono_pixmap( MONO_PIXEL_ARGS
)
2934 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2935 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2936 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2937 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2939 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2940 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2941 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
2944 XMesaDrawPoint( dpy
, buffer
, gc
,
2945 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2951 static void write_pixels_mono_index_pixmap(const GLcontext
*ctx
,
2953 const GLint x
[], const GLint y
[],
2955 const GLubyte mask
[] )
2957 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2958 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2959 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2960 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2962 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
2965 XMesaDrawPoint( dpy
, buffer
, gc
,
2966 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2973 * Write an array of PF_TRUEDITHER pixels to a pixmap.
2975 static void write_pixels_mono_TRUEDITHER_pixmap( MONO_PIXEL_ARGS
)
2977 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2978 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2979 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2980 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2982 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2986 PACK_TRUEDITHER(p
, x
[i
], y
[i
], r
, g
, b
);
2987 XMesaSetForeground( dpy
, gc
, p
);
2988 XMesaDrawPoint( dpy
, buffer
, gc
,
2989 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2996 * Write an array of PF_DITHER pixels to a pixmap.
2998 static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS
)
3000 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3001 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3002 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3003 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3005 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3009 XMesaSetForeground( dpy
, gc
, DITHER( x
[i
], y
[i
], r
, g
, b
) );
3010 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3017 * Write an array of PF_1BIT pixels to a pixmap.
3019 static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS
)
3021 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3022 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3023 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3024 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3026 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3030 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
) );
3031 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3038 * Write an array of identical pixels to an XImage.
3040 static void write_pixels_mono_ximage( MONO_PIXEL_ARGS
)
3042 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3043 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3045 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
3046 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3049 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), pixel
);
3055 static void write_pixels_mono_index_ximage( const GLcontext
*ctx
, GLuint n
,
3056 const GLint x
[], const GLint y
[],
3058 const GLubyte mask
[] )
3060 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3061 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3065 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), colorIndex
);
3072 * Write an array of identical TRUEDITHER pixels to an XImage.
3074 static void write_pixels_mono_TRUEDITHER_ximage( MONO_PIXEL_ARGS
)
3076 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3077 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3079 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3083 PACK_TRUEDITHER(p
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), r
, g
, b
);
3084 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
3092 * Write an array of identical 8A8B8G8R pixels to an XImage
3094 static void write_pixels_mono_8A8B8G8R_ximage( MONO_PIXEL_ARGS
)
3096 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3097 const GLuint p
= PACK_8A8B8G8R(color
[RCOMP
], color
[GCOMP
],
3098 color
[BCOMP
], color
[ACOMP
]);
3102 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3110 * Write an array of identical 8R8G8B pixels to an XImage.
3112 static void write_pixels_mono_8R8G8B_ximage( MONO_PIXEL_ARGS
)
3114 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3116 const GLuint p
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3119 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3127 * Write an array of identical 8R8G8B pixels to an XImage.
3129 static void write_pixels_mono_8R8G8B24_ximage( MONO_PIXEL_ARGS
)
3131 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3132 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3136 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3146 * Write an array of identical PF_DITHER pixels to an XImage.
3148 static void write_pixels_mono_DITHER_ximage( MONO_PIXEL_ARGS
)
3150 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3151 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3152 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3157 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), DITHER( x
[i
], y
[i
], r
, g
, b
) );
3164 * Write an array of identical 8-bit PF_DITHER pixels to an XImage.
3166 static void write_pixels_mono_DITHER8_ximage( MONO_PIXEL_ARGS
)
3168 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3169 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3174 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3175 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], r
, g
, b
);
3182 * Write an array of identical 8-bit PF_LOOKUP pixels to an XImage.
3184 static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS
)
3186 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3190 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3193 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3202 * Write an array of identical PF_1BIT pixels to an XImage.
3204 static void write_pixels_mono_1BIT_ximage( MONO_PIXEL_ARGS
)
3206 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3207 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3208 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3213 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
3214 DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
));
3221 * Write an array of identical PF_HPCR pixels to an XImage.
3223 static void write_pixels_mono_HPCR_ximage( MONO_PIXEL_ARGS
)
3225 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3226 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3230 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3231 *ptr
= DITHER_HPCR( x
[i
], y
[i
], r
, g
, b
);
3238 * Write an array of identical 8-bit PF_GRAYSCALE pixels to an XImage.
3240 static void write_pixels_mono_GRAYSCALE8_ximage( MONO_PIXEL_ARGS
)
3242 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3244 register GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3247 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3255 * Write an array of identical PF_DITHER_5R6G5B pixels to an XImage.
3257 static void write_pixels_mono_DITHER_5R6G5B_ximage( MONO_PIXEL_ARGS
)
3259 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3260 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3264 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3265 PACK_TRUEDITHER(*ptr
, x
[i
], y
[i
], r
, g
, b
);
3272 /**********************************************************************/
3273 /*** Write INDEX SPAN functions ***/
3274 /**********************************************************************/
3276 #define INDEX_SPAN_ARGS const GLcontext *ctx, \
3277 GLuint n, GLint x, GLint y, const GLuint index[], \
3278 const GLubyte mask[]
3280 #define INDEX8_SPAN_ARGS const GLcontext *ctx, \
3281 GLuint n, GLint x, GLint y, const GLubyte index[], \
3282 const GLubyte mask[]
3286 * Write a span of CI pixels to a Pixmap.
3288 static void write_span_index_pixmap( INDEX_SPAN_ARGS
)
3290 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3291 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3292 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3293 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3295 y
= FLIP(xmesa
->xm_buffer
, y
);
3297 for (i
=0;i
<n
;i
++,x
++) {
3299 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3300 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3305 for (i
=0;i
<n
;i
++,x
++) {
3306 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3307 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3314 * Write a span of 8-bit CI pixels to a Pixmap.
3316 static void write_span_index8_pixmap( INDEX8_SPAN_ARGS
)
3318 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3319 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3320 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3321 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3323 y
= FLIP(xmesa
->xm_buffer
, y
);
3325 for (i
=0;i
<n
;i
++,x
++) {
3327 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3328 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3333 for (i
=0;i
<n
;i
++,x
++) {
3334 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3335 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3342 * Write a span of CI pixels to an XImage.
3344 static void write_span_index_ximage( INDEX_SPAN_ARGS
)
3346 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3347 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3349 y
= FLIP(xmesa
->xm_buffer
, y
);
3351 for (i
=0;i
<n
;i
++,x
++) {
3353 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3358 for (i
=0;i
<n
;i
++,x
++) {
3359 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3366 * Write a span of 8-bit CI pixels to a non 8-bit XImage.
3368 static void write_span_index8_ximage( INDEX8_SPAN_ARGS
)
3370 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3375 XMesaPutPixel(xmesa
->xm_buffer
->backimage
, x
+i
, y
, index
[i
]);
3382 XMesaPutPixel(xmesa
->xm_buffer
->backimage
, x
+i
, y
, index
[i
]);
3388 * Write a span of 8-bit CI pixels to an 8-bit XImage.
3390 static void write_span_index8_ximage8( INDEX8_SPAN_ARGS
)
3392 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3393 GLubyte
*dst
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
3403 MEMCPY( dst
, index
, n
);
3409 /**********************************************************************/
3410 /*** Write INDEX PIXELS functions ***/
3411 /**********************************************************************/
3413 #define INDEX_PIXELS_ARGS const GLcontext *ctx, \
3414 GLuint n, const GLint x[], const GLint y[], \
3415 const GLuint index[], const GLubyte mask[]
3419 * Write an array of CI pixels to a Pixmap.
3421 static void write_pixels_index_pixmap( INDEX_PIXELS_ARGS
)
3423 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3424 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3425 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3426 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3430 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3431 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3438 * Write an array of CI pixels to an XImage.
3440 static void write_pixels_index_ximage( INDEX_PIXELS_ARGS
)
3442 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3443 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3447 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), (unsigned long) index
[i
] );
3455 /**********************************************************************/
3456 /***** Pixel reading *****/
3457 /**********************************************************************/
3459 #ifndef XFree86Server
3461 * Do clip testing prior to calling XGetImage. If any of the region lies
3462 * outside the screen's bounds, XGetImage will return NULL.
3463 * We use XTranslateCoordinates() to check if that's the case and
3464 * adjust the x, y and length parameters accordingly.
3465 * \return -1 if span is totally clipped away,
3466 * else return number of pixels to skip in the destination array.
3469 clip_for_xgetimage(XMesaContext xmesa
, GLuint
*n
, GLint
*x
, GLint
*y
)
3471 XMesaBuffer source
= xmesa
->xm_buffer
;
3472 Window rootWin
= RootWindow(xmesa
->display
, 0);
3474 GLint screenWidth
= WidthOfScreen(DefaultScreenOfDisplay(xmesa
->display
));
3476 if (source
->type
== PBUFFER
)
3478 XTranslateCoordinates(xmesa
->display
, source
->buffer
, rootWin
,
3479 *x
, *y
, &dx
, &dy
, &child
);
3480 if (dx
>= screenWidth
) {
3481 /* totally clipped on right */
3485 /* clipped on left */
3487 if (clip
>= (GLint
) *n
)
3488 return -1; /* totally clipped on left */
3494 if ((GLint
) (dx
+ *n
) > screenWidth
) {
3495 /* clipped on right */
3496 GLint clip
= dx
+ *n
- screenWidth
;
3505 * Read a horizontal span of color-index pixels.
3507 static void read_index_span( const GLcontext
*ctx
,
3508 GLuint n
, GLint x
, GLint y
, GLuint index
[] )
3510 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3511 XMesaBuffer source
= xmesa
->xm_buffer
;
3514 y
= FLIP(source
, y
);
3516 if (source
->buffer
) {
3517 #ifndef XFree86Server
3518 XMesaImage
*span
= NULL
;
3520 int k
= clip_for_xgetimage(xmesa
, &n
, &x
, &y
);
3525 catch_xgetimage_errors( xmesa
->display
);
3526 span
= XGetImage( xmesa
->display
, source
->buffer
,
3527 x
, y
, n
, 1, AllPlanes
, ZPixmap
);
3528 error
= check_xgetimage_errors();
3529 if (span
&& !error
) {
3531 index
[i
] = (GLuint
) XMesaGetPixel( span
, i
, 0 );
3535 /* return 0 pixels */
3541 XMesaDestroyImage( span
);
3544 (*xmesa
->display
->GetImage
)(source
->buffer
,
3545 x
, y
, n
, 1, ZPixmap
,
3546 ~0L, (pointer
)index
);
3549 else if (source
->backimage
) {
3550 XMesaImage
*img
= source
->backimage
;
3551 for (i
=0;i
<n
;i
++,x
++) {
3552 index
[i
] = (GLuint
) XMesaGetPixel( img
, x
, y
);
3560 * Read a horizontal span of color pixels.
3562 static void read_color_span( const GLcontext
*ctx
,
3563 GLuint n
, GLint x
, GLint y
,
3566 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3567 XMesaBuffer source
= xmesa
->xm_buffer
;
3569 if (source
->buffer
) {
3570 /* Read from Pixmap or Window */
3571 XMesaImage
*span
= NULL
;
3573 #ifdef XFree86Server
3574 span
= XMesaCreateImage(xmesa
->xm_visual
->BitsPerPixel
, n
, 1, NULL
);
3575 span
->data
= (char *)MALLOC(span
->height
* span
->bytes_per_line
);
3576 error
= (!span
->data
);
3577 (*xmesa
->display
->GetImage
)(source
->buffer
,
3578 x
, FLIP(source
, y
), n
, 1, ZPixmap
,
3579 ~0L, (pointer
)span
->data
);
3582 y
= FLIP(source
, y
);
3583 k
= clip_for_xgetimage(xmesa
, &n
, &x
, &y
);
3587 catch_xgetimage_errors( xmesa
->display
);
3588 span
= XGetImage( xmesa
->display
, source
->buffer
,
3589 x
, y
, n
, 1, AllPlanes
, ZPixmap
);
3590 error
= check_xgetimage_errors();
3592 if (span
&& !error
) {
3593 switch (xmesa
->pixelformat
) {
3595 case PF_Dither_True
:
3597 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3598 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3599 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3600 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3601 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3602 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3603 GLint rShift
= xmesa
->xm_visual
->rshift
;
3604 GLint gShift
= xmesa
->xm_visual
->gshift
;
3605 GLint bShift
= xmesa
->xm_visual
->bshift
;
3609 p
= XMesaGetPixel( span
, i
, 0 );
3610 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3611 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3612 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3613 rgba
[i
][ACOMP
] = 255;
3618 case PF_Dither_5R6G5B
:
3620 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3621 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3622 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3625 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
3626 /* fast, but not quite accurate
3627 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3628 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3629 rgba[i][BCOMP] = ((p << 3) & 0xff);
3631 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
3632 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3633 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
3634 rgba
[i
][ACOMP
] = 255;
3640 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3643 GLuint p4
= *ptr4
++;
3644 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
3645 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3646 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3647 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
3653 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3656 GLuint p4
= *ptr4
++;
3657 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3658 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3659 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3660 rgba
[i
][ACOMP
] = 255;
3666 const bgr_t
*ptr3
= (bgr_t
*) span
->data
;
3669 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
3670 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
3671 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
3672 rgba
[i
][ACOMP
] = 255;
3678 GLubyte
*ptr1
= (GLubyte
*) span
->data
;
3681 GLubyte p
= *ptr1
++;
3682 rgba
[i
][RCOMP
] = p
& 0xE0;
3683 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
3684 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
3685 rgba
[i
][ACOMP
] = 255;
3693 GLubyte
*rTable
= source
->pixel_to_r
;
3694 GLubyte
*gTable
= source
->pixel_to_g
;
3695 GLubyte
*bTable
= source
->pixel_to_b
;
3696 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
3697 const GLubyte
*ptr1
= (GLubyte
*) span
->data
;
3700 unsigned long p
= *ptr1
++;
3701 rgba
[i
][RCOMP
] = rTable
[p
];
3702 rgba
[i
][GCOMP
] = gTable
[p
];
3703 rgba
[i
][BCOMP
] = bTable
[p
];
3704 rgba
[i
][ACOMP
] = 255;
3710 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
3711 rgba
[i
][RCOMP
] = rTable
[p
];
3712 rgba
[i
][GCOMP
] = gTable
[p
];
3713 rgba
[i
][BCOMP
] = bTable
[p
];
3714 rgba
[i
][ACOMP
] = 255;
3721 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
3725 p
= XMesaGetPixel( span
, i
, 0 ) ^ bitFlip
;
3726 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
3727 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
3728 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
3729 rgba
[i
][ACOMP
] = 255;
3734 _mesa_problem(NULL
,"Problem in DD.read_color_span (1)");
3739 /* return black pixels */
3742 rgba
[i
][RCOMP
] = rgba
[i
][GCOMP
] = rgba
[i
][BCOMP
] = rgba
[i
][ACOMP
] = 0;
3746 XMesaDestroyImage( span
);
3749 else if (source
->backimage
) {
3750 /* Read from XImage back buffer */
3751 switch (xmesa
->pixelformat
) {
3753 case PF_Dither_True
:
3755 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3756 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3757 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3758 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3759 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3760 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3761 GLint rShift
= xmesa
->xm_visual
->rshift
;
3762 GLint gShift
= xmesa
->xm_visual
->gshift
;
3763 GLint bShift
= xmesa
->xm_visual
->bshift
;
3764 XMesaImage
*img
= source
->backimage
;
3766 y
= FLIP(source
, y
);
3769 p
= XMesaGetPixel( img
, x
+i
, y
);
3770 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3771 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3772 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3773 rgba
[i
][ACOMP
] = 255;
3778 case PF_Dither_5R6G5B
:
3780 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3781 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3782 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3783 const GLushort
*ptr2
= PIXELADDR2( source
, x
, y
);
3785 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
3786 const GLuint
*ptr4
= (const GLuint
*) ptr2
;
3787 GLuint extraPixel
= (n
& 1);
3789 for (i
= 0; i
< n
; i
+= 2) {
3790 const GLuint p
= *ptr4
++;
3791 const GLuint p0
= p
& 0xffff;
3792 const GLuint p1
= p
>> 16;
3793 /* fast, but not quite accurate
3794 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3795 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3796 rgba[i][BCOMP] = ((p << 3) & 0xff);
3798 rgba
[i
][RCOMP
] = pixelToR
[p0
>> 11];
3799 rgba
[i
][GCOMP
] = pixelToG
[(p0
>> 5) & 0x3f];
3800 rgba
[i
][BCOMP
] = pixelToB
[p0
& 0x1f];
3801 rgba
[i
][ACOMP
] = 255;
3802 rgba
[i
+1][RCOMP
] = pixelToR
[p1
>> 11];
3803 rgba
[i
+1][GCOMP
] = pixelToG
[(p1
>> 5) & 0x3f];
3804 rgba
[i
+1][BCOMP
] = pixelToB
[p1
& 0x1f];
3805 rgba
[i
+1][ACOMP
] = 255;
3808 GLushort p
= ptr2
[n
];
3809 rgba
[n
][RCOMP
] = pixelToR
[p
>> 11];
3810 rgba
[n
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3811 rgba
[n
][BCOMP
] = pixelToB
[p
& 0x1f];
3812 rgba
[n
][ACOMP
] = 255;
3815 for (i
= 0; i
< n
; i
++) {
3816 const GLushort p
= ptr2
[i
];
3817 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
3818 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3819 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
3820 rgba
[i
][ACOMP
] = 255;
3827 const GLuint
*ptr4
= PIXELADDR4( source
, x
, y
);
3830 GLuint p4
= *ptr4
++;
3831 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
3832 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3833 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3834 rgba
[i
][ACOMP
] = (GLint
) ((p4
>> 24) & 0xff);
3840 const GLuint
*ptr4
= PIXELADDR4( source
, x
, y
);
3843 GLuint p4
= *ptr4
++;
3844 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3845 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3846 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3847 rgba
[i
][ACOMP
] = 255;
3853 const bgr_t
*ptr3
= PIXELADDR3( source
, x
, y
);
3856 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
3857 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
3858 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
3859 rgba
[i
][ACOMP
] = 255;
3865 const GLubyte
*ptr1
= PIXELADDR1( source
, x
, y
);
3868 GLubyte p
= *ptr1
++;
3869 rgba
[i
][RCOMP
] = p
& 0xE0;
3870 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
3871 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
3872 rgba
[i
][ACOMP
] = 255;
3880 const GLubyte
*rTable
= source
->pixel_to_r
;
3881 const GLubyte
*gTable
= source
->pixel_to_g
;
3882 const GLubyte
*bTable
= source
->pixel_to_b
;
3883 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
3884 GLubyte
*ptr1
= PIXELADDR1( source
, x
, y
);
3887 unsigned long p
= *ptr1
++;
3888 rgba
[i
][RCOMP
] = rTable
[p
];
3889 rgba
[i
][GCOMP
] = gTable
[p
];
3890 rgba
[i
][BCOMP
] = bTable
[p
];
3891 rgba
[i
][ACOMP
] = 255;
3895 XMesaImage
*img
= source
->backimage
;
3897 y
= FLIP(source
, y
);
3898 for (i
=0;i
<n
;i
++,x
++) {
3899 unsigned long p
= XMesaGetPixel( img
, x
, y
);
3900 rgba
[i
][RCOMP
] = rTable
[p
];
3901 rgba
[i
][GCOMP
] = gTable
[p
];
3902 rgba
[i
][BCOMP
] = bTable
[p
];
3903 rgba
[i
][ACOMP
] = 255;
3910 XMesaImage
*img
= source
->backimage
;
3911 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
3913 y
= FLIP(source
, y
);
3914 for (i
=0;i
<n
;i
++,x
++) {
3916 p
= XMesaGetPixel( img
, x
, y
) ^ bitFlip
;
3917 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
3918 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
3919 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
3920 rgba
[i
][ACOMP
] = 255;
3925 _mesa_problem(NULL
,"Problem in DD.read_color_span (2)");
3934 * Read an array of color index pixels.
3936 static void read_index_pixels( const GLcontext
*ctx
,
3937 GLuint n
, const GLint x
[], const GLint y
[],
3938 GLuint indx
[], const GLubyte mask
[] )
3940 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3942 XMesaBuffer source
= xmesa
->xm_buffer
;
3944 if (source
->buffer
) {
3947 indx
[i
] = (GLuint
) read_pixel( xmesa
->display
,
3949 x
[i
], FLIP(source
, y
[i
]) );
3953 else if (source
->backimage
) {
3954 XMesaImage
*img
= source
->backimage
;
3957 indx
[i
] = (GLuint
) XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
3965 static void read_color_pixels( const GLcontext
*ctx
,
3966 GLuint n
, const GLint x
[], const GLint y
[],
3967 GLubyte rgba
[][4], const GLubyte mask
[] )
3969 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3970 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3972 XMesaBuffer source
= xmesa
->xm_buffer
;
3973 XMesaDrawable buffer
= source
->buffer
; /* the X drawable */
3975 if (source
->buffer
) {
3976 switch (xmesa
->pixelformat
) {
3978 case PF_Dither_True
:
3980 case PF_Dither_5R6G5B
:
3982 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3983 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3984 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3985 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3986 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3987 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3988 GLint rShift
= xmesa
->xm_visual
->rshift
;
3989 GLint gShift
= xmesa
->xm_visual
->gshift
;
3990 GLint bShift
= xmesa
->xm_visual
->bshift
;
3993 unsigned long p
= read_pixel( dpy
, buffer
,
3994 x
[i
], FLIP(source
, y
[i
]) );
3995 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3996 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3997 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3998 rgba
[i
][ACOMP
] = 255;
4006 unsigned long p
= read_pixel( dpy
, buffer
,
4007 x
[i
], FLIP(source
, y
[i
]) );
4008 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xff);
4009 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4010 rgba
[i
][BCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4011 rgba
[i
][ACOMP
] = (GLubyte
) ((p
>> 24) & 0xff);
4018 unsigned long p
= read_pixel( dpy
, buffer
,
4019 x
[i
], FLIP(source
, y
[i
]) );
4020 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4021 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4022 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4023 rgba
[i
][ACOMP
] = 255;
4030 unsigned long p
= read_pixel( dpy
, buffer
,
4031 x
[i
], FLIP(source
, y
[i
]) );
4032 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4033 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4034 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4035 rgba
[i
][ACOMP
] = 255;
4043 unsigned long p
= read_pixel( dpy
, buffer
,
4044 x
[i
], FLIP(source
, y
[i
]) );
4045 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xE0 );
4046 rgba
[i
][GCOMP
] = (GLubyte
) ((p
& 0x1C) << 3);
4047 rgba
[i
][BCOMP
] = (GLubyte
) ((p
& 0x03) << 6);
4048 rgba
[i
][ACOMP
] = (GLubyte
) 255;
4057 GLubyte
*rTable
= source
->pixel_to_r
;
4058 GLubyte
*gTable
= source
->pixel_to_g
;
4059 GLubyte
*bTable
= source
->pixel_to_b
;
4062 unsigned long p
= read_pixel( dpy
, buffer
,
4063 x
[i
], FLIP(source
, y
[i
]) );
4064 rgba
[i
][RCOMP
] = rTable
[p
];
4065 rgba
[i
][GCOMP
] = gTable
[p
];
4066 rgba
[i
][BCOMP
] = bTable
[p
];
4067 rgba
[i
][ACOMP
] = 255;
4074 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4077 unsigned long p
= read_pixel( dpy
, buffer
,
4078 x
[i
], FLIP(source
, y
[i
])) ^ bitFlip
;
4079 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4080 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4081 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4082 rgba
[i
][ACOMP
] = 255;
4088 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4092 else if (source
->backimage
) {
4093 switch (xmesa
->pixelformat
) {
4095 case PF_Dither_True
:
4097 case PF_Dither_5R6G5B
:
4099 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4100 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4101 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4102 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4103 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4104 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4105 GLint rShift
= xmesa
->xm_visual
->rshift
;
4106 GLint gShift
= xmesa
->xm_visual
->gshift
;
4107 GLint bShift
= xmesa
->xm_visual
->bshift
;
4108 XMesaImage
*img
= source
->backimage
;
4112 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
4113 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4114 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4115 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4116 rgba
[i
][ACOMP
] = 255;
4124 GLuint
*ptr4
= PIXELADDR4( source
, x
[i
], y
[i
] );
4126 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
4127 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4128 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4129 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
4136 GLuint
*ptr4
= PIXELADDR4( source
, x
[i
], y
[i
] );
4138 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4139 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4140 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4141 rgba
[i
][ACOMP
] = 255;
4148 bgr_t
*ptr3
= PIXELADDR3( source
, x
[i
], y
[i
] );
4149 rgba
[i
][RCOMP
] = ptr3
->r
;
4150 rgba
[i
][GCOMP
] = ptr3
->g
;
4151 rgba
[i
][BCOMP
] = ptr3
->b
;
4152 rgba
[i
][ACOMP
] = 255;
4159 GLubyte
*ptr1
= PIXELADDR1( source
, x
[i
], y
[i
] );
4161 rgba
[i
][RCOMP
] = p
& 0xE0;
4162 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4163 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4164 rgba
[i
][ACOMP
] = 255;
4172 GLubyte
*rTable
= source
->pixel_to_r
;
4173 GLubyte
*gTable
= source
->pixel_to_g
;
4174 GLubyte
*bTable
= source
->pixel_to_b
;
4175 XMesaImage
*img
= source
->backimage
;
4179 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
4180 rgba
[i
][RCOMP
] = rTable
[p
];
4181 rgba
[i
][GCOMP
] = gTable
[p
];
4182 rgba
[i
][BCOMP
] = bTable
[p
];
4183 rgba
[i
][ACOMP
] = 255;
4190 XMesaImage
*img
= source
->backimage
;
4191 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4195 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) ) ^ bitFlip
;
4196 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4197 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4198 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4199 rgba
[i
][ACOMP
] = 255;
4205 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4213 clear_color_HPCR_ximage( GLcontext
*ctx
, const GLfloat color
[4] )
4216 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
4218 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[0], color
[0]);
4219 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[1], color
[1]);
4220 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[2], color
[2]);
4221 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[3], color
[3]);
4223 if (color
[0] == 0.0 && color
[1] == 0.0 && color
[2] == 0.0) {
4224 /* black is black */
4225 MEMSET( xmesa
->xm_visual
->hpcr_clear_ximage_pattern
, 0x0 ,
4226 sizeof(xmesa
->xm_visual
->hpcr_clear_ximage_pattern
));
4229 /* build clear pattern */
4230 for (i
=0; i
<16; i
++) {
4231 xmesa
->xm_visual
->hpcr_clear_ximage_pattern
[0][i
] =
4233 xmesa
->clearcolor
[0],
4234 xmesa
->clearcolor
[1],
4235 xmesa
->clearcolor
[2]);
4236 xmesa
->xm_visual
->hpcr_clear_ximage_pattern
[1][i
] =
4238 xmesa
->clearcolor
[0],
4239 xmesa
->clearcolor
[1],
4240 xmesa
->clearcolor
[2]);
4247 clear_color_HPCR_pixmap( GLcontext
*ctx
, const GLfloat color
[4] )
4250 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
4252 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[0], color
[0]);
4253 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[1], color
[1]);
4254 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[2], color
[2]);
4255 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[3], color
[3]);
4257 if (color
[0] == 0.0 && color
[1] == 0.0 && color
[2] == 0.0) {
4258 /* black is black */
4259 for (i
=0; i
<16; i
++) {
4260 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 0, 0);
4261 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 1, 0);
4265 for (i
=0; i
<16; i
++) {
4266 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 0,
4268 xmesa
->clearcolor
[0],
4269 xmesa
->clearcolor
[1],
4270 xmesa
->clearcolor
[2]));
4271 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 1,
4273 xmesa
->clearcolor
[0],
4274 xmesa
->clearcolor
[1],
4275 xmesa
->clearcolor
[2]));
4278 /* change tile pixmap content */
4279 XMesaPutImage(xmesa
->display
,
4280 (XMesaDrawable
)xmesa
->xm_visual
->hpcr_clear_pixmap
,
4281 xmesa
->xm_buffer
->cleargc
,
4282 xmesa
->xm_visual
->hpcr_clear_ximage
, 0, 0, 0, 0, 16, 2);
4287 void xmesa_update_span_funcs( GLcontext
*ctx
)
4289 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
4290 int depth
=GET_VISUAL_DEPTH(xmesa
->xm_visual
);
4291 struct swrast_device_driver
*dd
= _swrast_GetDeviceDriverReference( ctx
);
4294 * These drawing functions depend on color buffer config:
4296 if (xmesa
->xm_buffer
->buffer
!=XIMAGE
) {
4297 /* Writing to window or back pixmap */
4298 switch (xmesa
->pixelformat
) {
4300 dd
->WriteCI32Span
= write_span_index_pixmap
;
4301 dd
->WriteCI8Span
= write_span_index8_pixmap
;
4302 dd
->WriteMonoCISpan
= write_span_mono_index_pixmap
;
4303 dd
->WriteCI32Pixels
= write_pixels_index_pixmap
;
4304 dd
->WriteMonoCIPixels
= write_pixels_mono_index_pixmap
;
4307 dd
->WriteRGBASpan
= write_span_TRUECOLOR_pixmap
;
4308 dd
->WriteRGBSpan
= write_span_rgb_TRUECOLOR_pixmap
;
4309 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4310 dd
->WriteRGBAPixels
= write_pixels_TRUECOLOR_pixmap
;
4311 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4313 case PF_Dither_True
:
4314 dd
->WriteRGBASpan
= write_span_TRUEDITHER_pixmap
;
4315 dd
->WriteRGBSpan
= write_span_rgb_TRUEDITHER_pixmap
;
4316 dd
->WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_pixmap
;
4317 dd
->WriteRGBAPixels
= write_pixels_TRUEDITHER_pixmap
;
4318 dd
->WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_pixmap
;
4321 dd
->WriteRGBASpan
= write_span_8A8B8G8R_pixmap
;
4322 dd
->WriteRGBSpan
= write_span_rgb_8A8B8G8R_pixmap
;
4323 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4324 dd
->WriteRGBAPixels
= write_pixels_8A8B8G8R_pixmap
;
4325 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4328 dd
->WriteRGBASpan
= write_span_8R8G8B_pixmap
;
4329 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B_pixmap
;
4330 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4331 dd
->WriteRGBAPixels
= write_pixels_8R8G8B_pixmap
;
4332 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4335 dd
->WriteRGBASpan
= write_span_8R8G8B24_pixmap
;
4336 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B24_pixmap
;
4337 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4338 dd
->WriteRGBAPixels
= write_pixels_8R8G8B24_pixmap
;
4339 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4342 dd
->WriteRGBASpan
= write_span_5R6G5B_pixmap
;
4343 dd
->WriteRGBSpan
= write_span_rgb_5R6G5B_pixmap
;
4344 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4345 dd
->WriteRGBAPixels
= write_pixels_5R6G5B_pixmap
;
4346 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4348 case PF_Dither_5R6G5B
:
4349 dd
->WriteRGBASpan
= write_span_DITHER_5R6G5B_pixmap
;
4350 dd
->WriteRGBSpan
= write_span_rgb_DITHER_5R6G5B_pixmap
;
4351 dd
->WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_pixmap
;
4352 dd
->WriteRGBAPixels
= write_pixels_DITHER_5R6G5B_pixmap
;
4353 dd
->WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_pixmap
;
4356 dd
->WriteRGBASpan
= write_span_DITHER_pixmap
;
4357 dd
->WriteRGBSpan
= write_span_rgb_DITHER_pixmap
;
4358 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER_pixmap
;
4359 dd
->WriteRGBAPixels
= write_pixels_DITHER_pixmap
;
4360 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER_pixmap
;
4363 dd
->WriteRGBASpan
= write_span_1BIT_pixmap
;
4364 dd
->WriteRGBSpan
= write_span_rgb_1BIT_pixmap
;
4365 dd
->WriteMonoRGBASpan
= write_span_mono_1BIT_pixmap
;
4366 dd
->WriteRGBAPixels
= write_pixels_1BIT_pixmap
;
4367 dd
->WriteMonoRGBAPixels
= write_pixels_mono_1BIT_pixmap
;
4370 dd
->WriteRGBASpan
= write_span_HPCR_pixmap
;
4371 dd
->WriteRGBSpan
= write_span_rgb_HPCR_pixmap
;
4372 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4373 dd
->WriteRGBAPixels
= write_pixels_HPCR_pixmap
;
4374 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4375 if (xmesa
->xm_visual
->hpcr_clear_flag
) {
4376 ctx
->Driver
.ClearColor
= clear_color_HPCR_pixmap
;
4380 dd
->WriteRGBASpan
= write_span_LOOKUP_pixmap
;
4381 dd
->WriteRGBSpan
= write_span_rgb_LOOKUP_pixmap
;
4382 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4383 dd
->WriteRGBAPixels
= write_pixels_LOOKUP_pixmap
;
4384 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4387 dd
->WriteRGBASpan
= write_span_GRAYSCALE_pixmap
;
4388 dd
->WriteRGBSpan
= write_span_rgb_GRAYSCALE_pixmap
;
4389 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4390 dd
->WriteRGBAPixels
= write_pixels_GRAYSCALE_pixmap
;
4391 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4394 _mesa_problem(NULL
,"Bad pixel format in xmesa_update_state (1)");
4398 else if (xmesa
->xm_buffer
->buffer
==XIMAGE
) {
4399 /* Writing to back XImage */
4400 switch (xmesa
->pixelformat
) {
4402 dd
->WriteCI32Span
= write_span_index_ximage
;
4404 dd
->WriteCI8Span
= write_span_index8_ximage8
;
4406 dd
->WriteCI8Span
= write_span_index8_ximage
;
4407 dd
->WriteMonoCISpan
= write_span_mono_index_ximage
;
4408 dd
->WriteCI32Pixels
= write_pixels_index_ximage
;
4409 dd
->WriteMonoCIPixels
= write_pixels_mono_index_ximage
;
4413 dd
->WriteRGBASpan
= write_span_TRUECOLOR_ximage
;
4414 dd
->WriteRGBSpan
= write_span_rgb_TRUECOLOR_ximage
;
4415 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4416 dd
->WriteRGBAPixels
= write_pixels_TRUECOLOR_ximage
;
4417 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4419 case PF_Dither_True
:
4420 dd
->WriteRGBASpan
= write_span_TRUEDITHER_ximage
;
4421 dd
->WriteRGBSpan
= write_span_rgb_TRUEDITHER_ximage
;
4422 dd
->WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_ximage
;
4423 dd
->WriteRGBAPixels
= write_pixels_TRUEDITHER_ximage
;
4424 dd
->WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_ximage
;
4427 dd
->WriteRGBASpan
= write_span_8A8B8G8R_ximage
;
4428 dd
->WriteRGBSpan
= write_span_rgb_8A8B8G8R_ximage
;
4429 dd
->WriteMonoRGBASpan
= write_span_mono_8A8B8G8R_ximage
;
4430 dd
->WriteRGBAPixels
= write_pixels_8A8B8G8R_ximage
;
4431 dd
->WriteMonoRGBAPixels
= write_pixels_mono_8A8B8G8R_ximage
;
4434 dd
->WriteRGBASpan
= write_span_8R8G8B_ximage
;
4435 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B_ximage
;
4436 dd
->WriteMonoRGBASpan
= write_span_mono_8R8G8B_ximage
;
4437 dd
->WriteRGBAPixels
= write_pixels_8R8G8B_ximage
;
4438 dd
->WriteMonoRGBAPixels
= write_pixels_mono_8R8G8B_ximage
;
4441 dd
->WriteRGBASpan
= write_span_8R8G8B24_ximage
;
4442 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B24_ximage
;
4443 dd
->WriteMonoRGBASpan
= write_span_mono_8R8G8B24_ximage
;
4444 dd
->WriteRGBAPixels
= write_pixels_8R8G8B24_ximage
;
4445 dd
->WriteMonoRGBAPixels
= write_pixels_mono_8R8G8B24_ximage
;
4448 dd
->WriteRGBASpan
= write_span_5R6G5B_ximage
;
4449 dd
->WriteRGBSpan
= write_span_rgb_5R6G5B_ximage
;
4450 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4451 dd
->WriteRGBAPixels
= write_pixels_5R6G5B_ximage
;
4452 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4454 case PF_Dither_5R6G5B
:
4455 dd
->WriteRGBASpan
= write_span_DITHER_5R6G5B_ximage
;
4456 dd
->WriteRGBSpan
= write_span_rgb_DITHER_5R6G5B_ximage
;
4457 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER_5R6G5B_ximage
;
4458 dd
->WriteRGBAPixels
= write_pixels_DITHER_5R6G5B_ximage
;
4459 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER_5R6G5B_ximage
;
4463 dd
->WriteRGBASpan
= write_span_DITHER8_ximage
;
4464 dd
->WriteRGBSpan
= write_span_rgb_DITHER8_ximage
;
4465 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER8_ximage
;
4466 dd
->WriteRGBAPixels
= write_pixels_DITHER8_ximage
;
4467 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER8_ximage
;
4470 dd
->WriteRGBASpan
= write_span_DITHER_ximage
;
4471 dd
->WriteRGBSpan
= write_span_rgb_DITHER_ximage
;
4472 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER_ximage
;
4473 dd
->WriteRGBAPixels
= write_pixels_DITHER_ximage
;
4474 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER_ximage
;
4478 dd
->WriteRGBASpan
= write_span_1BIT_ximage
;
4479 dd
->WriteRGBSpan
= write_span_rgb_1BIT_ximage
;
4480 dd
->WriteMonoRGBASpan
= write_span_mono_1BIT_ximage
;
4481 dd
->WriteRGBAPixels
= write_pixels_1BIT_ximage
;
4482 dd
->WriteMonoRGBAPixels
= write_pixels_mono_1BIT_ximage
;
4485 dd
->WriteRGBASpan
= write_span_HPCR_ximage
;
4486 dd
->WriteRGBSpan
= write_span_rgb_HPCR_ximage
;
4487 dd
->WriteMonoRGBASpan
= write_span_mono_HPCR_ximage
;
4488 dd
->WriteRGBAPixels
= write_pixels_HPCR_ximage
;
4489 dd
->WriteMonoRGBAPixels
= write_pixels_mono_HPCR_ximage
;
4490 if (xmesa
->xm_visual
->hpcr_clear_flag
) {
4491 ctx
->Driver
.ClearColor
= clear_color_HPCR_ximage
;
4496 dd
->WriteRGBASpan
= write_span_LOOKUP8_ximage
;
4497 dd
->WriteRGBSpan
= write_rgb_LOOKUP8_ximage
;
4498 dd
->WriteMonoRGBASpan
= write_span_mono_LOOKUP8_ximage
;
4499 dd
->WriteRGBAPixels
= write_pixels_LOOKUP8_ximage
;
4500 dd
->WriteMonoRGBAPixels
= write_pixels_mono_LOOKUP8_ximage
;
4503 dd
->WriteRGBASpan
= write_span_LOOKUP_ximage
;
4504 dd
->WriteRGBSpan
= write_span_rgb_LOOKUP_ximage
;
4505 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4506 dd
->WriteRGBAPixels
= write_pixels_LOOKUP_ximage
;
4507 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4512 dd
->WriteRGBASpan
= write_span_GRAYSCALE8_ximage
;
4513 dd
->WriteRGBSpan
= write_span_rgb_GRAYSCALE8_ximage
;
4514 dd
->WriteMonoRGBASpan
= write_span_mono_GRAYSCALE8_ximage
;
4515 dd
->WriteRGBAPixels
= write_pixels_GRAYSCALE8_ximage
;
4516 dd
->WriteMonoRGBAPixels
= write_pixels_mono_GRAYSCALE8_ximage
;
4519 dd
->WriteRGBASpan
= write_span_GRAYSCALE_ximage
;
4520 dd
->WriteRGBSpan
= write_span_rgb_GRAYSCALE_ximage
;
4521 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4522 dd
->WriteRGBAPixels
= write_pixels_GRAYSCALE_ximage
;
4523 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4527 _mesa_problem(NULL
,"Bad pixel format in xmesa_update_state (2)");
4532 /* Pixel/span reading functions: */
4533 dd
->ReadCI32Span
= read_index_span
;
4534 dd
->ReadRGBASpan
= read_color_span
;
4535 dd
->ReadCI32Pixels
= read_index_pixels
;
4536 dd
->ReadRGBAPixels
= read_color_pixels
;