1 /* $Id: xm_span.c,v 1.19 2003/02/17 16:35:59 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 /* $XFree86: xc/extras/Mesa/src/X/xm_span.c,v 1.3 2002/02/27 21:07:54 tsi Exp $ */
28 #include "glxheader.h"
33 #include "extensions.h"
40 #include "swrast/swrast.h"
44 * The following functions are used to trap XGetImage() calls which
45 * generate BadMatch errors if the drawable isn't mapped.
49 static int caught_xgetimage_error
= 0;
50 static int (*old_xerror_handler
)( XMesaDisplay
*dpy
, XErrorEvent
*ev
);
51 static unsigned long xgetimage_serial
;
54 * This is the error handler which will be called if XGetImage fails.
56 static int xgetimage_error_handler( XMesaDisplay
*dpy
, XErrorEvent
*ev
)
58 if (ev
->serial
==xgetimage_serial
&& ev
->error_code
==BadMatch
) {
59 /* caught the expected error */
60 caught_xgetimage_error
= 0;
63 /* call the original X error handler, if any. otherwise ignore */
64 if (old_xerror_handler
) {
65 (*old_xerror_handler
)( dpy
, ev
);
73 * Call this right before XGetImage to setup error trap.
75 static void catch_xgetimage_errors( XMesaDisplay
*dpy
)
77 xgetimage_serial
= NextRequest( dpy
);
78 old_xerror_handler
= XSetErrorHandler( xgetimage_error_handler
);
79 caught_xgetimage_error
= 0;
84 * Call this right after XGetImage to check if an error occured.
86 static int check_xgetimage_errors( void )
88 /* restore old handler */
89 (void) XSetErrorHandler( old_xerror_handler
);
90 /* return 0=no error, 1=error caught */
91 return caught_xgetimage_error
;
97 * Read a pixel from an X drawable.
99 static unsigned long read_pixel( XMesaDisplay
*dpy
,
100 XMesaDrawable d
, int x
, int y
)
103 #ifndef XFree86Server
104 XMesaImage
*pixel
= NULL
;
107 catch_xgetimage_errors( dpy
);
108 pixel
= XGetImage( dpy
, d
, x
, y
, 1, 1, AllPlanes
, ZPixmap
);
109 error
= check_xgetimage_errors();
110 if (pixel
&& !error
) {
111 p
= XMesaGetPixel( pixel
, 0, 0 );
117 XMesaDestroyImage( pixel
);
120 (*dpy
->GetImage
)(d
, x
, y
, 1, 1, ZPixmap
, ~0L, (pointer
)&p
);
128 * The Mesa library needs to be able to draw pixels in a number of ways:
129 * 1. RGB vs Color Index
130 * 2. as horizontal spans (polygons, images) vs random locations (points,
132 * 3. different color per-pixel or same color for all pixels
134 * Furthermore, the X driver needs to support rendering to 3 possible
135 * "buffers", usually one, but sometimes two at a time:
136 * 1. The front buffer as an X window
137 * 2. The back buffer as a Pixmap
138 * 3. The back buffer as an XImage
140 * Finally, if the back buffer is an XImage, we can avoid using XPutPixel and
141 * optimize common cases such as 24-bit and 8-bit modes.
143 * By multiplication, there's at least 48 possible combinations of the above.
145 * Below are implementations of the most commonly used combinations. They are
146 * accessed through function pointers which get initialized here and are used
147 * directly from the Mesa library. The 8 function pointers directly correspond
148 * to the first 3 cases listed above.
151 * The function naming convention is:
153 * write_[span|pixels]_[mono]_[format]_[pixmap|ximage]
155 * New functions optimized for specific cases can be added without too much
156 * trouble. An example might be the 24-bit TrueColor mode 8A8R8G8B which is
157 * found on IBM RS/6000 X servers.
163 /**********************************************************************/
164 /*** Write COLOR SPAN functions ***/
165 /**********************************************************************/
168 #define RGBA_SPAN_ARGS const GLcontext *ctx, \
169 GLuint n, GLint x, GLint y, \
170 CONST GLubyte rgba[][4], const GLubyte mask[]
172 #define RGB_SPAN_ARGS const GLcontext *ctx, \
173 GLuint n, GLint x, GLint y, \
174 CONST GLubyte rgb[][3], const GLubyte mask[]
177 /* NOTE: if mask==NULL, draw all pixels */
181 * Write a span of PF_TRUECOLOR pixels to a pixmap.
183 static void write_span_TRUECOLOR_pixmap( RGBA_SPAN_ARGS
)
185 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
186 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
187 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
188 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
191 (void)DitherValues
; /* Muffle compiler */
193 y
= FLIP(xmesa
->xm_buffer
, y
);
195 for (i
=0;i
<n
;i
++,x
++) {
198 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
199 XMesaSetForeground( dpy
, gc
, p
);
200 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
205 /* draw all pixels */
206 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
209 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
210 XMesaPutPixel( rowimg
, i
, 0, p
);
212 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
218 * Write a span of PF_TRUECOLOR pixels to a pixmap.
220 static void write_span_rgb_TRUECOLOR_pixmap( RGB_SPAN_ARGS
)
222 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
223 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
224 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
225 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
227 y
= FLIP(xmesa
->xm_buffer
, y
);
229 for (i
=0;i
<n
;i
++,x
++) {
232 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
233 XMesaSetForeground( dpy
, gc
, p
);
234 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
239 /* draw all pixels */
240 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
243 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
244 XMesaPutPixel( rowimg
, i
, 0, p
);
246 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
252 * Write a span of PF_TRUEDITHER pixels to a pixmap.
254 static void write_span_TRUEDITHER_pixmap( RGBA_SPAN_ARGS
)
256 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
257 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
258 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
259 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
261 y
= FLIP(xmesa
->xm_buffer
, y
);
263 for (i
=0;i
<n
;i
++,x
++) {
266 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
267 XMesaSetForeground( dpy
, gc
, p
);
268 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
273 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
276 PACK_TRUEDITHER(p
, x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
277 XMesaPutPixel( rowimg
, i
, 0, p
);
279 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
285 * Write a span of PF_TRUEDITHER pixels to a pixmap (no alpha).
287 static void write_span_rgb_TRUEDITHER_pixmap( RGB_SPAN_ARGS
)
289 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
290 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
291 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
292 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
294 y
= FLIP(xmesa
->xm_buffer
, y
);
296 for (i
=0;i
<n
;i
++,x
++) {
299 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
300 XMesaSetForeground( dpy
, gc
, p
);
301 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
306 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
309 PACK_TRUEDITHER(p
, x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
310 XMesaPutPixel( rowimg
, i
, 0, p
);
312 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
319 * Write a span of PF_8A8B8G8R pixels to a pixmap.
321 static void write_span_8A8B8G8R_pixmap( RGBA_SPAN_ARGS
)
323 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
324 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
325 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
326 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
328 y
= FLIP(xmesa
->xm_buffer
, y
);
330 for (i
=0;i
<n
;i
++,x
++) {
332 XMesaSetForeground( dpy
, gc
,
333 PACK_8A8B8G8R(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
]) );
334 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
339 /* draw all pixels */
340 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
341 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
343 *ptr4
++ = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
345 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
351 * Write a span of PF_8A8B8G8R pixels to a pixmap (no alpha).
353 static void write_span_rgb_8A8B8G8R_pixmap( RGB_SPAN_ARGS
)
355 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
356 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
357 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
358 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
360 y
= FLIP(xmesa
->xm_buffer
, y
);
362 for (i
=0;i
<n
;i
++,x
++) {
364 XMesaSetForeground( dpy
, gc
,
365 PACK_8B8G8R(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
366 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
371 /* draw all pixels */
372 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
373 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
375 *ptr4
++ = PACK_8B8G8R(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
377 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
383 * Write a span of PF_8R8G8B pixels to a pixmap.
385 static void write_span_8R8G8B_pixmap( RGBA_SPAN_ARGS
)
387 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
388 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
389 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
390 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
392 y
= FLIP(xmesa
->xm_buffer
, y
);
394 for (i
=0;i
<n
;i
++,x
++) {
396 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
397 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
402 /* draw all pixels */
403 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
404 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
406 *ptr4
++ = PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
408 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
414 * Write a span of PF_8R8G8B24 pixels to a pixmap.
416 static void write_span_8R8G8B24_pixmap( RGBA_SPAN_ARGS
)
418 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
419 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
420 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
421 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
422 y
= FLIP(xmesa
->xm_buffer
, y
);
425 for (i
=0;i
<n
;i
++,x
++) {
427 XMesaSetForeground( dpy
, gc
,
428 PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
429 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
434 /* draw all pixels */
435 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
436 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
437 register GLuint pixel
;
438 static const GLuint shift
[4] = {0, 8, 16, 24};
439 register GLuint i
= 0;
442 pixel
= rgba
[i
][BCOMP
] /* << shift[0]*/;
443 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
444 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
445 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
448 pixel
= rgba
[i
][GCOMP
] /* << shift[0]*/;
449 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
450 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
451 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
454 pixel
= rgba
[i
++][RCOMP
]/* << shift[0]*/;
455 pixel
|= rgba
[i
][BCOMP
] << shift
[1];
456 pixel
|= rgba
[i
][GCOMP
] << shift
[2];
457 pixel
|= rgba
[i
++][RCOMP
] << shift
[3];
465 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
466 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
467 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
468 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
471 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
472 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
473 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
474 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
476 pixel
= 0xffffff00 & *ptr4
;
477 pixel
|= rgba
[i
][RCOMP
] /*<< shift[0]*/;
482 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
483 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
484 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
485 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
487 pixel
= 0xffff0000 & *ptr4
;
488 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
489 pixel
|= rgba
[i
][RCOMP
] << shift
[1];
493 pixel
= 0xff000000 & *ptr4
;
494 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
495 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
496 pixel
|= rgba
[i
][RCOMP
] << shift
[2];
502 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
508 * Write a span of PF_8R8G8B pixels to a pixmap (no alpha).
510 static void write_span_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS
)
512 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
513 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
514 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
515 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
517 y
= FLIP(xmesa
->xm_buffer
, y
);
519 for (i
=0;i
<n
;i
++,x
++) {
521 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
522 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
527 /* draw all pixels */
528 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
529 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
531 *ptr4
++ = PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
533 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
539 * Write a span of PF_8R8G8B24 pixels to a pixmap (no alpha).
541 static void write_span_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS
)
543 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
544 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
545 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
546 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
547 y
= FLIP(xmesa
->xm_buffer
, y
);
550 for (i
=0;i
<n
;i
++,x
++) {
552 XMesaSetForeground( dpy
, gc
,
553 PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
554 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
559 /* draw all pixels */
560 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
561 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
562 register GLuint pixel
;
563 static const GLuint shift
[4] = {0, 8, 16, 24};
565 register GLuint i
= 0;
568 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
569 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
570 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
571 pixel
|= rgb
[i
][BCOMP
] <<shift
[3];
575 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
576 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
577 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
578 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
582 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
583 pixel
|= rgb
[i
][BCOMP
] << shift
[1];
584 pixel
|= rgb
[i
][GCOMP
] << shift
[2];
585 pixel
|= rgb
[i
++][RCOMP
] << shift
[3];
592 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
593 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
594 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
595 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
598 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
599 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
600 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
601 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
605 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
610 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
611 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
612 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
613 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
617 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
618 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
624 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
625 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
626 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
632 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
638 * Write a span of PF_5R6G5B pixels to a pixmap.
640 static void write_span_5R6G5B_pixmap( RGBA_SPAN_ARGS
)
642 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
643 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
644 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
645 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
647 y
= FLIP(xmesa
->xm_buffer
, y
);
649 for (i
=0;i
<n
;i
++,x
++) {
651 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
652 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
657 /* draw all pixels */
658 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
659 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
661 ptr2
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
663 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
669 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap.
671 static void write_span_DITHER_5R6G5B_pixmap( RGBA_SPAN_ARGS
)
673 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
674 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
675 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
676 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
678 y
= FLIP(xmesa
->xm_buffer
, y
);
680 for (i
=0;i
<n
;i
++,x
++) {
683 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
684 XMesaSetForeground( dpy
, gc
, p
);
685 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
690 /* draw all pixels */
691 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
692 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
694 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
696 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
702 * Write a span of PF_5R6G5B pixels to a pixmap (no alpha).
704 static void write_span_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS
)
706 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
707 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
708 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
709 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
711 y
= FLIP(xmesa
->xm_buffer
, y
);
713 for (i
=0;i
<n
;i
++,x
++) {
715 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
716 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
721 /* draw all pixels */
722 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
723 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
725 ptr2
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
727 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
733 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap (no alpha).
735 static void write_span_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS
)
737 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
738 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
739 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
740 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
742 y
= FLIP(xmesa
->xm_buffer
, y
);
744 for (i
=0;i
<n
;i
++,x
++) {
747 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
748 XMesaSetForeground( dpy
, gc
, p
);
749 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
754 /* draw all pixels */
755 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
756 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
758 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
760 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
767 * Write a span of PF_DITHER pixels to a pixmap.
769 static void write_span_DITHER_pixmap( RGBA_SPAN_ARGS
)
771 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
772 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
773 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
774 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
777 y
= FLIP(xmesa
->xm_buffer
, y
);
779 for (i
=0;i
<n
;i
++,x
++) {
781 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
782 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
787 /* draw all pixels */
788 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
790 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
792 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
798 * Write a span of PF_DITHER pixels to a pixmap (no alpha).
800 static void write_span_rgb_DITHER_pixmap( RGB_SPAN_ARGS
)
802 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
803 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
804 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
805 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
808 y
= FLIP(xmesa
->xm_buffer
, y
);
810 for (i
=0;i
<n
;i
++,x
++) {
812 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
813 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
818 /* draw all pixels */
819 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
821 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
823 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
829 * Write a span of PF_1BIT pixels to a pixmap.
831 static void write_span_1BIT_pixmap( RGBA_SPAN_ARGS
)
833 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
834 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
835 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
836 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
839 y
= FLIP(xmesa
->xm_buffer
, y
);
841 for (i
=0;i
<n
;i
++,x
++) {
843 XMesaSetForeground( dpy
, gc
,
844 DITHER_1BIT( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
845 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
850 /* draw all pixels */
851 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
853 XMesaPutPixel( rowimg
, i
, 0,
854 DITHER_1BIT( x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
856 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
862 * Write a span of PF_1BIT pixels to a pixmap (no alpha).
864 static void write_span_rgb_1BIT_pixmap( RGB_SPAN_ARGS
)
866 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
867 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
868 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
869 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
872 y
= FLIP(xmesa
->xm_buffer
, y
);
874 for (i
=0;i
<n
;i
++,x
++) {
876 XMesaSetForeground( dpy
, gc
,
877 DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
878 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
883 /* draw all pixels */
884 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
886 XMesaPutPixel( rowimg
, i
, 0,
887 DITHER_1BIT(x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
889 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
895 * Write a span of PF_HPCR pixels to a pixmap.
897 static void write_span_HPCR_pixmap( RGBA_SPAN_ARGS
)
899 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
900 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
901 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
902 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
904 y
= FLIP(xmesa
->xm_buffer
, y
);
906 for (i
=0;i
<n
;i
++,x
++) {
908 XMesaSetForeground( dpy
, gc
,
909 DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
910 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
915 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
916 register GLubyte
*ptr
= (GLubyte
*) xmesa
->xm_buffer
->rowimage
->data
;
918 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
920 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
926 * Write a span of PF_HPCR pixels to a pixmap (no alpha).
928 static void write_span_rgb_HPCR_pixmap( RGB_SPAN_ARGS
)
930 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
931 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
932 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
933 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
935 y
= FLIP(xmesa
->xm_buffer
, y
);
937 for (i
=0;i
<n
;i
++,x
++) {
939 XMesaSetForeground( dpy
, gc
,
940 DITHER_HPCR(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
941 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
946 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
947 register GLubyte
*ptr
= (GLubyte
*) xmesa
->xm_buffer
->rowimage
->data
;
949 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
951 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
957 * Write a span of PF_LOOKUP pixels to a pixmap.
959 static void write_span_LOOKUP_pixmap( RGBA_SPAN_ARGS
)
961 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
962 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
963 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
964 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
967 y
= FLIP(xmesa
->xm_buffer
, y
);
969 for (i
=0;i
<n
;i
++,x
++) {
971 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
972 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
977 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
979 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
981 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
987 * Write a span of PF_LOOKUP pixels to a pixmap (no alpha).
989 static void write_span_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS
)
991 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
992 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
993 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
994 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
997 y
= FLIP(xmesa
->xm_buffer
, y
);
999 for (i
=0;i
<n
;i
++,x
++) {
1001 XMesaSetForeground( dpy
, gc
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1002 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1007 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1009 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1011 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1018 * Write a span of PF_GRAYSCALE pixels to a pixmap.
1020 static void write_span_GRAYSCALE_pixmap( RGBA_SPAN_ARGS
)
1022 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1023 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1024 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
1025 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
1027 y
= FLIP(xmesa
->xm_buffer
, y
);
1029 for (i
=0;i
<n
;i
++,x
++) {
1031 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1032 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1037 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1039 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
1041 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1047 * Write a span of PF_GRAYSCALE pixels to a pixmap (no alpha).
1049 static void write_span_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS
)
1051 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1052 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1053 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
1054 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
1056 y
= FLIP(xmesa
->xm_buffer
, y
);
1058 for (i
=0;i
<n
;i
++,x
++) {
1060 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1061 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1066 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1068 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1070 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1076 * Write a span of PF_TRUECOLOR pixels to an XImage.
1078 static void write_span_TRUECOLOR_ximage( RGBA_SPAN_ARGS
)
1080 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1081 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1083 y
= FLIP(xmesa
->xm_buffer
, y
);
1085 for (i
=0;i
<n
;i
++,x
++) {
1088 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1089 XMesaPutPixel( img
, x
, y
, p
);
1094 /* draw all pixels */
1095 for (i
=0;i
<n
;i
++,x
++) {
1097 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1098 XMesaPutPixel( img
, x
, y
, p
);
1105 * Write a span of PF_TRUECOLOR pixels to an XImage (no alpha).
1107 static void write_span_rgb_TRUECOLOR_ximage( RGB_SPAN_ARGS
)
1109 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1110 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1112 y
= FLIP(xmesa
->xm_buffer
, y
);
1114 for (i
=0;i
<n
;i
++,x
++) {
1117 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1118 XMesaPutPixel( img
, x
, y
, p
);
1123 /* draw all pixels */
1124 for (i
=0;i
<n
;i
++,x
++) {
1126 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1127 XMesaPutPixel( img
, x
, y
, p
);
1134 * Write a span of PF_TRUEDITHER pixels to an XImage.
1136 static void write_span_TRUEDITHER_ximage( RGBA_SPAN_ARGS
)
1138 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1139 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1141 y
= FLIP(xmesa
->xm_buffer
, y
);
1143 for (i
=0;i
<n
;i
++,x
++) {
1146 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1147 XMesaPutPixel( img
, x
, y
, p
);
1152 /* draw all pixels */
1153 for (i
=0;i
<n
;i
++,x
++) {
1155 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1156 XMesaPutPixel( img
, x
, y
, p
);
1163 * Write a span of PF_TRUEDITHER pixels to an XImage (no alpha).
1165 static void write_span_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS
)
1167 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1168 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1170 y
= FLIP(xmesa
->xm_buffer
, y
);
1172 for (i
=0;i
<n
;i
++,x
++) {
1175 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1176 XMesaPutPixel( img
, x
, y
, p
);
1181 /* draw all pixels */
1182 for (i
=0;i
<n
;i
++,x
++) {
1184 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1185 XMesaPutPixel( img
, x
, y
, p
);
1192 * Write a span of PF_8A8B8G8R-format pixels to an ximage.
1194 static void write_span_8A8B8G8R_ximage( RGBA_SPAN_ARGS
)
1196 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1198 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1202 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1207 /* draw all pixels */
1209 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1216 * Write a span of PF_8A8B8G8R-format pixels to an ximage (no alpha).
1218 static void write_span_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS
)
1220 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1222 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1226 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1231 /* draw all pixels */
1233 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1240 * Write a span of PF_8R8G8B-format pixels to an ximage.
1242 static void write_span_8R8G8B_ximage( RGBA_SPAN_ARGS
)
1244 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1246 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1250 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1256 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1263 * Write a span of PF_8R8G8B24-format pixels to an ximage.
1265 static void write_span_8R8G8B24_ximage( RGBA_SPAN_ARGS
)
1267 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1269 register GLubyte
*ptr
= (GLubyte
*) PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
1273 GLuint
*ptr4
= (GLuint
*) ptr
;
1274 register GLuint pixel
= *ptr4
;
1275 switch (3 & (int)(ptr
- (GLubyte
*)ptr4
)) {
1277 pixel
&= 0xff000000;
1278 pixel
|= rgba
[i
][BCOMP
];
1279 pixel
|= rgba
[i
][GCOMP
] << 8;
1280 pixel
|= rgba
[i
][RCOMP
] << 16;
1284 pixel
&= 0x00ffffff;
1285 pixel
|= rgba
[i
][BCOMP
] << 24;
1287 pixel
= *ptr4
&& 0xffff0000;
1288 pixel
|= rgba
[i
][GCOMP
];
1289 pixel
|= rgba
[i
][RCOMP
] << 8;
1293 pixel
&= 0x0000ffff;
1294 pixel
|= rgba
[i
][BCOMP
] << 16;
1295 pixel
|= rgba
[i
][GCOMP
] << 24;
1297 pixel
= *ptr4
&& 0xffffff00;
1298 pixel
|= rgba
[i
][RCOMP
];
1302 pixel
&= 0x000000ff;
1303 pixel
|= rgba
[i
][BCOMP
] << 8;
1304 pixel
|= rgba
[i
][GCOMP
] << 16;
1305 pixel
|= rgba
[i
][RCOMP
] << 24;
1314 /* write all pixels */
1316 GLuint
*ptr4
= (GLuint
*) ptr
;
1317 register GLuint pixel
= *ptr4
;
1318 int index
= (int)(ptr
- (GLubyte
*)ptr4
);
1319 register GLuint i
= 0;
1324 pixel
&= 0x00ffffff;
1325 pixel
|= rgba
[i
][BCOMP
] << 24;
1327 pixel
= *ptr4
&& 0xffff0000;
1328 pixel
|= rgba
[i
][GCOMP
];
1329 pixel
|= rgba
[i
++][RCOMP
] << 8;
1334 pixel
&= 0x0000ffff;
1335 pixel
|= rgba
[i
][BCOMP
] << 16;
1336 pixel
|= rgba
[i
][GCOMP
] << 24;
1338 pixel
= *ptr4
&& 0xffffff00;
1339 pixel
|= rgba
[i
++][RCOMP
];
1344 pixel
&= 0x000000ff;
1345 pixel
|= rgba
[i
][BCOMP
] << 8;
1346 pixel
|= rgba
[i
][GCOMP
] << 16;
1347 pixel
|= rgba
[i
++][RCOMP
] << 24;
1354 pixel
= rgba
[i
][BCOMP
];
1355 pixel
|= rgba
[i
][GCOMP
] << 8;
1356 pixel
|= rgba
[i
++][RCOMP
] << 16;
1357 pixel
|= rgba
[i
][BCOMP
] << 24;
1359 pixel
= rgba
[i
][GCOMP
];
1360 pixel
|= rgba
[i
++][RCOMP
] << 8;
1361 pixel
|= rgba
[i
][BCOMP
] << 16;
1362 pixel
|= rgba
[i
][GCOMP
] << 24;
1364 pixel
= rgba
[i
++][RCOMP
];
1365 pixel
|= rgba
[i
][BCOMP
] << 8;
1366 pixel
|= rgba
[i
][GCOMP
] << 16;
1367 pixel
|= rgba
[i
++][RCOMP
] << 24;
1375 pixel
= *ptr4
& 0xff000000;
1376 pixel
|= rgba
[i
][BCOMP
];
1377 pixel
|= rgba
[i
][GCOMP
] << 8;
1378 pixel
|= rgba
[i
][RCOMP
] << 16;
1382 pixel
= rgba
[i
][BCOMP
];
1383 pixel
|= rgba
[i
][GCOMP
] << 8;
1384 pixel
|= rgba
[i
++][RCOMP
] << 16;
1385 pixel
|= rgba
[i
][BCOMP
] << 24;
1387 pixel
= *ptr4
& 0xffff0000;
1388 pixel
|= rgba
[i
][GCOMP
];
1389 pixel
|= rgba
[i
][RCOMP
] << 8;
1393 pixel
= rgba
[i
][BCOMP
];
1394 pixel
|= rgba
[i
][GCOMP
] << 8;
1395 pixel
|= rgba
[i
++][RCOMP
] << 16;
1396 pixel
|= rgba
[i
][BCOMP
] << 24;
1398 pixel
= rgba
[i
][GCOMP
];
1399 pixel
|= rgba
[i
++][RCOMP
] << 8;
1400 pixel
|= rgba
[i
][BCOMP
] << 16;
1401 pixel
|= rgba
[i
][GCOMP
] << 24;
1403 pixel
= *ptr4
& 0xffffff00;
1404 pixel
|= rgba
[i
][RCOMP
];
1413 * Write a span of PF_8R8G8B-format pixels to an ximage (no alpha).
1415 static void write_span_rgb_8R8G8B_ximage( RGB_SPAN_ARGS
)
1417 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1419 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1423 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1428 /* draw all pixels */
1430 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1437 * Write a span of PF_8R8G8B24-format pixels to an ximage (no alpha).
1439 static void write_span_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS
)
1441 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1443 register GLubyte
*ptr
= (GLubyte
*) PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
1447 *ptr
++ = rgb
[i
][BCOMP
];
1448 *ptr
++ = rgb
[i
][GCOMP
];
1449 *ptr
++ = rgb
[i
][RCOMP
];
1457 /* draw all pixels */
1459 *ptr
++ = rgb
[i
][BCOMP
];
1460 *ptr
++ = rgb
[i
][GCOMP
];
1461 *ptr
++ = rgb
[i
][RCOMP
];
1468 * Write a span of PF_5R6G5B-format pixels to an ximage.
1470 static void write_span_5R6G5B_ximage( RGBA_SPAN_ARGS
)
1472 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1474 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1478 ptr
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1483 /* draw all pixels */
1484 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1485 GLuint
*ptr32
= (GLuint
*) ptr
;
1486 GLuint extraPixel
= (n
& 1);
1488 for (i
= 0; i
< n
; i
+= 2) {
1490 p0
= PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1491 p1
= PACK_5R6G5B(rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
]);
1492 *ptr32
++ = (p1
<< 16) | p0
;
1495 ptr
[n
] = PACK_5R6G5B(rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1498 for (i
= 0; i
< n
; i
++) {
1499 ptr
[i
] = PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1507 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage.
1509 static void write_span_DITHER_5R6G5B_ximage( RGBA_SPAN_ARGS
)
1511 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1513 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1514 const GLint y2
= FLIP(xmesa
->xm_buffer
, y
);
1516 for (i
=0;i
<n
;i
++,x
++) {
1518 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1523 /* draw all pixels */
1524 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1525 GLuint
*ptr32
= (GLuint
*) ptr
;
1526 GLuint extraPixel
= (n
& 1);
1528 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1530 PACK_TRUEDITHER( p0
, x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1531 PACK_TRUEDITHER( p1
, x
+1, y2
, rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
] );
1532 *ptr32
++ = (p1
<< 16) | p0
;
1535 PACK_TRUEDITHER( ptr
[n
], x
+n
, y2
, rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1538 for (i
= 0; i
< n
; i
++, x
++) {
1539 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1547 * Write a span of PF_5R6G5B-format pixels to an ximage (no alpha).
1549 static void write_span_rgb_5R6G5B_ximage( RGB_SPAN_ARGS
)
1551 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1553 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1557 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1562 /* draw all pixels */
1563 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1564 GLuint
*ptr32
= (GLuint
*) ptr
;
1565 GLuint extraPixel
= (n
& 1);
1567 for (i
= 0; i
< n
; i
+= 2) {
1569 p0
= PACK_5R6G5B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1570 p1
= PACK_5R6G5B(rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
]);
1571 *ptr32
++ = (p1
<< 16) | p0
;
1574 ptr
[n
] = PACK_5R6G5B(rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1578 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1586 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage (no alpha).
1588 static void write_span_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS
)
1590 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1592 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1594 for (i
=0;i
<n
;i
++,x
++) {
1596 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1601 /* draw all pixels */
1602 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1603 GLuint
*ptr32
= (GLuint
*) ptr
;
1604 GLuint extraPixel
= (n
& 1);
1606 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1608 PACK_TRUEDITHER( p0
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1609 PACK_TRUEDITHER( p1
, x
+1, y
, rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
] );
1610 *ptr32
++ = (p1
<< 16) | p0
;
1613 PACK_TRUEDITHER( ptr
[n
], x
+n
, y
, rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1616 for (i
=0;i
<n
;i
++,x
++) {
1617 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1625 * Write a span of PF_DITHER pixels to an XImage.
1627 static void write_span_DITHER_ximage( RGBA_SPAN_ARGS
)
1629 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1630 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1632 int yy
= FLIP(xmesa
->xm_buffer
, y
);
1635 for (i
=0;i
<n
;i
++,x
++) {
1637 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1642 /* draw all pixels */
1643 for (i
=0;i
<n
;i
++,x
++) {
1644 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1651 * Write a span of PF_DITHER pixels to an XImage (no alpha).
1653 static void write_span_rgb_DITHER_ximage( RGB_SPAN_ARGS
)
1655 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1656 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1658 int yy
= FLIP(xmesa
->xm_buffer
, y
);
1661 for (i
=0;i
<n
;i
++,x
++) {
1663 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1668 /* draw all pixels */
1669 for (i
=0;i
<n
;i
++,x
++) {
1670 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1678 * Write a span of 8-bit PF_DITHER pixels to an XImage.
1680 static void write_span_DITHER8_ximage( RGBA_SPAN_ARGS
)
1682 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1684 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1687 for (i
=0;i
<n
;i
++,x
++) {
1689 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1694 for (i
=0;i
<n
;i
++,x
++) {
1695 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1701 static void write_span_rgb_DITHER8_ximage( RGB_SPAN_ARGS
)
1703 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1705 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1708 for (i
=0;i
<n
;i
++,x
++) {
1710 ptr
[i
] = (GLubyte
) XDITHER( x
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
1715 const GLubyte
*data
= (GLubyte
*) rgb
;
1716 for (i
=0;i
<n
;i
++,x
++) {
1717 /*ptr[i] = XDITHER( x, rgb[i][0], rgb[i][1], rgb[i][2] );*/
1718 ptr
[i
] = (GLubyte
) XDITHER( x
, data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
1726 * Write a span of PF_1BIT pixels to an XImage.
1728 static void write_span_1BIT_ximage( RGBA_SPAN_ARGS
)
1730 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1731 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1734 y
= FLIP(xmesa
->xm_buffer
, y
);
1736 for (i
=0;i
<n
;i
++,x
++) {
1738 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]));
1743 for (i
=0;i
<n
;i
++,x
++) {
1744 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
1751 * Write a span of PF_1BIT pixels to an XImage (no alpha).
1753 static void write_span_rgb_1BIT_ximage( RGB_SPAN_ARGS
)
1755 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1756 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1759 y
= FLIP(xmesa
->xm_buffer
, y
);
1761 for (i
=0;i
<n
;i
++,x
++) {
1763 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]));
1768 for (i
=0;i
<n
;i
++,x
++) {
1769 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
1776 * Write a span of PF_HPCR pixels to an XImage.
1778 static void write_span_HPCR_ximage( RGBA_SPAN_ARGS
)
1780 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1782 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1784 for (i
=0;i
<n
;i
++,x
++) {
1786 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1791 /* draw all pixels */
1792 for (i
=0;i
<n
;i
++,x
++) {
1793 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1800 * Write a span of PF_HPCR pixels to an XImage (no alpha).
1802 static void write_span_rgb_HPCR_ximage( RGB_SPAN_ARGS
)
1804 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1806 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1808 for (i
=0;i
<n
;i
++,x
++) {
1810 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1815 /* draw all pixels */
1816 for (i
=0;i
<n
;i
++,x
++) {
1817 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1824 * Write a span of PF_LOOKUP pixels to an XImage.
1826 static void write_span_LOOKUP_ximage( RGBA_SPAN_ARGS
)
1828 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1829 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1832 y
= FLIP(xmesa
->xm_buffer
, y
);
1834 for (i
=0;i
<n
;i
++,x
++) {
1836 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1841 /* draw all pixels */
1842 for (i
=0;i
<n
;i
++,x
++) {
1843 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1850 * Write a span of PF_LOOKUP pixels to an XImage (no alpha).
1852 static void write_span_rgb_LOOKUP_ximage( RGB_SPAN_ARGS
)
1854 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1855 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1858 y
= FLIP(xmesa
->xm_buffer
, y
);
1860 for (i
=0;i
<n
;i
++,x
++) {
1862 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1867 /* draw all pixels */
1868 for (i
=0;i
<n
;i
++,x
++) {
1869 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1876 * Write a span of 8-bit PF_LOOKUP pixels to an XImage.
1878 static void write_span_LOOKUP8_ximage( RGBA_SPAN_ARGS
)
1880 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1882 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1885 for (i
=0;i
<n
;i
++,x
++) {
1887 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1892 /* draw all pixels */
1893 for (i
=0;i
<n
;i
++,x
++) {
1894 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1900 static void write_rgb_LOOKUP8_ximage( const GLcontext
*ctx
,
1901 GLuint n
, GLint x
, GLint y
,
1902 CONST GLubyte rgb
[][3],
1903 const GLubyte mask
[] )
1905 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1907 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1910 for (i
=0;i
<n
;i
++,x
++) {
1912 ptr
[i
] = (GLubyte
) LOOKUP( rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
1917 /* draw all pixels */
1918 const GLubyte
*data
= (GLubyte
*) rgb
;
1919 for (i
=0;i
<n
;i
++,x
++) {
1920 /*ptr[i] = LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );*/
1921 ptr
[i
] = (GLubyte
) LOOKUP( data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
1928 * Write a span of PF_GRAYSCALE pixels to an XImage.
1930 static void write_span_GRAYSCALE_ximage( RGBA_SPAN_ARGS
)
1932 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1933 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1935 y
= FLIP(xmesa
->xm_buffer
, y
);
1937 for (i
=0;i
<n
;i
++,x
++) {
1939 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1944 /* draw all pixels */
1945 for (i
=0;i
<n
;i
++,x
++) {
1946 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1953 * Write a span of PF_GRAYSCALE pixels to an XImage (no alpha).
1955 static void write_span_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS
)
1957 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1958 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1960 y
= FLIP(xmesa
->xm_buffer
, y
);
1962 for (i
=0;i
<n
;i
++,x
++) {
1964 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1969 /* draw all pixels */
1970 for (i
=0;i
<n
;i
++,x
++) {
1971 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1978 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage.
1980 static void write_span_GRAYSCALE8_ximage( RGBA_SPAN_ARGS
)
1982 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1984 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1988 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1993 /* draw all pixels */
1995 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2002 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage (no alpha).
2004 static void write_span_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS
)
2006 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2008 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
2012 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2017 /* draw all pixels */
2019 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2027 /**********************************************************************/
2028 /*** Write COLOR PIXEL functions ***/
2029 /**********************************************************************/
2032 #define RGBA_PIXEL_ARGS const GLcontext *ctx, \
2033 GLuint n, const GLint x[], const GLint y[], \
2034 CONST GLubyte rgba[][4], const GLubyte mask[]
2038 * Write an array of PF_TRUECOLOR pixels to a pixmap.
2040 static void write_pixels_TRUECOLOR_pixmap( RGBA_PIXEL_ARGS
)
2042 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2043 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2044 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2045 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2050 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2051 XMesaSetForeground( dpy
, gc
, p
);
2052 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2059 * Write an array of PF_TRUEDITHER pixels to a pixmap.
2061 static void write_pixels_TRUEDITHER_pixmap( RGBA_PIXEL_ARGS
)
2063 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2064 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2065 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2066 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2071 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2072 XMesaSetForeground( dpy
, gc
, p
);
2073 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2080 * Write an array of PF_8A8B8G8R pixels to a pixmap.
2082 static void write_pixels_8A8B8G8R_pixmap( RGBA_PIXEL_ARGS
)
2084 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2085 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2086 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2087 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2091 XMesaSetForeground( dpy
, gc
,
2092 PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] ));
2093 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2100 * Write an array of PF_8R8G8B pixels to a pixmap.
2102 static void write_pixels_8R8G8B_pixmap( RGBA_PIXEL_ARGS
)
2104 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2105 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2106 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2107 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2111 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2112 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2119 * Write an array of PF_8R8G8B24 pixels to a pixmap.
2121 static void write_pixels_8R8G8B24_pixmap( RGBA_PIXEL_ARGS
)
2123 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2124 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2125 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2126 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2130 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2131 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2138 * Write an array of PF_5R6G5B pixels to a pixmap.
2140 static void write_pixels_5R6G5B_pixmap( RGBA_PIXEL_ARGS
)
2142 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2143 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2144 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2145 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2149 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2150 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2157 * Write an array of PF_DITHER_5R6G5B pixels to a pixmap.
2159 static void write_pixels_DITHER_5R6G5B_pixmap( RGBA_PIXEL_ARGS
)
2161 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2162 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2163 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2164 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2169 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2170 XMesaSetForeground( dpy
, gc
, p
);
2171 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2178 * Write an array of PF_DITHER pixels to a pixmap.
2180 static void write_pixels_DITHER_pixmap( RGBA_PIXEL_ARGS
)
2182 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2183 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2184 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2185 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2190 XMesaSetForeground( dpy
, gc
,
2191 DITHER(x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2192 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2199 * Write an array of PF_1BIT pixels to a pixmap.
2201 static void write_pixels_1BIT_pixmap( RGBA_PIXEL_ARGS
)
2203 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2204 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2205 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2206 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2211 XMesaSetForeground( dpy
, gc
,
2212 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2213 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2220 * Write an array of PF_HPCR pixels to a pixmap.
2222 static void write_pixels_HPCR_pixmap( RGBA_PIXEL_ARGS
)
2224 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2225 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2226 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2227 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2231 XMesaSetForeground( dpy
, gc
,
2232 DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2233 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2240 * Write an array of PF_LOOKUP pixels to a pixmap.
2242 static void write_pixels_LOOKUP_pixmap( RGBA_PIXEL_ARGS
)
2244 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2245 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2246 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2247 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2252 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2253 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2260 * Write an array of PF_GRAYSCALE pixels to a pixmap.
2262 static void write_pixels_GRAYSCALE_pixmap( RGBA_PIXEL_ARGS
)
2264 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2265 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2266 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2267 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2271 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2272 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2279 * Write an array of PF_TRUECOLOR pixels to an ximage.
2281 static void write_pixels_TRUECOLOR_ximage( RGBA_PIXEL_ARGS
)
2283 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2284 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2289 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2290 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
2297 * Write an array of PF_TRUEDITHER pixels to an XImage.
2299 static void write_pixels_TRUEDITHER_ximage( RGBA_PIXEL_ARGS
)
2301 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2302 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2307 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2308 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
2315 * Write an array of PF_8A8B8G8R pixels to an ximage.
2317 static void write_pixels_8A8B8G8R_ximage( RGBA_PIXEL_ARGS
)
2319 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2323 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2324 *ptr
= PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
2331 * Write an array of PF_8R8G8B pixels to an ximage.
2333 static void write_pixels_8R8G8B_ximage( RGBA_PIXEL_ARGS
)
2335 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2339 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2340 *ptr
= PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2347 * Write an array of PF_8R8G8B24 pixels to an ximage.
2349 static void write_pixels_8R8G8B24_ximage( RGBA_PIXEL_ARGS
)
2351 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2355 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2356 ptr
->r
= rgba
[i
][RCOMP
];
2357 ptr
->g
= rgba
[i
][GCOMP
];
2358 ptr
->b
= rgba
[i
][BCOMP
];
2365 * Write an array of PF_5R6G5B pixels to an ximage.
2367 static void write_pixels_5R6G5B_ximage( RGBA_PIXEL_ARGS
)
2369 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2373 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2374 *ptr
= PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2381 * Write an array of PF_DITHER_5R6G5B pixels to an ximage.
2383 static void write_pixels_DITHER_5R6G5B_ximage( RGBA_PIXEL_ARGS
)
2385 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2389 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2390 PACK_TRUEDITHER( *ptr
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2397 * Write an array of PF_DITHER pixels to an XImage.
2399 static void write_pixels_DITHER_ximage( RGBA_PIXEL_ARGS
)
2401 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2402 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2407 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2408 DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2415 * Write an array of 8-bit PF_DITHER pixels to an XImage.
2417 static void write_pixels_DITHER8_ximage( RGBA_PIXEL_ARGS
)
2419 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2424 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2425 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2432 * Write an array of PF_1BIT pixels to an XImage.
2434 static void write_pixels_1BIT_ximage( RGBA_PIXEL_ARGS
)
2436 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2437 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2442 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2443 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2450 * Write an array of PF_HPCR pixels to an XImage.
2452 static void write_pixels_HPCR_ximage( RGBA_PIXEL_ARGS
)
2454 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2458 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2459 *ptr
= (GLubyte
) DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2466 * Write an array of PF_LOOKUP pixels to an XImage.
2468 static void write_pixels_LOOKUP_ximage( RGBA_PIXEL_ARGS
)
2470 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2471 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2476 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), LOOKUP(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2483 * Write an array of 8-bit PF_LOOKUP pixels to an XImage.
2485 static void write_pixels_LOOKUP8_ximage( RGBA_PIXEL_ARGS
)
2487 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2492 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2493 *ptr
= (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2500 * Write an array of PF_GRAYSCALE pixels to an XImage.
2502 static void write_pixels_GRAYSCALE_ximage( RGBA_PIXEL_ARGS
)
2504 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2505 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2509 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2510 GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2517 * Write an array of 8-bit PF_GRAYSCALE pixels to an XImage.
2519 static void write_pixels_GRAYSCALE8_ximage( RGBA_PIXEL_ARGS
)
2521 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2525 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2526 *ptr
= (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2534 /**********************************************************************/
2535 /*** Write MONO COLOR SPAN functions ***/
2536 /**********************************************************************/
2538 #define MONO_SPAN_ARGS const GLcontext *ctx, \
2539 GLuint n, GLint x, GLint y, const GLchan color[4], \
2540 const GLubyte mask[]
2544 * Write a span of identical pixels to a pixmap.
2546 static void write_span_mono_pixmap( MONO_SPAN_ARGS
)
2548 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2549 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2550 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2551 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2552 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2553 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2555 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
2556 y
= FLIP(xmesa
->xm_buffer
, y
);
2558 /* New code contributed by Jeff Epler and cleaned up by Keith
2561 for (i
= 0; i
< n
; ) {
2564 /* Identify and emit contiguous rendered pixels
2566 while (i
< n
&& (!mask
|| mask
[i
]))
2570 XMesaFillRectangle( dpy
, buffer
, gc
,
2571 (int)(x
+start
), (int) y
,
2574 /* Eat up non-rendered pixels
2576 while (i
< n
&& !mask
[i
])
2583 static void write_span_mono_index_pixmap( const GLcontext
*ctx
, GLuint n
,
2584 GLint x
, GLint y
, GLuint colorIndex
,
2585 const GLubyte mask
[] )
2587 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2588 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2589 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2590 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2592 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
2593 y
= FLIP(xmesa
->xm_buffer
, y
);
2595 for (i
= 0 ; i
< n
;) {
2598 /* Identify and emit contiguous rendered pixels
2600 while (i
< n
&& mask
[i
])
2604 XMesaFillRectangle( dpy
, buffer
, gc
,
2605 (int)(x
+start
), (int) y
,
2608 /* Eat up non-rendered pixels
2610 while (i
< n
&& !mask
[i
])
2618 * Write a span of PF_TRUEDITHER pixels to a pixmap.
2620 static void write_span_mono_TRUEDITHER_pixmap( MONO_SPAN_ARGS
)
2622 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2623 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2624 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2625 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2626 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2628 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2629 for (i
=0;i
<n
;i
++,x
++) {
2632 PACK_TRUEDITHER(p
, x
, yy
, r
, g
, b
);
2633 XMesaSetForeground( dpy
, gc
, p
);
2634 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2641 * Write a span of PF_DITHER pixels to a pixmap.
2643 static void write_span_mono_DITHER_pixmap( MONO_SPAN_ARGS
)
2645 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2646 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2647 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2648 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2649 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2651 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2653 for (i
=0;i
<n
;i
++,x
++) {
2655 XMesaSetForeground( dpy
, gc
, XDITHER( x
, r
, g
, b
) );
2656 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2663 * Write a span of PF_1BIT pixels to a pixmap.
2665 static void write_span_mono_1BIT_pixmap( MONO_SPAN_ARGS
)
2667 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2668 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2669 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2670 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2671 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2674 y
= FLIP(xmesa
->xm_buffer
, y
);
2675 for (i
=0;i
<n
;i
++,x
++) {
2677 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
, y
, r
, g
, b
) );
2678 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
2685 * Write a span of identical pixels to an XImage.
2687 static void write_span_mono_ximage( MONO_SPAN_ARGS
)
2689 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2690 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2692 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2693 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2694 y
= FLIP(xmesa
->xm_buffer
, y
);
2695 for (i
=0;i
<n
;i
++,x
++) {
2697 XMesaPutPixel( img
, x
, y
, pixel
);
2703 static void write_span_mono_index_ximage( const GLcontext
*ctx
, GLuint n
,
2706 const GLubyte mask
[] )
2708 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2709 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2711 y
= FLIP(xmesa
->xm_buffer
, y
);
2712 for (i
=0;i
<n
;i
++,x
++) {
2714 XMesaPutPixel( img
, x
, y
, colorIndex
);
2721 * Write a span of identical PF_TRUEDITHER pixels to an XImage.
2723 static void write_span_mono_TRUEDITHER_ximage( MONO_SPAN_ARGS
)
2725 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2726 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2727 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2729 y
= FLIP(xmesa
->xm_buffer
, y
);
2733 PACK_TRUEDITHER( p
, x
+i
, y
, r
, g
, b
);
2734 XMesaPutPixel( img
, x
+i
, y
, p
);
2741 * Write a span of identical 8A8B8G8R pixels to an XImage.
2743 static void write_span_mono_8A8B8G8R_ximage( MONO_SPAN_ARGS
)
2745 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2747 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2748 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2749 ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
2759 * Write a span of identical 8R8G8B pixels to an XImage.
2761 static void write_span_mono_8R8G8B_ximage( MONO_SPAN_ARGS
)
2763 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2764 const GLuint pixel
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2765 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
2768 if (!mask
|| mask
[i
]) {
2776 * Write a span of identical 8R8G8B pixels to an XImage.
2778 static void write_span_mono_8R8G8B24_ximage( MONO_SPAN_ARGS
)
2780 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2781 const GLubyte r
= color
[RCOMP
];
2782 const GLubyte g
= color
[GCOMP
];
2783 const GLubyte b
= color
[BCOMP
];
2785 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
2797 * Write a span of identical DITHER pixels to an XImage.
2799 static void write_span_mono_DITHER_ximage( MONO_SPAN_ARGS
)
2801 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2802 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2803 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2804 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2807 for (i
=0;i
<n
;i
++,x
++) {
2809 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, r
, g
, b
) );
2816 * Write a span of identical 8-bit DITHER pixels to an XImage.
2818 static void write_span_mono_DITHER8_ximage( MONO_SPAN_ARGS
)
2820 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2821 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2822 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2825 for (i
=0;i
<n
;i
++,x
++) {
2827 ptr
[i
] = (GLubyte
) XDITHER( x
, r
, g
, b
);
2834 * Write a span of identical 8-bit LOOKUP pixels to an XImage.
2836 static void write_span_mono_LOOKUP8_ximage( MONO_SPAN_ARGS
)
2838 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2840 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2843 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2853 * Write a span of identical PF_1BIT pixels to an XImage.
2855 static void write_span_mono_1BIT_ximage( MONO_SPAN_ARGS
)
2857 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2858 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2859 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2862 y
= FLIP(xmesa
->xm_buffer
, y
);
2863 for (i
=0;i
<n
;i
++,x
++) {
2865 XMesaPutPixel( img
, x
, y
, DITHER_1BIT( x
, y
, r
, g
, b
) );
2872 * Write a span of identical HPCR pixels to an XImage.
2874 static void write_span_mono_HPCR_ximage( MONO_SPAN_ARGS
)
2876 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2877 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2878 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2880 for (i
=0;i
<n
;i
++,x
++) {
2882 ptr
[i
] = DITHER_HPCR( x
, y
, r
, g
, b
);
2889 * Write a span of identical 8-bit GRAYSCALE pixels to an XImage.
2891 static void write_span_mono_GRAYSCALE8_ximage( MONO_SPAN_ARGS
)
2893 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2894 const GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2895 GLubyte
*ptr
= (GLubyte
*) PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2907 * Write a span of identical PF_DITHER_5R6G5B pixels to an XImage.
2909 static void write_span_mono_DITHER_5R6G5B_ximage( MONO_SPAN_ARGS
)
2911 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2912 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
2913 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2915 y
= FLIP(xmesa
->xm_buffer
, y
);
2918 PACK_TRUEDITHER(ptr
[i
], x
+i
, y
, r
, g
, b
);
2925 /**********************************************************************/
2926 /*** Write MONO COLOR PIXELS functions ***/
2927 /**********************************************************************/
2929 #define MONO_PIXEL_ARGS const GLcontext *ctx, \
2930 GLuint n, const GLint x[], const GLint y[], \
2931 const GLchan color[4], const GLubyte mask[]
2934 * Write an array of identical pixels to a pixmap.
2936 static void write_pixels_mono_pixmap( MONO_PIXEL_ARGS
)
2938 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2939 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2940 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2941 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2943 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2944 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2945 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
2948 XMesaDrawPoint( dpy
, buffer
, gc
,
2949 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2955 static void write_pixels_mono_index_pixmap(const GLcontext
*ctx
,
2957 const GLint x
[], const GLint y
[],
2959 const GLubyte mask
[] )
2961 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2962 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2963 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2964 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2966 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
2969 XMesaDrawPoint( dpy
, buffer
, gc
,
2970 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2977 * Write an array of PF_TRUEDITHER pixels to a pixmap.
2979 static void write_pixels_mono_TRUEDITHER_pixmap( MONO_PIXEL_ARGS
)
2981 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2982 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2983 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2984 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2986 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2990 PACK_TRUEDITHER(p
, x
[i
], y
[i
], r
, g
, b
);
2991 XMesaSetForeground( dpy
, gc
, p
);
2992 XMesaDrawPoint( dpy
, buffer
, gc
,
2993 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3000 * Write an array of PF_DITHER pixels to a pixmap.
3002 static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS
)
3004 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3005 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3006 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3007 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3009 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3013 XMesaSetForeground( dpy
, gc
, DITHER( x
[i
], y
[i
], r
, g
, b
) );
3014 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3021 * Write an array of PF_1BIT pixels to a pixmap.
3023 static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS
)
3025 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3026 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3027 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3028 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3030 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3034 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
) );
3035 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3042 * Write an array of identical pixels to an XImage.
3044 static void write_pixels_mono_ximage( MONO_PIXEL_ARGS
)
3046 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3047 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3049 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
3050 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3053 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), pixel
);
3059 static void write_pixels_mono_index_ximage( const GLcontext
*ctx
, GLuint n
,
3060 const GLint x
[], const GLint y
[],
3062 const GLubyte mask
[] )
3064 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3065 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3069 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), colorIndex
);
3076 * Write an array of identical TRUEDITHER pixels to an XImage.
3078 static void write_pixels_mono_TRUEDITHER_ximage( MONO_PIXEL_ARGS
)
3080 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3081 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3083 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3087 PACK_TRUEDITHER(p
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), r
, g
, b
);
3088 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
3096 * Write an array of identical 8A8B8G8R pixels to an XImage
3098 static void write_pixels_mono_8A8B8G8R_ximage( MONO_PIXEL_ARGS
)
3100 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3101 const GLuint p
= PACK_8A8B8G8R(color
[RCOMP
], color
[GCOMP
],
3102 color
[BCOMP
], color
[ACOMP
]);
3106 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3114 * Write an array of identical 8R8G8B pixels to an XImage.
3116 static void write_pixels_mono_8R8G8B_ximage( MONO_PIXEL_ARGS
)
3118 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3120 const GLuint p
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3123 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3131 * Write an array of identical 8R8G8B pixels to an XImage.
3133 static void write_pixels_mono_8R8G8B24_ximage( MONO_PIXEL_ARGS
)
3135 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3136 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3140 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3150 * Write an array of identical PF_DITHER pixels to an XImage.
3152 static void write_pixels_mono_DITHER_ximage( MONO_PIXEL_ARGS
)
3154 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3155 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3156 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3161 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), DITHER( x
[i
], y
[i
], r
, g
, b
) );
3168 * Write an array of identical 8-bit PF_DITHER pixels to an XImage.
3170 static void write_pixels_mono_DITHER8_ximage( MONO_PIXEL_ARGS
)
3172 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3173 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3178 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3179 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], r
, g
, b
);
3186 * Write an array of identical 8-bit PF_LOOKUP pixels to an XImage.
3188 static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS
)
3190 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3194 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3197 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3206 * Write an array of identical PF_1BIT pixels to an XImage.
3208 static void write_pixels_mono_1BIT_ximage( MONO_PIXEL_ARGS
)
3210 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3211 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3212 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3217 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
3218 DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
));
3225 * Write an array of identical PF_HPCR pixels to an XImage.
3227 static void write_pixels_mono_HPCR_ximage( MONO_PIXEL_ARGS
)
3229 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3230 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3234 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3235 *ptr
= DITHER_HPCR( x
[i
], y
[i
], r
, g
, b
);
3242 * Write an array of identical 8-bit PF_GRAYSCALE pixels to an XImage.
3244 static void write_pixels_mono_GRAYSCALE8_ximage( MONO_PIXEL_ARGS
)
3246 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3248 register GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3251 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3259 * Write an array of identical PF_DITHER_5R6G5B pixels to an XImage.
3261 static void write_pixels_mono_DITHER_5R6G5B_ximage( MONO_PIXEL_ARGS
)
3263 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3264 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3268 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3269 PACK_TRUEDITHER(*ptr
, x
[i
], y
[i
], r
, g
, b
);
3276 /**********************************************************************/
3277 /*** Write INDEX SPAN functions ***/
3278 /**********************************************************************/
3280 #define INDEX_SPAN_ARGS const GLcontext *ctx, \
3281 GLuint n, GLint x, GLint y, const GLuint index[], \
3282 const GLubyte mask[]
3284 #define INDEX8_SPAN_ARGS const GLcontext *ctx, \
3285 GLuint n, GLint x, GLint y, const GLubyte index[], \
3286 const GLubyte mask[]
3290 * Write a span of CI pixels to a Pixmap.
3292 static void write_span_index_pixmap( INDEX_SPAN_ARGS
)
3294 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3295 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3296 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3297 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3299 y
= FLIP(xmesa
->xm_buffer
, y
);
3301 for (i
=0;i
<n
;i
++,x
++) {
3303 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3304 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3309 for (i
=0;i
<n
;i
++,x
++) {
3310 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3311 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3318 * Write a span of 8-bit CI pixels to a Pixmap.
3320 static void write_span_index8_pixmap( INDEX8_SPAN_ARGS
)
3322 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3323 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3324 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3325 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3327 y
= FLIP(xmesa
->xm_buffer
, y
);
3329 for (i
=0;i
<n
;i
++,x
++) {
3331 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3332 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3337 for (i
=0;i
<n
;i
++,x
++) {
3338 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3339 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3346 * Write a span of CI pixels to an XImage.
3348 static void write_span_index_ximage( INDEX_SPAN_ARGS
)
3350 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3351 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3353 y
= FLIP(xmesa
->xm_buffer
, y
);
3355 for (i
=0;i
<n
;i
++,x
++) {
3357 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3362 for (i
=0;i
<n
;i
++,x
++) {
3363 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3370 * Write a span of 8-bit CI pixels to a non 8-bit XImage.
3372 static void write_span_index8_ximage( const GLcontext
*ctx
, GLuint n
,
3373 GLint x
, GLint y
, const GLubyte index
[],
3374 const GLubyte mask
[] )
3376 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3381 XMesaPutPixel(xmesa
->xm_buffer
->backimage
, x
+i
, y
, index
[i
]);
3388 XMesaPutPixel(xmesa
->xm_buffer
->backimage
, x
+i
, y
, index
[i
]);
3394 * Write a span of 8-bit CI pixels to an 8-bit XImage.
3396 static void write_span_index8_ximage8( const GLcontext
*ctx
, GLuint n
,
3397 GLint x
, GLint y
, const GLubyte index
[],
3398 const GLubyte mask
[] )
3400 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3401 GLubyte
*dst
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
3411 MEMCPY( dst
, index
, n
);
3417 /**********************************************************************/
3418 /*** Write INDEX PIXELS functions ***/
3419 /**********************************************************************/
3421 #define INDEX_PIXELS_ARGS const GLcontext *ctx, \
3422 GLuint n, const GLint x[], const GLint y[], \
3423 const GLuint index[], const GLubyte mask[]
3427 * Write an array of CI pixels to a Pixmap.
3429 static void write_pixels_index_pixmap( INDEX_PIXELS_ARGS
)
3431 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3432 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3433 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3434 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3438 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3439 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3446 * Write an array of CI pixels to an XImage.
3448 static void write_pixels_index_ximage( INDEX_PIXELS_ARGS
)
3450 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3451 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3455 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), (unsigned long) index
[i
] );
3463 /**********************************************************************/
3464 /***** Pixel reading *****/
3465 /**********************************************************************/
3470 * Read a horizontal span of color-index pixels.
3472 static void read_index_span( const GLcontext
*ctx
,
3473 GLuint n
, GLint x
, GLint y
, GLuint index
[] )
3475 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3476 XMesaBuffer source
= xmesa
->xm_buffer
;
3479 y
= FLIP(source
, y
);
3481 if (source
->buffer
) {
3482 #ifndef XFree86Server
3483 XMesaImage
*span
= NULL
;
3485 catch_xgetimage_errors( xmesa
->display
);
3486 span
= XGetImage( xmesa
->display
, source
->buffer
,
3487 x
, y
, n
, 1, AllPlanes
, ZPixmap
);
3488 error
= check_xgetimage_errors();
3489 if (span
&& !error
) {
3491 index
[i
] = (GLuint
) XMesaGetPixel( span
, i
, 0 );
3495 /* return 0 pixels */
3501 XMesaDestroyImage( span
);
3504 (*xmesa
->display
->GetImage
)(source
->buffer
,
3505 x
, y
, n
, 1, ZPixmap
,
3506 ~0L, (pointer
)index
);
3509 else if (source
->backimage
) {
3510 XMesaImage
*img
= source
->backimage
;
3511 for (i
=0;i
<n
;i
++,x
++) {
3512 index
[i
] = (GLuint
) XMesaGetPixel( img
, x
, y
);
3520 * Read a horizontal span of color pixels.
3522 static void read_color_span( const GLcontext
*ctx
,
3523 GLuint n
, GLint x
, GLint y
,
3526 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3527 XMesaBuffer source
= xmesa
->xm_buffer
;
3529 if (source
->buffer
) {
3530 /* Read from Pixmap or Window */
3531 XMesaImage
*span
= NULL
;
3533 #ifdef XFree86Server
3534 span
= XMesaCreateImage(xmesa
->xm_visual
->BitsPerPixel
, n
, 1, NULL
);
3535 span
->data
= (char *)MALLOC(span
->height
* span
->bytes_per_line
);
3536 error
= (!span
->data
);
3537 (*xmesa
->display
->GetImage
)(source
->buffer
,
3538 x
, FLIP(source
, y
), n
, 1, ZPixmap
,
3539 ~0L, (pointer
)span
->data
);
3541 catch_xgetimage_errors( xmesa
->display
);
3542 span
= XGetImage( xmesa
->display
, source
->buffer
,
3543 x
, FLIP(source
, y
), n
, 1, AllPlanes
, ZPixmap
);
3544 error
= check_xgetimage_errors();
3546 if (span
&& !error
) {
3547 switch (xmesa
->pixelformat
) {
3549 case PF_Dither_True
:
3551 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3552 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3553 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3554 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3555 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3556 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3557 GLint rShift
= xmesa
->xm_visual
->rshift
;
3558 GLint gShift
= xmesa
->xm_visual
->gshift
;
3559 GLint bShift
= xmesa
->xm_visual
->bshift
;
3563 p
= XMesaGetPixel( span
, i
, 0 );
3564 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3565 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3566 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3567 rgba
[i
][ACOMP
] = 255;
3572 case PF_Dither_5R6G5B
:
3574 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3575 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3576 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3579 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
3580 /* fast, but not quite accurate
3581 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3582 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3583 rgba[i][BCOMP] = ((p << 3) & 0xff);
3585 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
3586 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3587 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
3588 rgba
[i
][ACOMP
] = 255;
3594 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3597 GLuint p4
= *ptr4
++;
3598 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
3599 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3600 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3601 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
3607 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3610 GLuint p4
= *ptr4
++;
3611 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3612 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3613 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3614 rgba
[i
][ACOMP
] = 255;
3620 const bgr_t
*ptr3
= (bgr_t
*) span
->data
;
3623 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
3624 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
3625 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
3626 rgba
[i
][ACOMP
] = 255;
3632 GLubyte
*ptr1
= (GLubyte
*) span
->data
;
3635 GLubyte p
= *ptr1
++;
3636 rgba
[i
][RCOMP
] = p
& 0xE0;
3637 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
3638 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
3639 rgba
[i
][ACOMP
] = 255;
3647 GLubyte
*rTable
= source
->pixel_to_r
;
3648 GLubyte
*gTable
= source
->pixel_to_g
;
3649 GLubyte
*bTable
= source
->pixel_to_b
;
3650 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
3651 const GLubyte
*ptr1
= (GLubyte
*) span
->data
;
3654 unsigned long p
= *ptr1
++;
3655 rgba
[i
][RCOMP
] = rTable
[p
];
3656 rgba
[i
][GCOMP
] = gTable
[p
];
3657 rgba
[i
][BCOMP
] = bTable
[p
];
3658 rgba
[i
][ACOMP
] = 255;
3664 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
3665 rgba
[i
][RCOMP
] = rTable
[p
];
3666 rgba
[i
][GCOMP
] = gTable
[p
];
3667 rgba
[i
][BCOMP
] = bTable
[p
];
3668 rgba
[i
][ACOMP
] = 255;
3675 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
3679 p
= XMesaGetPixel( span
, i
, 0 ) ^ bitFlip
;
3680 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
3681 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
3682 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
3683 rgba
[i
][ACOMP
] = 255;
3688 _mesa_problem(NULL
,"Problem in DD.read_color_span (1)");
3693 /* return black pixels */
3696 rgba
[i
][RCOMP
] = rgba
[i
][GCOMP
] = rgba
[i
][BCOMP
] = rgba
[i
][ACOMP
] = 0;
3700 XMesaDestroyImage( span
);
3703 else if (source
->backimage
) {
3704 /* Read from XImage back buffer */
3705 switch (xmesa
->pixelformat
) {
3707 case PF_Dither_True
:
3709 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3710 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3711 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3712 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3713 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3714 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3715 GLint rShift
= xmesa
->xm_visual
->rshift
;
3716 GLint gShift
= xmesa
->xm_visual
->gshift
;
3717 GLint bShift
= xmesa
->xm_visual
->bshift
;
3718 XMesaImage
*img
= source
->backimage
;
3720 y
= FLIP(source
, y
);
3723 p
= XMesaGetPixel( img
, x
+i
, y
);
3724 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3725 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3726 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3727 rgba
[i
][ACOMP
] = 255;
3732 case PF_Dither_5R6G5B
:
3734 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3735 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3736 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3737 const GLushort
*ptr2
= PIXELADDR2( source
, x
, y
);
3739 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
3740 const GLuint
*ptr4
= (const GLuint
*) ptr2
;
3741 GLuint extraPixel
= (n
& 1);
3743 for (i
= 0; i
< n
; i
+= 2) {
3744 const GLuint p
= *ptr4
++;
3745 const GLuint p0
= p
& 0xffff;
3746 const GLuint p1
= p
>> 16;
3747 /* fast, but not quite accurate
3748 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3749 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3750 rgba[i][BCOMP] = ((p << 3) & 0xff);
3752 rgba
[i
][RCOMP
] = pixelToR
[p0
>> 11];
3753 rgba
[i
][GCOMP
] = pixelToG
[(p0
>> 5) & 0x3f];
3754 rgba
[i
][BCOMP
] = pixelToB
[p0
& 0x1f];
3755 rgba
[i
][ACOMP
] = 255;
3756 rgba
[i
+1][RCOMP
] = pixelToR
[p1
>> 11];
3757 rgba
[i
+1][GCOMP
] = pixelToG
[(p1
>> 5) & 0x3f];
3758 rgba
[i
+1][BCOMP
] = pixelToB
[p1
& 0x1f];
3759 rgba
[i
+1][ACOMP
] = 255;
3762 GLushort p
= ptr2
[n
];
3763 rgba
[n
][RCOMP
] = pixelToR
[p
>> 11];
3764 rgba
[n
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3765 rgba
[n
][BCOMP
] = pixelToB
[p
& 0x1f];
3766 rgba
[n
][ACOMP
] = 255;
3769 for (i
= 0; i
< n
; i
++) {
3770 const GLushort p
= ptr2
[i
];
3771 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
3772 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3773 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
3774 rgba
[i
][ACOMP
] = 255;
3781 const GLuint
*ptr4
= PIXELADDR4( source
, x
, y
);
3784 GLuint p4
= *ptr4
++;
3785 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
3786 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3787 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3788 rgba
[i
][ACOMP
] = (GLint
) ((p4
>> 24) & 0xff);
3794 const GLuint
*ptr4
= PIXELADDR4( source
, x
, y
);
3797 GLuint p4
= *ptr4
++;
3798 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3799 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3800 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3801 rgba
[i
][ACOMP
] = 255;
3807 const bgr_t
*ptr3
= PIXELADDR3( source
, x
, y
);
3810 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
3811 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
3812 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
3813 rgba
[i
][ACOMP
] = 255;
3819 const GLubyte
*ptr1
= PIXELADDR1( source
, x
, y
);
3822 GLubyte p
= *ptr1
++;
3823 rgba
[i
][RCOMP
] = p
& 0xE0;
3824 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
3825 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
3826 rgba
[i
][ACOMP
] = 255;
3834 const GLubyte
*rTable
= source
->pixel_to_r
;
3835 const GLubyte
*gTable
= source
->pixel_to_g
;
3836 const GLubyte
*bTable
= source
->pixel_to_b
;
3837 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
3838 GLubyte
*ptr1
= PIXELADDR1( source
, x
, y
);
3841 unsigned long p
= *ptr1
++;
3842 rgba
[i
][RCOMP
] = rTable
[p
];
3843 rgba
[i
][GCOMP
] = gTable
[p
];
3844 rgba
[i
][BCOMP
] = bTable
[p
];
3845 rgba
[i
][ACOMP
] = 255;
3849 XMesaImage
*img
= source
->backimage
;
3851 y
= FLIP(source
, y
);
3852 for (i
=0;i
<n
;i
++,x
++) {
3853 unsigned long p
= XMesaGetPixel( img
, x
, y
);
3854 rgba
[i
][RCOMP
] = rTable
[p
];
3855 rgba
[i
][GCOMP
] = gTable
[p
];
3856 rgba
[i
][BCOMP
] = bTable
[p
];
3857 rgba
[i
][ACOMP
] = 255;
3864 XMesaImage
*img
= source
->backimage
;
3865 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
3867 y
= FLIP(source
, y
);
3868 for (i
=0;i
<n
;i
++,x
++) {
3870 p
= XMesaGetPixel( img
, x
, y
) ^ bitFlip
;
3871 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
3872 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
3873 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
3874 rgba
[i
][ACOMP
] = 255;
3879 _mesa_problem(NULL
,"Problem in DD.read_color_span (2)");
3888 * Read an array of color index pixels.
3890 static void read_index_pixels( const GLcontext
*ctx
,
3891 GLuint n
, const GLint x
[], const GLint y
[],
3892 GLuint indx
[], const GLubyte mask
[] )
3894 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3896 XMesaBuffer source
= xmesa
->xm_buffer
;
3898 if (source
->buffer
) {
3901 indx
[i
] = (GLuint
) read_pixel( xmesa
->display
,
3903 x
[i
], FLIP(source
, y
[i
]) );
3907 else if (source
->backimage
) {
3908 XMesaImage
*img
= source
->backimage
;
3911 indx
[i
] = (GLuint
) XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
3919 static void read_color_pixels( const GLcontext
*ctx
,
3920 GLuint n
, const GLint x
[], const GLint y
[],
3921 GLubyte rgba
[][4], const GLubyte mask
[] )
3923 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3924 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3926 XMesaBuffer source
= xmesa
->xm_buffer
;
3927 XMesaDrawable buffer
= source
->buffer
; /* the X drawable */
3929 if (source
->buffer
) {
3930 switch (xmesa
->pixelformat
) {
3932 case PF_Dither_True
:
3934 case PF_Dither_5R6G5B
:
3936 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3937 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3938 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3939 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3940 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3941 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3942 GLint rShift
= xmesa
->xm_visual
->rshift
;
3943 GLint gShift
= xmesa
->xm_visual
->gshift
;
3944 GLint bShift
= xmesa
->xm_visual
->bshift
;
3947 unsigned long p
= read_pixel( dpy
, buffer
,
3948 x
[i
], FLIP(source
, y
[i
]) );
3949 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3950 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3951 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3952 rgba
[i
][ACOMP
] = 255;
3960 unsigned long p
= read_pixel( dpy
, buffer
,
3961 x
[i
], FLIP(source
, y
[i
]) );
3962 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xff);
3963 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
3964 rgba
[i
][BCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
3965 rgba
[i
][ACOMP
] = (GLubyte
) ((p
>> 24) & 0xff);
3972 unsigned long p
= read_pixel( dpy
, buffer
,
3973 x
[i
], FLIP(source
, y
[i
]) );
3974 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
3975 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
3976 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
3977 rgba
[i
][ACOMP
] = 255;
3984 unsigned long p
= read_pixel( dpy
, buffer
,
3985 x
[i
], FLIP(source
, y
[i
]) );
3986 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
3987 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
3988 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
3989 rgba
[i
][ACOMP
] = 255;
3997 unsigned long p
= read_pixel( dpy
, buffer
,
3998 x
[i
], FLIP(source
, y
[i
]) );
3999 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xE0 );
4000 rgba
[i
][GCOMP
] = (GLubyte
) ((p
& 0x1C) << 3);
4001 rgba
[i
][BCOMP
] = (GLubyte
) ((p
& 0x03) << 6);
4002 rgba
[i
][ACOMP
] = (GLubyte
) 255;
4011 GLubyte
*rTable
= source
->pixel_to_r
;
4012 GLubyte
*gTable
= source
->pixel_to_g
;
4013 GLubyte
*bTable
= source
->pixel_to_b
;
4016 unsigned long p
= read_pixel( dpy
, buffer
,
4017 x
[i
], FLIP(source
, y
[i
]) );
4018 rgba
[i
][RCOMP
] = rTable
[p
];
4019 rgba
[i
][GCOMP
] = gTable
[p
];
4020 rgba
[i
][BCOMP
] = bTable
[p
];
4021 rgba
[i
][ACOMP
] = 255;
4028 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4031 unsigned long p
= read_pixel( dpy
, buffer
,
4032 x
[i
], FLIP(source
, y
[i
])) ^ bitFlip
;
4033 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4034 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4035 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4036 rgba
[i
][ACOMP
] = 255;
4042 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4046 else if (source
->backimage
) {
4047 switch (xmesa
->pixelformat
) {
4049 case PF_Dither_True
:
4051 case PF_Dither_5R6G5B
:
4053 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4054 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4055 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4056 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4057 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4058 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4059 GLint rShift
= xmesa
->xm_visual
->rshift
;
4060 GLint gShift
= xmesa
->xm_visual
->gshift
;
4061 GLint bShift
= xmesa
->xm_visual
->bshift
;
4062 XMesaImage
*img
= source
->backimage
;
4066 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
4067 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4068 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4069 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4070 rgba
[i
][ACOMP
] = 255;
4078 GLuint
*ptr4
= PIXELADDR4( source
, x
[i
], y
[i
] );
4080 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
4081 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4082 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4083 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
4090 GLuint
*ptr4
= PIXELADDR4( source
, x
[i
], y
[i
] );
4092 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4093 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4094 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4095 rgba
[i
][ACOMP
] = 255;
4102 bgr_t
*ptr3
= PIXELADDR3( source
, x
[i
], y
[i
] );
4103 rgba
[i
][RCOMP
] = ptr3
->r
;
4104 rgba
[i
][GCOMP
] = ptr3
->g
;
4105 rgba
[i
][BCOMP
] = ptr3
->b
;
4106 rgba
[i
][ACOMP
] = 255;
4113 GLubyte
*ptr1
= PIXELADDR1( source
, x
[i
], y
[i
] );
4115 rgba
[i
][RCOMP
] = p
& 0xE0;
4116 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4117 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4118 rgba
[i
][ACOMP
] = 255;
4126 GLubyte
*rTable
= source
->pixel_to_r
;
4127 GLubyte
*gTable
= source
->pixel_to_g
;
4128 GLubyte
*bTable
= source
->pixel_to_b
;
4129 XMesaImage
*img
= source
->backimage
;
4133 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
4134 rgba
[i
][RCOMP
] = rTable
[p
];
4135 rgba
[i
][GCOMP
] = gTable
[p
];
4136 rgba
[i
][BCOMP
] = bTable
[p
];
4137 rgba
[i
][ACOMP
] = 255;
4144 XMesaImage
*img
= source
->backimage
;
4145 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4149 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) ) ^ bitFlip
;
4150 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4151 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4152 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4153 rgba
[i
][ACOMP
] = 255;
4159 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4167 clear_color_HPCR_ximage( GLcontext
*ctx
, const GLfloat color
[4] )
4170 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
4172 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[0], color
[0]);
4173 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[1], color
[1]);
4174 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[2], color
[2]);
4175 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[3], color
[3]);
4177 if (color
[0] == 0.0 && color
[1] == 0.0 && color
[2] == 0.0) {
4178 /* black is black */
4179 MEMSET( xmesa
->xm_visual
->hpcr_clear_ximage_pattern
, 0x0 ,
4180 sizeof(xmesa
->xm_visual
->hpcr_clear_ximage_pattern
));
4183 /* build clear pattern */
4184 for (i
=0; i
<16; i
++) {
4185 xmesa
->xm_visual
->hpcr_clear_ximage_pattern
[0][i
] =
4187 xmesa
->clearcolor
[0],
4188 xmesa
->clearcolor
[1],
4189 xmesa
->clearcolor
[2]);
4190 xmesa
->xm_visual
->hpcr_clear_ximage_pattern
[1][i
] =
4192 xmesa
->clearcolor
[0],
4193 xmesa
->clearcolor
[1],
4194 xmesa
->clearcolor
[2]);
4201 clear_color_HPCR_pixmap( GLcontext
*ctx
, const GLfloat color
[4] )
4204 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
4206 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[0], color
[0]);
4207 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[1], color
[1]);
4208 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[2], color
[2]);
4209 CLAMPED_FLOAT_TO_UBYTE(xmesa
->clearcolor
[3], color
[3]);
4211 if (color
[0] == 0.0 && color
[1] == 0.0 && color
[2] == 0.0) {
4212 /* black is black */
4213 for (i
=0; i
<16; i
++) {
4214 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 0, 0);
4215 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 1, 0);
4219 for (i
=0; i
<16; i
++) {
4220 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 0,
4222 xmesa
->clearcolor
[0],
4223 xmesa
->clearcolor
[1],
4224 xmesa
->clearcolor
[2]));
4225 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 1,
4227 xmesa
->clearcolor
[0],
4228 xmesa
->clearcolor
[1],
4229 xmesa
->clearcolor
[2]));
4232 /* change tile pixmap content */
4233 XMesaPutImage(xmesa
->display
,
4234 (XMesaDrawable
)xmesa
->xm_visual
->hpcr_clear_pixmap
,
4235 xmesa
->xm_buffer
->cleargc
,
4236 xmesa
->xm_visual
->hpcr_clear_ximage
, 0, 0, 0, 0, 16, 2);
4241 void xmesa_update_span_funcs( GLcontext
*ctx
)
4243 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
4244 int depth
=GET_VISUAL_DEPTH(xmesa
->xm_visual
);
4245 struct swrast_device_driver
*dd
= _swrast_GetDeviceDriverReference( ctx
);
4248 * These drawing functions depend on color buffer config:
4250 if (xmesa
->xm_buffer
->buffer
!=XIMAGE
) {
4251 /* Writing to window or back pixmap */
4252 switch (xmesa
->pixelformat
) {
4254 dd
->WriteCI32Span
= write_span_index_pixmap
;
4255 dd
->WriteCI8Span
= write_span_index8_pixmap
;
4256 dd
->WriteMonoCISpan
= write_span_mono_index_pixmap
;
4257 dd
->WriteCI32Pixels
= write_pixels_index_pixmap
;
4258 dd
->WriteMonoCIPixels
= write_pixels_mono_index_pixmap
;
4261 dd
->WriteRGBASpan
= write_span_TRUECOLOR_pixmap
;
4262 dd
->WriteRGBSpan
= write_span_rgb_TRUECOLOR_pixmap
;
4263 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4264 dd
->WriteRGBAPixels
= write_pixels_TRUECOLOR_pixmap
;
4265 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4267 case PF_Dither_True
:
4268 dd
->WriteRGBASpan
= write_span_TRUEDITHER_pixmap
;
4269 dd
->WriteRGBSpan
= write_span_rgb_TRUEDITHER_pixmap
;
4270 dd
->WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_pixmap
;
4271 dd
->WriteRGBAPixels
= write_pixels_TRUEDITHER_pixmap
;
4272 dd
->WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_pixmap
;
4275 dd
->WriteRGBASpan
= write_span_8A8B8G8R_pixmap
;
4276 dd
->WriteRGBSpan
= write_span_rgb_8A8B8G8R_pixmap
;
4277 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4278 dd
->WriteRGBAPixels
= write_pixels_8A8B8G8R_pixmap
;
4279 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4282 dd
->WriteRGBASpan
= write_span_8R8G8B_pixmap
;
4283 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B_pixmap
;
4284 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4285 dd
->WriteRGBAPixels
= write_pixels_8R8G8B_pixmap
;
4286 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4289 dd
->WriteRGBASpan
= write_span_8R8G8B24_pixmap
;
4290 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B24_pixmap
;
4291 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4292 dd
->WriteRGBAPixels
= write_pixels_8R8G8B24_pixmap
;
4293 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4296 dd
->WriteRGBASpan
= write_span_5R6G5B_pixmap
;
4297 dd
->WriteRGBSpan
= write_span_rgb_5R6G5B_pixmap
;
4298 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4299 dd
->WriteRGBAPixels
= write_pixels_5R6G5B_pixmap
;
4300 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4302 case PF_Dither_5R6G5B
:
4303 dd
->WriteRGBASpan
= write_span_DITHER_5R6G5B_pixmap
;
4304 dd
->WriteRGBSpan
= write_span_rgb_DITHER_5R6G5B_pixmap
;
4305 dd
->WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_pixmap
;
4306 dd
->WriteRGBAPixels
= write_pixels_DITHER_5R6G5B_pixmap
;
4307 dd
->WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_pixmap
;
4310 dd
->WriteRGBASpan
= write_span_DITHER_pixmap
;
4311 dd
->WriteRGBSpan
= write_span_rgb_DITHER_pixmap
;
4312 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER_pixmap
;
4313 dd
->WriteRGBAPixels
= write_pixels_DITHER_pixmap
;
4314 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER_pixmap
;
4317 dd
->WriteRGBASpan
= write_span_1BIT_pixmap
;
4318 dd
->WriteRGBSpan
= write_span_rgb_1BIT_pixmap
;
4319 dd
->WriteMonoRGBASpan
= write_span_mono_1BIT_pixmap
;
4320 dd
->WriteRGBAPixels
= write_pixels_1BIT_pixmap
;
4321 dd
->WriteMonoRGBAPixels
= write_pixels_mono_1BIT_pixmap
;
4324 dd
->WriteRGBASpan
= write_span_HPCR_pixmap
;
4325 dd
->WriteRGBSpan
= write_span_rgb_HPCR_pixmap
;
4326 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4327 dd
->WriteRGBAPixels
= write_pixels_HPCR_pixmap
;
4328 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4329 if (xmesa
->xm_visual
->hpcr_clear_flag
) {
4330 ctx
->Driver
.ClearColor
= clear_color_HPCR_pixmap
;
4334 dd
->WriteRGBASpan
= write_span_LOOKUP_pixmap
;
4335 dd
->WriteRGBSpan
= write_span_rgb_LOOKUP_pixmap
;
4336 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4337 dd
->WriteRGBAPixels
= write_pixels_LOOKUP_pixmap
;
4338 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4341 dd
->WriteRGBASpan
= write_span_GRAYSCALE_pixmap
;
4342 dd
->WriteRGBSpan
= write_span_rgb_GRAYSCALE_pixmap
;
4343 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4344 dd
->WriteRGBAPixels
= write_pixels_GRAYSCALE_pixmap
;
4345 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4348 _mesa_problem(NULL
,"Bad pixel format in xmesa_update_state (1)");
4352 else if (xmesa
->xm_buffer
->buffer
==XIMAGE
) {
4353 /* Writing to back XImage */
4354 switch (xmesa
->pixelformat
) {
4356 dd
->WriteCI32Span
= write_span_index_ximage
;
4358 dd
->WriteCI8Span
= write_span_index8_ximage8
;
4360 dd
->WriteCI8Span
= write_span_index8_ximage
;
4361 dd
->WriteMonoCISpan
= write_span_mono_index_ximage
;
4362 dd
->WriteCI32Pixels
= write_pixels_index_ximage
;
4363 dd
->WriteMonoCIPixels
= write_pixels_mono_index_ximage
;
4367 dd
->WriteRGBASpan
= write_span_TRUECOLOR_ximage
;
4368 dd
->WriteRGBSpan
= write_span_rgb_TRUECOLOR_ximage
;
4369 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4370 dd
->WriteRGBAPixels
= write_pixels_TRUECOLOR_ximage
;
4371 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4373 case PF_Dither_True
:
4374 dd
->WriteRGBASpan
= write_span_TRUEDITHER_ximage
;
4375 dd
->WriteRGBSpan
= write_span_rgb_TRUEDITHER_ximage
;
4376 dd
->WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_ximage
;
4377 dd
->WriteRGBAPixels
= write_pixels_TRUEDITHER_ximage
;
4378 dd
->WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_ximage
;
4381 dd
->WriteRGBASpan
= write_span_8A8B8G8R_ximage
;
4382 dd
->WriteRGBSpan
= write_span_rgb_8A8B8G8R_ximage
;
4383 dd
->WriteMonoRGBASpan
= write_span_mono_8A8B8G8R_ximage
;
4384 dd
->WriteRGBAPixels
= write_pixels_8A8B8G8R_ximage
;
4385 dd
->WriteMonoRGBAPixels
= write_pixels_mono_8A8B8G8R_ximage
;
4388 dd
->WriteRGBASpan
= write_span_8R8G8B_ximage
;
4389 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B_ximage
;
4390 dd
->WriteMonoRGBASpan
= write_span_mono_8R8G8B_ximage
;
4391 dd
->WriteRGBAPixels
= write_pixels_8R8G8B_ximage
;
4392 dd
->WriteMonoRGBAPixels
= write_pixels_mono_8R8G8B_ximage
;
4395 dd
->WriteRGBASpan
= write_span_8R8G8B24_ximage
;
4396 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B24_ximage
;
4397 dd
->WriteMonoRGBASpan
= write_span_mono_8R8G8B24_ximage
;
4398 dd
->WriteRGBAPixels
= write_pixels_8R8G8B24_ximage
;
4399 dd
->WriteMonoRGBAPixels
= write_pixels_mono_8R8G8B24_ximage
;
4402 dd
->WriteRGBASpan
= write_span_5R6G5B_ximage
;
4403 dd
->WriteRGBSpan
= write_span_rgb_5R6G5B_ximage
;
4404 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4405 dd
->WriteRGBAPixels
= write_pixels_5R6G5B_ximage
;
4406 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4408 case PF_Dither_5R6G5B
:
4409 dd
->WriteRGBASpan
= write_span_DITHER_5R6G5B_ximage
;
4410 dd
->WriteRGBSpan
= write_span_rgb_DITHER_5R6G5B_ximage
;
4411 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER_5R6G5B_ximage
;
4412 dd
->WriteRGBAPixels
= write_pixels_DITHER_5R6G5B_ximage
;
4413 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER_5R6G5B_ximage
;
4417 dd
->WriteRGBASpan
= write_span_DITHER8_ximage
;
4418 dd
->WriteRGBSpan
= write_span_rgb_DITHER8_ximage
;
4419 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER8_ximage
;
4420 dd
->WriteRGBAPixels
= write_pixels_DITHER8_ximage
;
4421 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER8_ximage
;
4424 dd
->WriteRGBASpan
= write_span_DITHER_ximage
;
4425 dd
->WriteRGBSpan
= write_span_rgb_DITHER_ximage
;
4426 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER_ximage
;
4427 dd
->WriteRGBAPixels
= write_pixels_DITHER_ximage
;
4428 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER_ximage
;
4432 dd
->WriteRGBASpan
= write_span_1BIT_ximage
;
4433 dd
->WriteRGBSpan
= write_span_rgb_1BIT_ximage
;
4434 dd
->WriteMonoRGBASpan
= write_span_mono_1BIT_ximage
;
4435 dd
->WriteRGBAPixels
= write_pixels_1BIT_ximage
;
4436 dd
->WriteMonoRGBAPixels
= write_pixels_mono_1BIT_ximage
;
4439 dd
->WriteRGBASpan
= write_span_HPCR_ximage
;
4440 dd
->WriteRGBSpan
= write_span_rgb_HPCR_ximage
;
4441 dd
->WriteMonoRGBASpan
= write_span_mono_HPCR_ximage
;
4442 dd
->WriteRGBAPixels
= write_pixels_HPCR_ximage
;
4443 dd
->WriteMonoRGBAPixels
= write_pixels_mono_HPCR_ximage
;
4444 if (xmesa
->xm_visual
->hpcr_clear_flag
) {
4445 ctx
->Driver
.ClearColor
= clear_color_HPCR_ximage
;
4450 dd
->WriteRGBASpan
= write_span_LOOKUP8_ximage
;
4451 dd
->WriteRGBSpan
= write_rgb_LOOKUP8_ximage
;
4452 dd
->WriteMonoRGBASpan
= write_span_mono_LOOKUP8_ximage
;
4453 dd
->WriteRGBAPixels
= write_pixels_LOOKUP8_ximage
;
4454 dd
->WriteMonoRGBAPixels
= write_pixels_mono_LOOKUP8_ximage
;
4457 dd
->WriteRGBASpan
= write_span_LOOKUP_ximage
;
4458 dd
->WriteRGBSpan
= write_span_rgb_LOOKUP_ximage
;
4459 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4460 dd
->WriteRGBAPixels
= write_pixels_LOOKUP_ximage
;
4461 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4466 dd
->WriteRGBASpan
= write_span_GRAYSCALE8_ximage
;
4467 dd
->WriteRGBSpan
= write_span_rgb_GRAYSCALE8_ximage
;
4468 dd
->WriteMonoRGBASpan
= write_span_mono_GRAYSCALE8_ximage
;
4469 dd
->WriteRGBAPixels
= write_pixels_GRAYSCALE8_ximage
;
4470 dd
->WriteMonoRGBAPixels
= write_pixels_mono_GRAYSCALE8_ximage
;
4473 dd
->WriteRGBASpan
= write_span_GRAYSCALE_ximage
;
4474 dd
->WriteRGBSpan
= write_span_rgb_GRAYSCALE_ximage
;
4475 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4476 dd
->WriteRGBAPixels
= write_pixels_GRAYSCALE_ximage
;
4477 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4481 _mesa_problem(NULL
,"Bad pixel format in xmesa_update_state (2)");
4486 /* Pixel/span reading functions: */
4487 dd
->ReadCI32Span
= read_index_span
;
4488 dd
->ReadRGBASpan
= read_color_span
;
4489 dd
->ReadCI32Pixels
= read_index_pixels
;
4490 dd
->ReadRGBAPixels
= read_color_pixels
;