1 /* $Id: xm_span.c,v 1.14 2002/03/01 04:28:32 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"
37 #include "extensions.h"
39 #include "swrast/swrast.h"
43 * The following functions are used to trap XGetImage() calls which
44 * generate BadMatch errors if the drawable isn't mapped.
48 static int caught_xgetimage_error
= 0;
49 static int (*old_xerror_handler
)( XMesaDisplay
*dpy
, XErrorEvent
*ev
);
50 static unsigned long xgetimage_serial
;
53 * This is the error handler which will be called if XGetImage fails.
55 static int xgetimage_error_handler( XMesaDisplay
*dpy
, XErrorEvent
*ev
)
57 if (ev
->serial
==xgetimage_serial
&& ev
->error_code
==BadMatch
) {
58 /* caught the expected error */
59 caught_xgetimage_error
= 0;
62 /* call the original X error handler, if any. otherwise ignore */
63 if (old_xerror_handler
) {
64 (*old_xerror_handler
)( dpy
, ev
);
72 * Call this right before XGetImage to setup error trap.
74 static void catch_xgetimage_errors( XMesaDisplay
*dpy
)
76 xgetimage_serial
= NextRequest( dpy
);
77 old_xerror_handler
= XSetErrorHandler( xgetimage_error_handler
);
78 caught_xgetimage_error
= 0;
83 * Call this right after XGetImage to check if an error occured.
85 static int check_xgetimage_errors( void )
87 /* restore old handler */
88 (void) XSetErrorHandler( old_xerror_handler
);
89 /* return 0=no error, 1=error caught */
90 return caught_xgetimage_error
;
96 * Read a pixel from an X drawable.
98 static unsigned long read_pixel( XMesaDisplay
*dpy
,
99 XMesaDrawable d
, int x
, int y
)
102 #ifndef XFree86Server
103 XMesaImage
*pixel
= NULL
;
106 catch_xgetimage_errors( dpy
);
107 pixel
= XGetImage( dpy
, d
, x
, y
, 1, 1, AllPlanes
, ZPixmap
);
108 error
= check_xgetimage_errors();
109 if (pixel
&& !error
) {
110 p
= XMesaGetPixel( pixel
, 0, 0 );
116 XMesaDestroyImage( pixel
);
119 (*dpy
->GetImage
)(d
, x
, y
, 1, 1, ZPixmap
, ~0L, (pointer
)&p
);
127 * The Mesa library needs to be able to draw pixels in a number of ways:
128 * 1. RGB vs Color Index
129 * 2. as horizontal spans (polygons, images) vs random locations (points,
131 * 3. different color per-pixel or same color for all pixels
133 * Furthermore, the X driver needs to support rendering to 3 possible
134 * "buffers", usually one, but sometimes two at a time:
135 * 1. The front buffer as an X window
136 * 2. The back buffer as a Pixmap
137 * 3. The back buffer as an XImage
139 * Finally, if the back buffer is an XImage, we can avoid using XPutPixel and
140 * optimize common cases such as 24-bit and 8-bit modes.
142 * By multiplication, there's at least 48 possible combinations of the above.
144 * Below are implementations of the most commonly used combinations. They are
145 * accessed through function pointers which get initialized here and are used
146 * directly from the Mesa library. The 8 function pointers directly correspond
147 * to the first 3 cases listed above.
150 * The function naming convention is:
152 * write_[span|pixels]_[mono]_[format]_[pixmap|ximage]
154 * New functions optimized for specific cases can be added without too much
155 * trouble. An example might be the 24-bit TrueColor mode 8A8R8G8B which is
156 * found on IBM RS/6000 X servers.
162 /**********************************************************************/
163 /*** Write COLOR SPAN functions ***/
164 /**********************************************************************/
167 #define RGBA_SPAN_ARGS const GLcontext *ctx, \
168 GLuint n, GLint x, GLint y, \
169 CONST GLubyte rgba[][4], const GLubyte mask[]
171 #define RGB_SPAN_ARGS const GLcontext *ctx, \
172 GLuint n, GLint x, GLint y, \
173 CONST GLubyte rgb[][3], const GLubyte mask[]
176 /* NOTE: if mask==NULL, draw all pixels */
180 * Write a span of PF_TRUECOLOR pixels to a pixmap.
182 static void write_span_TRUECOLOR_pixmap( RGBA_SPAN_ARGS
)
184 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
185 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
186 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
187 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
190 (void)DitherValues
; /* Muffle compiler */
192 y
= FLIP(xmesa
->xm_buffer
, y
);
194 for (i
=0;i
<n
;i
++,x
++) {
197 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
198 XMesaSetForeground( dpy
, gc
, p
);
199 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
204 /* draw all pixels */
205 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
208 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
209 XMesaPutPixel( rowimg
, i
, 0, p
);
211 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
217 * Write a span of PF_TRUECOLOR pixels to a pixmap.
219 static void write_span_rgb_TRUECOLOR_pixmap( RGB_SPAN_ARGS
)
221 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
222 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
223 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
224 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
226 y
= FLIP(xmesa
->xm_buffer
, y
);
228 for (i
=0;i
<n
;i
++,x
++) {
231 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
232 XMesaSetForeground( dpy
, gc
, p
);
233 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
238 /* draw all pixels */
239 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
242 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
243 XMesaPutPixel( rowimg
, i
, 0, p
);
245 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
251 * Write a span of PF_TRUEDITHER pixels to a pixmap.
253 static void write_span_TRUEDITHER_pixmap( RGBA_SPAN_ARGS
)
255 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
256 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
257 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
258 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
260 y
= FLIP(xmesa
->xm_buffer
, y
);
262 for (i
=0;i
<n
;i
++,x
++) {
265 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
266 XMesaSetForeground( dpy
, gc
, p
);
267 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
272 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
275 PACK_TRUEDITHER(p
, x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
276 XMesaPutPixel( rowimg
, i
, 0, p
);
278 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
284 * Write a span of PF_TRUEDITHER pixels to a pixmap (no alpha).
286 static void write_span_rgb_TRUEDITHER_pixmap( RGB_SPAN_ARGS
)
288 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
289 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
290 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
291 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
293 y
= FLIP(xmesa
->xm_buffer
, y
);
295 for (i
=0;i
<n
;i
++,x
++) {
298 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
299 XMesaSetForeground( dpy
, gc
, p
);
300 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
305 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
308 PACK_TRUEDITHER(p
, x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
309 XMesaPutPixel( rowimg
, i
, 0, p
);
311 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
318 * Write a span of PF_8A8B8G8R pixels to a pixmap.
320 static void write_span_8A8B8G8R_pixmap( RGBA_SPAN_ARGS
)
322 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
323 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
324 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
325 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
327 y
= FLIP(xmesa
->xm_buffer
, y
);
329 for (i
=0;i
<n
;i
++,x
++) {
331 XMesaSetForeground( dpy
, gc
,
332 PACK_8A8B8G8R(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
]) );
333 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
338 /* draw all pixels */
339 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
340 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
342 *ptr4
++ = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
344 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
350 * Write a span of PF_8A8B8G8R pixels to a pixmap (no alpha).
352 static void write_span_rgb_8A8B8G8R_pixmap( RGB_SPAN_ARGS
)
354 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
355 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
356 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
357 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
359 y
= FLIP(xmesa
->xm_buffer
, y
);
361 for (i
=0;i
<n
;i
++,x
++) {
363 XMesaSetForeground( dpy
, gc
,
364 PACK_8B8G8R(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
365 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
370 /* draw all pixels */
371 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
372 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
374 *ptr4
++ = PACK_8B8G8R(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
376 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
382 * Write a span of PF_8R8G8B pixels to a pixmap.
384 static void write_span_8R8G8B_pixmap( RGBA_SPAN_ARGS
)
386 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
387 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
388 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
389 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
391 y
= FLIP(xmesa
->xm_buffer
, y
);
393 for (i
=0;i
<n
;i
++,x
++) {
395 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
396 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
401 /* draw all pixels */
402 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
403 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
405 *ptr4
++ = PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
407 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
413 * Write a span of PF_8R8G8B24 pixels to a pixmap.
415 static void write_span_8R8G8B24_pixmap( RGBA_SPAN_ARGS
)
417 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
418 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
419 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
420 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
421 y
= FLIP(xmesa
->xm_buffer
, y
);
424 for (i
=0;i
<n
;i
++,x
++) {
426 XMesaSetForeground( dpy
, gc
,
427 PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
428 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
433 /* draw all pixels */
434 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
435 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
436 register GLuint pixel
;
437 static const GLuint shift
[4] = {0, 8, 16, 24};
438 register GLuint i
= 0;
441 pixel
= rgba
[i
][BCOMP
] /* << shift[0]*/;
442 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
443 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
444 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
447 pixel
= rgba
[i
][GCOMP
] /* << shift[0]*/;
448 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
449 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
450 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
453 pixel
= rgba
[i
++][RCOMP
]/* << shift[0]*/;
454 pixel
|= rgba
[i
][BCOMP
] << shift
[1];
455 pixel
|= rgba
[i
][GCOMP
] << shift
[2];
456 pixel
|= rgba
[i
++][RCOMP
] << shift
[3];
464 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
465 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
466 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
467 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
470 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
471 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
472 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
473 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
475 pixel
= 0xffffff00 & *ptr4
;
476 pixel
|= rgba
[i
][RCOMP
] /*<< shift[0]*/;
481 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
482 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
483 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
484 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
486 pixel
= 0xffff0000 & *ptr4
;
487 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
488 pixel
|= rgba
[i
][RCOMP
] << shift
[1];
492 pixel
= 0xff000000 & *ptr4
;
493 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
494 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
495 pixel
|= rgba
[i
][RCOMP
] << shift
[2];
501 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
507 * Write a span of PF_8R8G8B pixels to a pixmap (no alpha).
509 static void write_span_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS
)
511 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
512 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
513 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
514 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
516 y
= FLIP(xmesa
->xm_buffer
, y
);
518 for (i
=0;i
<n
;i
++,x
++) {
520 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
521 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
526 /* draw all pixels */
527 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
528 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
530 *ptr4
++ = PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
532 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
538 * Write a span of PF_8R8G8B24 pixels to a pixmap (no alpha).
540 static void write_span_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS
)
542 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
543 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
544 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
545 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
546 y
= FLIP(xmesa
->xm_buffer
, y
);
549 for (i
=0;i
<n
;i
++,x
++) {
551 XMesaSetForeground( dpy
, gc
,
552 PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
553 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
558 /* draw all pixels */
559 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
560 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
561 register GLuint pixel
;
562 static const GLuint shift
[4] = {0, 8, 16, 24};
564 register GLuint i
= 0;
567 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
568 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
569 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
570 pixel
|= rgb
[i
][BCOMP
] <<shift
[3];
574 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
575 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
576 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
577 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
581 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
582 pixel
|= rgb
[i
][BCOMP
] << shift
[1];
583 pixel
|= rgb
[i
][GCOMP
] << shift
[2];
584 pixel
|= rgb
[i
++][RCOMP
] << shift
[3];
591 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
592 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
593 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
594 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
597 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
598 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
599 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
600 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
604 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
609 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
610 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
611 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
612 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
616 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
617 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
623 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
624 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
625 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
631 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
637 * Write a span of PF_5R6G5B pixels to a pixmap.
639 static void write_span_5R6G5B_pixmap( RGBA_SPAN_ARGS
)
641 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
642 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
643 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
644 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
646 y
= FLIP(xmesa
->xm_buffer
, y
);
648 for (i
=0;i
<n
;i
++,x
++) {
650 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
651 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
656 /* draw all pixels */
657 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
658 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
660 ptr2
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
662 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
668 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap.
670 static void write_span_DITHER_5R6G5B_pixmap( RGBA_SPAN_ARGS
)
672 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
673 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
674 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
675 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
677 y
= FLIP(xmesa
->xm_buffer
, y
);
679 for (i
=0;i
<n
;i
++,x
++) {
682 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
683 XMesaSetForeground( dpy
, gc
, p
);
684 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
689 /* draw all pixels */
690 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
691 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
693 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
695 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
701 * Write a span of PF_5R6G5B pixels to a pixmap (no alpha).
703 static void write_span_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS
)
705 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
706 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
707 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
708 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
710 y
= FLIP(xmesa
->xm_buffer
, y
);
712 for (i
=0;i
<n
;i
++,x
++) {
714 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
715 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
720 /* draw all pixels */
721 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
722 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
724 ptr2
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
726 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
732 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap (no alpha).
734 static void write_span_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS
)
736 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
737 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
738 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
739 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
741 y
= FLIP(xmesa
->xm_buffer
, y
);
743 for (i
=0;i
<n
;i
++,x
++) {
746 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
747 XMesaSetForeground( dpy
, gc
, p
);
748 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
753 /* draw all pixels */
754 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
755 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
757 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
759 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
766 * Write a span of PF_DITHER pixels to a pixmap.
768 static void write_span_DITHER_pixmap( RGBA_SPAN_ARGS
)
770 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
771 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
772 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
773 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
776 y
= FLIP(xmesa
->xm_buffer
, y
);
778 for (i
=0;i
<n
;i
++,x
++) {
780 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
781 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
786 /* draw all pixels */
787 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
789 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
791 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
797 * Write a span of PF_DITHER pixels to a pixmap (no alpha).
799 static void write_span_rgb_DITHER_pixmap( RGB_SPAN_ARGS
)
801 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
802 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
803 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
804 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
807 y
= FLIP(xmesa
->xm_buffer
, y
);
809 for (i
=0;i
<n
;i
++,x
++) {
811 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
812 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
817 /* draw all pixels */
818 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
820 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
822 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
828 * Write a span of PF_1BIT pixels to a pixmap.
830 static void write_span_1BIT_pixmap( RGBA_SPAN_ARGS
)
832 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
833 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
834 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
835 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
838 y
= FLIP(xmesa
->xm_buffer
, y
);
840 for (i
=0;i
<n
;i
++,x
++) {
842 XMesaSetForeground( dpy
, gc
,
843 DITHER_1BIT( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
844 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
849 /* draw all pixels */
850 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
852 XMesaPutPixel( rowimg
, i
, 0,
853 DITHER_1BIT( x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
855 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
861 * Write a span of PF_1BIT pixels to a pixmap (no alpha).
863 static void write_span_rgb_1BIT_pixmap( RGB_SPAN_ARGS
)
865 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
866 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
867 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
868 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
871 y
= FLIP(xmesa
->xm_buffer
, y
);
873 for (i
=0;i
<n
;i
++,x
++) {
875 XMesaSetForeground( dpy
, gc
,
876 DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
877 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
882 /* draw all pixels */
883 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
885 XMesaPutPixel( rowimg
, i
, 0,
886 DITHER_1BIT(x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
888 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
894 * Write a span of PF_HPCR pixels to a pixmap.
896 static void write_span_HPCR_pixmap( RGBA_SPAN_ARGS
)
898 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
899 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
900 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
901 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
903 y
= FLIP(xmesa
->xm_buffer
, y
);
905 for (i
=0;i
<n
;i
++,x
++) {
907 XMesaSetForeground( dpy
, gc
,
908 DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
909 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
914 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
915 register GLubyte
*ptr
= (GLubyte
*) xmesa
->xm_buffer
->rowimage
->data
;
917 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
919 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
925 * Write a span of PF_HPCR pixels to a pixmap (no alpha).
927 static void write_span_rgb_HPCR_pixmap( RGB_SPAN_ARGS
)
929 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
930 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
931 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
932 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
934 y
= FLIP(xmesa
->xm_buffer
, y
);
936 for (i
=0;i
<n
;i
++,x
++) {
938 XMesaSetForeground( dpy
, gc
,
939 DITHER_HPCR(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
940 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
945 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
946 register GLubyte
*ptr
= (GLubyte
*) xmesa
->xm_buffer
->rowimage
->data
;
948 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
950 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
956 * Write a span of PF_LOOKUP pixels to a pixmap.
958 static void write_span_LOOKUP_pixmap( RGBA_SPAN_ARGS
)
960 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
961 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
962 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
963 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
966 y
= FLIP(xmesa
->xm_buffer
, y
);
968 for (i
=0;i
<n
;i
++,x
++) {
970 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
971 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
976 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
978 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
980 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
986 * Write a span of PF_LOOKUP pixels to a pixmap (no alpha).
988 static void write_span_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS
)
990 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
991 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
992 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
993 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
996 y
= FLIP(xmesa
->xm_buffer
, y
);
998 for (i
=0;i
<n
;i
++,x
++) {
1000 XMesaSetForeground( dpy
, gc
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1001 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1006 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1008 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1010 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1017 * Write a span of PF_GRAYSCALE pixels to a pixmap.
1019 static void write_span_GRAYSCALE_pixmap( RGBA_SPAN_ARGS
)
1021 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1022 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1023 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
1024 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
1026 y
= FLIP(xmesa
->xm_buffer
, y
);
1028 for (i
=0;i
<n
;i
++,x
++) {
1030 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1031 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1036 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1038 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
1040 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1046 * Write a span of PF_GRAYSCALE pixels to a pixmap (no alpha).
1048 static void write_span_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS
)
1050 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1051 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1052 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
1053 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
1055 y
= FLIP(xmesa
->xm_buffer
, y
);
1057 for (i
=0;i
<n
;i
++,x
++) {
1059 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1060 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1065 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1067 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1069 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1075 * Write a span of PF_TRUECOLOR pixels to an XImage.
1077 static void write_span_TRUECOLOR_ximage( RGBA_SPAN_ARGS
)
1079 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1080 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1082 y
= FLIP(xmesa
->xm_buffer
, y
);
1084 for (i
=0;i
<n
;i
++,x
++) {
1087 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1088 XMesaPutPixel( img
, x
, y
, p
);
1093 /* draw all pixels */
1094 for (i
=0;i
<n
;i
++,x
++) {
1096 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1097 XMesaPutPixel( img
, x
, y
, p
);
1104 * Write a span of PF_TRUECOLOR pixels to an XImage (no alpha).
1106 static void write_span_rgb_TRUECOLOR_ximage( RGB_SPAN_ARGS
)
1108 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1109 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1111 y
= FLIP(xmesa
->xm_buffer
, y
);
1113 for (i
=0;i
<n
;i
++,x
++) {
1116 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1117 XMesaPutPixel( img
, x
, y
, p
);
1122 /* draw all pixels */
1123 for (i
=0;i
<n
;i
++,x
++) {
1125 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1126 XMesaPutPixel( img
, x
, y
, p
);
1133 * Write a span of PF_TRUEDITHER pixels to an XImage.
1135 static void write_span_TRUEDITHER_ximage( RGBA_SPAN_ARGS
)
1137 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1138 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1140 y
= FLIP(xmesa
->xm_buffer
, y
);
1142 for (i
=0;i
<n
;i
++,x
++) {
1145 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1146 XMesaPutPixel( img
, x
, y
, p
);
1151 /* draw all pixels */
1152 for (i
=0;i
<n
;i
++,x
++) {
1154 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1155 XMesaPutPixel( img
, x
, y
, p
);
1162 * Write a span of PF_TRUEDITHER pixels to an XImage (no alpha).
1164 static void write_span_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS
)
1166 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1167 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1169 y
= FLIP(xmesa
->xm_buffer
, y
);
1171 for (i
=0;i
<n
;i
++,x
++) {
1174 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1175 XMesaPutPixel( img
, x
, y
, p
);
1180 /* draw all pixels */
1181 for (i
=0;i
<n
;i
++,x
++) {
1183 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1184 XMesaPutPixel( img
, x
, y
, p
);
1191 * Write a span of PF_8A8B8G8R-format pixels to an ximage.
1193 static void write_span_8A8B8G8R_ximage( RGBA_SPAN_ARGS
)
1195 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1197 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1201 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1206 /* draw all pixels */
1208 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1215 * Write a span of PF_8A8B8G8R-format pixels to an ximage (no alpha).
1217 static void write_span_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS
)
1219 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1221 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1225 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1230 /* draw all pixels */
1232 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1239 * Write a span of PF_8R8G8B-format pixels to an ximage.
1241 static void write_span_8R8G8B_ximage( RGBA_SPAN_ARGS
)
1243 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1245 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1249 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1255 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1262 * Write a span of PF_8R8G8B24-format pixels to an ximage.
1264 static void write_span_8R8G8B24_ximage( RGBA_SPAN_ARGS
)
1266 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1268 register GLubyte
*ptr
= (GLubyte
*) PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
1272 GLuint
*ptr4
= (GLuint
*) ptr
;
1273 register GLuint pixel
= *ptr4
;
1274 switch (3 & (int)(ptr
- (GLubyte
*)ptr4
)) {
1276 pixel
&= 0xff000000;
1277 pixel
|= rgba
[i
][BCOMP
];
1278 pixel
|= rgba
[i
][GCOMP
] << 8;
1279 pixel
|= rgba
[i
][RCOMP
] << 16;
1283 pixel
&= 0x00ffffff;
1284 pixel
|= rgba
[i
][BCOMP
] << 24;
1286 pixel
= *ptr4
&& 0xffff0000;
1287 pixel
|= rgba
[i
][GCOMP
];
1288 pixel
|= rgba
[i
][RCOMP
] << 8;
1292 pixel
&= 0x0000ffff;
1293 pixel
|= rgba
[i
][BCOMP
] << 16;
1294 pixel
|= rgba
[i
][GCOMP
] << 24;
1296 pixel
= *ptr4
&& 0xffffff00;
1297 pixel
|= rgba
[i
][RCOMP
];
1301 pixel
&= 0x000000ff;
1302 pixel
|= rgba
[i
][BCOMP
] << 8;
1303 pixel
|= rgba
[i
][GCOMP
] << 16;
1304 pixel
|= rgba
[i
][RCOMP
] << 24;
1313 /* write all pixels */
1315 GLuint
*ptr4
= (GLuint
*) ptr
;
1316 register GLuint pixel
= *ptr4
;
1317 int index
= (int)(ptr
- (GLubyte
*)ptr4
);
1318 register GLuint i
= 0;
1323 pixel
&= 0x00ffffff;
1324 pixel
|= rgba
[i
][BCOMP
] << 24;
1326 pixel
= *ptr4
&& 0xffff0000;
1327 pixel
|= rgba
[i
][GCOMP
];
1328 pixel
|= rgba
[i
++][RCOMP
] << 8;
1333 pixel
&= 0x0000ffff;
1334 pixel
|= rgba
[i
][BCOMP
] << 16;
1335 pixel
|= rgba
[i
][GCOMP
] << 24;
1337 pixel
= *ptr4
&& 0xffffff00;
1338 pixel
|= rgba
[i
++][RCOMP
];
1343 pixel
&= 0x000000ff;
1344 pixel
|= rgba
[i
][BCOMP
] << 8;
1345 pixel
|= rgba
[i
][GCOMP
] << 16;
1346 pixel
|= rgba
[i
++][RCOMP
] << 24;
1353 pixel
= rgba
[i
][BCOMP
];
1354 pixel
|= rgba
[i
][GCOMP
] << 8;
1355 pixel
|= rgba
[i
++][RCOMP
] << 16;
1356 pixel
|= rgba
[i
][BCOMP
] << 24;
1358 pixel
= rgba
[i
][GCOMP
];
1359 pixel
|= rgba
[i
++][RCOMP
] << 8;
1360 pixel
|= rgba
[i
][BCOMP
] << 16;
1361 pixel
|= rgba
[i
][GCOMP
] << 24;
1363 pixel
= rgba
[i
++][RCOMP
];
1364 pixel
|= rgba
[i
][BCOMP
] << 8;
1365 pixel
|= rgba
[i
][GCOMP
] << 16;
1366 pixel
|= rgba
[i
++][RCOMP
] << 24;
1374 pixel
= *ptr4
& 0xff000000;
1375 pixel
|= rgba
[i
][BCOMP
];
1376 pixel
|= rgba
[i
][GCOMP
] << 8;
1377 pixel
|= rgba
[i
][RCOMP
] << 16;
1381 pixel
= rgba
[i
][BCOMP
];
1382 pixel
|= rgba
[i
][GCOMP
] << 8;
1383 pixel
|= rgba
[i
++][RCOMP
] << 16;
1384 pixel
|= rgba
[i
][BCOMP
] << 24;
1386 pixel
= *ptr4
& 0xffff0000;
1387 pixel
|= rgba
[i
][GCOMP
];
1388 pixel
|= rgba
[i
][RCOMP
] << 8;
1392 pixel
= rgba
[i
][BCOMP
];
1393 pixel
|= rgba
[i
][GCOMP
] << 8;
1394 pixel
|= rgba
[i
++][RCOMP
] << 16;
1395 pixel
|= rgba
[i
][BCOMP
] << 24;
1397 pixel
= rgba
[i
][GCOMP
];
1398 pixel
|= rgba
[i
++][RCOMP
] << 8;
1399 pixel
|= rgba
[i
][BCOMP
] << 16;
1400 pixel
|= rgba
[i
][GCOMP
] << 24;
1402 pixel
= *ptr4
& 0xffffff00;
1403 pixel
|= rgba
[i
][RCOMP
];
1412 * Write a span of PF_8R8G8B-format pixels to an ximage (no alpha).
1414 static void write_span_rgb_8R8G8B_ximage( RGB_SPAN_ARGS
)
1416 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1418 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1422 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1427 /* draw all pixels */
1429 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1436 * Write a span of PF_8R8G8B24-format pixels to an ximage (no alpha).
1438 static void write_span_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS
)
1440 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1442 register GLubyte
*ptr
= (GLubyte
*) PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
1446 *ptr
++ = rgb
[i
][BCOMP
];
1447 *ptr
++ = rgb
[i
][GCOMP
];
1448 *ptr
++ = rgb
[i
][RCOMP
];
1456 /* draw all pixels */
1458 *ptr
++ = rgb
[i
][BCOMP
];
1459 *ptr
++ = rgb
[i
][GCOMP
];
1460 *ptr
++ = rgb
[i
][RCOMP
];
1467 * Write a span of PF_5R6G5B-format pixels to an ximage.
1469 static void write_span_5R6G5B_ximage( RGBA_SPAN_ARGS
)
1471 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1473 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1477 ptr
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1482 /* draw all pixels */
1483 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1484 GLuint
*ptr32
= (GLuint
*) ptr
;
1485 GLuint extraPixel
= (n
& 1);
1487 for (i
= 0; i
< n
; i
+= 2) {
1489 p0
= PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1490 p1
= PACK_5R6G5B(rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
]);
1491 *ptr32
++ = (p1
<< 16) | p0
;
1494 ptr
[n
] = PACK_5R6G5B(rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1497 for (i
= 0; i
< n
; i
++) {
1498 ptr
[i
] = PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1506 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage.
1508 static void write_span_DITHER_5R6G5B_ximage( RGBA_SPAN_ARGS
)
1510 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1512 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1513 const GLint y2
= FLIP(xmesa
->xm_buffer
, y
);
1515 for (i
=0;i
<n
;i
++,x
++) {
1517 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1522 /* draw all pixels */
1523 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1524 GLuint
*ptr32
= (GLuint
*) ptr
;
1525 GLuint extraPixel
= (n
& 1);
1527 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1529 PACK_TRUEDITHER( p0
, x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1530 PACK_TRUEDITHER( p1
, x
+1, y2
, rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
] );
1531 *ptr32
++ = (p1
<< 16) | p0
;
1534 PACK_TRUEDITHER( ptr
[n
], x
+n
, y2
, rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1537 for (i
= 0; i
< n
; i
++, x
++) {
1538 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1546 * Write a span of PF_5R6G5B-format pixels to an ximage (no alpha).
1548 static void write_span_rgb_5R6G5B_ximage( RGB_SPAN_ARGS
)
1550 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1552 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1556 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1561 /* draw all pixels */
1562 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1563 GLuint
*ptr32
= (GLuint
*) ptr
;
1564 GLuint extraPixel
= (n
& 1);
1566 for (i
= 0; i
< n
; i
+= 2) {
1568 p0
= PACK_5R6G5B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1569 p1
= PACK_5R6G5B(rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
]);
1570 *ptr32
++ = (p1
<< 16) | p0
;
1573 ptr
[n
] = PACK_5R6G5B(rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1577 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1585 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage (no alpha).
1587 static void write_span_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS
)
1589 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1591 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1593 for (i
=0;i
<n
;i
++,x
++) {
1595 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1600 /* draw all pixels */
1601 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1602 GLuint
*ptr32
= (GLuint
*) ptr
;
1603 GLuint extraPixel
= (n
& 1);
1605 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1607 PACK_TRUEDITHER( p0
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1608 PACK_TRUEDITHER( p1
, x
+1, y
, rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
] );
1609 *ptr32
++ = (p1
<< 16) | p0
;
1612 PACK_TRUEDITHER( ptr
[n
], x
+n
, y
, rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1615 for (i
=0;i
<n
;i
++,x
++) {
1616 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1624 * Write a span of PF_DITHER pixels to an XImage.
1626 static void write_span_DITHER_ximage( RGBA_SPAN_ARGS
)
1628 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1629 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1631 int yy
= FLIP(xmesa
->xm_buffer
, y
);
1634 for (i
=0;i
<n
;i
++,x
++) {
1636 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1641 /* draw all pixels */
1642 for (i
=0;i
<n
;i
++,x
++) {
1643 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1650 * Write a span of PF_DITHER pixels to an XImage (no alpha).
1652 static void write_span_rgb_DITHER_ximage( RGB_SPAN_ARGS
)
1654 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1655 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1657 int yy
= FLIP(xmesa
->xm_buffer
, y
);
1660 for (i
=0;i
<n
;i
++,x
++) {
1662 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1667 /* draw all pixels */
1668 for (i
=0;i
<n
;i
++,x
++) {
1669 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1677 * Write a span of 8-bit PF_DITHER pixels to an XImage.
1679 static void write_span_DITHER8_ximage( RGBA_SPAN_ARGS
)
1681 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1683 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1686 for (i
=0;i
<n
;i
++,x
++) {
1688 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1693 for (i
=0;i
<n
;i
++,x
++) {
1694 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1700 static void write_span_rgb_DITHER8_ximage( RGB_SPAN_ARGS
)
1702 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1704 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1707 for (i
=0;i
<n
;i
++,x
++) {
1709 ptr
[i
] = (GLubyte
) XDITHER( x
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
1714 const GLubyte
*data
= (GLubyte
*) rgb
;
1715 for (i
=0;i
<n
;i
++,x
++) {
1716 /*ptr[i] = XDITHER( x, rgb[i][0], rgb[i][1], rgb[i][2] );*/
1717 ptr
[i
] = (GLubyte
) XDITHER( x
, data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
1725 * Write a span of PF_1BIT pixels to an XImage.
1727 static void write_span_1BIT_ximage( RGBA_SPAN_ARGS
)
1729 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1730 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1733 y
= FLIP(xmesa
->xm_buffer
, y
);
1735 for (i
=0;i
<n
;i
++,x
++) {
1737 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]));
1742 for (i
=0;i
<n
;i
++,x
++) {
1743 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
1750 * Write a span of PF_1BIT pixels to an XImage (no alpha).
1752 static void write_span_rgb_1BIT_ximage( RGB_SPAN_ARGS
)
1754 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1755 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1758 y
= FLIP(xmesa
->xm_buffer
, y
);
1760 for (i
=0;i
<n
;i
++,x
++) {
1762 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]));
1767 for (i
=0;i
<n
;i
++,x
++) {
1768 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
1775 * Write a span of PF_HPCR pixels to an XImage.
1777 static void write_span_HPCR_ximage( RGBA_SPAN_ARGS
)
1779 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1781 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1783 for (i
=0;i
<n
;i
++,x
++) {
1785 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1790 /* draw all pixels */
1791 for (i
=0;i
<n
;i
++,x
++) {
1792 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1799 * Write a span of PF_HPCR pixels to an XImage (no alpha).
1801 static void write_span_rgb_HPCR_ximage( RGB_SPAN_ARGS
)
1803 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1805 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1807 for (i
=0;i
<n
;i
++,x
++) {
1809 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1814 /* draw all pixels */
1815 for (i
=0;i
<n
;i
++,x
++) {
1816 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1823 * Write a span of PF_LOOKUP pixels to an XImage.
1825 static void write_span_LOOKUP_ximage( RGBA_SPAN_ARGS
)
1827 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1828 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1831 y
= FLIP(xmesa
->xm_buffer
, y
);
1833 for (i
=0;i
<n
;i
++,x
++) {
1835 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1840 /* draw all pixels */
1841 for (i
=0;i
<n
;i
++,x
++) {
1842 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1849 * Write a span of PF_LOOKUP pixels to an XImage (no alpha).
1851 static void write_span_rgb_LOOKUP_ximage( RGB_SPAN_ARGS
)
1853 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1854 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1857 y
= FLIP(xmesa
->xm_buffer
, y
);
1859 for (i
=0;i
<n
;i
++,x
++) {
1861 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1866 /* draw all pixels */
1867 for (i
=0;i
<n
;i
++,x
++) {
1868 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1875 * Write a span of 8-bit PF_LOOKUP pixels to an XImage.
1877 static void write_span_LOOKUP8_ximage( RGBA_SPAN_ARGS
)
1879 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1881 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1884 for (i
=0;i
<n
;i
++,x
++) {
1886 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1891 /* draw all pixels */
1892 for (i
=0;i
<n
;i
++,x
++) {
1893 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1899 static void write_rgb_LOOKUP8_ximage( const GLcontext
*ctx
,
1900 GLuint n
, GLint x
, GLint y
,
1901 CONST GLubyte rgb
[][3],
1902 const GLubyte mask
[] )
1904 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1906 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1909 for (i
=0;i
<n
;i
++,x
++) {
1911 ptr
[i
] = (GLubyte
) LOOKUP( rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
1916 /* draw all pixels */
1917 const GLubyte
*data
= (GLubyte
*) rgb
;
1918 for (i
=0;i
<n
;i
++,x
++) {
1919 /*ptr[i] = LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );*/
1920 ptr
[i
] = (GLubyte
) LOOKUP( data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
1927 * Write a span of PF_GRAYSCALE pixels to an XImage.
1929 static void write_span_GRAYSCALE_ximage( RGBA_SPAN_ARGS
)
1931 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1932 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1934 y
= FLIP(xmesa
->xm_buffer
, y
);
1936 for (i
=0;i
<n
;i
++,x
++) {
1938 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1943 /* draw all pixels */
1944 for (i
=0;i
<n
;i
++,x
++) {
1945 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1952 * Write a span of PF_GRAYSCALE pixels to an XImage (no alpha).
1954 static void write_span_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS
)
1956 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1957 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1959 y
= FLIP(xmesa
->xm_buffer
, y
);
1961 for (i
=0;i
<n
;i
++,x
++) {
1963 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1968 /* draw all pixels */
1969 for (i
=0;i
<n
;i
++,x
++) {
1970 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1977 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage.
1979 static void write_span_GRAYSCALE8_ximage( RGBA_SPAN_ARGS
)
1981 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1983 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1987 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1992 /* draw all pixels */
1994 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2001 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage (no alpha).
2003 static void write_span_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS
)
2005 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2007 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
2011 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2016 /* draw all pixels */
2018 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2026 /**********************************************************************/
2027 /*** Write COLOR PIXEL functions ***/
2028 /**********************************************************************/
2031 #define RGBA_PIXEL_ARGS const GLcontext *ctx, \
2032 GLuint n, const GLint x[], const GLint y[], \
2033 CONST GLubyte rgba[][4], const GLubyte mask[]
2037 * Write an array of PF_TRUECOLOR pixels to a pixmap.
2039 static void write_pixels_TRUECOLOR_pixmap( RGBA_PIXEL_ARGS
)
2041 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2042 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2043 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2044 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2049 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2050 XMesaSetForeground( dpy
, gc
, p
);
2051 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2058 * Write an array of PF_TRUEDITHER pixels to a pixmap.
2060 static void write_pixels_TRUEDITHER_pixmap( RGBA_PIXEL_ARGS
)
2062 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2063 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2064 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2065 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2070 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2071 XMesaSetForeground( dpy
, gc
, p
);
2072 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2079 * Write an array of PF_8A8B8G8R pixels to a pixmap.
2081 static void write_pixels_8A8B8G8R_pixmap( RGBA_PIXEL_ARGS
)
2083 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2084 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2085 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2086 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2090 XMesaSetForeground( dpy
, gc
,
2091 PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] ));
2092 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2099 * Write an array of PF_8R8G8B pixels to a pixmap.
2101 static void write_pixels_8R8G8B_pixmap( RGBA_PIXEL_ARGS
)
2103 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2104 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2105 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2106 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2110 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2111 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2118 * Write an array of PF_8R8G8B24 pixels to a pixmap.
2120 static void write_pixels_8R8G8B24_pixmap( RGBA_PIXEL_ARGS
)
2122 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2123 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2124 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2125 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2129 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2130 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2137 * Write an array of PF_5R6G5B pixels to a pixmap.
2139 static void write_pixels_5R6G5B_pixmap( RGBA_PIXEL_ARGS
)
2141 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2142 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2143 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2144 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2148 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2149 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2156 * Write an array of PF_DITHER_5R6G5B pixels to a pixmap.
2158 static void write_pixels_DITHER_5R6G5B_pixmap( RGBA_PIXEL_ARGS
)
2160 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2161 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2162 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2163 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2168 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2169 XMesaSetForeground( dpy
, gc
, p
);
2170 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2177 * Write an array of PF_DITHER pixels to a pixmap.
2179 static void write_pixels_DITHER_pixmap( RGBA_PIXEL_ARGS
)
2181 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2182 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2183 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2184 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2189 XMesaSetForeground( dpy
, gc
,
2190 DITHER(x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2191 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2198 * Write an array of PF_1BIT pixels to a pixmap.
2200 static void write_pixels_1BIT_pixmap( RGBA_PIXEL_ARGS
)
2202 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2203 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2204 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2205 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2210 XMesaSetForeground( dpy
, gc
,
2211 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2212 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2219 * Write an array of PF_HPCR pixels to a pixmap.
2221 static void write_pixels_HPCR_pixmap( RGBA_PIXEL_ARGS
)
2223 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2224 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2225 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2226 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2230 XMesaSetForeground( dpy
, gc
,
2231 DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2232 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2239 * Write an array of PF_LOOKUP pixels to a pixmap.
2241 static void write_pixels_LOOKUP_pixmap( RGBA_PIXEL_ARGS
)
2243 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2244 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2245 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2246 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2251 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2252 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2259 * Write an array of PF_GRAYSCALE pixels to a pixmap.
2261 static void write_pixels_GRAYSCALE_pixmap( RGBA_PIXEL_ARGS
)
2263 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2264 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2265 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2266 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2270 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2271 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2278 * Write an array of PF_TRUECOLOR pixels to an ximage.
2280 static void write_pixels_TRUECOLOR_ximage( RGBA_PIXEL_ARGS
)
2282 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2283 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2288 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2289 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
2296 * Write an array of PF_TRUEDITHER pixels to an XImage.
2298 static void write_pixels_TRUEDITHER_ximage( RGBA_PIXEL_ARGS
)
2300 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2301 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2306 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2307 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
2314 * Write an array of PF_8A8B8G8R pixels to an ximage.
2316 static void write_pixels_8A8B8G8R_ximage( RGBA_PIXEL_ARGS
)
2318 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2322 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2323 *ptr
= PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
2330 * Write an array of PF_8R8G8B pixels to an ximage.
2332 static void write_pixels_8R8G8B_ximage( RGBA_PIXEL_ARGS
)
2334 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2338 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2339 *ptr
= PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2346 * Write an array of PF_8R8G8B24 pixels to an ximage.
2348 static void write_pixels_8R8G8B24_ximage( RGBA_PIXEL_ARGS
)
2350 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2354 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2355 ptr
->r
= rgba
[i
][RCOMP
];
2356 ptr
->g
= rgba
[i
][GCOMP
];
2357 ptr
->b
= rgba
[i
][BCOMP
];
2364 * Write an array of PF_5R6G5B pixels to an ximage.
2366 static void write_pixels_5R6G5B_ximage( RGBA_PIXEL_ARGS
)
2368 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2372 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2373 *ptr
= PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2380 * Write an array of PF_DITHER_5R6G5B pixels to an ximage.
2382 static void write_pixels_DITHER_5R6G5B_ximage( RGBA_PIXEL_ARGS
)
2384 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2388 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2389 PACK_TRUEDITHER( *ptr
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2396 * Write an array of PF_DITHER pixels to an XImage.
2398 static void write_pixels_DITHER_ximage( RGBA_PIXEL_ARGS
)
2400 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2401 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2406 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2407 DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2414 * Write an array of 8-bit PF_DITHER pixels to an XImage.
2416 static void write_pixels_DITHER8_ximage( RGBA_PIXEL_ARGS
)
2418 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2423 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2424 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2431 * Write an array of PF_1BIT pixels to an XImage.
2433 static void write_pixels_1BIT_ximage( RGBA_PIXEL_ARGS
)
2435 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2436 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2441 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2442 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2449 * Write an array of PF_HPCR pixels to an XImage.
2451 static void write_pixels_HPCR_ximage( RGBA_PIXEL_ARGS
)
2453 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2457 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2458 *ptr
= (GLubyte
) DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2465 * Write an array of PF_LOOKUP pixels to an XImage.
2467 static void write_pixels_LOOKUP_ximage( RGBA_PIXEL_ARGS
)
2469 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2470 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2475 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), LOOKUP(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2482 * Write an array of 8-bit PF_LOOKUP pixels to an XImage.
2484 static void write_pixels_LOOKUP8_ximage( RGBA_PIXEL_ARGS
)
2486 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2491 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2492 *ptr
= (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2499 * Write an array of PF_GRAYSCALE pixels to an XImage.
2501 static void write_pixels_GRAYSCALE_ximage( RGBA_PIXEL_ARGS
)
2503 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2504 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2508 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2509 GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2516 * Write an array of 8-bit PF_GRAYSCALE pixels to an XImage.
2518 static void write_pixels_GRAYSCALE8_ximage( RGBA_PIXEL_ARGS
)
2520 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2524 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2525 *ptr
= (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2533 /**********************************************************************/
2534 /*** Write MONO COLOR SPAN functions ***/
2535 /**********************************************************************/
2537 #define MONO_SPAN_ARGS const GLcontext *ctx, \
2538 GLuint n, GLint x, GLint y, const GLchan color[4], \
2539 const GLubyte mask[]
2543 * Write a span of identical pixels to a pixmap.
2545 static void write_span_mono_pixmap( MONO_SPAN_ARGS
)
2547 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2548 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2549 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2550 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2551 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2552 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2554 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
2555 y
= FLIP(xmesa
->xm_buffer
, y
);
2557 /* New code contributed by Jeff Epler and cleaned up by Keith
2560 for (i
= 0; i
< n
; ) {
2563 /* Identify and emit contiguous rendered pixels
2565 while (i
< n
&& mask
[i
])
2569 XMesaFillRectangle( dpy
, buffer
, gc
,
2570 (int)(x
+start
), (int) y
,
2573 /* Eat up non-rendered pixels
2575 while (i
< n
&& !mask
[i
])
2582 static void write_span_mono_index_pixmap( const GLcontext
*ctx
, GLuint n
,
2583 GLint x
, GLint y
, GLuint colorIndex
,
2584 const GLubyte mask
[] )
2586 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2587 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2588 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2589 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2591 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
2592 y
= FLIP(xmesa
->xm_buffer
, y
);
2594 for (i
= 0 ; i
< n
;) {
2597 /* Identify and emit contiguous rendered pixels
2599 while (i
< n
&& mask
[i
])
2603 XMesaFillRectangle( dpy
, buffer
, gc
,
2604 (int)(x
+start
), (int) y
,
2607 /* Eat up non-rendered pixels
2609 while (i
< n
&& !mask
[i
])
2617 * Write a span of PF_TRUEDITHER pixels to a pixmap.
2619 static void write_span_mono_TRUEDITHER_pixmap( MONO_SPAN_ARGS
)
2621 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2622 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2623 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2624 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2625 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2627 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2628 for (i
=0;i
<n
;i
++,x
++) {
2631 PACK_TRUEDITHER(p
, x
, yy
, r
, g
, b
);
2632 XMesaSetForeground( dpy
, gc
, p
);
2633 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2640 * Write a span of PF_DITHER pixels to a pixmap.
2642 static void write_span_mono_DITHER_pixmap( MONO_SPAN_ARGS
)
2644 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2645 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2646 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2647 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2648 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2650 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2652 for (i
=0;i
<n
;i
++,x
++) {
2654 XMesaSetForeground( dpy
, gc
, XDITHER( x
, r
, g
, b
) );
2655 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2662 * Write a span of PF_1BIT pixels to a pixmap.
2664 static void write_span_mono_1BIT_pixmap( MONO_SPAN_ARGS
)
2666 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2667 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2668 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2669 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2670 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2673 y
= FLIP(xmesa
->xm_buffer
, y
);
2674 for (i
=0;i
<n
;i
++,x
++) {
2676 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
, y
, r
, g
, b
) );
2677 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
2684 * Write a span of identical pixels to an XImage.
2686 static void write_span_mono_ximage( MONO_SPAN_ARGS
)
2688 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2689 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2691 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2692 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2693 y
= FLIP(xmesa
->xm_buffer
, y
);
2694 for (i
=0;i
<n
;i
++,x
++) {
2696 XMesaPutPixel( img
, x
, y
, pixel
);
2702 static void write_span_mono_index_ximage( const GLcontext
*ctx
, GLuint n
,
2705 const GLubyte mask
[] )
2707 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2708 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2710 y
= FLIP(xmesa
->xm_buffer
, y
);
2711 for (i
=0;i
<n
;i
++,x
++) {
2713 XMesaPutPixel( img
, x
, y
, colorIndex
);
2720 * Write a span of identical PF_TRUEDITHER pixels to an XImage.
2722 static void write_span_mono_TRUEDITHER_ximage( MONO_SPAN_ARGS
)
2724 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2725 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2726 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2728 y
= FLIP(xmesa
->xm_buffer
, y
);
2732 PACK_TRUEDITHER( p
, x
+i
, y
, r
, g
, b
);
2733 XMesaPutPixel( img
, x
+i
, y
, p
);
2740 * Write a span of identical 8A8B8G8R pixels to an XImage.
2742 static void write_span_mono_8A8B8G8R_ximage( MONO_SPAN_ARGS
)
2744 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2746 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2747 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2748 ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
2758 * Write a span of identical 8R8G8B pixels to an XImage.
2760 static void write_span_mono_8R8G8B_ximage( MONO_SPAN_ARGS
)
2762 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2763 const GLuint pixel
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2764 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
2775 * Write a span of identical 8R8G8B pixels to an XImage.
2777 static void write_span_mono_8R8G8B24_ximage( MONO_SPAN_ARGS
)
2779 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2780 const GLubyte r
= color
[RCOMP
];
2781 const GLubyte g
= color
[GCOMP
];
2782 const GLubyte b
= color
[BCOMP
];
2784 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
2796 * Write a span of identical DITHER pixels to an XImage.
2798 static void write_span_mono_DITHER_ximage( MONO_SPAN_ARGS
)
2800 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2801 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2802 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2803 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2806 for (i
=0;i
<n
;i
++,x
++) {
2808 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, r
, g
, b
) );
2815 * Write a span of identical 8-bit DITHER pixels to an XImage.
2817 static void write_span_mono_DITHER8_ximage( MONO_SPAN_ARGS
)
2819 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2820 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2821 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2824 for (i
=0;i
<n
;i
++,x
++) {
2826 ptr
[i
] = (GLubyte
) XDITHER( x
, r
, g
, b
);
2833 * Write a span of identical 8-bit LOOKUP pixels to an XImage.
2835 static void write_span_mono_LOOKUP8_ximage( MONO_SPAN_ARGS
)
2837 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2839 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2842 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2852 * Write a span of identical PF_1BIT pixels to an XImage.
2854 static void write_span_mono_1BIT_ximage( MONO_SPAN_ARGS
)
2856 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2857 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2858 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2861 y
= FLIP(xmesa
->xm_buffer
, y
);
2862 for (i
=0;i
<n
;i
++,x
++) {
2864 XMesaPutPixel( img
, x
, y
, DITHER_1BIT( x
, y
, r
, g
, b
) );
2871 * Write a span of identical HPCR pixels to an XImage.
2873 static void write_span_mono_HPCR_ximage( MONO_SPAN_ARGS
)
2875 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2876 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2877 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2879 for (i
=0;i
<n
;i
++,x
++) {
2881 ptr
[i
] = DITHER_HPCR( x
, y
, r
, g
, b
);
2888 * Write a span of identical 8-bit GRAYSCALE pixels to an XImage.
2890 static void write_span_mono_GRAYSCALE8_ximage( MONO_SPAN_ARGS
)
2892 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2893 const GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2894 GLubyte
*ptr
= (GLubyte
*) PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2906 * Write a span of identical PF_DITHER_5R6G5B pixels to an XImage.
2908 static void write_span_mono_DITHER_5R6G5B_ximage( MONO_SPAN_ARGS
)
2910 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2911 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
2912 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2914 y
= FLIP(xmesa
->xm_buffer
, y
);
2917 PACK_TRUEDITHER(ptr
[i
], x
+i
, y
, r
, g
, b
);
2924 /**********************************************************************/
2925 /*** Write MONO COLOR PIXELS functions ***/
2926 /**********************************************************************/
2928 #define MONO_PIXEL_ARGS const GLcontext *ctx, \
2929 GLuint n, const GLint x[], const GLint y[], \
2930 const GLchan color[4], const GLubyte mask[]
2933 * Write an array of identical pixels to a pixmap.
2935 static void write_pixels_mono_pixmap( MONO_PIXEL_ARGS
)
2937 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2938 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2939 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2940 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2942 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2943 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2944 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
2947 XMesaDrawPoint( dpy
, buffer
, gc
,
2948 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2954 static void write_pixels_mono_index_pixmap(const GLcontext
*ctx
,
2956 const GLint x
[], const GLint y
[],
2958 const GLubyte mask
[] )
2960 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2961 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2962 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2963 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2965 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
2968 XMesaDrawPoint( dpy
, buffer
, gc
,
2969 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2976 * Write an array of PF_TRUEDITHER pixels to a pixmap.
2978 static void write_pixels_mono_TRUEDITHER_pixmap( MONO_PIXEL_ARGS
)
2980 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2981 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2982 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2983 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2985 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2989 PACK_TRUEDITHER(p
, x
[i
], y
[i
], r
, g
, b
);
2990 XMesaSetForeground( dpy
, gc
, p
);
2991 XMesaDrawPoint( dpy
, buffer
, gc
,
2992 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2999 * Write an array of PF_DITHER pixels to a pixmap.
3001 static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS
)
3003 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3004 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3005 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3006 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3008 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3012 XMesaSetForeground( dpy
, gc
, DITHER( x
[i
], y
[i
], r
, g
, b
) );
3013 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3020 * Write an array of PF_1BIT pixels to a pixmap.
3022 static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS
)
3024 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3025 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3026 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3027 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3029 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3033 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
) );
3034 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3041 * Write an array of identical pixels to an XImage.
3043 static void write_pixels_mono_ximage( MONO_PIXEL_ARGS
)
3045 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3046 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3048 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
3049 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3052 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), pixel
);
3058 static void write_pixels_mono_index_ximage( const GLcontext
*ctx
, GLuint n
,
3059 const GLint x
[], const GLint y
[],
3061 const GLubyte mask
[] )
3063 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3064 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3068 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), colorIndex
);
3075 * Write an array of identical TRUEDITHER pixels to an XImage.
3077 static void write_pixels_mono_TRUEDITHER_ximage( MONO_PIXEL_ARGS
)
3079 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3080 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3082 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3086 PACK_TRUEDITHER(p
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), r
, g
, b
);
3087 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
3095 * Write an array of identical 8A8B8G8R pixels to an XImage
3097 static void write_pixels_mono_8A8B8G8R_ximage( MONO_PIXEL_ARGS
)
3099 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3100 const GLuint p
= PACK_8A8B8G8R(color
[RCOMP
], color
[GCOMP
],
3101 color
[BCOMP
], color
[ACOMP
]);
3105 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3113 * Write an array of identical 8R8G8B pixels to an XImage.
3115 static void write_pixels_mono_8R8G8B_ximage( MONO_PIXEL_ARGS
)
3117 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3119 const GLuint p
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3122 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3130 * Write an array of identical 8R8G8B pixels to an XImage.
3132 static void write_pixels_mono_8R8G8B24_ximage( MONO_PIXEL_ARGS
)
3134 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3135 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3139 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3149 * Write an array of identical PF_DITHER pixels to an XImage.
3151 static void write_pixels_mono_DITHER_ximage( MONO_PIXEL_ARGS
)
3153 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3154 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3155 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3160 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), DITHER( x
[i
], y
[i
], r
, g
, b
) );
3167 * Write an array of identical 8-bit PF_DITHER pixels to an XImage.
3169 static void write_pixels_mono_DITHER8_ximage( MONO_PIXEL_ARGS
)
3171 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3172 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3177 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3178 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], r
, g
, b
);
3185 * Write an array of identical 8-bit PF_LOOKUP pixels to an XImage.
3187 static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS
)
3189 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3193 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3196 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3205 * Write an array of identical PF_1BIT pixels to an XImage.
3207 static void write_pixels_mono_1BIT_ximage( MONO_PIXEL_ARGS
)
3209 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3210 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3211 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3216 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
3217 DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
));
3224 * Write an array of identical PF_HPCR pixels to an XImage.
3226 static void write_pixels_mono_HPCR_ximage( MONO_PIXEL_ARGS
)
3228 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3229 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3233 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3234 *ptr
= DITHER_HPCR( x
[i
], y
[i
], r
, g
, b
);
3241 * Write an array of identical 8-bit PF_GRAYSCALE pixels to an XImage.
3243 static void write_pixels_mono_GRAYSCALE8_ximage( MONO_PIXEL_ARGS
)
3245 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3247 register GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3250 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3258 * Write an array of identical PF_DITHER_5R6G5B pixels to an XImage.
3260 static void write_pixels_mono_DITHER_5R6G5B_ximage( MONO_PIXEL_ARGS
)
3262 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3263 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3267 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3268 PACK_TRUEDITHER(*ptr
, x
[i
], y
[i
], r
, g
, b
);
3275 /**********************************************************************/
3276 /*** Write INDEX SPAN functions ***/
3277 /**********************************************************************/
3279 #define INDEX_SPAN_ARGS const GLcontext *ctx, \
3280 GLuint n, GLint x, GLint y, const GLuint index[], \
3281 const GLubyte mask[]
3283 #define INDEX8_SPAN_ARGS const GLcontext *ctx, \
3284 GLuint n, GLint x, GLint y, const GLubyte index[], \
3285 const GLubyte mask[]
3289 * Write a span of CI pixels to a Pixmap.
3291 static void write_span_index_pixmap( INDEX_SPAN_ARGS
)
3293 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3294 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3295 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3296 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3298 y
= FLIP(xmesa
->xm_buffer
, y
);
3300 for (i
=0;i
<n
;i
++,x
++) {
3302 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3303 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3308 for (i
=0;i
<n
;i
++,x
++) {
3309 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3310 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3317 * Write a span of 8-bit CI pixels to a Pixmap.
3319 static void write_span_index8_pixmap( INDEX8_SPAN_ARGS
)
3321 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3322 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3323 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3324 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3326 y
= FLIP(xmesa
->xm_buffer
, y
);
3328 for (i
=0;i
<n
;i
++,x
++) {
3330 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3331 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3336 for (i
=0;i
<n
;i
++,x
++) {
3337 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3338 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3345 * Write a span of CI pixels to an XImage.
3347 static void write_span_index_ximage( INDEX_SPAN_ARGS
)
3349 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3350 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3352 y
= FLIP(xmesa
->xm_buffer
, y
);
3354 for (i
=0;i
<n
;i
++,x
++) {
3356 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3361 for (i
=0;i
<n
;i
++,x
++) {
3362 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3369 * Write a span of 8-bit CI pixels to a non 8-bit XImage.
3371 static void write_span_index8_ximage( const GLcontext
*ctx
, GLuint n
,
3372 GLint x
, GLint y
, const GLubyte index
[],
3373 const GLubyte mask
[] )
3375 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3380 XMesaPutPixel(xmesa
->xm_buffer
->backimage
, x
+i
, y
, index
[i
]);
3387 XMesaPutPixel(xmesa
->xm_buffer
->backimage
, x
+i
, y
, index
[i
]);
3393 * Write a span of 8-bit CI pixels to an 8-bit XImage.
3395 static void write_span_index8_ximage8( const GLcontext
*ctx
, GLuint n
,
3396 GLint x
, GLint y
, const GLubyte index
[],
3397 const GLubyte mask
[] )
3399 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3400 GLubyte
*dst
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
3410 MEMCPY( dst
, index
, n
);
3416 /**********************************************************************/
3417 /*** Write INDEX PIXELS functions ***/
3418 /**********************************************************************/
3420 #define INDEX_PIXELS_ARGS const GLcontext *ctx, \
3421 GLuint n, const GLint x[], const GLint y[], \
3422 const GLuint index[], const GLubyte mask[]
3426 * Write an array of CI pixels to a Pixmap.
3428 static void write_pixels_index_pixmap( INDEX_PIXELS_ARGS
)
3430 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3431 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3432 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3433 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3437 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3438 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3445 * Write an array of CI pixels to an XImage.
3447 static void write_pixels_index_ximage( INDEX_PIXELS_ARGS
)
3449 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3450 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3454 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), (unsigned long) index
[i
] );
3462 /**********************************************************************/
3463 /***** Pixel reading *****/
3464 /**********************************************************************/
3469 * Read a horizontal span of color-index pixels.
3471 static void read_index_span( const GLcontext
*ctx
,
3472 GLuint n
, GLint x
, GLint y
, GLuint index
[] )
3474 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3478 if (xmesa
->use_read_buffer
)
3479 source
= xmesa
->xm_read_buffer
;
3481 source
= xmesa
->xm_buffer
;
3483 y
= FLIP(source
, y
);
3485 if (source
->buffer
) {
3486 #ifndef XFree86Server
3487 XMesaImage
*span
= NULL
;
3489 catch_xgetimage_errors( xmesa
->display
);
3490 span
= XGetImage( xmesa
->display
, source
->buffer
,
3491 x
, y
, n
, 1, AllPlanes
, ZPixmap
);
3492 error
= check_xgetimage_errors();
3493 if (span
&& !error
) {
3495 index
[i
] = (GLuint
) XMesaGetPixel( span
, i
, 0 );
3499 /* return 0 pixels */
3505 XMesaDestroyImage( span
);
3508 (*xmesa
->display
->GetImage
)(source
->buffer
,
3509 x
, y
, n
, 1, ZPixmap
,
3510 ~0L, (pointer
)index
);
3513 else if (source
->backimage
) {
3514 XMesaImage
*img
= source
->backimage
;
3515 for (i
=0;i
<n
;i
++,x
++) {
3516 index
[i
] = (GLuint
) XMesaGetPixel( img
, x
, y
);
3524 * Read a horizontal span of color pixels.
3526 static void read_color_span( const GLcontext
*ctx
,
3527 GLuint n
, GLint x
, GLint y
,
3530 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3533 if (xmesa
->use_read_buffer
)
3534 source
= xmesa
->xm_read_buffer
;
3536 source
= xmesa
->xm_buffer
;
3538 if (source
->buffer
) {
3539 /* Read from Pixmap or Window */
3540 XMesaImage
*span
= NULL
;
3542 #ifdef XFree86Server
3543 span
= XMesaCreateImage(xmesa
->xm_visual
->BitsPerPixel
, n
, 1, NULL
);
3544 span
->data
= (char *)MALLOC(span
->height
* span
->bytes_per_line
);
3545 error
= (!span
->data
);
3546 (*xmesa
->display
->GetImage
)(source
->buffer
,
3547 x
, FLIP(source
, y
), n
, 1, ZPixmap
,
3548 ~0L, (pointer
)span
->data
);
3550 catch_xgetimage_errors( xmesa
->display
);
3551 span
= XGetImage( xmesa
->display
, source
->buffer
,
3552 x
, FLIP(source
, y
), n
, 1, AllPlanes
, ZPixmap
);
3553 error
= check_xgetimage_errors();
3555 if (span
&& !error
) {
3556 switch (xmesa
->pixelformat
) {
3560 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3561 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3562 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3563 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3564 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3565 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3566 GLint rShift
= xmesa
->xm_visual
->rshift
;
3567 GLint gShift
= xmesa
->xm_visual
->gshift
;
3568 GLint bShift
= xmesa
->xm_visual
->bshift
;
3572 p
= XMesaGetPixel( span
, i
, 0 );
3573 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3574 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3575 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3576 rgba
[i
][ACOMP
] = 255;
3581 case PF_DITHER_5R6G5B
:
3583 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3584 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3585 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3588 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
3589 /* fast, but not quite accurate
3590 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3591 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3592 rgba[i][BCOMP] = ((p << 3) & 0xff);
3594 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
3595 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3596 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
3597 rgba
[i
][ACOMP
] = 255;
3603 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3606 GLuint p4
= *ptr4
++;
3607 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
3608 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3609 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3610 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
3616 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3619 GLuint p4
= *ptr4
++;
3620 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3621 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3622 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3623 rgba
[i
][ACOMP
] = 255;
3629 const bgr_t
*ptr3
= (bgr_t
*) span
->data
;
3632 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
3633 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
3634 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
3635 rgba
[i
][ACOMP
] = 255;
3641 GLubyte
*ptr1
= (GLubyte
*) span
->data
;
3644 GLubyte p
= *ptr1
++;
3645 rgba
[i
][RCOMP
] = p
& 0xE0;
3646 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
3647 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
3648 rgba
[i
][ACOMP
] = 255;
3656 GLubyte
*rTable
= source
->pixel_to_r
;
3657 GLubyte
*gTable
= source
->pixel_to_g
;
3658 GLubyte
*bTable
= source
->pixel_to_b
;
3659 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
3660 const GLubyte
*ptr1
= (GLubyte
*) span
->data
;
3663 unsigned long p
= *ptr1
++;
3664 rgba
[i
][RCOMP
] = rTable
[p
];
3665 rgba
[i
][GCOMP
] = gTable
[p
];
3666 rgba
[i
][BCOMP
] = bTable
[p
];
3667 rgba
[i
][ACOMP
] = 255;
3673 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
3674 rgba
[i
][RCOMP
] = rTable
[p
];
3675 rgba
[i
][GCOMP
] = gTable
[p
];
3676 rgba
[i
][BCOMP
] = bTable
[p
];
3677 rgba
[i
][ACOMP
] = 255;
3684 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
3688 p
= XMesaGetPixel( span
, i
, 0 ) ^ bitFlip
;
3689 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
3690 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
3691 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
3692 rgba
[i
][ACOMP
] = 255;
3697 _mesa_problem(NULL
,"Problem in DD.read_color_span (1)");
3702 /* return black pixels */
3705 rgba
[i
][RCOMP
] = rgba
[i
][GCOMP
] = rgba
[i
][BCOMP
] = rgba
[i
][ACOMP
] = 0;
3709 XMesaDestroyImage( span
);
3712 else if (source
->backimage
) {
3713 /* Read from XImage back buffer */
3714 switch (xmesa
->pixelformat
) {
3718 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3719 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3720 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3721 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3722 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3723 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3724 GLint rShift
= xmesa
->xm_visual
->rshift
;
3725 GLint gShift
= xmesa
->xm_visual
->gshift
;
3726 GLint bShift
= xmesa
->xm_visual
->bshift
;
3727 XMesaImage
*img
= source
->backimage
;
3729 y
= FLIP(source
, y
);
3732 p
= XMesaGetPixel( img
, x
+i
, y
);
3733 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3734 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3735 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3736 rgba
[i
][ACOMP
] = 255;
3741 case PF_DITHER_5R6G5B
:
3743 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3744 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3745 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3746 const GLushort
*ptr2
= PIXELADDR2( source
, x
, y
);
3748 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
3749 const GLuint
*ptr4
= (const GLuint
*) ptr2
;
3750 GLuint extraPixel
= (n
& 1);
3752 for (i
= 0; i
< n
; i
+= 2) {
3753 const GLuint p
= *ptr4
++;
3754 const GLuint p0
= p
& 0xffff;
3755 const GLuint p1
= p
>> 16;
3756 /* fast, but not quite accurate
3757 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3758 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3759 rgba[i][BCOMP] = ((p << 3) & 0xff);
3761 rgba
[i
][RCOMP
] = pixelToR
[p0
>> 11];
3762 rgba
[i
][GCOMP
] = pixelToG
[(p0
>> 5) & 0x3f];
3763 rgba
[i
][BCOMP
] = pixelToB
[p0
& 0x1f];
3764 rgba
[i
][ACOMP
] = 255;
3765 rgba
[i
+1][RCOMP
] = pixelToR
[p1
>> 11];
3766 rgba
[i
+1][GCOMP
] = pixelToG
[(p1
>> 5) & 0x3f];
3767 rgba
[i
+1][BCOMP
] = pixelToB
[p1
& 0x1f];
3768 rgba
[i
+1][ACOMP
] = 255;
3771 GLushort p
= ptr2
[n
];
3772 rgba
[n
][RCOMP
] = pixelToR
[p
>> 11];
3773 rgba
[n
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3774 rgba
[n
][BCOMP
] = pixelToB
[p
& 0x1f];
3775 rgba
[n
][ACOMP
] = 255;
3778 for (i
= 0; i
< n
; i
++) {
3779 const GLushort p
= ptr2
[i
];
3780 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
3781 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3782 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
3783 rgba
[i
][ACOMP
] = 255;
3790 const GLuint
*ptr4
= PIXELADDR4( source
, x
, y
);
3793 GLuint p4
= *ptr4
++;
3794 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
3795 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3796 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3797 rgba
[i
][ACOMP
] = (GLint
) ((p4
>> 24) & 0xff);
3803 const GLuint
*ptr4
= PIXELADDR4( source
, x
, y
);
3806 GLuint p4
= *ptr4
++;
3807 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3808 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3809 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3810 rgba
[i
][ACOMP
] = 255;
3816 const bgr_t
*ptr3
= PIXELADDR3( source
, x
, y
);
3819 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
3820 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
3821 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
3822 rgba
[i
][ACOMP
] = 255;
3828 const GLubyte
*ptr1
= PIXELADDR1( source
, x
, y
);
3831 GLubyte p
= *ptr1
++;
3832 rgba
[i
][RCOMP
] = p
& 0xE0;
3833 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
3834 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
3835 rgba
[i
][ACOMP
] = 255;
3843 const GLubyte
*rTable
= source
->pixel_to_r
;
3844 const GLubyte
*gTable
= source
->pixel_to_g
;
3845 const GLubyte
*bTable
= source
->pixel_to_b
;
3846 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
3847 GLubyte
*ptr1
= PIXELADDR1( source
, x
, y
);
3850 unsigned long p
= *ptr1
++;
3851 rgba
[i
][RCOMP
] = rTable
[p
];
3852 rgba
[i
][GCOMP
] = gTable
[p
];
3853 rgba
[i
][BCOMP
] = bTable
[p
];
3854 rgba
[i
][ACOMP
] = 255;
3858 XMesaImage
*img
= source
->backimage
;
3860 y
= FLIP(source
, y
);
3861 for (i
=0;i
<n
;i
++,x
++) {
3862 unsigned long p
= XMesaGetPixel( img
, x
, y
);
3863 rgba
[i
][RCOMP
] = rTable
[p
];
3864 rgba
[i
][GCOMP
] = gTable
[p
];
3865 rgba
[i
][BCOMP
] = bTable
[p
];
3866 rgba
[i
][ACOMP
] = 255;
3873 XMesaImage
*img
= source
->backimage
;
3874 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
3876 y
= FLIP(source
, y
);
3877 for (i
=0;i
<n
;i
++,x
++) {
3879 p
= XMesaGetPixel( img
, x
, y
) ^ bitFlip
;
3880 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
3881 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
3882 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
3883 rgba
[i
][ACOMP
] = 255;
3888 _mesa_problem(NULL
,"Problem in DD.read_color_span (2)");
3897 * Read an array of color index pixels.
3899 static void read_index_pixels( const GLcontext
*ctx
,
3900 GLuint n
, const GLint x
[], const GLint y
[],
3901 GLuint indx
[], const GLubyte mask
[] )
3903 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3907 if (xmesa
->use_read_buffer
)
3908 source
= xmesa
->xm_read_buffer
;
3910 source
= xmesa
->xm_buffer
;
3912 if (source
->buffer
) {
3915 indx
[i
] = (GLuint
) read_pixel( xmesa
->display
,
3917 x
[i
], FLIP(source
, y
[i
]) );
3921 else if (source
->backimage
) {
3922 XMesaImage
*img
= source
->backimage
;
3925 indx
[i
] = (GLuint
) XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
3933 static void read_color_pixels( const GLcontext
*ctx
,
3934 GLuint n
, const GLint x
[], const GLint y
[],
3935 GLubyte rgba
[][4], const GLubyte mask
[] )
3937 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3938 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3941 XMesaDrawable buffer
;
3943 if (xmesa
->use_read_buffer
)
3944 source
= xmesa
->xm_read_buffer
;
3946 source
= xmesa
->xm_buffer
;
3948 buffer
= source
->buffer
; /* the X drawable */
3950 if (source
->buffer
) {
3951 switch (xmesa
->pixelformat
) {
3955 case PF_DITHER_5R6G5B
:
3957 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3958 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3959 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3960 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3961 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3962 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3963 GLint rShift
= xmesa
->xm_visual
->rshift
;
3964 GLint gShift
= xmesa
->xm_visual
->gshift
;
3965 GLint bShift
= xmesa
->xm_visual
->bshift
;
3968 unsigned long p
= read_pixel( dpy
, buffer
,
3969 x
[i
], FLIP(source
, y
[i
]) );
3970 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3971 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3972 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3973 rgba
[i
][ACOMP
] = 255;
3981 unsigned long p
= read_pixel( dpy
, buffer
,
3982 x
[i
], FLIP(source
, y
[i
]) );
3983 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xff);
3984 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
3985 rgba
[i
][BCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
3986 rgba
[i
][ACOMP
] = (GLubyte
) ((p
>> 24) & 0xff);
3993 unsigned long p
= read_pixel( dpy
, buffer
,
3994 x
[i
], FLIP(source
, y
[i
]) );
3995 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
3996 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
3997 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
3998 rgba
[i
][ACOMP
] = 255;
4005 unsigned long p
= read_pixel( dpy
, buffer
,
4006 x
[i
], FLIP(source
, y
[i
]) );
4007 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4008 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4009 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4010 rgba
[i
][ACOMP
] = 255;
4018 unsigned long p
= read_pixel( dpy
, buffer
,
4019 x
[i
], FLIP(source
, y
[i
]) );
4020 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xE0 );
4021 rgba
[i
][GCOMP
] = (GLubyte
) ((p
& 0x1C) << 3);
4022 rgba
[i
][BCOMP
] = (GLubyte
) ((p
& 0x03) << 6);
4023 rgba
[i
][ACOMP
] = (GLubyte
) 255;
4032 GLubyte
*rTable
= source
->pixel_to_r
;
4033 GLubyte
*gTable
= source
->pixel_to_g
;
4034 GLubyte
*bTable
= source
->pixel_to_b
;
4037 unsigned long p
= read_pixel( dpy
, buffer
,
4038 x
[i
], FLIP(source
, y
[i
]) );
4039 rgba
[i
][RCOMP
] = rTable
[p
];
4040 rgba
[i
][GCOMP
] = gTable
[p
];
4041 rgba
[i
][BCOMP
] = bTable
[p
];
4042 rgba
[i
][ACOMP
] = 255;
4049 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4052 unsigned long p
= read_pixel( dpy
, buffer
,
4053 x
[i
], FLIP(source
, y
[i
])) ^ bitFlip
;
4054 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4055 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4056 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4057 rgba
[i
][ACOMP
] = 255;
4063 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4067 else if (source
->backimage
) {
4068 switch (xmesa
->pixelformat
) {
4072 case PF_DITHER_5R6G5B
:
4074 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4075 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4076 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4077 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4078 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4079 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4080 GLint rShift
= xmesa
->xm_visual
->rshift
;
4081 GLint gShift
= xmesa
->xm_visual
->gshift
;
4082 GLint bShift
= xmesa
->xm_visual
->bshift
;
4083 XMesaImage
*img
= source
->backimage
;
4087 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
4088 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4089 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4090 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4091 rgba
[i
][ACOMP
] = 255;
4099 GLuint
*ptr4
= PIXELADDR4( source
, x
[i
], y
[i
] );
4101 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
4102 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4103 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4104 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
4111 GLuint
*ptr4
= PIXELADDR4( source
, x
[i
], y
[i
] );
4113 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4114 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4115 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4116 rgba
[i
][ACOMP
] = 255;
4123 bgr_t
*ptr3
= PIXELADDR3( source
, x
[i
], y
[i
] );
4124 rgba
[i
][RCOMP
] = ptr3
->r
;
4125 rgba
[i
][GCOMP
] = ptr3
->g
;
4126 rgba
[i
][BCOMP
] = ptr3
->b
;
4127 rgba
[i
][ACOMP
] = 255;
4134 GLubyte
*ptr1
= PIXELADDR1( source
, x
[i
], y
[i
] );
4136 rgba
[i
][RCOMP
] = p
& 0xE0;
4137 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4138 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4139 rgba
[i
][ACOMP
] = 255;
4147 GLubyte
*rTable
= source
->pixel_to_r
;
4148 GLubyte
*gTable
= source
->pixel_to_g
;
4149 GLubyte
*bTable
= source
->pixel_to_b
;
4150 XMesaImage
*img
= source
->backimage
;
4154 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
4155 rgba
[i
][RCOMP
] = rTable
[p
];
4156 rgba
[i
][GCOMP
] = gTable
[p
];
4157 rgba
[i
][BCOMP
] = bTable
[p
];
4158 rgba
[i
][ACOMP
] = 255;
4165 XMesaImage
*img
= source
->backimage
;
4166 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4170 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) ) ^ bitFlip
;
4171 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4172 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4173 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4174 rgba
[i
][ACOMP
] = 255;
4180 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4188 clear_color_HPCR_ximage( GLcontext
*ctx
, const GLchan color
[4] )
4191 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
4193 COPY_4V(xmesa
->clearcolor
, color
);
4195 if (color
[0] == 0 && color
[1] == 0 && color
[2] == 0) {
4196 /* black is black */
4197 MEMSET( xmesa
->xm_visual
->hpcr_clear_ximage_pattern
, 0x0 ,
4198 sizeof(xmesa
->xm_visual
->hpcr_clear_ximage_pattern
));
4201 /* build clear pattern */
4202 for (i
=0; i
<16; i
++) {
4203 xmesa
->xm_visual
->hpcr_clear_ximage_pattern
[0][i
] =
4204 DITHER_HPCR(i
, 0, color
[0], color
[1], color
[2]);
4205 xmesa
->xm_visual
->hpcr_clear_ximage_pattern
[1][i
] =
4206 DITHER_HPCR(i
, 1, color
[0], color
[1], color
[2]);
4213 clear_color_HPCR_pixmap( GLcontext
*ctx
, const GLchan color
[4] )
4216 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
4218 COPY_4V(xmesa
->clearcolor
, color
);
4220 if (color
[0] == 0 && color
[1] == 0 && color
[2] == 0) {
4221 /* black is black */
4222 for (i
=0; i
<16; i
++) {
4223 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 0, 0);
4224 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 1, 0);
4228 for (i
=0; i
<16; i
++) {
4229 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 0,
4230 DITHER_HPCR(i
, 0, color
[0], color
[1], color
[2]));
4231 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 1,
4232 DITHER_HPCR(i
, 1, color
[0], color
[1], color
[2]));
4235 /* change tile pixmap content */
4236 XMesaPutImage(xmesa
->display
,
4237 (XMesaDrawable
)xmesa
->xm_visual
->hpcr_clear_pixmap
,
4238 xmesa
->xm_buffer
->cleargc
,
4239 xmesa
->xm_visual
->hpcr_clear_ximage
, 0, 0, 0, 0, 16, 2);
4244 void xmesa_update_span_funcs( GLcontext
*ctx
)
4246 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
4247 int depth
=GET_VISUAL_DEPTH(xmesa
->xm_visual
);
4248 struct swrast_device_driver
*dd
= _swrast_GetDeviceDriverReference( ctx
);
4251 * These drawing functions depend on color buffer config:
4253 if (xmesa
->xm_buffer
->buffer
!=XIMAGE
) {
4254 /* Writing to window or back pixmap */
4255 switch (xmesa
->pixelformat
) {
4257 dd
->WriteCI32Span
= write_span_index_pixmap
;
4258 dd
->WriteCI8Span
= write_span_index8_pixmap
;
4259 dd
->WriteMonoCISpan
= write_span_mono_index_pixmap
;
4260 dd
->WriteCI32Pixels
= write_pixels_index_pixmap
;
4261 dd
->WriteMonoCIPixels
= write_pixels_mono_index_pixmap
;
4264 dd
->WriteRGBASpan
= write_span_TRUECOLOR_pixmap
;
4265 dd
->WriteRGBSpan
= write_span_rgb_TRUECOLOR_pixmap
;
4266 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4267 dd
->WriteRGBAPixels
= write_pixels_TRUECOLOR_pixmap
;
4268 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4271 dd
->WriteRGBASpan
= write_span_TRUEDITHER_pixmap
;
4272 dd
->WriteRGBSpan
= write_span_rgb_TRUEDITHER_pixmap
;
4273 dd
->WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_pixmap
;
4274 dd
->WriteRGBAPixels
= write_pixels_TRUEDITHER_pixmap
;
4275 dd
->WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_pixmap
;
4278 dd
->WriteRGBASpan
= write_span_8A8B8G8R_pixmap
;
4279 dd
->WriteRGBSpan
= write_span_rgb_8A8B8G8R_pixmap
;
4280 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4281 dd
->WriteRGBAPixels
= write_pixels_8A8B8G8R_pixmap
;
4282 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4285 dd
->WriteRGBASpan
= write_span_8R8G8B_pixmap
;
4286 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B_pixmap
;
4287 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4288 dd
->WriteRGBAPixels
= write_pixels_8R8G8B_pixmap
;
4289 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4292 dd
->WriteRGBASpan
= write_span_8R8G8B24_pixmap
;
4293 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B24_pixmap
;
4294 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4295 dd
->WriteRGBAPixels
= write_pixels_8R8G8B24_pixmap
;
4296 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4299 dd
->WriteRGBASpan
= write_span_5R6G5B_pixmap
;
4300 dd
->WriteRGBSpan
= write_span_rgb_5R6G5B_pixmap
;
4301 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4302 dd
->WriteRGBAPixels
= write_pixels_5R6G5B_pixmap
;
4303 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4305 case PF_DITHER_5R6G5B
:
4306 dd
->WriteRGBASpan
= write_span_DITHER_5R6G5B_pixmap
;
4307 dd
->WriteRGBSpan
= write_span_rgb_DITHER_5R6G5B_pixmap
;
4308 dd
->WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_pixmap
;
4309 dd
->WriteRGBAPixels
= write_pixels_DITHER_5R6G5B_pixmap
;
4310 dd
->WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_pixmap
;
4313 dd
->WriteRGBASpan
= write_span_DITHER_pixmap
;
4314 dd
->WriteRGBSpan
= write_span_rgb_DITHER_pixmap
;
4315 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER_pixmap
;
4316 dd
->WriteRGBAPixels
= write_pixels_DITHER_pixmap
;
4317 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER_pixmap
;
4320 dd
->WriteRGBASpan
= write_span_1BIT_pixmap
;
4321 dd
->WriteRGBSpan
= write_span_rgb_1BIT_pixmap
;
4322 dd
->WriteMonoRGBASpan
= write_span_mono_1BIT_pixmap
;
4323 dd
->WriteRGBAPixels
= write_pixels_1BIT_pixmap
;
4324 dd
->WriteMonoRGBAPixels
= write_pixels_mono_1BIT_pixmap
;
4327 dd
->WriteRGBASpan
= write_span_HPCR_pixmap
;
4328 dd
->WriteRGBSpan
= write_span_rgb_HPCR_pixmap
;
4329 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4330 dd
->WriteRGBAPixels
= write_pixels_HPCR_pixmap
;
4331 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4332 if (xmesa
->xm_visual
->hpcr_clear_flag
) {
4333 ctx
->Driver
.ClearColor
= clear_color_HPCR_pixmap
;
4337 dd
->WriteRGBASpan
= write_span_LOOKUP_pixmap
;
4338 dd
->WriteRGBSpan
= write_span_rgb_LOOKUP_pixmap
;
4339 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4340 dd
->WriteRGBAPixels
= write_pixels_LOOKUP_pixmap
;
4341 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4344 dd
->WriteRGBASpan
= write_span_GRAYSCALE_pixmap
;
4345 dd
->WriteRGBSpan
= write_span_rgb_GRAYSCALE_pixmap
;
4346 dd
->WriteMonoRGBASpan
= write_span_mono_pixmap
;
4347 dd
->WriteRGBAPixels
= write_pixels_GRAYSCALE_pixmap
;
4348 dd
->WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4351 _mesa_problem(NULL
,"Bad pixel format in xmesa_update_state (1)");
4355 else if (xmesa
->xm_buffer
->buffer
==XIMAGE
) {
4356 /* Writing to back XImage */
4357 switch (xmesa
->pixelformat
) {
4359 dd
->WriteCI32Span
= write_span_index_ximage
;
4361 dd
->WriteCI8Span
= write_span_index8_ximage8
;
4363 dd
->WriteCI8Span
= write_span_index8_ximage
;
4364 dd
->WriteMonoCISpan
= write_span_mono_index_ximage
;
4365 dd
->WriteCI32Pixels
= write_pixels_index_ximage
;
4366 dd
->WriteMonoCIPixels
= write_pixels_mono_index_ximage
;
4370 dd
->WriteRGBASpan
= write_span_TRUECOLOR_ximage
;
4371 dd
->WriteRGBSpan
= write_span_rgb_TRUECOLOR_ximage
;
4372 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4373 dd
->WriteRGBAPixels
= write_pixels_TRUECOLOR_ximage
;
4374 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4377 dd
->WriteRGBASpan
= write_span_TRUEDITHER_ximage
;
4378 dd
->WriteRGBSpan
= write_span_rgb_TRUEDITHER_ximage
;
4379 dd
->WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_ximage
;
4380 dd
->WriteRGBAPixels
= write_pixels_TRUEDITHER_ximage
;
4381 dd
->WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_ximage
;
4384 dd
->WriteRGBASpan
= write_span_8A8B8G8R_ximage
;
4385 dd
->WriteRGBSpan
= write_span_rgb_8A8B8G8R_ximage
;
4386 dd
->WriteMonoRGBASpan
= write_span_mono_8A8B8G8R_ximage
;
4387 dd
->WriteRGBAPixels
= write_pixels_8A8B8G8R_ximage
;
4388 dd
->WriteMonoRGBAPixels
= write_pixels_mono_8A8B8G8R_ximage
;
4391 dd
->WriteRGBASpan
= write_span_8R8G8B_ximage
;
4392 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B_ximage
;
4393 dd
->WriteMonoRGBASpan
= write_span_mono_8R8G8B_ximage
;
4394 dd
->WriteRGBAPixels
= write_pixels_8R8G8B_ximage
;
4395 dd
->WriteMonoRGBAPixels
= write_pixels_mono_8R8G8B_ximage
;
4398 dd
->WriteRGBASpan
= write_span_8R8G8B24_ximage
;
4399 dd
->WriteRGBSpan
= write_span_rgb_8R8G8B24_ximage
;
4400 dd
->WriteMonoRGBASpan
= write_span_mono_8R8G8B24_ximage
;
4401 dd
->WriteRGBAPixels
= write_pixels_8R8G8B24_ximage
;
4402 dd
->WriteMonoRGBAPixels
= write_pixels_mono_8R8G8B24_ximage
;
4405 dd
->WriteRGBASpan
= write_span_5R6G5B_ximage
;
4406 dd
->WriteRGBSpan
= write_span_rgb_5R6G5B_ximage
;
4407 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4408 dd
->WriteRGBAPixels
= write_pixels_5R6G5B_ximage
;
4409 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4411 case PF_DITHER_5R6G5B
:
4412 dd
->WriteRGBASpan
= write_span_DITHER_5R6G5B_ximage
;
4413 dd
->WriteRGBSpan
= write_span_rgb_DITHER_5R6G5B_ximage
;
4414 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER_5R6G5B_ximage
;
4415 dd
->WriteRGBAPixels
= write_pixels_DITHER_5R6G5B_ximage
;
4416 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER_5R6G5B_ximage
;
4420 dd
->WriteRGBASpan
= write_span_DITHER8_ximage
;
4421 dd
->WriteRGBSpan
= write_span_rgb_DITHER8_ximage
;
4422 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER8_ximage
;
4423 dd
->WriteRGBAPixels
= write_pixels_DITHER8_ximage
;
4424 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER8_ximage
;
4427 dd
->WriteRGBASpan
= write_span_DITHER_ximage
;
4428 dd
->WriteRGBSpan
= write_span_rgb_DITHER_ximage
;
4429 dd
->WriteMonoRGBASpan
= write_span_mono_DITHER_ximage
;
4430 dd
->WriteRGBAPixels
= write_pixels_DITHER_ximage
;
4431 dd
->WriteMonoRGBAPixels
= write_pixels_mono_DITHER_ximage
;
4435 dd
->WriteRGBASpan
= write_span_1BIT_ximage
;
4436 dd
->WriteRGBSpan
= write_span_rgb_1BIT_ximage
;
4437 dd
->WriteMonoRGBASpan
= write_span_mono_1BIT_ximage
;
4438 dd
->WriteRGBAPixels
= write_pixels_1BIT_ximage
;
4439 dd
->WriteMonoRGBAPixels
= write_pixels_mono_1BIT_ximage
;
4442 dd
->WriteRGBASpan
= write_span_HPCR_ximage
;
4443 dd
->WriteRGBSpan
= write_span_rgb_HPCR_ximage
;
4444 dd
->WriteMonoRGBASpan
= write_span_mono_HPCR_ximage
;
4445 dd
->WriteRGBAPixels
= write_pixels_HPCR_ximage
;
4446 dd
->WriteMonoRGBAPixels
= write_pixels_mono_HPCR_ximage
;
4447 if (xmesa
->xm_visual
->hpcr_clear_flag
) {
4448 ctx
->Driver
.ClearColor
= clear_color_HPCR_ximage
;
4453 dd
->WriteRGBASpan
= write_span_LOOKUP8_ximage
;
4454 dd
->WriteRGBSpan
= write_rgb_LOOKUP8_ximage
;
4455 dd
->WriteMonoRGBASpan
= write_span_mono_LOOKUP8_ximage
;
4456 dd
->WriteRGBAPixels
= write_pixels_LOOKUP8_ximage
;
4457 dd
->WriteMonoRGBAPixels
= write_pixels_mono_LOOKUP8_ximage
;
4460 dd
->WriteRGBASpan
= write_span_LOOKUP_ximage
;
4461 dd
->WriteRGBSpan
= write_span_rgb_LOOKUP_ximage
;
4462 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4463 dd
->WriteRGBAPixels
= write_pixels_LOOKUP_ximage
;
4464 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4469 dd
->WriteRGBASpan
= write_span_GRAYSCALE8_ximage
;
4470 dd
->WriteRGBSpan
= write_span_rgb_GRAYSCALE8_ximage
;
4471 dd
->WriteMonoRGBASpan
= write_span_mono_GRAYSCALE8_ximage
;
4472 dd
->WriteRGBAPixels
= write_pixels_GRAYSCALE8_ximage
;
4473 dd
->WriteMonoRGBAPixels
= write_pixels_mono_GRAYSCALE8_ximage
;
4476 dd
->WriteRGBASpan
= write_span_GRAYSCALE_ximage
;
4477 dd
->WriteRGBSpan
= write_span_rgb_GRAYSCALE_ximage
;
4478 dd
->WriteMonoRGBASpan
= write_span_mono_ximage
;
4479 dd
->WriteRGBAPixels
= write_pixels_GRAYSCALE_ximage
;
4480 dd
->WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4484 _mesa_problem(NULL
,"Bad pixel format in xmesa_update_state (2)");
4489 /* Pixel/span reading functions: */
4490 dd
->ReadCI32Span
= read_index_span
;
4491 dd
->ReadRGBASpan
= read_color_span
;
4492 dd
->ReadCI32Pixels
= read_index_pixels
;
4493 dd
->ReadRGBAPixels
= read_color_pixels
;
4495 dd
->SetReadBuffer
= xmesa_set_read_buffer
;