2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2003 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 (void)DitherValues
; /* Muffle compiler */
191 y
= FLIP(xmesa
->xm_buffer
, y
);
193 for (i
=0;i
<n
;i
++,x
++) {
196 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
197 XMesaSetForeground( dpy
, gc
, p
);
198 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
203 /* draw all pixels */
204 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
207 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
208 XMesaPutPixel( rowimg
, i
, 0, p
);
210 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
216 * Write a span of PF_TRUECOLOR pixels to a pixmap.
218 static void write_span_rgb_TRUECOLOR_pixmap( RGB_SPAN_ARGS
)
220 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
221 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
222 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
223 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
225 y
= FLIP(xmesa
->xm_buffer
, y
);
227 for (i
=0;i
<n
;i
++,x
++) {
230 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
231 XMesaSetForeground( dpy
, gc
, p
);
232 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
237 /* draw all pixels */
238 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
241 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
242 XMesaPutPixel( rowimg
, i
, 0, p
);
244 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
250 * Write a span of PF_TRUEDITHER pixels to a pixmap.
252 static void write_span_TRUEDITHER_pixmap( RGBA_SPAN_ARGS
)
254 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
255 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
256 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
257 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
259 y
= FLIP(xmesa
->xm_buffer
, y
);
261 for (i
=0;i
<n
;i
++,x
++) {
264 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
265 XMesaSetForeground( dpy
, gc
, p
);
266 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
271 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
274 PACK_TRUEDITHER(p
, x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
275 XMesaPutPixel( rowimg
, i
, 0, p
);
277 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
283 * Write a span of PF_TRUEDITHER pixels to a pixmap (no alpha).
285 static void write_span_rgb_TRUEDITHER_pixmap( RGB_SPAN_ARGS
)
287 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
288 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
289 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
290 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
292 y
= FLIP(xmesa
->xm_buffer
, y
);
294 for (i
=0;i
<n
;i
++,x
++) {
297 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
298 XMesaSetForeground( dpy
, gc
, p
);
299 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
304 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
307 PACK_TRUEDITHER(p
, x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
308 XMesaPutPixel( rowimg
, i
, 0, p
);
310 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
317 * Write a span of PF_8A8B8G8R pixels to a pixmap.
319 static void write_span_8A8B8G8R_pixmap( RGBA_SPAN_ARGS
)
321 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
322 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
323 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
324 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
326 y
= FLIP(xmesa
->xm_buffer
, y
);
328 for (i
=0;i
<n
;i
++,x
++) {
330 XMesaSetForeground( dpy
, gc
,
331 PACK_8A8B8G8R(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
]) );
332 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
337 /* draw all pixels */
338 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
339 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
341 *ptr4
++ = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
343 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
349 * Write a span of PF_8A8B8G8R pixels to a pixmap (no alpha).
351 static void write_span_rgb_8A8B8G8R_pixmap( RGB_SPAN_ARGS
)
353 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
354 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
355 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
356 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
358 y
= FLIP(xmesa
->xm_buffer
, y
);
360 for (i
=0;i
<n
;i
++,x
++) {
362 XMesaSetForeground( dpy
, gc
,
363 PACK_8B8G8R(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
364 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
369 /* draw all pixels */
370 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
371 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
373 *ptr4
++ = PACK_8B8G8R(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
375 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
381 * Write a span of PF_8R8G8B pixels to a pixmap.
383 static void write_span_8R8G8B_pixmap( RGBA_SPAN_ARGS
)
385 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
386 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
387 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
388 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
390 y
= FLIP(xmesa
->xm_buffer
, y
);
392 for (i
=0;i
<n
;i
++,x
++) {
394 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
395 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
400 /* draw all pixels */
401 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
402 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
404 *ptr4
++ = PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
406 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
412 * Write a span of PF_8R8G8B24 pixels to a pixmap.
414 static void write_span_8R8G8B24_pixmap( RGBA_SPAN_ARGS
)
416 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
417 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
418 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
419 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
420 y
= FLIP(xmesa
->xm_buffer
, y
);
423 for (i
=0;i
<n
;i
++,x
++) {
425 XMesaSetForeground( dpy
, gc
,
426 PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
427 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
432 /* draw all pixels */
433 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
434 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
435 register GLuint pixel
;
436 static const GLuint shift
[4] = {0, 8, 16, 24};
437 register GLuint i
= 0;
440 pixel
= rgba
[i
][BCOMP
] /* << shift[0]*/;
441 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
442 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
443 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
446 pixel
= rgba
[i
][GCOMP
] /* << shift[0]*/;
447 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
448 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
449 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
452 pixel
= rgba
[i
++][RCOMP
]/* << shift[0]*/;
453 pixel
|= rgba
[i
][BCOMP
] << shift
[1];
454 pixel
|= rgba
[i
][GCOMP
] << shift
[2];
455 pixel
|= rgba
[i
++][RCOMP
] << shift
[3];
463 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
464 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
465 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
466 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
469 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
470 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
471 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
472 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
474 pixel
= 0xffffff00 & *ptr4
;
475 pixel
|= rgba
[i
][RCOMP
] /*<< shift[0]*/;
480 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
481 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
482 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
483 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
485 pixel
= 0xffff0000 & *ptr4
;
486 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
487 pixel
|= rgba
[i
][RCOMP
] << shift
[1];
491 pixel
= 0xff000000 & *ptr4
;
492 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
493 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
494 pixel
|= rgba
[i
][RCOMP
] << shift
[2];
500 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
506 * Write a span of PF_8R8G8B pixels to a pixmap (no alpha).
508 static void write_span_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS
)
510 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
511 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
512 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
513 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
515 y
= FLIP(xmesa
->xm_buffer
, y
);
517 for (i
=0;i
<n
;i
++,x
++) {
519 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
520 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
525 /* draw all pixels */
526 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
527 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
529 *ptr4
++ = PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
531 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
537 * Write a span of PF_8R8G8B24 pixels to a pixmap (no alpha).
539 static void write_span_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS
)
541 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
542 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
543 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
544 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
545 y
= FLIP(xmesa
->xm_buffer
, y
);
548 for (i
=0;i
<n
;i
++,x
++) {
550 XMesaSetForeground( dpy
, gc
,
551 PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
552 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
557 /* draw all pixels */
558 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
559 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
560 register GLuint pixel
;
561 static const GLuint shift
[4] = {0, 8, 16, 24};
563 register GLuint i
= 0;
566 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
567 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
568 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
569 pixel
|= rgb
[i
][BCOMP
] <<shift
[3];
573 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
574 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
575 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
576 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
580 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
581 pixel
|= rgb
[i
][BCOMP
] << shift
[1];
582 pixel
|= rgb
[i
][GCOMP
] << shift
[2];
583 pixel
|= rgb
[i
++][RCOMP
] << shift
[3];
590 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
591 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
592 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
593 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
596 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
597 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
598 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
599 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
603 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
608 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
609 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
610 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
611 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
615 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
616 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
622 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
623 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
624 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
630 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
636 * Write a span of PF_5R6G5B pixels to a pixmap.
638 static void write_span_5R6G5B_pixmap( RGBA_SPAN_ARGS
)
640 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
641 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
642 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
643 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
645 y
= FLIP(xmesa
->xm_buffer
, y
);
647 for (i
=0;i
<n
;i
++,x
++) {
649 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
650 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
655 /* draw all pixels */
656 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
657 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
659 ptr2
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
661 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
667 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap.
669 static void write_span_DITHER_5R6G5B_pixmap( RGBA_SPAN_ARGS
)
671 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
672 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
673 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
674 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
676 y
= FLIP(xmesa
->xm_buffer
, y
);
678 for (i
=0;i
<n
;i
++,x
++) {
681 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
682 XMesaSetForeground( dpy
, gc
, p
);
683 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
688 /* draw all pixels */
689 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
690 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
692 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
694 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
700 * Write a span of PF_5R6G5B pixels to a pixmap (no alpha).
702 static void write_span_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS
)
704 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
705 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
706 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
707 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
709 y
= FLIP(xmesa
->xm_buffer
, y
);
711 for (i
=0;i
<n
;i
++,x
++) {
713 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
714 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
719 /* draw all pixels */
720 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
721 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
723 ptr2
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
725 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
731 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap (no alpha).
733 static void write_span_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS
)
735 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
736 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
737 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
738 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
740 y
= FLIP(xmesa
->xm_buffer
, y
);
742 for (i
=0;i
<n
;i
++,x
++) {
745 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
746 XMesaSetForeground( dpy
, gc
, p
);
747 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
752 /* draw all pixels */
753 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
754 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
756 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
758 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
765 * Write a span of PF_DITHER pixels to a pixmap.
767 static void write_span_DITHER_pixmap( RGBA_SPAN_ARGS
)
769 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
770 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
771 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
772 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
775 y
= FLIP(xmesa
->xm_buffer
, y
);
777 for (i
=0;i
<n
;i
++,x
++) {
779 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
780 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
785 /* draw all pixels */
786 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
788 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
790 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
796 * Write a span of PF_DITHER pixels to a pixmap (no alpha).
798 static void write_span_rgb_DITHER_pixmap( RGB_SPAN_ARGS
)
800 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
801 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
802 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
803 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
806 y
= FLIP(xmesa
->xm_buffer
, y
);
808 for (i
=0;i
<n
;i
++,x
++) {
810 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
811 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
816 /* draw all pixels */
817 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
819 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
821 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
827 * Write a span of PF_1BIT pixels to a pixmap.
829 static void write_span_1BIT_pixmap( RGBA_SPAN_ARGS
)
831 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
832 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
833 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
834 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
837 y
= FLIP(xmesa
->xm_buffer
, y
);
839 for (i
=0;i
<n
;i
++,x
++) {
841 XMesaSetForeground( dpy
, gc
,
842 DITHER_1BIT( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
843 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
848 /* draw all pixels */
849 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
851 XMesaPutPixel( rowimg
, i
, 0,
852 DITHER_1BIT( x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
854 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
860 * Write a span of PF_1BIT pixels to a pixmap (no alpha).
862 static void write_span_rgb_1BIT_pixmap( RGB_SPAN_ARGS
)
864 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
865 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
866 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
867 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
870 y
= FLIP(xmesa
->xm_buffer
, y
);
872 for (i
=0;i
<n
;i
++,x
++) {
874 XMesaSetForeground( dpy
, gc
,
875 DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
876 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
881 /* draw all pixels */
882 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
884 XMesaPutPixel( rowimg
, i
, 0,
885 DITHER_1BIT(x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
887 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
893 * Write a span of PF_HPCR pixels to a pixmap.
895 static void write_span_HPCR_pixmap( RGBA_SPAN_ARGS
)
897 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
898 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
899 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
900 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
902 y
= FLIP(xmesa
->xm_buffer
, y
);
904 for (i
=0;i
<n
;i
++,x
++) {
906 XMesaSetForeground( dpy
, gc
,
907 DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
908 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
913 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
914 register GLubyte
*ptr
= (GLubyte
*) xmesa
->xm_buffer
->rowimage
->data
;
916 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
918 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
924 * Write a span of PF_HPCR pixels to a pixmap (no alpha).
926 static void write_span_rgb_HPCR_pixmap( RGB_SPAN_ARGS
)
928 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
929 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
930 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
931 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
933 y
= FLIP(xmesa
->xm_buffer
, y
);
935 for (i
=0;i
<n
;i
++,x
++) {
937 XMesaSetForeground( dpy
, gc
,
938 DITHER_HPCR(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
939 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
944 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
945 register GLubyte
*ptr
= (GLubyte
*) xmesa
->xm_buffer
->rowimage
->data
;
947 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
949 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
955 * Write a span of PF_LOOKUP pixels to a pixmap.
957 static void write_span_LOOKUP_pixmap( RGBA_SPAN_ARGS
)
959 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
960 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
961 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
962 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
965 y
= FLIP(xmesa
->xm_buffer
, y
);
967 for (i
=0;i
<n
;i
++,x
++) {
969 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
970 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
975 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
977 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
979 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
985 * Write a span of PF_LOOKUP pixels to a pixmap (no alpha).
987 static void write_span_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS
)
989 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
990 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
991 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
992 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
995 y
= FLIP(xmesa
->xm_buffer
, y
);
997 for (i
=0;i
<n
;i
++,x
++) {
999 XMesaSetForeground( dpy
, gc
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1000 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1005 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1007 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1009 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1016 * Write a span of PF_GRAYSCALE pixels to a pixmap.
1018 static void write_span_GRAYSCALE_pixmap( RGBA_SPAN_ARGS
)
1020 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1021 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1022 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
1023 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
1025 y
= FLIP(xmesa
->xm_buffer
, y
);
1027 for (i
=0;i
<n
;i
++,x
++) {
1029 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1030 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1035 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1037 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
1039 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1045 * Write a span of PF_GRAYSCALE pixels to a pixmap (no alpha).
1047 static void write_span_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS
)
1049 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1050 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1051 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
1052 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
1054 y
= FLIP(xmesa
->xm_buffer
, y
);
1056 for (i
=0;i
<n
;i
++,x
++) {
1058 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1059 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1064 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1066 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1068 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1074 * Write a span of PF_TRUECOLOR pixels to an XImage.
1076 static void write_span_TRUECOLOR_ximage( RGBA_SPAN_ARGS
)
1078 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1079 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1081 y
= FLIP(xmesa
->xm_buffer
, y
);
1083 for (i
=0;i
<n
;i
++,x
++) {
1086 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1087 XMesaPutPixel( img
, x
, y
, p
);
1092 /* draw all pixels */
1093 for (i
=0;i
<n
;i
++,x
++) {
1095 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1096 XMesaPutPixel( img
, x
, y
, p
);
1103 * Write a span of PF_TRUECOLOR pixels to an XImage (no alpha).
1105 static void write_span_rgb_TRUECOLOR_ximage( RGB_SPAN_ARGS
)
1107 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1108 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1110 y
= FLIP(xmesa
->xm_buffer
, y
);
1112 for (i
=0;i
<n
;i
++,x
++) {
1115 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1116 XMesaPutPixel( img
, x
, y
, p
);
1121 /* draw all pixels */
1122 for (i
=0;i
<n
;i
++,x
++) {
1124 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1125 XMesaPutPixel( img
, x
, y
, p
);
1132 * Write a span of PF_TRUEDITHER pixels to an XImage.
1134 static void write_span_TRUEDITHER_ximage( RGBA_SPAN_ARGS
)
1136 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1137 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1139 y
= FLIP(xmesa
->xm_buffer
, y
);
1141 for (i
=0;i
<n
;i
++,x
++) {
1144 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1145 XMesaPutPixel( img
, x
, y
, p
);
1150 /* draw all pixels */
1151 for (i
=0;i
<n
;i
++,x
++) {
1153 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1154 XMesaPutPixel( img
, x
, y
, p
);
1161 * Write a span of PF_TRUEDITHER pixels to an XImage (no alpha).
1163 static void write_span_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS
)
1165 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1166 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1168 y
= FLIP(xmesa
->xm_buffer
, y
);
1170 for (i
=0;i
<n
;i
++,x
++) {
1173 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1174 XMesaPutPixel( img
, x
, y
, p
);
1179 /* draw all pixels */
1180 for (i
=0;i
<n
;i
++,x
++) {
1182 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1183 XMesaPutPixel( img
, x
, y
, p
);
1190 * Write a span of PF_8A8B8G8R-format pixels to an ximage.
1192 static void write_span_8A8B8G8R_ximage( RGBA_SPAN_ARGS
)
1194 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1196 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1200 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1205 /* draw all pixels */
1207 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1214 * Write a span of PF_8A8B8G8R-format pixels to an ximage (no alpha).
1216 static void write_span_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS
)
1218 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1220 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1224 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1229 /* draw all pixels */
1231 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1238 * Write a span of PF_8R8G8B-format pixels to an ximage.
1240 static void write_span_8R8G8B_ximage( RGBA_SPAN_ARGS
)
1242 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1244 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1248 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1254 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1261 * Write a span of PF_8R8G8B24-format pixels to an ximage.
1263 static void write_span_8R8G8B24_ximage( RGBA_SPAN_ARGS
)
1265 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1267 register GLubyte
*ptr
= (GLubyte
*) PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
1271 GLuint
*ptr4
= (GLuint
*) ptr
;
1272 register GLuint pixel
= *ptr4
;
1273 switch (3 & (int)(ptr
- (GLubyte
*)ptr4
)) {
1275 pixel
&= 0xff000000;
1276 pixel
|= rgba
[i
][BCOMP
];
1277 pixel
|= rgba
[i
][GCOMP
] << 8;
1278 pixel
|= rgba
[i
][RCOMP
] << 16;
1282 pixel
&= 0x00ffffff;
1283 pixel
|= rgba
[i
][BCOMP
] << 24;
1285 pixel
= *ptr4
&& 0xffff0000;
1286 pixel
|= rgba
[i
][GCOMP
];
1287 pixel
|= rgba
[i
][RCOMP
] << 8;
1291 pixel
&= 0x0000ffff;
1292 pixel
|= rgba
[i
][BCOMP
] << 16;
1293 pixel
|= rgba
[i
][GCOMP
] << 24;
1295 pixel
= *ptr4
&& 0xffffff00;
1296 pixel
|= rgba
[i
][RCOMP
];
1300 pixel
&= 0x000000ff;
1301 pixel
|= rgba
[i
][BCOMP
] << 8;
1302 pixel
|= rgba
[i
][GCOMP
] << 16;
1303 pixel
|= rgba
[i
][RCOMP
] << 24;
1312 /* write all pixels */
1314 GLuint
*ptr4
= (GLuint
*) ptr
;
1315 register GLuint pixel
= *ptr4
;
1316 int index
= (int)(ptr
- (GLubyte
*)ptr4
);
1317 register GLuint i
= 0;
1322 pixel
&= 0x00ffffff;
1323 pixel
|= rgba
[i
][BCOMP
] << 24;
1325 pixel
= *ptr4
&& 0xffff0000;
1326 pixel
|= rgba
[i
][GCOMP
];
1327 pixel
|= rgba
[i
++][RCOMP
] << 8;
1332 pixel
&= 0x0000ffff;
1333 pixel
|= rgba
[i
][BCOMP
] << 16;
1334 pixel
|= rgba
[i
][GCOMP
] << 24;
1336 pixel
= *ptr4
&& 0xffffff00;
1337 pixel
|= rgba
[i
++][RCOMP
];
1342 pixel
&= 0x000000ff;
1343 pixel
|= rgba
[i
][BCOMP
] << 8;
1344 pixel
|= rgba
[i
][GCOMP
] << 16;
1345 pixel
|= rgba
[i
++][RCOMP
] << 24;
1352 pixel
= rgba
[i
][BCOMP
];
1353 pixel
|= rgba
[i
][GCOMP
] << 8;
1354 pixel
|= rgba
[i
++][RCOMP
] << 16;
1355 pixel
|= rgba
[i
][BCOMP
] << 24;
1357 pixel
= rgba
[i
][GCOMP
];
1358 pixel
|= rgba
[i
++][RCOMP
] << 8;
1359 pixel
|= rgba
[i
][BCOMP
] << 16;
1360 pixel
|= rgba
[i
][GCOMP
] << 24;
1362 pixel
= rgba
[i
++][RCOMP
];
1363 pixel
|= rgba
[i
][BCOMP
] << 8;
1364 pixel
|= rgba
[i
][GCOMP
] << 16;
1365 pixel
|= rgba
[i
++][RCOMP
] << 24;
1373 pixel
= *ptr4
& 0xff000000;
1374 pixel
|= rgba
[i
][BCOMP
];
1375 pixel
|= rgba
[i
][GCOMP
] << 8;
1376 pixel
|= rgba
[i
][RCOMP
] << 16;
1380 pixel
= rgba
[i
][BCOMP
];
1381 pixel
|= rgba
[i
][GCOMP
] << 8;
1382 pixel
|= rgba
[i
++][RCOMP
] << 16;
1383 pixel
|= rgba
[i
][BCOMP
] << 24;
1385 pixel
= *ptr4
& 0xffff0000;
1386 pixel
|= rgba
[i
][GCOMP
];
1387 pixel
|= rgba
[i
][RCOMP
] << 8;
1391 pixel
= rgba
[i
][BCOMP
];
1392 pixel
|= rgba
[i
][GCOMP
] << 8;
1393 pixel
|= rgba
[i
++][RCOMP
] << 16;
1394 pixel
|= rgba
[i
][BCOMP
] << 24;
1396 pixel
= rgba
[i
][GCOMP
];
1397 pixel
|= rgba
[i
++][RCOMP
] << 8;
1398 pixel
|= rgba
[i
][BCOMP
] << 16;
1399 pixel
|= rgba
[i
][GCOMP
] << 24;
1401 pixel
= *ptr4
& 0xffffff00;
1402 pixel
|= rgba
[i
][RCOMP
];
1411 * Write a span of PF_8R8G8B-format pixels to an ximage (no alpha).
1413 static void write_span_rgb_8R8G8B_ximage( RGB_SPAN_ARGS
)
1415 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1417 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1421 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1426 /* draw all pixels */
1428 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1435 * Write a span of PF_8R8G8B24-format pixels to an ximage (no alpha).
1437 static void write_span_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS
)
1439 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1441 register GLubyte
*ptr
= (GLubyte
*) PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
1445 *ptr
++ = rgb
[i
][BCOMP
];
1446 *ptr
++ = rgb
[i
][GCOMP
];
1447 *ptr
++ = rgb
[i
][RCOMP
];
1455 /* draw all pixels */
1457 *ptr
++ = rgb
[i
][BCOMP
];
1458 *ptr
++ = rgb
[i
][GCOMP
];
1459 *ptr
++ = rgb
[i
][RCOMP
];
1466 * Write a span of PF_5R6G5B-format pixels to an ximage.
1468 static void write_span_5R6G5B_ximage( RGBA_SPAN_ARGS
)
1470 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1472 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1476 ptr
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1481 /* draw all pixels */
1482 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1483 GLuint
*ptr32
= (GLuint
*) ptr
;
1484 GLuint extraPixel
= (n
& 1);
1486 for (i
= 0; i
< n
; i
+= 2) {
1488 p0
= PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1489 p1
= PACK_5R6G5B(rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
]);
1490 *ptr32
++ = (p1
<< 16) | p0
;
1493 ptr
[n
] = PACK_5R6G5B(rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1496 for (i
= 0; i
< n
; i
++) {
1497 ptr
[i
] = PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1505 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage.
1507 static void write_span_DITHER_5R6G5B_ximage( RGBA_SPAN_ARGS
)
1509 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1511 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1512 const GLint y2
= FLIP(xmesa
->xm_buffer
, y
);
1514 for (i
=0;i
<n
;i
++,x
++) {
1516 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1521 /* draw all pixels */
1522 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1523 GLuint
*ptr32
= (GLuint
*) ptr
;
1524 GLuint extraPixel
= (n
& 1);
1526 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1528 PACK_TRUEDITHER( p0
, x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1529 PACK_TRUEDITHER( p1
, x
+1, y2
, rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
] );
1530 *ptr32
++ = (p1
<< 16) | p0
;
1533 PACK_TRUEDITHER( ptr
[n
], x
+n
, y2
, rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1536 for (i
= 0; i
< n
; i
++, x
++) {
1537 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1545 * Write a span of PF_5R6G5B-format pixels to an ximage (no alpha).
1547 static void write_span_rgb_5R6G5B_ximage( RGB_SPAN_ARGS
)
1549 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1551 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1555 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1560 /* draw all pixels */
1561 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1562 GLuint
*ptr32
= (GLuint
*) ptr
;
1563 GLuint extraPixel
= (n
& 1);
1565 for (i
= 0; i
< n
; i
+= 2) {
1567 p0
= PACK_5R6G5B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1568 p1
= PACK_5R6G5B(rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
]);
1569 *ptr32
++ = (p1
<< 16) | p0
;
1572 ptr
[n
] = PACK_5R6G5B(rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1576 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1584 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage (no alpha).
1586 static void write_span_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS
)
1588 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1590 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1592 for (i
=0;i
<n
;i
++,x
++) {
1594 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1599 /* draw all pixels */
1600 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1601 GLuint
*ptr32
= (GLuint
*) ptr
;
1602 GLuint extraPixel
= (n
& 1);
1604 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1606 PACK_TRUEDITHER( p0
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1607 PACK_TRUEDITHER( p1
, x
+1, y
, rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
] );
1608 *ptr32
++ = (p1
<< 16) | p0
;
1611 PACK_TRUEDITHER( ptr
[n
], x
+n
, y
, rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1614 for (i
=0;i
<n
;i
++,x
++) {
1615 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1623 * Write a span of PF_DITHER pixels to an XImage.
1625 static void write_span_DITHER_ximage( RGBA_SPAN_ARGS
)
1627 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1628 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1630 int yy
= FLIP(xmesa
->xm_buffer
, y
);
1633 for (i
=0;i
<n
;i
++,x
++) {
1635 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1640 /* draw all pixels */
1641 for (i
=0;i
<n
;i
++,x
++) {
1642 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1649 * Write a span of PF_DITHER pixels to an XImage (no alpha).
1651 static void write_span_rgb_DITHER_ximage( RGB_SPAN_ARGS
)
1653 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1654 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1656 int yy
= FLIP(xmesa
->xm_buffer
, y
);
1659 for (i
=0;i
<n
;i
++,x
++) {
1661 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1666 /* draw all pixels */
1667 for (i
=0;i
<n
;i
++,x
++) {
1668 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1676 * Write a span of 8-bit PF_DITHER pixels to an XImage.
1678 static void write_span_DITHER8_ximage( RGBA_SPAN_ARGS
)
1680 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1682 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1685 for (i
=0;i
<n
;i
++,x
++) {
1687 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1692 for (i
=0;i
<n
;i
++,x
++) {
1693 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1699 static void write_span_rgb_DITHER8_ximage( RGB_SPAN_ARGS
)
1701 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1703 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1706 for (i
=0;i
<n
;i
++,x
++) {
1708 ptr
[i
] = (GLubyte
) XDITHER( x
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
1713 const GLubyte
*data
= (GLubyte
*) rgb
;
1714 for (i
=0;i
<n
;i
++,x
++) {
1715 /*ptr[i] = XDITHER( x, rgb[i][0], rgb[i][1], rgb[i][2] );*/
1716 ptr
[i
] = (GLubyte
) XDITHER( x
, data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
1724 * Write a span of PF_1BIT pixels to an XImage.
1726 static void write_span_1BIT_ximage( RGBA_SPAN_ARGS
)
1728 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1729 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1732 y
= FLIP(xmesa
->xm_buffer
, y
);
1734 for (i
=0;i
<n
;i
++,x
++) {
1736 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]));
1741 for (i
=0;i
<n
;i
++,x
++) {
1742 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
1749 * Write a span of PF_1BIT pixels to an XImage (no alpha).
1751 static void write_span_rgb_1BIT_ximage( RGB_SPAN_ARGS
)
1753 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1754 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1757 y
= FLIP(xmesa
->xm_buffer
, y
);
1759 for (i
=0;i
<n
;i
++,x
++) {
1761 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]));
1766 for (i
=0;i
<n
;i
++,x
++) {
1767 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
1774 * Write a span of PF_HPCR pixels to an XImage.
1776 static void write_span_HPCR_ximage( RGBA_SPAN_ARGS
)
1778 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1780 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1782 for (i
=0;i
<n
;i
++,x
++) {
1784 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1789 /* draw all pixels */
1790 for (i
=0;i
<n
;i
++,x
++) {
1791 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1798 * Write a span of PF_HPCR pixels to an XImage (no alpha).
1800 static void write_span_rgb_HPCR_ximage( RGB_SPAN_ARGS
)
1802 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1804 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1806 for (i
=0;i
<n
;i
++,x
++) {
1808 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1813 /* draw all pixels */
1814 for (i
=0;i
<n
;i
++,x
++) {
1815 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1822 * Write a span of PF_LOOKUP pixels to an XImage.
1824 static void write_span_LOOKUP_ximage( RGBA_SPAN_ARGS
)
1826 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1827 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1830 y
= FLIP(xmesa
->xm_buffer
, y
);
1832 for (i
=0;i
<n
;i
++,x
++) {
1834 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1839 /* draw all pixels */
1840 for (i
=0;i
<n
;i
++,x
++) {
1841 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1848 * Write a span of PF_LOOKUP pixels to an XImage (no alpha).
1850 static void write_span_rgb_LOOKUP_ximage( RGB_SPAN_ARGS
)
1852 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1853 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1856 y
= FLIP(xmesa
->xm_buffer
, y
);
1858 for (i
=0;i
<n
;i
++,x
++) {
1860 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1865 /* draw all pixels */
1866 for (i
=0;i
<n
;i
++,x
++) {
1867 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1874 * Write a span of 8-bit PF_LOOKUP pixels to an XImage.
1876 static void write_span_LOOKUP8_ximage( RGBA_SPAN_ARGS
)
1878 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1880 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1883 for (i
=0;i
<n
;i
++,x
++) {
1885 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1890 /* draw all pixels */
1891 for (i
=0;i
<n
;i
++,x
++) {
1892 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1898 static void write_rgb_LOOKUP8_ximage( const GLcontext
*ctx
,
1899 GLuint n
, GLint x
, GLint y
,
1900 CONST GLubyte rgb
[][3],
1901 const GLubyte mask
[] )
1903 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1905 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1908 for (i
=0;i
<n
;i
++,x
++) {
1910 ptr
[i
] = (GLubyte
) LOOKUP( rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
1915 /* draw all pixels */
1916 const GLubyte
*data
= (GLubyte
*) rgb
;
1917 for (i
=0;i
<n
;i
++,x
++) {
1918 /*ptr[i] = LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );*/
1919 ptr
[i
] = (GLubyte
) LOOKUP( data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
1926 * Write a span of PF_GRAYSCALE pixels to an XImage.
1928 static void write_span_GRAYSCALE_ximage( RGBA_SPAN_ARGS
)
1930 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1931 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1933 y
= FLIP(xmesa
->xm_buffer
, y
);
1935 for (i
=0;i
<n
;i
++,x
++) {
1937 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1942 /* draw all pixels */
1943 for (i
=0;i
<n
;i
++,x
++) {
1944 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1951 * Write a span of PF_GRAYSCALE pixels to an XImage (no alpha).
1953 static void write_span_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS
)
1955 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1956 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1958 y
= FLIP(xmesa
->xm_buffer
, y
);
1960 for (i
=0;i
<n
;i
++,x
++) {
1962 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1967 /* draw all pixels */
1968 for (i
=0;i
<n
;i
++,x
++) {
1969 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1976 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage.
1978 static void write_span_GRAYSCALE8_ximage( RGBA_SPAN_ARGS
)
1980 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1982 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1986 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1991 /* draw all pixels */
1993 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2000 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage (no alpha).
2002 static void write_span_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS
)
2004 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2006 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
2010 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2015 /* draw all pixels */
2017 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2025 /**********************************************************************/
2026 /*** Write COLOR PIXEL functions ***/
2027 /**********************************************************************/
2030 #define RGBA_PIXEL_ARGS const GLcontext *ctx, \
2031 GLuint n, const GLint x[], const GLint y[], \
2032 CONST GLubyte rgba[][4], const GLubyte mask[]
2036 * Write an array of PF_TRUECOLOR pixels to a pixmap.
2038 static void write_pixels_TRUECOLOR_pixmap( RGBA_PIXEL_ARGS
)
2040 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2041 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2042 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2043 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2048 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2049 XMesaSetForeground( dpy
, gc
, p
);
2050 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2057 * Write an array of PF_TRUEDITHER pixels to a pixmap.
2059 static void write_pixels_TRUEDITHER_pixmap( RGBA_PIXEL_ARGS
)
2061 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2062 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2063 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2064 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2069 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2070 XMesaSetForeground( dpy
, gc
, p
);
2071 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2078 * Write an array of PF_8A8B8G8R pixels to a pixmap.
2080 static void write_pixels_8A8B8G8R_pixmap( RGBA_PIXEL_ARGS
)
2082 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2083 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2084 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2085 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2089 XMesaSetForeground( dpy
, gc
,
2090 PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] ));
2091 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2098 * Write an array of PF_8R8G8B pixels to a pixmap.
2100 static void write_pixels_8R8G8B_pixmap( RGBA_PIXEL_ARGS
)
2102 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2103 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2104 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2105 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2109 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2110 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2117 * Write an array of PF_8R8G8B24 pixels to a pixmap.
2119 static void write_pixels_8R8G8B24_pixmap( RGBA_PIXEL_ARGS
)
2121 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2122 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2123 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2124 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2128 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2129 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2136 * Write an array of PF_5R6G5B pixels to a pixmap.
2138 static void write_pixels_5R6G5B_pixmap( RGBA_PIXEL_ARGS
)
2140 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2141 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2142 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2143 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2147 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2148 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2155 * Write an array of PF_DITHER_5R6G5B pixels to a pixmap.
2157 static void write_pixels_DITHER_5R6G5B_pixmap( RGBA_PIXEL_ARGS
)
2159 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2160 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2161 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2162 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2167 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2168 XMesaSetForeground( dpy
, gc
, p
);
2169 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2176 * Write an array of PF_DITHER pixels to a pixmap.
2178 static void write_pixels_DITHER_pixmap( RGBA_PIXEL_ARGS
)
2180 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2181 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2182 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2183 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2188 XMesaSetForeground( dpy
, gc
,
2189 DITHER(x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2190 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2197 * Write an array of PF_1BIT pixels to a pixmap.
2199 static void write_pixels_1BIT_pixmap( RGBA_PIXEL_ARGS
)
2201 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2202 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2203 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2204 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2209 XMesaSetForeground( dpy
, gc
,
2210 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2211 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2218 * Write an array of PF_HPCR pixels to a pixmap.
2220 static void write_pixels_HPCR_pixmap( RGBA_PIXEL_ARGS
)
2222 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2223 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2224 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2225 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2229 XMesaSetForeground( dpy
, gc
,
2230 DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2231 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2238 * Write an array of PF_LOOKUP pixels to a pixmap.
2240 static void write_pixels_LOOKUP_pixmap( RGBA_PIXEL_ARGS
)
2242 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2243 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2244 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2245 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2250 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2251 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2258 * Write an array of PF_GRAYSCALE pixels to a pixmap.
2260 static void write_pixels_GRAYSCALE_pixmap( RGBA_PIXEL_ARGS
)
2262 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2263 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2264 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2265 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2269 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2270 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2277 * Write an array of PF_TRUECOLOR pixels to an ximage.
2279 static void write_pixels_TRUECOLOR_ximage( RGBA_PIXEL_ARGS
)
2281 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2282 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2287 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2288 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
2295 * Write an array of PF_TRUEDITHER pixels to an XImage.
2297 static void write_pixels_TRUEDITHER_ximage( RGBA_PIXEL_ARGS
)
2299 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2300 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2305 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2306 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
2313 * Write an array of PF_8A8B8G8R pixels to an ximage.
2315 static void write_pixels_8A8B8G8R_ximage( RGBA_PIXEL_ARGS
)
2317 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2321 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2322 *ptr
= PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
2329 * Write an array of PF_8R8G8B pixels to an ximage.
2331 static void write_pixels_8R8G8B_ximage( RGBA_PIXEL_ARGS
)
2333 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2337 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2338 *ptr
= PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2345 * Write an array of PF_8R8G8B24 pixels to an ximage.
2347 static void write_pixels_8R8G8B24_ximage( RGBA_PIXEL_ARGS
)
2349 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2353 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2354 ptr
->r
= rgba
[i
][RCOMP
];
2355 ptr
->g
= rgba
[i
][GCOMP
];
2356 ptr
->b
= rgba
[i
][BCOMP
];
2363 * Write an array of PF_5R6G5B pixels to an ximage.
2365 static void write_pixels_5R6G5B_ximage( RGBA_PIXEL_ARGS
)
2367 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2371 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2372 *ptr
= PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2379 * Write an array of PF_DITHER_5R6G5B pixels to an ximage.
2381 static void write_pixels_DITHER_5R6G5B_ximage( RGBA_PIXEL_ARGS
)
2383 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2387 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2388 PACK_TRUEDITHER( *ptr
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2395 * Write an array of PF_DITHER pixels to an XImage.
2397 static void write_pixels_DITHER_ximage( RGBA_PIXEL_ARGS
)
2399 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2400 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2405 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2406 DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2413 * Write an array of 8-bit PF_DITHER pixels to an XImage.
2415 static void write_pixels_DITHER8_ximage( RGBA_PIXEL_ARGS
)
2417 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2422 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2423 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2430 * Write an array of PF_1BIT pixels to an XImage.
2432 static void write_pixels_1BIT_ximage( RGBA_PIXEL_ARGS
)
2434 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2435 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2440 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2441 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2448 * Write an array of PF_HPCR pixels to an XImage.
2450 static void write_pixels_HPCR_ximage( RGBA_PIXEL_ARGS
)
2452 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2456 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2457 *ptr
= (GLubyte
) DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2464 * Write an array of PF_LOOKUP pixels to an XImage.
2466 static void write_pixels_LOOKUP_ximage( RGBA_PIXEL_ARGS
)
2468 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2469 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2474 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), LOOKUP(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2481 * Write an array of 8-bit PF_LOOKUP pixels to an XImage.
2483 static void write_pixels_LOOKUP8_ximage( RGBA_PIXEL_ARGS
)
2485 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2490 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2491 *ptr
= (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2498 * Write an array of PF_GRAYSCALE pixels to an XImage.
2500 static void write_pixels_GRAYSCALE_ximage( RGBA_PIXEL_ARGS
)
2502 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2503 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2507 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2508 GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2515 * Write an array of 8-bit PF_GRAYSCALE pixels to an XImage.
2517 static void write_pixels_GRAYSCALE8_ximage( RGBA_PIXEL_ARGS
)
2519 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2523 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2524 *ptr
= (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2532 /**********************************************************************/
2533 /*** Write MONO COLOR SPAN functions ***/
2534 /**********************************************************************/
2536 #define MONO_SPAN_ARGS const GLcontext *ctx, \
2537 GLuint n, GLint x, GLint y, const GLchan color[4], \
2538 const GLubyte mask[]
2542 * Write a span of identical pixels to a pixmap.
2544 static void write_span_mono_pixmap( MONO_SPAN_ARGS
)
2546 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2547 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2548 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2549 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2550 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2551 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2553 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
2554 y
= FLIP(xmesa
->xm_buffer
, y
);
2556 /* New code contributed by Jeff Epler and cleaned up by Keith
2559 for (i
= 0; i
< n
; ) {
2562 /* Identify and emit contiguous rendered pixels
2564 while (i
< n
&& (!mask
|| mask
[i
]))
2568 XMesaFillRectangle( dpy
, buffer
, gc
,
2569 (int)(x
+start
), (int) y
,
2572 /* Eat up non-rendered pixels
2574 while (i
< n
&& !mask
[i
])
2581 static void write_span_mono_index_pixmap( const GLcontext
*ctx
, GLuint n
,
2582 GLint x
, GLint y
, GLuint colorIndex
,
2583 const GLubyte mask
[] )
2585 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2586 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2587 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2588 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2590 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
2591 y
= FLIP(xmesa
->xm_buffer
, y
);
2593 for (i
= 0 ; i
< n
;) {
2596 /* Identify and emit contiguous rendered pixels
2598 while (i
< n
&& mask
[i
])
2602 XMesaFillRectangle( dpy
, buffer
, gc
,
2603 (int)(x
+start
), (int) y
,
2606 /* Eat up non-rendered pixels
2608 while (i
< n
&& !mask
[i
])
2616 * Write a span of PF_TRUEDITHER pixels to a pixmap.
2618 static void write_span_mono_TRUEDITHER_pixmap( MONO_SPAN_ARGS
)
2620 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2621 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2622 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2623 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2624 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2626 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2627 for (i
=0;i
<n
;i
++,x
++) {
2630 PACK_TRUEDITHER(p
, x
, yy
, r
, g
, b
);
2631 XMesaSetForeground( dpy
, gc
, p
);
2632 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2639 * Write a span of PF_DITHER pixels to a pixmap.
2641 static void write_span_mono_DITHER_pixmap( MONO_SPAN_ARGS
)
2643 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2644 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2645 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2646 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2647 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2649 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2651 for (i
=0;i
<n
;i
++,x
++) {
2653 XMesaSetForeground( dpy
, gc
, XDITHER( x
, r
, g
, b
) );
2654 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2661 * Write a span of PF_1BIT pixels to a pixmap.
2663 static void write_span_mono_1BIT_pixmap( MONO_SPAN_ARGS
)
2665 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2666 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2667 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2668 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2669 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2672 y
= FLIP(xmesa
->xm_buffer
, y
);
2673 for (i
=0;i
<n
;i
++,x
++) {
2675 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
, y
, r
, g
, b
) );
2676 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
2683 * Write a span of identical pixels to an XImage.
2685 static void write_span_mono_ximage( MONO_SPAN_ARGS
)
2687 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2688 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2690 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2691 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2692 y
= FLIP(xmesa
->xm_buffer
, y
);
2693 for (i
=0;i
<n
;i
++,x
++) {
2695 XMesaPutPixel( img
, x
, y
, pixel
);
2701 static void write_span_mono_index_ximage( const GLcontext
*ctx
, GLuint n
,
2704 const GLubyte mask
[] )
2706 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2707 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2709 y
= FLIP(xmesa
->xm_buffer
, y
);
2710 for (i
=0;i
<n
;i
++,x
++) {
2712 XMesaPutPixel( img
, x
, y
, colorIndex
);
2719 * Write a span of identical PF_TRUEDITHER pixels to an XImage.
2721 static void write_span_mono_TRUEDITHER_ximage( MONO_SPAN_ARGS
)
2723 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2724 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2725 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2727 y
= FLIP(xmesa
->xm_buffer
, y
);
2731 PACK_TRUEDITHER( p
, x
+i
, y
, r
, g
, b
);
2732 XMesaPutPixel( img
, x
+i
, y
, p
);
2739 * Write a span of identical 8A8B8G8R pixels to an XImage.
2741 static void write_span_mono_8A8B8G8R_ximage( MONO_SPAN_ARGS
)
2743 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2745 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2746 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2747 ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
2757 * Write a span of identical 8R8G8B pixels to an XImage.
2759 static void write_span_mono_8R8G8B_ximage( MONO_SPAN_ARGS
)
2761 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2762 const GLuint pixel
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2763 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
2766 if (!mask
|| mask
[i
]) {
2774 * Write a span of identical 8R8G8B pixels to an XImage.
2776 static void write_span_mono_8R8G8B24_ximage( MONO_SPAN_ARGS
)
2778 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2779 const GLubyte r
= color
[RCOMP
];
2780 const GLubyte g
= color
[GCOMP
];
2781 const GLubyte b
= color
[BCOMP
];
2783 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
2795 * Write a span of identical DITHER pixels to an XImage.
2797 static void write_span_mono_DITHER_ximage( MONO_SPAN_ARGS
)
2799 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2800 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2801 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2802 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2805 for (i
=0;i
<n
;i
++,x
++) {
2807 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, r
, g
, b
) );
2814 * Write a span of identical 8-bit DITHER pixels to an XImage.
2816 static void write_span_mono_DITHER8_ximage( MONO_SPAN_ARGS
)
2818 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2819 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2820 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2823 for (i
=0;i
<n
;i
++,x
++) {
2825 ptr
[i
] = (GLubyte
) XDITHER( x
, r
, g
, b
);
2832 * Write a span of identical 8-bit LOOKUP pixels to an XImage.
2834 static void write_span_mono_LOOKUP8_ximage( MONO_SPAN_ARGS
)
2836 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2838 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2841 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2851 * Write a span of identical PF_1BIT pixels to an XImage.
2853 static void write_span_mono_1BIT_ximage( MONO_SPAN_ARGS
)
2855 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2856 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2857 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2860 y
= FLIP(xmesa
->xm_buffer
, y
);
2861 for (i
=0;i
<n
;i
++,x
++) {
2863 XMesaPutPixel( img
, x
, y
, DITHER_1BIT( x
, y
, r
, g
, b
) );
2870 * Write a span of identical HPCR pixels to an XImage.
2872 static void write_span_mono_HPCR_ximage( MONO_SPAN_ARGS
)
2874 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2875 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2876 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2878 for (i
=0;i
<n
;i
++,x
++) {
2880 ptr
[i
] = DITHER_HPCR( x
, y
, r
, g
, b
);
2887 * Write a span of identical 8-bit GRAYSCALE pixels to an XImage.
2889 static void write_span_mono_GRAYSCALE8_ximage( MONO_SPAN_ARGS
)
2891 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2892 const GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2893 GLubyte
*ptr
= (GLubyte
*) PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2905 * Write a span of identical PF_DITHER_5R6G5B pixels to an XImage.
2907 static void write_span_mono_DITHER_5R6G5B_ximage( MONO_SPAN_ARGS
)
2909 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2910 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
2911 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2913 y
= FLIP(xmesa
->xm_buffer
, y
);
2916 PACK_TRUEDITHER(ptr
[i
], x
+i
, y
, r
, g
, b
);
2923 /**********************************************************************/
2924 /*** Write MONO COLOR PIXELS functions ***/
2925 /**********************************************************************/
2927 #define MONO_PIXEL_ARGS const GLcontext *ctx, \
2928 GLuint n, const GLint x[], const GLint y[], \
2929 const GLchan color[4], const GLubyte mask[]
2932 * Write an array of identical pixels to a pixmap.
2934 static void write_pixels_mono_pixmap( MONO_PIXEL_ARGS
)
2936 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2937 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2938 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2939 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2941 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2942 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2943 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
2946 XMesaDrawPoint( dpy
, buffer
, gc
,
2947 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2953 static void write_pixels_mono_index_pixmap(const GLcontext
*ctx
,
2955 const GLint x
[], const GLint y
[],
2957 const GLubyte mask
[] )
2959 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2960 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2961 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2962 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2964 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
2967 XMesaDrawPoint( dpy
, buffer
, gc
,
2968 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2975 * Write an array of PF_TRUEDITHER pixels to a pixmap.
2977 static void write_pixels_mono_TRUEDITHER_pixmap( MONO_PIXEL_ARGS
)
2979 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2980 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2981 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2982 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2984 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2988 PACK_TRUEDITHER(p
, x
[i
], y
[i
], r
, g
, b
);
2989 XMesaSetForeground( dpy
, gc
, p
);
2990 XMesaDrawPoint( dpy
, buffer
, gc
,
2991 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2998 * Write an array of PF_DITHER pixels to a pixmap.
3000 static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS
)
3002 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3003 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3004 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3005 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3007 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3011 XMesaSetForeground( dpy
, gc
, DITHER( x
[i
], y
[i
], r
, g
, b
) );
3012 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3019 * Write an array of PF_1BIT pixels to a pixmap.
3021 static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS
)
3023 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3024 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3025 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3026 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3028 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3032 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
) );
3033 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3040 * Write an array of identical pixels to an XImage.
3042 static void write_pixels_mono_ximage( MONO_PIXEL_ARGS
)
3044 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3045 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3047 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
3048 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3051 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), pixel
);
3057 static void write_pixels_mono_index_ximage( const GLcontext
*ctx
, GLuint n
,
3058 const GLint x
[], const GLint y
[],
3060 const GLubyte mask
[] )
3062 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3063 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3067 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), colorIndex
);
3074 * Write an array of identical TRUEDITHER pixels to an XImage.
3076 static void write_pixels_mono_TRUEDITHER_ximage( MONO_PIXEL_ARGS
)
3078 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3079 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3081 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3085 PACK_TRUEDITHER(p
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), r
, g
, b
);
3086 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
3094 * Write an array of identical 8A8B8G8R pixels to an XImage
3096 static void write_pixels_mono_8A8B8G8R_ximage( MONO_PIXEL_ARGS
)
3098 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3099 const GLuint p
= PACK_8A8B8G8R(color
[RCOMP
], color
[GCOMP
],
3100 color
[BCOMP
], color
[ACOMP
]);
3104 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3112 * Write an array of identical 8R8G8B pixels to an XImage.
3114 static void write_pixels_mono_8R8G8B_ximage( MONO_PIXEL_ARGS
)
3116 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3118 const GLuint p
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3121 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3129 * Write an array of identical 8R8G8B pixels to an XImage.
3131 static void write_pixels_mono_8R8G8B24_ximage( MONO_PIXEL_ARGS
)
3133 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3134 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3138 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3148 * Write an array of identical PF_DITHER pixels to an XImage.
3150 static void write_pixels_mono_DITHER_ximage( MONO_PIXEL_ARGS
)
3152 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3153 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3154 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3159 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), DITHER( x
[i
], y
[i
], r
, g
, b
) );
3166 * Write an array of identical 8-bit PF_DITHER pixels to an XImage.
3168 static void write_pixels_mono_DITHER8_ximage( MONO_PIXEL_ARGS
)
3170 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3171 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3176 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3177 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], r
, g
, b
);
3184 * Write an array of identical 8-bit PF_LOOKUP pixels to an XImage.
3186 static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS
)
3188 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3192 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3195 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3204 * Write an array of identical PF_1BIT pixels to an XImage.
3206 static void write_pixels_mono_1BIT_ximage( MONO_PIXEL_ARGS
)
3208 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3209 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3210 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3215 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
3216 DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
));
3223 * Write an array of identical PF_HPCR pixels to an XImage.
3225 static void write_pixels_mono_HPCR_ximage( MONO_PIXEL_ARGS
)
3227 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3228 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3232 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3233 *ptr
= DITHER_HPCR( x
[i
], y
[i
], r
, g
, b
);
3240 * Write an array of identical 8-bit PF_GRAYSCALE pixels to an XImage.
3242 static void write_pixels_mono_GRAYSCALE8_ximage( MONO_PIXEL_ARGS
)
3244 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3246 register GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3249 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3257 * Write an array of identical PF_DITHER_5R6G5B pixels to an XImage.
3259 static void write_pixels_mono_DITHER_5R6G5B_ximage( MONO_PIXEL_ARGS
)
3261 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3262 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3266 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3267 PACK_TRUEDITHER(*ptr
, x
[i
], y
[i
], r
, g
, b
);
3274 /**********************************************************************/
3275 /*** Write INDEX SPAN functions ***/
3276 /**********************************************************************/
3278 #define INDEX_SPAN_ARGS const GLcontext *ctx, \
3279 GLuint n, GLint x, GLint y, const GLuint index[], \
3280 const GLubyte mask[]
3282 #define INDEX8_SPAN_ARGS const GLcontext *ctx, \
3283 GLuint n, GLint x, GLint y, const GLubyte index[], \
3284 const GLubyte mask[]
3288 * Write a span of CI pixels to a Pixmap.
3290 static void write_span_index_pixmap( INDEX_SPAN_ARGS
)
3292 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3293 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3294 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3295 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3297 y
= FLIP(xmesa
->xm_buffer
, y
);
3299 for (i
=0;i
<n
;i
++,x
++) {
3301 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3302 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3307 for (i
=0;i
<n
;i
++,x
++) {
3308 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3309 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3316 * Write a span of 8-bit CI pixels to a Pixmap.
3318 static void write_span_index8_pixmap( INDEX8_SPAN_ARGS
)
3320 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3321 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3322 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3323 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3325 y
= FLIP(xmesa
->xm_buffer
, y
);
3327 for (i
=0;i
<n
;i
++,x
++) {
3329 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3330 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3335 for (i
=0;i
<n
;i
++,x
++) {
3336 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3337 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3344 * Write a span of CI pixels to an XImage.
3346 static void write_span_index_ximage( INDEX_SPAN_ARGS
)
3348 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3349 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3351 y
= FLIP(xmesa
->xm_buffer
, y
);
3353 for (i
=0;i
<n
;i
++,x
++) {
3355 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3360 for (i
=0;i
<n
;i
++,x
++) {
3361 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3368 * Write a span of 8-bit CI pixels to a non 8-bit XImage.
3370 static void write_span_index8_ximage( INDEX8_SPAN_ARGS
)
3372 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3377 XMesaPutPixel(xmesa
->xm_buffer
->backimage
, x
+i
, y
, index
[i
]);
3384 XMesaPutPixel(xmesa
->xm_buffer
->backimage
, x
+i
, y
, index
[i
]);
3390 * Write a span of 8-bit CI pixels to an 8-bit XImage.
3392 static void write_span_index8_ximage8( INDEX8_SPAN_ARGS
)
3394 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3395 GLubyte
*dst
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
3405 MEMCPY( dst
, index
, n
);
3411 /**********************************************************************/
3412 /*** Write INDEX PIXELS functions ***/
3413 /**********************************************************************/
3415 #define INDEX_PIXELS_ARGS const GLcontext *ctx, \
3416 GLuint n, const GLint x[], const GLint y[], \
3417 const GLuint index[], const GLubyte mask[]
3421 * Write an array of CI pixels to a Pixmap.
3423 static void write_pixels_index_pixmap( INDEX_PIXELS_ARGS
)
3425 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3426 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3427 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3428 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3432 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3433 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3440 * Write an array of CI pixels to an XImage.
3442 static void write_pixels_index_ximage( INDEX_PIXELS_ARGS
)
3444 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3445 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3449 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), (unsigned long) index
[i
] );
3457 /**********************************************************************/
3458 /***** Pixel reading *****/
3459 /**********************************************************************/
3464 * Read a horizontal span of color-index pixels.
3466 static void read_index_span( const GLcontext
*ctx
,
3467 GLuint n
, GLint x
, GLint y
, GLuint index
[] )
3469 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3470 XMesaBuffer source
= xmesa
->xm_buffer
;
3473 y
= FLIP(source
, y
);
3475 if (source
->buffer
) {
3476 #ifndef XFree86Server
3477 XMesaImage
*span
= NULL
;
3479 catch_xgetimage_errors( xmesa
->display
);
3480 span
= XGetImage( xmesa
->display
, source
->buffer
,
3481 x
, y
, n
, 1, AllPlanes
, ZPixmap
);
3482 error
= check_xgetimage_errors();
3483 if (span
&& !error
) {
3485 index
[i
] = (GLuint
) XMesaGetPixel( span
, i
, 0 );
3489 /* return 0 pixels */
3495 XMesaDestroyImage( span
);
3498 (*xmesa
->display
->GetImage
)(source
->buffer
,
3499 x
, y
, n
, 1, ZPixmap
,
3500 ~0L, (pointer
)index
);
3503 else if (source
->backimage
) {
3504 XMesaImage
*img
= source
->backimage
;
3505 for (i
=0;i
<n
;i
++,x
++) {
3506 index
[i
] = (GLuint
) XMesaGetPixel( img
, x
, y
);
3514 * Read a horizontal span of color pixels.
3516 static void read_color_span( const GLcontext
*ctx
,
3517 GLuint n
, GLint x
, GLint y
,
3520 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3521 XMesaBuffer source
= xmesa
->xm_buffer
;
3523 if (source
->buffer
) {
3524 /* Read from Pixmap or Window */
3525 XMesaImage
*span
= NULL
;
3527 #ifdef XFree86Server
3528 span
= XMesaCreateImage(xmesa
->xm_visual
->BitsPerPixel
, n
, 1, NULL
);
3529 span
->data
= (char *)MALLOC(span
->height
* span
->bytes_per_line
);
3530 error
= (!span
->data
);
3531 (*xmesa
->display
->GetImage
)(source
->buffer
,
3532 x
, FLIP(source
, y
), n
, 1, ZPixmap
,
3533 ~0L, (pointer
)span
->data
);
3535 catch_xgetimage_errors( xmesa
->display
);
3536 span
= XGetImage( xmesa
->display
, source
->buffer
,
3537 x
, FLIP(source
, y
), n
, 1, AllPlanes
, ZPixmap
);
3538 error
= check_xgetimage_errors();
3540 if (span
&& !error
) {
3541 switch (xmesa
->pixelformat
) {
3543 case PF_Dither_True
:
3545 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3546 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3547 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3548 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3549 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3550 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3551 GLint rShift
= xmesa
->xm_visual
->rshift
;
3552 GLint gShift
= xmesa
->xm_visual
->gshift
;
3553 GLint bShift
= xmesa
->xm_visual
->bshift
;
3557 p
= XMesaGetPixel( span
, i
, 0 );
3558 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3559 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3560 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3561 rgba
[i
][ACOMP
] = 255;
3566 case PF_Dither_5R6G5B
:
3568 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3569 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3570 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3573 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
3574 /* fast, but not quite accurate
3575 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3576 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3577 rgba[i][BCOMP] = ((p << 3) & 0xff);
3579 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
3580 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3581 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
3582 rgba
[i
][ACOMP
] = 255;
3588 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3591 GLuint p4
= *ptr4
++;
3592 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
3593 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3594 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3595 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
3601 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3604 GLuint p4
= *ptr4
++;
3605 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3606 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3607 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3608 rgba
[i
][ACOMP
] = 255;
3614 const bgr_t
*ptr3
= (bgr_t
*) span
->data
;
3617 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
3618 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
3619 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
3620 rgba
[i
][ACOMP
] = 255;
3626 GLubyte
*ptr1
= (GLubyte
*) span
->data
;
3629 GLubyte p
= *ptr1
++;
3630 rgba
[i
][RCOMP
] = p
& 0xE0;
3631 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
3632 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
3633 rgba
[i
][ACOMP
] = 255;
3641 GLubyte
*rTable
= source
->pixel_to_r
;
3642 GLubyte
*gTable
= source
->pixel_to_g
;
3643 GLubyte
*bTable
= source
->pixel_to_b
;
3644 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
3645 const GLubyte
*ptr1
= (GLubyte
*) span
->data
;
3648 unsigned long p
= *ptr1
++;
3649 rgba
[i
][RCOMP
] = rTable
[p
];
3650 rgba
[i
][GCOMP
] = gTable
[p
];
3651 rgba
[i
][BCOMP
] = bTable
[p
];
3652 rgba
[i
][ACOMP
] = 255;
3658 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
3659 rgba
[i
][RCOMP
] = rTable
[p
];
3660 rgba
[i
][GCOMP
] = gTable
[p
];
3661 rgba
[i
][BCOMP
] = bTable
[p
];
3662 rgba
[i
][ACOMP
] = 255;
3669 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
3673 p
= XMesaGetPixel( span
, i
, 0 ) ^ bitFlip
;
3674 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
3675 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
3676 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
3677 rgba
[i
][ACOMP
] = 255;
3682 _mesa_problem(NULL
,"Problem in DD.read_color_span (1)");
3687 /* return black pixels */
3690 rgba
[i
][RCOMP
] = rgba
[i
][GCOMP
] = rgba
[i
][BCOMP
] = rgba
[i
][ACOMP
] = 0;
3694 XMesaDestroyImage( span
);
3697 else if (source
->backimage
) {
3698 /* Read from XImage back buffer */
3699 switch (xmesa
->pixelformat
) {
3701 case PF_Dither_True
:
3703 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3704 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3705 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3706 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3707 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3708 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3709 GLint rShift
= xmesa
->xm_visual
->rshift
;
3710 GLint gShift
= xmesa
->xm_visual
->gshift
;
3711 GLint bShift
= xmesa
->xm_visual
->bshift
;
3712 XMesaImage
*img
= source
->backimage
;
3714 y
= FLIP(source
, y
);
3717 p
= XMesaGetPixel( img
, x
+i
, y
);
3718 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3719 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3720 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3721 rgba
[i
][ACOMP
] = 255;
3726 case PF_Dither_5R6G5B
:
3728 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3729 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3730 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3731 const GLushort
*ptr2
= PIXELADDR2( source
, x
, y
);
3733 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
3734 const GLuint
*ptr4
= (const GLuint
*) ptr2
;
3735 GLuint extraPixel
= (n
& 1);
3737 for (i
= 0; i
< n
; i
+= 2) {
3738 const GLuint p
= *ptr4
++;
3739 const GLuint p0
= p
& 0xffff;
3740 const GLuint p1
= p
>> 16;
3741 /* fast, but not quite accurate
3742 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3743 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3744 rgba[i][BCOMP] = ((p << 3) & 0xff);
3746 rgba
[i
][RCOMP
] = pixelToR
[p0
>> 11];
3747 rgba
[i
][GCOMP
] = pixelToG
[(p0
>> 5) & 0x3f];
3748 rgba
[i
][BCOMP
] = pixelToB
[p0
& 0x1f];
3749 rgba
[i
][ACOMP
] = 255;
3750 rgba
[i
+1][RCOMP
] = pixelToR
[p1
>> 11];
3751 rgba
[i
+1][GCOMP
] = pixelToG
[(p1
>> 5) & 0x3f];
3752 rgba
[i
+1][BCOMP
] = pixelToB
[p1
& 0x1f];
3753 rgba
[i
+1][ACOMP
] = 255;
3756 GLushort p
= ptr2
[n
];
3757 rgba
[n
][RCOMP
] = pixelToR
[p
>> 11];
3758 rgba
[n
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3759 rgba
[n
][BCOMP
] = pixelToB
[p
& 0x1f];
3760 rgba
[n
][ACOMP
] = 255;
3763 for (i
= 0; i
< n
; i
++) {
3764 const GLushort p
= ptr2
[i
];
3765 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
3766 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3767 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
3768 rgba
[i
][ACOMP
] = 255;
3775 const GLuint
*ptr4
= PIXELADDR4( source
, x
, y
);
3778 GLuint p4
= *ptr4
++;
3779 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
3780 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3781 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3782 rgba
[i
][ACOMP
] = (GLint
) ((p4
>> 24) & 0xff);
3788 const GLuint
*ptr4
= PIXELADDR4( source
, x
, y
);
3791 GLuint p4
= *ptr4
++;
3792 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3793 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3794 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3795 rgba
[i
][ACOMP
] = 255;
3801 const bgr_t
*ptr3
= PIXELADDR3( source
, x
, y
);
3804 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
3805 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
3806 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
3807 rgba
[i
][ACOMP
] = 255;
3813 const GLubyte
*ptr1
= PIXELADDR1( source
, x
, y
);
3816 GLubyte p
= *ptr1
++;
3817 rgba
[i
][RCOMP
] = p
& 0xE0;
3818 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
3819 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
3820 rgba
[i
][ACOMP
] = 255;
3828 const GLubyte
*rTable
= source
->pixel_to_r
;
3829 const GLubyte
*gTable
= source
->pixel_to_g
;
3830 const GLubyte
*bTable
= source
->pixel_to_b
;
3831 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
3832 GLubyte
*ptr1
= PIXELADDR1( source
, x
, y
);
3835 unsigned long p
= *ptr1
++;
3836 rgba
[i
][RCOMP
] = rTable
[p
];
3837 rgba
[i
][GCOMP
] = gTable
[p
];
3838 rgba
[i
][BCOMP
] = bTable
[p
];
3839 rgba
[i
][ACOMP
] = 255;
3843 XMesaImage
*img
= source
->backimage
;
3845 y
= FLIP(source
, y
);
3846 for (i
=0;i
<n
;i
++,x
++) {
3847 unsigned long p
= XMesaGetPixel( img
, x
, y
);
3848 rgba
[i
][RCOMP
] = rTable
[p
];
3849 rgba
[i
][GCOMP
] = gTable
[p
];
3850 rgba
[i
][BCOMP
] = bTable
[p
];
3851 rgba
[i
][ACOMP
] = 255;
3858 XMesaImage
*img
= source
->backimage
;
3859 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
3861 y
= FLIP(source
, y
);
3862 for (i
=0;i
<n
;i
++,x
++) {
3864 p
= XMesaGetPixel( img
, x
, y
) ^ bitFlip
;
3865 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
3866 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
3867 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
3868 rgba
[i
][ACOMP
] = 255;
3873 _mesa_problem(NULL
,"Problem in DD.read_color_span (2)");
3882 * Read an array of color index pixels.
3884 static void read_index_pixels( const GLcontext
*ctx
,
3885 GLuint n
, const GLint x
[], const GLint y
[],
3886 GLuint indx
[], const GLubyte mask
[] )
3888 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3890 XMesaBuffer source
= xmesa
->xm_buffer
;
3892 if (source
->buffer
) {
3895 indx
[i
] = (GLuint
) read_pixel( xmesa
->display
,
3897 x
[i
], FLIP(source
, y
[i
]) );
3901 else if (source
->backimage
) {
3902 XMesaImage
*img
= source
->backimage
;
3905 indx
[i
] = (GLuint
) XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
3913 static void read_color_pixels( const GLcontext
*ctx
,
3914 GLuint n
, const GLint x
[], const GLint y
[],
3915 GLubyte rgba
[][4], const GLubyte mask
[] )
3917 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3918 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3920 XMesaBuffer source
= xmesa
->xm_buffer
;
3921 XMesaDrawable buffer
= source
->buffer
; /* the X drawable */
3923 if (source
->buffer
) {
3924 switch (xmesa
->pixelformat
) {
3926 case PF_Dither_True
:
3928 case PF_Dither_5R6G5B
:
3930 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3931 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3932 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3933 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3934 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3935 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3936 GLint rShift
= xmesa
->xm_visual
->rshift
;
3937 GLint gShift
= xmesa
->xm_visual
->gshift
;
3938 GLint bShift
= xmesa
->xm_visual
->bshift
;
3941 unsigned long p
= read_pixel( dpy
, buffer
,
3942 x
[i
], FLIP(source
, y
[i
]) );
3943 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3944 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3945 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3946 rgba
[i
][ACOMP
] = 255;
3954 unsigned long p
= read_pixel( dpy
, buffer
,
3955 x
[i
], FLIP(source
, y
[i
]) );
3956 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xff);
3957 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
3958 rgba
[i
][BCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
3959 rgba
[i
][ACOMP
] = (GLubyte
) ((p
>> 24) & 0xff);
3966 unsigned long p
= read_pixel( dpy
, buffer
,
3967 x
[i
], FLIP(source
, y
[i
]) );
3968 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
3969 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
3970 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
3971 rgba
[i
][ACOMP
] = 255;
3978 unsigned long p
= read_pixel( dpy
, buffer
,
3979 x
[i
], FLIP(source
, y
[i
]) );
3980 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
3981 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
3982 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
3983 rgba
[i
][ACOMP
] = 255;
3991 unsigned long p
= read_pixel( dpy
, buffer
,
3992 x
[i
], FLIP(source
, y
[i
]) );
3993 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xE0 );
3994 rgba
[i
][GCOMP
] = (GLubyte
) ((p
& 0x1C) << 3);
3995 rgba
[i
][BCOMP
] = (GLubyte
) ((p
& 0x03) << 6);
3996 rgba
[i
][ACOMP
] = (GLubyte
) 255;
4005 GLubyte
*rTable
= source
->pixel_to_r
;
4006 GLubyte
*gTable
= source
->pixel_to_g
;
4007 GLubyte
*bTable
= source
->pixel_to_b
;
4010 unsigned long p
= read_pixel( dpy
, buffer
,
4011 x
[i
], FLIP(source
, y
[i
]) );
4012 rgba
[i
][RCOMP
] = rTable
[p
];
4013 rgba
[i
][GCOMP
] = gTable
[p
];
4014 rgba
[i
][BCOMP
] = bTable
[p
];
4015 rgba
[i
][ACOMP
] = 255;
4022 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4025 unsigned long p
= read_pixel( dpy
, buffer
,
4026 x
[i
], FLIP(source
, y
[i
])) ^ bitFlip
;
4027 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4028 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4029 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4030 rgba
[i
][ACOMP
] = 255;
4036 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4040 else if (source
->backimage
) {
4041 switch (xmesa
->pixelformat
) {
4043 case PF_Dither_True
:
4045 case PF_Dither_5R6G5B
:
4047 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4048 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4049 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4050 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4051 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4052 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4053 GLint rShift
= xmesa
->xm_visual
->rshift
;
4054 GLint gShift
= xmesa
->xm_visual
->gshift
;
4055 GLint bShift
= xmesa
->xm_visual
->bshift
;
4056 XMesaImage
*img
= source
->backimage
;
4060 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
4061 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4062 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4063 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4064 rgba
[i
][ACOMP
] = 255;
4072 GLuint
*ptr4
= PIXELADDR4( source
, x
[i
], y
[i
] );
4074 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
4075 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4076 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4077 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
4084 GLuint
*ptr4
= PIXELADDR4( source
, x
[i
], y
[i
] );
4086 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4087 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4088 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4089 rgba
[i
][ACOMP
] = 255;
4096 bgr_t
*ptr3
= PIXELADDR3( source
, x
[i
], y
[i
] );
4097 rgba
[i
][RCOMP
] = ptr3
->r
;
4098 rgba
[i
][GCOMP
] = ptr3
->g
;
4099 rgba
[i
][BCOMP
] = ptr3
->b
;
4100 rgba
[i
][ACOMP
] = 255;
4107 GLubyte
*ptr1
= PIXELADDR1( source
, x
[i
], y
[i
] );
4109 rgba
[i
][RCOMP
] = p
& 0xE0;
4110 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4111 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4112 rgba
[i
][ACOMP
] = 255;
4120 GLubyte
*rTable
= source
->pixel_to_r
;
4121 GLubyte
*gTable
= source
->pixel_to_g
;
4122 GLubyte
*bTable
= source
->pixel_to_b
;
4123 XMesaImage
*img
= source
->backimage
;
4127 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
4128 rgba
[i
][RCOMP
] = rTable
[p
];
4129 rgba
[i
][GCOMP
] = gTable
[p
];
4130 rgba
[i
][BCOMP
] = bTable
[p
];
4131 rgba
[i
][ACOMP
] = 255;
4138 XMesaImage
*img
= source
->backimage
;
4139 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4143 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) ) ^ bitFlip
;
4144 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4145 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4146 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4147 rgba
[i
][ACOMP
] = 255;
4153 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4161 clear_color_HPCR_ximage( GLcontext
*ctx
, const GLfloat color
[4] )
4164 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
4166 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[0], color
[0]);
4167 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[1], color
[1]);
4168 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[2], color
[2]);
4169 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[3], color
[3]);
4171 if (color
[0] == 0.0 && color
[1] == 0.0 && color
[2] == 0.0) {
4172 /* black is black */
4173 MEMSET( xmesa
->xm_visual
->hpcr_clear_ximage_pattern
, 0x0 ,
4174 sizeof(xmesa
->xm_visual
->hpcr_clear_ximage_pattern
));
4177 /* build clear pattern */
4178 for (i
=0; i
<16; i
++) {
4179 xmesa
->xm_visual
->hpcr_clear_ximage_pattern
[0][i
] =
4181 xmesa
->clearcolor
[0],
4182 xmesa
->clearcolor
[1],
4183 xmesa
->clearcolor
[2]);
4184 xmesa
->xm_visual
->hpcr_clear_ximage_pattern
[1][i
] =
4186 xmesa
->clearcolor
[0],
4187 xmesa
->clearcolor
[1],
4188 xmesa
->clearcolor
[2]);
4195 clear_color_HPCR_pixmap( GLcontext
*ctx
, const GLfloat color
[4] )
4198 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
4200 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[0], color
[0]);
4201 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[1], color
[1]);
4202 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[2], color
[2]);
4203 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[3], color
[3]);
4205 if (color
[0] == 0.0 && color
[1] == 0.0 && color
[2] == 0.0) {
4206 /* black is black */
4207 for (i
=0; i
<16; i
++) {
4208 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 0, 0);
4209 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 1, 0);
4213 for (i
=0; i
<16; i
++) {
4214 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 0,
4216 xmesa
->clearcolor
[0],
4217 xmesa
->clearcolor
[1],
4218 xmesa
->clearcolor
[2]));
4219 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 1,
4221 xmesa
->clearcolor
[0],
4222 xmesa
->clearcolor
[1],
4223 xmesa
->clearcolor
[2]));
4226 /* change tile pixmap content */
4227 XMesaPutImage(xmesa
->display
,
4228 (XMesaDrawable
)xmesa
->xm_visual
->hpcr_clear_pixmap
,
4229 xmesa
->xm_buffer
->cleargc
,
4230 xmesa
->xm_visual
->hpcr_clear_ximage
, 0, 0, 0, 0, 16, 2);
4235 void xmesa_update_span_funcs( GLcontext
*ctx
)
4237 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
4238 int depth
=GET_VISUAL_DEPTH(xmesa
->xm_visual
);
4239 struct swrast_device_driver
*dd
= _swrast_GetDeviceDriverReference( ctx
);
4242 * These drawing functions depend on color buffer config:
4244 if (xmesa
->xm_buffer
->buffer
!=XIMAGE
) {
4245 /* Writing to window or back pixmap */
4246 switch (xmesa
->pixelformat
) {
4248 dd
->WriteCI32Span
= write_span_index_pixmap
;
4249 dd
->WriteCI8Span
= write_span_index8_pixmap
;
4250 dd
->WriteMonoCISpan
= write_span_mono_index_pixmap
;
4251 dd
->WriteCI32Pixels
= write_pixels_index_pixmap
;
4252 dd
->WriteMonoCIPixels
= write_pixels_mono_index_pixmap
;
4255 dd
->WriteRGBASpan
= write_span_TRUECOLOR_pixmap
;
4256 dd
->WriteRGBSpan
= write_span_rgb_TRUECOLOR_pixmap
;
4257 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4258 dd
->WriteRGBAPixels
= write_pixels_TRUECOLOR_pixmap
;
4259 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4261 case PF_Dither_True
:
4262 dd
->WriteRGBASpan
= write_span_TRUEDITHER_pixmap
;
4263 dd
->WriteRGBSpan
= write_span_rgb_TRUEDITHER_pixmap
;
4264 dd
->WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_pixmap
;
4265 dd
->WriteRGBAPixels
= write_pixels_TRUEDITHER_pixmap
;
4266 dd
->WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_pixmap
;
4269 dd
->WriteRGBASpan
= write_span_8A8B8G8R_pixmap
;
4270 dd
->WriteRGBSpan
= write_span_rgb_8A8B8G8R_pixmap
;
4271 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4272 dd
->WriteRGBAPixels
= write_pixels_8A8B8G8R_pixmap
;
4273 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4276 dd
->WriteRGBASpan
= write_span_8R8G8B_pixmap
;
4277 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B_pixmap
;
4278 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4279 dd
->WriteRGBAPixels
= write_pixels_8R8G8B_pixmap
;
4280 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4283 dd
->WriteRGBASpan
= write_span_8R8G8B24_pixmap
;
4284 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B24_pixmap
;
4285 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4286 dd
->WriteRGBAPixels
= write_pixels_8R8G8B24_pixmap
;
4287 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4290 dd
->WriteRGBASpan
= write_span_5R6G5B_pixmap
;
4291 dd
->WriteRGBSpan
= write_span_rgb_5R6G5B_pixmap
;
4292 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4293 dd
->WriteRGBAPixels
= write_pixels_5R6G5B_pixmap
;
4294 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4296 case PF_Dither_5R6G5B
:
4297 dd
->WriteRGBASpan
= write_span_DITHER_5R6G5B_pixmap
;
4298 dd
->WriteRGBSpan
= write_span_rgb_DITHER_5R6G5B_pixmap
;
4299 dd
->WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_pixmap
;
4300 dd
->WriteRGBAPixels
= write_pixels_DITHER_5R6G5B_pixmap
;
4301 dd
->WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_pixmap
;
4304 dd
->WriteRGBASpan
= write_span_DITHER_pixmap
;
4305 dd
->WriteRGBSpan
= write_span_rgb_DITHER_pixmap
;
4306 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER_pixmap
;
4307 dd
->WriteRGBAPixels
= write_pixels_DITHER_pixmap
;
4308 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER_pixmap
;
4311 dd
->WriteRGBASpan
= write_span_1BIT_pixmap
;
4312 dd
->WriteRGBSpan
= write_span_rgb_1BIT_pixmap
;
4313 dd
->WriteMonoRGBASpan
= write_span_mono_1BIT_pixmap
;
4314 dd
->WriteRGBAPixels
= write_pixels_1BIT_pixmap
;
4315 dd
->WriteMonoRGBAPixels
= write_pixels_mono_1BIT_pixmap
;
4318 dd
->WriteRGBASpan
= write_span_HPCR_pixmap
;
4319 dd
->WriteRGBSpan
= write_span_rgb_HPCR_pixmap
;
4320 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4321 dd
->WriteRGBAPixels
= write_pixels_HPCR_pixmap
;
4322 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4323 if (xmesa
->xm_visual
->hpcr_clear_flag
) {
4324 ctx
->Driver
.ClearColor
= clear_color_HPCR_pixmap
;
4328 dd
->WriteRGBASpan
= write_span_LOOKUP_pixmap
;
4329 dd
->WriteRGBSpan
= write_span_rgb_LOOKUP_pixmap
;
4330 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4331 dd
->WriteRGBAPixels
= write_pixels_LOOKUP_pixmap
;
4332 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4335 dd
->WriteRGBASpan
= write_span_GRAYSCALE_pixmap
;
4336 dd
->WriteRGBSpan
= write_span_rgb_GRAYSCALE_pixmap
;
4337 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4338 dd
->WriteRGBAPixels
= write_pixels_GRAYSCALE_pixmap
;
4339 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4342 _mesa_problem(NULL
,"Bad pixel format in xmesa_update_state (1)");
4346 else if (xmesa
->xm_buffer
->buffer
==XIMAGE
) {
4347 /* Writing to back XImage */
4348 switch (xmesa
->pixelformat
) {
4350 dd
->WriteCI32Span
= write_span_index_ximage
;
4352 dd
->WriteCI8Span
= write_span_index8_ximage8
;
4354 dd
->WriteCI8Span
= write_span_index8_ximage
;
4355 dd
->WriteMonoCISpan
= write_span_mono_index_ximage
;
4356 dd
->WriteCI32Pixels
= write_pixels_index_ximage
;
4357 dd
->WriteMonoCIPixels
= write_pixels_mono_index_ximage
;
4361 dd
->WriteRGBASpan
= write_span_TRUECOLOR_ximage
;
4362 dd
->WriteRGBSpan
= write_span_rgb_TRUECOLOR_ximage
;
4363 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4364 dd
->WriteRGBAPixels
= write_pixels_TRUECOLOR_ximage
;
4365 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4367 case PF_Dither_True
:
4368 dd
->WriteRGBASpan
= write_span_TRUEDITHER_ximage
;
4369 dd
->WriteRGBSpan
= write_span_rgb_TRUEDITHER_ximage
;
4370 dd
->WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_ximage
;
4371 dd
->WriteRGBAPixels
= write_pixels_TRUEDITHER_ximage
;
4372 dd
->WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_ximage
;
4375 dd
->WriteRGBASpan
= write_span_8A8B8G8R_ximage
;
4376 dd
->WriteRGBSpan
= write_span_rgb_8A8B8G8R_ximage
;
4377 dd
->WriteMonoRGBASpan
= write_span_mono_8A8B8G8R_ximage
;
4378 dd
->WriteRGBAPixels
= write_pixels_8A8B8G8R_ximage
;
4379 dd
->WriteMonoRGBAPixels
= write_pixels_mono_8A8B8G8R_ximage
;
4382 dd
->WriteRGBASpan
= write_span_8R8G8B_ximage
;
4383 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B_ximage
;
4384 dd
->WriteMonoRGBASpan
= write_span_mono_8R8G8B_ximage
;
4385 dd
->WriteRGBAPixels
= write_pixels_8R8G8B_ximage
;
4386 dd
->WriteMonoRGBAPixels
= write_pixels_mono_8R8G8B_ximage
;
4389 dd
->WriteRGBASpan
= write_span_8R8G8B24_ximage
;
4390 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B24_ximage
;
4391 dd
->WriteMonoRGBASpan
= write_span_mono_8R8G8B24_ximage
;
4392 dd
->WriteRGBAPixels
= write_pixels_8R8G8B24_ximage
;
4393 dd
->WriteMonoRGBAPixels
= write_pixels_mono_8R8G8B24_ximage
;
4396 dd
->WriteRGBASpan
= write_span_5R6G5B_ximage
;
4397 dd
->WriteRGBSpan
= write_span_rgb_5R6G5B_ximage
;
4398 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4399 dd
->WriteRGBAPixels
= write_pixels_5R6G5B_ximage
;
4400 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4402 case PF_Dither_5R6G5B
:
4403 dd
->WriteRGBASpan
= write_span_DITHER_5R6G5B_ximage
;
4404 dd
->WriteRGBSpan
= write_span_rgb_DITHER_5R6G5B_ximage
;
4405 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER_5R6G5B_ximage
;
4406 dd
->WriteRGBAPixels
= write_pixels_DITHER_5R6G5B_ximage
;
4407 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER_5R6G5B_ximage
;
4411 dd
->WriteRGBASpan
= write_span_DITHER8_ximage
;
4412 dd
->WriteRGBSpan
= write_span_rgb_DITHER8_ximage
;
4413 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER8_ximage
;
4414 dd
->WriteRGBAPixels
= write_pixels_DITHER8_ximage
;
4415 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER8_ximage
;
4418 dd
->WriteRGBASpan
= write_span_DITHER_ximage
;
4419 dd
->WriteRGBSpan
= write_span_rgb_DITHER_ximage
;
4420 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER_ximage
;
4421 dd
->WriteRGBAPixels
= write_pixels_DITHER_ximage
;
4422 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER_ximage
;
4426 dd
->WriteRGBASpan
= write_span_1BIT_ximage
;
4427 dd
->WriteRGBSpan
= write_span_rgb_1BIT_ximage
;
4428 dd
->WriteMonoRGBASpan
= write_span_mono_1BIT_ximage
;
4429 dd
->WriteRGBAPixels
= write_pixels_1BIT_ximage
;
4430 dd
->WriteMonoRGBAPixels
= write_pixels_mono_1BIT_ximage
;
4433 dd
->WriteRGBASpan
= write_span_HPCR_ximage
;
4434 dd
->WriteRGBSpan
= write_span_rgb_HPCR_ximage
;
4435 dd
->WriteMonoRGBASpan
= write_span_mono_HPCR_ximage
;
4436 dd
->WriteRGBAPixels
= write_pixels_HPCR_ximage
;
4437 dd
->WriteMonoRGBAPixels
= write_pixels_mono_HPCR_ximage
;
4438 if (xmesa
->xm_visual
->hpcr_clear_flag
) {
4439 ctx
->Driver
.ClearColor
= clear_color_HPCR_ximage
;
4444 dd
->WriteRGBASpan
= write_span_LOOKUP8_ximage
;
4445 dd
->WriteRGBSpan
= write_rgb_LOOKUP8_ximage
;
4446 dd
->WriteMonoRGBASpan
= write_span_mono_LOOKUP8_ximage
;
4447 dd
->WriteRGBAPixels
= write_pixels_LOOKUP8_ximage
;
4448 dd
->WriteMonoRGBAPixels
= write_pixels_mono_LOOKUP8_ximage
;
4451 dd
->WriteRGBASpan
= write_span_LOOKUP_ximage
;
4452 dd
->WriteRGBSpan
= write_span_rgb_LOOKUP_ximage
;
4453 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4454 dd
->WriteRGBAPixels
= write_pixels_LOOKUP_ximage
;
4455 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4460 dd
->WriteRGBASpan
= write_span_GRAYSCALE8_ximage
;
4461 dd
->WriteRGBSpan
= write_span_rgb_GRAYSCALE8_ximage
;
4462 dd
->WriteMonoRGBASpan
= write_span_mono_GRAYSCALE8_ximage
;
4463 dd
->WriteRGBAPixels
= write_pixels_GRAYSCALE8_ximage
;
4464 dd
->WriteMonoRGBAPixels
= write_pixels_mono_GRAYSCALE8_ximage
;
4467 dd
->WriteRGBASpan
= write_span_GRAYSCALE_ximage
;
4468 dd
->WriteRGBSpan
= write_span_rgb_GRAYSCALE_ximage
;
4469 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4470 dd
->WriteRGBAPixels
= write_pixels_GRAYSCALE_ximage
;
4471 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4475 _mesa_problem(NULL
,"Bad pixel format in xmesa_update_state (2)");
4480 /* Pixel/span reading functions: */
4481 dd
->ReadCI32Span
= read_index_span
;
4482 dd
->ReadRGBASpan
= read_color_span
;
4483 dd
->ReadCI32Pixels
= read_index_pixels
;
4484 dd
->ReadRGBAPixels
= read_color_pixels
;