1 /* $Id: xm_span.c,v 1.4 2000/11/22 07:32:18 joukj Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 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.
28 #include "glxheader.h"
37 #include "extensions.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
;
189 y
= FLIP(xmesa
->xm_buffer
, y
);
191 for (i
=0;i
<n
;i
++,x
++) {
194 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
195 XMesaSetForeground( dpy
, gc
, p
);
196 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
201 /* draw all pixels */
202 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
205 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
206 XMesaPutPixel( rowimg
, i
, 0, p
);
208 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
214 * Write a span of PF_TRUECOLOR pixels to a pixmap.
216 static void write_span_rgb_TRUECOLOR_pixmap( RGB_SPAN_ARGS
)
218 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
219 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
220 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
221 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
223 y
= FLIP(xmesa
->xm_buffer
, y
);
225 for (i
=0;i
<n
;i
++,x
++) {
228 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
229 XMesaSetForeground( dpy
, gc
, p
);
230 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
235 /* draw all pixels */
236 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
239 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
240 XMesaPutPixel( rowimg
, i
, 0, p
);
242 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
248 * Write a span of PF_TRUEDITHER pixels to a pixmap.
250 static void write_span_TRUEDITHER_pixmap( RGBA_SPAN_ARGS
)
252 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
253 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
254 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
255 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
257 y
= FLIP(xmesa
->xm_buffer
, y
);
259 for (i
=0;i
<n
;i
++,x
++) {
262 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
263 XMesaSetForeground( dpy
, gc
, p
);
264 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
269 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
272 PACK_TRUEDITHER(p
, x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
273 XMesaPutPixel( rowimg
, i
, 0, p
);
275 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
281 * Write a span of PF_TRUEDITHER pixels to a pixmap (no alpha).
283 static void write_span_rgb_TRUEDITHER_pixmap( RGB_SPAN_ARGS
)
285 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
286 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
287 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
288 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
290 y
= FLIP(xmesa
->xm_buffer
, y
);
292 for (i
=0;i
<n
;i
++,x
++) {
295 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
296 XMesaSetForeground( dpy
, gc
, p
);
297 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
302 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
305 PACK_TRUEDITHER(p
, x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
306 XMesaPutPixel( rowimg
, i
, 0, p
);
308 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
315 * Write a span of PF_8A8B8G8R pixels to a pixmap.
317 static void write_span_8A8B8G8R_pixmap( RGBA_SPAN_ARGS
)
319 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
320 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
321 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
322 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
324 y
= FLIP(xmesa
->xm_buffer
, y
);
326 for (i
=0;i
<n
;i
++,x
++) {
328 XMesaSetForeground( dpy
, gc
,
329 PACK_8A8B8G8R(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
]) );
330 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
335 /* draw all pixels */
336 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
337 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
339 *ptr4
++ = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
341 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
347 * Write a span of PF_8A8B8G8R pixels to a pixmap (no alpha).
349 static void write_span_rgb_8A8B8G8R_pixmap( RGB_SPAN_ARGS
)
351 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
352 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
353 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
354 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
356 y
= FLIP(xmesa
->xm_buffer
, y
);
358 for (i
=0;i
<n
;i
++,x
++) {
360 XMesaSetForeground( dpy
, gc
,
361 PACK_8B8G8R(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
362 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
367 /* draw all pixels */
368 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
369 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
371 *ptr4
++ = PACK_8B8G8R(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
373 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
379 * Write a span of PF_8R8G8B pixels to a pixmap.
381 static void write_span_8R8G8B_pixmap( RGBA_SPAN_ARGS
)
383 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
384 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
385 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
386 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
388 y
= FLIP(xmesa
->xm_buffer
, y
);
390 for (i
=0;i
<n
;i
++,x
++) {
392 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
393 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
398 /* draw all pixels */
399 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
400 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
402 *ptr4
++ = PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
404 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
410 * Write a span of PF_8R8G8B24 pixels to a pixmap.
412 static void write_span_8R8G8B24_pixmap( RGBA_SPAN_ARGS
)
414 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
415 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
416 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
417 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
418 y
= FLIP(xmesa
->xm_buffer
, y
);
421 for (i
=0;i
<n
;i
++,x
++) {
423 XMesaSetForeground( dpy
, gc
,
424 PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
425 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
430 /* draw all pixels */
431 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
432 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
433 register GLuint pixel
;
434 static const GLuint shift
[4] = {0, 8, 16, 24};
435 register GLuint i
= 0;
438 pixel
= rgba
[i
][BCOMP
] /* << shift[0]*/;
439 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
440 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
441 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
444 pixel
= rgba
[i
][GCOMP
] /* << shift[0]*/;
445 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
446 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
447 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
450 pixel
= rgba
[i
++][RCOMP
]/* << shift[0]*/;
451 pixel
|= rgba
[i
][BCOMP
] << shift
[1];
452 pixel
|= rgba
[i
][GCOMP
] << shift
[2];
453 pixel
|= rgba
[i
++][RCOMP
] << shift
[3];
461 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
462 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
463 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
464 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
467 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
468 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
469 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
470 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
472 pixel
= 0xffffff00 & *ptr4
;
473 pixel
|= rgba
[i
][RCOMP
] /*<< shift[0]*/;
478 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
479 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
480 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
481 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
483 pixel
= 0xffff0000 & *ptr4
;
484 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
485 pixel
|= rgba
[i
][RCOMP
] << shift
[1];
489 pixel
= 0xff000000 & *ptr4
;
490 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
491 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
492 pixel
|= rgba
[i
][RCOMP
] << shift
[2];
498 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
504 * Write a span of PF_8R8G8B pixels to a pixmap (no alpha).
506 static void write_span_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS
)
508 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
509 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
510 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
511 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
513 y
= FLIP(xmesa
->xm_buffer
, y
);
515 for (i
=0;i
<n
;i
++,x
++) {
517 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
518 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
523 /* draw all pixels */
524 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
525 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
527 *ptr4
++ = PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
529 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
535 * Write a span of PF_8R8G8B24 pixels to a pixmap (no alpha).
537 static void write_span_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS
)
539 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
540 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
541 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
542 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
543 y
= FLIP(xmesa
->xm_buffer
, y
);
546 for (i
=0;i
<n
;i
++,x
++) {
548 XMesaSetForeground( dpy
, gc
,
549 PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
550 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
555 /* draw all pixels */
556 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
557 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
558 register GLuint pixel
;
559 static const GLuint shift
[4] = {0, 8, 16, 24};
561 register GLuint i
= 0;
564 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
565 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
566 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
567 pixel
|= rgb
[i
][BCOMP
] <<shift
[3];
571 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
572 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
573 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
574 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
578 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
579 pixel
|= rgb
[i
][BCOMP
] << shift
[1];
580 pixel
|= rgb
[i
][GCOMP
] << shift
[2];
581 pixel
|= rgb
[i
++][RCOMP
] << shift
[3];
588 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
589 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
590 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
591 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
594 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
595 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
596 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
597 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
601 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
606 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
607 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
608 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
609 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
613 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
614 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
620 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
621 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
622 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
628 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
634 * Write a span of PF_5R6G5B pixels to a pixmap.
636 static void write_span_5R6G5B_pixmap( RGBA_SPAN_ARGS
)
638 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
639 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
640 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
641 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
643 y
= FLIP(xmesa
->xm_buffer
, y
);
645 for (i
=0;i
<n
;i
++,x
++) {
647 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
648 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
653 /* draw all pixels */
654 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
655 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
657 ptr2
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
659 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
665 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap.
667 static void write_span_DITHER_5R6G5B_pixmap( RGBA_SPAN_ARGS
)
669 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
670 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
671 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
672 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
674 y
= FLIP(xmesa
->xm_buffer
, y
);
676 for (i
=0;i
<n
;i
++,x
++) {
679 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
680 XMesaSetForeground( dpy
, gc
, p
);
681 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
686 /* draw all pixels */
687 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
688 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
690 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
692 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
698 * Write a span of PF_5R6G5B pixels to a pixmap (no alpha).
700 static void write_span_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS
)
702 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
703 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
704 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
705 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
707 y
= FLIP(xmesa
->xm_buffer
, y
);
709 for (i
=0;i
<n
;i
++,x
++) {
711 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
712 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
717 /* draw all pixels */
718 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
719 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
721 ptr2
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
723 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
729 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap (no alpha).
731 static void write_span_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS
)
733 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
734 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
735 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
736 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
738 y
= FLIP(xmesa
->xm_buffer
, y
);
740 for (i
=0;i
<n
;i
++,x
++) {
743 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
744 XMesaSetForeground( dpy
, gc
, p
);
745 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
750 /* draw all pixels */
751 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
752 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
754 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
756 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
763 * Write a span of PF_DITHER pixels to a pixmap.
765 static void write_span_DITHER_pixmap( RGBA_SPAN_ARGS
)
767 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
768 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
769 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
770 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
773 y
= FLIP(xmesa
->xm_buffer
, y
);
775 for (i
=0;i
<n
;i
++,x
++) {
777 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
778 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
783 /* draw all pixels */
784 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
786 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
788 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
794 * Write a span of PF_DITHER pixels to a pixmap (no alpha).
796 static void write_span_rgb_DITHER_pixmap( RGB_SPAN_ARGS
)
798 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
799 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
800 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
801 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
804 y
= FLIP(xmesa
->xm_buffer
, y
);
806 for (i
=0;i
<n
;i
++,x
++) {
808 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
809 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
814 /* draw all pixels */
815 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
817 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
819 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
825 * Write a span of PF_1BIT pixels to a pixmap.
827 static void write_span_1BIT_pixmap( RGBA_SPAN_ARGS
)
829 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
830 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
831 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
832 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
835 y
= FLIP(xmesa
->xm_buffer
, y
);
837 for (i
=0;i
<n
;i
++,x
++) {
839 XMesaSetForeground( dpy
, gc
,
840 DITHER_1BIT( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
841 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
846 /* draw all pixels */
847 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
849 XMesaPutPixel( rowimg
, i
, 0,
850 DITHER_1BIT( x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
852 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
858 * Write a span of PF_1BIT pixels to a pixmap (no alpha).
860 static void write_span_rgb_1BIT_pixmap( RGB_SPAN_ARGS
)
862 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
863 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
864 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
865 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
868 y
= FLIP(xmesa
->xm_buffer
, y
);
870 for (i
=0;i
<n
;i
++,x
++) {
872 XMesaSetForeground( dpy
, gc
,
873 DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
874 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
879 /* draw all pixels */
880 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
882 XMesaPutPixel( rowimg
, i
, 0,
883 DITHER_1BIT(x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
885 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
891 * Write a span of PF_HPCR pixels to a pixmap.
893 static void write_span_HPCR_pixmap( RGBA_SPAN_ARGS
)
895 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
896 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
897 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
898 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
900 y
= FLIP(xmesa
->xm_buffer
, y
);
902 for (i
=0;i
<n
;i
++,x
++) {
904 XMesaSetForeground( dpy
, gc
,
905 DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
906 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
911 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
912 register GLubyte
*ptr
= (GLubyte
*) xmesa
->xm_buffer
->rowimage
->data
;
914 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
916 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
922 * Write a span of PF_HPCR pixels to a pixmap (no alpha).
924 static void write_span_rgb_HPCR_pixmap( RGB_SPAN_ARGS
)
926 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
927 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
928 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
929 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
931 y
= FLIP(xmesa
->xm_buffer
, y
);
933 for (i
=0;i
<n
;i
++,x
++) {
935 XMesaSetForeground( dpy
, gc
,
936 DITHER_HPCR(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
937 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
942 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
943 register GLubyte
*ptr
= (GLubyte
*) xmesa
->xm_buffer
->rowimage
->data
;
945 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
947 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
953 * Write a span of PF_LOOKUP pixels to a pixmap.
955 static void write_span_LOOKUP_pixmap( RGBA_SPAN_ARGS
)
957 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
958 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
959 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
960 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
963 y
= FLIP(xmesa
->xm_buffer
, y
);
965 for (i
=0;i
<n
;i
++,x
++) {
967 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
968 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
973 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
975 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
977 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
983 * Write a span of PF_LOOKUP pixels to a pixmap (no alpha).
985 static void write_span_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS
)
987 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
988 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
989 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
990 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
993 y
= FLIP(xmesa
->xm_buffer
, y
);
995 for (i
=0;i
<n
;i
++,x
++) {
997 XMesaSetForeground( dpy
, gc
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
998 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1003 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1005 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1007 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1014 * Write a span of PF_GRAYSCALE pixels to a pixmap.
1016 static void write_span_GRAYSCALE_pixmap( RGBA_SPAN_ARGS
)
1018 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1019 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1020 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
1021 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
1023 y
= FLIP(xmesa
->xm_buffer
, y
);
1025 for (i
=0;i
<n
;i
++,x
++) {
1027 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1028 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1033 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1035 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
1037 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1043 * Write a span of PF_GRAYSCALE pixels to a pixmap (no alpha).
1045 static void write_span_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS
)
1047 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1048 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1049 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
1050 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
1052 y
= FLIP(xmesa
->xm_buffer
, y
);
1054 for (i
=0;i
<n
;i
++,x
++) {
1056 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1057 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1062 XMesaImage
*rowimg
= xmesa
->xm_buffer
->rowimage
;
1064 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1066 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1072 * Write a span of PF_TRUECOLOR pixels to an XImage.
1074 static void write_span_TRUECOLOR_ximage( RGBA_SPAN_ARGS
)
1076 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1077 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1079 y
= FLIP(xmesa
->xm_buffer
, y
);
1081 for (i
=0;i
<n
;i
++,x
++) {
1084 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1085 XMesaPutPixel( img
, x
, y
, p
);
1090 /* draw all pixels */
1091 for (i
=0;i
<n
;i
++,x
++) {
1093 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1094 XMesaPutPixel( img
, x
, y
, p
);
1101 * Write a span of PF_TRUECOLOR pixels to an XImage (no alpha).
1103 static void write_span_rgb_TRUECOLOR_ximage( RGB_SPAN_ARGS
)
1105 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1106 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1108 y
= FLIP(xmesa
->xm_buffer
, y
);
1110 for (i
=0;i
<n
;i
++,x
++) {
1113 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1114 XMesaPutPixel( img
, x
, y
, p
);
1119 /* draw all pixels */
1120 for (i
=0;i
<n
;i
++,x
++) {
1122 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1123 XMesaPutPixel( img
, x
, y
, p
);
1130 * Write a span of PF_TRUEDITHER pixels to an XImage.
1132 static void write_span_TRUEDITHER_ximage( RGBA_SPAN_ARGS
)
1134 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1135 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1137 y
= FLIP(xmesa
->xm_buffer
, y
);
1139 for (i
=0;i
<n
;i
++,x
++) {
1142 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1143 XMesaPutPixel( img
, x
, y
, p
);
1148 /* draw all pixels */
1149 for (i
=0;i
<n
;i
++,x
++) {
1151 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1152 XMesaPutPixel( img
, x
, y
, p
);
1159 * Write a span of PF_TRUEDITHER pixels to an XImage (no alpha).
1161 static void write_span_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS
)
1163 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1164 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1166 y
= FLIP(xmesa
->xm_buffer
, y
);
1168 for (i
=0;i
<n
;i
++,x
++) {
1171 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1172 XMesaPutPixel( img
, x
, y
, p
);
1177 /* draw all pixels */
1178 for (i
=0;i
<n
;i
++,x
++) {
1180 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1181 XMesaPutPixel( img
, x
, y
, p
);
1188 * Write a span of PF_8A8B8G8R-format pixels to an ximage.
1190 static void write_span_8A8B8G8R_ximage( RGBA_SPAN_ARGS
)
1192 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1194 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1198 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1203 /* draw all pixels */
1205 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1212 * Write a span of PF_8A8B8G8R-format pixels to an ximage (no alpha).
1214 static void write_span_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS
)
1216 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1218 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1222 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1227 /* draw all pixels */
1229 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1236 * Write a span of PF_8R8G8B-format pixels to an ximage.
1238 static void write_span_8R8G8B_ximage( RGBA_SPAN_ARGS
)
1240 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1242 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1246 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1252 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1259 * Write a span of PF_8R8G8B24-format pixels to an ximage.
1261 static void write_span_8R8G8B24_ximage( RGBA_SPAN_ARGS
)
1263 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1265 register GLubyte
*ptr
= (GLubyte
*) PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
1269 GLuint
*ptr4
= (GLuint
*) ptr
;
1270 register GLuint pixel
= *ptr4
;
1271 switch (3 & (int)(ptr
- (GLubyte
*)ptr4
)) {
1273 pixel
&= 0xff000000;
1274 pixel
|= rgba
[i
][BCOMP
];
1275 pixel
|= rgba
[i
][GCOMP
] << 8;
1276 pixel
|= rgba
[i
][RCOMP
] << 16;
1280 pixel
&= 0x00ffffff;
1281 pixel
|= rgba
[i
][BCOMP
] << 24;
1283 pixel
= *ptr4
&& 0xffff0000;
1284 pixel
|= rgba
[i
][GCOMP
];
1285 pixel
|= rgba
[i
][RCOMP
] << 8;
1289 pixel
&= 0x0000ffff;
1290 pixel
|= rgba
[i
][BCOMP
] << 16;
1291 pixel
|= rgba
[i
][GCOMP
] << 24;
1293 pixel
= *ptr4
&& 0xffffff00;
1294 pixel
|= rgba
[i
][RCOMP
];
1298 pixel
&= 0x000000ff;
1299 pixel
|= rgba
[i
][BCOMP
] << 8;
1300 pixel
|= rgba
[i
][GCOMP
] << 16;
1301 pixel
|= rgba
[i
][RCOMP
] << 24;
1310 /* write all pixels */
1312 GLuint
*ptr4
= (GLuint
*) ptr
;
1313 register GLuint pixel
= *ptr4
;
1314 int index
= (int)(ptr
- (GLubyte
*)ptr4
);
1315 register GLuint i
= 0;
1320 pixel
&= 0x00ffffff;
1321 pixel
|= rgba
[i
][BCOMP
] << 24;
1323 pixel
= *ptr4
&& 0xffff0000;
1324 pixel
|= rgba
[i
][GCOMP
];
1325 pixel
|= rgba
[i
++][RCOMP
] << 8;
1330 pixel
&= 0x0000ffff;
1331 pixel
|= rgba
[i
][BCOMP
] << 16;
1332 pixel
|= rgba
[i
][GCOMP
] << 24;
1334 pixel
= *ptr4
&& 0xffffff00;
1335 pixel
|= rgba
[i
++][RCOMP
];
1340 pixel
&= 0x000000ff;
1341 pixel
|= rgba
[i
][BCOMP
] << 8;
1342 pixel
|= rgba
[i
][GCOMP
] << 16;
1343 pixel
|= rgba
[i
++][RCOMP
] << 24;
1350 pixel
= rgba
[i
][BCOMP
];
1351 pixel
|= rgba
[i
][GCOMP
] << 8;
1352 pixel
|= rgba
[i
++][RCOMP
] << 16;
1353 pixel
|= rgba
[i
][BCOMP
] << 24;
1355 pixel
= rgba
[i
][GCOMP
];
1356 pixel
|= rgba
[i
++][RCOMP
] << 8;
1357 pixel
|= rgba
[i
][BCOMP
] << 16;
1358 pixel
|= rgba
[i
][GCOMP
] << 24;
1360 pixel
= rgba
[i
++][RCOMP
];
1361 pixel
|= rgba
[i
][BCOMP
] << 8;
1362 pixel
|= rgba
[i
][GCOMP
] << 16;
1363 pixel
|= rgba
[i
++][RCOMP
] << 24;
1371 pixel
= *ptr4
& 0xff000000;
1372 pixel
|= rgba
[i
][BCOMP
];
1373 pixel
|= rgba
[i
][GCOMP
] << 8;
1374 pixel
|= rgba
[i
][RCOMP
] << 16;
1378 pixel
= rgba
[i
][BCOMP
];
1379 pixel
|= rgba
[i
][GCOMP
] << 8;
1380 pixel
|= rgba
[i
++][RCOMP
] << 16;
1381 pixel
|= rgba
[i
][BCOMP
] << 24;
1383 pixel
= *ptr4
& 0xffff0000;
1384 pixel
|= rgba
[i
][GCOMP
];
1385 pixel
|= rgba
[i
][RCOMP
] << 8;
1389 pixel
= rgba
[i
][BCOMP
];
1390 pixel
|= rgba
[i
][GCOMP
] << 8;
1391 pixel
|= rgba
[i
++][RCOMP
] << 16;
1392 pixel
|= rgba
[i
][BCOMP
] << 24;
1394 pixel
= rgba
[i
][GCOMP
];
1395 pixel
|= rgba
[i
++][RCOMP
] << 8;
1396 pixel
|= rgba
[i
][BCOMP
] << 16;
1397 pixel
|= rgba
[i
][GCOMP
] << 24;
1399 pixel
= *ptr4
& 0xffffff00;
1400 pixel
|= rgba
[i
][RCOMP
];
1409 * Write a span of PF_8R8G8B-format pixels to an ximage (no alpha).
1411 static void write_span_rgb_8R8G8B_ximage( RGB_SPAN_ARGS
)
1413 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1415 register GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
1419 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1424 /* draw all pixels */
1426 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1433 * Write a span of PF_8R8G8B24-format pixels to an ximage (no alpha).
1435 static void write_span_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS
)
1437 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1439 register GLubyte
*ptr
= (GLubyte
*) PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
1443 *ptr
++ = rgb
[i
][BCOMP
];
1444 *ptr
++ = rgb
[i
][GCOMP
];
1445 *ptr
++ = rgb
[i
][RCOMP
];
1453 /* draw all pixels */
1455 *ptr
++ = rgb
[i
][BCOMP
];
1456 *ptr
++ = rgb
[i
][GCOMP
];
1457 *ptr
++ = rgb
[i
][RCOMP
];
1464 * Write a span of PF_5R6G5B-format pixels to an ximage.
1466 static void write_span_5R6G5B_ximage( RGBA_SPAN_ARGS
)
1468 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1470 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1474 ptr
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1479 /* draw all pixels */
1480 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1481 GLuint
*ptr32
= (GLuint
*) ptr
;
1482 GLuint extraPixel
= (n
& 1);
1484 for (i
= 0; i
< n
; i
+= 2) {
1486 p0
= PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1487 p1
= PACK_5R6G5B(rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
]);
1488 *ptr32
++ = (p1
<< 16) | p0
;
1491 ptr
[n
] = PACK_5R6G5B(rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1494 for (i
= 0; i
< n
; i
++) {
1495 ptr
[i
] = PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1503 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage.
1505 static void write_span_DITHER_5R6G5B_ximage( RGBA_SPAN_ARGS
)
1507 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1509 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1511 for (i
=0;i
<n
;i
++,x
++) {
1513 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1518 /* draw all pixels */
1519 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1520 GLuint
*ptr32
= (GLuint
*) ptr
;
1521 GLuint extraPixel
= (n
& 1);
1523 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1525 PACK_TRUEDITHER( p0
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1526 PACK_TRUEDITHER( p1
, x
+1, y
, rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
] );
1527 *ptr32
++ = (p1
<< 16) | p0
;
1530 PACK_TRUEDITHER( ptr
[n
], x
+n
, y
, rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1533 for (i
= 0; i
< n
; i
++, x
++) {
1534 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1542 * Write a span of PF_5R6G5B-format pixels to an ximage (no alpha).
1544 static void write_span_rgb_5R6G5B_ximage( RGB_SPAN_ARGS
)
1546 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1548 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1552 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1557 /* draw all pixels */
1558 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1559 GLuint
*ptr32
= (GLuint
*) ptr
;
1560 GLuint extraPixel
= (n
& 1);
1562 for (i
= 0; i
< n
; i
+= 2) {
1564 p0
= PACK_5R6G5B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1565 p1
= PACK_5R6G5B(rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
]);
1566 *ptr32
++ = (p1
<< 16) | p0
;
1569 ptr
[n
] = PACK_5R6G5B(rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1573 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1581 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage (no alpha).
1583 static void write_span_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS
)
1585 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1587 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
1589 for (i
=0;i
<n
;i
++,x
++) {
1591 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1596 /* draw all pixels */
1597 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1598 GLuint
*ptr32
= (GLuint
*) ptr
;
1599 GLuint extraPixel
= (n
& 1);
1601 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1603 PACK_TRUEDITHER( p0
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1604 PACK_TRUEDITHER( p1
, x
+1, y
, rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
] );
1605 *ptr32
++ = (p1
<< 16) | p0
;
1608 PACK_TRUEDITHER( ptr
[n
], x
+n
, y
, rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1611 for (i
=0;i
<n
;i
++,x
++) {
1612 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1620 * Write a span of PF_DITHER pixels to an XImage.
1622 static void write_span_DITHER_ximage( RGBA_SPAN_ARGS
)
1624 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1625 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1627 int yy
= FLIP(xmesa
->xm_buffer
, y
);
1630 for (i
=0;i
<n
;i
++,x
++) {
1632 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1637 /* draw all pixels */
1638 for (i
=0;i
<n
;i
++,x
++) {
1639 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1646 * Write a span of PF_DITHER pixels to an XImage (no alpha).
1648 static void write_span_rgb_DITHER_ximage( RGB_SPAN_ARGS
)
1650 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1651 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1653 int yy
= FLIP(xmesa
->xm_buffer
, y
);
1656 for (i
=0;i
<n
;i
++,x
++) {
1658 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1663 /* draw all pixels */
1664 for (i
=0;i
<n
;i
++,x
++) {
1665 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1673 * Write a span of 8-bit PF_DITHER pixels to an XImage.
1675 static void write_span_DITHER8_ximage( RGBA_SPAN_ARGS
)
1677 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1679 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1682 for (i
=0;i
<n
;i
++,x
++) {
1684 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1689 for (i
=0;i
<n
;i
++,x
++) {
1690 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1696 static void write_span_rgb_DITHER8_ximage( RGB_SPAN_ARGS
)
1698 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1700 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1703 for (i
=0;i
<n
;i
++,x
++) {
1705 ptr
[i
] = (GLubyte
) XDITHER( x
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
1710 const GLubyte
*data
= (GLubyte
*) rgb
;
1711 for (i
=0;i
<n
;i
++,x
++) {
1712 /*ptr[i] = XDITHER( x, rgb[i][0], rgb[i][1], rgb[i][2] );*/
1713 ptr
[i
] = (GLubyte
) XDITHER( x
, data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
1721 * Write a span of PF_1BIT pixels to an XImage.
1723 static void write_span_1BIT_ximage( RGBA_SPAN_ARGS
)
1725 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1726 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1729 y
= FLIP(xmesa
->xm_buffer
, y
);
1731 for (i
=0;i
<n
;i
++,x
++) {
1733 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]));
1738 for (i
=0;i
<n
;i
++,x
++) {
1739 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
1746 * Write a span of PF_1BIT pixels to an XImage (no alpha).
1748 static void write_span_rgb_1BIT_ximage( RGB_SPAN_ARGS
)
1750 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1751 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1754 y
= FLIP(xmesa
->xm_buffer
, y
);
1756 for (i
=0;i
<n
;i
++,x
++) {
1758 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]));
1763 for (i
=0;i
<n
;i
++,x
++) {
1764 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
1771 * Write a span of PF_HPCR pixels to an XImage.
1773 static void write_span_HPCR_ximage( RGBA_SPAN_ARGS
)
1775 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1777 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1779 for (i
=0;i
<n
;i
++,x
++) {
1781 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1786 /* draw all pixels */
1787 for (i
=0;i
<n
;i
++,x
++) {
1788 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1795 * Write a span of PF_HPCR pixels to an XImage (no alpha).
1797 static void write_span_rgb_HPCR_ximage( RGB_SPAN_ARGS
)
1799 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1801 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1803 for (i
=0;i
<n
;i
++,x
++) {
1805 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1810 /* draw all pixels */
1811 for (i
=0;i
<n
;i
++,x
++) {
1812 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1819 * Write a span of PF_LOOKUP pixels to an XImage.
1821 static void write_span_LOOKUP_ximage( RGBA_SPAN_ARGS
)
1823 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1824 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1827 y
= FLIP(xmesa
->xm_buffer
, y
);
1829 for (i
=0;i
<n
;i
++,x
++) {
1831 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1836 /* draw all pixels */
1837 for (i
=0;i
<n
;i
++,x
++) {
1838 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1845 * Write a span of PF_LOOKUP pixels to an XImage (no alpha).
1847 static void write_span_rgb_LOOKUP_ximage( RGB_SPAN_ARGS
)
1849 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1850 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1853 y
= FLIP(xmesa
->xm_buffer
, y
);
1855 for (i
=0;i
<n
;i
++,x
++) {
1857 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1862 /* draw all pixels */
1863 for (i
=0;i
<n
;i
++,x
++) {
1864 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1871 * Write a span of 8-bit PF_LOOKUP pixels to an XImage.
1873 static void write_span_LOOKUP8_ximage( RGBA_SPAN_ARGS
)
1875 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1877 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1880 for (i
=0;i
<n
;i
++,x
++) {
1882 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1887 /* draw all pixels */
1888 for (i
=0;i
<n
;i
++,x
++) {
1889 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1895 static void write_rgb_LOOKUP8_ximage( const GLcontext
*ctx
,
1896 GLuint n
, GLint x
, GLint y
,
1897 CONST GLubyte rgb
[][3],
1898 const GLubyte mask
[] )
1900 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1902 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1905 for (i
=0;i
<n
;i
++,x
++) {
1907 ptr
[i
] = (GLubyte
) LOOKUP( rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
1912 /* draw all pixels */
1913 const GLubyte
*data
= (GLubyte
*) rgb
;
1914 for (i
=0;i
<n
;i
++,x
++) {
1915 /*ptr[i] = LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );*/
1916 ptr
[i
] = (GLubyte
) LOOKUP( data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
1923 * Write a span of PF_GRAYSCALE pixels to an XImage.
1925 static void write_span_GRAYSCALE_ximage( RGBA_SPAN_ARGS
)
1927 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1928 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1930 y
= FLIP(xmesa
->xm_buffer
, y
);
1932 for (i
=0;i
<n
;i
++,x
++) {
1934 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1939 /* draw all pixels */
1940 for (i
=0;i
<n
;i
++,x
++) {
1941 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1948 * Write a span of PF_GRAYSCALE pixels to an XImage (no alpha).
1950 static void write_span_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS
)
1952 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1953 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1955 y
= FLIP(xmesa
->xm_buffer
, y
);
1957 for (i
=0;i
<n
;i
++,x
++) {
1959 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1964 /* draw all pixels */
1965 for (i
=0;i
<n
;i
++,x
++) {
1966 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1973 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage.
1975 static void write_span_GRAYSCALE8_ximage( RGBA_SPAN_ARGS
)
1977 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1979 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
1983 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1988 /* draw all pixels */
1990 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1997 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage (no alpha).
1999 static void write_span_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS
)
2001 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2003 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
, y
);
2007 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2012 /* draw all pixels */
2014 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2022 /**********************************************************************/
2023 /*** Write COLOR PIXEL functions ***/
2024 /**********************************************************************/
2027 #define RGBA_PIXEL_ARGS const GLcontext *ctx, \
2028 GLuint n, const GLint x[], const GLint y[], \
2029 CONST GLubyte rgba[][4], const GLubyte mask[]
2033 * Write an array of PF_TRUECOLOR pixels to a pixmap.
2035 static void write_pixels_TRUECOLOR_pixmap( RGBA_PIXEL_ARGS
)
2037 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2038 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2039 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2040 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2045 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2046 XMesaSetForeground( dpy
, gc
, p
);
2047 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2054 * Write an array of PF_TRUEDITHER pixels to a pixmap.
2056 static void write_pixels_TRUEDITHER_pixmap( RGBA_PIXEL_ARGS
)
2058 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2059 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2060 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2061 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2066 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2067 XMesaSetForeground( dpy
, gc
, p
);
2068 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2075 * Write an array of PF_8A8B8G8R pixels to a pixmap.
2077 static void write_pixels_8A8B8G8R_pixmap( RGBA_PIXEL_ARGS
)
2079 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2080 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2081 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2082 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2086 XMesaSetForeground( dpy
, gc
,
2087 PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] ));
2088 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2095 * Write an array of PF_8R8G8B pixels to a pixmap.
2097 static void write_pixels_8R8G8B_pixmap( RGBA_PIXEL_ARGS
)
2099 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2100 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2101 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2102 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2106 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2107 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2114 * Write an array of PF_8R8G8B24 pixels to a pixmap.
2116 static void write_pixels_8R8G8B24_pixmap( RGBA_PIXEL_ARGS
)
2118 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2119 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2120 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2121 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2125 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2126 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2133 * Write an array of PF_5R6G5B pixels to a pixmap.
2135 static void write_pixels_5R6G5B_pixmap( RGBA_PIXEL_ARGS
)
2137 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2138 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2139 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2140 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2144 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2145 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2152 * Write an array of PF_DITHER_5R6G5B pixels to a pixmap.
2154 static void write_pixels_DITHER_5R6G5B_pixmap( RGBA_PIXEL_ARGS
)
2156 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2157 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2158 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2159 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2164 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2165 XMesaSetForeground( dpy
, gc
, p
);
2166 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2173 * Write an array of PF_DITHER pixels to a pixmap.
2175 static void write_pixels_DITHER_pixmap( RGBA_PIXEL_ARGS
)
2177 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2178 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2179 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2180 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2185 XMesaSetForeground( dpy
, gc
,
2186 DITHER(x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2187 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2194 * Write an array of PF_1BIT pixels to a pixmap.
2196 static void write_pixels_1BIT_pixmap( RGBA_PIXEL_ARGS
)
2198 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2199 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2200 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2201 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2206 XMesaSetForeground( dpy
, gc
,
2207 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2208 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2215 * Write an array of PF_HPCR pixels to a pixmap.
2217 static void write_pixels_HPCR_pixmap( RGBA_PIXEL_ARGS
)
2219 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2220 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2221 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2222 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2226 XMesaSetForeground( dpy
, gc
,
2227 DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2228 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2235 * Write an array of PF_LOOKUP pixels to a pixmap.
2237 static void write_pixels_LOOKUP_pixmap( RGBA_PIXEL_ARGS
)
2239 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2240 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2241 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2242 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2247 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2248 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2255 * Write an array of PF_GRAYSCALE pixels to a pixmap.
2257 static void write_pixels_GRAYSCALE_pixmap( RGBA_PIXEL_ARGS
)
2259 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2260 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2261 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2262 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2266 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2267 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2274 * Write an array of PF_TRUECOLOR pixels to an ximage.
2276 static void write_pixels_TRUECOLOR_ximage( RGBA_PIXEL_ARGS
)
2278 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2279 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2284 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2285 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
2292 * Write an array of PF_TRUEDITHER pixels to an XImage.
2294 static void write_pixels_TRUEDITHER_ximage( RGBA_PIXEL_ARGS
)
2296 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2297 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2302 PACK_TRUEDITHER(p
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2303 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
2310 * Write an array of PF_8A8B8G8R pixels to an ximage.
2312 static void write_pixels_8A8B8G8R_ximage( RGBA_PIXEL_ARGS
)
2314 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2318 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2319 *ptr
= PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
2326 * Write an array of PF_8R8G8B pixels to an ximage.
2328 static void write_pixels_8R8G8B_ximage( RGBA_PIXEL_ARGS
)
2330 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2334 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2335 *ptr
= PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2342 * Write an array of PF_8R8G8B24 pixels to an ximage.
2344 static void write_pixels_8R8G8B24_ximage( RGBA_PIXEL_ARGS
)
2346 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2350 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2351 ptr
->r
= rgba
[i
][RCOMP
];
2352 ptr
->g
= rgba
[i
][GCOMP
];
2353 ptr
->b
= rgba
[i
][BCOMP
];
2360 * Write an array of PF_5R6G5B pixels to an ximage.
2362 static void write_pixels_5R6G5B_ximage( RGBA_PIXEL_ARGS
)
2364 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2368 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2369 *ptr
= PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2376 * Write an array of PF_DITHER_5R6G5B pixels to an ximage.
2378 static void write_pixels_DITHER_5R6G5B_ximage( RGBA_PIXEL_ARGS
)
2380 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2384 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2385 PACK_TRUEDITHER( *ptr
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2392 * Write an array of PF_DITHER pixels to an XImage.
2394 static void write_pixels_DITHER_ximage( RGBA_PIXEL_ARGS
)
2396 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2397 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2402 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2403 DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2410 * Write an array of 8-bit PF_DITHER pixels to an XImage.
2412 static void write_pixels_DITHER8_ximage( RGBA_PIXEL_ARGS
)
2414 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2419 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2420 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2427 * Write an array of PF_1BIT pixels to an XImage.
2429 static void write_pixels_1BIT_ximage( RGBA_PIXEL_ARGS
)
2431 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2432 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2437 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2438 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2445 * Write an array of PF_HPCR pixels to an XImage.
2447 static void write_pixels_HPCR_ximage( RGBA_PIXEL_ARGS
)
2449 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2453 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2454 *ptr
= (GLubyte
) DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2461 * Write an array of PF_LOOKUP pixels to an XImage.
2463 static void write_pixels_LOOKUP_ximage( RGBA_PIXEL_ARGS
)
2465 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2466 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2471 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), LOOKUP(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2478 * Write an array of 8-bit PF_LOOKUP pixels to an XImage.
2480 static void write_pixels_LOOKUP8_ximage( RGBA_PIXEL_ARGS
)
2482 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2487 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
2488 *ptr
= (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2495 * Write an array of PF_GRAYSCALE pixels to an XImage.
2497 static void write_pixels_GRAYSCALE_ximage( RGBA_PIXEL_ARGS
)
2499 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2500 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2504 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
2505 GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2512 * Write an array of 8-bit PF_GRAYSCALE pixels to an XImage.
2514 static void write_pixels_GRAYSCALE8_ximage( RGBA_PIXEL_ARGS
)
2516 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2520 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
, x
[i
], y
[i
] );
2521 *ptr
= (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2529 /**********************************************************************/
2530 /*** Write MONO COLOR SPAN functions ***/
2531 /**********************************************************************/
2533 #define MONO_SPAN_ARGS const GLcontext *ctx, \
2534 GLuint n, GLint x, GLint y, const GLchan color[4], \
2535 const GLubyte mask[]
2539 * Write a span of identical pixels to a pixmap.
2541 static void write_span_mono_pixmap( MONO_SPAN_ARGS
)
2543 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2544 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2545 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2546 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2547 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2548 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2549 register GLboolean write_all
;
2551 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
2552 y
= FLIP(xmesa
->xm_buffer
, y
);
2553 write_all
= GL_TRUE
;
2556 write_all
= GL_FALSE
;
2561 XMesaFillRectangle( dpy
, buffer
, gc
, (int) x
, (int) y
, n
, 1 );
2564 for (i
=0;i
<n
;i
++,x
++) {
2566 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
2573 static void write_span_mono_index_pixmap( const GLcontext
*ctx
, GLuint n
,
2574 GLint x
, GLint y
, GLuint colorIndex
,
2575 const GLubyte mask
[] )
2577 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2578 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2579 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2580 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2581 register GLboolean write_all
;
2583 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
2584 y
= FLIP(xmesa
->xm_buffer
, y
);
2585 write_all
= GL_TRUE
;
2588 write_all
= GL_FALSE
;
2593 XMesaFillRectangle( dpy
, buffer
, gc
, (int) x
, (int) y
, n
, 1 );
2596 for (i
=0;i
<n
;i
++,x
++) {
2598 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
2607 * Write a span of PF_TRUEDITHER pixels to a pixmap.
2609 static void write_span_mono_TRUEDITHER_pixmap( MONO_SPAN_ARGS
)
2611 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2612 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2613 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2614 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2615 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2617 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2618 for (i
=0;i
<n
;i
++,x
++) {
2621 PACK_TRUEDITHER(p
, x
, yy
, r
, g
, b
);
2622 XMesaSetForeground( dpy
, gc
, p
);
2623 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2630 * Write a span of PF_DITHER pixels to a pixmap.
2632 static void write_span_mono_DITHER_pixmap( MONO_SPAN_ARGS
)
2634 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2635 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2636 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2637 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2638 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2640 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2642 for (i
=0;i
<n
;i
++,x
++) {
2644 XMesaSetForeground( dpy
, gc
, XDITHER( x
, r
, g
, b
) );
2645 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2652 * Write a span of PF_1BIT pixels to a pixmap.
2654 static void write_span_mono_1BIT_pixmap( MONO_SPAN_ARGS
)
2656 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2657 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2658 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2659 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2660 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2663 y
= FLIP(xmesa
->xm_buffer
, y
);
2664 for (i
=0;i
<n
;i
++,x
++) {
2666 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
, y
, r
, g
, b
) );
2667 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
2674 * Write a span of identical pixels to an XImage.
2676 static void write_span_mono_ximage( MONO_SPAN_ARGS
)
2678 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2679 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2681 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2682 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2683 y
= FLIP(xmesa
->xm_buffer
, y
);
2684 for (i
=0;i
<n
;i
++,x
++) {
2686 XMesaPutPixel( img
, x
, y
, pixel
);
2692 static void write_span_mono_index_ximage( const GLcontext
*ctx
, GLuint n
,
2695 const GLubyte mask
[] )
2697 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2698 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2700 y
= FLIP(xmesa
->xm_buffer
, y
);
2701 for (i
=0;i
<n
;i
++,x
++) {
2703 XMesaPutPixel( img
, x
, y
, colorIndex
);
2710 * Write a span of identical PF_TRUEDITHER pixels to an XImage.
2712 static void write_span_mono_TRUEDITHER_ximage( MONO_SPAN_ARGS
)
2714 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2715 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2716 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2718 y
= FLIP(xmesa
->xm_buffer
, y
);
2722 PACK_TRUEDITHER( p
, x
+i
, y
, r
, g
, b
);
2723 XMesaPutPixel( img
, x
+i
, y
, p
);
2730 * Write a span of identical 8A8B8G8R pixels to an XImage.
2732 static void write_span_mono_8A8B8G8R_ximage( MONO_SPAN_ARGS
)
2734 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2736 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2737 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2738 ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
2748 * Write a span of identical 8R8G8B pixels to an XImage.
2750 static void write_span_mono_8R8G8B_ximage( MONO_SPAN_ARGS
)
2752 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2753 const GLuint pixel
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2754 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
, y
);
2765 * Write a span of identical 8R8G8B pixels to an XImage.
2767 static void write_span_mono_8R8G8B24_ximage( MONO_SPAN_ARGS
)
2769 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2770 const GLubyte r
= color
[RCOMP
];
2771 const GLubyte g
= color
[GCOMP
];
2772 const GLubyte b
= color
[BCOMP
];
2774 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
, y
);
2786 * Write a span of identical DITHER pixels to an XImage.
2788 static void write_span_mono_DITHER_ximage( MONO_SPAN_ARGS
)
2790 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2791 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2792 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2793 int yy
= FLIP(xmesa
->xm_buffer
, y
);
2796 for (i
=0;i
<n
;i
++,x
++) {
2798 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, r
, g
, b
) );
2805 * Write a span of identical 8-bit DITHER pixels to an XImage.
2807 static void write_span_mono_DITHER8_ximage( MONO_SPAN_ARGS
)
2809 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2810 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2811 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2814 for (i
=0;i
<n
;i
++,x
++) {
2816 ptr
[i
] = (GLubyte
) XDITHER( x
, r
, g
, b
);
2823 * Write a span of identical 8-bit LOOKUP pixels to an XImage.
2825 static void write_span_mono_LOOKUP8_ximage( MONO_SPAN_ARGS
)
2827 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2829 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2832 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2842 * Write a span of identical PF_1BIT pixels to an XImage.
2844 static void write_span_mono_1BIT_ximage( MONO_SPAN_ARGS
)
2846 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2847 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2848 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
2851 y
= FLIP(xmesa
->xm_buffer
, y
);
2852 for (i
=0;i
<n
;i
++,x
++) {
2854 XMesaPutPixel( img
, x
, y
, DITHER_1BIT( x
, y
, r
, g
, b
) );
2861 * Write a span of identical HPCR pixels to an XImage.
2863 static void write_span_mono_HPCR_ximage( MONO_SPAN_ARGS
)
2865 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2866 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2867 register GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2869 for (i
=0;i
<n
;i
++,x
++) {
2871 ptr
[i
] = DITHER_HPCR( x
, y
, r
, g
, b
);
2878 * Write a span of identical 8-bit GRAYSCALE pixels to an XImage.
2880 static void write_span_mono_GRAYSCALE8_ximage( MONO_SPAN_ARGS
)
2882 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2883 const GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
2884 GLubyte
*ptr
= (GLubyte
*) PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
2896 * Write a span of identical PF_DITHER_5R6G5B pixels to an XImage.
2898 static void write_span_mono_DITHER_5R6G5B_ximage( MONO_SPAN_ARGS
)
2900 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2901 register GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
, y
);
2902 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2904 y
= FLIP(xmesa
->xm_buffer
, y
);
2907 PACK_TRUEDITHER(ptr
[i
], x
+i
, y
, r
, g
, b
);
2914 /**********************************************************************/
2915 /*** Write MONO COLOR PIXELS functions ***/
2916 /**********************************************************************/
2918 #define MONO_PIXEL_ARGS const GLcontext *ctx, \
2919 GLuint n, const GLint x[], const GLint y[], \
2920 const GLchan color[4], const GLubyte mask[]
2923 * Write an array of identical pixels to a pixmap.
2925 static void write_pixels_mono_pixmap( MONO_PIXEL_ARGS
)
2927 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2928 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2929 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2930 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2932 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
2933 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2934 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
2937 XMesaDrawPoint( dpy
, buffer
, gc
,
2938 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2944 static void write_pixels_mono_index_pixmap(const GLcontext
*ctx
,
2946 const GLint x
[], const GLint y
[],
2948 const GLubyte mask
[] )
2950 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2951 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2952 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2953 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2955 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
2958 XMesaDrawPoint( dpy
, buffer
, gc
,
2959 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2966 * Write an array of PF_TRUEDITHER pixels to a pixmap.
2968 static void write_pixels_mono_TRUEDITHER_pixmap( MONO_PIXEL_ARGS
)
2970 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2971 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2972 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2973 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2975 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2979 PACK_TRUEDITHER(p
, x
[i
], y
[i
], r
, g
, b
);
2980 XMesaSetForeground( dpy
, gc
, p
);
2981 XMesaDrawPoint( dpy
, buffer
, gc
,
2982 (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
2989 * Write an array of PF_DITHER pixels to a pixmap.
2991 static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS
)
2993 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
2994 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2995 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
2996 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
2998 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3002 XMesaSetForeground( dpy
, gc
, DITHER( x
[i
], y
[i
], r
, g
, b
) );
3003 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3010 * Write an array of PF_1BIT pixels to a pixmap.
3012 static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS
)
3014 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3015 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3016 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3017 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3019 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3023 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
) );
3024 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3031 * Write an array of identical pixels to an XImage.
3033 static void write_pixels_mono_ximage( MONO_PIXEL_ARGS
)
3035 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3036 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3038 const unsigned long pixel
= xmesa_color_to_pixel(xmesa
, color
[RCOMP
],
3039 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3042 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), pixel
);
3048 static void write_pixels_mono_index_ximage( const GLcontext
*ctx
, GLuint n
,
3049 const GLint x
[], const GLint y
[],
3051 const GLubyte mask
[] )
3053 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3054 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3058 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), colorIndex
);
3065 * Write an array of identical TRUEDITHER pixels to an XImage.
3067 static void write_pixels_mono_TRUEDITHER_ximage( MONO_PIXEL_ARGS
)
3069 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3070 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3072 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3076 PACK_TRUEDITHER(p
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), r
, g
, b
);
3077 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), p
);
3085 * Write an array of identical 8A8B8G8R pixels to an XImage
3087 static void write_pixels_mono_8A8B8G8R_ximage( MONO_PIXEL_ARGS
)
3089 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3090 const GLuint p
= PACK_8A8B8G8R(color
[RCOMP
], color
[GCOMP
],
3091 color
[BCOMP
], color
[ACOMP
]);
3095 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3103 * Write an array of identical 8R8G8B pixels to an XImage.
3105 static void write_pixels_mono_8R8G8B_ximage( MONO_PIXEL_ARGS
)
3107 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3109 const GLuint p
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3112 GLuint
*ptr
= PIXELADDR4( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3120 * Write an array of identical 8R8G8B pixels to an XImage.
3122 static void write_pixels_mono_8R8G8B24_ximage( MONO_PIXEL_ARGS
)
3124 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3125 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3129 bgr_t
*ptr
= PIXELADDR3( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3139 * Write an array of identical PF_DITHER pixels to an XImage.
3141 static void write_pixels_mono_DITHER_ximage( MONO_PIXEL_ARGS
)
3143 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3144 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3145 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3150 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), DITHER( x
[i
], y
[i
], r
, g
, b
) );
3157 * Write an array of identical 8-bit PF_DITHER pixels to an XImage.
3159 static void write_pixels_mono_DITHER8_ximage( MONO_PIXEL_ARGS
)
3161 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3162 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3167 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3168 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], r
, g
, b
);
3175 * Write an array of identical 8-bit PF_LOOKUP pixels to an XImage.
3177 static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS
)
3179 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3183 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3186 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3195 * Write an array of identical PF_1BIT pixels to an XImage.
3197 static void write_pixels_mono_1BIT_ximage( MONO_PIXEL_ARGS
)
3199 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3200 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3201 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3206 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]),
3207 DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
));
3214 * Write an array of identical PF_HPCR pixels to an XImage.
3216 static void write_pixels_mono_HPCR_ximage( MONO_PIXEL_ARGS
)
3218 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3219 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3223 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3224 *ptr
= DITHER_HPCR( x
[i
], y
[i
], r
, g
, b
);
3231 * Write an array of identical 8-bit PF_GRAYSCALE pixels to an XImage.
3233 static void write_pixels_mono_GRAYSCALE8_ximage( MONO_PIXEL_ARGS
)
3235 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3237 register GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3240 GLubyte
*ptr
= PIXELADDR1( xmesa
->xm_buffer
,x
[i
],y
[i
]);
3248 * Write an array of identical PF_DITHER_5R6G5B pixels to an XImage.
3250 static void write_pixels_mono_DITHER_5R6G5B_ximage( MONO_PIXEL_ARGS
)
3252 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3253 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3257 GLushort
*ptr
= PIXELADDR2( xmesa
->xm_buffer
, x
[i
], y
[i
] );
3258 PACK_TRUEDITHER(*ptr
, x
[i
], y
[i
], r
, g
, b
);
3265 /**********************************************************************/
3266 /*** Write INDEX SPAN functions ***/
3267 /**********************************************************************/
3269 #define INDEX_SPAN_ARGS const GLcontext *ctx, \
3270 GLuint n, GLint x, GLint y, const GLuint index[], \
3271 const GLubyte mask[]
3273 #define INDEX8_SPAN_ARGS const GLcontext *ctx, \
3274 GLuint n, GLint x, GLint y, const GLubyte index[], \
3275 const GLubyte mask[]
3279 * Write a span of CI pixels to a Pixmap.
3281 static void write_span_index_pixmap( INDEX_SPAN_ARGS
)
3283 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3284 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3285 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3286 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3288 y
= FLIP(xmesa
->xm_buffer
, y
);
3289 for (i
=0;i
<n
;i
++,x
++) {
3291 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3292 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3299 * Write a span of 8-bit CI pixels to a Pixmap.
3301 static void write_span_index8_pixmap( INDEX8_SPAN_ARGS
)
3303 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3304 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3305 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3306 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3308 y
= FLIP(xmesa
->xm_buffer
, y
);
3309 for (i
=0;i
<n
;i
++,x
++) {
3311 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3312 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3319 * Write a span of CI pixels to an XImage.
3321 static void write_span_index_ximage( INDEX_SPAN_ARGS
)
3323 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3324 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3326 y
= FLIP(xmesa
->xm_buffer
, y
);
3327 for (i
=0;i
<n
;i
++,x
++) {
3329 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3336 * Write a span of 8-bit CI pixels to a non 8-bit XImage.
3338 static void write_span_index8_ximage( const GLcontext
*ctx
, GLuint n
,
3339 GLint x
, GLint y
, const GLubyte index
[],
3340 const GLubyte mask
[] )
3342 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3347 XMesaPutPixel(xmesa
->xm_buffer
->backimage
, x
+i
, y
, index
[i
]);
3354 XMesaPutPixel(xmesa
->xm_buffer
->backimage
, x
+i
, y
, index
[i
]);
3360 * Write a span of 8-bit CI pixels to an 8-bit XImage.
3362 static void write_span_index8_ximage8( const GLcontext
*ctx
, GLuint n
,
3363 GLint x
, GLint y
, const GLubyte index
[],
3364 const GLubyte mask
[] )
3366 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3367 GLubyte
*dst
= PIXELADDR1( xmesa
->xm_buffer
,x
,y
);
3377 MEMCPY( dst
, index
, n
);
3383 /**********************************************************************/
3384 /*** Write INDEX PIXELS functions ***/
3385 /**********************************************************************/
3387 #define INDEX_PIXELS_ARGS const GLcontext *ctx, \
3388 GLuint n, const GLint x[], const GLint y[], \
3389 const GLuint index[], const GLubyte mask[]
3393 * Write an array of CI pixels to a Pixmap.
3395 static void write_pixels_index_pixmap( INDEX_PIXELS_ARGS
)
3397 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3398 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3399 XMesaDrawable buffer
= xmesa
->xm_buffer
->buffer
;
3400 XMesaGC gc
= xmesa
->xm_buffer
->gc
;
3404 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3405 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) FLIP(xmesa
->xm_buffer
, y
[i
]) );
3412 * Write an array of CI pixels to an XImage.
3414 static void write_pixels_index_ximage( INDEX_PIXELS_ARGS
)
3416 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3417 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
3421 XMesaPutPixel( img
, x
[i
], FLIP(xmesa
->xm_buffer
, y
[i
]), (unsigned long) index
[i
] );
3429 /**********************************************************************/
3430 /***** Pixel reading *****/
3431 /**********************************************************************/
3436 * Read a horizontal span of color-index pixels.
3438 static void read_index_span( const GLcontext
*ctx
,
3439 GLuint n
, GLint x
, GLint y
, GLuint index
[] )
3441 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3445 if (xmesa
->use_read_buffer
)
3446 source
= xmesa
->xm_read_buffer
;
3448 source
= xmesa
->xm_buffer
;
3450 y
= FLIP(source
, y
);
3452 if (source
->buffer
) {
3453 #ifndef XFree86Server
3454 XMesaImage
*span
= NULL
;
3456 catch_xgetimage_errors( xmesa
->display
);
3457 span
= XGetImage( xmesa
->display
, source
->buffer
,
3458 x
, y
, n
, 1, AllPlanes
, ZPixmap
);
3459 error
= check_xgetimage_errors();
3460 if (span
&& !error
) {
3462 index
[i
] = (GLuint
) XMesaGetPixel( span
, i
, 0 );
3466 /* return 0 pixels */
3472 XMesaDestroyImage( span
);
3475 (*xmesa
->display
->GetImage
)(source
->buffer
,
3476 x
, y
, n
, 1, ZPixmap
,
3477 ~0L, (pointer
)index
);
3480 else if (source
->backimage
) {
3481 XMesaImage
*img
= source
->backimage
;
3482 for (i
=0;i
<n
;i
++,x
++) {
3483 index
[i
] = (GLuint
) XMesaGetPixel( img
, x
, y
);
3491 * Read a horizontal span of color pixels.
3493 static void read_color_span( const GLcontext
*ctx
,
3494 GLuint n
, GLint x
, GLint y
,
3497 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3500 if (xmesa
->use_read_buffer
)
3501 source
= xmesa
->xm_read_buffer
;
3503 source
= xmesa
->xm_buffer
;
3505 if (source
->buffer
) {
3506 /* Read from Pixmap or Window */
3507 XMesaImage
*span
= NULL
;
3509 #ifdef XFree86Server
3510 span
= XMesaCreateImage(xmesa
->xm_visual
->BitsPerPixel
, n
, 1, NULL
);
3511 span
->data
= (char *)MALLOC(span
->height
* span
->bytes_per_line
);
3512 error
= (!span
->data
);
3513 (*xmesa
->display
->GetImage
)(source
->buffer
,
3514 x
, FLIP(source
, y
), n
, 1, ZPixmap
,
3515 ~0L, (pointer
)span
->data
);
3517 catch_xgetimage_errors( xmesa
->display
);
3518 span
= XGetImage( xmesa
->display
, source
->buffer
,
3519 x
, FLIP(source
, y
), n
, 1, AllPlanes
, ZPixmap
);
3520 error
= check_xgetimage_errors();
3522 if (span
&& !error
) {
3523 switch (xmesa
->pixelformat
) {
3527 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3528 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3529 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3530 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3531 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3532 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3533 GLint rShift
= xmesa
->xm_visual
->rshift
;
3534 GLint gShift
= xmesa
->xm_visual
->gshift
;
3535 GLint bShift
= xmesa
->xm_visual
->bshift
;
3539 p
= XMesaGetPixel( span
, i
, 0 );
3540 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3541 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3542 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3543 rgba
[i
][ACOMP
] = 255;
3548 case PF_DITHER_5R6G5B
:
3550 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3551 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3552 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3555 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
3556 /* fast, but not quite accurate
3557 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3558 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3559 rgba[i][BCOMP] = ((p << 3) & 0xff);
3561 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
3562 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3563 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
3564 rgba
[i
][ACOMP
] = 255;
3570 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3573 GLuint p4
= *ptr4
++;
3574 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
3575 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3576 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3577 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
3583 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3586 GLuint p4
= *ptr4
++;
3587 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3588 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3589 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3590 rgba
[i
][ACOMP
] = 255;
3596 const bgr_t
*ptr3
= (bgr_t
*) span
->data
;
3599 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
3600 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
3601 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
3602 rgba
[i
][ACOMP
] = 255;
3608 GLubyte
*ptr1
= (GLubyte
*) span
->data
;
3611 GLubyte p
= *ptr1
++;
3612 rgba
[i
][RCOMP
] = p
& 0xE0;
3613 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
3614 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
3615 rgba
[i
][ACOMP
] = 255;
3623 GLubyte
*rTable
= source
->pixel_to_r
;
3624 GLubyte
*gTable
= source
->pixel_to_g
;
3625 GLubyte
*bTable
= source
->pixel_to_b
;
3626 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
3627 const GLubyte
*ptr1
= (GLubyte
*) span
->data
;
3630 unsigned long p
= *ptr1
++;
3631 rgba
[i
][RCOMP
] = rTable
[p
];
3632 rgba
[i
][GCOMP
] = gTable
[p
];
3633 rgba
[i
][BCOMP
] = bTable
[p
];
3634 rgba
[i
][ACOMP
] = 255;
3640 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
3641 rgba
[i
][RCOMP
] = rTable
[p
];
3642 rgba
[i
][GCOMP
] = gTable
[p
];
3643 rgba
[i
][BCOMP
] = bTable
[p
];
3644 rgba
[i
][ACOMP
] = 255;
3651 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
3655 p
= XMesaGetPixel( span
, i
, 0 ) ^ bitFlip
;
3656 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
3657 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
3658 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
3659 rgba
[i
][ACOMP
] = 255;
3664 gl_problem(NULL
,"Problem in DD.read_color_span (1)");
3669 /* return black pixels */
3672 rgba
[i
][RCOMP
] = rgba
[i
][GCOMP
] = rgba
[i
][BCOMP
] = rgba
[i
][ACOMP
] = 0;
3676 XMesaDestroyImage( span
);
3679 else if (source
->backimage
) {
3680 /* Read from XImage back buffer */
3681 switch (xmesa
->pixelformat
) {
3685 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3686 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3687 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3688 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3689 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3690 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3691 GLint rShift
= xmesa
->xm_visual
->rshift
;
3692 GLint gShift
= xmesa
->xm_visual
->gshift
;
3693 GLint bShift
= xmesa
->xm_visual
->bshift
;
3694 XMesaImage
*img
= source
->backimage
;
3696 y
= FLIP(source
, y
);
3699 p
= XMesaGetPixel( img
, x
+i
, y
);
3700 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3701 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3702 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3703 rgba
[i
][ACOMP
] = 255;
3708 case PF_DITHER_5R6G5B
:
3710 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3711 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3712 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3713 const GLushort
*ptr2
= PIXELADDR2( source
, x
, y
);
3714 const GLuint
*ptr4
= (const GLuint
*) ptr2
;
3716 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
3717 GLuint extraPixel
= (n
& 1);
3719 for (i
= 0; i
< n
; i
+= 2) {
3720 const GLuint p
= *ptr4
++;
3721 const GLuint p0
= p
& 0xffff;
3722 const GLuint p1
= p
>> 16;
3723 /* fast, but not quite accurate
3724 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3725 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3726 rgba[i][BCOMP] = ((p << 3) & 0xff);
3728 rgba
[i
][RCOMP
] = pixelToR
[p0
>> 11];
3729 rgba
[i
][GCOMP
] = pixelToG
[(p0
>> 5) & 0x3f];
3730 rgba
[i
][BCOMP
] = pixelToB
[p0
& 0x1f];
3731 rgba
[i
][ACOMP
] = 255;
3732 rgba
[i
+1][RCOMP
] = pixelToR
[p1
>> 11];
3733 rgba
[i
+1][GCOMP
] = pixelToG
[(p1
>> 5) & 0x3f];
3734 rgba
[i
+1][BCOMP
] = pixelToB
[p1
& 0x1f];
3735 rgba
[i
+1][ACOMP
] = 255;
3738 GLushort p
= ptr2
[n
];
3739 rgba
[n
][RCOMP
] = pixelToR
[p
>> 11];
3740 rgba
[n
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3741 rgba
[n
][BCOMP
] = pixelToB
[p
& 0x1f];
3742 rgba
[n
][ACOMP
] = 255;
3745 for (i
= 0; i
< n
; i
++) {
3746 const GLushort p
= ptr2
[i
];
3747 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
3748 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3749 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
3750 rgba
[i
][ACOMP
] = 255;
3757 const GLuint
*ptr4
= PIXELADDR4( source
, x
, y
);
3760 GLuint p4
= *ptr4
++;
3761 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
3762 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3763 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3764 rgba
[i
][ACOMP
] = (GLint
) ((p4
>> 24) & 0xff);
3770 const GLuint
*ptr4
= PIXELADDR4( source
, x
, y
);
3773 GLuint p4
= *ptr4
++;
3774 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3775 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3776 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3777 rgba
[i
][ACOMP
] = 255;
3783 const bgr_t
*ptr3
= PIXELADDR3( source
, x
, y
);
3786 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
3787 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
3788 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
3789 rgba
[i
][ACOMP
] = 255;
3795 const GLubyte
*ptr1
= PIXELADDR1( source
, x
, y
);
3798 GLubyte p
= *ptr1
++;
3799 rgba
[i
][RCOMP
] = p
& 0xE0;
3800 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
3801 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
3802 rgba
[i
][ACOMP
] = 255;
3810 const GLubyte
*rTable
= source
->pixel_to_r
;
3811 const GLubyte
*gTable
= source
->pixel_to_g
;
3812 const GLubyte
*bTable
= source
->pixel_to_b
;
3813 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
3814 GLubyte
*ptr1
= PIXELADDR1( source
, x
, y
);
3817 unsigned long p
= *ptr1
++;
3818 rgba
[i
][RCOMP
] = rTable
[p
];
3819 rgba
[i
][GCOMP
] = gTable
[p
];
3820 rgba
[i
][BCOMP
] = bTable
[p
];
3821 rgba
[i
][ACOMP
] = 255;
3825 XMesaImage
*img
= source
->backimage
;
3827 y
= FLIP(source
, y
);
3828 for (i
=0;i
<n
;i
++,x
++) {
3829 unsigned long p
= XMesaGetPixel( img
, x
, y
);
3830 rgba
[i
][RCOMP
] = rTable
[p
];
3831 rgba
[i
][GCOMP
] = gTable
[p
];
3832 rgba
[i
][BCOMP
] = bTable
[p
];
3833 rgba
[i
][ACOMP
] = 255;
3840 XMesaImage
*img
= source
->backimage
;
3841 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
3843 y
= FLIP(source
, y
);
3844 for (i
=0;i
<n
;i
++,x
++) {
3846 p
= XMesaGetPixel( img
, x
, y
) ^ bitFlip
;
3847 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
3848 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
3849 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
3850 rgba
[i
][ACOMP
] = 255;
3855 gl_problem(NULL
,"Problem in DD.read_color_span (2)");
3864 * Read an array of color index pixels.
3866 static void read_index_pixels( const GLcontext
*ctx
,
3867 GLuint n
, const GLint x
[], const GLint y
[],
3868 GLuint indx
[], const GLubyte mask
[] )
3870 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3874 if (xmesa
->use_read_buffer
)
3875 source
= xmesa
->xm_read_buffer
;
3877 source
= xmesa
->xm_buffer
;
3879 if (source
->buffer
) {
3882 indx
[i
] = (GLuint
) read_pixel( xmesa
->display
,
3884 x
[i
], FLIP(source
, y
[i
]) );
3888 else if (source
->backimage
) {
3889 XMesaImage
*img
= source
->backimage
;
3892 indx
[i
] = (GLuint
) XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
3900 static void read_color_pixels( const GLcontext
*ctx
,
3901 GLuint n
, const GLint x
[], const GLint y
[],
3902 GLubyte rgba
[][4], const GLubyte mask
[] )
3904 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
3905 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3908 XMesaDrawable buffer
;
3910 if (xmesa
->use_read_buffer
)
3911 source
= xmesa
->xm_read_buffer
;
3913 source
= xmesa
->xm_buffer
;
3915 buffer
= source
->buffer
; /* the X drawable */
3917 if (source
->buffer
) {
3918 switch (xmesa
->pixelformat
) {
3922 case PF_DITHER_5R6G5B
:
3924 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3925 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3926 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3927 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3928 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3929 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3930 GLint rShift
= xmesa
->xm_visual
->rshift
;
3931 GLint gShift
= xmesa
->xm_visual
->gshift
;
3932 GLint bShift
= xmesa
->xm_visual
->bshift
;
3935 unsigned long p
= read_pixel( dpy
, buffer
,
3936 x
[i
], FLIP(source
, y
[i
]) );
3937 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3938 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3939 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3940 rgba
[i
][ACOMP
] = 255;
3948 unsigned long p
= read_pixel( dpy
, buffer
,
3949 x
[i
], FLIP(source
, y
[i
]) );
3950 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xff);
3951 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
3952 rgba
[i
][BCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
3953 rgba
[i
][ACOMP
] = (GLubyte
) ((p
>> 24) & 0xff);
3960 unsigned long p
= read_pixel( dpy
, buffer
,
3961 x
[i
], FLIP(source
, y
[i
]) );
3962 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
3963 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
3964 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
3965 rgba
[i
][ACOMP
] = 255;
3972 unsigned long p
= read_pixel( dpy
, buffer
,
3973 x
[i
], FLIP(source
, y
[i
]) );
3974 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
3975 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
3976 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
3977 rgba
[i
][ACOMP
] = 255;
3985 unsigned long p
= read_pixel( dpy
, buffer
,
3986 x
[i
], FLIP(source
, y
[i
]) );
3987 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xE0 );
3988 rgba
[i
][GCOMP
] = (GLubyte
) ((p
& 0x1C) << 3);
3989 rgba
[i
][BCOMP
] = (GLubyte
) ((p
& 0x03) << 6);
3990 rgba
[i
][ACOMP
] = (GLubyte
) 255;
3999 GLubyte
*rTable
= source
->pixel_to_r
;
4000 GLubyte
*gTable
= source
->pixel_to_g
;
4001 GLubyte
*bTable
= source
->pixel_to_b
;
4004 unsigned long p
= read_pixel( dpy
, buffer
,
4005 x
[i
], FLIP(source
, y
[i
]) );
4006 rgba
[i
][RCOMP
] = rTable
[p
];
4007 rgba
[i
][GCOMP
] = gTable
[p
];
4008 rgba
[i
][BCOMP
] = bTable
[p
];
4009 rgba
[i
][ACOMP
] = 255;
4016 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4019 unsigned long p
= read_pixel( dpy
, buffer
,
4020 x
[i
], FLIP(source
, y
[i
])) ^ bitFlip
;
4021 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4022 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4023 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4024 rgba
[i
][ACOMP
] = 255;
4030 gl_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4034 else if (source
->backimage
) {
4035 switch (xmesa
->pixelformat
) {
4039 case PF_DITHER_5R6G5B
:
4041 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4042 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4043 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4044 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4045 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4046 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4047 GLint rShift
= xmesa
->xm_visual
->rshift
;
4048 GLint gShift
= xmesa
->xm_visual
->gshift
;
4049 GLint bShift
= xmesa
->xm_visual
->bshift
;
4050 XMesaImage
*img
= source
->backimage
;
4054 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
4055 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4056 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4057 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4058 rgba
[i
][ACOMP
] = 255;
4066 GLuint
*ptr4
= PIXELADDR4( source
, x
[i
], y
[i
] );
4068 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
4069 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4070 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4071 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
4078 GLuint
*ptr4
= PIXELADDR4( source
, x
[i
], y
[i
] );
4080 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4081 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4082 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4083 rgba
[i
][ACOMP
] = 255;
4090 bgr_t
*ptr3
= PIXELADDR3( source
, x
[i
], y
[i
] );
4091 rgba
[i
][RCOMP
] = ptr3
->r
;
4092 rgba
[i
][GCOMP
] = ptr3
->g
;
4093 rgba
[i
][BCOMP
] = ptr3
->b
;
4094 rgba
[i
][ACOMP
] = 255;
4101 GLubyte
*ptr1
= PIXELADDR1( source
, x
[i
], y
[i
] );
4103 rgba
[i
][RCOMP
] = p
& 0xE0;
4104 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4105 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4106 rgba
[i
][ACOMP
] = 255;
4114 GLubyte
*rTable
= source
->pixel_to_r
;
4115 GLubyte
*gTable
= source
->pixel_to_g
;
4116 GLubyte
*bTable
= source
->pixel_to_b
;
4117 XMesaImage
*img
= source
->backimage
;
4121 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) );
4122 rgba
[i
][RCOMP
] = rTable
[p
];
4123 rgba
[i
][GCOMP
] = gTable
[p
];
4124 rgba
[i
][BCOMP
] = bTable
[p
];
4125 rgba
[i
][ACOMP
] = 255;
4132 XMesaImage
*img
= source
->backimage
;
4133 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4137 p
= XMesaGetPixel( img
, x
[i
], FLIP(source
, y
[i
]) ) ^ bitFlip
;
4138 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4139 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4140 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4141 rgba
[i
][ACOMP
] = 255;
4147 gl_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4155 clear_color_HPCR_ximage( GLcontext
*ctx
,
4156 GLubyte r
, GLubyte g
, GLubyte b
, GLubyte a
)
4159 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
4160 xmesa
->clearcolor
[0] = r
;
4161 xmesa
->clearcolor
[1] = g
;
4162 xmesa
->clearcolor
[2] = b
;
4163 xmesa
->clearcolor
[3] = a
;
4165 if (r
== 0 && g
== 0 && b
== 0) {
4166 /* black is black */
4167 MEMSET( xmesa
->xm_visual
->hpcr_clear_ximage_pattern
, 0x0 ,
4168 sizeof(xmesa
->xm_visual
->hpcr_clear_ximage_pattern
));
4171 /* build clear pattern */
4172 for (i
=0; i
<16; i
++) {
4173 xmesa
->xm_visual
->hpcr_clear_ximage_pattern
[0][i
] =
4174 DITHER_HPCR(i
, 0, r
, g
, b
);
4175 xmesa
->xm_visual
->hpcr_clear_ximage_pattern
[1][i
] =
4176 DITHER_HPCR(i
, 1, r
, g
, b
);
4183 clear_color_HPCR_pixmap( GLcontext
*ctx
,
4184 GLubyte r
, GLubyte g
, GLubyte b
, GLubyte a
)
4187 const XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
4188 xmesa
->clearcolor
[0] = r
;
4189 xmesa
->clearcolor
[1] = g
;
4190 xmesa
->clearcolor
[2] = b
;
4191 xmesa
->clearcolor
[3] = a
;
4194 if (0x0==r
&& 0x0==g
&& 0x0==b
) {
4195 /* black is black */
4196 for (i
=0; i
<16; i
++) {
4197 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 0, 0);
4198 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 1, 0);
4202 for (i
=0; i
<16; i
++) {
4203 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 0, DITHER_HPCR(i
, 0, r
, g
, b
));
4204 XMesaPutPixel(xmesa
->xm_visual
->hpcr_clear_ximage
, i
, 1, DITHER_HPCR(i
, 1, r
, g
, b
));
4207 /* change tile pixmap content */
4208 XMesaPutImage(xmesa
->display
,
4209 (XMesaDrawable
)xmesa
->xm_visual
->hpcr_clear_pixmap
,
4210 xmesa
->xm_buffer
->cleargc
,
4211 xmesa
->xm_visual
->hpcr_clear_ximage
, 0, 0, 0, 0, 16, 2);
4216 void xmesa_update_span_funcs( GLcontext
*ctx
)
4218 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
4219 int depth
=GET_VISUAL_DEPTH(xmesa
->xm_visual
);
4222 * These drawing functions depend on color buffer config:
4224 if (xmesa
->xm_buffer
->buffer
!=XIMAGE
) {
4225 /* Writing to window or back pixmap */
4226 switch (xmesa
->pixelformat
) {
4228 ctx
->Driver
.WriteCI32Span
= write_span_index_pixmap
;
4229 ctx
->Driver
.WriteCI8Span
= write_span_index8_pixmap
;
4230 ctx
->Driver
.WriteMonoCISpan
= write_span_mono_index_pixmap
;
4231 ctx
->Driver
.WriteCI32Pixels
= write_pixels_index_pixmap
;
4232 ctx
->Driver
.WriteMonoCIPixels
= write_pixels_mono_index_pixmap
;
4235 ctx
->Driver
.WriteRGBASpan
= write_span_TRUECOLOR_pixmap
;
4236 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_TRUECOLOR_pixmap
;
4237 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_pixmap
;
4238 ctx
->Driver
.WriteRGBAPixels
= write_pixels_TRUECOLOR_pixmap
;
4239 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4242 ctx
->Driver
.WriteRGBASpan
= write_span_TRUEDITHER_pixmap
;
4243 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_TRUEDITHER_pixmap
;
4244 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_pixmap
;
4245 ctx
->Driver
.WriteRGBAPixels
= write_pixels_TRUEDITHER_pixmap
;
4246 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_pixmap
;
4249 ctx
->Driver
.WriteRGBASpan
= write_span_8A8B8G8R_pixmap
;
4250 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_8A8B8G8R_pixmap
;
4251 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_pixmap
;
4252 ctx
->Driver
.WriteRGBAPixels
= write_pixels_8A8B8G8R_pixmap
;
4253 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4256 ctx
->Driver
.WriteRGBASpan
= write_span_8R8G8B_pixmap
;
4257 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_8R8G8B_pixmap
;
4258 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_pixmap
;
4259 ctx
->Driver
.WriteRGBAPixels
= write_pixels_8R8G8B_pixmap
;
4260 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4261 ctx
->Driver
.DrawPixels
= NULL
; /*drawpixels_8R8G8B;*/
4264 ctx
->Driver
.WriteRGBASpan
= write_span_8R8G8B24_pixmap
;
4265 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_8R8G8B24_pixmap
;
4266 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_pixmap
;
4267 ctx
->Driver
.WriteRGBAPixels
= write_pixels_8R8G8B24_pixmap
;
4268 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4271 ctx
->Driver
.WriteRGBASpan
= write_span_5R6G5B_pixmap
;
4272 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_5R6G5B_pixmap
;
4273 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_pixmap
;
4274 ctx
->Driver
.WriteRGBAPixels
= write_pixels_5R6G5B_pixmap
;
4275 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4277 case PF_DITHER_5R6G5B
:
4278 ctx
->Driver
.WriteRGBASpan
= write_span_DITHER_5R6G5B_pixmap
;
4279 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_DITHER_5R6G5B_pixmap
;
4280 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_pixmap
;
4281 ctx
->Driver
.WriteRGBAPixels
= write_pixels_DITHER_5R6G5B_pixmap
;
4282 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_pixmap
;
4285 ctx
->Driver
.WriteRGBASpan
= write_span_DITHER_pixmap
;
4286 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_DITHER_pixmap
;
4287 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_DITHER_pixmap
;
4288 ctx
->Driver
.WriteRGBAPixels
= write_pixels_DITHER_pixmap
;
4289 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_DITHER_pixmap
;
4292 ctx
->Driver
.WriteRGBASpan
= write_span_1BIT_pixmap
;
4293 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_1BIT_pixmap
;
4294 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_1BIT_pixmap
;
4295 ctx
->Driver
.WriteRGBAPixels
= write_pixels_1BIT_pixmap
;
4296 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_1BIT_pixmap
;
4299 ctx
->Driver
.WriteRGBASpan
= write_span_HPCR_pixmap
;
4300 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_HPCR_pixmap
;
4301 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_pixmap
;
4302 ctx
->Driver
.WriteRGBAPixels
= write_pixels_HPCR_pixmap
;
4303 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4304 if (xmesa
->xm_visual
->hpcr_clear_flag
) {
4305 ctx
->Driver
.ClearColor
= clear_color_HPCR_pixmap
;
4309 ctx
->Driver
.WriteRGBASpan
= write_span_LOOKUP_pixmap
;
4310 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_LOOKUP_pixmap
;
4311 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_pixmap
;
4312 ctx
->Driver
.WriteRGBAPixels
= write_pixels_LOOKUP_pixmap
;
4313 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4316 ctx
->Driver
.WriteRGBASpan
= write_span_GRAYSCALE_pixmap
;
4317 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_GRAYSCALE_pixmap
;
4318 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_pixmap
;
4319 ctx
->Driver
.WriteRGBAPixels
= write_pixels_GRAYSCALE_pixmap
;
4320 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_pixmap
;
4323 gl_problem(NULL
,"Bad pixel format in xmesa_update_state (1)");
4327 else if (xmesa
->xm_buffer
->buffer
==XIMAGE
) {
4328 /* Writing to back XImage */
4329 switch (xmesa
->pixelformat
) {
4331 ctx
->Driver
.WriteCI32Span
= write_span_index_ximage
;
4333 ctx
->Driver
.WriteCI8Span
= write_span_index8_ximage8
;
4335 ctx
->Driver
.WriteCI8Span
= write_span_index8_ximage
;
4336 ctx
->Driver
.WriteMonoCISpan
= write_span_mono_index_ximage
;
4337 ctx
->Driver
.WriteCI32Pixels
= write_pixels_index_ximage
;
4338 ctx
->Driver
.WriteMonoCIPixels
= write_pixels_mono_index_ximage
;
4342 ctx
->Driver
.WriteRGBASpan
= write_span_TRUECOLOR_ximage
;
4343 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_TRUECOLOR_ximage
;
4344 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_ximage
;
4345 ctx
->Driver
.WriteRGBAPixels
= write_pixels_TRUECOLOR_ximage
;
4346 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4349 ctx
->Driver
.WriteRGBASpan
= write_span_TRUEDITHER_ximage
;
4350 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_TRUEDITHER_ximage
;
4351 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_TRUEDITHER_ximage
;
4352 ctx
->Driver
.WriteRGBAPixels
= write_pixels_TRUEDITHER_ximage
;
4353 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_TRUEDITHER_ximage
;
4356 ctx
->Driver
.WriteRGBASpan
= write_span_8A8B8G8R_ximage
;
4357 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_8A8B8G8R_ximage
;
4358 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_8A8B8G8R_ximage
;
4359 ctx
->Driver
.WriteRGBAPixels
= write_pixels_8A8B8G8R_ximage
;
4360 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_8A8B8G8R_ximage
;
4363 ctx
->Driver
.WriteRGBASpan
= write_span_8R8G8B_ximage
;
4364 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_8R8G8B_ximage
;
4365 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_8R8G8B_ximage
;
4366 ctx
->Driver
.WriteRGBAPixels
= write_pixels_8R8G8B_ximage
;
4367 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_8R8G8B_ximage
;
4368 ctx
->Driver
.DrawPixels
= NULL
;
4371 ctx
->Driver
.WriteRGBASpan
= write_span_8R8G8B24_ximage
;
4372 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_8R8G8B24_ximage
;
4373 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_8R8G8B24_ximage
;
4374 ctx
->Driver
.WriteRGBAPixels
= write_pixels_8R8G8B24_ximage
;
4375 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_8R8G8B24_ximage
;
4378 ctx
->Driver
.WriteRGBASpan
= write_span_5R6G5B_ximage
;
4379 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_5R6G5B_ximage
;
4380 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_ximage
;
4381 ctx
->Driver
.WriteRGBAPixels
= write_pixels_5R6G5B_ximage
;
4382 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4384 case PF_DITHER_5R6G5B
:
4385 ctx
->Driver
.WriteRGBASpan
= write_span_DITHER_5R6G5B_ximage
;
4386 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_DITHER_5R6G5B_ximage
;
4387 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_DITHER_5R6G5B_ximage
;
4388 ctx
->Driver
.WriteRGBAPixels
= write_pixels_DITHER_5R6G5B_ximage
;
4389 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_DITHER_5R6G5B_ximage
;
4393 ctx
->Driver
.WriteRGBASpan
= write_span_DITHER8_ximage
;
4394 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_DITHER8_ximage
;
4395 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_DITHER8_ximage
;
4396 ctx
->Driver
.WriteRGBAPixels
= write_pixels_DITHER8_ximage
;
4397 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_DITHER8_ximage
;
4400 ctx
->Driver
.WriteRGBASpan
= write_span_DITHER_ximage
;
4401 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_DITHER_ximage
;
4402 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_DITHER_ximage
;
4403 ctx
->Driver
.WriteRGBAPixels
= write_pixels_DITHER_ximage
;
4404 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_DITHER_ximage
;
4408 ctx
->Driver
.WriteRGBASpan
= write_span_1BIT_ximage
;
4409 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_1BIT_ximage
;
4410 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_1BIT_ximage
;
4411 ctx
->Driver
.WriteRGBAPixels
= write_pixels_1BIT_ximage
;
4412 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_1BIT_ximage
;
4415 ctx
->Driver
.WriteRGBASpan
= write_span_HPCR_ximage
;
4416 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_HPCR_ximage
;
4417 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_HPCR_ximage
;
4418 ctx
->Driver
.WriteRGBAPixels
= write_pixels_HPCR_ximage
;
4419 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_HPCR_ximage
;
4420 if (xmesa
->xm_visual
->hpcr_clear_flag
) {
4421 ctx
->Driver
.ClearColor
= clear_color_HPCR_ximage
;
4426 ctx
->Driver
.WriteRGBASpan
= write_span_LOOKUP8_ximage
;
4427 ctx
->Driver
.WriteRGBSpan
= write_rgb_LOOKUP8_ximage
;
4428 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_LOOKUP8_ximage
;
4429 ctx
->Driver
.WriteRGBAPixels
= write_pixels_LOOKUP8_ximage
;
4430 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_LOOKUP8_ximage
;
4433 ctx
->Driver
.WriteRGBASpan
= write_span_LOOKUP_ximage
;
4434 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_LOOKUP_ximage
;
4435 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_ximage
;
4436 ctx
->Driver
.WriteRGBAPixels
= write_pixels_LOOKUP_ximage
;
4437 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4442 ctx
->Driver
.WriteRGBASpan
= write_span_GRAYSCALE8_ximage
;
4443 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_GRAYSCALE8_ximage
;
4444 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_GRAYSCALE8_ximage
;
4445 ctx
->Driver
.WriteRGBAPixels
= write_pixels_GRAYSCALE8_ximage
;
4446 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_GRAYSCALE8_ximage
;
4449 ctx
->Driver
.WriteRGBASpan
= write_span_GRAYSCALE_ximage
;
4450 ctx
->Driver
.WriteRGBSpan
= write_span_rgb_GRAYSCALE_ximage
;
4451 ctx
->Driver
.WriteMonoRGBASpan
= write_span_mono_ximage
;
4452 ctx
->Driver
.WriteRGBAPixels
= write_pixels_GRAYSCALE_ximage
;
4453 ctx
->Driver
.WriteMonoRGBAPixels
= write_pixels_mono_ximage
;
4457 gl_problem(NULL
,"Bad pixel format in xmesa_update_state (2)");
4462 /* Pixel/span reading functions: */
4463 ctx
->Driver
.ReadCI32Span
= read_index_span
;
4464 ctx
->Driver
.ReadRGBASpan
= read_color_span
;
4465 ctx
->Driver
.ReadCI32Pixels
= read_index_pixels
;
4466 ctx
->Driver
.ReadRGBAPixels
= read_color_pixels
;