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.
25 #include "glxheader.h"
26 #include "main/colormac.h"
27 #include "main/context.h"
28 #include "main/depth.h"
29 #include "main/drawpix.h"
30 #include "main/extensions.h"
31 #include "main/macros.h"
32 #include "main/imports.h"
33 #include "main/mtypes.h"
34 #include "main/state.h"
37 #include "swrast/swrast.h"
41 * The following functions are used to trap XGetImage() calls which
42 * generate BadMatch errors if the drawable isn't mapped.
46 static int caught_xgetimage_error
= 0;
47 static int (*old_xerror_handler
)( XMesaDisplay
*dpy
, XErrorEvent
*ev
);
48 static unsigned long xgetimage_serial
;
51 * This is the error handler which will be called if XGetImage fails.
53 static int xgetimage_error_handler( XMesaDisplay
*dpy
, XErrorEvent
*ev
)
55 if (ev
->serial
==xgetimage_serial
&& ev
->error_code
==BadMatch
) {
56 /* caught the expected error */
57 caught_xgetimage_error
= 0;
60 /* call the original X error handler, if any. otherwise ignore */
61 if (old_xerror_handler
) {
62 (*old_xerror_handler
)( dpy
, ev
);
70 * Call this right before XGetImage to setup error trap.
72 static void catch_xgetimage_errors( XMesaDisplay
*dpy
)
74 xgetimage_serial
= NextRequest( dpy
);
75 old_xerror_handler
= XSetErrorHandler( xgetimage_error_handler
);
76 caught_xgetimage_error
= 0;
81 * Call this right after XGetImage to check if an error occured.
83 static int check_xgetimage_errors( void )
85 /* restore old handler */
86 (void) XSetErrorHandler( old_xerror_handler
);
87 /* return 0=no error, 1=error caught */
88 return caught_xgetimage_error
;
94 * Read a pixel from an X drawable.
96 static unsigned long read_pixel( XMesaDisplay
*dpy
,
97 XMesaDrawable d
, int x
, int y
)
100 #ifndef XFree86Server
101 XMesaImage
*pixel
= NULL
;
104 catch_xgetimage_errors( dpy
);
105 pixel
= XGetImage( dpy
, d
, x
, y
, 1, 1, AllPlanes
, ZPixmap
);
106 error
= check_xgetimage_errors();
107 if (pixel
&& !error
) {
108 p
= XMesaGetPixel( pixel
, 0, 0 );
114 XMesaDestroyImage( pixel
);
117 (*dpy
->GetImage
)(d
, x
, y
, 1, 1, ZPixmap
, ~0L, (pointer
)&p
);
125 * The Mesa library needs to be able to draw pixels in a number of ways:
126 * 1. RGB vs Color Index
127 * 2. as horizontal spans (polygons, images) vs random locations (points,
129 * 3. different color per-pixel or same color for all pixels
131 * Furthermore, the X driver needs to support rendering to 3 possible
132 * "buffers", usually one, but sometimes two at a time:
133 * 1. The front buffer as an X window
134 * 2. The back buffer as a Pixmap
135 * 3. The back buffer as an XImage
137 * Finally, if the back buffer is an XImage, we can avoid using XPutPixel and
138 * optimize common cases such as 24-bit and 8-bit modes.
140 * By multiplication, there's at least 48 possible combinations of the above.
142 * Below are implementations of the most commonly used combinations. They are
143 * accessed through function pointers which get initialized here and are used
144 * directly from the Mesa library. The 8 function pointers directly correspond
145 * to the first 3 cases listed above.
148 * The function naming convention is:
150 * [put|get]_[mono]_[row|values]_[format]_[pixmap|ximage]
152 * New functions optimized for specific cases can be added without too much
153 * trouble. An example might be the 24-bit TrueColor mode 8A8R8G8B which is
154 * found on IBM RS/6000 X servers.
160 /**********************************************************************/
161 /*** Write COLOR SPAN functions ***/
162 /**********************************************************************/
165 #define PUT_ROW_ARGS \
166 struct gl_context *ctx, \
167 struct gl_renderbuffer *rb, \
168 GLuint n, GLint x, GLint y, \
169 const void *values, const GLubyte mask[]
171 #define RGB_SPAN_ARGS \
172 struct gl_context *ctx, \
173 struct gl_renderbuffer *rb, \
174 GLuint n, GLint x, GLint y, \
175 const void *values, const GLubyte mask[]
178 #define GET_XRB(XRB) \
179 struct xmesa_renderbuffer *XRB = xmesa_renderbuffer(rb)
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
);
190 XMesaDisplay
*dpy
= XMESA_BUFFER(ctx
->DrawBuffer
)->display
;
191 XMesaDrawable buffer
= xrb
->drawable
;
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
);
227 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
228 XMesaDrawable buffer
= xrb
->drawable
;
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
);
262 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
263 XMesaDrawable buffer
= xrb
->drawable
;
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
);
297 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
298 XMesaDrawable buffer
= xrb
->drawable
;
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
);
332 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
333 XMesaDrawable buffer
= xrb
->drawable
;
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
);
366 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
367 XMesaDrawable buffer
= xrb
->drawable
;
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
);
399 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
400 XMesaDrawable buffer
= xrb
->drawable
;
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
);
433 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
434 XMesaDrawable buffer
= xrb
->drawable
;
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
);
466 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
467 XMesaDrawable buffer
= xrb
->drawable
;
468 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
472 for (i
=0;i
<n
;i
++,x
++) {
476 * XXX Something funny is going on here.
477 * If we're drawing into a window that uses a depth 32 TrueColor
478 * visual, we see the right pixels on screen, but when we read
479 * them back with XGetImage() we get random colors.
480 * The alternative code below which uses XPutImage() instead
481 * seems to mostly fix the problem, but not always.
482 * We don't normally create windows with this visual, but glean
483 * does and we're seeing some failures there.
485 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
486 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
488 /* This code works more often, but not always */
489 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
490 GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
491 *ptr4
= PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
492 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, 1, 1 );
498 /* draw all pixels */
499 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
500 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
502 *ptr4
++ = PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
504 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
510 * Write a span of PF_8R8G8B24 pixels to a pixmap.
512 static void put_row_8R8G8B24_pixmap( PUT_ROW_ARGS
)
514 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
515 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
517 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
518 XMesaDrawable buffer
= xrb
->drawable
;
519 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
523 for (i
=0;i
<n
;i
++,x
++) {
525 XMesaSetForeground( dpy
, gc
,
526 PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
527 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
532 /* draw all pixels */
533 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
534 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
535 register GLuint pixel
;
536 static const GLuint shift
[4] = {0, 8, 16, 24};
537 register GLuint i
= 0;
540 pixel
= rgba
[i
][BCOMP
] /* << shift[0]*/;
541 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
542 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
543 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
546 pixel
= rgba
[i
][GCOMP
] /* << shift[0]*/;
547 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
548 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
549 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
552 pixel
= rgba
[i
++][RCOMP
]/* << shift[0]*/;
553 pixel
|= rgba
[i
][BCOMP
] << shift
[1];
554 pixel
|= rgba
[i
][GCOMP
] << shift
[2];
555 pixel
|= rgba
[i
++][RCOMP
] << shift
[3];
563 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
564 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
565 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
566 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
569 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
570 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
571 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
572 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
574 pixel
= 0xffffff00 & *ptr4
;
575 pixel
|= rgba
[i
][RCOMP
] /*<< shift[0]*/;
580 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
581 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
582 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
583 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
585 pixel
= 0xffff0000 & *ptr4
;
586 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
587 pixel
|= rgba
[i
][RCOMP
] << shift
[1];
591 pixel
= 0xff000000 & *ptr4
;
592 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
593 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
594 pixel
|= rgba
[i
][RCOMP
] << shift
[2];
600 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
606 * Write a span of PF_8R8G8B pixels to a pixmap (no alpha).
608 static void put_row_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS
)
610 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
611 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
613 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
614 XMesaDrawable buffer
= xrb
->drawable
;
615 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
619 for (i
=0;i
<n
;i
++,x
++) {
621 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
622 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
627 /* draw all pixels */
628 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
629 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
631 *ptr4
++ = PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
633 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
638 * Write a span of PF_8R8G8B24 pixels to a pixmap (no alpha).
640 static void put_row_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS
)
642 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
643 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
645 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
646 XMesaDrawable buffer
= xrb
->drawable
;
647 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
651 for (i
=0;i
<n
;i
++,x
++) {
653 XMesaSetForeground( dpy
, gc
,
654 PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
655 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
660 /* draw all pixels */
661 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
662 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
663 register GLuint pixel
;
664 static const GLuint shift
[4] = {0, 8, 16, 24};
666 register GLuint i
= 0;
669 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
670 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
671 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
672 pixel
|= rgb
[i
][BCOMP
] <<shift
[3];
676 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
677 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
678 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
679 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
683 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
684 pixel
|= rgb
[i
][BCOMP
] << shift
[1];
685 pixel
|= rgb
[i
][GCOMP
] << shift
[2];
686 pixel
|= rgb
[i
++][RCOMP
] << shift
[3];
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];
699 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
700 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
701 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
702 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
706 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
711 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
712 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
713 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
714 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
718 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
719 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
725 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
726 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
727 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
733 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
739 * Write a span of PF_5R6G5B pixels to a pixmap.
741 static void put_row_5R6G5B_pixmap( PUT_ROW_ARGS
)
743 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
744 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
746 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
747 XMesaDrawable buffer
= xrb
->drawable
;
748 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
752 for (i
=0;i
<n
;i
++,x
++) {
754 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
755 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
760 /* draw all pixels */
761 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
762 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
764 ptr2
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
766 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
772 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap.
774 static void put_row_DITHER_5R6G5B_pixmap( PUT_ROW_ARGS
)
776 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
777 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
779 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
780 XMesaDrawable buffer
= xrb
->drawable
;
781 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
785 for (i
=0;i
<n
;i
++,x
++) {
788 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
789 XMesaSetForeground( dpy
, gc
, p
);
790 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
795 /* draw all pixels */
796 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
797 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
799 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
801 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
807 * Write a span of PF_5R6G5B pixels to a pixmap (no alpha).
809 static void put_row_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS
)
811 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
812 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
814 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
815 XMesaDrawable buffer
= xrb
->drawable
;
816 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
820 for (i
=0;i
<n
;i
++,x
++) {
822 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
823 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
828 /* draw all pixels */
829 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
830 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
832 ptr2
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
834 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
840 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap (no alpha).
842 static void put_row_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS
)
844 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
845 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
847 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
848 XMesaDrawable buffer
= xrb
->drawable
;
849 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
853 for (i
=0;i
<n
;i
++,x
++) {
856 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
857 XMesaSetForeground( dpy
, gc
, p
);
858 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
863 /* draw all pixels */
864 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
865 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
867 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
869 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
875 * Write a span of PF_DITHER pixels to a pixmap.
877 static void put_row_DITHER_pixmap( PUT_ROW_ARGS
)
879 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
880 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
882 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
883 XMesaDrawable buffer
= xrb
->drawable
;
884 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
889 for (i
=0;i
<n
;i
++,x
++) {
891 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
892 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
897 /* draw all pixels */
898 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
900 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
902 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
908 * Write a span of PF_DITHER pixels to a pixmap (no alpha).
910 static void put_row_rgb_DITHER_pixmap( RGB_SPAN_ARGS
)
912 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
913 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
915 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
916 XMesaDrawable buffer
= xrb
->drawable
;
917 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
922 for (i
=0;i
<n
;i
++,x
++) {
924 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
925 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
930 /* draw all pixels */
931 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
933 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
935 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
941 * Write a span of PF_1BIT pixels to a pixmap.
943 static void put_row_1BIT_pixmap( PUT_ROW_ARGS
)
945 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
946 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
948 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
949 XMesaDrawable buffer
= xrb
->drawable
;
950 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
955 for (i
=0;i
<n
;i
++,x
++) {
957 XMesaSetForeground( dpy
, gc
,
958 DITHER_1BIT( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
959 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
964 /* draw all pixels */
965 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
967 XMesaPutPixel( rowimg
, i
, 0,
968 DITHER_1BIT( x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
970 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
976 * Write a span of PF_1BIT pixels to a pixmap (no alpha).
978 static void put_row_rgb_1BIT_pixmap( RGB_SPAN_ARGS
)
980 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
981 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
983 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
984 XMesaDrawable buffer
= xrb
->drawable
;
985 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
990 for (i
=0;i
<n
;i
++,x
++) {
992 XMesaSetForeground( dpy
, gc
,
993 DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
994 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
999 /* draw all pixels */
1000 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1002 XMesaPutPixel( rowimg
, i
, 0,
1003 DITHER_1BIT(x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
1005 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1011 * Write a span of PF_HPCR pixels to a pixmap.
1013 static void put_row_HPCR_pixmap( PUT_ROW_ARGS
)
1015 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1016 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1018 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1019 XMesaDrawable buffer
= xrb
->drawable
;
1020 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1024 for (i
=0;i
<n
;i
++,x
++) {
1026 XMesaSetForeground( dpy
, gc
,
1027 DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1028 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1033 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1034 register GLubyte
*ptr
= (GLubyte
*) XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
->data
;
1036 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1038 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1044 * Write a span of PF_HPCR pixels to a pixmap (no alpha).
1046 static void put_row_rgb_HPCR_pixmap( RGB_SPAN_ARGS
)
1048 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1049 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1051 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1052 XMesaDrawable buffer
= xrb
->drawable
;
1053 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1057 for (i
=0;i
<n
;i
++,x
++) {
1059 XMesaSetForeground( dpy
, gc
,
1060 DITHER_HPCR(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
1061 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1066 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1067 register GLubyte
*ptr
= (GLubyte
*) XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
->data
;
1069 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1071 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1076 * Write a span of PF_LOOKUP pixels to a pixmap.
1078 static void put_row_LOOKUP_pixmap( PUT_ROW_ARGS
)
1080 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1081 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1083 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1084 XMesaDrawable buffer
= xrb
->drawable
;
1085 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1090 for (i
=0;i
<n
;i
++,x
++) {
1092 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1093 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1098 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1100 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
1102 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1108 * Write a span of PF_LOOKUP pixels to a pixmap (no alpha).
1110 static void put_row_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS
)
1112 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1113 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1115 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1116 XMesaDrawable buffer
= xrb
->drawable
;
1117 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1122 for (i
=0;i
<n
;i
++,x
++) {
1124 XMesaSetForeground( dpy
, gc
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1125 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1130 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1132 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1134 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1140 * Write a span of PF_GRAYSCALE pixels to a pixmap.
1142 static void put_row_GRAYSCALE_pixmap( PUT_ROW_ARGS
)
1144 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1145 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1147 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1148 XMesaDrawable buffer
= xrb
->drawable
;
1149 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1153 for (i
=0;i
<n
;i
++,x
++) {
1155 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1156 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1161 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1163 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
1165 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1171 * Write a span of PF_GRAYSCALE pixels to a pixmap (no alpha).
1173 static void put_row_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS
)
1175 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1176 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1178 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1179 XMesaDrawable buffer
= xrb
->drawable
;
1180 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1184 for (i
=0;i
<n
;i
++,x
++) {
1186 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1187 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1192 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1194 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1196 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1201 * Write a span of PF_TRUECOLOR pixels to an XImage.
1203 static void put_row_TRUECOLOR_ximage( PUT_ROW_ARGS
)
1205 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1206 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1208 XMesaImage
*img
= xrb
->ximage
;
1212 for (i
=0;i
<n
;i
++,x
++) {
1215 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1216 XMesaPutPixel( img
, x
, y
, p
);
1221 /* draw all pixels */
1222 for (i
=0;i
<n
;i
++,x
++) {
1224 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1225 XMesaPutPixel( img
, x
, y
, p
);
1232 * Write a span of PF_TRUECOLOR pixels to an XImage (no alpha).
1234 static void put_row_rgb_TRUECOLOR_ximage( RGB_SPAN_ARGS
)
1236 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1237 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1239 XMesaImage
*img
= xrb
->ximage
;
1243 for (i
=0;i
<n
;i
++,x
++) {
1246 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1247 XMesaPutPixel( img
, x
, y
, p
);
1252 /* draw all pixels */
1253 for (i
=0;i
<n
;i
++,x
++) {
1255 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1256 XMesaPutPixel( img
, x
, y
, p
);
1263 * Write a span of PF_TRUEDITHER pixels to an XImage.
1265 static void put_row_TRUEDITHER_ximage( PUT_ROW_ARGS
)
1267 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1268 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1270 XMesaImage
*img
= xrb
->ximage
;
1274 for (i
=0;i
<n
;i
++,x
++) {
1277 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1278 XMesaPutPixel( img
, x
, y
, p
);
1283 /* draw all pixels */
1284 for (i
=0;i
<n
;i
++,x
++) {
1286 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1287 XMesaPutPixel( img
, x
, y
, p
);
1294 * Write a span of PF_TRUEDITHER pixels to an XImage (no alpha).
1296 static void put_row_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS
)
1298 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1299 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1301 XMesaImage
*img
= xrb
->ximage
;
1305 for (i
=0;i
<n
;i
++,x
++) {
1308 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1309 XMesaPutPixel( img
, x
, y
, p
);
1314 /* draw all pixels */
1315 for (i
=0;i
<n
;i
++,x
++) {
1317 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1318 XMesaPutPixel( img
, x
, y
, p
);
1325 * Write a span of PF_8A8B8G8R-format pixels to an ximage.
1327 static void put_row_8A8B8G8R_ximage( PUT_ROW_ARGS
)
1329 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1332 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1337 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1342 /* draw all pixels */
1344 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1351 * Write a span of PF_8A8B8G8R-format pixels to an ximage (no alpha).
1353 static void put_row_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS
)
1355 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1358 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1362 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1367 /* draw all pixels */
1369 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1375 * Write a span of PF_8A8R8G8B-format pixels to an ximage.
1377 static void put_row_8A8R8G8B_ximage( PUT_ROW_ARGS
)
1379 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1382 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1386 ptr
[i
] = PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1391 /* draw all pixels */
1393 ptr
[i
] = PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1400 * Write a span of PF_8A8R8G8B-format pixels to an ximage (no alpha).
1402 static void put_row_rgb_8A8R8G8B_ximage( RGB_SPAN_ARGS
)
1404 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1407 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1411 ptr
[i
] = PACK_8A8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1416 /* draw all pixels */
1418 ptr
[i
] = PACK_8A8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1425 * Write a span of PF_8R8G8B-format pixels to an ximage.
1427 static void put_row_8R8G8B_ximage( PUT_ROW_ARGS
)
1429 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1432 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1436 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1442 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1449 * Write a span of PF_8R8G8B24-format pixels to an ximage.
1451 static void put_row_8R8G8B24_ximage( PUT_ROW_ARGS
)
1453 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1456 register GLubyte
*ptr
= (GLubyte
*) PIXEL_ADDR3(xrb
, x
, y
);
1460 GLuint
*ptr4
= (GLuint
*) ptr
;
1461 register GLuint pixel
= *ptr4
;
1462 switch (3 & (int)(ptr
- (GLubyte
*)ptr4
)) {
1464 pixel
&= 0xff000000;
1465 pixel
|= rgba
[i
][BCOMP
];
1466 pixel
|= rgba
[i
][GCOMP
] << 8;
1467 pixel
|= rgba
[i
][RCOMP
] << 16;
1471 pixel
&= 0x00ffffff;
1472 pixel
|= rgba
[i
][BCOMP
] << 24;
1474 pixel
= *ptr4
& 0xffff0000;
1475 pixel
|= rgba
[i
][GCOMP
];
1476 pixel
|= rgba
[i
][RCOMP
] << 8;
1480 pixel
&= 0x0000ffff;
1481 pixel
|= rgba
[i
][BCOMP
] << 16;
1482 pixel
|= rgba
[i
][GCOMP
] << 24;
1484 pixel
= *ptr4
& 0xffffff00;
1485 pixel
|= rgba
[i
][RCOMP
];
1489 pixel
&= 0x000000ff;
1490 pixel
|= rgba
[i
][BCOMP
] << 8;
1491 pixel
|= rgba
[i
][GCOMP
] << 16;
1492 pixel
|= rgba
[i
][RCOMP
] << 24;
1501 /* write all pixels */
1503 GLuint
*ptr4
= (GLuint
*) ptr
;
1504 register GLuint pixel
= *ptr4
;
1505 int index
= (int)(ptr
- (GLubyte
*)ptr4
);
1506 register GLuint i
= 0;
1511 pixel
&= 0x00ffffff;
1512 pixel
|= rgba
[i
][BCOMP
] << 24;
1514 pixel
= *ptr4
& 0xffff0000;
1515 pixel
|= rgba
[i
][GCOMP
];
1516 pixel
|= rgba
[i
++][RCOMP
] << 8;
1521 pixel
&= 0x0000ffff;
1522 pixel
|= rgba
[i
][BCOMP
] << 16;
1523 pixel
|= rgba
[i
][GCOMP
] << 24;
1525 pixel
= *ptr4
& 0xffffff00;
1526 pixel
|= rgba
[i
++][RCOMP
];
1531 pixel
&= 0x000000ff;
1532 pixel
|= rgba
[i
][BCOMP
] << 8;
1533 pixel
|= rgba
[i
][GCOMP
] << 16;
1534 pixel
|= rgba
[i
++][RCOMP
] << 24;
1541 pixel
= rgba
[i
][BCOMP
];
1542 pixel
|= rgba
[i
][GCOMP
] << 8;
1543 pixel
|= rgba
[i
++][RCOMP
] << 16;
1544 pixel
|= rgba
[i
][BCOMP
] << 24;
1546 pixel
= rgba
[i
][GCOMP
];
1547 pixel
|= rgba
[i
++][RCOMP
] << 8;
1548 pixel
|= rgba
[i
][BCOMP
] << 16;
1549 pixel
|= rgba
[i
][GCOMP
] << 24;
1551 pixel
= rgba
[i
++][RCOMP
];
1552 pixel
|= rgba
[i
][BCOMP
] << 8;
1553 pixel
|= rgba
[i
][GCOMP
] << 16;
1554 pixel
|= rgba
[i
++][RCOMP
] << 24;
1562 pixel
= *ptr4
& 0xff000000;
1563 pixel
|= rgba
[i
][BCOMP
];
1564 pixel
|= rgba
[i
][GCOMP
] << 8;
1565 pixel
|= rgba
[i
][RCOMP
] << 16;
1569 pixel
= rgba
[i
][BCOMP
];
1570 pixel
|= rgba
[i
][GCOMP
] << 8;
1571 pixel
|= rgba
[i
++][RCOMP
] << 16;
1572 pixel
|= rgba
[i
][BCOMP
] << 24;
1574 pixel
= *ptr4
& 0xffff0000;
1575 pixel
|= rgba
[i
][GCOMP
];
1576 pixel
|= rgba
[i
][RCOMP
] << 8;
1580 pixel
= rgba
[i
][BCOMP
];
1581 pixel
|= rgba
[i
][GCOMP
] << 8;
1582 pixel
|= rgba
[i
++][RCOMP
] << 16;
1583 pixel
|= rgba
[i
][BCOMP
] << 24;
1585 pixel
= rgba
[i
][GCOMP
];
1586 pixel
|= rgba
[i
++][RCOMP
] << 8;
1587 pixel
|= rgba
[i
][BCOMP
] << 16;
1588 pixel
|= rgba
[i
][GCOMP
] << 24;
1590 pixel
= *ptr4
& 0xffffff00;
1591 pixel
|= rgba
[i
][RCOMP
];
1600 * Write a span of PF_8R8G8B-format pixels to an ximage (no alpha).
1602 static void put_row_rgb_8R8G8B_ximage( RGB_SPAN_ARGS
)
1604 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1607 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1611 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1616 /* draw all pixels */
1618 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1625 * Write a span of PF_8R8G8B24-format pixels to an ximage (no alpha).
1627 static void put_row_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS
)
1629 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1632 register GLubyte
*ptr
= (GLubyte
*) PIXEL_ADDR3(xrb
, x
, y
);
1636 *ptr
++ = rgb
[i
][BCOMP
];
1637 *ptr
++ = rgb
[i
][GCOMP
];
1638 *ptr
++ = rgb
[i
][RCOMP
];
1646 /* draw all pixels */
1648 *ptr
++ = rgb
[i
][BCOMP
];
1649 *ptr
++ = rgb
[i
][GCOMP
];
1650 *ptr
++ = rgb
[i
][RCOMP
];
1657 * Write a span of PF_5R6G5B-format pixels to an ximage.
1659 static void put_row_5R6G5B_ximage( PUT_ROW_ARGS
)
1661 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1664 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1668 ptr
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1673 /* draw all pixels */
1674 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1675 GLuint
*ptr32
= (GLuint
*) ptr
;
1676 GLuint extraPixel
= (n
& 1);
1678 for (i
= 0; i
< n
; i
+= 2) {
1680 p0
= PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1681 p1
= PACK_5R6G5B(rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
]);
1682 *ptr32
++ = (p1
<< 16) | p0
;
1685 ptr
[n
] = PACK_5R6G5B(rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1688 for (i
= 0; i
< n
; i
++) {
1689 ptr
[i
] = PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1697 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage.
1699 static void put_row_DITHER_5R6G5B_ximage( PUT_ROW_ARGS
)
1701 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1703 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1705 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1706 const GLint y2
= YFLIP(xrb
, y
);
1708 for (i
=0;i
<n
;i
++,x
++) {
1710 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1715 /* draw all pixels */
1716 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1717 GLuint
*ptr32
= (GLuint
*) ptr
;
1718 GLuint extraPixel
= (n
& 1);
1720 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1722 PACK_TRUEDITHER( p0
, x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1723 PACK_TRUEDITHER( p1
, x
+1, y2
, rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
] );
1724 *ptr32
++ = (p1
<< 16) | p0
;
1727 PACK_TRUEDITHER( ptr
[n
], x
+n
, y2
, rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1730 for (i
= 0; i
< n
; i
++, x
++) {
1731 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1739 * Write a span of PF_5R6G5B-format pixels to an ximage (no alpha).
1741 static void put_row_rgb_5R6G5B_ximage( RGB_SPAN_ARGS
)
1743 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1746 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1750 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1755 /* draw all pixels */
1756 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1757 GLuint
*ptr32
= (GLuint
*) ptr
;
1758 GLuint extraPixel
= (n
& 1);
1760 for (i
= 0; i
< n
; i
+= 2) {
1762 p0
= PACK_5R6G5B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1763 p1
= PACK_5R6G5B(rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
]);
1764 *ptr32
++ = (p1
<< 16) | p0
;
1767 ptr
[n
] = PACK_5R6G5B(rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1771 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1779 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage (no alpha).
1781 static void put_row_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS
)
1783 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1785 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1787 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1789 for (i
=0;i
<n
;i
++,x
++) {
1791 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1796 /* draw all pixels */
1797 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1798 GLuint
*ptr32
= (GLuint
*) ptr
;
1799 GLuint extraPixel
= (n
& 1);
1801 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1803 PACK_TRUEDITHER( p0
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1804 PACK_TRUEDITHER( p1
, x
+1, y
, rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
] );
1805 *ptr32
++ = (p1
<< 16) | p0
;
1808 PACK_TRUEDITHER( ptr
[n
], x
+n
, y
, rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1811 for (i
=0;i
<n
;i
++,x
++) {
1812 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1820 * Write a span of PF_DITHER pixels to an XImage.
1822 static void put_row_DITHER_ximage( PUT_ROW_ARGS
)
1824 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1826 XMesaImage
*img
= xrb
->ximage
;
1828 int yy
= YFLIP(xrb
, y
);
1831 for (i
=0;i
<n
;i
++,x
++) {
1833 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1838 /* draw all pixels */
1839 for (i
=0;i
<n
;i
++,x
++) {
1840 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1847 * Write a span of PF_DITHER pixels to an XImage (no alpha).
1849 static void put_row_rgb_DITHER_ximage( RGB_SPAN_ARGS
)
1851 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1853 XMesaImage
*img
= xrb
->ximage
;
1855 int yy
= YFLIP(xrb
, y
);
1858 for (i
=0;i
<n
;i
++,x
++) {
1860 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1865 /* draw all pixels */
1866 for (i
=0;i
<n
;i
++,x
++) {
1867 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1875 * Write a span of 8-bit PF_DITHER pixels to an XImage.
1877 static void put_row_DITHER8_ximage( PUT_ROW_ARGS
)
1879 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1882 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
1885 for (i
=0;i
<n
;i
++,x
++) {
1887 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1892 for (i
=0;i
<n
;i
++,x
++) {
1893 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1899 static void put_row_rgb_DITHER8_ximage( RGB_SPAN_ARGS
)
1901 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1904 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
1907 for (i
=0;i
<n
;i
++,x
++) {
1909 ptr
[i
] = (GLubyte
) XDITHER( x
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
1914 const GLubyte
*data
= (GLubyte
*) rgb
;
1915 for (i
=0;i
<n
;i
++,x
++) {
1916 /*ptr[i] = XDITHER( x, rgb[i][0], rgb[i][1], rgb[i][2] );*/
1917 ptr
[i
] = (GLubyte
) XDITHER( x
, data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
1925 * Write a span of PF_1BIT pixels to an XImage.
1927 static void put_row_1BIT_ximage( PUT_ROW_ARGS
)
1929 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1930 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1932 XMesaImage
*img
= xrb
->ximage
;
1937 for (i
=0;i
<n
;i
++,x
++) {
1939 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]));
1944 for (i
=0;i
<n
;i
++,x
++) {
1945 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
1952 * Write a span of PF_1BIT pixels to an XImage (no alpha).
1954 static void put_row_rgb_1BIT_ximage( RGB_SPAN_ARGS
)
1956 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1957 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1959 XMesaImage
*img
= xrb
->ximage
;
1964 for (i
=0;i
<n
;i
++,x
++) {
1966 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]));
1971 for (i
=0;i
<n
;i
++,x
++) {
1972 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
1979 * Write a span of PF_HPCR pixels to an XImage.
1981 static void put_row_HPCR_ximage( PUT_ROW_ARGS
)
1983 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1985 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1987 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
1989 for (i
=0;i
<n
;i
++,x
++) {
1991 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1996 /* draw all pixels */
1997 for (i
=0;i
<n
;i
++,x
++) {
1998 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2005 * Write a span of PF_HPCR pixels to an XImage (no alpha).
2007 static void put_row_rgb_HPCR_ximage( RGB_SPAN_ARGS
)
2009 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2011 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2013 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2015 for (i
=0;i
<n
;i
++,x
++) {
2017 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2022 /* draw all pixels */
2023 for (i
=0;i
<n
;i
++,x
++) {
2024 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2031 * Write a span of PF_LOOKUP pixels to an XImage.
2033 static void put_row_LOOKUP_ximage( PUT_ROW_ARGS
)
2035 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2037 XMesaImage
*img
= xrb
->ximage
;
2042 for (i
=0;i
<n
;i
++,x
++) {
2044 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2049 /* draw all pixels */
2050 for (i
=0;i
<n
;i
++,x
++) {
2051 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2058 * Write a span of PF_LOOKUP pixels to an XImage (no alpha).
2060 static void put_row_rgb_LOOKUP_ximage( RGB_SPAN_ARGS
)
2062 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2064 XMesaImage
*img
= xrb
->ximage
;
2069 for (i
=0;i
<n
;i
++,x
++) {
2071 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2076 /* draw all pixels */
2077 for (i
=0;i
<n
;i
++,x
++) {
2078 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2085 * Write a span of 8-bit PF_LOOKUP pixels to an XImage.
2087 static void put_row_LOOKUP8_ximage( PUT_ROW_ARGS
)
2089 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2092 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2095 for (i
=0;i
<n
;i
++,x
++) {
2097 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2102 /* draw all pixels */
2103 for (i
=0;i
<n
;i
++,x
++) {
2104 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2110 static void put_row_rgb_LOOKUP8_ximage( RGB_SPAN_ARGS
)
2112 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2115 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2118 for (i
=0;i
<n
;i
++,x
++) {
2120 ptr
[i
] = (GLubyte
) LOOKUP( rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
2125 /* draw all pixels */
2126 const GLubyte
*data
= (GLubyte
*) rgb
;
2127 for (i
=0;i
<n
;i
++,x
++) {
2128 /*ptr[i] = LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );*/
2129 ptr
[i
] = (GLubyte
) LOOKUP( data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
2136 * Write a span of PF_GRAYSCALE pixels to an XImage.
2138 static void put_row_GRAYSCALE_ximage( PUT_ROW_ARGS
)
2140 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2142 XMesaImage
*img
= xrb
->ximage
;
2146 for (i
=0;i
<n
;i
++,x
++) {
2148 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2153 /* draw all pixels */
2154 for (i
=0;i
<n
;i
++,x
++) {
2155 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2162 * Write a span of PF_GRAYSCALE pixels to an XImage (no alpha).
2164 static void put_row_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS
)
2166 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2168 XMesaImage
*img
= xrb
->ximage
;
2172 for (i
=0;i
<n
;i
++,x
++) {
2174 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2179 /* draw all pixels */
2180 for (i
=0;i
<n
;i
++,x
++) {
2181 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2188 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage.
2190 static void put_row_GRAYSCALE8_ximage( PUT_ROW_ARGS
)
2192 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2195 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2199 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2204 /* draw all pixels */
2206 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2213 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage (no alpha).
2215 static void put_row_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS
)
2217 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2220 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2224 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2229 /* draw all pixels */
2231 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2239 /**********************************************************************/
2240 /*** Write COLOR PIXEL functions ***/
2241 /**********************************************************************/
2244 #define PUT_VALUES_ARGS \
2245 struct gl_context *ctx, struct gl_renderbuffer *rb, \
2246 GLuint n, const GLint x[], const GLint y[], \
2247 const void *values, const GLubyte mask[]
2251 * Write an array of PF_TRUECOLOR pixels to a pixmap.
2253 static void put_values_TRUECOLOR_pixmap( PUT_VALUES_ARGS
)
2255 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2256 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2258 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2259 XMesaDrawable buffer
= xrb
->drawable
;
2260 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2265 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2266 XMesaSetForeground( dpy
, gc
, p
);
2267 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2274 * Write an array of PF_TRUEDITHER pixels to a pixmap.
2276 static void put_values_TRUEDITHER_pixmap( PUT_VALUES_ARGS
)
2278 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2279 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2281 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2282 XMesaDrawable buffer
= xrb
->drawable
;
2283 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2288 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2289 XMesaSetForeground( dpy
, gc
, p
);
2290 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2297 * Write an array of PF_8A8B8G8R pixels to a pixmap.
2299 static void put_values_8A8B8G8R_pixmap( PUT_VALUES_ARGS
)
2301 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2302 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2304 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2305 XMesaDrawable buffer
= xrb
->drawable
;
2306 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2310 XMesaSetForeground( dpy
, gc
,
2311 PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] ));
2312 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2318 * Write an array of PF_8A8R8G8B pixels to a pixmap.
2320 static void put_values_8A8R8G8B_pixmap( PUT_VALUES_ARGS
)
2322 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2323 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2325 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2326 XMesaDrawable buffer
= xrb
->drawable
;
2327 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2331 XMesaSetForeground( dpy
, gc
,
2332 PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] ));
2333 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2339 * Write an array of PF_8R8G8B pixels to a pixmap.
2341 static void put_values_8R8G8B_pixmap( PUT_VALUES_ARGS
)
2343 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2344 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2346 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2347 XMesaDrawable buffer
= xrb
->drawable
;
2348 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2352 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2353 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2360 * Write an array of PF_8R8G8B24 pixels to a pixmap.
2362 static void put_values_8R8G8B24_pixmap( PUT_VALUES_ARGS
)
2364 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2365 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2367 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2368 XMesaDrawable buffer
= xrb
->drawable
;
2369 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2373 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2374 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2381 * Write an array of PF_5R6G5B pixels to a pixmap.
2383 static void put_values_5R6G5B_pixmap( PUT_VALUES_ARGS
)
2385 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2386 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2388 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2389 XMesaDrawable buffer
= xrb
->drawable
;
2390 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2394 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2395 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2402 * Write an array of PF_DITHER_5R6G5B pixels to a pixmap.
2404 static void put_values_DITHER_5R6G5B_pixmap( PUT_VALUES_ARGS
)
2406 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2407 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2409 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2410 XMesaDrawable buffer
= xrb
->drawable
;
2411 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2416 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2417 XMesaSetForeground( dpy
, gc
, p
);
2418 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2425 * Write an array of PF_DITHER pixels to a pixmap.
2427 static void put_values_DITHER_pixmap( PUT_VALUES_ARGS
)
2429 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2430 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2432 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2433 XMesaDrawable buffer
= xrb
->drawable
;
2434 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2439 XMesaSetForeground( dpy
, gc
,
2440 DITHER(x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2441 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2448 * Write an array of PF_1BIT pixels to a pixmap.
2450 static void put_values_1BIT_pixmap( PUT_VALUES_ARGS
)
2452 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2453 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2455 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2456 XMesaDrawable buffer
= xrb
->drawable
;
2457 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2462 XMesaSetForeground( dpy
, gc
,
2463 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2464 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2471 * Write an array of PF_HPCR pixels to a pixmap.
2473 static void put_values_HPCR_pixmap( PUT_VALUES_ARGS
)
2475 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2476 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2478 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2479 XMesaDrawable buffer
= xrb
->drawable
;
2480 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2484 XMesaSetForeground( dpy
, gc
,
2485 DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2486 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2493 * Write an array of PF_LOOKUP pixels to a pixmap.
2495 static void put_values_LOOKUP_pixmap( PUT_VALUES_ARGS
)
2497 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2498 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2500 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2501 XMesaDrawable buffer
= xrb
->drawable
;
2502 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2507 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2508 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2515 * Write an array of PF_GRAYSCALE pixels to a pixmap.
2517 static void put_values_GRAYSCALE_pixmap( PUT_VALUES_ARGS
)
2519 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2520 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2522 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2523 XMesaDrawable buffer
= xrb
->drawable
;
2524 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2528 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2529 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2536 * Write an array of PF_TRUECOLOR pixels to an ximage.
2538 static void put_values_TRUECOLOR_ximage( PUT_VALUES_ARGS
)
2540 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2541 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2543 XMesaImage
*img
= xrb
->ximage
;
2548 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2549 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), p
);
2556 * Write an array of PF_TRUEDITHER pixels to an XImage.
2558 static void put_values_TRUEDITHER_ximage( PUT_VALUES_ARGS
)
2560 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2561 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2563 XMesaImage
*img
= xrb
->ximage
;
2568 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2569 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), p
);
2576 * Write an array of PF_8A8B8G8R pixels to an ximage.
2578 static void put_values_8A8B8G8R_ximage( PUT_VALUES_ARGS
)
2580 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2585 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
2586 *ptr
= PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
2592 * Write an array of PF_8A8R8G8B pixels to an ximage.
2594 static void put_values_8A8R8G8B_ximage( PUT_VALUES_ARGS
)
2596 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2601 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
2602 *ptr
= PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
2609 * Write an array of PF_8R8G8B pixels to an ximage.
2611 static void put_values_8R8G8B_ximage( PUT_VALUES_ARGS
)
2613 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2618 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
2619 *ptr
= PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2626 * Write an array of PF_8R8G8B24 pixels to an ximage.
2628 static void put_values_8R8G8B24_ximage( PUT_VALUES_ARGS
)
2630 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2635 bgr_t
*ptr
= PIXEL_ADDR3(xrb
, x
[i
], y
[i
] );
2636 ptr
->r
= rgba
[i
][RCOMP
];
2637 ptr
->g
= rgba
[i
][GCOMP
];
2638 ptr
->b
= rgba
[i
][BCOMP
];
2645 * Write an array of PF_5R6G5B pixels to an ximage.
2647 static void put_values_5R6G5B_ximage( PUT_VALUES_ARGS
)
2649 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2654 GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
[i
], y
[i
] );
2655 *ptr
= PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2662 * Write an array of PF_DITHER_5R6G5B pixels to an ximage.
2664 static void put_values_DITHER_5R6G5B_ximage( PUT_VALUES_ARGS
)
2666 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2668 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2672 GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
[i
], y
[i
] );
2673 PACK_TRUEDITHER( *ptr
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2680 * Write an array of PF_DITHER pixels to an XImage.
2682 static void put_values_DITHER_ximage( PUT_VALUES_ARGS
)
2684 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2686 XMesaImage
*img
= xrb
->ximage
;
2691 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
2692 DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2699 * Write an array of 8-bit PF_DITHER pixels to an XImage.
2701 static void put_values_DITHER8_ximage( PUT_VALUES_ARGS
)
2703 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2709 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
2710 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2717 * Write an array of PF_1BIT pixels to an XImage.
2719 static void put_values_1BIT_ximage( PUT_VALUES_ARGS
)
2721 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2722 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2724 XMesaImage
*img
= xrb
->ximage
;
2729 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
2730 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2737 * Write an array of PF_HPCR pixels to an XImage.
2739 static void put_values_HPCR_ximage( PUT_VALUES_ARGS
)
2741 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2743 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2747 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
2748 *ptr
= (GLubyte
) DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2755 * Write an array of PF_LOOKUP pixels to an XImage.
2757 static void put_values_LOOKUP_ximage( PUT_VALUES_ARGS
)
2759 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2761 XMesaImage
*img
= xrb
->ximage
;
2766 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), LOOKUP(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2773 * Write an array of 8-bit PF_LOOKUP pixels to an XImage.
2775 static void put_values_LOOKUP8_ximage( PUT_VALUES_ARGS
)
2777 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2783 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
2784 *ptr
= (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2791 * Write an array of PF_GRAYSCALE pixels to an XImage.
2793 static void put_values_GRAYSCALE_ximage( PUT_VALUES_ARGS
)
2795 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2797 XMesaImage
*img
= xrb
->ximage
;
2801 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
2802 GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2809 * Write an array of 8-bit PF_GRAYSCALE pixels to an XImage.
2811 static void put_values_GRAYSCALE8_ximage( PUT_VALUES_ARGS
)
2813 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2818 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
] );
2819 *ptr
= (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2827 /**********************************************************************/
2828 /*** Write MONO COLOR SPAN functions ***/
2829 /**********************************************************************/
2831 #define PUT_MONO_ROW_ARGS \
2832 struct gl_context *ctx, struct gl_renderbuffer *rb, \
2833 GLuint n, GLint x, GLint y, const void *value, \
2834 const GLubyte mask[]
2839 * Write a span of identical pixels to a pixmap.
2841 static void put_mono_row_pixmap( PUT_MONO_ROW_ARGS
)
2843 const GLubyte
*color
= (const GLubyte
*) value
;
2845 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2846 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2847 XMesaDrawable buffer
= xrb
->drawable
;
2848 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2849 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
2850 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2852 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
2855 /* New code contributed by Jeff Epler and cleaned up by Keith
2858 for (i
= 0; i
< n
; ) {
2861 /* Identify and emit contiguous rendered pixels
2863 while (i
< n
&& (!mask
|| mask
[i
]))
2867 XMesaFillRectangle( dpy
, buffer
, gc
,
2868 (int)(x
+start
), (int) y
,
2871 /* Eat up non-rendered pixels
2873 while (i
< n
&& !mask
[i
])
2881 put_mono_row_ci_pixmap( PUT_MONO_ROW_ARGS
)
2883 GLuint colorIndex
= *((GLuint
*) value
);
2884 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2886 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2887 XMesaDrawable buffer
= xrb
->drawable
;
2888 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2890 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
2893 for (i
= 0 ; i
< n
;) {
2896 /* Identify and emit contiguous rendered pixels
2898 while (i
< n
&& (!mask
|| mask
[i
]))
2902 XMesaFillRectangle( dpy
, buffer
, gc
,
2903 (int)(x
+start
), (int) y
,
2906 /* Eat up non-rendered pixels
2908 while (i
< n
&& !mask
[i
])
2916 * Write a span of PF_TRUEDITHER pixels to a pixmap.
2918 static void put_mono_row_TRUEDITHER_pixmap( PUT_MONO_ROW_ARGS
)
2920 const GLubyte
*color
= (const GLubyte
*) value
;
2922 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2923 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2924 XMesaDrawable buffer
= xrb
->drawable
;
2925 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2926 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2928 int yy
= YFLIP(xrb
, y
);
2929 for (i
=0;i
<n
;i
++,x
++) {
2930 if (!mask
|| mask
[i
]) {
2932 PACK_TRUEDITHER(p
, x
, yy
, r
, g
, b
);
2933 XMesaSetForeground( dpy
, gc
, p
);
2934 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2941 * Write a span of PF_DITHER pixels to a pixmap.
2943 static void put_mono_row_DITHER_pixmap( PUT_MONO_ROW_ARGS
)
2945 const GLubyte
*color
= (const GLubyte
*) value
;
2947 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2948 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2949 XMesaDrawable buffer
= xrb
->drawable
;
2950 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2951 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2953 int yy
= YFLIP(xrb
, y
);
2955 for (i
=0;i
<n
;i
++,x
++) {
2956 if (!mask
|| mask
[i
]) {
2957 XMesaSetForeground( dpy
, gc
, XDITHER( x
, r
, g
, b
) );
2958 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2965 * Write a span of PF_1BIT pixels to a pixmap.
2967 static void put_mono_row_1BIT_pixmap( PUT_MONO_ROW_ARGS
)
2969 const GLubyte
*color
= (const GLubyte
*) value
;
2971 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2972 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2973 XMesaDrawable buffer
= xrb
->drawable
;
2974 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2975 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2979 for (i
=0;i
<n
;i
++,x
++) {
2980 if (!mask
|| mask
[i
]) {
2981 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
, y
, r
, g
, b
) );
2982 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
2989 * Write a span of identical pixels to an XImage.
2991 static void put_mono_row_ximage( PUT_MONO_ROW_ARGS
)
2993 const GLubyte
*color
= (const GLubyte
*) value
;
2995 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2996 XMesaImage
*img
= xrb
->ximage
;
2998 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
2999 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3001 for (i
=0;i
<n
;i
++,x
++) {
3002 if (!mask
|| mask
[i
]) {
3003 XMesaPutPixel( img
, x
, y
, pixel
);
3010 put_mono_row_ci_ximage( PUT_MONO_ROW_ARGS
)
3012 const GLuint colorIndex
= *((GLuint
*) value
);
3014 XMesaImage
*img
= xrb
->ximage
;
3017 for (i
=0;i
<n
;i
++,x
++) {
3018 if (!mask
|| mask
[i
]) {
3019 XMesaPutPixel( img
, x
, y
, colorIndex
);
3026 * Write a span of identical PF_TRUEDITHER pixels to an XImage.
3028 static void put_mono_row_TRUEDITHER_ximage( PUT_MONO_ROW_ARGS
)
3030 const GLubyte
*color
= (const GLubyte
*) value
;
3032 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3033 XMesaImage
*img
= xrb
->ximage
;
3034 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3038 if (!mask
|| mask
[i
]) {
3040 PACK_TRUEDITHER( p
, x
+i
, y
, r
, g
, b
);
3041 XMesaPutPixel( img
, x
+i
, y
, p
);
3048 * Write a span of identical 8A8B8G8R pixels to an XImage.
3050 static void put_mono_row_8A8B8G8R_ximage( PUT_MONO_ROW_ARGS
)
3052 const GLubyte
*color
= (const GLubyte
*) value
;
3054 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
]) {
3067 * Write a span of identical 8A8R8G8B pixels to an XImage.
3069 static void put_mono_row_8A8R8G8B_ximage( PUT_MONO_ROW_ARGS
)
3071 const GLubyte
*color
= (const GLubyte
*) value
;
3074 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3075 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3076 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3077 ptr
= PIXEL_ADDR4(xrb
, x
, y
);
3079 if (!mask
|| mask
[i
]) {
3087 * Write a span of identical 8R8G8B pixels to an XImage.
3089 static void put_mono_row_8R8G8B_ximage( PUT_MONO_ROW_ARGS
)
3091 const GLubyte
*color
= (const GLubyte
*) value
;
3093 const GLuint pixel
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3094 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
3097 if (!mask
|| mask
[i
]) {
3105 * Write a span of identical 8R8G8B pixels to an XImage.
3107 static void put_mono_row_8R8G8B24_ximage( PUT_MONO_ROW_ARGS
)
3109 const GLubyte
*color
= (const GLubyte
*) value
;
3111 const GLubyte r
= color
[RCOMP
];
3112 const GLubyte g
= color
[GCOMP
];
3113 const GLubyte b
= color
[BCOMP
];
3115 bgr_t
*ptr
= PIXEL_ADDR3(xrb
, x
, y
);
3117 if (!mask
|| mask
[i
]) {
3127 * Write a span of identical DITHER pixels to an XImage.
3129 static void put_mono_row_DITHER_ximage( PUT_MONO_ROW_ARGS
)
3131 const GLubyte
*color
= (const GLubyte
*) value
;
3133 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3134 XMesaImage
*img
= xrb
->ximage
;
3135 int yy
= YFLIP(xrb
, y
);
3138 for (i
=0;i
<n
;i
++,x
++) {
3139 if (!mask
|| mask
[i
]) {
3140 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, r
, g
, b
) );
3147 * Write a span of identical 8-bit DITHER pixels to an XImage.
3149 static void put_mono_row_DITHER8_ximage( PUT_MONO_ROW_ARGS
)
3151 const GLubyte
*color
= (const GLubyte
*) value
;
3153 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3154 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
3157 for (i
=0;i
<n
;i
++,x
++) {
3158 if (!mask
|| mask
[i
]) {
3159 ptr
[i
] = (GLubyte
) XDITHER( x
, r
, g
, b
);
3166 * Write a span of identical 8-bit LOOKUP pixels to an XImage.
3168 static void put_mono_row_LOOKUP8_ximage( PUT_MONO_ROW_ARGS
)
3170 const GLubyte
*color
= (const GLubyte
*) value
;
3173 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
3176 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3178 if (!mask
|| mask
[i
]) {
3186 * Write a span of identical PF_1BIT pixels to an XImage.
3188 static void put_mono_row_1BIT_ximage( PUT_MONO_ROW_ARGS
)
3190 const GLubyte
*color
= (const GLubyte
*) value
;
3191 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3193 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3194 XMesaImage
*img
= xrb
->ximage
;
3198 for (i
=0;i
<n
;i
++,x
++) {
3199 if (!mask
|| mask
[i
]) {
3200 XMesaPutPixel( img
, x
, y
, DITHER_1BIT( x
, y
, r
, g
, b
) );
3207 * Write a span of identical HPCR pixels to an XImage.
3209 static void put_mono_row_HPCR_ximage( PUT_MONO_ROW_ARGS
)
3211 const GLubyte
*color
= (const GLubyte
*) value
;
3213 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3214 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3215 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
3217 for (i
=0;i
<n
;i
++,x
++) {
3218 if (!mask
|| mask
[i
]) {
3219 ptr
[i
] = DITHER_HPCR( x
, y
, r
, g
, b
);
3226 * Write a span of identical 8-bit GRAYSCALE pixels to an XImage.
3228 static void put_mono_row_GRAYSCALE8_ximage( PUT_MONO_ROW_ARGS
)
3230 const GLubyte
*color
= (const GLubyte
*) value
;
3232 const GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3233 GLubyte
*ptr
= (GLubyte
*) PIXEL_ADDR1(xrb
, x
, y
);
3236 if (!mask
|| mask
[i
]) {
3245 * Write a span of identical PF_DITHER_5R6G5B pixels to an XImage.
3247 static void put_mono_row_DITHER_5R6G5B_ximage( PUT_MONO_ROW_ARGS
)
3249 const GLubyte
*color
= (const GLubyte
*) value
;
3251 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3252 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
3253 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3257 if (!mask
|| mask
[i
]) {
3258 PACK_TRUEDITHER(ptr
[i
], x
+i
, y
, r
, g
, b
);
3265 /**********************************************************************/
3266 /*** Write MONO COLOR PIXELS functions ***/
3267 /**********************************************************************/
3269 #define PUT_MONO_VALUES_ARGS \
3270 struct gl_context *ctx, struct gl_renderbuffer *rb, \
3271 GLuint n, const GLint x[], const GLint y[], \
3272 const void *value, const GLubyte mask[]
3277 * Write an array of identical pixels to a pixmap.
3279 static void put_mono_values_pixmap( PUT_MONO_VALUES_ARGS
)
3281 const GLubyte
*color
= (const GLubyte
*) value
;
3282 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3284 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3285 XMesaDrawable buffer
= xrb
->drawable
;
3286 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3288 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3289 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3290 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
3293 XMesaDrawPoint( dpy
, buffer
, gc
,
3294 (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3301 put_mono_values_ci_pixmap( PUT_MONO_VALUES_ARGS
)
3303 const GLuint colorIndex
= *((GLuint
*) value
);
3304 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3306 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3307 XMesaDrawable buffer
= xrb
->drawable
;
3308 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3310 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
3313 XMesaDrawPoint( dpy
, buffer
, gc
,
3314 (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3321 * Write an array of PF_TRUEDITHER pixels to a pixmap.
3323 static void put_mono_values_TRUEDITHER_pixmap( PUT_MONO_VALUES_ARGS
)
3325 const GLubyte
*color
= (const GLubyte
*) value
;
3326 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3328 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3329 XMesaDrawable buffer
= xrb
->drawable
;
3330 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3332 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3336 PACK_TRUEDITHER(p
, x
[i
], y
[i
], r
, g
, b
);
3337 XMesaSetForeground( dpy
, gc
, p
);
3338 XMesaDrawPoint( dpy
, buffer
, gc
,
3339 (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3346 * Write an array of PF_DITHER pixels to a pixmap.
3348 static void put_mono_values_DITHER_pixmap( PUT_MONO_VALUES_ARGS
)
3350 const GLubyte
*color
= (const GLubyte
*) value
;
3351 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3353 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3354 XMesaDrawable buffer
= xrb
->drawable
;
3355 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3357 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3361 XMesaSetForeground( dpy
, gc
, DITHER( x
[i
], y
[i
], r
, g
, b
) );
3362 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3369 * Write an array of PF_1BIT pixels to a pixmap.
3371 static void put_mono_values_1BIT_pixmap( PUT_MONO_VALUES_ARGS
)
3373 const GLubyte
*color
= (const GLubyte
*) value
;
3374 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3376 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3377 XMesaDrawable buffer
= xrb
->drawable
;
3378 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3380 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3384 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
) );
3385 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3392 * Write an array of identical pixels to an XImage.
3394 static void put_mono_values_ximage( PUT_MONO_VALUES_ARGS
)
3396 const GLubyte
*color
= (const GLubyte
*) value
;
3397 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3399 XMesaImage
*img
= xrb
->ximage
;
3401 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3402 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3405 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), pixel
);
3412 put_mono_values_ci_ximage( PUT_MONO_VALUES_ARGS
)
3414 const GLuint colorIndex
= *((GLuint
*) value
);
3416 XMesaImage
*img
= xrb
->ximage
;
3420 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), colorIndex
);
3427 * Write an array of identical TRUEDITHER pixels to an XImage.
3429 static void put_mono_values_TRUEDITHER_ximage( PUT_MONO_VALUES_ARGS
)
3431 const GLubyte
*color
= (const GLubyte
*) value
;
3432 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3434 XMesaImage
*img
= xrb
->ximage
;
3436 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3440 PACK_TRUEDITHER(p
, x
[i
], YFLIP(xrb
, y
[i
]), r
, g
, b
);
3441 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), p
);
3449 * Write an array of identical 8A8B8G8R pixels to an XImage
3451 static void put_mono_values_8A8B8G8R_ximage( PUT_MONO_VALUES_ARGS
)
3453 const GLubyte
*color
= (const GLubyte
*) value
;
3455 const GLuint p
= PACK_8A8B8G8R(color
[RCOMP
], color
[GCOMP
],
3456 color
[BCOMP
], color
[ACOMP
]);
3460 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
3467 * Write an array of identical 8A8R8G8B pixels to an XImage
3469 static void put_mono_values_8A8R8G8B_ximage( PUT_MONO_VALUES_ARGS
)
3471 const GLubyte
*color
= (const GLubyte
*) value
;
3473 const GLuint p
= PACK_8A8R8G8B(color
[RCOMP
], color
[GCOMP
],
3474 color
[BCOMP
], color
[ACOMP
]);
3478 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
3485 * Write an array of identical 8R8G8B pixels to an XImage.
3487 static void put_mono_values_8R8G8B_ximage( PUT_MONO_VALUES_ARGS
)
3489 const GLubyte
*color
= (const GLubyte
*) value
;
3492 const GLuint p
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3495 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
3503 * Write an array of identical 8R8G8B pixels to an XImage.
3505 static void put_mono_values_8R8G8B24_ximage( PUT_MONO_VALUES_ARGS
)
3507 const GLubyte
*color
= (const GLubyte
*) value
;
3509 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3513 bgr_t
*ptr
= PIXEL_ADDR3(xrb
, x
[i
], y
[i
] );
3523 * Write an array of identical PF_DITHER pixels to an XImage.
3525 static void put_mono_values_DITHER_ximage( PUT_MONO_VALUES_ARGS
)
3527 const GLubyte
*color
= (const GLubyte
*) value
;
3529 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3530 XMesaImage
*img
= xrb
->ximage
;
3535 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), DITHER( x
[i
], y
[i
], r
, g
, b
) );
3542 * Write an array of identical 8-bit PF_DITHER pixels to an XImage.
3544 static void put_mono_values_DITHER8_ximage( PUT_MONO_VALUES_ARGS
)
3546 const GLubyte
*color
= (const GLubyte
*) value
;
3548 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3553 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3554 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], r
, g
, b
);
3561 * Write an array of identical 8-bit PF_LOOKUP pixels to an XImage.
3563 static void put_mono_values_LOOKUP8_ximage( PUT_MONO_VALUES_ARGS
)
3565 const GLubyte
*color
= (const GLubyte
*) value
;
3570 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3573 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3582 * Write an array of identical PF_1BIT pixels to an XImage.
3584 static void put_mono_values_1BIT_ximage( PUT_MONO_VALUES_ARGS
)
3586 const GLubyte
*color
= (const GLubyte
*) value
;
3587 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3589 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3590 XMesaImage
*img
= xrb
->ximage
;
3595 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
3596 DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
));
3603 * Write an array of identical PF_HPCR pixels to an XImage.
3605 static void put_mono_values_HPCR_ximage( PUT_MONO_VALUES_ARGS
)
3607 const GLubyte
*color
= (const GLubyte
*) value
;
3609 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3610 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3614 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3615 *ptr
= DITHER_HPCR( x
[i
], y
[i
], r
, g
, b
);
3622 * Write an array of identical 8-bit PF_GRAYSCALE pixels to an XImage.
3624 static void put_mono_values_GRAYSCALE8_ximage( PUT_MONO_VALUES_ARGS
)
3626 const GLubyte
*color
= (const GLubyte
*) value
;
3629 register GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3632 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3640 * Write an array of identical PF_DITHER_5R6G5B pixels to an XImage.
3642 static void put_mono_values_DITHER_5R6G5B_ximage( PUT_MONO_VALUES_ARGS
)
3644 const GLubyte
*color
= (const GLubyte
*) value
;
3646 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3647 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3651 GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
[i
], y
[i
] );
3652 PACK_TRUEDITHER(*ptr
, x
[i
], y
[i
], r
, g
, b
);
3659 /**********************************************************************/
3660 /*** Write INDEX SPAN functions ***/
3661 /**********************************************************************/
3664 * Write a span of CI pixels to a Pixmap.
3666 static void put_row_ci_pixmap( PUT_ROW_ARGS
)
3668 const GLuint
*index
= (GLuint
*) values
;
3669 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3671 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3672 XMesaDrawable buffer
= xrb
->drawable
;
3673 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3677 for (i
=0;i
<n
;i
++,x
++) {
3679 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3680 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3685 for (i
=0;i
<n
;i
++,x
++) {
3686 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3687 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3694 * Write a span of CI pixels to an XImage.
3696 static void put_row_ci_ximage( PUT_ROW_ARGS
)
3698 const GLuint
*index
= (const GLuint
*) values
;
3700 XMesaImage
*img
= xrb
->ximage
;
3704 for (i
=0;i
<n
;i
++,x
++) {
3706 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3711 for (i
=0;i
<n
;i
++,x
++) {
3712 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3718 /**********************************************************************/
3719 /*** Write INDEX PIXELS functions ***/
3720 /**********************************************************************/
3723 * Write an array of CI pixels to a Pixmap.
3725 static void put_values_ci_pixmap( PUT_VALUES_ARGS
)
3727 const GLuint
*index
= (const GLuint
*) values
;
3728 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3730 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3731 XMesaDrawable buffer
= xrb
->drawable
;
3732 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3736 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3737 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3744 * Write an array of CI pixels to an XImage.
3746 static void put_values_ci_ximage( PUT_VALUES_ARGS
)
3748 const GLuint
*index
= (const GLuint
*) values
;
3750 XMesaImage
*img
= xrb
->ximage
;
3754 XMesaPutPixel(img
, x
[i
], YFLIP(xrb
, y
[i
]), (unsigned long) index
[i
]);
3762 /**********************************************************************/
3763 /***** Pixel reading *****/
3764 /**********************************************************************/
3766 #ifndef XFree86Server
3768 * Do clip testing prior to calling XGetImage. If any of the region lies
3769 * outside the screen's bounds, XGetImage will return NULL.
3770 * We use XTranslateCoordinates() to check if that's the case and
3771 * adjust the x, y and length parameters accordingly.
3772 * \return -1 if span is totally clipped away,
3773 * else return number of pixels to skip in the destination array.
3776 clip_for_xgetimage(struct gl_context
*ctx
, XMesaPixmap pixmap
, GLuint
*n
, GLint
*x
, GLint
*y
)
3778 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3779 XMesaBuffer source
= XMESA_BUFFER(ctx
->DrawBuffer
);
3780 Window rootWin
= RootWindow(xmesa
->display
, 0);
3782 GLint screenWidth
= WidthOfScreen(DefaultScreenOfDisplay(xmesa
->display
));
3784 if (source
->type
== PBUFFER
|| source
->type
== PIXMAP
)
3786 XTranslateCoordinates(xmesa
->display
, pixmap
, rootWin
,
3787 *x
, *y
, &dx
, &dy
, &child
);
3788 if (dx
>= screenWidth
) {
3789 /* totally clipped on right */
3793 /* clipped on left */
3795 if (clip
>= (GLint
) *n
)
3796 return -1; /* totally clipped on left */
3802 if ((GLint
) (dx
+ *n
) > screenWidth
) {
3803 /* clipped on right */
3804 GLint clip
= dx
+ *n
- screenWidth
;
3813 * Read a horizontal span of color-index pixels.
3816 get_row_ci(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
3817 GLuint n
, GLint x
, GLint y
, void *values
)
3819 GLuint
*index
= (GLuint
*) values
;
3820 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3827 #ifndef XFree86Server
3828 XMesaImage
*span
= NULL
;
3830 int k
= clip_for_xgetimage(ctx
, xrb
->pixmap
, &n
, &x
, &y
);
3835 catch_xgetimage_errors( xmesa
->display
);
3836 span
= XGetImage( xmesa
->display
, xrb
->pixmap
,
3837 x
, y
, n
, 1, AllPlanes
, ZPixmap
);
3838 error
= check_xgetimage_errors();
3839 if (span
&& !error
) {
3841 index
[i
] = (GLuint
) XMesaGetPixel( span
, i
, 0 );
3845 /* return 0 pixels */
3851 XMesaDestroyImage( span
);
3854 (*xmesa
->display
->GetImage
)(xrb
->drawable
,
3855 x
, y
, n
, 1, ZPixmap
,
3856 ~0L, (pointer
)index
);
3859 else if (xrb
->ximage
) {
3860 XMesaImage
*img
= xrb
->ximage
;
3861 for (i
=0;i
<n
;i
++,x
++) {
3862 index
[i
] = (GLuint
) XMesaGetPixel( img
, x
, y
);
3870 * Read a horizontal span of color pixels.
3873 get_row_rgba(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
3874 GLuint n
, GLint x
, GLint y
, void *values
)
3876 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
3877 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3879 XMesaBuffer source
= XMESA_BUFFER(ctx
->DrawBuffer
);
3882 /* Read from Pixmap or Window */
3883 XMesaImage
*span
= NULL
;
3885 #ifdef XFree86Server
3886 span
= XMesaCreateImage(xmesa
->xm_visual
->BitsPerPixel
, n
, 1, NULL
);
3887 span
->data
= (char *)MALLOC(span
->height
* span
->bytes_per_line
);
3888 error
= (!span
->data
);
3889 (*xmesa
->display
->GetImage
)(xrb
->drawable
,
3890 x
, YFLIP(xrb
, y
), n
, 1, ZPixmap
,
3891 ~0L, (pointer
)span
->data
);
3895 k
= clip_for_xgetimage(ctx
, xrb
->pixmap
, &n
, &x
, &y
);
3899 catch_xgetimage_errors( xmesa
->display
);
3900 span
= XGetImage( xmesa
->display
, xrb
->pixmap
,
3901 x
, y
, n
, 1, AllPlanes
, ZPixmap
);
3902 error
= check_xgetimage_errors();
3904 if (span
&& !error
) {
3905 switch (xmesa
->pixelformat
) {
3907 case PF_Dither_True
:
3909 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3910 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3911 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3912 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3913 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3914 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3915 GLint rShift
= xmesa
->xm_visual
->rshift
;
3916 GLint gShift
= xmesa
->xm_visual
->gshift
;
3917 GLint bShift
= xmesa
->xm_visual
->bshift
;
3921 p
= XMesaGetPixel( span
, i
, 0 );
3922 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3923 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3924 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3925 rgba
[i
][ACOMP
] = 255;
3930 case PF_Dither_5R6G5B
:
3932 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3933 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3934 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3937 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
3938 /* fast, but not quite accurate
3939 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3940 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3941 rgba[i][BCOMP] = ((p << 3) & 0xff);
3943 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
3944 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3945 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
3946 rgba
[i
][ACOMP
] = 255;
3952 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3955 GLuint p4
= *ptr4
++;
3956 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
3957 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3958 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3959 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
3965 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3968 GLuint p4
= *ptr4
++;
3969 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3970 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3971 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3972 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
3978 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3981 GLuint p4
= *ptr4
++;
3982 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3983 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3984 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3985 rgba
[i
][ACOMP
] = 255;
3991 const bgr_t
*ptr3
= (bgr_t
*) span
->data
;
3994 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
3995 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
3996 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
3997 rgba
[i
][ACOMP
] = 255;
4003 GLubyte
*ptr1
= (GLubyte
*) span
->data
;
4006 GLubyte p
= *ptr1
++;
4007 rgba
[i
][RCOMP
] = p
& 0xE0;
4008 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4009 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4010 rgba
[i
][ACOMP
] = 255;
4018 GLubyte
*rTable
= source
->pixel_to_r
;
4019 GLubyte
*gTable
= source
->pixel_to_g
;
4020 GLubyte
*bTable
= source
->pixel_to_b
;
4021 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
4022 const GLubyte
*ptr1
= (GLubyte
*) span
->data
;
4025 unsigned long p
= *ptr1
++;
4026 rgba
[i
][RCOMP
] = rTable
[p
];
4027 rgba
[i
][GCOMP
] = gTable
[p
];
4028 rgba
[i
][BCOMP
] = bTable
[p
];
4029 rgba
[i
][ACOMP
] = 255;
4035 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
4036 rgba
[i
][RCOMP
] = rTable
[p
];
4037 rgba
[i
][GCOMP
] = gTable
[p
];
4038 rgba
[i
][BCOMP
] = bTable
[p
];
4039 rgba
[i
][ACOMP
] = 255;
4046 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4050 p
= XMesaGetPixel( span
, i
, 0 ) ^ bitFlip
;
4051 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4052 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4053 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4054 rgba
[i
][ACOMP
] = 255;
4059 _mesa_problem(NULL
,"Problem in DD.read_color_span (1)");
4064 /* return black pixels */
4067 rgba
[i
][RCOMP
] = rgba
[i
][GCOMP
] = rgba
[i
][BCOMP
] = rgba
[i
][ACOMP
] = 0;
4071 XMesaDestroyImage( span
);
4074 else if (xrb
->ximage
) {
4075 /* Read from XImage back buffer */
4076 switch (xmesa
->pixelformat
) {
4078 case PF_Dither_True
:
4080 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4081 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4082 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4083 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4084 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4085 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4086 GLint rShift
= xmesa
->xm_visual
->rshift
;
4087 GLint gShift
= xmesa
->xm_visual
->gshift
;
4088 GLint bShift
= xmesa
->xm_visual
->bshift
;
4089 XMesaImage
*img
= xrb
->ximage
;
4094 p
= XMesaGetPixel( img
, x
+i
, y
);
4095 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4096 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4097 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4098 rgba
[i
][ACOMP
] = 255;
4103 case PF_Dither_5R6G5B
:
4105 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4106 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4107 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4108 const GLushort
*ptr2
= PIXEL_ADDR2(xrb
, x
, y
);
4110 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
4111 const GLuint
*ptr4
= (const GLuint
*) ptr2
;
4112 GLuint extraPixel
= (n
& 1);
4114 for (i
= 0; i
< n
; i
+= 2) {
4115 const GLuint p
= *ptr4
++;
4116 const GLuint p0
= p
& 0xffff;
4117 const GLuint p1
= p
>> 16;
4118 /* fast, but not quite accurate
4119 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
4120 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
4121 rgba[i][BCOMP] = ((p << 3) & 0xff);
4123 rgba
[i
][RCOMP
] = pixelToR
[p0
>> 11];
4124 rgba
[i
][GCOMP
] = pixelToG
[(p0
>> 5) & 0x3f];
4125 rgba
[i
][BCOMP
] = pixelToB
[p0
& 0x1f];
4126 rgba
[i
][ACOMP
] = 255;
4127 rgba
[i
+1][RCOMP
] = pixelToR
[p1
>> 11];
4128 rgba
[i
+1][GCOMP
] = pixelToG
[(p1
>> 5) & 0x3f];
4129 rgba
[i
+1][BCOMP
] = pixelToB
[p1
& 0x1f];
4130 rgba
[i
+1][ACOMP
] = 255;
4133 GLushort p
= ptr2
[n
];
4134 rgba
[n
][RCOMP
] = pixelToR
[p
>> 11];
4135 rgba
[n
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
4136 rgba
[n
][BCOMP
] = pixelToB
[p
& 0x1f];
4137 rgba
[n
][ACOMP
] = 255;
4140 for (i
= 0; i
< n
; i
++) {
4141 const GLushort p
= ptr2
[i
];
4142 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
4143 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
4144 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
4145 rgba
[i
][ACOMP
] = 255;
4152 const GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
, y
);
4155 GLuint p4
= *ptr4
++;
4156 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
4157 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4158 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4159 rgba
[i
][ACOMP
] = (GLint
) ((p4
>> 24) & 0xff);
4165 const GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
, y
);
4168 GLuint p4
= *ptr4
++;
4169 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4170 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4171 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4172 rgba
[i
][ACOMP
] = (GLint
) ((p4
>> 24) & 0xff);
4178 const GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
, y
);
4181 GLuint p4
= *ptr4
++;
4182 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4183 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4184 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4185 rgba
[i
][ACOMP
] = 255;
4191 const bgr_t
*ptr3
= PIXEL_ADDR3(xrb
, x
, y
);
4194 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
4195 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
4196 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
4197 rgba
[i
][ACOMP
] = 255;
4203 const GLubyte
*ptr1
= PIXEL_ADDR1(xrb
, x
, y
);
4206 GLubyte p
= *ptr1
++;
4207 rgba
[i
][RCOMP
] = p
& 0xE0;
4208 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4209 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4210 rgba
[i
][ACOMP
] = 255;
4218 const GLubyte
*rTable
= source
->pixel_to_r
;
4219 const GLubyte
*gTable
= source
->pixel_to_g
;
4220 const GLubyte
*bTable
= source
->pixel_to_b
;
4221 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
4222 GLubyte
*ptr1
= PIXEL_ADDR1(xrb
, x
, y
);
4225 unsigned long p
= *ptr1
++;
4226 rgba
[i
][RCOMP
] = rTable
[p
];
4227 rgba
[i
][GCOMP
] = gTable
[p
];
4228 rgba
[i
][BCOMP
] = bTable
[p
];
4229 rgba
[i
][ACOMP
] = 255;
4233 XMesaImage
*img
= xrb
->ximage
;
4236 for (i
=0;i
<n
;i
++,x
++) {
4237 unsigned long p
= XMesaGetPixel( img
, x
, y
);
4238 rgba
[i
][RCOMP
] = rTable
[p
];
4239 rgba
[i
][GCOMP
] = gTable
[p
];
4240 rgba
[i
][BCOMP
] = bTable
[p
];
4241 rgba
[i
][ACOMP
] = 255;
4248 XMesaImage
*img
= xrb
->ximage
;
4249 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4252 for (i
=0;i
<n
;i
++,x
++) {
4254 p
= XMesaGetPixel( img
, x
, y
) ^ bitFlip
;
4255 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4256 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4257 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4258 rgba
[i
][ACOMP
] = 255;
4263 _mesa_problem(NULL
,"Problem in DD.read_color_span (2)");
4272 * Read an array of color index pixels.
4275 get_values_ci(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
4276 GLuint n
, const GLint x
[], const GLint y
[], void *values
)
4278 GLuint
*indx
= (GLuint
*) values
;
4279 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
4284 indx
[i
] = (GLuint
) read_pixel( xmesa
->display
, xrb
->drawable
,
4285 x
[i
], YFLIP(xrb
, y
[i
]) );
4288 else if (xrb
->ximage
) {
4289 XMesaImage
*img
= xrb
->ximage
;
4291 indx
[i
] = (GLuint
) XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) );
4299 get_values_rgba(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
4300 GLuint n
, const GLint x
[], const GLint y
[], void *values
)
4302 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
4304 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
4305 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
4306 XMesaBuffer source
= XMESA_BUFFER(ctx
->DrawBuffer
);
4310 XMesaDrawable buffer
= xrb
->drawable
;
4311 switch (xmesa
->pixelformat
) {
4313 case PF_Dither_True
:
4315 case PF_Dither_5R6G5B
:
4317 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4318 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4319 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4320 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4321 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4322 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4323 GLint rShift
= xmesa
->xm_visual
->rshift
;
4324 GLint gShift
= xmesa
->xm_visual
->gshift
;
4325 GLint bShift
= xmesa
->xm_visual
->bshift
;
4327 unsigned long p
= read_pixel( dpy
, buffer
,
4328 x
[i
], YFLIP(xrb
, y
[i
]) );
4329 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4330 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4331 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4332 rgba
[i
][ACOMP
] = 255;
4338 unsigned long p
= read_pixel( dpy
, buffer
,
4339 x
[i
], YFLIP(xrb
, y
[i
]) );
4340 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xff);
4341 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4342 rgba
[i
][BCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4343 rgba
[i
][ACOMP
] = (GLubyte
) ((p
>> 24) & 0xff);
4348 unsigned long p
= read_pixel( dpy
, buffer
,
4349 x
[i
], YFLIP(xrb
, y
[i
]) );
4350 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4351 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4352 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4353 rgba
[i
][ACOMP
] = (GLubyte
) ((p
>> 24) & 0xff);
4358 unsigned long p
= read_pixel( dpy
, buffer
,
4359 x
[i
], YFLIP(xrb
, y
[i
]) );
4360 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4361 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4362 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4363 rgba
[i
][ACOMP
] = 255;
4368 unsigned long p
= read_pixel( dpy
, buffer
,
4369 x
[i
], YFLIP(xrb
, y
[i
]) );
4370 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4371 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4372 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4373 rgba
[i
][ACOMP
] = 255;
4378 unsigned long p
= read_pixel( dpy
, buffer
,
4379 x
[i
], YFLIP(xrb
, y
[i
]) );
4380 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xE0 );
4381 rgba
[i
][GCOMP
] = (GLubyte
) ((p
& 0x1C) << 3);
4382 rgba
[i
][BCOMP
] = (GLubyte
) ((p
& 0x03) << 6);
4383 rgba
[i
][ACOMP
] = (GLubyte
) 255;
4390 GLubyte
*rTable
= source
->pixel_to_r
;
4391 GLubyte
*gTable
= source
->pixel_to_g
;
4392 GLubyte
*bTable
= source
->pixel_to_b
;
4394 unsigned long p
= read_pixel( dpy
, buffer
,
4395 x
[i
], YFLIP(xrb
, y
[i
]) );
4396 rgba
[i
][RCOMP
] = rTable
[p
];
4397 rgba
[i
][GCOMP
] = gTable
[p
];
4398 rgba
[i
][BCOMP
] = bTable
[p
];
4399 rgba
[i
][ACOMP
] = 255;
4405 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4407 unsigned long p
= read_pixel( dpy
, buffer
,
4408 x
[i
], YFLIP(xrb
, y
[i
])) ^ bitFlip
;
4409 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4410 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4411 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4412 rgba
[i
][ACOMP
] = 255;
4417 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4421 else if (xrb
->ximage
) {
4422 /* Read from XImage back buffer */
4423 switch (xmesa
->pixelformat
) {
4425 case PF_Dither_True
:
4427 case PF_Dither_5R6G5B
:
4429 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4430 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4431 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4432 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4433 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4434 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4435 GLint rShift
= xmesa
->xm_visual
->rshift
;
4436 GLint gShift
= xmesa
->xm_visual
->gshift
;
4437 GLint bShift
= xmesa
->xm_visual
->bshift
;
4438 XMesaImage
*img
= xrb
->ximage
;
4441 p
= XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) );
4442 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4443 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4444 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4445 rgba
[i
][ACOMP
] = 255;
4451 GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
4453 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
4454 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4455 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4456 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
4461 GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
4463 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4464 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4465 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4466 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
4471 GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
4473 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4474 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4475 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4476 rgba
[i
][ACOMP
] = 255;
4481 bgr_t
*ptr3
= PIXEL_ADDR3(xrb
, x
[i
], y
[i
]);
4482 rgba
[i
][RCOMP
] = ptr3
->r
;
4483 rgba
[i
][GCOMP
] = ptr3
->g
;
4484 rgba
[i
][BCOMP
] = ptr3
->b
;
4485 rgba
[i
][ACOMP
] = 255;
4490 GLubyte
*ptr1
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
4492 rgba
[i
][RCOMP
] = p
& 0xE0;
4493 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4494 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4495 rgba
[i
][ACOMP
] = 255;
4502 GLubyte
*rTable
= source
->pixel_to_r
;
4503 GLubyte
*gTable
= source
->pixel_to_g
;
4504 GLubyte
*bTable
= source
->pixel_to_b
;
4505 XMesaImage
*img
= xrb
->ximage
;
4508 p
= XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) );
4509 rgba
[i
][RCOMP
] = rTable
[p
];
4510 rgba
[i
][GCOMP
] = gTable
[p
];
4511 rgba
[i
][BCOMP
] = bTable
[p
];
4512 rgba
[i
][ACOMP
] = 255;
4518 XMesaImage
*img
= xrb
->ximage
;
4519 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4522 p
= XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) ) ^ bitFlip
;
4523 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4524 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4525 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4526 rgba
[i
][ACOMP
] = 255;
4531 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4539 * Initialize the renderbuffer's PutRow, GetRow, etc. functions.
4540 * This would generally only need to be called once when the renderbuffer
4541 * is created. However, we can change pixel formats on the fly if dithering
4542 * is enabled/disabled. Therefore, we may call this more often than that.
4545 xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer
*xrb
,
4546 enum pixel_format pixelformat
, GLint depth
)
4548 const GLboolean pixmap
= xrb
->pixmap
? GL_TRUE
: GL_FALSE
;
4550 switch (pixelformat
) {
4552 ASSERT(xrb
->Base
.DataType
== GL_UNSIGNED_INT
);
4554 xrb
->Base
.PutRow
= put_row_ci_pixmap
;
4555 xrb
->Base
.PutRowRGB
= NULL
;
4556 xrb
->Base
.PutMonoRow
= put_mono_row_ci_pixmap
;
4557 xrb
->Base
.PutValues
= put_values_ci_pixmap
;
4558 xrb
->Base
.PutMonoValues
= put_mono_values_ci_pixmap
;
4561 xrb
->Base
.PutRow
= put_row_ci_ximage
;
4562 xrb
->Base
.PutRowRGB
= NULL
;
4563 xrb
->Base
.PutMonoRow
= put_mono_row_ci_ximage
;
4564 xrb
->Base
.PutValues
= put_values_ci_ximage
;
4565 xrb
->Base
.PutMonoValues
= put_mono_values_ci_ximage
;
4570 xrb
->Base
.PutRow
= put_row_TRUECOLOR_pixmap
;
4571 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUECOLOR_pixmap
;
4572 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4573 xrb
->Base
.PutValues
= put_values_TRUECOLOR_pixmap
;
4574 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4577 xrb
->Base
.PutRow
= put_row_TRUECOLOR_ximage
;
4578 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUECOLOR_ximage
;
4579 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4580 xrb
->Base
.PutValues
= put_values_TRUECOLOR_ximage
;
4581 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4584 case PF_Dither_True
:
4586 xrb
->Base
.PutRow
= put_row_TRUEDITHER_pixmap
;
4587 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUEDITHER_pixmap
;
4588 xrb
->Base
.PutMonoRow
= put_mono_row_TRUEDITHER_pixmap
;
4589 xrb
->Base
.PutValues
= put_values_TRUEDITHER_pixmap
;
4590 xrb
->Base
.PutMonoValues
= put_mono_values_TRUEDITHER_pixmap
;
4593 xrb
->Base
.PutRow
= put_row_TRUEDITHER_ximage
;
4594 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUEDITHER_ximage
;
4595 xrb
->Base
.PutMonoRow
= put_mono_row_TRUEDITHER_ximage
;
4596 xrb
->Base
.PutValues
= put_values_TRUEDITHER_ximage
;
4597 xrb
->Base
.PutMonoValues
= put_mono_values_TRUEDITHER_ximage
;
4602 xrb
->Base
.PutRow
= put_row_8A8B8G8R_pixmap
;
4603 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8B8G8R_pixmap
;
4604 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4605 xrb
->Base
.PutValues
= put_values_8A8B8G8R_pixmap
;
4606 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4609 xrb
->Base
.PutRow
= put_row_8A8B8G8R_ximage
;
4610 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8B8G8R_ximage
;
4611 xrb
->Base
.PutMonoRow
= put_mono_row_8A8B8G8R_ximage
;
4612 xrb
->Base
.PutValues
= put_values_8A8B8G8R_ximage
;
4613 xrb
->Base
.PutMonoValues
= put_mono_values_8A8B8G8R_ximage
;
4618 xrb
->Base
.PutRow
= put_row_8A8R8G8B_pixmap
;
4619 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8R8G8B_pixmap
;
4620 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4621 xrb
->Base
.PutValues
= put_values_8A8R8G8B_pixmap
;
4622 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4625 xrb
->Base
.PutRow
= put_row_8A8R8G8B_ximage
;
4626 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8R8G8B_ximage
;
4627 xrb
->Base
.PutMonoRow
= put_mono_row_8A8R8G8B_ximage
;
4628 xrb
->Base
.PutValues
= put_values_8A8R8G8B_ximage
;
4629 xrb
->Base
.PutMonoValues
= put_mono_values_8A8R8G8B_ximage
;
4634 xrb
->Base
.PutRow
= put_row_8R8G8B_pixmap
;
4635 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B_pixmap
;
4636 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4637 xrb
->Base
.PutValues
= put_values_8R8G8B_pixmap
;
4638 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4641 xrb
->Base
.PutRow
= put_row_8R8G8B_ximage
;
4642 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B_ximage
;
4643 xrb
->Base
.PutMonoRow
= put_mono_row_8R8G8B_ximage
;
4644 xrb
->Base
.PutValues
= put_values_8R8G8B_ximage
;
4645 xrb
->Base
.PutMonoValues
= put_mono_values_8R8G8B_ximage
;
4650 xrb
->Base
.PutRow
= put_row_8R8G8B24_pixmap
;
4651 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B24_pixmap
;
4652 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4653 xrb
->Base
.PutValues
= put_values_8R8G8B24_pixmap
;
4654 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4657 xrb
->Base
.PutRow
= put_row_8R8G8B24_ximage
;
4658 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B24_ximage
;
4659 xrb
->Base
.PutMonoRow
= put_mono_row_8R8G8B24_ximage
;
4660 xrb
->Base
.PutValues
= put_values_8R8G8B24_ximage
;
4661 xrb
->Base
.PutMonoValues
= put_mono_values_8R8G8B24_ximage
;
4666 xrb
->Base
.PutRow
= put_row_5R6G5B_pixmap
;
4667 xrb
->Base
.PutRowRGB
= put_row_rgb_5R6G5B_pixmap
;
4668 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4669 xrb
->Base
.PutValues
= put_values_5R6G5B_pixmap
;
4670 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4673 xrb
->Base
.PutRow
= put_row_5R6G5B_ximage
;
4674 xrb
->Base
.PutRowRGB
= put_row_rgb_5R6G5B_ximage
;
4675 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4676 xrb
->Base
.PutValues
= put_values_5R6G5B_ximage
;
4677 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4680 case PF_Dither_5R6G5B
:
4682 xrb
->Base
.PutRow
= put_row_DITHER_5R6G5B_pixmap
;
4683 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_5R6G5B_pixmap
;
4684 xrb
->Base
.PutMonoRow
= put_mono_row_TRUEDITHER_pixmap
;
4685 xrb
->Base
.PutValues
= put_values_DITHER_5R6G5B_pixmap
;
4686 xrb
->Base
.PutMonoValues
= put_mono_values_TRUEDITHER_pixmap
;
4689 xrb
->Base
.PutRow
= put_row_DITHER_5R6G5B_ximage
;
4690 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_5R6G5B_ximage
;
4691 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER_5R6G5B_ximage
;
4692 xrb
->Base
.PutValues
= put_values_DITHER_5R6G5B_ximage
;
4693 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER_5R6G5B_ximage
;
4698 xrb
->Base
.PutRow
= put_row_DITHER_pixmap
;
4699 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_pixmap
;
4700 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER_pixmap
;
4701 xrb
->Base
.PutValues
= put_values_DITHER_pixmap
;
4702 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER_pixmap
;
4706 xrb
->Base
.PutRow
= put_row_DITHER8_ximage
;
4707 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER8_ximage
;
4708 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER8_ximage
;
4709 xrb
->Base
.PutValues
= put_values_DITHER8_ximage
;
4710 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER8_ximage
;
4713 xrb
->Base
.PutRow
= put_row_DITHER_ximage
;
4714 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_ximage
;
4715 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER_ximage
;
4716 xrb
->Base
.PutValues
= put_values_DITHER_ximage
;
4717 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER_ximage
;
4723 xrb
->Base
.PutRow
= put_row_1BIT_pixmap
;
4724 xrb
->Base
.PutRowRGB
= put_row_rgb_1BIT_pixmap
;
4725 xrb
->Base
.PutMonoRow
= put_mono_row_1BIT_pixmap
;
4726 xrb
->Base
.PutValues
= put_values_1BIT_pixmap
;
4727 xrb
->Base
.PutMonoValues
= put_mono_values_1BIT_pixmap
;
4730 xrb
->Base
.PutRow
= put_row_1BIT_ximage
;
4731 xrb
->Base
.PutRowRGB
= put_row_rgb_1BIT_ximage
;
4732 xrb
->Base
.PutMonoRow
= put_mono_row_1BIT_ximage
;
4733 xrb
->Base
.PutValues
= put_values_1BIT_ximage
;
4734 xrb
->Base
.PutMonoValues
= put_mono_values_1BIT_ximage
;
4739 xrb
->Base
.PutRow
= put_row_HPCR_pixmap
;
4740 xrb
->Base
.PutRowRGB
= put_row_rgb_HPCR_pixmap
;
4741 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4742 xrb
->Base
.PutValues
= put_values_HPCR_pixmap
;
4743 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4746 xrb
->Base
.PutRow
= put_row_HPCR_ximage
;
4747 xrb
->Base
.PutRowRGB
= put_row_rgb_HPCR_ximage
;
4748 xrb
->Base
.PutMonoRow
= put_mono_row_HPCR_ximage
;
4749 xrb
->Base
.PutValues
= put_values_HPCR_ximage
;
4750 xrb
->Base
.PutMonoValues
= put_mono_values_HPCR_ximage
;
4755 xrb
->Base
.PutRow
= put_row_LOOKUP_pixmap
;
4756 xrb
->Base
.PutRowRGB
= put_row_rgb_LOOKUP_pixmap
;
4757 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4758 xrb
->Base
.PutValues
= put_values_LOOKUP_pixmap
;
4759 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4763 xrb
->Base
.PutRow
= put_row_LOOKUP8_ximage
;
4764 xrb
->Base
.PutRowRGB
= put_row_rgb_LOOKUP8_ximage
;
4765 xrb
->Base
.PutMonoRow
= put_mono_row_LOOKUP8_ximage
;
4766 xrb
->Base
.PutValues
= put_values_LOOKUP8_ximage
;
4767 xrb
->Base
.PutMonoValues
= put_mono_values_LOOKUP8_ximage
;
4770 xrb
->Base
.PutRow
= put_row_LOOKUP_ximage
;
4771 xrb
->Base
.PutRowRGB
= put_row_rgb_LOOKUP_ximage
;
4772 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4773 xrb
->Base
.PutValues
= put_values_LOOKUP_ximage
;
4774 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4780 xrb
->Base
.PutRow
= put_row_GRAYSCALE_pixmap
;
4781 xrb
->Base
.PutRowRGB
= put_row_rgb_GRAYSCALE_pixmap
;
4782 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4783 xrb
->Base
.PutValues
= put_values_GRAYSCALE_pixmap
;
4784 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4788 xrb
->Base
.PutRow
= put_row_GRAYSCALE8_ximage
;
4789 xrb
->Base
.PutRowRGB
= put_row_rgb_GRAYSCALE8_ximage
;
4790 xrb
->Base
.PutMonoRow
= put_mono_row_GRAYSCALE8_ximage
;
4791 xrb
->Base
.PutValues
= put_values_GRAYSCALE8_ximage
;
4792 xrb
->Base
.PutMonoValues
= put_mono_values_GRAYSCALE8_ximage
;
4795 xrb
->Base
.PutRow
= put_row_GRAYSCALE_ximage
;
4796 xrb
->Base
.PutRowRGB
= put_row_rgb_GRAYSCALE_ximage
;
4797 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4798 xrb
->Base
.PutValues
= put_values_GRAYSCALE_ximage
;
4799 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4804 _mesa_problem(NULL
, "Bad pixel format in xmesa_update_state (1)");
4810 if (pixelformat
== PF_Index
) {
4811 xrb
->Base
.GetRow
= get_row_ci
;
4812 xrb
->Base
.GetValues
= get_values_ci
;
4815 xrb
->Base
.GetRow
= get_row_rgba
;
4816 xrb
->Base
.GetValues
= get_values_rgba
;