3
* Mesa 3-D graphics library
6
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
8
* Permission is hereby granted, free of charge, to any person obtaining a
9
* copy of this software and associated documentation files (the "Software"),
10
* to deal in the Software without restriction, including without limitation
11
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
* and/or sell copies of the Software, and to permit persons to whom the
13
* Software is furnished to do so, subject to the following conditions:
15
* The above copyright notice and this permission notice shall be included
16
* in all copies or substantial portions of the Software.
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
/* $XFree86: xc/extras/Mesa/src/X/xm_span.c,v 1.5 2002/12/16 16:18:31 dawes Exp $ */
27
#include "glxheader.h"
36
#include "extensions.h"
38
#include "swrast/swrast.h"
42
* The following functions are used to trap XGetImage() calls which
43
* generate BadMatch errors if the drawable isn't mapped.
47
static int caught_xgetimage_error = 0;
48
static int (*old_xerror_handler)( XMesaDisplay *dpy, XErrorEvent *ev );
49
static unsigned long xgetimage_serial;
52
* This is the error handler which will be called if XGetImage fails.
54
static int xgetimage_error_handler( XMesaDisplay *dpy, XErrorEvent *ev )
56
if (ev->serial==xgetimage_serial && ev->error_code==BadMatch) {
57
/* caught the expected error */
58
caught_xgetimage_error = 0;
61
/* call the original X error handler, if any. otherwise ignore */
62
if (old_xerror_handler) {
63
(*old_xerror_handler)( dpy, ev );
71
* Call this right before XGetImage to setup error trap.
73
static void catch_xgetimage_errors( XMesaDisplay *dpy )
75
xgetimage_serial = NextRequest( dpy );
76
old_xerror_handler = XSetErrorHandler( xgetimage_error_handler );
77
caught_xgetimage_error = 0;
82
* Call this right after XGetImage to check if an error occured.
84
static int check_xgetimage_errors( void )
86
/* restore old handler */
87
(void) XSetErrorHandler( old_xerror_handler );
88
/* return 0=no error, 1=error caught */
89
return caught_xgetimage_error;
95
* Read a pixel from an X drawable.
97
static unsigned long read_pixel( XMesaDisplay *dpy,
98
XMesaDrawable d, int x, int y )
101
#ifndef XFree86Server
102
XMesaImage *pixel = NULL;
105
catch_xgetimage_errors( dpy );
106
pixel = XGetImage( dpy, d, x, y, 1, 1, AllPlanes, ZPixmap );
107
error = check_xgetimage_errors();
108
if (pixel && !error) {
109
p = XMesaGetPixel( pixel, 0, 0 );
115
XMesaDestroyImage( pixel );
118
(*dpy->GetImage)(d, x, y, 1, 1, ZPixmap, ~0L, (pointer)&p);
126
* The Mesa library needs to be able to draw pixels in a number of ways:
127
* 1. RGB vs Color Index
128
* 2. as horizontal spans (polygons, images) vs random locations (points,
130
* 3. different color per-pixel or same color for all pixels
132
* Furthermore, the X driver needs to support rendering to 3 possible
133
* "buffers", usually one, but sometimes two at a time:
134
* 1. The front buffer as an X window
135
* 2. The back buffer as a Pixmap
136
* 3. The back buffer as an XImage
138
* Finally, if the back buffer is an XImage, we can avoid using XPutPixel and
139
* optimize common cases such as 24-bit and 8-bit modes.
141
* By multiplication, there's at least 48 possible combinations of the above.
143
* Below are implementations of the most commonly used combinations. They are
144
* accessed through function pointers which get initialized here and are used
145
* directly from the Mesa library. The 8 function pointers directly correspond
146
* to the first 3 cases listed above.
149
* The function naming convention is:
151
* write_[span|pixels]_[mono]_[format]_[pixmap|ximage]
153
* New functions optimized for specific cases can be added without too much
154
* trouble. An example might be the 24-bit TrueColor mode 8A8R8G8B which is
155
* found on IBM RS/6000 X servers.
161
/**********************************************************************/
162
/*** Write COLOR SPAN functions ***/
163
/**********************************************************************/
166
#define RGBA_SPAN_ARGS const GLcontext *ctx, \
167
GLuint n, GLint x, GLint y, \
168
CONST GLubyte rgba[][4], const GLubyte mask[]
170
#define RGB_SPAN_ARGS const GLcontext *ctx, \
171
GLuint n, GLint x, GLint y, \
172
CONST GLubyte rgb[][3], const GLubyte mask[]
175
/* NOTE: if mask==NULL, draw all pixels */
179
* Write a span of PF_TRUECOLOR pixels to a pixmap.
181
static void write_span_TRUECOLOR_pixmap( RGBA_SPAN_ARGS )
183
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
184
XMesaDisplay *dpy = xmesa->xm_visual->display;
185
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
186
XMesaGC gc = xmesa->xm_buffer->gc;
189
(void)DitherValues; /* Muffle compiler */
191
y = FLIP(xmesa->xm_buffer, y);
193
for (i=0;i<n;i++,x++) {
196
PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
197
XMesaSetForeground( dpy, gc, p );
198
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
203
/* draw all pixels */
204
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
207
PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
208
XMesaPutPixel( rowimg, i, 0, p );
210
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
216
* Write a span of PF_TRUECOLOR pixels to a pixmap.
218
static void write_span_rgb_TRUECOLOR_pixmap( RGB_SPAN_ARGS )
220
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
221
XMesaDisplay *dpy = xmesa->xm_visual->display;
222
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
223
XMesaGC gc = xmesa->xm_buffer->gc;
225
y = FLIP(xmesa->xm_buffer, y);
227
for (i=0;i<n;i++,x++) {
230
PACK_TRUECOLOR( p, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
231
XMesaSetForeground( dpy, gc, p );
232
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
237
/* draw all pixels */
238
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
241
PACK_TRUECOLOR( p, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
242
XMesaPutPixel( rowimg, i, 0, p );
244
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
250
* Write a span of PF_TRUEDITHER pixels to a pixmap.
252
static void write_span_TRUEDITHER_pixmap( RGBA_SPAN_ARGS )
254
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
255
XMesaDisplay *dpy = xmesa->xm_visual->display;
256
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
257
XMesaGC gc = xmesa->xm_buffer->gc;
259
y = FLIP(xmesa->xm_buffer, y);
261
for (i=0;i<n;i++,x++) {
264
PACK_TRUEDITHER(p, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
265
XMesaSetForeground( dpy, gc, p );
266
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
271
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
274
PACK_TRUEDITHER(p, x+i, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
275
XMesaPutPixel( rowimg, i, 0, p );
277
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
283
* Write a span of PF_TRUEDITHER pixels to a pixmap (no alpha).
285
static void write_span_rgb_TRUEDITHER_pixmap( RGB_SPAN_ARGS )
287
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
288
XMesaDisplay *dpy = xmesa->xm_visual->display;
289
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
290
XMesaGC gc = xmesa->xm_buffer->gc;
292
y = FLIP(xmesa->xm_buffer, y);
294
for (i=0;i<n;i++,x++) {
297
PACK_TRUEDITHER(p, x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
298
XMesaSetForeground( dpy, gc, p );
299
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
304
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
307
PACK_TRUEDITHER(p, x+i, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
308
XMesaPutPixel( rowimg, i, 0, p );
310
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
317
* Write a span of PF_8A8B8G8R pixels to a pixmap.
319
static void write_span_8A8B8G8R_pixmap( RGBA_SPAN_ARGS )
321
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
322
XMesaDisplay *dpy = xmesa->xm_visual->display;
323
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
324
XMesaGC gc = xmesa->xm_buffer->gc;
326
y = FLIP(xmesa->xm_buffer, y);
328
for (i=0;i<n;i++,x++) {
330
XMesaSetForeground( dpy, gc,
331
PACK_8A8B8G8R(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP]) );
332
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
337
/* draw all pixels */
338
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
339
register GLuint *ptr4 = (GLuint *) rowimg->data;
341
*ptr4++ = PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
343
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
349
* Write a span of PF_8A8B8G8R pixels to a pixmap (no alpha).
351
static void write_span_rgb_8A8B8G8R_pixmap( RGB_SPAN_ARGS )
353
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
354
XMesaDisplay *dpy = xmesa->xm_visual->display;
355
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
356
XMesaGC gc = xmesa->xm_buffer->gc;
358
y = FLIP(xmesa->xm_buffer, y);
360
for (i=0;i<n;i++,x++) {
362
XMesaSetForeground( dpy, gc,
363
PACK_8B8G8R(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
364
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
369
/* draw all pixels */
370
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
371
register GLuint *ptr4 = (GLuint *) rowimg->data;
373
*ptr4++ = PACK_8B8G8R(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
375
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
381
* Write a span of PF_8R8G8B pixels to a pixmap.
383
static void write_span_8R8G8B_pixmap( RGBA_SPAN_ARGS )
385
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
386
XMesaDisplay *dpy = xmesa->xm_visual->display;
387
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
388
XMesaGC gc = xmesa->xm_buffer->gc;
390
y = FLIP(xmesa->xm_buffer, y);
392
for (i=0;i<n;i++,x++) {
394
XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
395
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
400
/* draw all pixels */
401
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
402
register GLuint *ptr4 = (GLuint *) rowimg->data;
404
*ptr4++ = PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
406
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
412
* Write a span of PF_8R8G8B24 pixels to a pixmap.
414
static void write_span_8R8G8B24_pixmap( RGBA_SPAN_ARGS )
416
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
417
XMesaDisplay *dpy = xmesa->xm_visual->display;
418
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
419
XMesaGC gc = xmesa->xm_buffer->gc;
420
y = FLIP(xmesa->xm_buffer, y);
423
for (i=0;i<n;i++,x++) {
425
XMesaSetForeground( dpy, gc,
426
PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
427
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
432
/* draw all pixels */
433
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
434
register GLuint *ptr4 = (GLuint *) rowimg->data;
435
register GLuint pixel;
436
static const GLuint shift[4] = {0, 8, 16, 24};
437
register GLuint i = 0;
440
pixel = rgba[i][BCOMP] /* << shift[0]*/;
441
pixel |= rgba[i][GCOMP] << shift[1];
442
pixel |= rgba[i++][RCOMP] << shift[2];
443
pixel |= rgba[i][BCOMP] << shift[3];
446
pixel = rgba[i][GCOMP] /* << shift[0]*/;
447
pixel |= rgba[i++][RCOMP] << shift[1];
448
pixel |= rgba[i][BCOMP] << shift[2];
449
pixel |= rgba[i][GCOMP] << shift[3];
452
pixel = rgba[i++][RCOMP]/* << shift[0]*/;
453
pixel |= rgba[i][BCOMP] << shift[1];
454
pixel |= rgba[i][GCOMP] << shift[2];
455
pixel |= rgba[i++][RCOMP] << shift[3];
463
pixel |= rgba[i][BCOMP] /*<< shift[0]*/;
464
pixel |= rgba[i][GCOMP] << shift[1];
465
pixel |= rgba[i++][RCOMP] << shift[2];
466
pixel |= rgba[i][BCOMP] << shift[3];
469
pixel |= rgba[i][GCOMP] /*<< shift[0]*/;
470
pixel |= rgba[i++][RCOMP] << shift[1];
471
pixel |= rgba[i][BCOMP] << shift[2];
472
pixel |= rgba[i][GCOMP] << shift[3];
474
pixel = 0xffffff00 & *ptr4;
475
pixel |= rgba[i][RCOMP] /*<< shift[0]*/;
480
pixel |= rgba[i][BCOMP] /*<< shift[0]*/;
481
pixel |= rgba[i][GCOMP] << shift[1];
482
pixel |= rgba[i++][RCOMP] << shift[2];
483
pixel |= rgba[i][BCOMP] << shift[3];
485
pixel = 0xffff0000 & *ptr4;
486
pixel |= rgba[i][GCOMP] /*<< shift[0]*/;
487
pixel |= rgba[i][RCOMP] << shift[1];
491
pixel = 0xff000000 & *ptr4;
492
pixel |= rgba[i][BCOMP] /*<< shift[0]*/;
493
pixel |= rgba[i][GCOMP] << shift[1];
494
pixel |= rgba[i][RCOMP] << shift[2];
500
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
506
* Write a span of PF_8R8G8B pixels to a pixmap (no alpha).
508
static void write_span_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS )
510
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
511
XMesaDisplay *dpy = xmesa->xm_visual->display;
512
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
513
XMesaGC gc = xmesa->xm_buffer->gc;
515
y = FLIP(xmesa->xm_buffer, y);
517
for (i=0;i<n;i++,x++) {
519
XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ));
520
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
525
/* draw all pixels */
526
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
527
register GLuint *ptr4 = (GLuint *) rowimg->data;
529
*ptr4++ = PACK_8R8G8B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
531
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
537
* Write a span of PF_8R8G8B24 pixels to a pixmap (no alpha).
539
static void write_span_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS )
541
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
542
XMesaDisplay *dpy = xmesa->xm_visual->display;
543
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
544
XMesaGC gc = xmesa->xm_buffer->gc;
545
y = FLIP(xmesa->xm_buffer, y);
548
for (i=0;i<n;i++,x++) {
550
XMesaSetForeground( dpy, gc,
551
PACK_8R8G8B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ));
552
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
557
/* draw all pixels */
558
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
559
register GLuint *ptr4 = (GLuint *) rowimg->data;
560
register GLuint pixel;
561
static const GLuint shift[4] = {0, 8, 16, 24};
563
register GLuint i = 0;
566
pixel |= rgb[i][BCOMP]/* << shift[0]*/;
567
pixel |= rgb[i][GCOMP] << shift[1];
568
pixel |= rgb[i++][RCOMP] << shift[2];
569
pixel |= rgb[i][BCOMP] <<shift[3];
573
pixel |= rgb[i][GCOMP]/* << shift[0]*/;
574
pixel |= rgb[i++][RCOMP] << shift[1];
575
pixel |= rgb[i][BCOMP] << shift[2];
576
pixel |= rgb[i][GCOMP] << shift[3];
580
pixel |= rgb[i++][RCOMP]/* << shift[0]*/;
581
pixel |= rgb[i][BCOMP] << shift[1];
582
pixel |= rgb[i][GCOMP] << shift[2];
583
pixel |= rgb[i++][RCOMP] << shift[3];
590
pixel |= rgb[i][BCOMP]/* << shift[0]*/;
591
pixel |= rgb[i][GCOMP] << shift[1];
592
pixel |= rgb[i++][RCOMP] << shift[2];
593
pixel |= rgb[i][BCOMP] << shift[3];
596
pixel |= rgb[i][GCOMP]/* << shift[0]*/;
597
pixel |= rgb[i++][RCOMP] << shift[1];
598
pixel |= rgb[i][BCOMP] << shift[2];
599
pixel |= rgb[i][GCOMP] << shift[3];
603
pixel |= rgb[i++][RCOMP]/* << shift[0]*/;
608
pixel |= rgb[i][BCOMP]/* << shift[0]*/;
609
pixel |= rgb[i][GCOMP] << shift[1];
610
pixel |= rgb[i++][RCOMP] << shift[2];
611
pixel |= rgb[i][BCOMP] << shift[3];
615
pixel |= rgb[i][GCOMP]/* << shift[0]*/;
616
pixel |= rgb[i++][RCOMP] << shift[1];
622
pixel |= rgb[i][BCOMP]/* << shift[0]*/;
623
pixel |= rgb[i][GCOMP] << shift[1];
624
pixel |= rgb[i++][RCOMP] << shift[2];
630
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
636
* Write a span of PF_5R6G5B pixels to a pixmap.
638
static void write_span_5R6G5B_pixmap( RGBA_SPAN_ARGS )
640
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
641
XMesaDisplay *dpy = xmesa->xm_visual->display;
642
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
643
XMesaGC gc = xmesa->xm_buffer->gc;
645
y = FLIP(xmesa->xm_buffer, y);
647
for (i=0;i<n;i++,x++) {
649
XMesaSetForeground( dpy, gc, PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
650
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
655
/* draw all pixels */
656
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
657
register GLushort *ptr2 = (GLushort *) rowimg->data;
659
ptr2[i] = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
661
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
667
* Write a span of PF_DITHER_5R6G5B pixels to a pixmap.
669
static void write_span_DITHER_5R6G5B_pixmap( RGBA_SPAN_ARGS )
671
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
672
XMesaDisplay *dpy = xmesa->xm_visual->display;
673
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
674
XMesaGC gc = xmesa->xm_buffer->gc;
676
y = FLIP(xmesa->xm_buffer, y);
678
for (i=0;i<n;i++,x++) {
681
PACK_TRUEDITHER(p, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
682
XMesaSetForeground( dpy, gc, p );
683
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
688
/* draw all pixels */
689
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
690
register GLushort *ptr2 = (GLushort *) rowimg->data;
692
PACK_TRUEDITHER( ptr2[i], x+i, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
694
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
700
* Write a span of PF_5R6G5B pixels to a pixmap (no alpha).
702
static void write_span_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS )
704
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
705
XMesaDisplay *dpy = xmesa->xm_visual->display;
706
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
707
XMesaGC gc = xmesa->xm_buffer->gc;
709
y = FLIP(xmesa->xm_buffer, y);
711
for (i=0;i<n;i++,x++) {
713
XMesaSetForeground( dpy, gc, PACK_5R6G5B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ));
714
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
719
/* draw all pixels */
720
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
721
register GLushort *ptr2 = (GLushort *) rowimg->data;
723
ptr2[i] = PACK_5R6G5B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
725
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
731
* Write a span of PF_DITHER_5R6G5B pixels to a pixmap (no alpha).
733
static void write_span_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS )
735
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
736
XMesaDisplay *dpy = xmesa->xm_visual->display;
737
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
738
XMesaGC gc = xmesa->xm_buffer->gc;
740
y = FLIP(xmesa->xm_buffer, y);
742
for (i=0;i<n;i++,x++) {
745
PACK_TRUEDITHER(p, x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
746
XMesaSetForeground( dpy, gc, p );
747
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
752
/* draw all pixels */
753
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
754
register GLushort *ptr2 = (GLushort *) rowimg->data;
756
PACK_TRUEDITHER( ptr2[i], x+i, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
758
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
765
* Write a span of PF_DITHER pixels to a pixmap.
767
static void write_span_DITHER_pixmap( RGBA_SPAN_ARGS )
769
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
770
XMesaDisplay *dpy = xmesa->xm_visual->display;
771
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
772
XMesaGC gc = xmesa->xm_buffer->gc;
775
y = FLIP(xmesa->xm_buffer, y);
777
for (i=0;i<n;i++,x++) {
779
XMesaSetForeground( dpy, gc, XDITHER(x, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
780
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
785
/* draw all pixels */
786
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
788
XMesaPutPixel( rowimg, i, 0, XDITHER(x+i, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
790
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
796
* Write a span of PF_DITHER pixels to a pixmap (no alpha).
798
static void write_span_rgb_DITHER_pixmap( RGB_SPAN_ARGS )
800
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
801
XMesaDisplay *dpy = xmesa->xm_visual->display;
802
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
803
XMesaGC gc = xmesa->xm_buffer->gc;
806
y = FLIP(xmesa->xm_buffer, y);
808
for (i=0;i<n;i++,x++) {
810
XMesaSetForeground( dpy, gc, XDITHER(x, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
811
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
816
/* draw all pixels */
817
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
819
XMesaPutPixel( rowimg, i, 0, XDITHER(x+i, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
821
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
827
* Write a span of PF_1BIT pixels to a pixmap.
829
static void write_span_1BIT_pixmap( RGBA_SPAN_ARGS )
831
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
832
XMesaDisplay *dpy = xmesa->xm_visual->display;
833
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
834
XMesaGC gc = xmesa->xm_buffer->gc;
837
y = FLIP(xmesa->xm_buffer, y);
839
for (i=0;i<n;i++,x++) {
841
XMesaSetForeground( dpy, gc,
842
DITHER_1BIT( x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
843
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
848
/* draw all pixels */
849
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
851
XMesaPutPixel( rowimg, i, 0,
852
DITHER_1BIT( x+i, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
854
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
860
* Write a span of PF_1BIT pixels to a pixmap (no alpha).
862
static void write_span_rgb_1BIT_pixmap( RGB_SPAN_ARGS )
864
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
865
XMesaDisplay *dpy = xmesa->xm_visual->display;
866
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
867
XMesaGC gc = xmesa->xm_buffer->gc;
870
y = FLIP(xmesa->xm_buffer, y);
872
for (i=0;i<n;i++,x++) {
874
XMesaSetForeground( dpy, gc,
875
DITHER_1BIT(x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
876
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
881
/* draw all pixels */
882
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
884
XMesaPutPixel( rowimg, i, 0,
885
DITHER_1BIT(x+i, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
887
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
893
* Write a span of PF_HPCR pixels to a pixmap.
895
static void write_span_HPCR_pixmap( RGBA_SPAN_ARGS )
897
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
898
XMesaDisplay *dpy = xmesa->xm_visual->display;
899
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
900
XMesaGC gc = xmesa->xm_buffer->gc;
902
y = FLIP(xmesa->xm_buffer, y);
904
for (i=0;i<n;i++,x++) {
906
XMesaSetForeground( dpy, gc,
907
DITHER_HPCR( x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
908
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
913
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
914
register GLubyte *ptr = (GLubyte *) xmesa->xm_buffer->rowimage->data;
916
ptr[i] = DITHER_HPCR( (x+i), y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
918
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
924
* Write a span of PF_HPCR pixels to a pixmap (no alpha).
926
static void write_span_rgb_HPCR_pixmap( RGB_SPAN_ARGS )
928
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
929
XMesaDisplay *dpy = xmesa->xm_visual->display;
930
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
931
XMesaGC gc = xmesa->xm_buffer->gc;
933
y = FLIP(xmesa->xm_buffer, y);
935
for (i=0;i<n;i++,x++) {
937
XMesaSetForeground( dpy, gc,
938
DITHER_HPCR(x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
939
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
944
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
945
register GLubyte *ptr = (GLubyte *) xmesa->xm_buffer->rowimage->data;
947
ptr[i] = DITHER_HPCR( (x+i), y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
949
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
955
* Write a span of PF_LOOKUP pixels to a pixmap.
957
static void write_span_LOOKUP_pixmap( RGBA_SPAN_ARGS )
959
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
960
XMesaDisplay *dpy = xmesa->xm_visual->display;
961
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
962
XMesaGC gc = xmesa->xm_buffer->gc;
965
y = FLIP(xmesa->xm_buffer, y);
967
for (i=0;i<n;i++,x++) {
969
XMesaSetForeground( dpy, gc, LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
970
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
975
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
977
XMesaPutPixel( rowimg, i, 0, LOOKUP(rgba[i][RCOMP],rgba[i][GCOMP],rgba[i][BCOMP]) );
979
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
985
* Write a span of PF_LOOKUP pixels to a pixmap (no alpha).
987
static void write_span_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS )
989
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
990
XMesaDisplay *dpy = xmesa->xm_visual->display;
991
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
992
XMesaGC gc = xmesa->xm_buffer->gc;
995
y = FLIP(xmesa->xm_buffer, y);
997
for (i=0;i<n;i++,x++) {
999
XMesaSetForeground( dpy, gc, LOOKUP( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
1000
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
1005
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
1007
XMesaPutPixel( rowimg, i, 0, LOOKUP(rgb[i][RCOMP],rgb[i][GCOMP],rgb[i][BCOMP]) );
1009
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
1016
* Write a span of PF_GRAYSCALE pixels to a pixmap.
1018
static void write_span_GRAYSCALE_pixmap( RGBA_SPAN_ARGS )
1020
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1021
XMesaDisplay *dpy = xmesa->xm_visual->display;
1022
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
1023
XMesaGC gc = xmesa->xm_buffer->gc;
1025
y = FLIP(xmesa->xm_buffer, y);
1027
for (i=0;i<n;i++,x++) {
1029
XMesaSetForeground( dpy, gc, GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
1030
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
1035
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
1037
XMesaPutPixel( rowimg, i, 0, GRAY_RGB(rgba[i][RCOMP],rgba[i][GCOMP],rgba[i][BCOMP]) );
1039
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
1045
* Write a span of PF_GRAYSCALE pixels to a pixmap (no alpha).
1047
static void write_span_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS )
1049
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1050
XMesaDisplay *dpy = xmesa->xm_visual->display;
1051
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
1052
XMesaGC gc = xmesa->xm_buffer->gc;
1054
y = FLIP(xmesa->xm_buffer, y);
1056
for (i=0;i<n;i++,x++) {
1058
XMesaSetForeground( dpy, gc, GRAY_RGB( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
1059
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
1064
XMesaImage *rowimg = xmesa->xm_buffer->rowimage;
1066
XMesaPutPixel( rowimg, i, 0, GRAY_RGB(rgb[i][RCOMP],rgb[i][GCOMP],rgb[i][BCOMP]) );
1068
XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
1074
* Write a span of PF_TRUECOLOR pixels to an XImage.
1076
static void write_span_TRUECOLOR_ximage( RGBA_SPAN_ARGS )
1078
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1079
XMesaImage *img = xmesa->xm_buffer->backimage;
1081
y = FLIP(xmesa->xm_buffer, y);
1083
for (i=0;i<n;i++,x++) {
1086
PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
1087
XMesaPutPixel( img, x, y, p );
1092
/* draw all pixels */
1093
for (i=0;i<n;i++,x++) {
1095
PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
1096
XMesaPutPixel( img, x, y, p );
1103
* Write a span of PF_TRUECOLOR pixels to an XImage (no alpha).
1105
static void write_span_rgb_TRUECOLOR_ximage( RGB_SPAN_ARGS )
1107
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1108
XMesaImage *img = xmesa->xm_buffer->backimage;
1110
y = FLIP(xmesa->xm_buffer, y);
1112
for (i=0;i<n;i++,x++) {
1115
PACK_TRUECOLOR( p, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
1116
XMesaPutPixel( img, x, y, p );
1121
/* draw all pixels */
1122
for (i=0;i<n;i++,x++) {
1124
PACK_TRUECOLOR( p, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
1125
XMesaPutPixel( img, x, y, p );
1132
* Write a span of PF_TRUEDITHER pixels to an XImage.
1134
static void write_span_TRUEDITHER_ximage( RGBA_SPAN_ARGS )
1136
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1137
XMesaImage *img = xmesa->xm_buffer->backimage;
1139
y = FLIP(xmesa->xm_buffer, y);
1141
for (i=0;i<n;i++,x++) {
1144
PACK_TRUEDITHER(p, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
1145
XMesaPutPixel( img, x, y, p );
1150
/* draw all pixels */
1151
for (i=0;i<n;i++,x++) {
1153
PACK_TRUEDITHER(p, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
1154
XMesaPutPixel( img, x, y, p );
1161
* Write a span of PF_TRUEDITHER pixels to an XImage (no alpha).
1163
static void write_span_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS )
1165
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1166
XMesaImage *img = xmesa->xm_buffer->backimage;
1168
y = FLIP(xmesa->xm_buffer, y);
1170
for (i=0;i<n;i++,x++) {
1173
PACK_TRUEDITHER(p, x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
1174
XMesaPutPixel( img, x, y, p );
1179
/* draw all pixels */
1180
for (i=0;i<n;i++,x++) {
1182
PACK_TRUEDITHER(p, x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
1183
XMesaPutPixel( img, x, y, p );
1190
* Write a span of PF_8A8B8G8R-format pixels to an ximage.
1192
static void write_span_8A8B8G8R_ximage( RGBA_SPAN_ARGS )
1194
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1196
register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
1200
ptr[i] = PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
1205
/* draw all pixels */
1207
ptr[i] = PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
1214
* Write a span of PF_8A8B8G8R-format pixels to an ximage (no alpha).
1216
static void write_span_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS )
1218
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1220
register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
1224
ptr[i] = PACK_8A8B8G8R( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP], 255 );
1229
/* draw all pixels */
1231
ptr[i] = PACK_8A8B8G8R( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP], 255 );
1238
* Write a span of PF_8R8G8B-format pixels to an ximage.
1240
static void write_span_8R8G8B_ximage( RGBA_SPAN_ARGS )
1242
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1244
register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
1248
ptr[i] = PACK_8R8G8B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
1254
ptr[i] = PACK_8R8G8B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
1261
* Write a span of PF_8R8G8B24-format pixels to an ximage.
1263
static void write_span_8R8G8B24_ximage( RGBA_SPAN_ARGS )
1265
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1267
register GLubyte *ptr = (GLubyte *) PIXELADDR3( xmesa->xm_buffer, x, y );
1271
GLuint *ptr4 = (GLuint *) ptr;
1272
register GLuint pixel = *ptr4;
1273
switch (3 & (int)(ptr - (GLubyte*)ptr4)) {
1275
pixel &= 0xff000000;
1276
pixel |= rgba[i][BCOMP];
1277
pixel |= rgba[i][GCOMP] << 8;
1278
pixel |= rgba[i][RCOMP] << 16;
1282
pixel &= 0x00ffffff;
1283
pixel |= rgba[i][BCOMP] << 24;
1285
pixel = *ptr4 && 0xffff0000;
1286
pixel |= rgba[i][GCOMP];
1287
pixel |= rgba[i][RCOMP] << 8;
1291
pixel &= 0x0000ffff;
1292
pixel |= rgba[i][BCOMP] << 16;
1293
pixel |= rgba[i][GCOMP] << 24;
1295
pixel = *ptr4 && 0xffffff00;
1296
pixel |= rgba[i][RCOMP];
1300
pixel &= 0x000000ff;
1301
pixel |= rgba[i][BCOMP] << 8;
1302
pixel |= rgba[i][GCOMP] << 16;
1303
pixel |= rgba[i][RCOMP] << 24;
1312
/* write all pixels */
1314
GLuint *ptr4 = (GLuint *) ptr;
1315
register GLuint pixel = *ptr4;
1316
int index = (int)(ptr - (GLubyte *)ptr4);
1317
register GLuint i = 0;
1322
pixel &= 0x00ffffff;
1323
pixel |= rgba[i][BCOMP] << 24;
1325
pixel = *ptr4 && 0xffff0000;
1326
pixel |= rgba[i][GCOMP];
1327
pixel |= rgba[i++][RCOMP] << 8;
1332
pixel &= 0x0000ffff;
1333
pixel |= rgba[i][BCOMP] << 16;
1334
pixel |= rgba[i][GCOMP] << 24;
1336
pixel = *ptr4 && 0xffffff00;
1337
pixel |= rgba[i++][RCOMP];
1342
pixel &= 0x000000ff;
1343
pixel |= rgba[i][BCOMP] << 8;
1344
pixel |= rgba[i][GCOMP] << 16;
1345
pixel |= rgba[i++][RCOMP] << 24;
1352
pixel = rgba[i][BCOMP];
1353
pixel |= rgba[i][GCOMP] << 8;
1354
pixel |= rgba[i++][RCOMP] << 16;
1355
pixel |= rgba[i][BCOMP] << 24;
1357
pixel = rgba[i][GCOMP];
1358
pixel |= rgba[i++][RCOMP] << 8;
1359
pixel |= rgba[i][BCOMP] << 16;
1360
pixel |= rgba[i][GCOMP] << 24;
1362
pixel = rgba[i++][RCOMP];
1363
pixel |= rgba[i][BCOMP] << 8;
1364
pixel |= rgba[i][GCOMP] << 16;
1365
pixel |= rgba[i++][RCOMP] << 24;
1373
pixel = *ptr4 & 0xff000000;
1374
pixel |= rgba[i][BCOMP];
1375
pixel |= rgba[i][GCOMP] << 8;
1376
pixel |= rgba[i][RCOMP] << 16;
1380
pixel = rgba[i][BCOMP];
1381
pixel |= rgba[i][GCOMP] << 8;
1382
pixel |= rgba[i++][RCOMP] << 16;
1383
pixel |= rgba[i][BCOMP] << 24;
1385
pixel = *ptr4 & 0xffff0000;
1386
pixel |= rgba[i][GCOMP];
1387
pixel |= rgba[i][RCOMP] << 8;
1391
pixel = rgba[i][BCOMP];
1392
pixel |= rgba[i][GCOMP] << 8;
1393
pixel |= rgba[i++][RCOMP] << 16;
1394
pixel |= rgba[i][BCOMP] << 24;
1396
pixel = rgba[i][GCOMP];
1397
pixel |= rgba[i++][RCOMP] << 8;
1398
pixel |= rgba[i][BCOMP] << 16;
1399
pixel |= rgba[i][GCOMP] << 24;
1401
pixel = *ptr4 & 0xffffff00;
1402
pixel |= rgba[i][RCOMP];
1411
* Write a span of PF_8R8G8B-format pixels to an ximage (no alpha).
1413
static void write_span_rgb_8R8G8B_ximage( RGB_SPAN_ARGS )
1415
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1417
register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
1421
ptr[i] = PACK_8R8G8B(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
1426
/* draw all pixels */
1428
ptr[i] = PACK_8R8G8B(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
1435
* Write a span of PF_8R8G8B24-format pixels to an ximage (no alpha).
1437
static void write_span_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS )
1439
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1441
register GLubyte *ptr = (GLubyte *) PIXELADDR3( xmesa->xm_buffer, x, y );
1445
*ptr++ = rgb[i][BCOMP];
1446
*ptr++ = rgb[i][GCOMP];
1447
*ptr++ = rgb[i][RCOMP];
1455
/* draw all pixels */
1457
*ptr++ = rgb[i][BCOMP];
1458
*ptr++ = rgb[i][GCOMP];
1459
*ptr++ = rgb[i][RCOMP];
1466
* Write a span of PF_5R6G5B-format pixels to an ximage.
1468
static void write_span_5R6G5B_ximage( RGBA_SPAN_ARGS )
1470
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1472
register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
1476
ptr[i] = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
1481
/* draw all pixels */
1482
#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1483
GLuint *ptr32 = (GLuint *) ptr;
1484
GLuint extraPixel = (n & 1);
1486
for (i = 0; i < n; i += 2) {
1488
p0 = PACK_5R6G5B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
1489
p1 = PACK_5R6G5B(rgba[i+1][RCOMP], rgba[i+1][GCOMP], rgba[i+1][BCOMP]);
1490
*ptr32++ = (p1 << 16) | p0;
1493
ptr[n] = PACK_5R6G5B(rgba[n][RCOMP], rgba[n][GCOMP], rgba[n][BCOMP]);
1496
for (i = 0; i < n; i++) {
1497
ptr[i] = PACK_5R6G5B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
1505
* Write a span of PF_DITHER_5R6G5B-format pixels to an ximage.
1507
static void write_span_DITHER_5R6G5B_ximage( RGBA_SPAN_ARGS )
1509
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1511
register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
1512
const GLint y2 = FLIP(xmesa->xm_buffer, y);
1514
for (i=0;i<n;i++,x++) {
1516
PACK_TRUEDITHER( ptr[i], x, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
1521
/* draw all pixels */
1522
#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1523
GLuint *ptr32 = (GLuint *) ptr;
1524
GLuint extraPixel = (n & 1);
1526
for (i = 0; i < n; i += 2, x += 2) {
1528
PACK_TRUEDITHER( p0, x, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
1529
PACK_TRUEDITHER( p1, x+1, y2, rgba[i+1][RCOMP], rgba[i+1][GCOMP], rgba[i+1][BCOMP] );
1530
*ptr32++ = (p1 << 16) | p0;
1533
PACK_TRUEDITHER( ptr[n], x+n, y2, rgba[n][RCOMP], rgba[n][GCOMP], rgba[n][BCOMP]);
1536
for (i = 0; i < n; i++, x++) {
1537
PACK_TRUEDITHER( ptr[i], x, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
1545
* Write a span of PF_5R6G5B-format pixels to an ximage (no alpha).
1547
static void write_span_rgb_5R6G5B_ximage( RGB_SPAN_ARGS )
1549
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1551
register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
1555
ptr[i] = PACK_5R6G5B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
1560
/* draw all pixels */
1561
#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1562
GLuint *ptr32 = (GLuint *) ptr;
1563
GLuint extraPixel = (n & 1);
1565
for (i = 0; i < n; i += 2) {
1567
p0 = PACK_5R6G5B(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
1568
p1 = PACK_5R6G5B(rgb[i+1][RCOMP], rgb[i+1][GCOMP], rgb[i+1][BCOMP]);
1569
*ptr32++ = (p1 << 16) | p0;
1572
ptr[n] = PACK_5R6G5B(rgb[n][RCOMP], rgb[n][GCOMP], rgb[n][BCOMP]);
1576
ptr[i] = PACK_5R6G5B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
1584
* Write a span of PF_DITHER_5R6G5B-format pixels to an ximage (no alpha).
1586
static void write_span_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS )
1588
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1590
register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
1592
for (i=0;i<n;i++,x++) {
1594
PACK_TRUEDITHER( ptr[i], x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
1599
/* draw all pixels */
1600
#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1601
GLuint *ptr32 = (GLuint *) ptr;
1602
GLuint extraPixel = (n & 1);
1604
for (i = 0; i < n; i += 2, x += 2) {
1606
PACK_TRUEDITHER( p0, x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
1607
PACK_TRUEDITHER( p1, x+1, y, rgb[i+1][RCOMP], rgb[i+1][GCOMP], rgb[i+1][BCOMP] );
1608
*ptr32++ = (p1 << 16) | p0;
1611
PACK_TRUEDITHER( ptr[n], x+n, y, rgb[n][RCOMP], rgb[n][GCOMP], rgb[n][BCOMP]);
1614
for (i=0;i<n;i++,x++) {
1615
PACK_TRUEDITHER( ptr[i], x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
1623
* Write a span of PF_DITHER pixels to an XImage.
1625
static void write_span_DITHER_ximage( RGBA_SPAN_ARGS )
1627
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1628
XMesaImage *img = xmesa->xm_buffer->backimage;
1630
int yy = FLIP(xmesa->xm_buffer, y);
1633
for (i=0;i<n;i++,x++) {
1635
XMesaPutPixel( img, x, yy, XDITHER( x, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
1640
/* draw all pixels */
1641
for (i=0;i<n;i++,x++) {
1642
XMesaPutPixel( img, x, yy, XDITHER( x, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
1649
* Write a span of PF_DITHER pixels to an XImage (no alpha).
1651
static void write_span_rgb_DITHER_ximage( RGB_SPAN_ARGS )
1653
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1654
XMesaImage *img = xmesa->xm_buffer->backimage;
1656
int yy = FLIP(xmesa->xm_buffer, y);
1659
for (i=0;i<n;i++,x++) {
1661
XMesaPutPixel( img, x, yy, XDITHER( x, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
1666
/* draw all pixels */
1667
for (i=0;i<n;i++,x++) {
1668
XMesaPutPixel( img, x, yy, XDITHER( x, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
1676
* Write a span of 8-bit PF_DITHER pixels to an XImage.
1678
static void write_span_DITHER8_ximage( RGBA_SPAN_ARGS )
1680
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1682
register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
1685
for (i=0;i<n;i++,x++) {
1687
ptr[i] = (GLubyte) XDITHER( x, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
1692
for (i=0;i<n;i++,x++) {
1693
ptr[i] = (GLubyte) XDITHER( x, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
1699
static void write_span_rgb_DITHER8_ximage( RGB_SPAN_ARGS )
1701
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1703
register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
1706
for (i=0;i<n;i++,x++) {
1708
ptr[i] = (GLubyte) XDITHER( x, rgb[i][0], rgb[i][1], rgb[i][2] );
1713
const GLubyte *data = (GLubyte *) rgb;
1714
for (i=0;i<n;i++,x++) {
1715
/*ptr[i] = XDITHER( x, rgb[i][0], rgb[i][1], rgb[i][2] );*/
1716
ptr[i] = (GLubyte) XDITHER( x, data[i+i+i], data[i+i+i+1], data[i+i+i+2] );
1724
* Write a span of PF_1BIT pixels to an XImage.
1726
static void write_span_1BIT_ximage( RGBA_SPAN_ARGS )
1728
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1729
XMesaImage *img = xmesa->xm_buffer->backimage;
1732
y = FLIP(xmesa->xm_buffer, y);
1734
for (i=0;i<n;i++,x++) {
1736
XMesaPutPixel(img, x, y, DITHER_1BIT(x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]));
1741
for (i=0;i<n;i++,x++) {
1742
XMesaPutPixel( img, x, y, DITHER_1BIT(x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
1749
* Write a span of PF_1BIT pixels to an XImage (no alpha).
1751
static void write_span_rgb_1BIT_ximage( RGB_SPAN_ARGS )
1753
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1754
XMesaImage *img = xmesa->xm_buffer->backimage;
1757
y = FLIP(xmesa->xm_buffer, y);
1759
for (i=0;i<n;i++,x++) {
1761
XMesaPutPixel(img, x, y, DITHER_1BIT(x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]));
1766
for (i=0;i<n;i++,x++) {
1767
XMesaPutPixel( img, x, y, DITHER_1BIT(x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
1774
* Write a span of PF_HPCR pixels to an XImage.
1776
static void write_span_HPCR_ximage( RGBA_SPAN_ARGS )
1778
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1780
register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
1782
for (i=0;i<n;i++,x++) {
1784
ptr[i] = DITHER_HPCR( x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
1789
/* draw all pixels */
1790
for (i=0;i<n;i++,x++) {
1791
ptr[i] = DITHER_HPCR( x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
1798
* Write a span of PF_HPCR pixels to an XImage (no alpha).
1800
static void write_span_rgb_HPCR_ximage( RGB_SPAN_ARGS )
1802
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1804
register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
1806
for (i=0;i<n;i++,x++) {
1808
ptr[i] = DITHER_HPCR( x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
1813
/* draw all pixels */
1814
for (i=0;i<n;i++,x++) {
1815
ptr[i] = DITHER_HPCR( x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
1822
* Write a span of PF_LOOKUP pixels to an XImage.
1824
static void write_span_LOOKUP_ximage( RGBA_SPAN_ARGS )
1826
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1827
XMesaImage *img = xmesa->xm_buffer->backimage;
1830
y = FLIP(xmesa->xm_buffer, y);
1832
for (i=0;i<n;i++,x++) {
1834
XMesaPutPixel( img, x, y, LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
1839
/* draw all pixels */
1840
for (i=0;i<n;i++,x++) {
1841
XMesaPutPixel( img, x, y, LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
1848
* Write a span of PF_LOOKUP pixels to an XImage (no alpha).
1850
static void write_span_rgb_LOOKUP_ximage( RGB_SPAN_ARGS )
1852
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1853
XMesaImage *img = xmesa->xm_buffer->backimage;
1856
y = FLIP(xmesa->xm_buffer, y);
1858
for (i=0;i<n;i++,x++) {
1860
XMesaPutPixel( img, x, y, LOOKUP( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
1865
/* draw all pixels */
1866
for (i=0;i<n;i++,x++) {
1867
XMesaPutPixel( img, x, y, LOOKUP( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
1874
* Write a span of 8-bit PF_LOOKUP pixels to an XImage.
1876
static void write_span_LOOKUP8_ximage( RGBA_SPAN_ARGS )
1878
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1880
register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
1883
for (i=0;i<n;i++,x++) {
1885
ptr[i] = (GLubyte) LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
1890
/* draw all pixels */
1891
for (i=0;i<n;i++,x++) {
1892
ptr[i] = (GLubyte) LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
1898
static void write_rgb_LOOKUP8_ximage( const GLcontext *ctx,
1899
GLuint n, GLint x, GLint y,
1900
CONST GLubyte rgb[][3],
1901
const GLubyte mask[] )
1903
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1905
register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
1908
for (i=0;i<n;i++,x++) {
1910
ptr[i] = (GLubyte) LOOKUP( rgb[i][0], rgb[i][1], rgb[i][2] );
1915
/* draw all pixels */
1916
const GLubyte *data = (GLubyte *) rgb;
1917
for (i=0;i<n;i++,x++) {
1918
/*ptr[i] = LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );*/
1919
ptr[i] = (GLubyte) LOOKUP( data[i+i+i], data[i+i+i+1], data[i+i+i+2] );
1926
* Write a span of PF_GRAYSCALE pixels to an XImage.
1928
static void write_span_GRAYSCALE_ximage( RGBA_SPAN_ARGS )
1930
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1931
XMesaImage *img = xmesa->xm_buffer->backimage;
1933
y = FLIP(xmesa->xm_buffer, y);
1935
for (i=0;i<n;i++,x++) {
1937
XMesaPutPixel( img, x, y, GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
1942
/* draw all pixels */
1943
for (i=0;i<n;i++,x++) {
1944
XMesaPutPixel( img, x, y, GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
1951
* Write a span of PF_GRAYSCALE pixels to an XImage (no alpha).
1953
static void write_span_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS )
1955
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1956
XMesaImage *img = xmesa->xm_buffer->backimage;
1958
y = FLIP(xmesa->xm_buffer, y);
1960
for (i=0;i<n;i++,x++) {
1962
XMesaPutPixel( img, x, y, GRAY_RGB( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
1967
/* draw all pixels */
1968
for (i=0;i<n;i++,x++) {
1969
XMesaPutPixel( img, x, y, GRAY_RGB( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
1976
* Write a span of 8-bit PF_GRAYSCALE pixels to an XImage.
1978
static void write_span_GRAYSCALE8_ximage( RGBA_SPAN_ARGS )
1980
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1982
register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
1986
ptr[i] = (GLubyte) GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
1991
/* draw all pixels */
1993
ptr[i] = (GLubyte) GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
2000
* Write a span of 8-bit PF_GRAYSCALE pixels to an XImage (no alpha).
2002
static void write_span_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS )
2004
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2006
register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
2010
ptr[i] = (GLubyte) GRAY_RGB( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
2015
/* draw all pixels */
2017
ptr[i] = (GLubyte) GRAY_RGB( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
2025
/**********************************************************************/
2026
/*** Write COLOR PIXEL functions ***/
2027
/**********************************************************************/
2030
#define RGBA_PIXEL_ARGS const GLcontext *ctx, \
2031
GLuint n, const GLint x[], const GLint y[], \
2032
CONST GLubyte rgba[][4], const GLubyte mask[]
2036
* Write an array of PF_TRUECOLOR pixels to a pixmap.
2038
static void write_pixels_TRUECOLOR_pixmap( RGBA_PIXEL_ARGS )
2040
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2041
XMesaDisplay *dpy = xmesa->xm_visual->display;
2042
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2043
XMesaGC gc = xmesa->xm_buffer->gc;
2048
PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
2049
XMesaSetForeground( dpy, gc, p );
2050
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2057
* Write an array of PF_TRUEDITHER pixels to a pixmap.
2059
static void write_pixels_TRUEDITHER_pixmap( RGBA_PIXEL_ARGS )
2061
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2062
XMesaDisplay *dpy = xmesa->xm_visual->display;
2063
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2064
XMesaGC gc = xmesa->xm_buffer->gc;
2069
PACK_TRUEDITHER(p, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
2070
XMesaSetForeground( dpy, gc, p );
2071
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2078
* Write an array of PF_8A8B8G8R pixels to a pixmap.
2080
static void write_pixels_8A8B8G8R_pixmap( RGBA_PIXEL_ARGS )
2082
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2083
XMesaDisplay *dpy = xmesa->xm_visual->display;
2084
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2085
XMesaGC gc = xmesa->xm_buffer->gc;
2089
XMesaSetForeground( dpy, gc,
2090
PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] ));
2091
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2098
* Write an array of PF_8R8G8B pixels to a pixmap.
2100
static void write_pixels_8R8G8B_pixmap( RGBA_PIXEL_ARGS )
2102
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2103
XMesaDisplay *dpy = xmesa->xm_visual->display;
2104
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2105
XMesaGC gc = xmesa->xm_buffer->gc;
2109
XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
2110
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2117
* Write an array of PF_8R8G8B24 pixels to a pixmap.
2119
static void write_pixels_8R8G8B24_pixmap( RGBA_PIXEL_ARGS )
2121
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2122
XMesaDisplay *dpy = xmesa->xm_visual->display;
2123
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2124
XMesaGC gc = xmesa->xm_buffer->gc;
2128
XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
2129
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2136
* Write an array of PF_5R6G5B pixels to a pixmap.
2138
static void write_pixels_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
2140
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2141
XMesaDisplay *dpy = xmesa->xm_visual->display;
2142
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2143
XMesaGC gc = xmesa->xm_buffer->gc;
2147
XMesaSetForeground( dpy, gc, PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
2148
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2155
* Write an array of PF_DITHER_5R6G5B pixels to a pixmap.
2157
static void write_pixels_DITHER_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
2159
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2160
XMesaDisplay *dpy = xmesa->xm_visual->display;
2161
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2162
XMesaGC gc = xmesa->xm_buffer->gc;
2167
PACK_TRUEDITHER(p, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
2168
XMesaSetForeground( dpy, gc, p );
2169
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2176
* Write an array of PF_DITHER pixels to a pixmap.
2178
static void write_pixels_DITHER_pixmap( RGBA_PIXEL_ARGS )
2180
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2181
XMesaDisplay *dpy = xmesa->xm_visual->display;
2182
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2183
XMesaGC gc = xmesa->xm_buffer->gc;
2188
XMesaSetForeground( dpy, gc,
2189
DITHER(x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
2190
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2197
* Write an array of PF_1BIT pixels to a pixmap.
2199
static void write_pixels_1BIT_pixmap( RGBA_PIXEL_ARGS )
2201
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2202
XMesaDisplay *dpy = xmesa->xm_visual->display;
2203
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2204
XMesaGC gc = xmesa->xm_buffer->gc;
2209
XMesaSetForeground( dpy, gc,
2210
DITHER_1BIT( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
2211
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2218
* Write an array of PF_HPCR pixels to a pixmap.
2220
static void write_pixels_HPCR_pixmap( RGBA_PIXEL_ARGS )
2222
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2223
XMesaDisplay *dpy = xmesa->xm_visual->display;
2224
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2225
XMesaGC gc = xmesa->xm_buffer->gc;
2229
XMesaSetForeground( dpy, gc,
2230
DITHER_HPCR( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
2231
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2238
* Write an array of PF_LOOKUP pixels to a pixmap.
2240
static void write_pixels_LOOKUP_pixmap( RGBA_PIXEL_ARGS )
2242
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2243
XMesaDisplay *dpy = xmesa->xm_visual->display;
2244
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2245
XMesaGC gc = xmesa->xm_buffer->gc;
2250
XMesaSetForeground( dpy, gc, LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
2251
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2258
* Write an array of PF_GRAYSCALE pixels to a pixmap.
2260
static void write_pixels_GRAYSCALE_pixmap( RGBA_PIXEL_ARGS )
2262
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2263
XMesaDisplay *dpy = xmesa->xm_visual->display;
2264
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2265
XMesaGC gc = xmesa->xm_buffer->gc;
2269
XMesaSetForeground( dpy, gc, GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
2270
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2277
* Write an array of PF_TRUECOLOR pixels to an ximage.
2279
static void write_pixels_TRUECOLOR_ximage( RGBA_PIXEL_ARGS )
2281
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2282
XMesaImage *img = xmesa->xm_buffer->backimage;
2287
PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
2288
XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), p );
2295
* Write an array of PF_TRUEDITHER pixels to an XImage.
2297
static void write_pixels_TRUEDITHER_ximage( RGBA_PIXEL_ARGS )
2299
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2300
XMesaImage *img = xmesa->xm_buffer->backimage;
2305
PACK_TRUEDITHER(p, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
2306
XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), p );
2313
* Write an array of PF_8A8B8G8R pixels to an ximage.
2315
static void write_pixels_8A8B8G8R_ximage( RGBA_PIXEL_ARGS )
2317
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2321
GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
2322
*ptr = PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
2329
* Write an array of PF_8R8G8B pixels to an ximage.
2331
static void write_pixels_8R8G8B_ximage( RGBA_PIXEL_ARGS )
2333
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2337
GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
2338
*ptr = PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
2345
* Write an array of PF_8R8G8B24 pixels to an ximage.
2347
static void write_pixels_8R8G8B24_ximage( RGBA_PIXEL_ARGS )
2349
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2353
bgr_t *ptr = PIXELADDR3( xmesa->xm_buffer, x[i], y[i] );
2354
ptr->r = rgba[i][RCOMP];
2355
ptr->g = rgba[i][GCOMP];
2356
ptr->b = rgba[i][BCOMP];
2363
* Write an array of PF_5R6G5B pixels to an ximage.
2365
static void write_pixels_5R6G5B_ximage( RGBA_PIXEL_ARGS )
2367
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2371
GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x[i], y[i] );
2372
*ptr = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
2379
* Write an array of PF_DITHER_5R6G5B pixels to an ximage.
2381
static void write_pixels_DITHER_5R6G5B_ximage( RGBA_PIXEL_ARGS )
2383
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2387
GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x[i], y[i] );
2388
PACK_TRUEDITHER( *ptr, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
2395
* Write an array of PF_DITHER pixels to an XImage.
2397
static void write_pixels_DITHER_ximage( RGBA_PIXEL_ARGS )
2399
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2400
XMesaImage *img = xmesa->xm_buffer->backimage;
2405
XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]),
2406
DITHER( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
2413
* Write an array of 8-bit PF_DITHER pixels to an XImage.
2415
static void write_pixels_DITHER8_ximage( RGBA_PIXEL_ARGS )
2417
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2422
GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
2423
*ptr = (GLubyte) DITHER( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
2430
* Write an array of PF_1BIT pixels to an XImage.
2432
static void write_pixels_1BIT_ximage( RGBA_PIXEL_ARGS )
2434
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2435
XMesaImage *img = xmesa->xm_buffer->backimage;
2440
XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]),
2441
DITHER_1BIT( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
2448
* Write an array of PF_HPCR pixels to an XImage.
2450
static void write_pixels_HPCR_ximage( RGBA_PIXEL_ARGS )
2452
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2456
GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
2457
*ptr = (GLubyte) DITHER_HPCR( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
2464
* Write an array of PF_LOOKUP pixels to an XImage.
2466
static void write_pixels_LOOKUP_ximage( RGBA_PIXEL_ARGS )
2468
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2469
XMesaImage *img = xmesa->xm_buffer->backimage;
2474
XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), LOOKUP(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
2481
* Write an array of 8-bit PF_LOOKUP pixels to an XImage.
2483
static void write_pixels_LOOKUP8_ximage( RGBA_PIXEL_ARGS )
2485
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2490
GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
2491
*ptr = (GLubyte) LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
2498
* Write an array of PF_GRAYSCALE pixels to an XImage.
2500
static void write_pixels_GRAYSCALE_ximage( RGBA_PIXEL_ARGS )
2502
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2503
XMesaImage *img = xmesa->xm_buffer->backimage;
2507
XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]),
2508
GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
2515
* Write an array of 8-bit PF_GRAYSCALE pixels to an XImage.
2517
static void write_pixels_GRAYSCALE8_ximage( RGBA_PIXEL_ARGS )
2519
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2523
GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x[i], y[i] );
2524
*ptr = (GLubyte) GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
2532
/**********************************************************************/
2533
/*** Write MONO COLOR SPAN functions ***/
2534
/**********************************************************************/
2536
#define MONO_SPAN_ARGS const GLcontext *ctx, \
2537
GLuint n, GLint x, GLint y, const GLchan color[4], \
2538
const GLubyte mask[]
2542
* Write a span of identical pixels to a pixmap.
2544
static void write_span_mono_pixmap( MONO_SPAN_ARGS )
2546
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2547
XMesaDisplay *dpy = xmesa->xm_visual->display;
2548
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2549
XMesaGC gc = xmesa->xm_buffer->gc;
2550
const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
2551
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
2553
XMesaSetForeground( xmesa->display, gc, pixel );
2554
y = FLIP(xmesa->xm_buffer, y);
2556
/* New code contributed by Jeff Epler and cleaned up by Keith
2559
for (i = 0; i < n; ) {
2562
/* Identify and emit contiguous rendered pixels
2564
while (i < n && mask[i])
2568
XMesaFillRectangle( dpy, buffer, gc,
2569
(int)(x+start), (int) y,
2572
/* Eat up non-rendered pixels
2574
while (i < n && !mask[i])
2581
static void write_span_mono_index_pixmap( const GLcontext *ctx, GLuint n,
2582
GLint x, GLint y, GLuint colorIndex,
2583
const GLubyte mask[] )
2585
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2586
XMesaDisplay *dpy = xmesa->xm_visual->display;
2587
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2588
XMesaGC gc = xmesa->xm_buffer->gc;
2590
XMesaSetForeground( xmesa->display, gc, colorIndex );
2591
y = FLIP(xmesa->xm_buffer, y);
2593
for (i = 0 ; i < n ;) {
2596
/* Identify and emit contiguous rendered pixels
2598
while (i < n && mask[i])
2602
XMesaFillRectangle( dpy, buffer, gc,
2603
(int)(x+start), (int) y,
2606
/* Eat up non-rendered pixels
2608
while (i < n && !mask[i])
2616
* Write a span of PF_TRUEDITHER pixels to a pixmap.
2618
static void write_span_mono_TRUEDITHER_pixmap( MONO_SPAN_ARGS )
2620
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2621
XMesaDisplay *dpy = xmesa->xm_visual->display;
2622
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2623
XMesaGC gc = xmesa->xm_buffer->gc;
2624
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
2626
int yy = FLIP(xmesa->xm_buffer, y);
2627
for (i=0;i<n;i++,x++) {
2630
PACK_TRUEDITHER(p, x, yy, r, g, b);
2631
XMesaSetForeground( dpy, gc, p );
2632
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) yy );
2639
* Write a span of PF_DITHER pixels to a pixmap.
2641
static void write_span_mono_DITHER_pixmap( MONO_SPAN_ARGS )
2643
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2644
XMesaDisplay *dpy = xmesa->xm_visual->display;
2645
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2646
XMesaGC gc = xmesa->xm_buffer->gc;
2647
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
2649
int yy = FLIP(xmesa->xm_buffer, y);
2651
for (i=0;i<n;i++,x++) {
2653
XMesaSetForeground( dpy, gc, XDITHER( x, r, g, b ) );
2654
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) yy );
2661
* Write a span of PF_1BIT pixels to a pixmap.
2663
static void write_span_mono_1BIT_pixmap( MONO_SPAN_ARGS )
2665
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2666
XMesaDisplay *dpy = xmesa->xm_visual->display;
2667
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2668
XMesaGC gc = xmesa->xm_buffer->gc;
2669
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
2672
y = FLIP(xmesa->xm_buffer, y);
2673
for (i=0;i<n;i++,x++) {
2675
XMesaSetForeground( dpy, gc, DITHER_1BIT( x, y, r, g, b ) );
2676
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
2683
* Write a span of identical pixels to an XImage.
2685
static void write_span_mono_ximage( MONO_SPAN_ARGS )
2687
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2688
XMesaImage *img = xmesa->xm_buffer->backimage;
2690
const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
2691
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
2692
y = FLIP(xmesa->xm_buffer, y);
2693
for (i=0;i<n;i++,x++) {
2695
XMesaPutPixel( img, x, y, pixel );
2701
static void write_span_mono_index_ximage( const GLcontext *ctx, GLuint n,
2704
const GLubyte mask[] )
2706
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2707
XMesaImage *img = xmesa->xm_buffer->backimage;
2709
y = FLIP(xmesa->xm_buffer, y);
2710
for (i=0;i<n;i++,x++) {
2712
XMesaPutPixel( img, x, y, colorIndex );
2719
* Write a span of identical PF_TRUEDITHER pixels to an XImage.
2721
static void write_span_mono_TRUEDITHER_ximage( MONO_SPAN_ARGS )
2723
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2724
XMesaImage *img = xmesa->xm_buffer->backimage;
2725
const GLint r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
2727
y = FLIP(xmesa->xm_buffer, y);
2731
PACK_TRUEDITHER( p, x+i, y, r, g, b);
2732
XMesaPutPixel( img, x+i, y, p );
2739
* Write a span of identical 8A8B8G8R pixels to an XImage.
2741
static void write_span_mono_8A8B8G8R_ximage( MONO_SPAN_ARGS )
2743
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2745
const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
2746
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
2747
ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
2757
* Write a span of identical 8R8G8B pixels to an XImage.
2759
static void write_span_mono_8R8G8B_ximage( MONO_SPAN_ARGS )
2761
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2762
const GLuint pixel = PACK_8R8G8B(color[RCOMP], color[GCOMP], color[BCOMP]);
2763
GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
2774
* Write a span of identical 8R8G8B pixels to an XImage.
2776
static void write_span_mono_8R8G8B24_ximage( MONO_SPAN_ARGS )
2778
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2779
const GLubyte r = color[RCOMP];
2780
const GLubyte g = color[GCOMP];
2781
const GLubyte b = color[BCOMP];
2783
bgr_t *ptr = PIXELADDR3( xmesa->xm_buffer, x, y );
2795
* Write a span of identical DITHER pixels to an XImage.
2797
static void write_span_mono_DITHER_ximage( MONO_SPAN_ARGS )
2799
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2800
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
2801
XMesaImage *img = xmesa->xm_buffer->backimage;
2802
int yy = FLIP(xmesa->xm_buffer, y);
2805
for (i=0;i<n;i++,x++) {
2807
XMesaPutPixel( img, x, yy, XDITHER( x, r, g, b ) );
2814
* Write a span of identical 8-bit DITHER pixels to an XImage.
2816
static void write_span_mono_DITHER8_ximage( MONO_SPAN_ARGS )
2818
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2819
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
2820
register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x,y);
2823
for (i=0;i<n;i++,x++) {
2825
ptr[i] = (GLubyte) XDITHER( x, r, g, b );
2832
* Write a span of identical 8-bit LOOKUP pixels to an XImage.
2834
static void write_span_mono_LOOKUP8_ximage( MONO_SPAN_ARGS )
2836
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2838
register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x,y);
2841
pixel = LOOKUP(color[RCOMP], color[GCOMP], color[BCOMP]);
2851
* Write a span of identical PF_1BIT pixels to an XImage.
2853
static void write_span_mono_1BIT_ximage( MONO_SPAN_ARGS )
2855
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2856
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
2857
XMesaImage *img = xmesa->xm_buffer->backimage;
2860
y = FLIP(xmesa->xm_buffer, y);
2861
for (i=0;i<n;i++,x++) {
2863
XMesaPutPixel( img, x, y, DITHER_1BIT( x, y, r, g, b ) );
2870
* Write a span of identical HPCR pixels to an XImage.
2872
static void write_span_mono_HPCR_ximage( MONO_SPAN_ARGS )
2874
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2875
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
2876
register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x,y);
2878
for (i=0;i<n;i++,x++) {
2880
ptr[i] = DITHER_HPCR( x, y, r, g, b );
2887
* Write a span of identical 8-bit GRAYSCALE pixels to an XImage.
2889
static void write_span_mono_GRAYSCALE8_ximage( MONO_SPAN_ARGS )
2891
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2892
const GLubyte p = GRAY_RGB(color[RCOMP], color[GCOMP], color[BCOMP]);
2893
GLubyte *ptr = (GLubyte *) PIXELADDR1( xmesa->xm_buffer,x,y);
2905
* Write a span of identical PF_DITHER_5R6G5B pixels to an XImage.
2907
static void write_span_mono_DITHER_5R6G5B_ximage( MONO_SPAN_ARGS )
2909
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2910
register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
2911
const GLint r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
2913
y = FLIP(xmesa->xm_buffer, y);
2916
PACK_TRUEDITHER(ptr[i], x+i, y, r, g, b);
2923
/**********************************************************************/
2924
/*** Write MONO COLOR PIXELS functions ***/
2925
/**********************************************************************/
2927
#define MONO_PIXEL_ARGS const GLcontext *ctx, \
2928
GLuint n, const GLint x[], const GLint y[], \
2929
const GLchan color[4], const GLubyte mask[]
2932
* Write an array of identical pixels to a pixmap.
2934
static void write_pixels_mono_pixmap( MONO_PIXEL_ARGS )
2936
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2937
XMesaDisplay *dpy = xmesa->xm_visual->display;
2938
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2939
XMesaGC gc = xmesa->xm_buffer->gc;
2941
const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
2942
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
2943
XMesaSetForeground( xmesa->display, gc, pixel );
2946
XMesaDrawPoint( dpy, buffer, gc,
2947
(int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2953
static void write_pixels_mono_index_pixmap(const GLcontext *ctx,
2955
const GLint x[], const GLint y[],
2957
const GLubyte mask[] )
2959
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2960
XMesaDisplay *dpy = xmesa->xm_visual->display;
2961
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2962
XMesaGC gc = xmesa->xm_buffer->gc;
2964
XMesaSetForeground( xmesa->display, gc, colorIndex );
2967
XMesaDrawPoint( dpy, buffer, gc,
2968
(int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2975
* Write an array of PF_TRUEDITHER pixels to a pixmap.
2977
static void write_pixels_mono_TRUEDITHER_pixmap( MONO_PIXEL_ARGS )
2979
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
2980
XMesaDisplay *dpy = xmesa->xm_visual->display;
2981
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
2982
XMesaGC gc = xmesa->xm_buffer->gc;
2984
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
2988
PACK_TRUEDITHER(p, x[i], y[i], r, g, b);
2989
XMesaSetForeground( dpy, gc, p );
2990
XMesaDrawPoint( dpy, buffer, gc,
2991
(int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
2998
* Write an array of PF_DITHER pixels to a pixmap.
3000
static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS )
3002
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3003
XMesaDisplay *dpy = xmesa->xm_visual->display;
3004
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
3005
XMesaGC gc = xmesa->xm_buffer->gc;
3007
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
3011
XMesaSetForeground( dpy, gc, DITHER( x[i], y[i], r, g, b ) );
3012
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
3019
* Write an array of PF_1BIT pixels to a pixmap.
3021
static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS )
3023
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3024
XMesaDisplay *dpy = xmesa->xm_visual->display;
3025
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
3026
XMesaGC gc = xmesa->xm_buffer->gc;
3028
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
3032
XMesaSetForeground( dpy, gc, DITHER_1BIT( x[i], y[i], r, g, b ) );
3033
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
3040
* Write an array of identical pixels to an XImage.
3042
static void write_pixels_mono_ximage( MONO_PIXEL_ARGS )
3044
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3045
XMesaImage *img = xmesa->xm_buffer->backimage;
3047
const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
3048
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
3051
XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), pixel );
3057
static void write_pixels_mono_index_ximage( const GLcontext *ctx, GLuint n,
3058
const GLint x[], const GLint y[],
3060
const GLubyte mask[] )
3062
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3063
XMesaImage *img = xmesa->xm_buffer->backimage;
3067
XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), colorIndex );
3074
* Write an array of identical TRUEDITHER pixels to an XImage.
3076
static void write_pixels_mono_TRUEDITHER_ximage( MONO_PIXEL_ARGS )
3078
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3079
XMesaImage *img = xmesa->xm_buffer->backimage;
3081
const int r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
3085
PACK_TRUEDITHER(p, x[i], FLIP(xmesa->xm_buffer, y[i]), r, g, b);
3086
XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), p );
3094
* Write an array of identical 8A8B8G8R pixels to an XImage
3096
static void write_pixels_mono_8A8B8G8R_ximage( MONO_PIXEL_ARGS )
3098
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3099
const GLuint p = PACK_8A8B8G8R(color[RCOMP], color[GCOMP],
3100
color[BCOMP], color[ACOMP]);
3104
GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
3112
* Write an array of identical 8R8G8B pixels to an XImage.
3114
static void write_pixels_mono_8R8G8B_ximage( MONO_PIXEL_ARGS )
3116
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3118
const GLuint p = PACK_8R8G8B(color[RCOMP], color[GCOMP], color[BCOMP]);
3121
GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
3129
* Write an array of identical 8R8G8B pixels to an XImage.
3131
static void write_pixels_mono_8R8G8B24_ximage( MONO_PIXEL_ARGS )
3133
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3134
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
3138
bgr_t *ptr = PIXELADDR3( xmesa->xm_buffer, x[i], y[i] );
3148
* Write an array of identical PF_DITHER pixels to an XImage.
3150
static void write_pixels_mono_DITHER_ximage( MONO_PIXEL_ARGS )
3152
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3153
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
3154
XMesaImage *img = xmesa->xm_buffer->backimage;
3159
XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), DITHER( x[i], y[i], r, g, b ) );
3166
* Write an array of identical 8-bit PF_DITHER pixels to an XImage.
3168
static void write_pixels_mono_DITHER8_ximage( MONO_PIXEL_ARGS )
3170
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3171
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
3176
GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
3177
*ptr = (GLubyte) DITHER( x[i], y[i], r, g, b );
3184
* Write an array of identical 8-bit PF_LOOKUP pixels to an XImage.
3186
static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS )
3188
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3192
pixel = LOOKUP(color[RCOMP], color[GCOMP], color[BCOMP]);
3195
GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
3204
* Write an array of identical PF_1BIT pixels to an XImage.
3206
static void write_pixels_mono_1BIT_ximage( MONO_PIXEL_ARGS )
3208
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3209
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
3210
XMesaImage *img = xmesa->xm_buffer->backimage;
3215
XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]),
3216
DITHER_1BIT( x[i], y[i], r, g, b ));
3223
* Write an array of identical PF_HPCR pixels to an XImage.
3225
static void write_pixels_mono_HPCR_ximage( MONO_PIXEL_ARGS )
3227
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3228
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
3232
GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
3233
*ptr = DITHER_HPCR( x[i], y[i], r, g, b );
3240
* Write an array of identical 8-bit PF_GRAYSCALE pixels to an XImage.
3242
static void write_pixels_mono_GRAYSCALE8_ximage( MONO_PIXEL_ARGS )
3244
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3246
register GLubyte p = GRAY_RGB(color[RCOMP], color[GCOMP], color[BCOMP]);
3249
GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
3257
* Write an array of identical PF_DITHER_5R6G5B pixels to an XImage.
3259
static void write_pixels_mono_DITHER_5R6G5B_ximage( MONO_PIXEL_ARGS )
3261
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3262
const int r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
3266
GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x[i], y[i] );
3267
PACK_TRUEDITHER(*ptr, x[i], y[i], r, g, b);
3274
/**********************************************************************/
3275
/*** Write INDEX SPAN functions ***/
3276
/**********************************************************************/
3278
#define INDEX_SPAN_ARGS const GLcontext *ctx, \
3279
GLuint n, GLint x, GLint y, const GLuint index[], \
3280
const GLubyte mask[]
3282
#define INDEX8_SPAN_ARGS const GLcontext *ctx, \
3283
GLuint n, GLint x, GLint y, const GLubyte index[], \
3284
const GLubyte mask[]
3288
* Write a span of CI pixels to a Pixmap.
3290
static void write_span_index_pixmap( INDEX_SPAN_ARGS )
3292
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3293
XMesaDisplay *dpy = xmesa->xm_visual->display;
3294
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
3295
XMesaGC gc = xmesa->xm_buffer->gc;
3297
y = FLIP(xmesa->xm_buffer, y);
3299
for (i=0;i<n;i++,x++) {
3301
XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
3302
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
3307
for (i=0;i<n;i++,x++) {
3308
XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
3309
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
3316
* Write a span of 8-bit CI pixels to a Pixmap.
3318
static void write_span_index8_pixmap( INDEX8_SPAN_ARGS )
3320
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3321
XMesaDisplay *dpy = xmesa->xm_visual->display;
3322
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
3323
XMesaGC gc = xmesa->xm_buffer->gc;
3325
y = FLIP(xmesa->xm_buffer, y);
3327
for (i=0;i<n;i++,x++) {
3329
XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
3330
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
3335
for (i=0;i<n;i++,x++) {
3336
XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
3337
XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
3344
* Write a span of CI pixels to an XImage.
3346
static void write_span_index_ximage( INDEX_SPAN_ARGS )
3348
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3349
XMesaImage *img = xmesa->xm_buffer->backimage;
3351
y = FLIP(xmesa->xm_buffer, y);
3353
for (i=0;i<n;i++,x++) {
3355
XMesaPutPixel( img, x, y, (unsigned long) index[i] );
3360
for (i=0;i<n;i++,x++) {
3361
XMesaPutPixel( img, x, y, (unsigned long) index[i] );
3368
* Write a span of 8-bit CI pixels to a non 8-bit XImage.
3370
static void write_span_index8_ximage( const GLcontext *ctx, GLuint n,
3371
GLint x, GLint y, const GLubyte index[],
3372
const GLubyte mask[] )
3374
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3379
XMesaPutPixel(xmesa->xm_buffer->backimage, x+i, y, index[i]);
3386
XMesaPutPixel(xmesa->xm_buffer->backimage, x+i, y, index[i]);
3392
* Write a span of 8-bit CI pixels to an 8-bit XImage.
3394
static void write_span_index8_ximage8( const GLcontext *ctx, GLuint n,
3395
GLint x, GLint y, const GLubyte index[],
3396
const GLubyte mask[] )
3398
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3399
GLubyte *dst = PIXELADDR1( xmesa->xm_buffer,x,y);
3409
MEMCPY( dst, index, n );
3415
/**********************************************************************/
3416
/*** Write INDEX PIXELS functions ***/
3417
/**********************************************************************/
3419
#define INDEX_PIXELS_ARGS const GLcontext *ctx, \
3420
GLuint n, const GLint x[], const GLint y[], \
3421
const GLuint index[], const GLubyte mask[]
3425
* Write an array of CI pixels to a Pixmap.
3427
static void write_pixels_index_pixmap( INDEX_PIXELS_ARGS )
3429
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3430
XMesaDisplay *dpy = xmesa->xm_visual->display;
3431
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
3432
XMesaGC gc = xmesa->xm_buffer->gc;
3436
XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
3437
XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
3444
* Write an array of CI pixels to an XImage.
3446
static void write_pixels_index_ximage( INDEX_PIXELS_ARGS )
3448
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3449
XMesaImage *img = xmesa->xm_buffer->backimage;
3453
XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), (unsigned long) index[i] );
3461
/**********************************************************************/
3462
/***** Pixel reading *****/
3463
/**********************************************************************/
3468
* Read a horizontal span of color-index pixels.
3470
static void read_index_span( const GLcontext *ctx,
3471
GLuint n, GLint x, GLint y, GLuint index[] )
3473
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3477
if (xmesa->use_read_buffer)
3478
source = xmesa->xm_read_buffer;
3480
source = xmesa->xm_buffer;
3482
y = FLIP(source, y);
3484
if (source->buffer) {
3485
#ifndef XFree86Server
3486
XMesaImage *span = NULL;
3488
catch_xgetimage_errors( xmesa->display );
3489
span = XGetImage( xmesa->display, source->buffer,
3490
x, y, n, 1, AllPlanes, ZPixmap );
3491
error = check_xgetimage_errors();
3492
if (span && !error) {
3494
index[i] = (GLuint) XMesaGetPixel( span, i, 0 );
3498
/* return 0 pixels */
3504
XMesaDestroyImage( span );
3507
(*xmesa->display->GetImage)(source->buffer,
3508
x, y, n, 1, ZPixmap,
3509
~0L, (pointer)index);
3512
else if (source->backimage) {
3513
XMesaImage *img = source->backimage;
3514
for (i=0;i<n;i++,x++) {
3515
index[i] = (GLuint) XMesaGetPixel( img, x, y );
3523
* Read a horizontal span of color pixels.
3525
static void read_color_span( const GLcontext *ctx,
3526
GLuint n, GLint x, GLint y,
3529
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3532
if (xmesa->use_read_buffer)
3533
source = xmesa->xm_read_buffer;
3535
source = xmesa->xm_buffer;
3537
if (source->buffer) {
3538
/* Read from Pixmap or Window */
3539
XMesaImage *span = NULL;
3541
#ifdef XFree86Server
3542
span = XMesaCreateImage(xmesa->xm_visual->BitsPerPixel, n, 1, NULL);
3543
span->data = (char *)MALLOC(span->height * span->bytes_per_line);
3544
error = (!span->data);
3545
(*xmesa->display->GetImage)(source->buffer,
3546
x, FLIP(source, y), n, 1, ZPixmap,
3547
~0L, (pointer)span->data);
3549
catch_xgetimage_errors( xmesa->display );
3550
span = XGetImage( xmesa->display, source->buffer,
3551
x, FLIP(source, y), n, 1, AllPlanes, ZPixmap );
3552
error = check_xgetimage_errors();
3554
if (span && !error) {
3555
switch (xmesa->pixelformat) {
3559
const GLubyte *pixelToR = xmesa->xm_visual->PixelToR;
3560
const GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
3561
const GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
3562
unsigned long rMask = GET_REDMASK(xmesa->xm_visual);
3563
unsigned long gMask = GET_GREENMASK(xmesa->xm_visual);
3564
unsigned long bMask = GET_BLUEMASK(xmesa->xm_visual);
3565
GLint rShift = xmesa->xm_visual->rshift;
3566
GLint gShift = xmesa->xm_visual->gshift;
3567
GLint bShift = xmesa->xm_visual->bshift;
3571
p = XMesaGetPixel( span, i, 0 );
3572
rgba[i][RCOMP] = pixelToR[(p & rMask) >> rShift];
3573
rgba[i][GCOMP] = pixelToG[(p & gMask) >> gShift];
3574
rgba[i][BCOMP] = pixelToB[(p & bMask) >> bShift];
3575
rgba[i][ACOMP] = 255;
3580
case PF_DITHER_5R6G5B:
3582
const GLubyte *pixelToR = xmesa->xm_visual->PixelToR;
3583
const GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
3584
const GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
3587
unsigned long p = XMesaGetPixel( span, i, 0 );
3588
/* fast, but not quite accurate
3589
rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3590
rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3591
rgba[i][BCOMP] = ((p << 3) & 0xff);
3593
rgba[i][RCOMP] = pixelToR[p >> 11];
3594
rgba[i][GCOMP] = pixelToG[(p >> 5) & 0x3f];
3595
rgba[i][BCOMP] = pixelToB[p & 0x1f];
3596
rgba[i][ACOMP] = 255;
3602
const GLuint *ptr4 = (GLuint *) span->data;
3605
GLuint p4 = *ptr4++;
3606
rgba[i][RCOMP] = (GLubyte) ( p4 & 0xff);
3607
rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
3608
rgba[i][BCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
3609
rgba[i][ACOMP] = (GLubyte) ((p4 >> 24) & 0xff);
3615
const GLuint *ptr4 = (GLuint *) span->data;
3618
GLuint p4 = *ptr4++;
3619
rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
3620
rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
3621
rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
3622
rgba[i][ACOMP] = 255;
3628
const bgr_t *ptr3 = (bgr_t *) span->data;
3631
rgba[i][RCOMP] = ptr3[i].r;
3632
rgba[i][GCOMP] = ptr3[i].g;
3633
rgba[i][BCOMP] = ptr3[i].b;
3634
rgba[i][ACOMP] = 255;
3640
GLubyte *ptr1 = (GLubyte *) span->data;
3643
GLubyte p = *ptr1++;
3644
rgba[i][RCOMP] = p & 0xE0;
3645
rgba[i][GCOMP] = (p & 0x1C) << 3;
3646
rgba[i][BCOMP] = (p & 0x03) << 6;
3647
rgba[i][ACOMP] = 255;
3655
GLubyte *rTable = source->pixel_to_r;
3656
GLubyte *gTable = source->pixel_to_g;
3657
GLubyte *bTable = source->pixel_to_b;
3658
if (GET_VISUAL_DEPTH(xmesa->xm_visual)==8) {
3659
const GLubyte *ptr1 = (GLubyte *) span->data;
3662
unsigned long p = *ptr1++;
3663
rgba[i][RCOMP] = rTable[p];
3664
rgba[i][GCOMP] = gTable[p];
3665
rgba[i][BCOMP] = bTable[p];
3666
rgba[i][ACOMP] = 255;
3672
unsigned long p = XMesaGetPixel( span, i, 0 );
3673
rgba[i][RCOMP] = rTable[p];
3674
rgba[i][GCOMP] = gTable[p];
3675
rgba[i][BCOMP] = bTable[p];
3676
rgba[i][ACOMP] = 255;
3683
int bitFlip = xmesa->xm_visual->bitFlip;
3687
p = XMesaGetPixel( span, i, 0 ) ^ bitFlip;
3688
rgba[i][RCOMP] = (GLubyte) (p * 255);
3689
rgba[i][GCOMP] = (GLubyte) (p * 255);
3690
rgba[i][BCOMP] = (GLubyte) (p * 255);
3691
rgba[i][ACOMP] = 255;
3696
_mesa_problem(NULL,"Problem in DD.read_color_span (1)");
3701
/* return black pixels */
3704
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = rgba[i][ACOMP] = 0;
3708
XMesaDestroyImage( span );
3711
else if (source->backimage) {
3712
/* Read from XImage back buffer */
3713
switch (xmesa->pixelformat) {
3717
const GLubyte *pixelToR = xmesa->xm_visual->PixelToR;
3718
const GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
3719
const GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
3720
unsigned long rMask = GET_REDMASK(xmesa->xm_visual);
3721
unsigned long gMask = GET_GREENMASK(xmesa->xm_visual);
3722
unsigned long bMask = GET_BLUEMASK(xmesa->xm_visual);
3723
GLint rShift = xmesa->xm_visual->rshift;
3724
GLint gShift = xmesa->xm_visual->gshift;
3725
GLint bShift = xmesa->xm_visual->bshift;
3726
XMesaImage *img = source->backimage;
3728
y = FLIP(source, y);
3731
p = XMesaGetPixel( img, x+i, y );
3732
rgba[i][RCOMP] = pixelToR[(p & rMask) >> rShift];
3733
rgba[i][GCOMP] = pixelToG[(p & gMask) >> gShift];
3734
rgba[i][BCOMP] = pixelToB[(p & bMask) >> bShift];
3735
rgba[i][ACOMP] = 255;
3740
case PF_DITHER_5R6G5B:
3742
const GLubyte *pixelToR = xmesa->xm_visual->PixelToR;
3743
const GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
3744
const GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
3745
const GLushort *ptr2 = PIXELADDR2( source, x, y );
3747
#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
3748
const GLuint *ptr4 = (const GLuint *) ptr2;
3749
GLuint extraPixel = (n & 1);
3751
for (i = 0; i < n; i += 2) {
3752
const GLuint p = *ptr4++;
3753
const GLuint p0 = p & 0xffff;
3754
const GLuint p1 = p >> 16;
3755
/* fast, but not quite accurate
3756
rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3757
rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3758
rgba[i][BCOMP] = ((p << 3) & 0xff);
3760
rgba[i][RCOMP] = pixelToR[p0 >> 11];
3761
rgba[i][GCOMP] = pixelToG[(p0 >> 5) & 0x3f];
3762
rgba[i][BCOMP] = pixelToB[p0 & 0x1f];
3763
rgba[i][ACOMP] = 255;
3764
rgba[i+1][RCOMP] = pixelToR[p1 >> 11];
3765
rgba[i+1][GCOMP] = pixelToG[(p1 >> 5) & 0x3f];
3766
rgba[i+1][BCOMP] = pixelToB[p1 & 0x1f];
3767
rgba[i+1][ACOMP] = 255;
3770
GLushort p = ptr2[n];
3771
rgba[n][RCOMP] = pixelToR[p >> 11];
3772
rgba[n][GCOMP] = pixelToG[(p >> 5) & 0x3f];
3773
rgba[n][BCOMP] = pixelToB[p & 0x1f];
3774
rgba[n][ACOMP] = 255;
3777
for (i = 0; i < n; i++) {
3778
const GLushort p = ptr2[i];
3779
rgba[i][RCOMP] = pixelToR[p >> 11];
3780
rgba[i][GCOMP] = pixelToG[(p >> 5) & 0x3f];
3781
rgba[i][BCOMP] = pixelToB[p & 0x1f];
3782
rgba[i][ACOMP] = 255;
3789
const GLuint *ptr4 = PIXELADDR4( source, x, y );
3792
GLuint p4 = *ptr4++;
3793
rgba[i][RCOMP] = (GLubyte) ( p4 & 0xff);
3794
rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
3795
rgba[i][BCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
3796
rgba[i][ACOMP] = (GLint) ((p4 >> 24) & 0xff);
3802
const GLuint *ptr4 = PIXELADDR4( source, x, y );
3805
GLuint p4 = *ptr4++;
3806
rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
3807
rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
3808
rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
3809
rgba[i][ACOMP] = 255;
3815
const bgr_t *ptr3 = PIXELADDR3( source, x, y );
3818
rgba[i][RCOMP] = ptr3[i].r;
3819
rgba[i][GCOMP] = ptr3[i].g;
3820
rgba[i][BCOMP] = ptr3[i].b;
3821
rgba[i][ACOMP] = 255;
3827
const GLubyte *ptr1 = PIXELADDR1( source, x, y );
3830
GLubyte p = *ptr1++;
3831
rgba[i][RCOMP] = p & 0xE0;
3832
rgba[i][GCOMP] = (p & 0x1C) << 3;
3833
rgba[i][BCOMP] = (p & 0x03) << 6;
3834
rgba[i][ACOMP] = 255;
3842
const GLubyte *rTable = source->pixel_to_r;
3843
const GLubyte *gTable = source->pixel_to_g;
3844
const GLubyte *bTable = source->pixel_to_b;
3845
if (GET_VISUAL_DEPTH(xmesa->xm_visual)==8) {
3846
GLubyte *ptr1 = PIXELADDR1( source, x, y );
3849
unsigned long p = *ptr1++;
3850
rgba[i][RCOMP] = rTable[p];
3851
rgba[i][GCOMP] = gTable[p];
3852
rgba[i][BCOMP] = bTable[p];
3853
rgba[i][ACOMP] = 255;
3857
XMesaImage *img = source->backimage;
3859
y = FLIP(source, y);
3860
for (i=0;i<n;i++,x++) {
3861
unsigned long p = XMesaGetPixel( img, x, y );
3862
rgba[i][RCOMP] = rTable[p];
3863
rgba[i][GCOMP] = gTable[p];
3864
rgba[i][BCOMP] = bTable[p];
3865
rgba[i][ACOMP] = 255;
3872
XMesaImage *img = source->backimage;
3873
int bitFlip = xmesa->xm_visual->bitFlip;
3875
y = FLIP(source, y);
3876
for (i=0;i<n;i++,x++) {
3878
p = XMesaGetPixel( img, x, y ) ^ bitFlip;
3879
rgba[i][RCOMP] = (GLubyte) (p * 255);
3880
rgba[i][GCOMP] = (GLubyte) (p * 255);
3881
rgba[i][BCOMP] = (GLubyte) (p * 255);
3882
rgba[i][ACOMP] = 255;
3887
_mesa_problem(NULL,"Problem in DD.read_color_span (2)");
3896
* Read an array of color index pixels.
3898
static void read_index_pixels( const GLcontext *ctx,
3899
GLuint n, const GLint x[], const GLint y[],
3900
GLuint indx[], const GLubyte mask[] )
3902
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3906
if (xmesa->use_read_buffer)
3907
source = xmesa->xm_read_buffer;
3909
source = xmesa->xm_buffer;
3911
if (source->buffer) {
3914
indx[i] = (GLuint) read_pixel( xmesa->display,
3916
x[i], FLIP(source, y[i]) );
3920
else if (source->backimage) {
3921
XMesaImage *img = source->backimage;
3924
indx[i] = (GLuint) XMesaGetPixel( img, x[i], FLIP(source, y[i]) );
3932
static void read_color_pixels( const GLcontext *ctx,
3933
GLuint n, const GLint x[], const GLint y[],
3934
GLubyte rgba[][4], const GLubyte mask[] )
3936
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
3937
XMesaDisplay *dpy = xmesa->xm_visual->display;
3940
XMesaDrawable buffer;
3942
if (xmesa->use_read_buffer)
3943
source = xmesa->xm_read_buffer;
3945
source = xmesa->xm_buffer;
3947
buffer = source->buffer; /* the X drawable */
3949
if (source->buffer) {
3950
switch (xmesa->pixelformat) {
3954
case PF_DITHER_5R6G5B:
3956
unsigned long rMask = GET_REDMASK(xmesa->xm_visual);
3957
unsigned long gMask = GET_GREENMASK(xmesa->xm_visual);
3958
unsigned long bMask = GET_BLUEMASK(xmesa->xm_visual);
3959
GLubyte *pixelToR = xmesa->xm_visual->PixelToR;
3960
GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
3961
GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
3962
GLint rShift = xmesa->xm_visual->rshift;
3963
GLint gShift = xmesa->xm_visual->gshift;
3964
GLint bShift = xmesa->xm_visual->bshift;
3967
unsigned long p = read_pixel( dpy, buffer,
3968
x[i], FLIP(source, y[i]) );
3969
rgba[i][RCOMP] = pixelToR[(p & rMask) >> rShift];
3970
rgba[i][GCOMP] = pixelToG[(p & gMask) >> gShift];
3971
rgba[i][BCOMP] = pixelToB[(p & bMask) >> bShift];
3972
rgba[i][ACOMP] = 255;
3980
unsigned long p = read_pixel( dpy, buffer,
3981
x[i], FLIP(source, y[i]) );
3982
rgba[i][RCOMP] = (GLubyte) ( p & 0xff);
3983
rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
3984
rgba[i][BCOMP] = (GLubyte) ((p >> 16) & 0xff);
3985
rgba[i][ACOMP] = (GLubyte) ((p >> 24) & 0xff);
3992
unsigned long p = read_pixel( dpy, buffer,
3993
x[i], FLIP(source, y[i]) );
3994
rgba[i][RCOMP] = (GLubyte) ((p >> 16) & 0xff);
3995
rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
3996
rgba[i][BCOMP] = (GLubyte) ( p & 0xff);
3997
rgba[i][ACOMP] = 255;
4004
unsigned long p = read_pixel( dpy, buffer,
4005
x[i], FLIP(source, y[i]) );
4006
rgba[i][RCOMP] = (GLubyte) ((p >> 16) & 0xff);
4007
rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
4008
rgba[i][BCOMP] = (GLubyte) ( p & 0xff);
4009
rgba[i][ACOMP] = 255;
4017
unsigned long p = read_pixel( dpy, buffer,
4018
x[i], FLIP(source, y[i]) );
4019
rgba[i][RCOMP] = (GLubyte) ( p & 0xE0 );
4020
rgba[i][GCOMP] = (GLubyte) ((p & 0x1C) << 3);
4021
rgba[i][BCOMP] = (GLubyte) ((p & 0x03) << 6);
4022
rgba[i][ACOMP] = (GLubyte) 255;
4031
GLubyte *rTable = source->pixel_to_r;
4032
GLubyte *gTable = source->pixel_to_g;
4033
GLubyte *bTable = source->pixel_to_b;
4036
unsigned long p = read_pixel( dpy, buffer,
4037
x[i], FLIP(source, y[i]) );
4038
rgba[i][RCOMP] = rTable[p];
4039
rgba[i][GCOMP] = gTable[p];
4040
rgba[i][BCOMP] = bTable[p];
4041
rgba[i][ACOMP] = 255;
4048
int bitFlip = xmesa->xm_visual->bitFlip;
4051
unsigned long p = read_pixel( dpy, buffer,
4052
x[i], FLIP(source, y[i])) ^ bitFlip;
4053
rgba[i][RCOMP] = (GLubyte) (p * 255);
4054
rgba[i][GCOMP] = (GLubyte) (p * 255);
4055
rgba[i][BCOMP] = (GLubyte) (p * 255);
4056
rgba[i][ACOMP] = 255;
4062
_mesa_problem(NULL,"Problem in DD.read_color_pixels (1)");
4066
else if (source->backimage) {
4067
switch (xmesa->pixelformat) {
4071
case PF_DITHER_5R6G5B:
4073
unsigned long rMask = GET_REDMASK(xmesa->xm_visual);
4074
unsigned long gMask = GET_GREENMASK(xmesa->xm_visual);
4075
unsigned long bMask = GET_BLUEMASK(xmesa->xm_visual);
4076
GLubyte *pixelToR = xmesa->xm_visual->PixelToR;
4077
GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
4078
GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
4079
GLint rShift = xmesa->xm_visual->rshift;
4080
GLint gShift = xmesa->xm_visual->gshift;
4081
GLint bShift = xmesa->xm_visual->bshift;
4082
XMesaImage *img = source->backimage;
4086
p = XMesaGetPixel( img, x[i], FLIP(source, y[i]) );
4087
rgba[i][RCOMP] = pixelToR[(p & rMask) >> rShift];
4088
rgba[i][GCOMP] = pixelToG[(p & gMask) >> gShift];
4089
rgba[i][BCOMP] = pixelToB[(p & bMask) >> bShift];
4090
rgba[i][ACOMP] = 255;
4098
GLuint *ptr4 = PIXELADDR4( source, x[i], y[i] );
4100
rgba[i][RCOMP] = (GLubyte) ( p4 & 0xff);
4101
rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
4102
rgba[i][BCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
4103
rgba[i][ACOMP] = (GLubyte) ((p4 >> 24) & 0xff);
4110
GLuint *ptr4 = PIXELADDR4( source, x[i], y[i] );
4112
rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
4113
rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
4114
rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
4115
rgba[i][ACOMP] = 255;
4122
bgr_t *ptr3 = PIXELADDR3( source, x[i], y[i] );
4123
rgba[i][RCOMP] = ptr3->r;
4124
rgba[i][GCOMP] = ptr3->g;
4125
rgba[i][BCOMP] = ptr3->b;
4126
rgba[i][ACOMP] = 255;
4133
GLubyte *ptr1 = PIXELADDR1( source, x[i], y[i] );
4135
rgba[i][RCOMP] = p & 0xE0;
4136
rgba[i][GCOMP] = (p & 0x1C) << 3;
4137
rgba[i][BCOMP] = (p & 0x03) << 6;
4138
rgba[i][ACOMP] = 255;
4146
GLubyte *rTable = source->pixel_to_r;
4147
GLubyte *gTable = source->pixel_to_g;
4148
GLubyte *bTable = source->pixel_to_b;
4149
XMesaImage *img = source->backimage;
4153
p = XMesaGetPixel( img, x[i], FLIP(source, y[i]) );
4154
rgba[i][RCOMP] = rTable[p];
4155
rgba[i][GCOMP] = gTable[p];
4156
rgba[i][BCOMP] = bTable[p];
4157
rgba[i][ACOMP] = 255;
4164
XMesaImage *img = source->backimage;
4165
int bitFlip = xmesa->xm_visual->bitFlip;
4169
p = XMesaGetPixel( img, x[i], FLIP(source, y[i]) ) ^ bitFlip;
4170
rgba[i][RCOMP] = (GLubyte) (p * 255);
4171
rgba[i][GCOMP] = (GLubyte) (p * 255);
4172
rgba[i][BCOMP] = (GLubyte) (p * 255);
4173
rgba[i][ACOMP] = 255;
4179
_mesa_problem(NULL,"Problem in DD.read_color_pixels (1)");
4187
clear_color_HPCR_ximage( GLcontext *ctx, const GLchan color[4] )
4190
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
4192
COPY_4V(xmesa->clearcolor, color);
4194
if (color[0] == 0 && color[1] == 0 && color[2] == 0) {
4195
/* black is black */
4196
MEMSET( xmesa->xm_visual->hpcr_clear_ximage_pattern, 0x0 ,
4197
sizeof(xmesa->xm_visual->hpcr_clear_ximage_pattern));
4200
/* build clear pattern */
4201
for (i=0; i<16; i++) {
4202
xmesa->xm_visual->hpcr_clear_ximage_pattern[0][i] =
4203
DITHER_HPCR(i, 0, color[0], color[1], color[2]);
4204
xmesa->xm_visual->hpcr_clear_ximage_pattern[1][i] =
4205
DITHER_HPCR(i, 1, color[0], color[1], color[2]);
4212
clear_color_HPCR_pixmap( GLcontext *ctx, const GLchan color[4] )
4215
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
4217
COPY_4V(xmesa->clearcolor, color);
4219
if (color[0] == 0 && color[1] == 0 && color[2] == 0) {
4220
/* black is black */
4221
for (i=0; i<16; i++) {
4222
XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0, 0);
4223
XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1, 0);
4227
for (i=0; i<16; i++) {
4228
XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0,
4229
DITHER_HPCR(i, 0, color[0], color[1], color[2]));
4230
XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1,
4231
DITHER_HPCR(i, 1, color[0], color[1], color[2]));
4234
/* change tile pixmap content */
4235
XMesaPutImage(xmesa->display,
4236
(XMesaDrawable)xmesa->xm_visual->hpcr_clear_pixmap,
4237
xmesa->xm_buffer->cleargc,
4238
xmesa->xm_visual->hpcr_clear_ximage, 0, 0, 0, 0, 16, 2);
4243
void xmesa_update_span_funcs( GLcontext *ctx )
4245
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
4246
int depth=GET_VISUAL_DEPTH(xmesa->xm_visual);
4247
struct swrast_device_driver *dd = _swrast_GetDeviceDriverReference( ctx );
4250
* These drawing functions depend on color buffer config:
4252
if (xmesa->xm_buffer->buffer!=XIMAGE) {
4253
/* Writing to window or back pixmap */
4254
switch (xmesa->pixelformat) {
4256
dd->WriteCI32Span = write_span_index_pixmap;
4257
dd->WriteCI8Span = write_span_index8_pixmap;
4258
dd->WriteMonoCISpan = write_span_mono_index_pixmap;
4259
dd->WriteCI32Pixels = write_pixels_index_pixmap;
4260
dd->WriteMonoCIPixels = write_pixels_mono_index_pixmap;
4263
dd->WriteRGBASpan = write_span_TRUECOLOR_pixmap;
4264
dd->WriteRGBSpan = write_span_rgb_TRUECOLOR_pixmap;
4265
dd->WriteMonoRGBASpan = write_span_mono_pixmap;
4266
dd->WriteRGBAPixels = write_pixels_TRUECOLOR_pixmap;
4267
dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
4270
dd->WriteRGBASpan = write_span_TRUEDITHER_pixmap;
4271
dd->WriteRGBSpan = write_span_rgb_TRUEDITHER_pixmap;
4272
dd->WriteMonoRGBASpan = write_span_mono_TRUEDITHER_pixmap;
4273
dd->WriteRGBAPixels = write_pixels_TRUEDITHER_pixmap;
4274
dd->WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_pixmap;
4277
dd->WriteRGBASpan = write_span_8A8B8G8R_pixmap;
4278
dd->WriteRGBSpan = write_span_rgb_8A8B8G8R_pixmap;
4279
dd->WriteMonoRGBASpan = write_span_mono_pixmap;
4280
dd->WriteRGBAPixels = write_pixels_8A8B8G8R_pixmap;
4281
dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
4284
dd->WriteRGBASpan = write_span_8R8G8B_pixmap;
4285
dd->WriteRGBSpan = write_span_rgb_8R8G8B_pixmap;
4286
dd->WriteMonoRGBASpan = write_span_mono_pixmap;
4287
dd->WriteRGBAPixels = write_pixels_8R8G8B_pixmap;
4288
dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
4291
dd->WriteRGBASpan = write_span_8R8G8B24_pixmap;
4292
dd->WriteRGBSpan = write_span_rgb_8R8G8B24_pixmap;
4293
dd->WriteMonoRGBASpan = write_span_mono_pixmap;
4294
dd->WriteRGBAPixels = write_pixels_8R8G8B24_pixmap;
4295
dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
4298
dd->WriteRGBASpan = write_span_5R6G5B_pixmap;
4299
dd->WriteRGBSpan = write_span_rgb_5R6G5B_pixmap;
4300
dd->WriteMonoRGBASpan = write_span_mono_pixmap;
4301
dd->WriteRGBAPixels = write_pixels_5R6G5B_pixmap;
4302
dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
4304
case PF_DITHER_5R6G5B:
4305
dd->WriteRGBASpan = write_span_DITHER_5R6G5B_pixmap;
4306
dd->WriteRGBSpan = write_span_rgb_DITHER_5R6G5B_pixmap;
4307
dd->WriteMonoRGBASpan = write_span_mono_TRUEDITHER_pixmap;
4308
dd->WriteRGBAPixels = write_pixels_DITHER_5R6G5B_pixmap;
4309
dd->WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_pixmap;
4312
dd->WriteRGBASpan = write_span_DITHER_pixmap;
4313
dd->WriteRGBSpan = write_span_rgb_DITHER_pixmap;
4314
dd->WriteMonoRGBASpan = write_span_mono_DITHER_pixmap;
4315
dd->WriteRGBAPixels = write_pixels_DITHER_pixmap;
4316
dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER_pixmap;
4319
dd->WriteRGBASpan = write_span_1BIT_pixmap;
4320
dd->WriteRGBSpan = write_span_rgb_1BIT_pixmap;
4321
dd->WriteMonoRGBASpan = write_span_mono_1BIT_pixmap;
4322
dd->WriteRGBAPixels = write_pixels_1BIT_pixmap;
4323
dd->WriteMonoRGBAPixels = write_pixels_mono_1BIT_pixmap;
4326
dd->WriteRGBASpan = write_span_HPCR_pixmap;
4327
dd->WriteRGBSpan = write_span_rgb_HPCR_pixmap;
4328
dd->WriteMonoRGBASpan = write_span_mono_pixmap;
4329
dd->WriteRGBAPixels = write_pixels_HPCR_pixmap;
4330
dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
4331
if (xmesa->xm_visual->hpcr_clear_flag) {
4332
ctx->Driver.ClearColor = clear_color_HPCR_pixmap;
4336
dd->WriteRGBASpan = write_span_LOOKUP_pixmap;
4337
dd->WriteRGBSpan = write_span_rgb_LOOKUP_pixmap;
4338
dd->WriteMonoRGBASpan = write_span_mono_pixmap;
4339
dd->WriteRGBAPixels = write_pixels_LOOKUP_pixmap;
4340
dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
4343
dd->WriteRGBASpan = write_span_GRAYSCALE_pixmap;
4344
dd->WriteRGBSpan = write_span_rgb_GRAYSCALE_pixmap;
4345
dd->WriteMonoRGBASpan = write_span_mono_pixmap;
4346
dd->WriteRGBAPixels = write_pixels_GRAYSCALE_pixmap;
4347
dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
4350
_mesa_problem(NULL,"Bad pixel format in xmesa_update_state (1)");
4354
else if (xmesa->xm_buffer->buffer==XIMAGE) {
4355
/* Writing to back XImage */
4356
switch (xmesa->pixelformat) {
4358
dd->WriteCI32Span = write_span_index_ximage;
4360
dd->WriteCI8Span = write_span_index8_ximage8;
4362
dd->WriteCI8Span = write_span_index8_ximage;
4363
dd->WriteMonoCISpan = write_span_mono_index_ximage;
4364
dd->WriteCI32Pixels = write_pixels_index_ximage;
4365
dd->WriteMonoCIPixels = write_pixels_mono_index_ximage;
4369
dd->WriteRGBASpan = write_span_TRUECOLOR_ximage;
4370
dd->WriteRGBSpan = write_span_rgb_TRUECOLOR_ximage;
4371
dd->WriteMonoRGBASpan = write_span_mono_ximage;
4372
dd->WriteRGBAPixels = write_pixels_TRUECOLOR_ximage;
4373
dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
4376
dd->WriteRGBASpan = write_span_TRUEDITHER_ximage;
4377
dd->WriteRGBSpan = write_span_rgb_TRUEDITHER_ximage;
4378
dd->WriteMonoRGBASpan = write_span_mono_TRUEDITHER_ximage;
4379
dd->WriteRGBAPixels = write_pixels_TRUEDITHER_ximage;
4380
dd->WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_ximage;
4383
dd->WriteRGBASpan = write_span_8A8B8G8R_ximage;
4384
dd->WriteRGBSpan = write_span_rgb_8A8B8G8R_ximage;
4385
dd->WriteMonoRGBASpan = write_span_mono_8A8B8G8R_ximage;
4386
dd->WriteRGBAPixels = write_pixels_8A8B8G8R_ximage;
4387
dd->WriteMonoRGBAPixels = write_pixels_mono_8A8B8G8R_ximage;
4390
dd->WriteRGBASpan = write_span_8R8G8B_ximage;
4391
dd->WriteRGBSpan = write_span_rgb_8R8G8B_ximage;
4392
dd->WriteMonoRGBASpan = write_span_mono_8R8G8B_ximage;
4393
dd->WriteRGBAPixels = write_pixels_8R8G8B_ximage;
4394
dd->WriteMonoRGBAPixels = write_pixels_mono_8R8G8B_ximage;
4397
dd->WriteRGBASpan = write_span_8R8G8B24_ximage;
4398
dd->WriteRGBSpan = write_span_rgb_8R8G8B24_ximage;
4399
dd->WriteMonoRGBASpan = write_span_mono_8R8G8B24_ximage;
4400
dd->WriteRGBAPixels = write_pixels_8R8G8B24_ximage;
4401
dd->WriteMonoRGBAPixels = write_pixels_mono_8R8G8B24_ximage;
4404
dd->WriteRGBASpan = write_span_5R6G5B_ximage;
4405
dd->WriteRGBSpan = write_span_rgb_5R6G5B_ximage;
4406
dd->WriteMonoRGBASpan = write_span_mono_ximage;
4407
dd->WriteRGBAPixels = write_pixels_5R6G5B_ximage;
4408
dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
4410
case PF_DITHER_5R6G5B:
4411
dd->WriteRGBASpan = write_span_DITHER_5R6G5B_ximage;
4412
dd->WriteRGBSpan = write_span_rgb_DITHER_5R6G5B_ximage;
4413
dd->WriteMonoRGBASpan = write_span_mono_DITHER_5R6G5B_ximage;
4414
dd->WriteRGBAPixels = write_pixels_DITHER_5R6G5B_ximage;
4415
dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER_5R6G5B_ximage;
4419
dd->WriteRGBASpan = write_span_DITHER8_ximage;
4420
dd->WriteRGBSpan = write_span_rgb_DITHER8_ximage;
4421
dd->WriteMonoRGBASpan = write_span_mono_DITHER8_ximage;
4422
dd->WriteRGBAPixels = write_pixels_DITHER8_ximage;
4423
dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER8_ximage;
4426
dd->WriteRGBASpan = write_span_DITHER_ximage;
4427
dd->WriteRGBSpan = write_span_rgb_DITHER_ximage;
4428
dd->WriteMonoRGBASpan = write_span_mono_DITHER_ximage;
4429
dd->WriteRGBAPixels = write_pixels_DITHER_ximage;
4430
dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER_ximage;
4434
dd->WriteRGBASpan = write_span_1BIT_ximage;
4435
dd->WriteRGBSpan = write_span_rgb_1BIT_ximage;
4436
dd->WriteMonoRGBASpan = write_span_mono_1BIT_ximage;
4437
dd->WriteRGBAPixels = write_pixels_1BIT_ximage;
4438
dd->WriteMonoRGBAPixels = write_pixels_mono_1BIT_ximage;
4441
dd->WriteRGBASpan = write_span_HPCR_ximage;
4442
dd->WriteRGBSpan = write_span_rgb_HPCR_ximage;
4443
dd->WriteMonoRGBASpan = write_span_mono_HPCR_ximage;
4444
dd->WriteRGBAPixels = write_pixels_HPCR_ximage;
4445
dd->WriteMonoRGBAPixels = write_pixels_mono_HPCR_ximage;
4446
if (xmesa->xm_visual->hpcr_clear_flag) {
4447
ctx->Driver.ClearColor = clear_color_HPCR_ximage;
4452
dd->WriteRGBASpan = write_span_LOOKUP8_ximage;
4453
dd->WriteRGBSpan = write_rgb_LOOKUP8_ximage;
4454
dd->WriteMonoRGBASpan = write_span_mono_LOOKUP8_ximage;
4455
dd->WriteRGBAPixels = write_pixels_LOOKUP8_ximage;
4456
dd->WriteMonoRGBAPixels = write_pixels_mono_LOOKUP8_ximage;
4459
dd->WriteRGBASpan = write_span_LOOKUP_ximage;
4460
dd->WriteRGBSpan = write_span_rgb_LOOKUP_ximage;
4461
dd->WriteMonoRGBASpan = write_span_mono_ximage;
4462
dd->WriteRGBAPixels = write_pixels_LOOKUP_ximage;
4463
dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
4468
dd->WriteRGBASpan = write_span_GRAYSCALE8_ximage;
4469
dd->WriteRGBSpan = write_span_rgb_GRAYSCALE8_ximage;
4470
dd->WriteMonoRGBASpan = write_span_mono_GRAYSCALE8_ximage;
4471
dd->WriteRGBAPixels = write_pixels_GRAYSCALE8_ximage;
4472
dd->WriteMonoRGBAPixels = write_pixels_mono_GRAYSCALE8_ximage;
4475
dd->WriteRGBASpan = write_span_GRAYSCALE_ximage;
4476
dd->WriteRGBSpan = write_span_rgb_GRAYSCALE_ximage;
4477
dd->WriteMonoRGBASpan = write_span_mono_ximage;
4478
dd->WriteRGBAPixels = write_pixels_GRAYSCALE_ximage;
4479
dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
4483
_mesa_problem(NULL,"Bad pixel format in xmesa_update_state (2)");
4488
/* Pixel/span reading functions: */
4489
dd->ReadCI32Span = read_index_span;
4490
dd->ReadRGBASpan = read_color_span;
4491
dd->ReadCI32Pixels = read_index_pixels;
4492
dd->ReadRGBAPixels = read_color_pixels;
4494
dd->SetReadBuffer = xmesa_set_read_buffer;