2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 /* $XFree86: xc/extras/Mesa/src/X/xm_span.c,v 1.3 2002/02/27 21:07:54 tsi Exp $ */
26 #include "glxheader.h"
31 #include "extensions.h"
38 #include "swrast/swrast.h"
42 * The following functions are used to trap XGetImage() calls which
43 * generate BadMatch errors if the drawable isn't mapped.
47 static int caught_xgetimage_error
= 0;
48 static int (*old_xerror_handler
)( XMesaDisplay
*dpy
, XErrorEvent
*ev
);
49 static unsigned long xgetimage_serial
;
52 * This is the error handler which will be called if XGetImage fails.
54 static int xgetimage_error_handler( XMesaDisplay
*dpy
, XErrorEvent
*ev
)
56 if (ev
->serial
==xgetimage_serial
&& ev
->error_code
==BadMatch
) {
57 /* caught the expected error */
58 caught_xgetimage_error
= 0;
61 /* call the original X error handler, if any. otherwise ignore */
62 if (old_xerror_handler
) {
63 (*old_xerror_handler
)( dpy
, ev
);
71 * Call this right before XGetImage to setup error trap.
73 static void catch_xgetimage_errors( XMesaDisplay
*dpy
)
75 xgetimage_serial
= NextRequest( dpy
);
76 old_xerror_handler
= XSetErrorHandler( xgetimage_error_handler
);
77 caught_xgetimage_error
= 0;
82 * Call this right after XGetImage to check if an error occured.
84 static int check_xgetimage_errors( void )
86 /* restore old handler */
87 (void) XSetErrorHandler( old_xerror_handler
);
88 /* return 0=no error, 1=error caught */
89 return caught_xgetimage_error
;
95 * Read a pixel from an X drawable.
97 static unsigned long read_pixel( XMesaDisplay
*dpy
,
98 XMesaDrawable d
, int x
, int y
)
101 #ifndef XFree86Server
102 XMesaImage
*pixel
= NULL
;
105 catch_xgetimage_errors( dpy
);
106 pixel
= XGetImage( dpy
, d
, x
, y
, 1, 1, AllPlanes
, ZPixmap
);
107 error
= check_xgetimage_errors();
108 if (pixel
&& !error
) {
109 p
= XMesaGetPixel( pixel
, 0, 0 );
115 XMesaDestroyImage( pixel
);
118 (*dpy
->GetImage
)(d
, x
, y
, 1, 1, ZPixmap
, ~0L, (pointer
)&p
);
126 * The Mesa library needs to be able to draw pixels in a number of ways:
127 * 1. RGB vs Color Index
128 * 2. as horizontal spans (polygons, images) vs random locations (points,
130 * 3. different color per-pixel or same color for all pixels
132 * Furthermore, the X driver needs to support rendering to 3 possible
133 * "buffers", usually one, but sometimes two at a time:
134 * 1. The front buffer as an X window
135 * 2. The back buffer as a Pixmap
136 * 3. The back buffer as an XImage
138 * Finally, if the back buffer is an XImage, we can avoid using XPutPixel and
139 * optimize common cases such as 24-bit and 8-bit modes.
141 * By multiplication, there's at least 48 possible combinations of the above.
143 * Below are implementations of the most commonly used combinations. They are
144 * accessed through function pointers which get initialized here and are used
145 * directly from the Mesa library. The 8 function pointers directly correspond
146 * to the first 3 cases listed above.
149 * The function naming convention is:
151 * [put|get]_[mono]_[row|values]_[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 PUT_ROW_ARGS \
168 struct gl_renderbuffer *rb, \
169 GLuint n, GLint x, GLint y, \
170 const void *values, const GLubyte mask[]
172 #define RGB_SPAN_ARGS \
174 struct gl_renderbuffer *rb, \
175 GLuint n, GLint x, GLint y, \
176 const void *values, const GLubyte mask[]
179 /* NOTE: if mask==NULL, draw all pixels */
183 * Write a span of PF_TRUECOLOR pixels to a pixmap.
185 static void put_row_TRUECOLOR_pixmap( PUT_ROW_ARGS
)
187 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
188 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
189 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
190 XMesaDisplay
*dpy
= XMESA_BUFFER(ctx
->DrawBuffer
)->display
;
191 XMesaDrawable buffer
= xrb
->pixmap
;
192 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
197 for (i
=0;i
<n
;i
++,x
++) {
200 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
201 XMesaSetForeground( dpy
, gc
, p
);
202 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
207 /* draw all pixels */
208 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
211 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
212 XMesaPutPixel( rowimg
, i
, 0, p
);
214 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
220 * Write a span of PF_TRUECOLOR pixels to a pixmap.
222 static void put_row_rgb_TRUECOLOR_pixmap( RGB_SPAN_ARGS
)
224 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
225 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
226 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
227 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
228 XMesaDrawable buffer
= xrb
->pixmap
;
229 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
233 for (i
=0;i
<n
;i
++,x
++) {
236 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
237 XMesaSetForeground( dpy
, gc
, p
);
238 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
243 /* draw all pixels */
244 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
247 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
248 XMesaPutPixel( rowimg
, i
, 0, p
);
250 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
255 * Write a span of PF_TRUEDITHER pixels to a pixmap.
257 static void put_row_TRUEDITHER_pixmap( PUT_ROW_ARGS
)
259 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
260 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
261 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
262 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
263 XMesaDrawable buffer
= xrb
->pixmap
;
264 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
268 for (i
=0;i
<n
;i
++,x
++) {
271 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
272 XMesaSetForeground( dpy
, gc
, p
);
273 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
278 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
281 PACK_TRUEDITHER(p
, x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
282 XMesaPutPixel( rowimg
, i
, 0, p
);
284 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
290 * Write a span of PF_TRUEDITHER pixels to a pixmap (no alpha).
292 static void put_row_rgb_TRUEDITHER_pixmap( RGB_SPAN_ARGS
)
294 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
295 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
296 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
297 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
298 XMesaDrawable buffer
= xrb
->pixmap
;
299 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
303 for (i
=0;i
<n
;i
++,x
++) {
306 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
307 XMesaSetForeground( dpy
, gc
, p
);
308 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
313 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
316 PACK_TRUEDITHER(p
, x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
317 XMesaPutPixel( rowimg
, i
, 0, p
);
319 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
325 * Write a span of PF_8A8B8G8R pixels to a pixmap.
327 static void put_row_8A8B8G8R_pixmap( PUT_ROW_ARGS
)
329 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
330 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
331 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
332 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
333 XMesaDrawable buffer
= xrb
->pixmap
;
334 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
338 for (i
=0;i
<n
;i
++,x
++) {
340 XMesaSetForeground( dpy
, gc
,
341 PACK_8A8B8G8R(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
]) );
342 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
347 /* draw all pixels */
348 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
349 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
351 *ptr4
++ = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
353 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
359 * Write a span of PF_8A8B8G8R pixels to a pixmap (no alpha).
361 static void put_row_rgb_8A8B8G8R_pixmap( RGB_SPAN_ARGS
)
363 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
364 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
365 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
366 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
367 XMesaDrawable buffer
= xrb
->pixmap
;
368 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
372 for (i
=0;i
<n
;i
++,x
++) {
374 XMesaSetForeground( dpy
, gc
,
375 PACK_8B8G8R(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
376 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
381 /* draw all pixels */
382 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
383 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
385 *ptr4
++ = PACK_8B8G8R(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
387 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
392 * Write a span of PF_8A8R8G8B pixels to a pixmap.
394 static void put_row_8A8R8G8B_pixmap( PUT_ROW_ARGS
)
396 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
397 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
398 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
399 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
400 XMesaDrawable buffer
= xrb
->pixmap
;
401 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
405 for (i
=0;i
<n
;i
++,x
++) {
407 XMesaSetForeground( dpy
, gc
,
408 PACK_8A8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
]) );
409 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
414 /* draw all pixels */
415 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
416 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
418 *ptr4
++ = PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
420 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
426 * Write a span of PF_8A8R8G8B pixels to a pixmap (no alpha).
428 static void put_row_rgb_8A8R8G8B_pixmap( RGB_SPAN_ARGS
)
430 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
431 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
432 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
433 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
434 XMesaDrawable buffer
= xrb
->pixmap
;
435 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
439 for (i
=0;i
<n
;i
++,x
++) {
441 XMesaSetForeground( dpy
, gc
,
442 PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
443 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
448 /* draw all pixels */
449 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
450 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
452 *ptr4
++ = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
454 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
459 * Write a span of PF_8R8G8B pixels to a pixmap.
461 static void put_row_8R8G8B_pixmap( PUT_ROW_ARGS
)
463 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
464 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
465 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
466 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
467 XMesaDrawable buffer
= xrb
->pixmap
;
468 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
472 for (i
=0;i
<n
;i
++,x
++) {
474 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
475 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
480 /* draw all pixels */
481 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
482 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
484 *ptr4
++ = PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
486 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
492 * Write a span of PF_8R8G8B24 pixels to a pixmap.
494 static void put_row_8R8G8B24_pixmap( PUT_ROW_ARGS
)
496 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
497 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
498 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
499 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
500 XMesaDrawable buffer
= xrb
->pixmap
;
501 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
505 for (i
=0;i
<n
;i
++,x
++) {
507 XMesaSetForeground( dpy
, gc
,
508 PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
509 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
514 /* draw all pixels */
515 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
516 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
517 register GLuint pixel
;
518 static const GLuint shift
[4] = {0, 8, 16, 24};
519 register GLuint i
= 0;
522 pixel
= rgba
[i
][BCOMP
] /* << shift[0]*/;
523 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
524 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
525 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
528 pixel
= rgba
[i
][GCOMP
] /* << shift[0]*/;
529 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
530 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
531 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
534 pixel
= rgba
[i
++][RCOMP
]/* << shift[0]*/;
535 pixel
|= rgba
[i
][BCOMP
] << shift
[1];
536 pixel
|= rgba
[i
][GCOMP
] << shift
[2];
537 pixel
|= rgba
[i
++][RCOMP
] << shift
[3];
545 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
546 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
547 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
548 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
551 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
552 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
553 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
554 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
556 pixel
= 0xffffff00 & *ptr4
;
557 pixel
|= rgba
[i
][RCOMP
] /*<< shift[0]*/;
562 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
563 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
564 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
565 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
567 pixel
= 0xffff0000 & *ptr4
;
568 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
569 pixel
|= rgba
[i
][RCOMP
] << shift
[1];
573 pixel
= 0xff000000 & *ptr4
;
574 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
575 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
576 pixel
|= rgba
[i
][RCOMP
] << shift
[2];
582 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
588 * Write a span of PF_8R8G8B pixels to a pixmap (no alpha).
590 static void put_row_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS
)
592 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
593 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
594 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
595 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
596 XMesaDrawable buffer
= xrb
->pixmap
;
597 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
601 for (i
=0;i
<n
;i
++,x
++) {
603 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
604 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
609 /* draw all pixels */
610 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
611 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
613 *ptr4
++ = PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
615 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
620 * Write a span of PF_8R8G8B24 pixels to a pixmap (no alpha).
622 static void put_row_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS
)
624 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
625 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
626 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
627 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
628 XMesaDrawable buffer
= xrb
->pixmap
;
629 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
633 for (i
=0;i
<n
;i
++,x
++) {
635 XMesaSetForeground( dpy
, gc
,
636 PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
637 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
642 /* draw all pixels */
643 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
644 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
645 register GLuint pixel
;
646 static const GLuint shift
[4] = {0, 8, 16, 24};
648 register GLuint i
= 0;
651 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
652 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
653 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
654 pixel
|= rgb
[i
][BCOMP
] <<shift
[3];
658 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
659 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
660 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
661 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
665 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
666 pixel
|= rgb
[i
][BCOMP
] << shift
[1];
667 pixel
|= rgb
[i
][GCOMP
] << shift
[2];
668 pixel
|= rgb
[i
++][RCOMP
] << shift
[3];
675 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
676 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
677 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
678 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
681 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
682 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
683 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
684 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
688 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
693 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
694 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
695 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
696 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
700 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
701 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
707 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
708 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
709 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
715 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
721 * Write a span of PF_5R6G5B pixels to a pixmap.
723 static void put_row_5R6G5B_pixmap( PUT_ROW_ARGS
)
725 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
726 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
727 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
728 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
729 XMesaDrawable buffer
= xrb
->pixmap
;
730 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
734 for (i
=0;i
<n
;i
++,x
++) {
736 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
737 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
742 /* draw all pixels */
743 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
744 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
746 ptr2
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
748 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
754 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap.
756 static void put_row_DITHER_5R6G5B_pixmap( PUT_ROW_ARGS
)
758 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
759 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
760 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
761 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
762 XMesaDrawable buffer
= xrb
->pixmap
;
763 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
767 for (i
=0;i
<n
;i
++,x
++) {
770 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
771 XMesaSetForeground( dpy
, gc
, p
);
772 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
777 /* draw all pixels */
778 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
779 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
781 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
783 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
789 * Write a span of PF_5R6G5B pixels to a pixmap (no alpha).
791 static void put_row_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS
)
793 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
794 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
795 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
796 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
797 XMesaDrawable buffer
= xrb
->pixmap
;
798 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
802 for (i
=0;i
<n
;i
++,x
++) {
804 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
805 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
810 /* draw all pixels */
811 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
812 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
814 ptr2
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
816 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
822 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap (no alpha).
824 static void put_row_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS
)
826 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
827 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
828 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
829 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
830 XMesaDrawable buffer
= xrb
->pixmap
;
831 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
835 for (i
=0;i
<n
;i
++,x
++) {
838 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
839 XMesaSetForeground( dpy
, gc
, p
);
840 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
845 /* draw all pixels */
846 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
847 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
849 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
851 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
857 * Write a span of PF_DITHER pixels to a pixmap.
859 static void put_row_DITHER_pixmap( PUT_ROW_ARGS
)
861 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
862 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
863 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
864 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
865 XMesaDrawable buffer
= xrb
->pixmap
;
866 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
871 for (i
=0;i
<n
;i
++,x
++) {
873 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
874 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
879 /* draw all pixels */
880 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
882 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
884 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
890 * Write a span of PF_DITHER pixels to a pixmap (no alpha).
892 static void put_row_rgb_DITHER_pixmap( RGB_SPAN_ARGS
)
894 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
895 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
896 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
897 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
898 XMesaDrawable buffer
= xrb
->pixmap
;
899 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
904 for (i
=0;i
<n
;i
++,x
++) {
906 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
907 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
912 /* draw all pixels */
913 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
915 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
917 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
923 * Write a span of PF_1BIT pixels to a pixmap.
925 static void put_row_1BIT_pixmap( PUT_ROW_ARGS
)
927 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
928 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
929 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
930 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
931 XMesaDrawable buffer
= xrb
->pixmap
;
932 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
937 for (i
=0;i
<n
;i
++,x
++) {
939 XMesaSetForeground( dpy
, gc
,
940 DITHER_1BIT( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
941 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
946 /* draw all pixels */
947 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
949 XMesaPutPixel( rowimg
, i
, 0,
950 DITHER_1BIT( x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
952 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
958 * Write a span of PF_1BIT pixels to a pixmap (no alpha).
960 static void put_row_rgb_1BIT_pixmap( RGB_SPAN_ARGS
)
962 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
963 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
964 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
965 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
966 XMesaDrawable buffer
= xrb
->pixmap
;
967 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
972 for (i
=0;i
<n
;i
++,x
++) {
974 XMesaSetForeground( dpy
, gc
,
975 DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
976 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
981 /* draw all pixels */
982 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
984 XMesaPutPixel( rowimg
, i
, 0,
985 DITHER_1BIT(x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
987 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
993 * Write a span of PF_HPCR pixels to a pixmap.
995 static void put_row_HPCR_pixmap( PUT_ROW_ARGS
)
997 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
998 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
999 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1000 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1001 XMesaDrawable buffer
= xrb
->pixmap
;
1002 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1006 for (i
=0;i
<n
;i
++,x
++) {
1008 XMesaSetForeground( dpy
, gc
,
1009 DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1010 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1015 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1016 register GLubyte
*ptr
= (GLubyte
*) XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
->data
;
1018 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1020 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1026 * Write a span of PF_HPCR pixels to a pixmap (no alpha).
1028 static void put_row_rgb_HPCR_pixmap( RGB_SPAN_ARGS
)
1030 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1031 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1032 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1033 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1034 XMesaDrawable buffer
= xrb
->pixmap
;
1035 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1039 for (i
=0;i
<n
;i
++,x
++) {
1041 XMesaSetForeground( dpy
, gc
,
1042 DITHER_HPCR(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
1043 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1048 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1049 register GLubyte
*ptr
= (GLubyte
*) XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
->data
;
1051 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1053 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1058 * Write a span of PF_LOOKUP pixels to a pixmap.
1060 static void put_row_LOOKUP_pixmap( PUT_ROW_ARGS
)
1062 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1063 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1064 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1065 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1066 XMesaDrawable buffer
= xrb
->pixmap
;
1067 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1072 for (i
=0;i
<n
;i
++,x
++) {
1074 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1075 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1080 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1082 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
1084 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1090 * Write a span of PF_LOOKUP pixels to a pixmap (no alpha).
1092 static void put_row_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS
)
1094 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1095 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1096 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1097 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1098 XMesaDrawable buffer
= xrb
->pixmap
;
1099 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1104 for (i
=0;i
<n
;i
++,x
++) {
1106 XMesaSetForeground( dpy
, gc
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1107 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1112 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1114 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1116 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1122 * Write a span of PF_GRAYSCALE pixels to a pixmap.
1124 static void put_row_GRAYSCALE_pixmap( PUT_ROW_ARGS
)
1126 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1127 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1128 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1129 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1130 XMesaDrawable buffer
= xrb
->pixmap
;
1131 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1135 for (i
=0;i
<n
;i
++,x
++) {
1137 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1138 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1143 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1145 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
1147 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1153 * Write a span of PF_GRAYSCALE pixels to a pixmap (no alpha).
1155 static void put_row_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS
)
1157 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1158 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1159 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1160 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1161 XMesaDrawable buffer
= xrb
->pixmap
;
1162 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1166 for (i
=0;i
<n
;i
++,x
++) {
1168 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1169 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1174 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1176 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1178 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1183 * Write a span of PF_TRUECOLOR pixels to an XImage.
1185 static void put_row_TRUECOLOR_ximage( PUT_ROW_ARGS
)
1187 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1188 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1189 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1190 XMesaImage
*img
= xrb
->ximage
;
1194 for (i
=0;i
<n
;i
++,x
++) {
1197 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1198 XMesaPutPixel( img
, x
, y
, p
);
1203 /* draw all pixels */
1204 for (i
=0;i
<n
;i
++,x
++) {
1206 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1207 XMesaPutPixel( img
, x
, y
, p
);
1214 * Write a span of PF_TRUECOLOR pixels to an XImage (no alpha).
1216 static void put_row_rgb_TRUECOLOR_ximage( RGB_SPAN_ARGS
)
1218 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1219 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1220 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1221 XMesaImage
*img
= xrb
->ximage
;
1225 for (i
=0;i
<n
;i
++,x
++) {
1228 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1229 XMesaPutPixel( img
, x
, y
, p
);
1234 /* draw all pixels */
1235 for (i
=0;i
<n
;i
++,x
++) {
1237 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1238 XMesaPutPixel( img
, x
, y
, p
);
1245 * Write a span of PF_TRUEDITHER pixels to an XImage.
1247 static void put_row_TRUEDITHER_ximage( PUT_ROW_ARGS
)
1249 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1250 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1251 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1252 XMesaImage
*img
= xrb
->ximage
;
1256 for (i
=0;i
<n
;i
++,x
++) {
1259 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1260 XMesaPutPixel( img
, x
, y
, p
);
1265 /* draw all pixels */
1266 for (i
=0;i
<n
;i
++,x
++) {
1268 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1269 XMesaPutPixel( img
, x
, y
, p
);
1276 * Write a span of PF_TRUEDITHER pixels to an XImage (no alpha).
1278 static void put_row_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS
)
1280 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1281 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1282 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1283 XMesaImage
*img
= xrb
->ximage
;
1287 for (i
=0;i
<n
;i
++,x
++) {
1290 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1291 XMesaPutPixel( img
, x
, y
, p
);
1296 /* draw all pixels */
1297 for (i
=0;i
<n
;i
++,x
++) {
1299 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1300 XMesaPutPixel( img
, x
, y
, p
);
1307 * Write a span of PF_8A8B8G8R-format pixels to an ximage.
1309 static void put_row_8A8B8G8R_ximage( PUT_ROW_ARGS
)
1311 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1312 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1314 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1318 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1323 /* draw all pixels */
1325 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1332 * Write a span of PF_8A8B8G8R-format pixels to an ximage (no alpha).
1334 static void put_row_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS
)
1336 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1337 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1339 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1343 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1348 /* draw all pixels */
1350 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1356 * Write a span of PF_8A8R8G8B-format pixels to an ximage.
1358 static void put_row_8A8R8G8B_ximage( PUT_ROW_ARGS
)
1360 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1361 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1363 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1367 ptr
[i
] = PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1372 /* draw all pixels */
1374 ptr
[i
] = PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1381 * Write a span of PF_8A8R8G8B-format pixels to an ximage (no alpha).
1383 static void put_row_rgb_8A8R8G8B_ximage( RGB_SPAN_ARGS
)
1385 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1386 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1388 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1392 ptr
[i
] = PACK_8A8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1397 /* draw all pixels */
1399 ptr
[i
] = PACK_8A8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1406 * Write a span of PF_8R8G8B-format pixels to an ximage.
1408 static void put_row_8R8G8B_ximage( PUT_ROW_ARGS
)
1410 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1411 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1413 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1417 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1423 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1430 * Write a span of PF_8R8G8B24-format pixels to an ximage.
1432 static void put_row_8R8G8B24_ximage( PUT_ROW_ARGS
)
1434 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1435 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1437 register GLubyte
*ptr
= (GLubyte
*) PIXEL_ADDR3(xrb
, x
, y
);
1441 GLuint
*ptr4
= (GLuint
*) ptr
;
1442 register GLuint pixel
= *ptr4
;
1443 switch (3 & (int)(ptr
- (GLubyte
*)ptr4
)) {
1445 pixel
&= 0xff000000;
1446 pixel
|= rgba
[i
][BCOMP
];
1447 pixel
|= rgba
[i
][GCOMP
] << 8;
1448 pixel
|= rgba
[i
][RCOMP
] << 16;
1452 pixel
&= 0x00ffffff;
1453 pixel
|= rgba
[i
][BCOMP
] << 24;
1455 pixel
= *ptr4
&& 0xffff0000;
1456 pixel
|= rgba
[i
][GCOMP
];
1457 pixel
|= rgba
[i
][RCOMP
] << 8;
1461 pixel
&= 0x0000ffff;
1462 pixel
|= rgba
[i
][BCOMP
] << 16;
1463 pixel
|= rgba
[i
][GCOMP
] << 24;
1465 pixel
= *ptr4
&& 0xffffff00;
1466 pixel
|= rgba
[i
][RCOMP
];
1470 pixel
&= 0x000000ff;
1471 pixel
|= rgba
[i
][BCOMP
] << 8;
1472 pixel
|= rgba
[i
][GCOMP
] << 16;
1473 pixel
|= rgba
[i
][RCOMP
] << 24;
1482 /* write all pixels */
1484 GLuint
*ptr4
= (GLuint
*) ptr
;
1485 register GLuint pixel
= *ptr4
;
1486 int index
= (int)(ptr
- (GLubyte
*)ptr4
);
1487 register GLuint i
= 0;
1492 pixel
&= 0x00ffffff;
1493 pixel
|= rgba
[i
][BCOMP
] << 24;
1495 pixel
= *ptr4
&& 0xffff0000;
1496 pixel
|= rgba
[i
][GCOMP
];
1497 pixel
|= rgba
[i
++][RCOMP
] << 8;
1502 pixel
&= 0x0000ffff;
1503 pixel
|= rgba
[i
][BCOMP
] << 16;
1504 pixel
|= rgba
[i
][GCOMP
] << 24;
1506 pixel
= *ptr4
&& 0xffffff00;
1507 pixel
|= rgba
[i
++][RCOMP
];
1512 pixel
&= 0x000000ff;
1513 pixel
|= rgba
[i
][BCOMP
] << 8;
1514 pixel
|= rgba
[i
][GCOMP
] << 16;
1515 pixel
|= rgba
[i
++][RCOMP
] << 24;
1522 pixel
= rgba
[i
][BCOMP
];
1523 pixel
|= rgba
[i
][GCOMP
] << 8;
1524 pixel
|= rgba
[i
++][RCOMP
] << 16;
1525 pixel
|= rgba
[i
][BCOMP
] << 24;
1527 pixel
= rgba
[i
][GCOMP
];
1528 pixel
|= rgba
[i
++][RCOMP
] << 8;
1529 pixel
|= rgba
[i
][BCOMP
] << 16;
1530 pixel
|= rgba
[i
][GCOMP
] << 24;
1532 pixel
= rgba
[i
++][RCOMP
];
1533 pixel
|= rgba
[i
][BCOMP
] << 8;
1534 pixel
|= rgba
[i
][GCOMP
] << 16;
1535 pixel
|= rgba
[i
++][RCOMP
] << 24;
1543 pixel
= *ptr4
& 0xff000000;
1544 pixel
|= rgba
[i
][BCOMP
];
1545 pixel
|= rgba
[i
][GCOMP
] << 8;
1546 pixel
|= rgba
[i
][RCOMP
] << 16;
1550 pixel
= rgba
[i
][BCOMP
];
1551 pixel
|= rgba
[i
][GCOMP
] << 8;
1552 pixel
|= rgba
[i
++][RCOMP
] << 16;
1553 pixel
|= rgba
[i
][BCOMP
] << 24;
1555 pixel
= *ptr4
& 0xffff0000;
1556 pixel
|= rgba
[i
][GCOMP
];
1557 pixel
|= rgba
[i
][RCOMP
] << 8;
1561 pixel
= rgba
[i
][BCOMP
];
1562 pixel
|= rgba
[i
][GCOMP
] << 8;
1563 pixel
|= rgba
[i
++][RCOMP
] << 16;
1564 pixel
|= rgba
[i
][BCOMP
] << 24;
1566 pixel
= rgba
[i
][GCOMP
];
1567 pixel
|= rgba
[i
++][RCOMP
] << 8;
1568 pixel
|= rgba
[i
][BCOMP
] << 16;
1569 pixel
|= rgba
[i
][GCOMP
] << 24;
1571 pixel
= *ptr4
& 0xffffff00;
1572 pixel
|= rgba
[i
][RCOMP
];
1581 * Write a span of PF_8R8G8B-format pixels to an ximage (no alpha).
1583 static void put_row_rgb_8R8G8B_ximage( RGB_SPAN_ARGS
)
1585 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1586 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1588 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1592 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1597 /* draw all pixels */
1599 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1606 * Write a span of PF_8R8G8B24-format pixels to an ximage (no alpha).
1608 static void put_row_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS
)
1610 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1611 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1613 register GLubyte
*ptr
= (GLubyte
*) PIXEL_ADDR3(xrb
, x
, y
);
1617 *ptr
++ = rgb
[i
][BCOMP
];
1618 *ptr
++ = rgb
[i
][GCOMP
];
1619 *ptr
++ = rgb
[i
][RCOMP
];
1627 /* draw all pixels */
1629 *ptr
++ = rgb
[i
][BCOMP
];
1630 *ptr
++ = rgb
[i
][GCOMP
];
1631 *ptr
++ = rgb
[i
][RCOMP
];
1638 * Write a span of PF_5R6G5B-format pixels to an ximage.
1640 static void put_row_5R6G5B_ximage( PUT_ROW_ARGS
)
1642 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1643 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1645 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1649 ptr
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1654 /* draw all pixels */
1655 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1656 GLuint
*ptr32
= (GLuint
*) ptr
;
1657 GLuint extraPixel
= (n
& 1);
1659 for (i
= 0; i
< n
; i
+= 2) {
1661 p0
= PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1662 p1
= PACK_5R6G5B(rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
]);
1663 *ptr32
++ = (p1
<< 16) | p0
;
1666 ptr
[n
] = PACK_5R6G5B(rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1669 for (i
= 0; i
< n
; i
++) {
1670 ptr
[i
] = PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1678 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage.
1680 static void put_row_DITHER_5R6G5B_ximage( PUT_ROW_ARGS
)
1682 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1683 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1684 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1686 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1687 const GLint y2
= YFLIP(xrb
, y
);
1689 for (i
=0;i
<n
;i
++,x
++) {
1691 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1696 /* draw all pixels */
1697 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1698 GLuint
*ptr32
= (GLuint
*) ptr
;
1699 GLuint extraPixel
= (n
& 1);
1701 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1703 PACK_TRUEDITHER( p0
, x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1704 PACK_TRUEDITHER( p1
, x
+1, y2
, rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
] );
1705 *ptr32
++ = (p1
<< 16) | p0
;
1708 PACK_TRUEDITHER( ptr
[n
], x
+n
, y2
, rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1711 for (i
= 0; i
< n
; i
++, x
++) {
1712 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1720 * Write a span of PF_5R6G5B-format pixels to an ximage (no alpha).
1722 static void put_row_rgb_5R6G5B_ximage( RGB_SPAN_ARGS
)
1724 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1725 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1727 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1731 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1736 /* draw all pixels */
1737 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1738 GLuint
*ptr32
= (GLuint
*) ptr
;
1739 GLuint extraPixel
= (n
& 1);
1741 for (i
= 0; i
< n
; i
+= 2) {
1743 p0
= PACK_5R6G5B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1744 p1
= PACK_5R6G5B(rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
]);
1745 *ptr32
++ = (p1
<< 16) | p0
;
1748 ptr
[n
] = PACK_5R6G5B(rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1752 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1760 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage (no alpha).
1762 static void put_row_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS
)
1764 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1765 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1766 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1768 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1770 for (i
=0;i
<n
;i
++,x
++) {
1772 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1777 /* draw all pixels */
1778 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1779 GLuint
*ptr32
= (GLuint
*) ptr
;
1780 GLuint extraPixel
= (n
& 1);
1782 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1784 PACK_TRUEDITHER( p0
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1785 PACK_TRUEDITHER( p1
, x
+1, y
, rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
] );
1786 *ptr32
++ = (p1
<< 16) | p0
;
1789 PACK_TRUEDITHER( ptr
[n
], x
+n
, y
, rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1792 for (i
=0;i
<n
;i
++,x
++) {
1793 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1801 * Write a span of PF_DITHER pixels to an XImage.
1803 static void put_row_DITHER_ximage( PUT_ROW_ARGS
)
1805 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1806 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1807 XMesaImage
*img
= xrb
->ximage
;
1809 int yy
= YFLIP(xrb
, y
);
1812 for (i
=0;i
<n
;i
++,x
++) {
1814 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1819 /* draw all pixels */
1820 for (i
=0;i
<n
;i
++,x
++) {
1821 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1828 * Write a span of PF_DITHER pixels to an XImage (no alpha).
1830 static void put_row_rgb_DITHER_ximage( RGB_SPAN_ARGS
)
1832 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1833 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1834 XMesaImage
*img
= xrb
->ximage
;
1836 int yy
= YFLIP(xrb
, y
);
1839 for (i
=0;i
<n
;i
++,x
++) {
1841 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1846 /* draw all pixels */
1847 for (i
=0;i
<n
;i
++,x
++) {
1848 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1856 * Write a span of 8-bit PF_DITHER pixels to an XImage.
1858 static void put_row_DITHER8_ximage( PUT_ROW_ARGS
)
1860 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1861 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1863 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
1866 for (i
=0;i
<n
;i
++,x
++) {
1868 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1873 for (i
=0;i
<n
;i
++,x
++) {
1874 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1880 static void put_row_rgb_DITHER8_ximage( RGB_SPAN_ARGS
)
1882 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1883 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1885 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
1888 for (i
=0;i
<n
;i
++,x
++) {
1890 ptr
[i
] = (GLubyte
) XDITHER( x
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
1895 const GLubyte
*data
= (GLubyte
*) rgb
;
1896 for (i
=0;i
<n
;i
++,x
++) {
1897 /*ptr[i] = XDITHER( x, rgb[i][0], rgb[i][1], rgb[i][2] );*/
1898 ptr
[i
] = (GLubyte
) XDITHER( x
, data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
1906 * Write a span of PF_1BIT pixels to an XImage.
1908 static void put_row_1BIT_ximage( PUT_ROW_ARGS
)
1910 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1911 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1912 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1913 XMesaImage
*img
= xrb
->ximage
;
1918 for (i
=0;i
<n
;i
++,x
++) {
1920 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]));
1925 for (i
=0;i
<n
;i
++,x
++) {
1926 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
1933 * Write a span of PF_1BIT pixels to an XImage (no alpha).
1935 static void put_row_rgb_1BIT_ximage( RGB_SPAN_ARGS
)
1937 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1938 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1939 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1940 XMesaImage
*img
= xrb
->ximage
;
1945 for (i
=0;i
<n
;i
++,x
++) {
1947 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]));
1952 for (i
=0;i
<n
;i
++,x
++) {
1953 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
1960 * Write a span of PF_HPCR pixels to an XImage.
1962 static void put_row_HPCR_ximage( PUT_ROW_ARGS
)
1964 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1965 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1966 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1968 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
1970 for (i
=0;i
<n
;i
++,x
++) {
1972 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1977 /* draw all pixels */
1978 for (i
=0;i
<n
;i
++,x
++) {
1979 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1986 * Write a span of PF_HPCR pixels to an XImage (no alpha).
1988 static void put_row_rgb_HPCR_ximage( RGB_SPAN_ARGS
)
1990 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1991 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
1992 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1994 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
1996 for (i
=0;i
<n
;i
++,x
++) {
1998 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2003 /* draw all pixels */
2004 for (i
=0;i
<n
;i
++,x
++) {
2005 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2012 * Write a span of PF_LOOKUP pixels to an XImage.
2014 static void put_row_LOOKUP_ximage( PUT_ROW_ARGS
)
2016 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2017 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2018 XMesaImage
*img
= xrb
->ximage
;
2023 for (i
=0;i
<n
;i
++,x
++) {
2025 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2030 /* draw all pixels */
2031 for (i
=0;i
<n
;i
++,x
++) {
2032 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2039 * Write a span of PF_LOOKUP pixels to an XImage (no alpha).
2041 static void put_row_rgb_LOOKUP_ximage( RGB_SPAN_ARGS
)
2043 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2044 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2045 XMesaImage
*img
= xrb
->ximage
;
2050 for (i
=0;i
<n
;i
++,x
++) {
2052 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2057 /* draw all pixels */
2058 for (i
=0;i
<n
;i
++,x
++) {
2059 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2066 * Write a span of 8-bit PF_LOOKUP pixels to an XImage.
2068 static void put_row_LOOKUP8_ximage( PUT_ROW_ARGS
)
2070 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2071 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2073 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2076 for (i
=0;i
<n
;i
++,x
++) {
2078 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2083 /* draw all pixels */
2084 for (i
=0;i
<n
;i
++,x
++) {
2085 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2091 static void put_row_rgb_LOOKUP8_ximage( RGB_SPAN_ARGS
)
2093 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2094 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2096 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2099 for (i
=0;i
<n
;i
++,x
++) {
2101 ptr
[i
] = (GLubyte
) LOOKUP( rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
2106 /* draw all pixels */
2107 const GLubyte
*data
= (GLubyte
*) rgb
;
2108 for (i
=0;i
<n
;i
++,x
++) {
2109 /*ptr[i] = LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );*/
2110 ptr
[i
] = (GLubyte
) LOOKUP( data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
2117 * Write a span of PF_GRAYSCALE pixels to an XImage.
2119 static void put_row_GRAYSCALE_ximage( PUT_ROW_ARGS
)
2121 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2122 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2123 XMesaImage
*img
= xrb
->ximage
;
2127 for (i
=0;i
<n
;i
++,x
++) {
2129 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2134 /* draw all pixels */
2135 for (i
=0;i
<n
;i
++,x
++) {
2136 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2143 * Write a span of PF_GRAYSCALE pixels to an XImage (no alpha).
2145 static void put_row_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS
)
2147 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2148 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2149 XMesaImage
*img
= xrb
->ximage
;
2153 for (i
=0;i
<n
;i
++,x
++) {
2155 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2160 /* draw all pixels */
2161 for (i
=0;i
<n
;i
++,x
++) {
2162 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2169 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage.
2171 static void put_row_GRAYSCALE8_ximage( PUT_ROW_ARGS
)
2173 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2174 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2176 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2180 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2185 /* draw all pixels */
2187 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2194 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage (no alpha).
2196 static void put_row_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS
)
2198 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2199 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2201 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2205 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2210 /* draw all pixels */
2212 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2220 /**********************************************************************/
2221 /*** Write COLOR PIXEL functions ***/
2222 /**********************************************************************/
2225 #define PUT_VALUES_ARGS \
2226 GLcontext *ctx, struct gl_renderbuffer *rb, \
2227 GLuint n, const GLint x[], const GLint y[], \
2228 const void *values, const GLubyte mask[]
2232 * Write an array of PF_TRUECOLOR pixels to a pixmap.
2234 static void put_values_TRUECOLOR_pixmap( PUT_VALUES_ARGS
)
2236 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2237 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2238 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2239 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2240 XMesaDrawable buffer
= xrb
->pixmap
;
2241 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2246 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2247 XMesaSetForeground( dpy
, gc
, p
);
2248 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2255 * Write an array of PF_TRUEDITHER pixels to a pixmap.
2257 static void put_values_TRUEDITHER_pixmap( PUT_VALUES_ARGS
)
2259 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2260 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2261 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2262 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2263 XMesaDrawable buffer
= xrb
->pixmap
;
2264 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2269 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2270 XMesaSetForeground( dpy
, gc
, p
);
2271 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2278 * Write an array of PF_8A8B8G8R pixels to a pixmap.
2280 static void put_values_8A8B8G8R_pixmap( PUT_VALUES_ARGS
)
2282 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2283 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2284 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2285 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2286 XMesaDrawable buffer
= xrb
->pixmap
;
2287 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2291 XMesaSetForeground( dpy
, gc
,
2292 PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] ));
2293 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2299 * Write an array of PF_8A8R8G8B pixels to a pixmap.
2301 static void put_values_8A8R8G8B_pixmap( PUT_VALUES_ARGS
)
2303 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2304 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2305 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2306 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2307 XMesaDrawable buffer
= xrb
->pixmap
;
2308 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2312 XMesaSetForeground( dpy
, gc
,
2313 PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] ));
2314 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2320 * Write an array of PF_8R8G8B pixels to a pixmap.
2322 static void put_values_8R8G8B_pixmap( PUT_VALUES_ARGS
)
2324 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2325 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2326 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2327 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2328 XMesaDrawable buffer
= xrb
->pixmap
;
2329 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2333 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2334 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2341 * Write an array of PF_8R8G8B24 pixels to a pixmap.
2343 static void put_values_8R8G8B24_pixmap( PUT_VALUES_ARGS
)
2345 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2346 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2347 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2348 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2349 XMesaDrawable buffer
= xrb
->pixmap
;
2350 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2354 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2355 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2362 * Write an array of PF_5R6G5B pixels to a pixmap.
2364 static void put_values_5R6G5B_pixmap( PUT_VALUES_ARGS
)
2366 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2367 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2368 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2369 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2370 XMesaDrawable buffer
= xrb
->pixmap
;
2371 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2375 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2376 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2383 * Write an array of PF_DITHER_5R6G5B pixels to a pixmap.
2385 static void put_values_DITHER_5R6G5B_pixmap( PUT_VALUES_ARGS
)
2387 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2388 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2389 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2390 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2391 XMesaDrawable buffer
= xrb
->pixmap
;
2392 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2397 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2398 XMesaSetForeground( dpy
, gc
, p
);
2399 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2406 * Write an array of PF_DITHER pixels to a pixmap.
2408 static void put_values_DITHER_pixmap( PUT_VALUES_ARGS
)
2410 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2411 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2412 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2413 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2414 XMesaDrawable buffer
= xrb
->pixmap
;
2415 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2420 XMesaSetForeground( dpy
, gc
,
2421 DITHER(x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2422 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2429 * Write an array of PF_1BIT pixels to a pixmap.
2431 static void put_values_1BIT_pixmap( PUT_VALUES_ARGS
)
2433 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2434 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2435 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2436 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2437 XMesaDrawable buffer
= xrb
->pixmap
;
2438 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2443 XMesaSetForeground( dpy
, gc
,
2444 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2445 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2452 * Write an array of PF_HPCR pixels to a pixmap.
2454 static void put_values_HPCR_pixmap( PUT_VALUES_ARGS
)
2456 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2457 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2458 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2459 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2460 XMesaDrawable buffer
= xrb
->pixmap
;
2461 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2465 XMesaSetForeground( dpy
, gc
,
2466 DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2467 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2474 * Write an array of PF_LOOKUP pixels to a pixmap.
2476 static void put_values_LOOKUP_pixmap( PUT_VALUES_ARGS
)
2478 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2479 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2480 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2481 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2482 XMesaDrawable buffer
= xrb
->pixmap
;
2483 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2488 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2489 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2496 * Write an array of PF_GRAYSCALE pixels to a pixmap.
2498 static void put_values_GRAYSCALE_pixmap( PUT_VALUES_ARGS
)
2500 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2501 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2502 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2503 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2504 XMesaDrawable buffer
= xrb
->pixmap
;
2505 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2509 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2510 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2517 * Write an array of PF_TRUECOLOR pixels to an ximage.
2519 static void put_values_TRUECOLOR_ximage( PUT_VALUES_ARGS
)
2521 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2522 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2523 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2524 XMesaImage
*img
= xrb
->ximage
;
2529 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2530 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), p
);
2537 * Write an array of PF_TRUEDITHER pixels to an XImage.
2539 static void put_values_TRUEDITHER_ximage( PUT_VALUES_ARGS
)
2541 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2542 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2543 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2544 XMesaImage
*img
= xrb
->ximage
;
2549 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2550 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), p
);
2557 * Write an array of PF_8A8B8G8R pixels to an ximage.
2559 static void put_values_8A8B8G8R_ximage( PUT_VALUES_ARGS
)
2561 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2562 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2566 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
2567 *ptr
= PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
2573 * Write an array of PF_8A8R8G8B pixels to an ximage.
2575 static void put_values_8A8R8G8B_ximage( PUT_VALUES_ARGS
)
2577 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2578 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2582 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
2583 *ptr
= PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
2590 * Write an array of PF_8R8G8B pixels to an ximage.
2592 static void put_values_8R8G8B_ximage( PUT_VALUES_ARGS
)
2594 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2595 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2599 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
2600 *ptr
= PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2607 * Write an array of PF_8R8G8B24 pixels to an ximage.
2609 static void put_values_8R8G8B24_ximage( PUT_VALUES_ARGS
)
2611 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2612 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2616 bgr_t
*ptr
= PIXEL_ADDR3(xrb
, x
[i
], y
[i
] );
2617 ptr
->r
= rgba
[i
][RCOMP
];
2618 ptr
->g
= rgba
[i
][GCOMP
];
2619 ptr
->b
= rgba
[i
][BCOMP
];
2626 * Write an array of PF_5R6G5B pixels to an ximage.
2628 static void put_values_5R6G5B_ximage( PUT_VALUES_ARGS
)
2630 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2631 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2635 GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
[i
], y
[i
] );
2636 *ptr
= PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2643 * Write an array of PF_DITHER_5R6G5B pixels to an ximage.
2645 static void put_values_DITHER_5R6G5B_ximage( PUT_VALUES_ARGS
)
2647 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2648 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2649 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2653 GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
[i
], y
[i
] );
2654 PACK_TRUEDITHER( *ptr
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2661 * Write an array of PF_DITHER pixels to an XImage.
2663 static void put_values_DITHER_ximage( PUT_VALUES_ARGS
)
2665 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2666 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2667 XMesaImage
*img
= xrb
->ximage
;
2672 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
2673 DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2680 * Write an array of 8-bit PF_DITHER pixels to an XImage.
2682 static void put_values_DITHER8_ximage( PUT_VALUES_ARGS
)
2684 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2685 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2690 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
2691 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2698 * Write an array of PF_1BIT pixels to an XImage.
2700 static void put_values_1BIT_ximage( PUT_VALUES_ARGS
)
2702 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2703 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2704 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2705 XMesaImage
*img
= xrb
->ximage
;
2710 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
2711 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2718 * Write an array of PF_HPCR pixels to an XImage.
2720 static void put_values_HPCR_ximage( PUT_VALUES_ARGS
)
2722 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2723 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2724 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2728 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
2729 *ptr
= (GLubyte
) DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2736 * Write an array of PF_LOOKUP pixels to an XImage.
2738 static void put_values_LOOKUP_ximage( PUT_VALUES_ARGS
)
2740 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2741 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2742 XMesaImage
*img
= xrb
->ximage
;
2747 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), LOOKUP(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2754 * Write an array of 8-bit PF_LOOKUP pixels to an XImage.
2756 static void put_values_LOOKUP8_ximage( PUT_VALUES_ARGS
)
2758 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2759 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2764 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
2765 *ptr
= (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2772 * Write an array of PF_GRAYSCALE pixels to an XImage.
2774 static void put_values_GRAYSCALE_ximage( PUT_VALUES_ARGS
)
2776 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2777 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2778 XMesaImage
*img
= xrb
->ximage
;
2782 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
2783 GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2790 * Write an array of 8-bit PF_GRAYSCALE pixels to an XImage.
2792 static void put_values_GRAYSCALE8_ximage( PUT_VALUES_ARGS
)
2794 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2795 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2799 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
] );
2800 *ptr
= (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2808 /**********************************************************************/
2809 /*** Write MONO COLOR SPAN functions ***/
2810 /**********************************************************************/
2812 #define PUT_MONO_ROW_ARGS \
2813 GLcontext *ctx, struct gl_renderbuffer *rb, \
2814 GLuint n, GLint x, GLint y, const void *value, \
2815 const GLubyte mask[]
2820 * Write a span of identical pixels to a pixmap.
2822 static void put_mono_row_pixmap( PUT_MONO_ROW_ARGS
)
2824 const GLubyte
*color
= (const GLubyte
*) value
;
2825 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2826 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2827 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2828 XMesaDrawable buffer
= xrb
->pixmap
;
2829 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2830 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
2831 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2833 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
2836 /* New code contributed by Jeff Epler and cleaned up by Keith
2839 for (i
= 0; i
< n
; ) {
2842 /* Identify and emit contiguous rendered pixels
2844 while (i
< n
&& (!mask
|| mask
[i
]))
2848 XMesaFillRectangle( dpy
, buffer
, gc
,
2849 (int)(x
+start
), (int) y
,
2852 /* Eat up non-rendered pixels
2854 while (i
< n
&& !mask
[i
])
2862 put_mono_row_ci_pixmap( PUT_MONO_ROW_ARGS
)
2864 GLuint colorIndex
= *((GLuint
*) value
);
2865 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2866 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2867 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2868 XMesaDrawable buffer
= xrb
->pixmap
;
2869 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2871 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
2874 for (i
= 0 ; i
< n
;) {
2877 /* Identify and emit contiguous rendered pixels
2879 while (i
< n
&& (!mask
|| mask
[i
]))
2883 XMesaFillRectangle( dpy
, buffer
, gc
,
2884 (int)(x
+start
), (int) y
,
2887 /* Eat up non-rendered pixels
2889 while (i
< n
&& !mask
[i
])
2897 * Write a span of PF_TRUEDITHER pixels to a pixmap.
2899 static void put_mono_row_TRUEDITHER_pixmap( PUT_MONO_ROW_ARGS
)
2901 const GLubyte
*color
= (const GLubyte
*) value
;
2902 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2903 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2904 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2905 XMesaDrawable buffer
= xrb
->pixmap
;
2906 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2907 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2909 int yy
= YFLIP(xrb
, y
);
2910 for (i
=0;i
<n
;i
++,x
++) {
2911 if (!mask
|| mask
[i
]) {
2913 PACK_TRUEDITHER(p
, x
, yy
, r
, g
, b
);
2914 XMesaSetForeground( dpy
, gc
, p
);
2915 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2922 * Write a span of PF_DITHER pixels to a pixmap.
2924 static void put_mono_row_DITHER_pixmap( PUT_MONO_ROW_ARGS
)
2926 const GLubyte
*color
= (const GLubyte
*) value
;
2927 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2928 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2929 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2930 XMesaDrawable buffer
= xrb
->pixmap
;
2931 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2932 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2934 int yy
= YFLIP(xrb
, y
);
2936 for (i
=0;i
<n
;i
++,x
++) {
2937 if (!mask
|| mask
[i
]) {
2938 XMesaSetForeground( dpy
, gc
, XDITHER( x
, r
, g
, b
) );
2939 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2946 * Write a span of PF_1BIT pixels to a pixmap.
2948 static void put_mono_row_1BIT_pixmap( PUT_MONO_ROW_ARGS
)
2950 const GLubyte
*color
= (const GLubyte
*) value
;
2951 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2952 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2953 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2954 XMesaDrawable buffer
= xrb
->pixmap
;
2955 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2956 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2960 for (i
=0;i
<n
;i
++,x
++) {
2961 if (!mask
|| mask
[i
]) {
2962 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
, y
, r
, g
, b
) );
2963 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
2970 * Write a span of identical pixels to an XImage.
2972 static void put_mono_row_ximage( PUT_MONO_ROW_ARGS
)
2974 const GLubyte
*color
= (const GLubyte
*) value
;
2975 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2976 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2977 XMesaImage
*img
= xrb
->ximage
;
2979 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
2980 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2982 for (i
=0;i
<n
;i
++,x
++) {
2983 if (!mask
|| mask
[i
]) {
2984 XMesaPutPixel( img
, x
, y
, pixel
);
2991 put_mono_row_ci_ximage( PUT_MONO_ROW_ARGS
)
2993 const GLuint colorIndex
= *((GLuint
*) value
);
2994 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
2995 XMesaImage
*img
= xrb
->ximage
;
2998 for (i
=0;i
<n
;i
++,x
++) {
2999 if (!mask
|| mask
[i
]) {
3000 XMesaPutPixel( img
, x
, y
, colorIndex
);
3007 * Write a span of identical PF_TRUEDITHER pixels to an XImage.
3009 static void put_mono_row_TRUEDITHER_ximage( PUT_MONO_ROW_ARGS
)
3011 const GLubyte
*color
= (const GLubyte
*) value
;
3012 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3013 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3014 XMesaImage
*img
= xrb
->ximage
;
3015 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3019 if (!mask
|| mask
[i
]) {
3021 PACK_TRUEDITHER( p
, x
+i
, y
, r
, g
, b
);
3022 XMesaPutPixel( img
, x
+i
, y
, p
);
3029 * Write a span of identical 8A8B8G8R pixels to an XImage.
3031 static void put_mono_row_8A8B8G8R_ximage( PUT_MONO_ROW_ARGS
)
3033 const GLubyte
*color
= (const GLubyte
*) value
;
3034 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3035 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3037 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3038 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3039 ptr
= PIXEL_ADDR4(xrb
, x
, y
);
3041 if (!mask
|| mask
[i
]) {
3048 * Write a span of identical 8A8R8G8B pixels to an XImage.
3050 static void put_mono_row_8A8R8G8B_ximage( PUT_MONO_ROW_ARGS
)
3052 const GLubyte
*color
= (const GLubyte
*) value
;
3053 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3055 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3056 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3057 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3058 ptr
= PIXEL_ADDR4(xrb
, x
, y
);
3060 if (!mask
|| mask
[i
]) {
3068 * Write a span of identical 8R8G8B pixels to an XImage.
3070 static void put_mono_row_8R8G8B_ximage( PUT_MONO_ROW_ARGS
)
3072 const GLubyte
*color
= (const GLubyte
*) value
;
3073 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3074 const GLuint pixel
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3075 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
3078 if (!mask
|| mask
[i
]) {
3086 * Write a span of identical 8R8G8B pixels to an XImage.
3088 static void put_mono_row_8R8G8B24_ximage( PUT_MONO_ROW_ARGS
)
3090 const GLubyte
*color
= (const GLubyte
*) value
;
3091 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3092 const GLubyte r
= color
[RCOMP
];
3093 const GLubyte g
= color
[GCOMP
];
3094 const GLubyte b
= color
[BCOMP
];
3096 bgr_t
*ptr
= PIXEL_ADDR3(xrb
, x
, y
);
3098 if (!mask
|| mask
[i
]) {
3108 * Write a span of identical DITHER pixels to an XImage.
3110 static void put_mono_row_DITHER_ximage( PUT_MONO_ROW_ARGS
)
3112 const GLubyte
*color
= (const GLubyte
*) value
;
3113 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3114 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3115 XMesaImage
*img
= xrb
->ximage
;
3116 int yy
= YFLIP(xrb
, y
);
3119 for (i
=0;i
<n
;i
++,x
++) {
3120 if (!mask
|| mask
[i
]) {
3121 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, r
, g
, b
) );
3128 * Write a span of identical 8-bit DITHER pixels to an XImage.
3130 static void put_mono_row_DITHER8_ximage( PUT_MONO_ROW_ARGS
)
3132 const GLubyte
*color
= (const GLubyte
*) value
;
3133 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3134 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3135 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
3138 for (i
=0;i
<n
;i
++,x
++) {
3139 if (!mask
|| mask
[i
]) {
3140 ptr
[i
] = (GLubyte
) XDITHER( x
, r
, g
, b
);
3147 * Write a span of identical 8-bit LOOKUP pixels to an XImage.
3149 static void put_mono_row_LOOKUP8_ximage( PUT_MONO_ROW_ARGS
)
3151 const GLubyte
*color
= (const GLubyte
*) value
;
3152 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3154 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
3157 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3159 if (!mask
|| mask
[i
]) {
3167 * Write a span of identical PF_1BIT pixels to an XImage.
3169 static void put_mono_row_1BIT_ximage( PUT_MONO_ROW_ARGS
)
3171 const GLubyte
*color
= (const GLubyte
*) value
;
3172 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3173 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3174 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3175 XMesaImage
*img
= xrb
->ximage
;
3179 for (i
=0;i
<n
;i
++,x
++) {
3180 if (!mask
|| mask
[i
]) {
3181 XMesaPutPixel( img
, x
, y
, DITHER_1BIT( x
, y
, r
, g
, b
) );
3188 * Write a span of identical HPCR pixels to an XImage.
3190 static void put_mono_row_HPCR_ximage( PUT_MONO_ROW_ARGS
)
3192 const GLubyte
*color
= (const GLubyte
*) value
;
3193 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3194 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3195 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3196 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
3198 for (i
=0;i
<n
;i
++,x
++) {
3199 if (!mask
|| mask
[i
]) {
3200 ptr
[i
] = DITHER_HPCR( x
, y
, r
, g
, b
);
3207 * Write a span of identical 8-bit GRAYSCALE pixels to an XImage.
3209 static void put_mono_row_GRAYSCALE8_ximage( PUT_MONO_ROW_ARGS
)
3211 const GLubyte
*color
= (const GLubyte
*) value
;
3212 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3213 const GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3214 GLubyte
*ptr
= (GLubyte
*) PIXEL_ADDR1(xrb
, x
, y
);
3217 if (!mask
|| mask
[i
]) {
3226 * Write a span of identical PF_DITHER_5R6G5B pixels to an XImage.
3228 static void put_mono_row_DITHER_5R6G5B_ximage( PUT_MONO_ROW_ARGS
)
3230 const GLubyte
*color
= (const GLubyte
*) value
;
3231 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3232 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3233 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
3234 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3238 if (!mask
|| mask
[i
]) {
3239 PACK_TRUEDITHER(ptr
[i
], x
+i
, y
, r
, g
, b
);
3246 /**********************************************************************/
3247 /*** Write MONO COLOR PIXELS functions ***/
3248 /**********************************************************************/
3250 #define PUT_MONO_VALUES_ARGS \
3251 GLcontext *ctx, struct gl_renderbuffer *rb, \
3252 GLuint n, const GLint x[], const GLint y[], \
3253 const void *value, const GLubyte mask[]
3258 * Write an array of identical pixels to a pixmap.
3260 static void put_mono_values_pixmap( PUT_MONO_VALUES_ARGS
)
3262 const GLubyte
*color
= (const GLubyte
*) value
;
3263 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3264 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3265 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3266 XMesaDrawable buffer
= xrb
->pixmap
;
3267 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3269 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3270 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3271 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
3274 XMesaDrawPoint( dpy
, buffer
, gc
,
3275 (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3282 put_mono_values_ci_pixmap( PUT_MONO_VALUES_ARGS
)
3284 const GLuint colorIndex
= *((GLuint
*) value
);
3285 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3286 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3287 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3288 XMesaDrawable buffer
= xrb
->pixmap
;
3289 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3291 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
3294 XMesaDrawPoint( dpy
, buffer
, gc
,
3295 (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3302 * Write an array of PF_TRUEDITHER pixels to a pixmap.
3304 static void put_mono_values_TRUEDITHER_pixmap( PUT_MONO_VALUES_ARGS
)
3306 const GLubyte
*color
= (const GLubyte
*) value
;
3307 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3308 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3309 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3310 XMesaDrawable buffer
= xrb
->pixmap
;
3311 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3313 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3317 PACK_TRUEDITHER(p
, x
[i
], y
[i
], r
, g
, b
);
3318 XMesaSetForeground( dpy
, gc
, p
);
3319 XMesaDrawPoint( dpy
, buffer
, gc
,
3320 (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3327 * Write an array of PF_DITHER pixels to a pixmap.
3329 static void put_mono_values_DITHER_pixmap( PUT_MONO_VALUES_ARGS
)
3331 const GLubyte
*color
= (const GLubyte
*) value
;
3332 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3333 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3334 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3335 XMesaDrawable buffer
= xrb
->pixmap
;
3336 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3338 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3342 XMesaSetForeground( dpy
, gc
, DITHER( x
[i
], y
[i
], r
, g
, b
) );
3343 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3350 * Write an array of PF_1BIT pixels to a pixmap.
3352 static void put_mono_values_1BIT_pixmap( PUT_MONO_VALUES_ARGS
)
3354 const GLubyte
*color
= (const GLubyte
*) value
;
3355 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3356 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3357 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3358 XMesaDrawable buffer
= xrb
->pixmap
;
3359 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3361 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3365 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
) );
3366 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3373 * Write an array of identical pixels to an XImage.
3375 static void put_mono_values_ximage( PUT_MONO_VALUES_ARGS
)
3377 const GLubyte
*color
= (const GLubyte
*) value
;
3378 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3379 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3380 XMesaImage
*img
= xrb
->ximage
;
3382 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3383 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3386 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), pixel
);
3393 put_mono_values_ci_ximage( PUT_MONO_VALUES_ARGS
)
3395 const GLuint colorIndex
= *((GLuint
*) value
);
3396 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3397 XMesaImage
*img
= xrb
->ximage
;
3401 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), colorIndex
);
3408 * Write an array of identical TRUEDITHER pixels to an XImage.
3410 static void put_mono_values_TRUEDITHER_ximage( PUT_MONO_VALUES_ARGS
)
3412 const GLubyte
*color
= (const GLubyte
*) value
;
3413 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3414 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3415 XMesaImage
*img
= xrb
->ximage
;
3417 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3421 PACK_TRUEDITHER(p
, x
[i
], YFLIP(xrb
, y
[i
]), r
, g
, b
);
3422 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), p
);
3430 * Write an array of identical 8A8B8G8R pixels to an XImage
3432 static void put_mono_values_8A8B8G8R_ximage( PUT_MONO_VALUES_ARGS
)
3434 const GLubyte
*color
= (const GLubyte
*) value
;
3435 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3436 const GLuint p
= PACK_8A8B8G8R(color
[RCOMP
], color
[GCOMP
],
3437 color
[BCOMP
], color
[ACOMP
]);
3441 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
3448 * Write an array of identical 8A8R8G8B pixels to an XImage
3450 static void put_mono_values_8A8R8G8B_ximage( PUT_MONO_VALUES_ARGS
)
3452 const GLubyte
*color
= (const GLubyte
*) value
;
3453 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3454 const GLuint p
= PACK_8A8R8G8B(color
[RCOMP
], color
[GCOMP
],
3455 color
[BCOMP
], color
[ACOMP
]);
3459 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
3466 * Write an array of identical 8R8G8B pixels to an XImage.
3468 static void put_mono_values_8R8G8B_ximage( PUT_MONO_VALUES_ARGS
)
3470 const GLubyte
*color
= (const GLubyte
*) value
;
3471 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3473 const GLuint p
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3476 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
3484 * Write an array of identical 8R8G8B pixels to an XImage.
3486 static void put_mono_values_8R8G8B24_ximage( PUT_MONO_VALUES_ARGS
)
3488 const GLubyte
*color
= (const GLubyte
*) value
;
3489 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3490 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3494 bgr_t
*ptr
= PIXEL_ADDR3(xrb
, x
[i
], y
[i
] );
3504 * Write an array of identical PF_DITHER pixels to an XImage.
3506 static void put_mono_values_DITHER_ximage( PUT_MONO_VALUES_ARGS
)
3508 const GLubyte
*color
= (const GLubyte
*) value
;
3509 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3510 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3511 XMesaImage
*img
= xrb
->ximage
;
3516 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), DITHER( x
[i
], y
[i
], r
, g
, b
) );
3523 * Write an array of identical 8-bit PF_DITHER pixels to an XImage.
3525 static void put_mono_values_DITHER8_ximage( PUT_MONO_VALUES_ARGS
)
3527 const GLubyte
*color
= (const GLubyte
*) value
;
3528 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3529 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3534 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3535 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], r
, g
, b
);
3542 * Write an array of identical 8-bit PF_LOOKUP pixels to an XImage.
3544 static void put_mono_values_LOOKUP8_ximage( PUT_MONO_VALUES_ARGS
)
3546 const GLubyte
*color
= (const GLubyte
*) value
;
3547 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3551 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3554 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3563 * Write an array of identical PF_1BIT pixels to an XImage.
3565 static void put_mono_values_1BIT_ximage( PUT_MONO_VALUES_ARGS
)
3567 const GLubyte
*color
= (const GLubyte
*) value
;
3568 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3569 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3570 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3571 XMesaImage
*img
= xrb
->ximage
;
3576 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
3577 DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
));
3584 * Write an array of identical PF_HPCR pixels to an XImage.
3586 static void put_mono_values_HPCR_ximage( PUT_MONO_VALUES_ARGS
)
3588 const GLubyte
*color
= (const GLubyte
*) value
;
3589 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3590 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3591 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3595 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3596 *ptr
= DITHER_HPCR( x
[i
], y
[i
], r
, g
, b
);
3603 * Write an array of identical 8-bit PF_GRAYSCALE pixels to an XImage.
3605 static void put_mono_values_GRAYSCALE8_ximage( PUT_MONO_VALUES_ARGS
)
3607 const GLubyte
*color
= (const GLubyte
*) value
;
3608 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3610 register GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3613 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3621 * Write an array of identical PF_DITHER_5R6G5B pixels to an XImage.
3623 static void put_mono_values_DITHER_5R6G5B_ximage( PUT_MONO_VALUES_ARGS
)
3625 const GLubyte
*color
= (const GLubyte
*) value
;
3626 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3627 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3628 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3632 GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
[i
], y
[i
] );
3633 PACK_TRUEDITHER(*ptr
, x
[i
], y
[i
], r
, g
, b
);
3640 /**********************************************************************/
3641 /*** Write INDEX SPAN functions ***/
3642 /**********************************************************************/
3645 * Write a span of CI pixels to a Pixmap.
3647 static void put_row_ci_pixmap( PUT_ROW_ARGS
)
3649 const GLuint
*index
= (GLuint
*) values
;
3650 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3651 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3652 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3653 XMesaDrawable buffer
= xrb
->pixmap
;
3654 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3658 for (i
=0;i
<n
;i
++,x
++) {
3660 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3661 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3666 for (i
=0;i
<n
;i
++,x
++) {
3667 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3668 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3675 * Write a span of CI pixels to an XImage.
3677 static void put_row_ci_ximage( PUT_ROW_ARGS
)
3679 const GLuint
*index
= (const GLuint
*) values
;
3680 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3681 XMesaImage
*img
= xrb
->ximage
;
3685 for (i
=0;i
<n
;i
++,x
++) {
3687 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3692 for (i
=0;i
<n
;i
++,x
++) {
3693 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3699 /**********************************************************************/
3700 /*** Write INDEX PIXELS functions ***/
3701 /**********************************************************************/
3704 * Write an array of CI pixels to a Pixmap.
3706 static void put_values_ci_pixmap( PUT_VALUES_ARGS
)
3708 const GLuint
*index
= (const GLuint
*) values
;
3709 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3710 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3711 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3712 XMesaDrawable buffer
= xrb
->pixmap
;
3713 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3717 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3718 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3725 * Write an array of CI pixels to an XImage.
3727 static void put_values_ci_ximage( PUT_VALUES_ARGS
)
3729 const GLuint
*index
= (const GLuint
*) values
;
3730 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3731 XMesaImage
*img
= xrb
->ximage
;
3735 XMesaPutPixel(img
, x
[i
], YFLIP(xrb
, y
[i
]), (unsigned long) index
[i
]);
3743 /**********************************************************************/
3744 /***** Pixel reading *****/
3745 /**********************************************************************/
3747 #ifndef XFree86Server
3749 * Do clip testing prior to calling XGetImage. If any of the region lies
3750 * outside the screen's bounds, XGetImage will return NULL.
3751 * We use XTranslateCoordinates() to check if that's the case and
3752 * adjust the x, y and length parameters accordingly.
3753 * \return -1 if span is totally clipped away,
3754 * else return number of pixels to skip in the destination array.
3757 clip_for_xgetimage(GLcontext
*ctx
, GLuint
*n
, GLint
*x
, GLint
*y
)
3759 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3760 XMesaBuffer source
= XMESA_BUFFER(ctx
->DrawBuffer
);
3761 Window rootWin
= RootWindow(xmesa
->display
, 0);
3763 GLint screenWidth
= WidthOfScreen(DefaultScreenOfDisplay(xmesa
->display
));
3765 if (source
->type
== PBUFFER
)
3767 XTranslateCoordinates(xmesa
->display
, source
->frontxrb
->pixmap
, rootWin
,
3768 *x
, *y
, &dx
, &dy
, &child
);
3769 if (dx
>= screenWidth
) {
3770 /* totally clipped on right */
3774 /* clipped on left */
3776 if (clip
>= (GLint
) *n
)
3777 return -1; /* totally clipped on left */
3783 if ((GLint
) (dx
+ *n
) > screenWidth
) {
3784 /* clipped on right */
3785 GLint clip
= dx
+ *n
- screenWidth
;
3794 * Read a horizontal span of color-index pixels.
3797 get_row_ci(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
3798 GLuint n
, GLint x
, GLint y
, void *values
)
3800 GLuint
*index
= (GLuint
*) values
;
3801 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3802 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3808 #ifndef XFree86Server
3809 XMesaImage
*span
= NULL
;
3811 int k
= clip_for_xgetimage(ctx
, &n
, &x
, &y
);
3816 catch_xgetimage_errors( xmesa
->display
);
3817 span
= XGetImage( xmesa
->display
, xrb
->pixmap
,
3818 x
, y
, n
, 1, AllPlanes
, ZPixmap
);
3819 error
= check_xgetimage_errors();
3820 if (span
&& !error
) {
3822 index
[i
] = (GLuint
) XMesaGetPixel( span
, i
, 0 );
3826 /* return 0 pixels */
3832 XMesaDestroyImage( span
);
3835 (*xmesa
->display
->GetImage
)(xrb
->pixmap
,
3836 x
, y
, n
, 1, ZPixmap
,
3837 ~0L, (pointer
)index
);
3840 else if (xrb
->ximage
) {
3841 XMesaImage
*img
= xrb
->ximage
;
3842 for (i
=0;i
<n
;i
++,x
++) {
3843 index
[i
] = (GLuint
) XMesaGetPixel( img
, x
, y
);
3851 * Read a horizontal span of color pixels.
3854 get_row_rgba(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
3855 GLuint n
, GLint x
, GLint y
, void *values
)
3857 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
3858 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3859 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
3860 XMesaBuffer source
= XMESA_BUFFER(ctx
->DrawBuffer
);
3863 /* Read from Pixmap or Window */
3864 XMesaImage
*span
= NULL
;
3866 #ifdef XFree86Server
3867 span
= XMesaCreateImage(xmesa
->xm_visual
->BitsPerPixel
, n
, 1, NULL
);
3868 span
->data
= (char *)MALLOC(span
->height
* span
->bytes_per_line
);
3869 error
= (!span
->data
);
3870 (*xmesa
->display
->GetImage
)(xrb
->pixmap
,
3871 x
, YFLIP(xrb
, y
), n
, 1, ZPixmap
,
3872 ~0L, (pointer
)span
->data
);
3876 k
= clip_for_xgetimage(ctx
, &n
, &x
, &y
);
3880 catch_xgetimage_errors( xmesa
->display
);
3881 span
= XGetImage( xmesa
->display
, xrb
->pixmap
,
3882 x
, y
, n
, 1, AllPlanes
, ZPixmap
);
3883 error
= check_xgetimage_errors();
3885 if (span
&& !error
) {
3886 switch (xmesa
->pixelformat
) {
3888 case PF_Dither_True
:
3890 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3891 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3892 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3893 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3894 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3895 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3896 GLint rShift
= xmesa
->xm_visual
->rshift
;
3897 GLint gShift
= xmesa
->xm_visual
->gshift
;
3898 GLint bShift
= xmesa
->xm_visual
->bshift
;
3902 p
= XMesaGetPixel( span
, i
, 0 );
3903 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3904 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3905 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3906 rgba
[i
][ACOMP
] = 255;
3911 case PF_Dither_5R6G5B
:
3913 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3914 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3915 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3918 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
3919 /* fast, but not quite accurate
3920 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3921 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3922 rgba[i][BCOMP] = ((p << 3) & 0xff);
3924 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
3925 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3926 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
3927 rgba
[i
][ACOMP
] = 255;
3933 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3936 GLuint p4
= *ptr4
++;
3937 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
3938 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3939 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3940 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
3946 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3949 GLuint p4
= *ptr4
++;
3950 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3951 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3952 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3953 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
3959 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3962 GLuint p4
= *ptr4
++;
3963 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3964 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3965 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3966 rgba
[i
][ACOMP
] = 255;
3972 const bgr_t
*ptr3
= (bgr_t
*) span
->data
;
3975 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
3976 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
3977 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
3978 rgba
[i
][ACOMP
] = 255;
3984 GLubyte
*ptr1
= (GLubyte
*) span
->data
;
3987 GLubyte p
= *ptr1
++;
3988 rgba
[i
][RCOMP
] = p
& 0xE0;
3989 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
3990 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
3991 rgba
[i
][ACOMP
] = 255;
3999 GLubyte
*rTable
= source
->pixel_to_r
;
4000 GLubyte
*gTable
= source
->pixel_to_g
;
4001 GLubyte
*bTable
= source
->pixel_to_b
;
4002 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
4003 const GLubyte
*ptr1
= (GLubyte
*) span
->data
;
4006 unsigned long p
= *ptr1
++;
4007 rgba
[i
][RCOMP
] = rTable
[p
];
4008 rgba
[i
][GCOMP
] = gTable
[p
];
4009 rgba
[i
][BCOMP
] = bTable
[p
];
4010 rgba
[i
][ACOMP
] = 255;
4016 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
4017 rgba
[i
][RCOMP
] = rTable
[p
];
4018 rgba
[i
][GCOMP
] = gTable
[p
];
4019 rgba
[i
][BCOMP
] = bTable
[p
];
4020 rgba
[i
][ACOMP
] = 255;
4027 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4031 p
= XMesaGetPixel( span
, i
, 0 ) ^ bitFlip
;
4032 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4033 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4034 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4035 rgba
[i
][ACOMP
] = 255;
4040 _mesa_problem(NULL
,"Problem in DD.read_color_span (1)");
4045 /* return black pixels */
4048 rgba
[i
][RCOMP
] = rgba
[i
][GCOMP
] = rgba
[i
][BCOMP
] = rgba
[i
][ACOMP
] = 0;
4052 XMesaDestroyImage( span
);
4055 else if (xrb
->ximage
) {
4056 /* Read from XImage back buffer */
4057 switch (xmesa
->pixelformat
) {
4059 case PF_Dither_True
:
4061 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4062 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4063 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4064 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4065 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4066 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4067 GLint rShift
= xmesa
->xm_visual
->rshift
;
4068 GLint gShift
= xmesa
->xm_visual
->gshift
;
4069 GLint bShift
= xmesa
->xm_visual
->bshift
;
4070 XMesaImage
*img
= xrb
->ximage
;
4075 p
= XMesaGetPixel( img
, x
+i
, y
);
4076 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4077 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4078 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4079 rgba
[i
][ACOMP
] = 255;
4084 case PF_Dither_5R6G5B
:
4086 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4087 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4088 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4089 const GLushort
*ptr2
= PIXEL_ADDR2(xrb
, x
, y
);
4091 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
4092 const GLuint
*ptr4
= (const GLuint
*) ptr2
;
4093 GLuint extraPixel
= (n
& 1);
4095 for (i
= 0; i
< n
; i
+= 2) {
4096 const GLuint p
= *ptr4
++;
4097 const GLuint p0
= p
& 0xffff;
4098 const GLuint p1
= p
>> 16;
4099 /* fast, but not quite accurate
4100 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
4101 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
4102 rgba[i][BCOMP] = ((p << 3) & 0xff);
4104 rgba
[i
][RCOMP
] = pixelToR
[p0
>> 11];
4105 rgba
[i
][GCOMP
] = pixelToG
[(p0
>> 5) & 0x3f];
4106 rgba
[i
][BCOMP
] = pixelToB
[p0
& 0x1f];
4107 rgba
[i
][ACOMP
] = 255;
4108 rgba
[i
+1][RCOMP
] = pixelToR
[p1
>> 11];
4109 rgba
[i
+1][GCOMP
] = pixelToG
[(p1
>> 5) & 0x3f];
4110 rgba
[i
+1][BCOMP
] = pixelToB
[p1
& 0x1f];
4111 rgba
[i
+1][ACOMP
] = 255;
4114 GLushort p
= ptr2
[n
];
4115 rgba
[n
][RCOMP
] = pixelToR
[p
>> 11];
4116 rgba
[n
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
4117 rgba
[n
][BCOMP
] = pixelToB
[p
& 0x1f];
4118 rgba
[n
][ACOMP
] = 255;
4121 for (i
= 0; i
< n
; i
++) {
4122 const GLushort p
= ptr2
[i
];
4123 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
4124 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
4125 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
4126 rgba
[i
][ACOMP
] = 255;
4133 const GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
, y
);
4136 GLuint p4
= *ptr4
++;
4137 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
4138 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4139 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4140 rgba
[i
][ACOMP
] = (GLint
) ((p4
>> 24) & 0xff);
4146 const GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
, y
);
4149 GLuint p4
= *ptr4
++;
4150 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4151 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4152 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4153 rgba
[i
][ACOMP
] = (GLint
) ((p4
>> 24) & 0xff);
4159 const GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
, y
);
4162 GLuint p4
= *ptr4
++;
4163 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4164 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4165 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4166 rgba
[i
][ACOMP
] = 255;
4172 const bgr_t
*ptr3
= PIXEL_ADDR3(xrb
, x
, y
);
4175 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
4176 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
4177 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
4178 rgba
[i
][ACOMP
] = 255;
4184 const GLubyte
*ptr1
= PIXEL_ADDR1(xrb
, x
, y
);
4187 GLubyte p
= *ptr1
++;
4188 rgba
[i
][RCOMP
] = p
& 0xE0;
4189 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4190 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4191 rgba
[i
][ACOMP
] = 255;
4199 const GLubyte
*rTable
= source
->pixel_to_r
;
4200 const GLubyte
*gTable
= source
->pixel_to_g
;
4201 const GLubyte
*bTable
= source
->pixel_to_b
;
4202 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
4203 GLubyte
*ptr1
= PIXEL_ADDR1(xrb
, x
, y
);
4206 unsigned long p
= *ptr1
++;
4207 rgba
[i
][RCOMP
] = rTable
[p
];
4208 rgba
[i
][GCOMP
] = gTable
[p
];
4209 rgba
[i
][BCOMP
] = bTable
[p
];
4210 rgba
[i
][ACOMP
] = 255;
4214 XMesaImage
*img
= xrb
->ximage
;
4217 for (i
=0;i
<n
;i
++,x
++) {
4218 unsigned long p
= XMesaGetPixel( img
, x
, y
);
4219 rgba
[i
][RCOMP
] = rTable
[p
];
4220 rgba
[i
][GCOMP
] = gTable
[p
];
4221 rgba
[i
][BCOMP
] = bTable
[p
];
4222 rgba
[i
][ACOMP
] = 255;
4229 XMesaImage
*img
= xrb
->ximage
;
4230 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4233 for (i
=0;i
<n
;i
++,x
++) {
4235 p
= XMesaGetPixel( img
, x
, y
) ^ bitFlip
;
4236 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4237 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4238 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4239 rgba
[i
][ACOMP
] = 255;
4244 _mesa_problem(NULL
,"Problem in DD.read_color_span (2)");
4253 * Read an array of color index pixels.
4256 get_values_ci(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
4257 GLuint n
, const GLint x
[], const GLint y
[], void *values
)
4259 GLuint
*indx
= (GLuint
*) values
;
4260 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
4261 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
4265 indx
[i
] = (GLuint
) read_pixel( xmesa
->display
, xrb
->pixmap
,
4266 x
[i
], YFLIP(xrb
, y
[i
]) );
4269 else if (xrb
->ximage
) {
4270 XMesaImage
*img
= xrb
->ximage
;
4272 indx
[i
] = (GLuint
) XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) );
4280 get_values_rgba(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
4281 GLuint n
, const GLint x
[], const GLint y
[], void *values
)
4283 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
4284 struct xmesa_renderbuffer
*xrb
= (struct xmesa_renderbuffer
*) rb
;
4285 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
4286 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
4287 XMesaBuffer source
= XMESA_BUFFER(ctx
->DrawBuffer
);
4291 XMesaDrawable buffer
= xrb
->pixmap
;
4292 switch (xmesa
->pixelformat
) {
4294 case PF_Dither_True
:
4296 case PF_Dither_5R6G5B
:
4298 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4299 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4300 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4301 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4302 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4303 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4304 GLint rShift
= xmesa
->xm_visual
->rshift
;
4305 GLint gShift
= xmesa
->xm_visual
->gshift
;
4306 GLint bShift
= xmesa
->xm_visual
->bshift
;
4308 unsigned long p
= read_pixel( dpy
, buffer
,
4309 x
[i
], YFLIP(xrb
, y
[i
]) );
4310 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4311 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4312 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4313 rgba
[i
][ACOMP
] = 255;
4319 unsigned long p
= read_pixel( dpy
, buffer
,
4320 x
[i
], YFLIP(xrb
, y
[i
]) );
4321 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xff);
4322 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4323 rgba
[i
][BCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4324 rgba
[i
][ACOMP
] = (GLubyte
) ((p
>> 24) & 0xff);
4329 unsigned long p
= read_pixel( dpy
, buffer
,
4330 x
[i
], YFLIP(xrb
, y
[i
]) );
4331 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4332 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4333 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4334 rgba
[i
][ACOMP
] = (GLubyte
) ((p
>> 24) & 0xff);
4339 unsigned long p
= read_pixel( dpy
, buffer
,
4340 x
[i
], YFLIP(xrb
, y
[i
]) );
4341 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4342 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4343 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4344 rgba
[i
][ACOMP
] = 255;
4349 unsigned long p
= read_pixel( dpy
, buffer
,
4350 x
[i
], YFLIP(xrb
, y
[i
]) );
4351 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4352 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4353 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4354 rgba
[i
][ACOMP
] = 255;
4359 unsigned long p
= read_pixel( dpy
, buffer
,
4360 x
[i
], YFLIP(xrb
, y
[i
]) );
4361 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xE0 );
4362 rgba
[i
][GCOMP
] = (GLubyte
) ((p
& 0x1C) << 3);
4363 rgba
[i
][BCOMP
] = (GLubyte
) ((p
& 0x03) << 6);
4364 rgba
[i
][ACOMP
] = (GLubyte
) 255;
4371 GLubyte
*rTable
= source
->pixel_to_r
;
4372 GLubyte
*gTable
= source
->pixel_to_g
;
4373 GLubyte
*bTable
= source
->pixel_to_b
;
4375 unsigned long p
= read_pixel( dpy
, buffer
,
4376 x
[i
], YFLIP(xrb
, y
[i
]) );
4377 rgba
[i
][RCOMP
] = rTable
[p
];
4378 rgba
[i
][GCOMP
] = gTable
[p
];
4379 rgba
[i
][BCOMP
] = bTable
[p
];
4380 rgba
[i
][ACOMP
] = 255;
4386 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4388 unsigned long p
= read_pixel( dpy
, buffer
,
4389 x
[i
], YFLIP(xrb
, y
[i
])) ^ bitFlip
;
4390 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4391 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4392 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4393 rgba
[i
][ACOMP
] = 255;
4398 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4402 else if (xrb
->ximage
) {
4403 /* Read from XImage back buffer */
4404 switch (xmesa
->pixelformat
) {
4406 case PF_Dither_True
:
4408 case PF_Dither_5R6G5B
:
4410 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4411 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4412 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4413 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4414 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4415 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4416 GLint rShift
= xmesa
->xm_visual
->rshift
;
4417 GLint gShift
= xmesa
->xm_visual
->gshift
;
4418 GLint bShift
= xmesa
->xm_visual
->bshift
;
4419 XMesaImage
*img
= xrb
->ximage
;
4422 p
= XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) );
4423 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4424 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4425 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4426 rgba
[i
][ACOMP
] = 255;
4432 GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
4434 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
4435 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4436 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4437 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
4442 GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
4444 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4445 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4446 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4447 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
4452 GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
4454 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4455 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4456 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4457 rgba
[i
][ACOMP
] = 255;
4462 bgr_t
*ptr3
= PIXEL_ADDR3(xrb
, x
[i
], y
[i
]);
4463 rgba
[i
][RCOMP
] = ptr3
->r
;
4464 rgba
[i
][GCOMP
] = ptr3
->g
;
4465 rgba
[i
][BCOMP
] = ptr3
->b
;
4466 rgba
[i
][ACOMP
] = 255;
4471 GLubyte
*ptr1
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
4473 rgba
[i
][RCOMP
] = p
& 0xE0;
4474 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4475 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4476 rgba
[i
][ACOMP
] = 255;
4483 GLubyte
*rTable
= source
->pixel_to_r
;
4484 GLubyte
*gTable
= source
->pixel_to_g
;
4485 GLubyte
*bTable
= source
->pixel_to_b
;
4486 XMesaImage
*img
= xrb
->ximage
;
4489 p
= XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) );
4490 rgba
[i
][RCOMP
] = rTable
[p
];
4491 rgba
[i
][GCOMP
] = gTable
[p
];
4492 rgba
[i
][BCOMP
] = bTable
[p
];
4493 rgba
[i
][ACOMP
] = 255;
4499 XMesaImage
*img
= xrb
->ximage
;
4500 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4503 p
= XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) ) ^ bitFlip
;
4504 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4505 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4506 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4507 rgba
[i
][ACOMP
] = 255;
4512 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4520 * Initialize the renderbuffer's PutRow, GetRow, etc. functions.
4521 * This would generally only need to be called once when the renderbuffer
4522 * is created. However, we can change pixel formats on the fly if dithering
4523 * is enabled/disabled. Therefore, we may call this more often than that.
4526 xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer
*xrb
,
4527 enum pixel_format pixelformat
, GLint depth
)
4529 const GLboolean pixmap
= xrb
->pixmap
? GL_TRUE
: GL_FALSE
;
4531 switch (pixelformat
) {
4533 ASSERT(xrb
->Base
.DataType
== GL_UNSIGNED_INT
);
4535 xrb
->Base
.PutRow
= put_row_ci_pixmap
;
4536 xrb
->Base
.PutRowRGB
= NULL
;
4537 xrb
->Base
.PutMonoRow
= put_mono_row_ci_pixmap
;
4538 xrb
->Base
.PutValues
= put_values_ci_pixmap
;
4539 xrb
->Base
.PutMonoValues
= put_mono_values_ci_pixmap
;
4542 xrb
->Base
.PutRow
= put_row_ci_ximage
;
4543 xrb
->Base
.PutRowRGB
= NULL
;
4544 xrb
->Base
.PutMonoRow
= put_mono_row_ci_ximage
;
4545 xrb
->Base
.PutValues
= put_values_ci_ximage
;
4546 xrb
->Base
.PutMonoValues
= put_mono_values_ci_ximage
;
4551 xrb
->Base
.PutRow
= put_row_TRUECOLOR_pixmap
;
4552 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUECOLOR_pixmap
;
4553 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4554 xrb
->Base
.PutValues
= put_values_TRUECOLOR_pixmap
;
4555 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4558 xrb
->Base
.PutRow
= put_row_TRUECOLOR_ximage
;
4559 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUECOLOR_ximage
;
4560 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4561 xrb
->Base
.PutValues
= put_values_TRUECOLOR_ximage
;
4562 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4565 case PF_Dither_True
:
4567 xrb
->Base
.PutRow
= put_row_TRUEDITHER_pixmap
;
4568 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUEDITHER_pixmap
;
4569 xrb
->Base
.PutMonoRow
= put_mono_row_TRUEDITHER_pixmap
;
4570 xrb
->Base
.PutValues
= put_values_TRUEDITHER_pixmap
;
4571 xrb
->Base
.PutMonoValues
= put_mono_values_TRUEDITHER_pixmap
;
4574 xrb
->Base
.PutRow
= put_row_TRUEDITHER_ximage
;
4575 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUEDITHER_ximage
;
4576 xrb
->Base
.PutMonoRow
= put_mono_row_TRUEDITHER_ximage
;
4577 xrb
->Base
.PutValues
= put_values_TRUEDITHER_ximage
;
4578 xrb
->Base
.PutMonoValues
= put_mono_values_TRUEDITHER_ximage
;
4583 xrb
->Base
.PutRow
= put_row_8A8B8G8R_pixmap
;
4584 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8B8G8R_pixmap
;
4585 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4586 xrb
->Base
.PutValues
= put_values_8A8B8G8R_pixmap
;
4587 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4590 xrb
->Base
.PutRow
= put_row_8A8B8G8R_ximage
;
4591 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8B8G8R_ximage
;
4592 xrb
->Base
.PutMonoRow
= put_mono_row_8A8B8G8R_ximage
;
4593 xrb
->Base
.PutValues
= put_values_8A8B8G8R_ximage
;
4594 xrb
->Base
.PutMonoValues
= put_mono_values_8A8B8G8R_ximage
;
4599 xrb
->Base
.PutRow
= put_row_8A8R8G8B_pixmap
;
4600 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8R8G8B_pixmap
;
4601 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4602 xrb
->Base
.PutValues
= put_values_8A8R8G8B_pixmap
;
4603 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4606 xrb
->Base
.PutRow
= put_row_8A8R8G8B_ximage
;
4607 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8R8G8B_ximage
;
4608 xrb
->Base
.PutMonoRow
= put_mono_row_8A8R8G8B_ximage
;
4609 xrb
->Base
.PutValues
= put_values_8A8R8G8B_ximage
;
4610 xrb
->Base
.PutMonoValues
= put_mono_values_8A8R8G8B_ximage
;
4615 xrb
->Base
.PutRow
= put_row_8R8G8B_pixmap
;
4616 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B_pixmap
;
4617 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4618 xrb
->Base
.PutValues
= put_values_8R8G8B_pixmap
;
4619 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4622 xrb
->Base
.PutRow
= put_row_8R8G8B_ximage
;
4623 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B_ximage
;
4624 xrb
->Base
.PutMonoRow
= put_mono_row_8R8G8B_ximage
;
4625 xrb
->Base
.PutValues
= put_values_8R8G8B_ximage
;
4626 xrb
->Base
.PutMonoValues
= put_mono_values_8R8G8B_ximage
;
4631 xrb
->Base
.PutRow
= put_row_8R8G8B24_pixmap
;
4632 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B24_pixmap
;
4633 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4634 xrb
->Base
.PutValues
= put_values_8R8G8B24_pixmap
;
4635 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4638 xrb
->Base
.PutRow
= put_row_8R8G8B24_ximage
;
4639 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B24_ximage
;
4640 xrb
->Base
.PutMonoRow
= put_mono_row_8R8G8B24_ximage
;
4641 xrb
->Base
.PutValues
= put_values_8R8G8B24_ximage
;
4642 xrb
->Base
.PutMonoValues
= put_mono_values_8R8G8B24_ximage
;
4647 xrb
->Base
.PutRow
= put_row_5R6G5B_pixmap
;
4648 xrb
->Base
.PutRowRGB
= put_row_rgb_5R6G5B_pixmap
;
4649 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4650 xrb
->Base
.PutValues
= put_values_5R6G5B_pixmap
;
4651 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4654 xrb
->Base
.PutRow
= put_row_5R6G5B_ximage
;
4655 xrb
->Base
.PutRowRGB
= put_row_rgb_5R6G5B_ximage
;
4656 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4657 xrb
->Base
.PutValues
= put_values_5R6G5B_ximage
;
4658 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4661 case PF_Dither_5R6G5B
:
4663 xrb
->Base
.PutRow
= put_row_DITHER_5R6G5B_pixmap
;
4664 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_5R6G5B_pixmap
;
4665 xrb
->Base
.PutMonoRow
= put_mono_row_TRUEDITHER_pixmap
;
4666 xrb
->Base
.PutValues
= put_values_DITHER_5R6G5B_pixmap
;
4667 xrb
->Base
.PutMonoValues
= put_mono_values_TRUEDITHER_pixmap
;
4670 xrb
->Base
.PutRow
= put_row_DITHER_5R6G5B_ximage
;
4671 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_5R6G5B_ximage
;
4672 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER_5R6G5B_ximage
;
4673 xrb
->Base
.PutValues
= put_values_DITHER_5R6G5B_ximage
;
4674 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER_5R6G5B_ximage
;
4679 xrb
->Base
.PutRow
= put_row_DITHER_pixmap
;
4680 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_pixmap
;
4681 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER_pixmap
;
4682 xrb
->Base
.PutValues
= put_values_DITHER_pixmap
;
4683 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER_pixmap
;
4687 xrb
->Base
.PutRow
= put_row_DITHER8_ximage
;
4688 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER8_ximage
;
4689 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER8_ximage
;
4690 xrb
->Base
.PutValues
= put_values_DITHER8_ximage
;
4691 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER8_ximage
;
4694 xrb
->Base
.PutRow
= put_row_DITHER_ximage
;
4695 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_ximage
;
4696 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER_ximage
;
4697 xrb
->Base
.PutValues
= put_values_DITHER_ximage
;
4698 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER_ximage
;
4704 xrb
->Base
.PutRow
= put_row_1BIT_pixmap
;
4705 xrb
->Base
.PutRowRGB
= put_row_rgb_1BIT_pixmap
;
4706 xrb
->Base
.PutMonoRow
= put_mono_row_1BIT_pixmap
;
4707 xrb
->Base
.PutValues
= put_values_1BIT_pixmap
;
4708 xrb
->Base
.PutMonoValues
= put_mono_values_1BIT_pixmap
;
4711 xrb
->Base
.PutRow
= put_row_1BIT_ximage
;
4712 xrb
->Base
.PutRowRGB
= put_row_rgb_1BIT_ximage
;
4713 xrb
->Base
.PutMonoRow
= put_mono_row_1BIT_ximage
;
4714 xrb
->Base
.PutValues
= put_values_1BIT_ximage
;
4715 xrb
->Base
.PutMonoValues
= put_mono_values_1BIT_ximage
;
4720 xrb
->Base
.PutRow
= put_row_HPCR_pixmap
;
4721 xrb
->Base
.PutRowRGB
= put_row_rgb_HPCR_pixmap
;
4722 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4723 xrb
->Base
.PutValues
= put_values_HPCR_pixmap
;
4724 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4727 xrb
->Base
.PutRow
= put_row_HPCR_ximage
;
4728 xrb
->Base
.PutRowRGB
= put_row_rgb_HPCR_ximage
;
4729 xrb
->Base
.PutMonoRow
= put_mono_row_HPCR_ximage
;
4730 xrb
->Base
.PutValues
= put_values_HPCR_ximage
;
4731 xrb
->Base
.PutMonoValues
= put_mono_values_HPCR_ximage
;
4736 xrb
->Base
.PutRow
= put_row_LOOKUP_pixmap
;
4737 xrb
->Base
.PutRowRGB
= put_row_rgb_LOOKUP_pixmap
;
4738 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4739 xrb
->Base
.PutValues
= put_values_LOOKUP_pixmap
;
4740 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4744 xrb
->Base
.PutRow
= put_row_LOOKUP8_ximage
;
4745 xrb
->Base
.PutRowRGB
= put_row_rgb_LOOKUP8_ximage
;
4746 xrb
->Base
.PutMonoRow
= put_mono_row_LOOKUP8_ximage
;
4747 xrb
->Base
.PutValues
= put_values_LOOKUP8_ximage
;
4748 xrb
->Base
.PutMonoValues
= put_mono_values_LOOKUP8_ximage
;
4751 xrb
->Base
.PutRow
= put_row_LOOKUP_ximage
;
4752 xrb
->Base
.PutRowRGB
= put_row_rgb_LOOKUP_ximage
;
4753 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4754 xrb
->Base
.PutValues
= put_values_LOOKUP_ximage
;
4755 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4761 xrb
->Base
.PutRow
= put_row_GRAYSCALE_pixmap
;
4762 xrb
->Base
.PutRowRGB
= put_row_rgb_GRAYSCALE_pixmap
;
4763 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4764 xrb
->Base
.PutValues
= put_values_GRAYSCALE_pixmap
;
4765 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4769 xrb
->Base
.PutRow
= put_row_GRAYSCALE8_ximage
;
4770 xrb
->Base
.PutRowRGB
= put_row_rgb_GRAYSCALE8_ximage
;
4771 xrb
->Base
.PutMonoRow
= put_mono_row_GRAYSCALE8_ximage
;
4772 xrb
->Base
.PutValues
= put_values_GRAYSCALE8_ximage
;
4773 xrb
->Base
.PutMonoValues
= put_mono_values_GRAYSCALE8_ximage
;
4776 xrb
->Base
.PutRow
= put_row_GRAYSCALE_ximage
;
4777 xrb
->Base
.PutRowRGB
= put_row_rgb_GRAYSCALE_ximage
;
4778 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4779 xrb
->Base
.PutValues
= put_values_GRAYSCALE_ximage
;
4780 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4785 _mesa_problem(NULL
, "Bad pixel format in xmesa_update_state (1)");
4791 if (pixelformat
== PF_Index
) {
4792 xrb
->Base
.GetRow
= get_row_ci
;
4793 xrb
->Base
.GetValues
= get_values_ci
;
4796 xrb
->Base
.GetRow
= get_row_rgba
;
4797 xrb
->Base
.GetValues
= get_values_rgba
;