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"
30 #include "extensions.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 \
167 struct gl_renderbuffer *rb, \
168 GLuint n, GLint x, GLint y, \
169 const void *values, const GLubyte mask[]
171 #define RGB_SPAN_ARGS \
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
++) {
474 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
475 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
480 /* draw all pixels */
481 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
482 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
484 *ptr4
++ = PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
486 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
492 * Write a span of PF_8R8G8B24 pixels to a pixmap.
494 static void put_row_8R8G8B24_pixmap( PUT_ROW_ARGS
)
496 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
497 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
499 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
500 XMesaDrawable buffer
= xrb
->drawable
;
501 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
505 for (i
=0;i
<n
;i
++,x
++) {
507 XMesaSetForeground( dpy
, gc
,
508 PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
509 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
514 /* draw all pixels */
515 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
516 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
517 register GLuint pixel
;
518 static const GLuint shift
[4] = {0, 8, 16, 24};
519 register GLuint i
= 0;
522 pixel
= rgba
[i
][BCOMP
] /* << shift[0]*/;
523 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
524 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
525 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
528 pixel
= rgba
[i
][GCOMP
] /* << shift[0]*/;
529 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
530 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
531 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
534 pixel
= rgba
[i
++][RCOMP
]/* << shift[0]*/;
535 pixel
|= rgba
[i
][BCOMP
] << shift
[1];
536 pixel
|= rgba
[i
][GCOMP
] << shift
[2];
537 pixel
|= rgba
[i
++][RCOMP
] << shift
[3];
545 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
546 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
547 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
548 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
551 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
552 pixel
|= rgba
[i
++][RCOMP
] << shift
[1];
553 pixel
|= rgba
[i
][BCOMP
] << shift
[2];
554 pixel
|= rgba
[i
][GCOMP
] << shift
[3];
556 pixel
= 0xffffff00 & *ptr4
;
557 pixel
|= rgba
[i
][RCOMP
] /*<< shift[0]*/;
562 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
563 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
564 pixel
|= rgba
[i
++][RCOMP
] << shift
[2];
565 pixel
|= rgba
[i
][BCOMP
] << shift
[3];
567 pixel
= 0xffff0000 & *ptr4
;
568 pixel
|= rgba
[i
][GCOMP
] /*<< shift[0]*/;
569 pixel
|= rgba
[i
][RCOMP
] << shift
[1];
573 pixel
= 0xff000000 & *ptr4
;
574 pixel
|= rgba
[i
][BCOMP
] /*<< shift[0]*/;
575 pixel
|= rgba
[i
][GCOMP
] << shift
[1];
576 pixel
|= rgba
[i
][RCOMP
] << shift
[2];
582 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
588 * Write a span of PF_8R8G8B pixels to a pixmap (no alpha).
590 static void put_row_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS
)
592 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
593 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
595 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
596 XMesaDrawable buffer
= xrb
->drawable
;
597 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
601 for (i
=0;i
<n
;i
++,x
++) {
603 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
604 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
609 /* draw all pixels */
610 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
611 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
613 *ptr4
++ = PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
615 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
620 * Write a span of PF_8R8G8B24 pixels to a pixmap (no alpha).
622 static void put_row_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS
)
624 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
625 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
627 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
628 XMesaDrawable buffer
= xrb
->drawable
;
629 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
633 for (i
=0;i
<n
;i
++,x
++) {
635 XMesaSetForeground( dpy
, gc
,
636 PACK_8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
637 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
642 /* draw all pixels */
643 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
644 register GLuint
*ptr4
= (GLuint
*) rowimg
->data
;
645 register GLuint pixel
;
646 static const GLuint shift
[4] = {0, 8, 16, 24};
648 register GLuint i
= 0;
651 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
652 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
653 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
654 pixel
|= rgb
[i
][BCOMP
] <<shift
[3];
658 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
659 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
660 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
661 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
665 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
666 pixel
|= rgb
[i
][BCOMP
] << shift
[1];
667 pixel
|= rgb
[i
][GCOMP
] << shift
[2];
668 pixel
|= rgb
[i
++][RCOMP
] << shift
[3];
675 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
676 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
677 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
678 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
681 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
682 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
683 pixel
|= rgb
[i
][BCOMP
] << shift
[2];
684 pixel
|= rgb
[i
][GCOMP
] << shift
[3];
688 pixel
|= rgb
[i
++][RCOMP
]/* << shift[0]*/;
693 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
694 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
695 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
696 pixel
|= rgb
[i
][BCOMP
] << shift
[3];
700 pixel
|= rgb
[i
][GCOMP
]/* << shift[0]*/;
701 pixel
|= rgb
[i
++][RCOMP
] << shift
[1];
707 pixel
|= rgb
[i
][BCOMP
]/* << shift[0]*/;
708 pixel
|= rgb
[i
][GCOMP
] << shift
[1];
709 pixel
|= rgb
[i
++][RCOMP
] << shift
[2];
715 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
721 * Write a span of PF_5R6G5B pixels to a pixmap.
723 static void put_row_5R6G5B_pixmap( PUT_ROW_ARGS
)
725 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
726 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
728 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
729 XMesaDrawable buffer
= xrb
->drawable
;
730 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
734 for (i
=0;i
<n
;i
++,x
++) {
736 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
737 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
742 /* draw all pixels */
743 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
744 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
746 ptr2
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
748 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
754 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap.
756 static void put_row_DITHER_5R6G5B_pixmap( PUT_ROW_ARGS
)
758 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
759 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
761 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
762 XMesaDrawable buffer
= xrb
->drawable
;
763 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
767 for (i
=0;i
<n
;i
++,x
++) {
770 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
771 XMesaSetForeground( dpy
, gc
, p
);
772 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
777 /* draw all pixels */
778 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
779 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
781 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
783 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
789 * Write a span of PF_5R6G5B pixels to a pixmap (no alpha).
791 static void put_row_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS
)
793 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
794 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
796 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
797 XMesaDrawable buffer
= xrb
->drawable
;
798 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
802 for (i
=0;i
<n
;i
++,x
++) {
804 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ));
805 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
810 /* draw all pixels */
811 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
812 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
814 ptr2
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
816 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
822 * Write a span of PF_DITHER_5R6G5B pixels to a pixmap (no alpha).
824 static void put_row_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS
)
826 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
827 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
829 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
830 XMesaDrawable buffer
= xrb
->drawable
;
831 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
835 for (i
=0;i
<n
;i
++,x
++) {
838 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
839 XMesaSetForeground( dpy
, gc
, p
);
840 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
845 /* draw all pixels */
846 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
847 register GLushort
*ptr2
= (GLushort
*) rowimg
->data
;
849 PACK_TRUEDITHER( ptr2
[i
], x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
851 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
857 * Write a span of PF_DITHER pixels to a pixmap.
859 static void put_row_DITHER_pixmap( PUT_ROW_ARGS
)
861 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
862 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
864 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
865 XMesaDrawable buffer
= xrb
->drawable
;
866 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
871 for (i
=0;i
<n
;i
++,x
++) {
873 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
874 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
879 /* draw all pixels */
880 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
882 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
884 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
890 * Write a span of PF_DITHER pixels to a pixmap (no alpha).
892 static void put_row_rgb_DITHER_pixmap( RGB_SPAN_ARGS
)
894 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
895 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
897 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
898 XMesaDrawable buffer
= xrb
->drawable
;
899 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
904 for (i
=0;i
<n
;i
++,x
++) {
906 XMesaSetForeground( dpy
, gc
, XDITHER(x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
907 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
912 /* draw all pixels */
913 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
915 XMesaPutPixel( rowimg
, i
, 0, XDITHER(x
+i
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
917 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
923 * Write a span of PF_1BIT pixels to a pixmap.
925 static void put_row_1BIT_pixmap( PUT_ROW_ARGS
)
927 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
928 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
930 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
931 XMesaDrawable buffer
= xrb
->drawable
;
932 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
937 for (i
=0;i
<n
;i
++,x
++) {
939 XMesaSetForeground( dpy
, gc
,
940 DITHER_1BIT( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
941 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
946 /* draw all pixels */
947 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
949 XMesaPutPixel( rowimg
, i
, 0,
950 DITHER_1BIT( x
+i
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
952 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
958 * Write a span of PF_1BIT pixels to a pixmap (no alpha).
960 static void put_row_rgb_1BIT_pixmap( RGB_SPAN_ARGS
)
962 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
963 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
965 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
966 XMesaDrawable buffer
= xrb
->drawable
;
967 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
972 for (i
=0;i
<n
;i
++,x
++) {
974 XMesaSetForeground( dpy
, gc
,
975 DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
976 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
981 /* draw all pixels */
982 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
984 XMesaPutPixel( rowimg
, i
, 0,
985 DITHER_1BIT(x
+i
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
987 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
993 * Write a span of PF_HPCR pixels to a pixmap.
995 static void put_row_HPCR_pixmap( PUT_ROW_ARGS
)
997 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
998 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1000 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1001 XMesaDrawable buffer
= xrb
->drawable
;
1002 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1006 for (i
=0;i
<n
;i
++,x
++) {
1008 XMesaSetForeground( dpy
, gc
,
1009 DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1010 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1015 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1016 register GLubyte
*ptr
= (GLubyte
*) XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
->data
;
1018 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1020 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1026 * Write a span of PF_HPCR pixels to a pixmap (no alpha).
1028 static void put_row_rgb_HPCR_pixmap( RGB_SPAN_ARGS
)
1030 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1031 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1033 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1034 XMesaDrawable buffer
= xrb
->drawable
;
1035 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1039 for (i
=0;i
<n
;i
++,x
++) {
1041 XMesaSetForeground( dpy
, gc
,
1042 DITHER_HPCR(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
1043 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1048 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1049 register GLubyte
*ptr
= (GLubyte
*) XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
->data
;
1051 ptr
[i
] = DITHER_HPCR( (x
+i
), y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1053 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1058 * Write a span of PF_LOOKUP pixels to a pixmap.
1060 static void put_row_LOOKUP_pixmap( PUT_ROW_ARGS
)
1062 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1063 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1065 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1066 XMesaDrawable buffer
= xrb
->drawable
;
1067 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1072 for (i
=0;i
<n
;i
++,x
++) {
1074 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1075 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1080 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1082 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
1084 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1090 * Write a span of PF_LOOKUP pixels to a pixmap (no alpha).
1092 static void put_row_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS
)
1094 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1095 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1097 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1098 XMesaDrawable buffer
= xrb
->drawable
;
1099 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1104 for (i
=0;i
<n
;i
++,x
++) {
1106 XMesaSetForeground( dpy
, gc
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1107 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1112 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1114 XMesaPutPixel( rowimg
, i
, 0, LOOKUP(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1116 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1122 * Write a span of PF_GRAYSCALE pixels to a pixmap.
1124 static void put_row_GRAYSCALE_pixmap( PUT_ROW_ARGS
)
1126 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1127 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1129 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1130 XMesaDrawable buffer
= xrb
->drawable
;
1131 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1135 for (i
=0;i
<n
;i
++,x
++) {
1137 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1138 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1143 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1145 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgba
[i
][RCOMP
],rgba
[i
][GCOMP
],rgba
[i
][BCOMP
]) );
1147 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1153 * Write a span of PF_GRAYSCALE pixels to a pixmap (no alpha).
1155 static void put_row_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS
)
1157 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1158 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1160 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
1161 XMesaDrawable buffer
= xrb
->drawable
;
1162 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
1166 for (i
=0;i
<n
;i
++,x
++) {
1168 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1169 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
1174 XMesaImage
*rowimg
= XMESA_BUFFER(ctx
->DrawBuffer
)->rowimage
;
1176 XMesaPutPixel( rowimg
, i
, 0, GRAY_RGB(rgb
[i
][RCOMP
],rgb
[i
][GCOMP
],rgb
[i
][BCOMP
]) );
1178 XMesaPutImage( dpy
, buffer
, gc
, rowimg
, 0, 0, x
, y
, n
, 1 );
1183 * Write a span of PF_TRUECOLOR pixels to an XImage.
1185 static void put_row_TRUECOLOR_ximage( PUT_ROW_ARGS
)
1187 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1188 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1190 XMesaImage
*img
= xrb
->ximage
;
1194 for (i
=0;i
<n
;i
++,x
++) {
1197 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1198 XMesaPutPixel( img
, x
, y
, p
);
1203 /* draw all pixels */
1204 for (i
=0;i
<n
;i
++,x
++) {
1206 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1207 XMesaPutPixel( img
, x
, y
, p
);
1214 * Write a span of PF_TRUECOLOR pixels to an XImage (no alpha).
1216 static void put_row_rgb_TRUECOLOR_ximage( RGB_SPAN_ARGS
)
1218 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1219 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1221 XMesaImage
*img
= xrb
->ximage
;
1225 for (i
=0;i
<n
;i
++,x
++) {
1228 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1229 XMesaPutPixel( img
, x
, y
, p
);
1234 /* draw all pixels */
1235 for (i
=0;i
<n
;i
++,x
++) {
1237 PACK_TRUECOLOR( p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1238 XMesaPutPixel( img
, x
, y
, p
);
1245 * Write a span of PF_TRUEDITHER pixels to an XImage.
1247 static void put_row_TRUEDITHER_ximage( PUT_ROW_ARGS
)
1249 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1250 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1252 XMesaImage
*img
= xrb
->ximage
;
1256 for (i
=0;i
<n
;i
++,x
++) {
1259 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1260 XMesaPutPixel( img
, x
, y
, p
);
1265 /* draw all pixels */
1266 for (i
=0;i
<n
;i
++,x
++) {
1268 PACK_TRUEDITHER(p
, x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1269 XMesaPutPixel( img
, x
, y
, p
);
1276 * Write a span of PF_TRUEDITHER pixels to an XImage (no alpha).
1278 static void put_row_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS
)
1280 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1281 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1283 XMesaImage
*img
= xrb
->ximage
;
1287 for (i
=0;i
<n
;i
++,x
++) {
1290 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1291 XMesaPutPixel( img
, x
, y
, p
);
1296 /* draw all pixels */
1297 for (i
=0;i
<n
;i
++,x
++) {
1299 PACK_TRUEDITHER(p
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1300 XMesaPutPixel( img
, x
, y
, p
);
1307 static void *get_pointer_4_ximage( GLcontext
*ctx
,
1308 struct gl_renderbuffer
*rb
,
1312 return PIXEL_ADDR4(xrb
, x
, y
);
1318 * Write a span of PF_8A8B8G8R-format pixels to an ximage.
1320 static void put_row_8A8B8G8R_ximage( PUT_ROW_ARGS
)
1322 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1325 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1330 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1335 /* draw all pixels */
1337 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1344 * Write a span of PF_8A8B8G8R-format pixels to an ximage (no alpha).
1346 static void put_row_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS
)
1348 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1351 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1355 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1360 /* draw all pixels */
1362 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1368 * Write a span of PF_8A8R8G8B-format pixels to an ximage.
1370 static void put_row_8A8R8G8B_ximage( PUT_ROW_ARGS
)
1372 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1375 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1379 ptr
[i
] = PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1384 /* draw all pixels */
1386 ptr
[i
] = PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1393 * Write a span of PF_8A8R8G8B-format pixels to an ximage (no alpha).
1395 static void put_row_rgb_8A8R8G8B_ximage( RGB_SPAN_ARGS
)
1397 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1400 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1404 ptr
[i
] = PACK_8A8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1409 /* draw all pixels */
1411 ptr
[i
] = PACK_8A8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1418 * Write a span of PF_8R8G8B-format pixels to an ximage.
1420 static void put_row_8R8G8B_ximage( PUT_ROW_ARGS
)
1422 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1425 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1429 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1435 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1442 * Write a span of PF_8R8G8B24-format pixels to an ximage.
1444 static void put_row_8R8G8B24_ximage( PUT_ROW_ARGS
)
1446 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1449 register GLubyte
*ptr
= (GLubyte
*) PIXEL_ADDR3(xrb
, x
, y
);
1453 GLuint
*ptr4
= (GLuint
*) ptr
;
1454 register GLuint pixel
= *ptr4
;
1455 switch (3 & (int)(ptr
- (GLubyte
*)ptr4
)) {
1457 pixel
&= 0xff000000;
1458 pixel
|= rgba
[i
][BCOMP
];
1459 pixel
|= rgba
[i
][GCOMP
] << 8;
1460 pixel
|= rgba
[i
][RCOMP
] << 16;
1464 pixel
&= 0x00ffffff;
1465 pixel
|= rgba
[i
][BCOMP
] << 24;
1467 pixel
= *ptr4
& 0xffff0000;
1468 pixel
|= rgba
[i
][GCOMP
];
1469 pixel
|= rgba
[i
][RCOMP
] << 8;
1473 pixel
&= 0x0000ffff;
1474 pixel
|= rgba
[i
][BCOMP
] << 16;
1475 pixel
|= rgba
[i
][GCOMP
] << 24;
1477 pixel
= *ptr4
& 0xffffff00;
1478 pixel
|= rgba
[i
][RCOMP
];
1482 pixel
&= 0x000000ff;
1483 pixel
|= rgba
[i
][BCOMP
] << 8;
1484 pixel
|= rgba
[i
][GCOMP
] << 16;
1485 pixel
|= rgba
[i
][RCOMP
] << 24;
1494 /* write all pixels */
1496 GLuint
*ptr4
= (GLuint
*) ptr
;
1497 register GLuint pixel
= *ptr4
;
1498 int index
= (int)(ptr
- (GLubyte
*)ptr4
);
1499 register GLuint i
= 0;
1504 pixel
&= 0x00ffffff;
1505 pixel
|= rgba
[i
][BCOMP
] << 24;
1507 pixel
= *ptr4
& 0xffff0000;
1508 pixel
|= rgba
[i
][GCOMP
];
1509 pixel
|= rgba
[i
++][RCOMP
] << 8;
1514 pixel
&= 0x0000ffff;
1515 pixel
|= rgba
[i
][BCOMP
] << 16;
1516 pixel
|= rgba
[i
][GCOMP
] << 24;
1518 pixel
= *ptr4
& 0xffffff00;
1519 pixel
|= rgba
[i
++][RCOMP
];
1524 pixel
&= 0x000000ff;
1525 pixel
|= rgba
[i
][BCOMP
] << 8;
1526 pixel
|= rgba
[i
][GCOMP
] << 16;
1527 pixel
|= rgba
[i
++][RCOMP
] << 24;
1534 pixel
= rgba
[i
][BCOMP
];
1535 pixel
|= rgba
[i
][GCOMP
] << 8;
1536 pixel
|= rgba
[i
++][RCOMP
] << 16;
1537 pixel
|= rgba
[i
][BCOMP
] << 24;
1539 pixel
= rgba
[i
][GCOMP
];
1540 pixel
|= rgba
[i
++][RCOMP
] << 8;
1541 pixel
|= rgba
[i
][BCOMP
] << 16;
1542 pixel
|= rgba
[i
][GCOMP
] << 24;
1544 pixel
= rgba
[i
++][RCOMP
];
1545 pixel
|= rgba
[i
][BCOMP
] << 8;
1546 pixel
|= rgba
[i
][GCOMP
] << 16;
1547 pixel
|= rgba
[i
++][RCOMP
] << 24;
1555 pixel
= *ptr4
& 0xff000000;
1556 pixel
|= rgba
[i
][BCOMP
];
1557 pixel
|= rgba
[i
][GCOMP
] << 8;
1558 pixel
|= rgba
[i
][RCOMP
] << 16;
1562 pixel
= rgba
[i
][BCOMP
];
1563 pixel
|= rgba
[i
][GCOMP
] << 8;
1564 pixel
|= rgba
[i
++][RCOMP
] << 16;
1565 pixel
|= rgba
[i
][BCOMP
] << 24;
1567 pixel
= *ptr4
& 0xffff0000;
1568 pixel
|= rgba
[i
][GCOMP
];
1569 pixel
|= rgba
[i
][RCOMP
] << 8;
1573 pixel
= rgba
[i
][BCOMP
];
1574 pixel
|= rgba
[i
][GCOMP
] << 8;
1575 pixel
|= rgba
[i
++][RCOMP
] << 16;
1576 pixel
|= rgba
[i
][BCOMP
] << 24;
1578 pixel
= rgba
[i
][GCOMP
];
1579 pixel
|= rgba
[i
++][RCOMP
] << 8;
1580 pixel
|= rgba
[i
][BCOMP
] << 16;
1581 pixel
|= rgba
[i
][GCOMP
] << 24;
1583 pixel
= *ptr4
& 0xffffff00;
1584 pixel
|= rgba
[i
][RCOMP
];
1593 * Write a span of PF_8R8G8B-format pixels to an ximage (no alpha).
1595 static void put_row_rgb_8R8G8B_ximage( RGB_SPAN_ARGS
)
1597 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1600 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1604 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1609 /* draw all pixels */
1611 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1618 * Write a span of PF_8R8G8B24-format pixels to an ximage (no alpha).
1620 static void put_row_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS
)
1622 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1625 register GLubyte
*ptr
= (GLubyte
*) PIXEL_ADDR3(xrb
, x
, y
);
1629 *ptr
++ = rgb
[i
][BCOMP
];
1630 *ptr
++ = rgb
[i
][GCOMP
];
1631 *ptr
++ = rgb
[i
][RCOMP
];
1639 /* draw all pixels */
1641 *ptr
++ = rgb
[i
][BCOMP
];
1642 *ptr
++ = rgb
[i
][GCOMP
];
1643 *ptr
++ = rgb
[i
][RCOMP
];
1650 * Write a span of PF_5R6G5B-format pixels to an ximage.
1652 static void put_row_5R6G5B_ximage( PUT_ROW_ARGS
)
1654 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1657 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1661 ptr
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1666 /* draw all pixels */
1667 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1668 GLuint
*ptr32
= (GLuint
*) ptr
;
1669 GLuint extraPixel
= (n
& 1);
1671 for (i
= 0; i
< n
; i
+= 2) {
1673 p0
= PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1674 p1
= PACK_5R6G5B(rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
]);
1675 *ptr32
++ = (p1
<< 16) | p0
;
1678 ptr
[n
] = PACK_5R6G5B(rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1681 for (i
= 0; i
< n
; i
++) {
1682 ptr
[i
] = PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1690 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage.
1692 static void put_row_DITHER_5R6G5B_ximage( PUT_ROW_ARGS
)
1694 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1696 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1698 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1699 const GLint y2
= YFLIP(xrb
, y
);
1701 for (i
=0;i
<n
;i
++,x
++) {
1703 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1708 /* draw all pixels */
1709 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1710 GLuint
*ptr32
= (GLuint
*) ptr
;
1711 GLuint extraPixel
= (n
& 1);
1713 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1715 PACK_TRUEDITHER( p0
, x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1716 PACK_TRUEDITHER( p1
, x
+1, y2
, rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
] );
1717 *ptr32
++ = (p1
<< 16) | p0
;
1720 PACK_TRUEDITHER( ptr
[n
], x
+n
, y2
, rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1723 for (i
= 0; i
< n
; i
++, x
++) {
1724 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1732 * Write a span of PF_5R6G5B-format pixels to an ximage (no alpha).
1734 static void put_row_rgb_5R6G5B_ximage( RGB_SPAN_ARGS
)
1736 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1739 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1743 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1748 /* draw all pixels */
1749 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1750 GLuint
*ptr32
= (GLuint
*) ptr
;
1751 GLuint extraPixel
= (n
& 1);
1753 for (i
= 0; i
< n
; i
+= 2) {
1755 p0
= PACK_5R6G5B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1756 p1
= PACK_5R6G5B(rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
]);
1757 *ptr32
++ = (p1
<< 16) | p0
;
1760 ptr
[n
] = PACK_5R6G5B(rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1764 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1772 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage (no alpha).
1774 static void put_row_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS
)
1776 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1778 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1780 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1782 for (i
=0;i
<n
;i
++,x
++) {
1784 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1789 /* draw all pixels */
1790 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1791 GLuint
*ptr32
= (GLuint
*) ptr
;
1792 GLuint extraPixel
= (n
& 1);
1794 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1796 PACK_TRUEDITHER( p0
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1797 PACK_TRUEDITHER( p1
, x
+1, y
, rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
] );
1798 *ptr32
++ = (p1
<< 16) | p0
;
1801 PACK_TRUEDITHER( ptr
[n
], x
+n
, y
, rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1804 for (i
=0;i
<n
;i
++,x
++) {
1805 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1813 * Write a span of PF_DITHER pixels to an XImage.
1815 static void put_row_DITHER_ximage( PUT_ROW_ARGS
)
1817 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1819 XMesaImage
*img
= xrb
->ximage
;
1821 int yy
= YFLIP(xrb
, y
);
1824 for (i
=0;i
<n
;i
++,x
++) {
1826 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1831 /* draw all pixels */
1832 for (i
=0;i
<n
;i
++,x
++) {
1833 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1840 * Write a span of PF_DITHER pixels to an XImage (no alpha).
1842 static void put_row_rgb_DITHER_ximage( RGB_SPAN_ARGS
)
1844 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1846 XMesaImage
*img
= xrb
->ximage
;
1848 int yy
= YFLIP(xrb
, y
);
1851 for (i
=0;i
<n
;i
++,x
++) {
1853 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1858 /* draw all pixels */
1859 for (i
=0;i
<n
;i
++,x
++) {
1860 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1868 * Write a span of 8-bit PF_DITHER pixels to an XImage.
1870 static void put_row_DITHER8_ximage( PUT_ROW_ARGS
)
1872 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1875 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
1878 for (i
=0;i
<n
;i
++,x
++) {
1880 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1885 for (i
=0;i
<n
;i
++,x
++) {
1886 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1892 static void put_row_rgb_DITHER8_ximage( RGB_SPAN_ARGS
)
1894 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1897 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
1900 for (i
=0;i
<n
;i
++,x
++) {
1902 ptr
[i
] = (GLubyte
) XDITHER( x
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
1907 const GLubyte
*data
= (GLubyte
*) rgb
;
1908 for (i
=0;i
<n
;i
++,x
++) {
1909 /*ptr[i] = XDITHER( x, rgb[i][0], rgb[i][1], rgb[i][2] );*/
1910 ptr
[i
] = (GLubyte
) XDITHER( x
, data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
1918 * Write a span of PF_1BIT pixels to an XImage.
1920 static void put_row_1BIT_ximage( PUT_ROW_ARGS
)
1922 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1923 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1925 XMesaImage
*img
= xrb
->ximage
;
1930 for (i
=0;i
<n
;i
++,x
++) {
1932 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]));
1937 for (i
=0;i
<n
;i
++,x
++) {
1938 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
1945 * Write a span of PF_1BIT pixels to an XImage (no alpha).
1947 static void put_row_rgb_1BIT_ximage( RGB_SPAN_ARGS
)
1949 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1950 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1952 XMesaImage
*img
= xrb
->ximage
;
1957 for (i
=0;i
<n
;i
++,x
++) {
1959 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]));
1964 for (i
=0;i
<n
;i
++,x
++) {
1965 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
1972 * Write a span of PF_HPCR pixels to an XImage.
1974 static void put_row_HPCR_ximage( PUT_ROW_ARGS
)
1976 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1978 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1980 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
1982 for (i
=0;i
<n
;i
++,x
++) {
1984 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1989 /* draw all pixels */
1990 for (i
=0;i
<n
;i
++,x
++) {
1991 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1998 * Write a span of PF_HPCR pixels to an XImage (no alpha).
2000 static void put_row_rgb_HPCR_ximage( RGB_SPAN_ARGS
)
2002 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2004 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2006 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2008 for (i
=0;i
<n
;i
++,x
++) {
2010 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2015 /* draw all pixels */
2016 for (i
=0;i
<n
;i
++,x
++) {
2017 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2024 * Write a span of PF_LOOKUP pixels to an XImage.
2026 static void put_row_LOOKUP_ximage( PUT_ROW_ARGS
)
2028 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2030 XMesaImage
*img
= xrb
->ximage
;
2035 for (i
=0;i
<n
;i
++,x
++) {
2037 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2042 /* draw all pixels */
2043 for (i
=0;i
<n
;i
++,x
++) {
2044 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2051 * Write a span of PF_LOOKUP pixels to an XImage (no alpha).
2053 static void put_row_rgb_LOOKUP_ximage( RGB_SPAN_ARGS
)
2055 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2057 XMesaImage
*img
= xrb
->ximage
;
2062 for (i
=0;i
<n
;i
++,x
++) {
2064 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2069 /* draw all pixels */
2070 for (i
=0;i
<n
;i
++,x
++) {
2071 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2078 * Write a span of 8-bit PF_LOOKUP pixels to an XImage.
2080 static void put_row_LOOKUP8_ximage( PUT_ROW_ARGS
)
2082 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2085 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2088 for (i
=0;i
<n
;i
++,x
++) {
2090 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2095 /* draw all pixels */
2096 for (i
=0;i
<n
;i
++,x
++) {
2097 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2103 static void put_row_rgb_LOOKUP8_ximage( RGB_SPAN_ARGS
)
2105 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2108 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2111 for (i
=0;i
<n
;i
++,x
++) {
2113 ptr
[i
] = (GLubyte
) LOOKUP( rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
2118 /* draw all pixels */
2119 const GLubyte
*data
= (GLubyte
*) rgb
;
2120 for (i
=0;i
<n
;i
++,x
++) {
2121 /*ptr[i] = LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );*/
2122 ptr
[i
] = (GLubyte
) LOOKUP( data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
2129 * Write a span of PF_GRAYSCALE pixels to an XImage.
2131 static void put_row_GRAYSCALE_ximage( PUT_ROW_ARGS
)
2133 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2135 XMesaImage
*img
= xrb
->ximage
;
2139 for (i
=0;i
<n
;i
++,x
++) {
2141 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2146 /* draw all pixels */
2147 for (i
=0;i
<n
;i
++,x
++) {
2148 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2155 * Write a span of PF_GRAYSCALE pixels to an XImage (no alpha).
2157 static void put_row_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS
)
2159 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2161 XMesaImage
*img
= xrb
->ximage
;
2165 for (i
=0;i
<n
;i
++,x
++) {
2167 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2172 /* draw all pixels */
2173 for (i
=0;i
<n
;i
++,x
++) {
2174 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2181 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage.
2183 static void put_row_GRAYSCALE8_ximage( PUT_ROW_ARGS
)
2185 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2188 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2192 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2197 /* draw all pixels */
2199 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2206 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage (no alpha).
2208 static void put_row_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS
)
2210 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2213 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2217 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2222 /* draw all pixels */
2224 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2232 /**********************************************************************/
2233 /*** Write COLOR PIXEL functions ***/
2234 /**********************************************************************/
2237 #define PUT_VALUES_ARGS \
2238 GLcontext *ctx, struct gl_renderbuffer *rb, \
2239 GLuint n, const GLint x[], const GLint y[], \
2240 const void *values, const GLubyte mask[]
2244 * Write an array of PF_TRUECOLOR pixels to a pixmap.
2246 static void put_values_TRUECOLOR_pixmap( PUT_VALUES_ARGS
)
2248 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2249 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2251 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2252 XMesaDrawable buffer
= xrb
->drawable
;
2253 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2258 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2259 XMesaSetForeground( dpy
, gc
, p
);
2260 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2267 * Write an array of PF_TRUEDITHER pixels to a pixmap.
2269 static void put_values_TRUEDITHER_pixmap( PUT_VALUES_ARGS
)
2271 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2272 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2274 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2275 XMesaDrawable buffer
= xrb
->drawable
;
2276 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2281 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2282 XMesaSetForeground( dpy
, gc
, p
);
2283 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2290 * Write an array of PF_8A8B8G8R pixels to a pixmap.
2292 static void put_values_8A8B8G8R_pixmap( PUT_VALUES_ARGS
)
2294 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2295 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2297 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2298 XMesaDrawable buffer
= xrb
->drawable
;
2299 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2303 XMesaSetForeground( dpy
, gc
,
2304 PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] ));
2305 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2311 * Write an array of PF_8A8R8G8B pixels to a pixmap.
2313 static void put_values_8A8R8G8B_pixmap( PUT_VALUES_ARGS
)
2315 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2316 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2318 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2319 XMesaDrawable buffer
= xrb
->drawable
;
2320 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2324 XMesaSetForeground( dpy
, gc
,
2325 PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] ));
2326 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2332 * Write an array of PF_8R8G8B pixels to a pixmap.
2334 static void put_values_8R8G8B_pixmap( PUT_VALUES_ARGS
)
2336 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2337 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2339 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2340 XMesaDrawable buffer
= xrb
->drawable
;
2341 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2345 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2346 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2353 * Write an array of PF_8R8G8B24 pixels to a pixmap.
2355 static void put_values_8R8G8B24_pixmap( PUT_VALUES_ARGS
)
2357 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2358 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2360 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2361 XMesaDrawable buffer
= xrb
->drawable
;
2362 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2366 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2367 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2374 * Write an array of PF_5R6G5B pixels to a pixmap.
2376 static void put_values_5R6G5B_pixmap( PUT_VALUES_ARGS
)
2378 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2379 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2381 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2382 XMesaDrawable buffer
= xrb
->drawable
;
2383 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2387 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2388 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2395 * Write an array of PF_DITHER_5R6G5B pixels to a pixmap.
2397 static void put_values_DITHER_5R6G5B_pixmap( PUT_VALUES_ARGS
)
2399 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2400 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2402 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2403 XMesaDrawable buffer
= xrb
->drawable
;
2404 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2409 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2410 XMesaSetForeground( dpy
, gc
, p
);
2411 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2418 * Write an array of PF_DITHER pixels to a pixmap.
2420 static void put_values_DITHER_pixmap( PUT_VALUES_ARGS
)
2422 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2423 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2425 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2426 XMesaDrawable buffer
= xrb
->drawable
;
2427 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2432 XMesaSetForeground( dpy
, gc
,
2433 DITHER(x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2434 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2441 * Write an array of PF_1BIT pixels to a pixmap.
2443 static void put_values_1BIT_pixmap( PUT_VALUES_ARGS
)
2445 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2446 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2448 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2449 XMesaDrawable buffer
= xrb
->drawable
;
2450 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2455 XMesaSetForeground( dpy
, gc
,
2456 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2457 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2464 * Write an array of PF_HPCR pixels to a pixmap.
2466 static void put_values_HPCR_pixmap( PUT_VALUES_ARGS
)
2468 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2469 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2471 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2472 XMesaDrawable buffer
= xrb
->drawable
;
2473 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2477 XMesaSetForeground( dpy
, gc
,
2478 DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2479 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2486 * Write an array of PF_LOOKUP pixels to a pixmap.
2488 static void put_values_LOOKUP_pixmap( PUT_VALUES_ARGS
)
2490 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2491 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2493 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2494 XMesaDrawable buffer
= xrb
->drawable
;
2495 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2500 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2501 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2508 * Write an array of PF_GRAYSCALE pixels to a pixmap.
2510 static void put_values_GRAYSCALE_pixmap( PUT_VALUES_ARGS
)
2512 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2513 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2515 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2516 XMesaDrawable buffer
= xrb
->drawable
;
2517 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2521 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2522 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2529 * Write an array of PF_TRUECOLOR pixels to an ximage.
2531 static void put_values_TRUECOLOR_ximage( PUT_VALUES_ARGS
)
2533 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2534 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2536 XMesaImage
*img
= xrb
->ximage
;
2541 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2542 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), p
);
2549 * Write an array of PF_TRUEDITHER pixels to an XImage.
2551 static void put_values_TRUEDITHER_ximage( PUT_VALUES_ARGS
)
2553 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2554 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2556 XMesaImage
*img
= xrb
->ximage
;
2561 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2562 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), p
);
2569 * Write an array of PF_8A8B8G8R pixels to an ximage.
2571 static void put_values_8A8B8G8R_ximage( PUT_VALUES_ARGS
)
2573 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2578 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
2579 *ptr
= PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
2585 * Write an array of PF_8A8R8G8B pixels to an ximage.
2587 static void put_values_8A8R8G8B_ximage( PUT_VALUES_ARGS
)
2589 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2594 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
2595 *ptr
= PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
2602 * Write an array of PF_8R8G8B pixels to an ximage.
2604 static void put_values_8R8G8B_ximage( PUT_VALUES_ARGS
)
2606 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2611 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
2612 *ptr
= PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2619 * Write an array of PF_8R8G8B24 pixels to an ximage.
2621 static void put_values_8R8G8B24_ximage( PUT_VALUES_ARGS
)
2623 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2628 bgr_t
*ptr
= PIXEL_ADDR3(xrb
, x
[i
], y
[i
] );
2629 ptr
->r
= rgba
[i
][RCOMP
];
2630 ptr
->g
= rgba
[i
][GCOMP
];
2631 ptr
->b
= rgba
[i
][BCOMP
];
2638 * Write an array of PF_5R6G5B pixels to an ximage.
2640 static void put_values_5R6G5B_ximage( PUT_VALUES_ARGS
)
2642 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2647 GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
[i
], y
[i
] );
2648 *ptr
= PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2655 * Write an array of PF_DITHER_5R6G5B pixels to an ximage.
2657 static void put_values_DITHER_5R6G5B_ximage( PUT_VALUES_ARGS
)
2659 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2661 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2665 GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
[i
], y
[i
] );
2666 PACK_TRUEDITHER( *ptr
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2673 * Write an array of PF_DITHER pixels to an XImage.
2675 static void put_values_DITHER_ximage( PUT_VALUES_ARGS
)
2677 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2679 XMesaImage
*img
= xrb
->ximage
;
2684 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
2685 DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2692 * Write an array of 8-bit PF_DITHER pixels to an XImage.
2694 static void put_values_DITHER8_ximage( PUT_VALUES_ARGS
)
2696 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2702 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
2703 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2710 * Write an array of PF_1BIT pixels to an XImage.
2712 static void put_values_1BIT_ximage( PUT_VALUES_ARGS
)
2714 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2715 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2717 XMesaImage
*img
= xrb
->ximage
;
2722 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
2723 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2730 * Write an array of PF_HPCR pixels to an XImage.
2732 static void put_values_HPCR_ximage( PUT_VALUES_ARGS
)
2734 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2736 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2740 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
2741 *ptr
= (GLubyte
) DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2748 * Write an array of PF_LOOKUP pixels to an XImage.
2750 static void put_values_LOOKUP_ximage( PUT_VALUES_ARGS
)
2752 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2754 XMesaImage
*img
= xrb
->ximage
;
2759 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), LOOKUP(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2766 * Write an array of 8-bit PF_LOOKUP pixels to an XImage.
2768 static void put_values_LOOKUP8_ximage( PUT_VALUES_ARGS
)
2770 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2776 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
2777 *ptr
= (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2784 * Write an array of PF_GRAYSCALE pixels to an XImage.
2786 static void put_values_GRAYSCALE_ximage( PUT_VALUES_ARGS
)
2788 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2790 XMesaImage
*img
= xrb
->ximage
;
2794 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
2795 GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2802 * Write an array of 8-bit PF_GRAYSCALE pixels to an XImage.
2804 static void put_values_GRAYSCALE8_ximage( PUT_VALUES_ARGS
)
2806 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2811 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
] );
2812 *ptr
= (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2820 /**********************************************************************/
2821 /*** Write MONO COLOR SPAN functions ***/
2822 /**********************************************************************/
2824 #define PUT_MONO_ROW_ARGS \
2825 GLcontext *ctx, struct gl_renderbuffer *rb, \
2826 GLuint n, GLint x, GLint y, const void *value, \
2827 const GLubyte mask[]
2832 * Write a span of identical pixels to a pixmap.
2834 static void put_mono_row_pixmap( PUT_MONO_ROW_ARGS
)
2836 const GLubyte
*color
= (const GLubyte
*) value
;
2838 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2839 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2840 XMesaDrawable buffer
= xrb
->drawable
;
2841 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2842 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
2843 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2845 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
2848 /* New code contributed by Jeff Epler and cleaned up by Keith
2851 for (i
= 0; i
< n
; ) {
2854 /* Identify and emit contiguous rendered pixels
2856 while (i
< n
&& (!mask
|| mask
[i
]))
2860 XMesaFillRectangle( dpy
, buffer
, gc
,
2861 (int)(x
+start
), (int) y
,
2864 /* Eat up non-rendered pixels
2866 while (i
< n
&& !mask
[i
])
2874 put_mono_row_ci_pixmap( PUT_MONO_ROW_ARGS
)
2876 GLuint colorIndex
= *((GLuint
*) value
);
2877 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2879 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2880 XMesaDrawable buffer
= xrb
->drawable
;
2881 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2883 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
2886 for (i
= 0 ; i
< n
;) {
2889 /* Identify and emit contiguous rendered pixels
2891 while (i
< n
&& (!mask
|| mask
[i
]))
2895 XMesaFillRectangle( dpy
, buffer
, gc
,
2896 (int)(x
+start
), (int) y
,
2899 /* Eat up non-rendered pixels
2901 while (i
< n
&& !mask
[i
])
2909 * Write a span of PF_TRUEDITHER pixels to a pixmap.
2911 static void put_mono_row_TRUEDITHER_pixmap( PUT_MONO_ROW_ARGS
)
2913 const GLubyte
*color
= (const GLubyte
*) value
;
2915 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2916 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2917 XMesaDrawable buffer
= xrb
->drawable
;
2918 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2919 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2921 int yy
= YFLIP(xrb
, y
);
2922 for (i
=0;i
<n
;i
++,x
++) {
2923 if (!mask
|| mask
[i
]) {
2925 PACK_TRUEDITHER(p
, x
, yy
, r
, g
, b
);
2926 XMesaSetForeground( dpy
, gc
, p
);
2927 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2934 * Write a span of PF_DITHER pixels to a pixmap.
2936 static void put_mono_row_DITHER_pixmap( PUT_MONO_ROW_ARGS
)
2938 const GLubyte
*color
= (const GLubyte
*) value
;
2940 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2941 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2942 XMesaDrawable buffer
= xrb
->drawable
;
2943 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2944 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2946 int yy
= YFLIP(xrb
, y
);
2948 for (i
=0;i
<n
;i
++,x
++) {
2949 if (!mask
|| mask
[i
]) {
2950 XMesaSetForeground( dpy
, gc
, XDITHER( x
, r
, g
, b
) );
2951 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2958 * Write a span of PF_1BIT pixels to a pixmap.
2960 static void put_mono_row_1BIT_pixmap( PUT_MONO_ROW_ARGS
)
2962 const GLubyte
*color
= (const GLubyte
*) value
;
2964 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2965 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2966 XMesaDrawable buffer
= xrb
->drawable
;
2967 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2968 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2972 for (i
=0;i
<n
;i
++,x
++) {
2973 if (!mask
|| mask
[i
]) {
2974 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
, y
, r
, g
, b
) );
2975 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
2982 * Write a span of identical pixels to an XImage.
2984 static void put_mono_row_ximage( PUT_MONO_ROW_ARGS
)
2986 const GLubyte
*color
= (const GLubyte
*) value
;
2988 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2989 XMesaImage
*img
= xrb
->ximage
;
2991 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
2992 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2994 for (i
=0;i
<n
;i
++,x
++) {
2995 if (!mask
|| mask
[i
]) {
2996 XMesaPutPixel( img
, x
, y
, pixel
);
3003 put_mono_row_ci_ximage( PUT_MONO_ROW_ARGS
)
3005 const GLuint colorIndex
= *((GLuint
*) value
);
3007 XMesaImage
*img
= xrb
->ximage
;
3010 for (i
=0;i
<n
;i
++,x
++) {
3011 if (!mask
|| mask
[i
]) {
3012 XMesaPutPixel( img
, x
, y
, colorIndex
);
3019 * Write a span of identical PF_TRUEDITHER pixels to an XImage.
3021 static void put_mono_row_TRUEDITHER_ximage( PUT_MONO_ROW_ARGS
)
3023 const GLubyte
*color
= (const GLubyte
*) value
;
3025 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3026 XMesaImage
*img
= xrb
->ximage
;
3027 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3031 if (!mask
|| mask
[i
]) {
3033 PACK_TRUEDITHER( p
, x
+i
, y
, r
, g
, b
);
3034 XMesaPutPixel( img
, x
+i
, y
, p
);
3041 * Write a span of identical 8A8B8G8R pixels to an XImage.
3043 static void put_mono_row_8A8B8G8R_ximage( PUT_MONO_ROW_ARGS
)
3045 const GLubyte
*color
= (const GLubyte
*) value
;
3047 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3049 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3050 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3051 ptr
= PIXEL_ADDR4(xrb
, x
, y
);
3053 if (!mask
|| mask
[i
]) {
3060 * Write a span of identical 8A8R8G8B pixels to an XImage.
3062 static void put_mono_row_8A8R8G8B_ximage( PUT_MONO_ROW_ARGS
)
3064 const GLubyte
*color
= (const GLubyte
*) value
;
3067 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3068 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3069 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3070 ptr
= PIXEL_ADDR4(xrb
, x
, y
);
3072 if (!mask
|| mask
[i
]) {
3080 * Write a span of identical 8R8G8B pixels to an XImage.
3082 static void put_mono_row_8R8G8B_ximage( PUT_MONO_ROW_ARGS
)
3084 const GLubyte
*color
= (const GLubyte
*) value
;
3086 const GLuint pixel
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3087 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
3090 if (!mask
|| mask
[i
]) {
3098 * Write a span of identical 8R8G8B pixels to an XImage.
3100 static void put_mono_row_8R8G8B24_ximage( PUT_MONO_ROW_ARGS
)
3102 const GLubyte
*color
= (const GLubyte
*) value
;
3104 const GLubyte r
= color
[RCOMP
];
3105 const GLubyte g
= color
[GCOMP
];
3106 const GLubyte b
= color
[BCOMP
];
3108 bgr_t
*ptr
= PIXEL_ADDR3(xrb
, x
, y
);
3110 if (!mask
|| mask
[i
]) {
3120 * Write a span of identical DITHER pixels to an XImage.
3122 static void put_mono_row_DITHER_ximage( PUT_MONO_ROW_ARGS
)
3124 const GLubyte
*color
= (const GLubyte
*) value
;
3126 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3127 XMesaImage
*img
= xrb
->ximage
;
3128 int yy
= YFLIP(xrb
, y
);
3131 for (i
=0;i
<n
;i
++,x
++) {
3132 if (!mask
|| mask
[i
]) {
3133 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, r
, g
, b
) );
3140 * Write a span of identical 8-bit DITHER pixels to an XImage.
3142 static void put_mono_row_DITHER8_ximage( PUT_MONO_ROW_ARGS
)
3144 const GLubyte
*color
= (const GLubyte
*) value
;
3146 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3147 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
3150 for (i
=0;i
<n
;i
++,x
++) {
3151 if (!mask
|| mask
[i
]) {
3152 ptr
[i
] = (GLubyte
) XDITHER( x
, r
, g
, b
);
3159 * Write a span of identical 8-bit LOOKUP pixels to an XImage.
3161 static void put_mono_row_LOOKUP8_ximage( PUT_MONO_ROW_ARGS
)
3163 const GLubyte
*color
= (const GLubyte
*) value
;
3166 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
3169 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3171 if (!mask
|| mask
[i
]) {
3179 * Write a span of identical PF_1BIT pixels to an XImage.
3181 static void put_mono_row_1BIT_ximage( PUT_MONO_ROW_ARGS
)
3183 const GLubyte
*color
= (const GLubyte
*) value
;
3184 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3186 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3187 XMesaImage
*img
= xrb
->ximage
;
3191 for (i
=0;i
<n
;i
++,x
++) {
3192 if (!mask
|| mask
[i
]) {
3193 XMesaPutPixel( img
, x
, y
, DITHER_1BIT( x
, y
, r
, g
, b
) );
3200 * Write a span of identical HPCR pixels to an XImage.
3202 static void put_mono_row_HPCR_ximage( PUT_MONO_ROW_ARGS
)
3204 const GLubyte
*color
= (const GLubyte
*) value
;
3206 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3207 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3208 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
3210 for (i
=0;i
<n
;i
++,x
++) {
3211 if (!mask
|| mask
[i
]) {
3212 ptr
[i
] = DITHER_HPCR( x
, y
, r
, g
, b
);
3219 * Write a span of identical 8-bit GRAYSCALE pixels to an XImage.
3221 static void put_mono_row_GRAYSCALE8_ximage( PUT_MONO_ROW_ARGS
)
3223 const GLubyte
*color
= (const GLubyte
*) value
;
3225 const GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3226 GLubyte
*ptr
= (GLubyte
*) PIXEL_ADDR1(xrb
, x
, y
);
3229 if (!mask
|| mask
[i
]) {
3238 * Write a span of identical PF_DITHER_5R6G5B pixels to an XImage.
3240 static void put_mono_row_DITHER_5R6G5B_ximage( PUT_MONO_ROW_ARGS
)
3242 const GLubyte
*color
= (const GLubyte
*) value
;
3244 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3245 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
3246 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3250 if (!mask
|| mask
[i
]) {
3251 PACK_TRUEDITHER(ptr
[i
], x
+i
, y
, r
, g
, b
);
3258 /**********************************************************************/
3259 /*** Write MONO COLOR PIXELS functions ***/
3260 /**********************************************************************/
3262 #define PUT_MONO_VALUES_ARGS \
3263 GLcontext *ctx, struct gl_renderbuffer *rb, \
3264 GLuint n, const GLint x[], const GLint y[], \
3265 const void *value, const GLubyte mask[]
3270 * Write an array of identical pixels to a pixmap.
3272 static void put_mono_values_pixmap( PUT_MONO_VALUES_ARGS
)
3274 const GLubyte
*color
= (const GLubyte
*) value
;
3275 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3277 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3278 XMesaDrawable buffer
= xrb
->drawable
;
3279 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3281 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3282 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3283 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
3286 XMesaDrawPoint( dpy
, buffer
, gc
,
3287 (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3294 put_mono_values_ci_pixmap( PUT_MONO_VALUES_ARGS
)
3296 const GLuint colorIndex
= *((GLuint
*) value
);
3297 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3299 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3300 XMesaDrawable buffer
= xrb
->drawable
;
3301 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3303 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
3306 XMesaDrawPoint( dpy
, buffer
, gc
,
3307 (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3314 * Write an array of PF_TRUEDITHER pixels to a pixmap.
3316 static void put_mono_values_TRUEDITHER_pixmap( PUT_MONO_VALUES_ARGS
)
3318 const GLubyte
*color
= (const GLubyte
*) value
;
3319 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3321 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3322 XMesaDrawable buffer
= xrb
->drawable
;
3323 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3325 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3329 PACK_TRUEDITHER(p
, x
[i
], y
[i
], r
, g
, b
);
3330 XMesaSetForeground( dpy
, gc
, p
);
3331 XMesaDrawPoint( dpy
, buffer
, gc
,
3332 (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3339 * Write an array of PF_DITHER pixels to a pixmap.
3341 static void put_mono_values_DITHER_pixmap( PUT_MONO_VALUES_ARGS
)
3343 const GLubyte
*color
= (const GLubyte
*) value
;
3344 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3346 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3347 XMesaDrawable buffer
= xrb
->drawable
;
3348 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3350 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3354 XMesaSetForeground( dpy
, gc
, DITHER( x
[i
], y
[i
], r
, g
, b
) );
3355 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3362 * Write an array of PF_1BIT pixels to a pixmap.
3364 static void put_mono_values_1BIT_pixmap( PUT_MONO_VALUES_ARGS
)
3366 const GLubyte
*color
= (const GLubyte
*) value
;
3367 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3369 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3370 XMesaDrawable buffer
= xrb
->drawable
;
3371 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3373 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3377 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
) );
3378 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3385 * Write an array of identical pixels to an XImage.
3387 static void put_mono_values_ximage( PUT_MONO_VALUES_ARGS
)
3389 const GLubyte
*color
= (const GLubyte
*) value
;
3390 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3392 XMesaImage
*img
= xrb
->ximage
;
3394 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3395 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3398 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), pixel
);
3405 put_mono_values_ci_ximage( PUT_MONO_VALUES_ARGS
)
3407 const GLuint colorIndex
= *((GLuint
*) value
);
3409 XMesaImage
*img
= xrb
->ximage
;
3413 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), colorIndex
);
3420 * Write an array of identical TRUEDITHER pixels to an XImage.
3422 static void put_mono_values_TRUEDITHER_ximage( PUT_MONO_VALUES_ARGS
)
3424 const GLubyte
*color
= (const GLubyte
*) value
;
3425 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3427 XMesaImage
*img
= xrb
->ximage
;
3429 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3433 PACK_TRUEDITHER(p
, x
[i
], YFLIP(xrb
, y
[i
]), r
, g
, b
);
3434 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), p
);
3442 * Write an array of identical 8A8B8G8R pixels to an XImage
3444 static void put_mono_values_8A8B8G8R_ximage( PUT_MONO_VALUES_ARGS
)
3446 const GLubyte
*color
= (const GLubyte
*) value
;
3448 const GLuint p
= PACK_8A8B8G8R(color
[RCOMP
], color
[GCOMP
],
3449 color
[BCOMP
], color
[ACOMP
]);
3453 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
3460 * Write an array of identical 8A8R8G8B pixels to an XImage
3462 static void put_mono_values_8A8R8G8B_ximage( PUT_MONO_VALUES_ARGS
)
3464 const GLubyte
*color
= (const GLubyte
*) value
;
3466 const GLuint p
= PACK_8A8R8G8B(color
[RCOMP
], color
[GCOMP
],
3467 color
[BCOMP
], color
[ACOMP
]);
3471 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
3478 * Write an array of identical 8R8G8B pixels to an XImage.
3480 static void put_mono_values_8R8G8B_ximage( PUT_MONO_VALUES_ARGS
)
3482 const GLubyte
*color
= (const GLubyte
*) value
;
3485 const GLuint p
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3488 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
3496 * Write an array of identical 8R8G8B pixels to an XImage.
3498 static void put_mono_values_8R8G8B24_ximage( PUT_MONO_VALUES_ARGS
)
3500 const GLubyte
*color
= (const GLubyte
*) value
;
3502 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3506 bgr_t
*ptr
= PIXEL_ADDR3(xrb
, x
[i
], y
[i
] );
3516 * Write an array of identical PF_DITHER pixels to an XImage.
3518 static void put_mono_values_DITHER_ximage( PUT_MONO_VALUES_ARGS
)
3520 const GLubyte
*color
= (const GLubyte
*) value
;
3522 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3523 XMesaImage
*img
= xrb
->ximage
;
3528 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), DITHER( x
[i
], y
[i
], r
, g
, b
) );
3535 * Write an array of identical 8-bit PF_DITHER pixels to an XImage.
3537 static void put_mono_values_DITHER8_ximage( PUT_MONO_VALUES_ARGS
)
3539 const GLubyte
*color
= (const GLubyte
*) value
;
3541 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3546 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3547 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], r
, g
, b
);
3554 * Write an array of identical 8-bit PF_LOOKUP pixels to an XImage.
3556 static void put_mono_values_LOOKUP8_ximage( PUT_MONO_VALUES_ARGS
)
3558 const GLubyte
*color
= (const GLubyte
*) value
;
3563 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3566 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3575 * Write an array of identical PF_1BIT pixels to an XImage.
3577 static void put_mono_values_1BIT_ximage( PUT_MONO_VALUES_ARGS
)
3579 const GLubyte
*color
= (const GLubyte
*) value
;
3580 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3582 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3583 XMesaImage
*img
= xrb
->ximage
;
3588 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
3589 DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
));
3596 * Write an array of identical PF_HPCR pixels to an XImage.
3598 static void put_mono_values_HPCR_ximage( PUT_MONO_VALUES_ARGS
)
3600 const GLubyte
*color
= (const GLubyte
*) value
;
3602 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3603 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3607 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3608 *ptr
= DITHER_HPCR( x
[i
], y
[i
], r
, g
, b
);
3615 * Write an array of identical 8-bit PF_GRAYSCALE pixels to an XImage.
3617 static void put_mono_values_GRAYSCALE8_ximage( PUT_MONO_VALUES_ARGS
)
3619 const GLubyte
*color
= (const GLubyte
*) value
;
3622 register GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3625 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3633 * Write an array of identical PF_DITHER_5R6G5B pixels to an XImage.
3635 static void put_mono_values_DITHER_5R6G5B_ximage( PUT_MONO_VALUES_ARGS
)
3637 const GLubyte
*color
= (const GLubyte
*) value
;
3639 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3640 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3644 GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
[i
], y
[i
] );
3645 PACK_TRUEDITHER(*ptr
, x
[i
], y
[i
], r
, g
, b
);
3652 /**********************************************************************/
3653 /*** Write INDEX SPAN functions ***/
3654 /**********************************************************************/
3657 * Write a span of CI pixels to a Pixmap.
3659 static void put_row_ci_pixmap( PUT_ROW_ARGS
)
3661 const GLuint
*index
= (GLuint
*) values
;
3662 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3664 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3665 XMesaDrawable buffer
= xrb
->drawable
;
3666 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3670 for (i
=0;i
<n
;i
++,x
++) {
3672 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3673 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3678 for (i
=0;i
<n
;i
++,x
++) {
3679 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3680 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3687 * Write a span of CI pixels to an XImage.
3689 static void put_row_ci_ximage( PUT_ROW_ARGS
)
3691 const GLuint
*index
= (const GLuint
*) values
;
3693 XMesaImage
*img
= xrb
->ximage
;
3697 for (i
=0;i
<n
;i
++,x
++) {
3699 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3704 for (i
=0;i
<n
;i
++,x
++) {
3705 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3711 /**********************************************************************/
3712 /*** Write INDEX PIXELS functions ***/
3713 /**********************************************************************/
3716 * Write an array of CI pixels to a Pixmap.
3718 static void put_values_ci_pixmap( PUT_VALUES_ARGS
)
3720 const GLuint
*index
= (const GLuint
*) values
;
3721 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3723 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3724 XMesaDrawable buffer
= xrb
->drawable
;
3725 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3729 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3730 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3737 * Write an array of CI pixels to an XImage.
3739 static void put_values_ci_ximage( PUT_VALUES_ARGS
)
3741 const GLuint
*index
= (const GLuint
*) values
;
3743 XMesaImage
*img
= xrb
->ximage
;
3747 XMesaPutPixel(img
, x
[i
], YFLIP(xrb
, y
[i
]), (unsigned long) index
[i
]);
3755 /**********************************************************************/
3756 /***** Pixel reading *****/
3757 /**********************************************************************/
3759 #ifndef XFree86Server
3761 * Do clip testing prior to calling XGetImage. If any of the region lies
3762 * outside the screen's bounds, XGetImage will return NULL.
3763 * We use XTranslateCoordinates() to check if that's the case and
3764 * adjust the x, y and length parameters accordingly.
3765 * \return -1 if span is totally clipped away,
3766 * else return number of pixels to skip in the destination array.
3769 clip_for_xgetimage(GLcontext
*ctx
, GLuint
*n
, GLint
*x
, GLint
*y
)
3771 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3772 XMesaBuffer source
= XMESA_BUFFER(ctx
->DrawBuffer
);
3773 Window rootWin
= RootWindow(xmesa
->display
, 0);
3775 GLint screenWidth
= WidthOfScreen(DefaultScreenOfDisplay(xmesa
->display
));
3777 if (source
->type
== PBUFFER
|| source
->type
== PIXMAP
)
3779 XTranslateCoordinates(xmesa
->display
, source
->frontxrb
->pixmap
, rootWin
,
3780 *x
, *y
, &dx
, &dy
, &child
);
3781 if (dx
>= screenWidth
) {
3782 /* totally clipped on right */
3786 /* clipped on left */
3788 if (clip
>= (GLint
) *n
)
3789 return -1; /* totally clipped on left */
3795 if ((GLint
) (dx
+ *n
) > screenWidth
) {
3796 /* clipped on right */
3797 GLint clip
= dx
+ *n
- screenWidth
;
3806 * Read a horizontal span of color-index pixels.
3809 get_row_ci(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
3810 GLuint n
, GLint x
, GLint y
, void *values
)
3812 GLuint
*index
= (GLuint
*) values
;
3813 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3820 #ifndef XFree86Server
3821 XMesaImage
*span
= NULL
;
3823 int k
= clip_for_xgetimage(ctx
, &n
, &x
, &y
);
3828 catch_xgetimage_errors( xmesa
->display
);
3829 span
= XGetImage( xmesa
->display
, xrb
->pixmap
,
3830 x
, y
, n
, 1, AllPlanes
, ZPixmap
);
3831 error
= check_xgetimage_errors();
3832 if (span
&& !error
) {
3834 index
[i
] = (GLuint
) XMesaGetPixel( span
, i
, 0 );
3838 /* return 0 pixels */
3844 XMesaDestroyImage( span
);
3847 (*xmesa
->display
->GetImage
)(xrb
->drawable
,
3848 x
, y
, n
, 1, ZPixmap
,
3849 ~0L, (pointer
)index
);
3852 else if (xrb
->ximage
) {
3853 XMesaImage
*img
= xrb
->ximage
;
3854 for (i
=0;i
<n
;i
++,x
++) {
3855 index
[i
] = (GLuint
) XMesaGetPixel( img
, x
, y
);
3863 * Read a horizontal span of color pixels.
3866 get_row_rgba(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
3867 GLuint n
, GLint x
, GLint y
, void *values
)
3869 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
3870 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3872 XMesaBuffer source
= XMESA_BUFFER(ctx
->DrawBuffer
);
3875 /* Read from Pixmap or Window */
3876 XMesaImage
*span
= NULL
;
3878 #ifdef XFree86Server
3879 span
= XMesaCreateImage(xmesa
->xm_visual
->BitsPerPixel
, n
, 1, NULL
);
3880 span
->data
= (char *)MALLOC(span
->height
* span
->bytes_per_line
);
3881 error
= (!span
->data
);
3882 (*xmesa
->display
->GetImage
)(xrb
->drawable
,
3883 x
, YFLIP(xrb
, y
), n
, 1, ZPixmap
,
3884 ~0L, (pointer
)span
->data
);
3888 k
= clip_for_xgetimage(ctx
, &n
, &x
, &y
);
3892 catch_xgetimage_errors( xmesa
->display
);
3893 span
= XGetImage( xmesa
->display
, xrb
->pixmap
,
3894 x
, y
, n
, 1, AllPlanes
, ZPixmap
);
3895 error
= check_xgetimage_errors();
3897 if (span
&& !error
) {
3898 switch (xmesa
->pixelformat
) {
3900 case PF_Dither_True
:
3902 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3903 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3904 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3905 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3906 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3907 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3908 GLint rShift
= xmesa
->xm_visual
->rshift
;
3909 GLint gShift
= xmesa
->xm_visual
->gshift
;
3910 GLint bShift
= xmesa
->xm_visual
->bshift
;
3914 p
= XMesaGetPixel( span
, i
, 0 );
3915 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3916 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3917 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3918 rgba
[i
][ACOMP
] = 255;
3923 case PF_Dither_5R6G5B
:
3925 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3926 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3927 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3930 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
3931 /* fast, but not quite accurate
3932 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3933 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3934 rgba[i][BCOMP] = ((p << 3) & 0xff);
3936 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
3937 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3938 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
3939 rgba
[i
][ACOMP
] = 255;
3945 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3948 GLuint p4
= *ptr4
++;
3949 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
3950 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3951 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3952 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
3958 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3961 GLuint p4
= *ptr4
++;
3962 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3963 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3964 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3965 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
3971 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3974 GLuint p4
= *ptr4
++;
3975 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3976 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3977 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3978 rgba
[i
][ACOMP
] = 255;
3984 const bgr_t
*ptr3
= (bgr_t
*) span
->data
;
3987 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
3988 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
3989 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
3990 rgba
[i
][ACOMP
] = 255;
3996 GLubyte
*ptr1
= (GLubyte
*) span
->data
;
3999 GLubyte p
= *ptr1
++;
4000 rgba
[i
][RCOMP
] = p
& 0xE0;
4001 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4002 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4003 rgba
[i
][ACOMP
] = 255;
4011 GLubyte
*rTable
= source
->pixel_to_r
;
4012 GLubyte
*gTable
= source
->pixel_to_g
;
4013 GLubyte
*bTable
= source
->pixel_to_b
;
4014 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
4015 const GLubyte
*ptr1
= (GLubyte
*) span
->data
;
4018 unsigned long p
= *ptr1
++;
4019 rgba
[i
][RCOMP
] = rTable
[p
];
4020 rgba
[i
][GCOMP
] = gTable
[p
];
4021 rgba
[i
][BCOMP
] = bTable
[p
];
4022 rgba
[i
][ACOMP
] = 255;
4028 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
4029 rgba
[i
][RCOMP
] = rTable
[p
];
4030 rgba
[i
][GCOMP
] = gTable
[p
];
4031 rgba
[i
][BCOMP
] = bTable
[p
];
4032 rgba
[i
][ACOMP
] = 255;
4039 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4043 p
= XMesaGetPixel( span
, i
, 0 ) ^ bitFlip
;
4044 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4045 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4046 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4047 rgba
[i
][ACOMP
] = 255;
4052 _mesa_problem(NULL
,"Problem in DD.read_color_span (1)");
4057 /* return black pixels */
4060 rgba
[i
][RCOMP
] = rgba
[i
][GCOMP
] = rgba
[i
][BCOMP
] = rgba
[i
][ACOMP
] = 0;
4064 XMesaDestroyImage( span
);
4067 else if (xrb
->ximage
) {
4068 /* Read from XImage back buffer */
4069 switch (xmesa
->pixelformat
) {
4071 case PF_Dither_True
:
4073 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4074 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4075 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4076 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4077 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4078 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4079 GLint rShift
= xmesa
->xm_visual
->rshift
;
4080 GLint gShift
= xmesa
->xm_visual
->gshift
;
4081 GLint bShift
= xmesa
->xm_visual
->bshift
;
4082 XMesaImage
*img
= xrb
->ximage
;
4087 p
= XMesaGetPixel( img
, x
+i
, y
);
4088 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4089 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4090 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4091 rgba
[i
][ACOMP
] = 255;
4096 case PF_Dither_5R6G5B
:
4098 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4099 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4100 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4101 const GLushort
*ptr2
= PIXEL_ADDR2(xrb
, x
, y
);
4103 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
4104 const GLuint
*ptr4
= (const GLuint
*) ptr2
;
4105 GLuint extraPixel
= (n
& 1);
4107 for (i
= 0; i
< n
; i
+= 2) {
4108 const GLuint p
= *ptr4
++;
4109 const GLuint p0
= p
& 0xffff;
4110 const GLuint p1
= p
>> 16;
4111 /* fast, but not quite accurate
4112 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
4113 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
4114 rgba[i][BCOMP] = ((p << 3) & 0xff);
4116 rgba
[i
][RCOMP
] = pixelToR
[p0
>> 11];
4117 rgba
[i
][GCOMP
] = pixelToG
[(p0
>> 5) & 0x3f];
4118 rgba
[i
][BCOMP
] = pixelToB
[p0
& 0x1f];
4119 rgba
[i
][ACOMP
] = 255;
4120 rgba
[i
+1][RCOMP
] = pixelToR
[p1
>> 11];
4121 rgba
[i
+1][GCOMP
] = pixelToG
[(p1
>> 5) & 0x3f];
4122 rgba
[i
+1][BCOMP
] = pixelToB
[p1
& 0x1f];
4123 rgba
[i
+1][ACOMP
] = 255;
4126 GLushort p
= ptr2
[n
];
4127 rgba
[n
][RCOMP
] = pixelToR
[p
>> 11];
4128 rgba
[n
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
4129 rgba
[n
][BCOMP
] = pixelToB
[p
& 0x1f];
4130 rgba
[n
][ACOMP
] = 255;
4133 for (i
= 0; i
< n
; i
++) {
4134 const GLushort p
= ptr2
[i
];
4135 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
4136 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
4137 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
4138 rgba
[i
][ACOMP
] = 255;
4145 const GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
, y
);
4148 GLuint p4
= *ptr4
++;
4149 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
4150 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4151 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4152 rgba
[i
][ACOMP
] = (GLint
) ((p4
>> 24) & 0xff);
4158 const GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
, y
);
4161 GLuint p4
= *ptr4
++;
4162 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4163 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4164 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4165 rgba
[i
][ACOMP
] = (GLint
) ((p4
>> 24) & 0xff);
4171 const GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
, y
);
4174 GLuint p4
= *ptr4
++;
4175 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4176 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4177 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4178 rgba
[i
][ACOMP
] = 255;
4184 const bgr_t
*ptr3
= PIXEL_ADDR3(xrb
, x
, y
);
4187 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
4188 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
4189 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
4190 rgba
[i
][ACOMP
] = 255;
4196 const GLubyte
*ptr1
= PIXEL_ADDR1(xrb
, x
, y
);
4199 GLubyte p
= *ptr1
++;
4200 rgba
[i
][RCOMP
] = p
& 0xE0;
4201 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4202 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4203 rgba
[i
][ACOMP
] = 255;
4211 const GLubyte
*rTable
= source
->pixel_to_r
;
4212 const GLubyte
*gTable
= source
->pixel_to_g
;
4213 const GLubyte
*bTable
= source
->pixel_to_b
;
4214 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
4215 GLubyte
*ptr1
= PIXEL_ADDR1(xrb
, x
, y
);
4218 unsigned long p
= *ptr1
++;
4219 rgba
[i
][RCOMP
] = rTable
[p
];
4220 rgba
[i
][GCOMP
] = gTable
[p
];
4221 rgba
[i
][BCOMP
] = bTable
[p
];
4222 rgba
[i
][ACOMP
] = 255;
4226 XMesaImage
*img
= xrb
->ximage
;
4229 for (i
=0;i
<n
;i
++,x
++) {
4230 unsigned long p
= XMesaGetPixel( img
, x
, y
);
4231 rgba
[i
][RCOMP
] = rTable
[p
];
4232 rgba
[i
][GCOMP
] = gTable
[p
];
4233 rgba
[i
][BCOMP
] = bTable
[p
];
4234 rgba
[i
][ACOMP
] = 255;
4241 XMesaImage
*img
= xrb
->ximage
;
4242 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4245 for (i
=0;i
<n
;i
++,x
++) {
4247 p
= XMesaGetPixel( img
, x
, y
) ^ bitFlip
;
4248 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4249 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4250 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4251 rgba
[i
][ACOMP
] = 255;
4256 _mesa_problem(NULL
,"Problem in DD.read_color_span (2)");
4265 * Read an array of color index pixels.
4268 get_values_ci(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
4269 GLuint n
, const GLint x
[], const GLint y
[], void *values
)
4271 GLuint
*indx
= (GLuint
*) values
;
4272 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
4277 indx
[i
] = (GLuint
) read_pixel( xmesa
->display
, xrb
->drawable
,
4278 x
[i
], YFLIP(xrb
, y
[i
]) );
4281 else if (xrb
->ximage
) {
4282 XMesaImage
*img
= xrb
->ximage
;
4284 indx
[i
] = (GLuint
) XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) );
4292 get_values_rgba(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
4293 GLuint n
, const GLint x
[], const GLint y
[], void *values
)
4295 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
4297 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
4298 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
4299 XMesaBuffer source
= XMESA_BUFFER(ctx
->DrawBuffer
);
4303 XMesaDrawable buffer
= xrb
->drawable
;
4304 switch (xmesa
->pixelformat
) {
4306 case PF_Dither_True
:
4308 case PF_Dither_5R6G5B
:
4310 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4311 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4312 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4313 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4314 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4315 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4316 GLint rShift
= xmesa
->xm_visual
->rshift
;
4317 GLint gShift
= xmesa
->xm_visual
->gshift
;
4318 GLint bShift
= xmesa
->xm_visual
->bshift
;
4320 unsigned long p
= read_pixel( dpy
, buffer
,
4321 x
[i
], YFLIP(xrb
, y
[i
]) );
4322 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4323 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4324 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4325 rgba
[i
][ACOMP
] = 255;
4331 unsigned long p
= read_pixel( dpy
, buffer
,
4332 x
[i
], YFLIP(xrb
, y
[i
]) );
4333 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xff);
4334 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4335 rgba
[i
][BCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4336 rgba
[i
][ACOMP
] = (GLubyte
) ((p
>> 24) & 0xff);
4341 unsigned long p
= read_pixel( dpy
, buffer
,
4342 x
[i
], YFLIP(xrb
, y
[i
]) );
4343 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4344 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4345 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4346 rgba
[i
][ACOMP
] = (GLubyte
) ((p
>> 24) & 0xff);
4351 unsigned long p
= read_pixel( dpy
, buffer
,
4352 x
[i
], YFLIP(xrb
, y
[i
]) );
4353 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4354 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4355 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4356 rgba
[i
][ACOMP
] = 255;
4361 unsigned long p
= read_pixel( dpy
, buffer
,
4362 x
[i
], YFLIP(xrb
, y
[i
]) );
4363 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4364 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4365 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4366 rgba
[i
][ACOMP
] = 255;
4371 unsigned long p
= read_pixel( dpy
, buffer
,
4372 x
[i
], YFLIP(xrb
, y
[i
]) );
4373 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xE0 );
4374 rgba
[i
][GCOMP
] = (GLubyte
) ((p
& 0x1C) << 3);
4375 rgba
[i
][BCOMP
] = (GLubyte
) ((p
& 0x03) << 6);
4376 rgba
[i
][ACOMP
] = (GLubyte
) 255;
4383 GLubyte
*rTable
= source
->pixel_to_r
;
4384 GLubyte
*gTable
= source
->pixel_to_g
;
4385 GLubyte
*bTable
= source
->pixel_to_b
;
4387 unsigned long p
= read_pixel( dpy
, buffer
,
4388 x
[i
], YFLIP(xrb
, y
[i
]) );
4389 rgba
[i
][RCOMP
] = rTable
[p
];
4390 rgba
[i
][GCOMP
] = gTable
[p
];
4391 rgba
[i
][BCOMP
] = bTable
[p
];
4392 rgba
[i
][ACOMP
] = 255;
4398 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4400 unsigned long p
= read_pixel( dpy
, buffer
,
4401 x
[i
], YFLIP(xrb
, y
[i
])) ^ bitFlip
;
4402 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4403 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4404 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4405 rgba
[i
][ACOMP
] = 255;
4410 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4414 else if (xrb
->ximage
) {
4415 /* Read from XImage back buffer */
4416 switch (xmesa
->pixelformat
) {
4418 case PF_Dither_True
:
4420 case PF_Dither_5R6G5B
:
4422 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4423 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4424 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4425 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4426 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4427 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4428 GLint rShift
= xmesa
->xm_visual
->rshift
;
4429 GLint gShift
= xmesa
->xm_visual
->gshift
;
4430 GLint bShift
= xmesa
->xm_visual
->bshift
;
4431 XMesaImage
*img
= xrb
->ximage
;
4434 p
= XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) );
4435 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4436 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4437 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4438 rgba
[i
][ACOMP
] = 255;
4444 GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
4446 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
4447 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4448 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4449 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
4454 GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
4456 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4457 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4458 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4459 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
4464 GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
4466 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4467 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4468 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4469 rgba
[i
][ACOMP
] = 255;
4474 bgr_t
*ptr3
= PIXEL_ADDR3(xrb
, x
[i
], y
[i
]);
4475 rgba
[i
][RCOMP
] = ptr3
->r
;
4476 rgba
[i
][GCOMP
] = ptr3
->g
;
4477 rgba
[i
][BCOMP
] = ptr3
->b
;
4478 rgba
[i
][ACOMP
] = 255;
4483 GLubyte
*ptr1
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
4485 rgba
[i
][RCOMP
] = p
& 0xE0;
4486 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4487 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4488 rgba
[i
][ACOMP
] = 255;
4495 GLubyte
*rTable
= source
->pixel_to_r
;
4496 GLubyte
*gTable
= source
->pixel_to_g
;
4497 GLubyte
*bTable
= source
->pixel_to_b
;
4498 XMesaImage
*img
= xrb
->ximage
;
4501 p
= XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) );
4502 rgba
[i
][RCOMP
] = rTable
[p
];
4503 rgba
[i
][GCOMP
] = gTable
[p
];
4504 rgba
[i
][BCOMP
] = bTable
[p
];
4505 rgba
[i
][ACOMP
] = 255;
4511 XMesaImage
*img
= xrb
->ximage
;
4512 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4515 p
= XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) ) ^ bitFlip
;
4516 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4517 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4518 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4519 rgba
[i
][ACOMP
] = 255;
4524 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4532 * Initialize the renderbuffer's PutRow, GetRow, etc. functions.
4533 * This would generally only need to be called once when the renderbuffer
4534 * is created. However, we can change pixel formats on the fly if dithering
4535 * is enabled/disabled. Therefore, we may call this more often than that.
4538 xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer
*xrb
,
4539 enum pixel_format pixelformat
, GLint depth
)
4541 const GLboolean pixmap
= xrb
->pixmap
? GL_TRUE
: GL_FALSE
;
4543 switch (pixelformat
) {
4545 ASSERT(xrb
->Base
.DataType
== GL_UNSIGNED_INT
);
4547 xrb
->Base
.PutRow
= put_row_ci_pixmap
;
4548 xrb
->Base
.PutRowRGB
= NULL
;
4549 xrb
->Base
.PutMonoRow
= put_mono_row_ci_pixmap
;
4550 xrb
->Base
.PutValues
= put_values_ci_pixmap
;
4551 xrb
->Base
.PutMonoValues
= put_mono_values_ci_pixmap
;
4554 xrb
->Base
.PutRow
= put_row_ci_ximage
;
4555 xrb
->Base
.PutRowRGB
= NULL
;
4556 xrb
->Base
.PutMonoRow
= put_mono_row_ci_ximage
;
4557 xrb
->Base
.PutValues
= put_values_ci_ximage
;
4558 xrb
->Base
.PutMonoValues
= put_mono_values_ci_ximage
;
4563 xrb
->Base
.PutRow
= put_row_TRUECOLOR_pixmap
;
4564 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUECOLOR_pixmap
;
4565 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4566 xrb
->Base
.PutValues
= put_values_TRUECOLOR_pixmap
;
4567 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4570 xrb
->Base
.PutRow
= put_row_TRUECOLOR_ximage
;
4571 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUECOLOR_ximage
;
4572 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4573 xrb
->Base
.PutValues
= put_values_TRUECOLOR_ximage
;
4574 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4577 case PF_Dither_True
:
4579 xrb
->Base
.PutRow
= put_row_TRUEDITHER_pixmap
;
4580 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUEDITHER_pixmap
;
4581 xrb
->Base
.PutMonoRow
= put_mono_row_TRUEDITHER_pixmap
;
4582 xrb
->Base
.PutValues
= put_values_TRUEDITHER_pixmap
;
4583 xrb
->Base
.PutMonoValues
= put_mono_values_TRUEDITHER_pixmap
;
4586 xrb
->Base
.PutRow
= put_row_TRUEDITHER_ximage
;
4587 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUEDITHER_ximage
;
4588 xrb
->Base
.PutMonoRow
= put_mono_row_TRUEDITHER_ximage
;
4589 xrb
->Base
.PutValues
= put_values_TRUEDITHER_ximage
;
4590 xrb
->Base
.PutMonoValues
= put_mono_values_TRUEDITHER_ximage
;
4595 xrb
->Base
.PutRow
= put_row_8A8B8G8R_pixmap
;
4596 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8B8G8R_pixmap
;
4597 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4598 xrb
->Base
.PutValues
= put_values_8A8B8G8R_pixmap
;
4599 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4602 xrb
->Base
.PutRow
= put_row_8A8B8G8R_ximage
;
4603 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8B8G8R_ximage
;
4604 xrb
->Base
.PutMonoRow
= put_mono_row_8A8B8G8R_ximage
;
4605 xrb
->Base
.PutValues
= put_values_8A8B8G8R_ximage
;
4606 xrb
->Base
.PutMonoValues
= put_mono_values_8A8B8G8R_ximage
;
4607 xrb
->Base
.GetPointer
= get_pointer_4_ximage
;
4612 xrb
->Base
.PutRow
= put_row_8A8R8G8B_pixmap
;
4613 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8R8G8B_pixmap
;
4614 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4615 xrb
->Base
.PutValues
= put_values_8A8R8G8B_pixmap
;
4616 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4619 xrb
->Base
.PutRow
= put_row_8A8R8G8B_ximage
;
4620 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8R8G8B_ximage
;
4621 xrb
->Base
.PutMonoRow
= put_mono_row_8A8R8G8B_ximage
;
4622 xrb
->Base
.PutValues
= put_values_8A8R8G8B_ximage
;
4623 xrb
->Base
.PutMonoValues
= put_mono_values_8A8R8G8B_ximage
;
4624 xrb
->Base
.GetPointer
= get_pointer_4_ximage
;
4629 xrb
->Base
.PutRow
= put_row_8R8G8B_pixmap
;
4630 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B_pixmap
;
4631 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4632 xrb
->Base
.PutValues
= put_values_8R8G8B_pixmap
;
4633 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4636 xrb
->Base
.PutRow
= put_row_8R8G8B_ximage
;
4637 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B_ximage
;
4638 xrb
->Base
.PutMonoRow
= put_mono_row_8R8G8B_ximage
;
4639 xrb
->Base
.PutValues
= put_values_8R8G8B_ximage
;
4640 xrb
->Base
.PutMonoValues
= put_mono_values_8R8G8B_ximage
;
4645 xrb
->Base
.PutRow
= put_row_8R8G8B24_pixmap
;
4646 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B24_pixmap
;
4647 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4648 xrb
->Base
.PutValues
= put_values_8R8G8B24_pixmap
;
4649 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4652 xrb
->Base
.PutRow
= put_row_8R8G8B24_ximage
;
4653 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B24_ximage
;
4654 xrb
->Base
.PutMonoRow
= put_mono_row_8R8G8B24_ximage
;
4655 xrb
->Base
.PutValues
= put_values_8R8G8B24_ximage
;
4656 xrb
->Base
.PutMonoValues
= put_mono_values_8R8G8B24_ximage
;
4661 xrb
->Base
.PutRow
= put_row_5R6G5B_pixmap
;
4662 xrb
->Base
.PutRowRGB
= put_row_rgb_5R6G5B_pixmap
;
4663 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4664 xrb
->Base
.PutValues
= put_values_5R6G5B_pixmap
;
4665 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4668 xrb
->Base
.PutRow
= put_row_5R6G5B_ximage
;
4669 xrb
->Base
.PutRowRGB
= put_row_rgb_5R6G5B_ximage
;
4670 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4671 xrb
->Base
.PutValues
= put_values_5R6G5B_ximage
;
4672 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4675 case PF_Dither_5R6G5B
:
4677 xrb
->Base
.PutRow
= put_row_DITHER_5R6G5B_pixmap
;
4678 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_5R6G5B_pixmap
;
4679 xrb
->Base
.PutMonoRow
= put_mono_row_TRUEDITHER_pixmap
;
4680 xrb
->Base
.PutValues
= put_values_DITHER_5R6G5B_pixmap
;
4681 xrb
->Base
.PutMonoValues
= put_mono_values_TRUEDITHER_pixmap
;
4684 xrb
->Base
.PutRow
= put_row_DITHER_5R6G5B_ximage
;
4685 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_5R6G5B_ximage
;
4686 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER_5R6G5B_ximage
;
4687 xrb
->Base
.PutValues
= put_values_DITHER_5R6G5B_ximage
;
4688 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER_5R6G5B_ximage
;
4693 xrb
->Base
.PutRow
= put_row_DITHER_pixmap
;
4694 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_pixmap
;
4695 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER_pixmap
;
4696 xrb
->Base
.PutValues
= put_values_DITHER_pixmap
;
4697 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER_pixmap
;
4701 xrb
->Base
.PutRow
= put_row_DITHER8_ximage
;
4702 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER8_ximage
;
4703 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER8_ximage
;
4704 xrb
->Base
.PutValues
= put_values_DITHER8_ximage
;
4705 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER8_ximage
;
4708 xrb
->Base
.PutRow
= put_row_DITHER_ximage
;
4709 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_ximage
;
4710 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER_ximage
;
4711 xrb
->Base
.PutValues
= put_values_DITHER_ximage
;
4712 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER_ximage
;
4718 xrb
->Base
.PutRow
= put_row_1BIT_pixmap
;
4719 xrb
->Base
.PutRowRGB
= put_row_rgb_1BIT_pixmap
;
4720 xrb
->Base
.PutMonoRow
= put_mono_row_1BIT_pixmap
;
4721 xrb
->Base
.PutValues
= put_values_1BIT_pixmap
;
4722 xrb
->Base
.PutMonoValues
= put_mono_values_1BIT_pixmap
;
4725 xrb
->Base
.PutRow
= put_row_1BIT_ximage
;
4726 xrb
->Base
.PutRowRGB
= put_row_rgb_1BIT_ximage
;
4727 xrb
->Base
.PutMonoRow
= put_mono_row_1BIT_ximage
;
4728 xrb
->Base
.PutValues
= put_values_1BIT_ximage
;
4729 xrb
->Base
.PutMonoValues
= put_mono_values_1BIT_ximage
;
4734 xrb
->Base
.PutRow
= put_row_HPCR_pixmap
;
4735 xrb
->Base
.PutRowRGB
= put_row_rgb_HPCR_pixmap
;
4736 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4737 xrb
->Base
.PutValues
= put_values_HPCR_pixmap
;
4738 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4741 xrb
->Base
.PutRow
= put_row_HPCR_ximage
;
4742 xrb
->Base
.PutRowRGB
= put_row_rgb_HPCR_ximage
;
4743 xrb
->Base
.PutMonoRow
= put_mono_row_HPCR_ximage
;
4744 xrb
->Base
.PutValues
= put_values_HPCR_ximage
;
4745 xrb
->Base
.PutMonoValues
= put_mono_values_HPCR_ximage
;
4750 xrb
->Base
.PutRow
= put_row_LOOKUP_pixmap
;
4751 xrb
->Base
.PutRowRGB
= put_row_rgb_LOOKUP_pixmap
;
4752 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4753 xrb
->Base
.PutValues
= put_values_LOOKUP_pixmap
;
4754 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4758 xrb
->Base
.PutRow
= put_row_LOOKUP8_ximage
;
4759 xrb
->Base
.PutRowRGB
= put_row_rgb_LOOKUP8_ximage
;
4760 xrb
->Base
.PutMonoRow
= put_mono_row_LOOKUP8_ximage
;
4761 xrb
->Base
.PutValues
= put_values_LOOKUP8_ximage
;
4762 xrb
->Base
.PutMonoValues
= put_mono_values_LOOKUP8_ximage
;
4765 xrb
->Base
.PutRow
= put_row_LOOKUP_ximage
;
4766 xrb
->Base
.PutRowRGB
= put_row_rgb_LOOKUP_ximage
;
4767 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4768 xrb
->Base
.PutValues
= put_values_LOOKUP_ximage
;
4769 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4775 xrb
->Base
.PutRow
= put_row_GRAYSCALE_pixmap
;
4776 xrb
->Base
.PutRowRGB
= put_row_rgb_GRAYSCALE_pixmap
;
4777 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4778 xrb
->Base
.PutValues
= put_values_GRAYSCALE_pixmap
;
4779 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4783 xrb
->Base
.PutRow
= put_row_GRAYSCALE8_ximage
;
4784 xrb
->Base
.PutRowRGB
= put_row_rgb_GRAYSCALE8_ximage
;
4785 xrb
->Base
.PutMonoRow
= put_mono_row_GRAYSCALE8_ximage
;
4786 xrb
->Base
.PutValues
= put_values_GRAYSCALE8_ximage
;
4787 xrb
->Base
.PutMonoValues
= put_mono_values_GRAYSCALE8_ximage
;
4790 xrb
->Base
.PutRow
= put_row_GRAYSCALE_ximage
;
4791 xrb
->Base
.PutRowRGB
= put_row_rgb_GRAYSCALE_ximage
;
4792 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4793 xrb
->Base
.PutValues
= put_values_GRAYSCALE_ximage
;
4794 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4799 _mesa_problem(NULL
, "Bad pixel format in xmesa_update_state (1)");
4805 if (pixelformat
== PF_Index
) {
4806 xrb
->Base
.GetRow
= get_row_ci
;
4807 xrb
->Base
.GetValues
= get_values_ci
;
4810 xrb
->Base
.GetRow
= get_row_rgba
;
4811 xrb
->Base
.GetValues
= get_values_rgba
;