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 * Write a span of PF_8A8B8G8R-format pixels to an ximage.
1309 static void put_row_8A8B8G8R_ximage( PUT_ROW_ARGS
)
1311 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1314 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1319 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1324 /* draw all pixels */
1326 ptr
[i
] = PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1333 * Write a span of PF_8A8B8G8R-format pixels to an ximage (no alpha).
1335 static void put_row_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS
)
1337 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1340 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1344 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1349 /* draw all pixels */
1351 ptr
[i
] = PACK_8A8B8G8R( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1357 * Write a span of PF_8A8R8G8B-format pixels to an ximage.
1359 static void put_row_8A8R8G8B_ximage( PUT_ROW_ARGS
)
1361 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1364 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1368 ptr
[i
] = PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1373 /* draw all pixels */
1375 ptr
[i
] = PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
1382 * Write a span of PF_8A8R8G8B-format pixels to an ximage (no alpha).
1384 static void put_row_rgb_8A8R8G8B_ximage( RGB_SPAN_ARGS
)
1386 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1389 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1393 ptr
[i
] = PACK_8A8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1398 /* draw all pixels */
1400 ptr
[i
] = PACK_8A8R8G8B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], 255 );
1407 * Write a span of PF_8R8G8B-format pixels to an ximage.
1409 static void put_row_8R8G8B_ximage( PUT_ROW_ARGS
)
1411 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1414 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1418 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1424 ptr
[i
] = PACK_8R8G8B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1431 * Write a span of PF_8R8G8B24-format pixels to an ximage.
1433 static void put_row_8R8G8B24_ximage( PUT_ROW_ARGS
)
1435 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1438 register GLubyte
*ptr
= (GLubyte
*) PIXEL_ADDR3(xrb
, x
, y
);
1442 GLuint
*ptr4
= (GLuint
*) ptr
;
1443 register GLuint pixel
= *ptr4
;
1444 switch (3 & (int)(ptr
- (GLubyte
*)ptr4
)) {
1446 pixel
&= 0xff000000;
1447 pixel
|= rgba
[i
][BCOMP
];
1448 pixel
|= rgba
[i
][GCOMP
] << 8;
1449 pixel
|= rgba
[i
][RCOMP
] << 16;
1453 pixel
&= 0x00ffffff;
1454 pixel
|= rgba
[i
][BCOMP
] << 24;
1456 pixel
= *ptr4
& 0xffff0000;
1457 pixel
|= rgba
[i
][GCOMP
];
1458 pixel
|= rgba
[i
][RCOMP
] << 8;
1462 pixel
&= 0x0000ffff;
1463 pixel
|= rgba
[i
][BCOMP
] << 16;
1464 pixel
|= rgba
[i
][GCOMP
] << 24;
1466 pixel
= *ptr4
& 0xffffff00;
1467 pixel
|= rgba
[i
][RCOMP
];
1471 pixel
&= 0x000000ff;
1472 pixel
|= rgba
[i
][BCOMP
] << 8;
1473 pixel
|= rgba
[i
][GCOMP
] << 16;
1474 pixel
|= rgba
[i
][RCOMP
] << 24;
1483 /* write all pixels */
1485 GLuint
*ptr4
= (GLuint
*) ptr
;
1486 register GLuint pixel
= *ptr4
;
1487 int index
= (int)(ptr
- (GLubyte
*)ptr4
);
1488 register GLuint i
= 0;
1493 pixel
&= 0x00ffffff;
1494 pixel
|= rgba
[i
][BCOMP
] << 24;
1496 pixel
= *ptr4
& 0xffff0000;
1497 pixel
|= rgba
[i
][GCOMP
];
1498 pixel
|= rgba
[i
++][RCOMP
] << 8;
1503 pixel
&= 0x0000ffff;
1504 pixel
|= rgba
[i
][BCOMP
] << 16;
1505 pixel
|= rgba
[i
][GCOMP
] << 24;
1507 pixel
= *ptr4
& 0xffffff00;
1508 pixel
|= rgba
[i
++][RCOMP
];
1513 pixel
&= 0x000000ff;
1514 pixel
|= rgba
[i
][BCOMP
] << 8;
1515 pixel
|= rgba
[i
][GCOMP
] << 16;
1516 pixel
|= rgba
[i
++][RCOMP
] << 24;
1523 pixel
= rgba
[i
][BCOMP
];
1524 pixel
|= rgba
[i
][GCOMP
] << 8;
1525 pixel
|= rgba
[i
++][RCOMP
] << 16;
1526 pixel
|= rgba
[i
][BCOMP
] << 24;
1528 pixel
= rgba
[i
][GCOMP
];
1529 pixel
|= rgba
[i
++][RCOMP
] << 8;
1530 pixel
|= rgba
[i
][BCOMP
] << 16;
1531 pixel
|= rgba
[i
][GCOMP
] << 24;
1533 pixel
= rgba
[i
++][RCOMP
];
1534 pixel
|= rgba
[i
][BCOMP
] << 8;
1535 pixel
|= rgba
[i
][GCOMP
] << 16;
1536 pixel
|= rgba
[i
++][RCOMP
] << 24;
1544 pixel
= *ptr4
& 0xff000000;
1545 pixel
|= rgba
[i
][BCOMP
];
1546 pixel
|= rgba
[i
][GCOMP
] << 8;
1547 pixel
|= rgba
[i
][RCOMP
] << 16;
1551 pixel
= rgba
[i
][BCOMP
];
1552 pixel
|= rgba
[i
][GCOMP
] << 8;
1553 pixel
|= rgba
[i
++][RCOMP
] << 16;
1554 pixel
|= rgba
[i
][BCOMP
] << 24;
1556 pixel
= *ptr4
& 0xffff0000;
1557 pixel
|= rgba
[i
][GCOMP
];
1558 pixel
|= rgba
[i
][RCOMP
] << 8;
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
= rgba
[i
][GCOMP
];
1568 pixel
|= rgba
[i
++][RCOMP
] << 8;
1569 pixel
|= rgba
[i
][BCOMP
] << 16;
1570 pixel
|= rgba
[i
][GCOMP
] << 24;
1572 pixel
= *ptr4
& 0xffffff00;
1573 pixel
|= rgba
[i
][RCOMP
];
1582 * Write a span of PF_8R8G8B-format pixels to an ximage (no alpha).
1584 static void put_row_rgb_8R8G8B_ximage( RGB_SPAN_ARGS
)
1586 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1589 register GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
1593 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1598 /* draw all pixels */
1600 ptr
[i
] = PACK_8R8G8B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1607 * Write a span of PF_8R8G8B24-format pixels to an ximage (no alpha).
1609 static void put_row_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS
)
1611 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1614 register GLubyte
*ptr
= (GLubyte
*) PIXEL_ADDR3(xrb
, x
, y
);
1618 *ptr
++ = rgb
[i
][BCOMP
];
1619 *ptr
++ = rgb
[i
][GCOMP
];
1620 *ptr
++ = rgb
[i
][RCOMP
];
1628 /* draw all pixels */
1630 *ptr
++ = rgb
[i
][BCOMP
];
1631 *ptr
++ = rgb
[i
][GCOMP
];
1632 *ptr
++ = rgb
[i
][RCOMP
];
1639 * Write a span of PF_5R6G5B-format pixels to an ximage.
1641 static void put_row_5R6G5B_ximage( PUT_ROW_ARGS
)
1643 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1646 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1650 ptr
[i
] = PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1655 /* draw all pixels */
1656 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1657 GLuint
*ptr32
= (GLuint
*) ptr
;
1658 GLuint extraPixel
= (n
& 1);
1660 for (i
= 0; i
< n
; i
+= 2) {
1662 p0
= PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1663 p1
= PACK_5R6G5B(rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
]);
1664 *ptr32
++ = (p1
<< 16) | p0
;
1667 ptr
[n
] = PACK_5R6G5B(rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1670 for (i
= 0; i
< n
; i
++) {
1671 ptr
[i
] = PACK_5R6G5B(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1679 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage.
1681 static void put_row_DITHER_5R6G5B_ximage( PUT_ROW_ARGS
)
1683 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1685 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1687 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1688 const GLint y2
= YFLIP(xrb
, y
);
1690 for (i
=0;i
<n
;i
++,x
++) {
1692 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1697 /* draw all pixels */
1698 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1699 GLuint
*ptr32
= (GLuint
*) ptr
;
1700 GLuint extraPixel
= (n
& 1);
1702 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1704 PACK_TRUEDITHER( p0
, x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1705 PACK_TRUEDITHER( p1
, x
+1, y2
, rgba
[i
+1][RCOMP
], rgba
[i
+1][GCOMP
], rgba
[i
+1][BCOMP
] );
1706 *ptr32
++ = (p1
<< 16) | p0
;
1709 PACK_TRUEDITHER( ptr
[n
], x
+n
, y2
, rgba
[n
][RCOMP
], rgba
[n
][GCOMP
], rgba
[n
][BCOMP
]);
1712 for (i
= 0; i
< n
; i
++, x
++) {
1713 PACK_TRUEDITHER( ptr
[i
], x
, y2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1721 * Write a span of PF_5R6G5B-format pixels to an ximage (no alpha).
1723 static void put_row_rgb_5R6G5B_ximage( RGB_SPAN_ARGS
)
1725 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1728 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1732 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1737 /* draw all pixels */
1738 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1739 GLuint
*ptr32
= (GLuint
*) ptr
;
1740 GLuint extraPixel
= (n
& 1);
1742 for (i
= 0; i
< n
; i
+= 2) {
1744 p0
= PACK_5R6G5B(rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1745 p1
= PACK_5R6G5B(rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
]);
1746 *ptr32
++ = (p1
<< 16) | p0
;
1749 ptr
[n
] = PACK_5R6G5B(rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1753 ptr
[i
] = PACK_5R6G5B( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1761 * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage (no alpha).
1763 static void put_row_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS
)
1765 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1767 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1769 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
1771 for (i
=0;i
<n
;i
++,x
++) {
1773 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1778 /* draw all pixels */
1779 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
1780 GLuint
*ptr32
= (GLuint
*) ptr
;
1781 GLuint extraPixel
= (n
& 1);
1783 for (i
= 0; i
< n
; i
+= 2, x
+= 2) {
1785 PACK_TRUEDITHER( p0
, x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1786 PACK_TRUEDITHER( p1
, x
+1, y
, rgb
[i
+1][RCOMP
], rgb
[i
+1][GCOMP
], rgb
[i
+1][BCOMP
] );
1787 *ptr32
++ = (p1
<< 16) | p0
;
1790 PACK_TRUEDITHER( ptr
[n
], x
+n
, y
, rgb
[n
][RCOMP
], rgb
[n
][GCOMP
], rgb
[n
][BCOMP
]);
1793 for (i
=0;i
<n
;i
++,x
++) {
1794 PACK_TRUEDITHER( ptr
[i
], x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
1802 * Write a span of PF_DITHER pixels to an XImage.
1804 static void put_row_DITHER_ximage( PUT_ROW_ARGS
)
1806 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1808 XMesaImage
*img
= xrb
->ximage
;
1810 int yy
= YFLIP(xrb
, y
);
1813 for (i
=0;i
<n
;i
++,x
++) {
1815 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1820 /* draw all pixels */
1821 for (i
=0;i
<n
;i
++,x
++) {
1822 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
1829 * Write a span of PF_DITHER pixels to an XImage (no alpha).
1831 static void put_row_rgb_DITHER_ximage( RGB_SPAN_ARGS
)
1833 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1835 XMesaImage
*img
= xrb
->ximage
;
1837 int yy
= YFLIP(xrb
, y
);
1840 for (i
=0;i
<n
;i
++,x
++) {
1842 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1847 /* draw all pixels */
1848 for (i
=0;i
<n
;i
++,x
++) {
1849 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
1857 * Write a span of 8-bit PF_DITHER pixels to an XImage.
1859 static void put_row_DITHER8_ximage( PUT_ROW_ARGS
)
1861 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1864 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
1867 for (i
=0;i
<n
;i
++,x
++) {
1869 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1874 for (i
=0;i
<n
;i
++,x
++) {
1875 ptr
[i
] = (GLubyte
) XDITHER( x
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1881 static void put_row_rgb_DITHER8_ximage( RGB_SPAN_ARGS
)
1883 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1886 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
1889 for (i
=0;i
<n
;i
++,x
++) {
1891 ptr
[i
] = (GLubyte
) XDITHER( x
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
1896 const GLubyte
*data
= (GLubyte
*) rgb
;
1897 for (i
=0;i
<n
;i
++,x
++) {
1898 /*ptr[i] = XDITHER( x, rgb[i][0], rgb[i][1], rgb[i][2] );*/
1899 ptr
[i
] = (GLubyte
) XDITHER( x
, data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
1907 * Write a span of PF_1BIT pixels to an XImage.
1909 static void put_row_1BIT_ximage( PUT_ROW_ARGS
)
1911 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1912 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1914 XMesaImage
*img
= xrb
->ximage
;
1919 for (i
=0;i
<n
;i
++,x
++) {
1921 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]));
1926 for (i
=0;i
<n
;i
++,x
++) {
1927 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
1934 * Write a span of PF_1BIT pixels to an XImage (no alpha).
1936 static void put_row_rgb_1BIT_ximage( RGB_SPAN_ARGS
)
1938 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1939 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1941 XMesaImage
*img
= xrb
->ximage
;
1946 for (i
=0;i
<n
;i
++,x
++) {
1948 XMesaPutPixel(img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]));
1953 for (i
=0;i
<n
;i
++,x
++) {
1954 XMesaPutPixel( img
, x
, y
, DITHER_1BIT(x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]) );
1961 * Write a span of PF_HPCR pixels to an XImage.
1963 static void put_row_HPCR_ximage( PUT_ROW_ARGS
)
1965 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
1967 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1969 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
1971 for (i
=0;i
<n
;i
++,x
++) {
1973 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1978 /* draw all pixels */
1979 for (i
=0;i
<n
;i
++,x
++) {
1980 ptr
[i
] = DITHER_HPCR( x
, y
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
1987 * Write a span of PF_HPCR pixels to an XImage (no alpha).
1989 static void put_row_rgb_HPCR_ximage( RGB_SPAN_ARGS
)
1991 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
1993 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1995 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
1997 for (i
=0;i
<n
;i
++,x
++) {
1999 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2004 /* draw all pixels */
2005 for (i
=0;i
<n
;i
++,x
++) {
2006 ptr
[i
] = DITHER_HPCR( x
, y
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2013 * Write a span of PF_LOOKUP pixels to an XImage.
2015 static void put_row_LOOKUP_ximage( PUT_ROW_ARGS
)
2017 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2019 XMesaImage
*img
= xrb
->ximage
;
2024 for (i
=0;i
<n
;i
++,x
++) {
2026 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2031 /* draw all pixels */
2032 for (i
=0;i
<n
;i
++,x
++) {
2033 XMesaPutPixel( img
, x
, y
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2040 * Write a span of PF_LOOKUP pixels to an XImage (no alpha).
2042 static void put_row_rgb_LOOKUP_ximage( RGB_SPAN_ARGS
)
2044 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2046 XMesaImage
*img
= xrb
->ximage
;
2051 for (i
=0;i
<n
;i
++,x
++) {
2053 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2058 /* draw all pixels */
2059 for (i
=0;i
<n
;i
++,x
++) {
2060 XMesaPutPixel( img
, x
, y
, LOOKUP( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2067 * Write a span of 8-bit PF_LOOKUP pixels to an XImage.
2069 static void put_row_LOOKUP8_ximage( PUT_ROW_ARGS
)
2071 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2074 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2077 for (i
=0;i
<n
;i
++,x
++) {
2079 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2084 /* draw all pixels */
2085 for (i
=0;i
<n
;i
++,x
++) {
2086 ptr
[i
] = (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2092 static void put_row_rgb_LOOKUP8_ximage( RGB_SPAN_ARGS
)
2094 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2097 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2100 for (i
=0;i
<n
;i
++,x
++) {
2102 ptr
[i
] = (GLubyte
) LOOKUP( rgb
[i
][0], rgb
[i
][1], rgb
[i
][2] );
2107 /* draw all pixels */
2108 const GLubyte
*data
= (GLubyte
*) rgb
;
2109 for (i
=0;i
<n
;i
++,x
++) {
2110 /*ptr[i] = LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );*/
2111 ptr
[i
] = (GLubyte
) LOOKUP( data
[i
+i
+i
], data
[i
+i
+i
+1], data
[i
+i
+i
+2] );
2118 * Write a span of PF_GRAYSCALE pixels to an XImage.
2120 static void put_row_GRAYSCALE_ximage( PUT_ROW_ARGS
)
2122 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2124 XMesaImage
*img
= xrb
->ximage
;
2128 for (i
=0;i
<n
;i
++,x
++) {
2130 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2135 /* draw all pixels */
2136 for (i
=0;i
<n
;i
++,x
++) {
2137 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2144 * Write a span of PF_GRAYSCALE pixels to an XImage (no alpha).
2146 static void put_row_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS
)
2148 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2150 XMesaImage
*img
= xrb
->ximage
;
2154 for (i
=0;i
<n
;i
++,x
++) {
2156 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2161 /* draw all pixels */
2162 for (i
=0;i
<n
;i
++,x
++) {
2163 XMesaPutPixel( img
, x
, y
, GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] ) );
2170 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage.
2172 static void put_row_GRAYSCALE8_ximage( PUT_ROW_ARGS
)
2174 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2177 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2181 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2186 /* draw all pixels */
2188 ptr
[i
] = (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2195 * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage (no alpha).
2197 static void put_row_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS
)
2199 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
2202 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
2206 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2211 /* draw all pixels */
2213 ptr
[i
] = (GLubyte
) GRAY_RGB( rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
] );
2221 /**********************************************************************/
2222 /*** Write COLOR PIXEL functions ***/
2223 /**********************************************************************/
2226 #define PUT_VALUES_ARGS \
2227 GLcontext *ctx, struct gl_renderbuffer *rb, \
2228 GLuint n, const GLint x[], const GLint y[], \
2229 const void *values, const GLubyte mask[]
2233 * Write an array of PF_TRUECOLOR pixels to a pixmap.
2235 static void put_values_TRUECOLOR_pixmap( PUT_VALUES_ARGS
)
2237 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2238 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2240 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2241 XMesaDrawable buffer
= xrb
->drawable
;
2242 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2247 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2248 XMesaSetForeground( dpy
, gc
, p
);
2249 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2256 * Write an array of PF_TRUEDITHER pixels to a pixmap.
2258 static void put_values_TRUEDITHER_pixmap( PUT_VALUES_ARGS
)
2260 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2261 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2263 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2264 XMesaDrawable buffer
= xrb
->drawable
;
2265 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2270 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2271 XMesaSetForeground( dpy
, gc
, p
);
2272 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2279 * Write an array of PF_8A8B8G8R pixels to a pixmap.
2281 static void put_values_8A8B8G8R_pixmap( PUT_VALUES_ARGS
)
2283 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2284 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2286 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2287 XMesaDrawable buffer
= xrb
->drawable
;
2288 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2292 XMesaSetForeground( dpy
, gc
,
2293 PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] ));
2294 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2300 * Write an array of PF_8A8R8G8B pixels to a pixmap.
2302 static void put_values_8A8R8G8B_pixmap( PUT_VALUES_ARGS
)
2304 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2305 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2307 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2308 XMesaDrawable buffer
= xrb
->drawable
;
2309 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2313 XMesaSetForeground( dpy
, gc
,
2314 PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] ));
2315 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2321 * Write an array of PF_8R8G8B pixels to a pixmap.
2323 static void put_values_8R8G8B_pixmap( PUT_VALUES_ARGS
)
2325 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2326 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2328 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2329 XMesaDrawable buffer
= xrb
->drawable
;
2330 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2334 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2335 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2342 * Write an array of PF_8R8G8B24 pixels to a pixmap.
2344 static void put_values_8R8G8B24_pixmap( PUT_VALUES_ARGS
)
2346 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2347 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2349 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2350 XMesaDrawable buffer
= xrb
->drawable
;
2351 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2355 XMesaSetForeground( dpy
, gc
, PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2356 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2363 * Write an array of PF_5R6G5B pixels to a pixmap.
2365 static void put_values_5R6G5B_pixmap( PUT_VALUES_ARGS
)
2367 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2368 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2370 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2371 XMesaDrawable buffer
= xrb
->drawable
;
2372 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2376 XMesaSetForeground( dpy
, gc
, PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2377 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2384 * Write an array of PF_DITHER_5R6G5B pixels to a pixmap.
2386 static void put_values_DITHER_5R6G5B_pixmap( PUT_VALUES_ARGS
)
2388 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2389 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2391 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2392 XMesaDrawable buffer
= xrb
->drawable
;
2393 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2398 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2399 XMesaSetForeground( dpy
, gc
, p
);
2400 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2407 * Write an array of PF_DITHER pixels to a pixmap.
2409 static void put_values_DITHER_pixmap( PUT_VALUES_ARGS
)
2411 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2412 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2414 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2415 XMesaDrawable buffer
= xrb
->drawable
;
2416 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2421 XMesaSetForeground( dpy
, gc
,
2422 DITHER(x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2423 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2430 * Write an array of PF_1BIT pixels to a pixmap.
2432 static void put_values_1BIT_pixmap( PUT_VALUES_ARGS
)
2434 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2435 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2437 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2438 XMesaDrawable buffer
= xrb
->drawable
;
2439 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2444 XMesaSetForeground( dpy
, gc
,
2445 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2446 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2453 * Write an array of PF_HPCR pixels to a pixmap.
2455 static void put_values_HPCR_pixmap( PUT_VALUES_ARGS
)
2457 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2458 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2460 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2461 XMesaDrawable buffer
= xrb
->drawable
;
2462 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2466 XMesaSetForeground( dpy
, gc
,
2467 DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2468 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2475 * Write an array of PF_LOOKUP pixels to a pixmap.
2477 static void put_values_LOOKUP_pixmap( PUT_VALUES_ARGS
)
2479 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2480 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2482 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2483 XMesaDrawable buffer
= xrb
->drawable
;
2484 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2489 XMesaSetForeground( dpy
, gc
, LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2490 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2497 * Write an array of PF_GRAYSCALE pixels to a pixmap.
2499 static void put_values_GRAYSCALE_pixmap( PUT_VALUES_ARGS
)
2501 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2502 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2504 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2505 XMesaDrawable buffer
= xrb
->drawable
;
2506 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2510 XMesaSetForeground( dpy
, gc
, GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2511 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
2518 * Write an array of PF_TRUECOLOR pixels to an ximage.
2520 static void put_values_TRUECOLOR_ximage( PUT_VALUES_ARGS
)
2522 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2523 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2525 XMesaImage
*img
= xrb
->ximage
;
2530 PACK_TRUECOLOR( p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2531 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), p
);
2538 * Write an array of PF_TRUEDITHER pixels to an XImage.
2540 static void put_values_TRUEDITHER_ximage( PUT_VALUES_ARGS
)
2542 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2543 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2545 XMesaImage
*img
= xrb
->ximage
;
2550 PACK_TRUEDITHER(p
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
2551 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), p
);
2558 * Write an array of PF_8A8B8G8R pixels to an ximage.
2560 static void put_values_8A8B8G8R_ximage( PUT_VALUES_ARGS
)
2562 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2567 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
2568 *ptr
= PACK_8A8B8G8R( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
2574 * Write an array of PF_8A8R8G8B pixels to an ximage.
2576 static void put_values_8A8R8G8B_ximage( PUT_VALUES_ARGS
)
2578 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2583 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
2584 *ptr
= PACK_8A8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
], rgba
[i
][ACOMP
] );
2591 * Write an array of PF_8R8G8B pixels to an ximage.
2593 static void put_values_8R8G8B_ximage( PUT_VALUES_ARGS
)
2595 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2600 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
2601 *ptr
= PACK_8R8G8B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2608 * Write an array of PF_8R8G8B24 pixels to an ximage.
2610 static void put_values_8R8G8B24_ximage( PUT_VALUES_ARGS
)
2612 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2617 bgr_t
*ptr
= PIXEL_ADDR3(xrb
, x
[i
], y
[i
] );
2618 ptr
->r
= rgba
[i
][RCOMP
];
2619 ptr
->g
= rgba
[i
][GCOMP
];
2620 ptr
->b
= rgba
[i
][BCOMP
];
2627 * Write an array of PF_5R6G5B pixels to an ximage.
2629 static void put_values_5R6G5B_ximage( PUT_VALUES_ARGS
)
2631 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2636 GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
[i
], y
[i
] );
2637 *ptr
= PACK_5R6G5B( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2644 * Write an array of PF_DITHER_5R6G5B pixels to an ximage.
2646 static void put_values_DITHER_5R6G5B_ximage( PUT_VALUES_ARGS
)
2648 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2650 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2654 GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
[i
], y
[i
] );
2655 PACK_TRUEDITHER( *ptr
, x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2662 * Write an array of PF_DITHER pixels to an XImage.
2664 static void put_values_DITHER_ximage( PUT_VALUES_ARGS
)
2666 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2668 XMesaImage
*img
= xrb
->ximage
;
2673 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
2674 DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2681 * Write an array of 8-bit PF_DITHER pixels to an XImage.
2683 static void put_values_DITHER8_ximage( PUT_VALUES_ARGS
)
2685 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2691 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
2692 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2699 * Write an array of PF_1BIT pixels to an XImage.
2701 static void put_values_1BIT_ximage( PUT_VALUES_ARGS
)
2703 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2704 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2706 XMesaImage
*img
= xrb
->ximage
;
2711 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
2712 DITHER_1BIT( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ));
2719 * Write an array of PF_HPCR pixels to an XImage.
2721 static void put_values_HPCR_ximage( PUT_VALUES_ARGS
)
2723 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2725 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2729 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
2730 *ptr
= (GLubyte
) DITHER_HPCR( x
[i
], y
[i
], rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2737 * Write an array of PF_LOOKUP pixels to an XImage.
2739 static void put_values_LOOKUP_ximage( PUT_VALUES_ARGS
)
2741 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2743 XMesaImage
*img
= xrb
->ximage
;
2748 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), LOOKUP(rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]) );
2755 * Write an array of 8-bit PF_LOOKUP pixels to an XImage.
2757 static void put_values_LOOKUP8_ximage( PUT_VALUES_ARGS
)
2759 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2765 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
2766 *ptr
= (GLubyte
) LOOKUP( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2773 * Write an array of PF_GRAYSCALE pixels to an XImage.
2775 static void put_values_GRAYSCALE_ximage( PUT_VALUES_ARGS
)
2777 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2779 XMesaImage
*img
= xrb
->ximage
;
2783 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
2784 GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] ) );
2791 * Write an array of 8-bit PF_GRAYSCALE pixels to an XImage.
2793 static void put_values_GRAYSCALE8_ximage( PUT_VALUES_ARGS
)
2795 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
2800 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
] );
2801 *ptr
= (GLubyte
) GRAY_RGB( rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
] );
2809 /**********************************************************************/
2810 /*** Write MONO COLOR SPAN functions ***/
2811 /**********************************************************************/
2813 #define PUT_MONO_ROW_ARGS \
2814 GLcontext *ctx, struct gl_renderbuffer *rb, \
2815 GLuint n, GLint x, GLint y, const void *value, \
2816 const GLubyte mask[]
2821 * Write a span of identical pixels to a pixmap.
2823 static void put_mono_row_pixmap( PUT_MONO_ROW_ARGS
)
2825 const GLubyte
*color
= (const GLubyte
*) value
;
2827 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2828 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2829 XMesaDrawable buffer
= xrb
->drawable
;
2830 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2831 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
2832 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2834 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
2837 /* New code contributed by Jeff Epler and cleaned up by Keith
2840 for (i
= 0; i
< n
; ) {
2843 /* Identify and emit contiguous rendered pixels
2845 while (i
< n
&& (!mask
|| mask
[i
]))
2849 XMesaFillRectangle( dpy
, buffer
, gc
,
2850 (int)(x
+start
), (int) y
,
2853 /* Eat up non-rendered pixels
2855 while (i
< n
&& !mask
[i
])
2863 put_mono_row_ci_pixmap( PUT_MONO_ROW_ARGS
)
2865 GLuint colorIndex
= *((GLuint
*) value
);
2866 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2868 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2869 XMesaDrawable buffer
= xrb
->drawable
;
2870 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2872 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
2875 for (i
= 0 ; i
< n
;) {
2878 /* Identify and emit contiguous rendered pixels
2880 while (i
< n
&& (!mask
|| mask
[i
]))
2884 XMesaFillRectangle( dpy
, buffer
, gc
,
2885 (int)(x
+start
), (int) y
,
2888 /* Eat up non-rendered pixels
2890 while (i
< n
&& !mask
[i
])
2898 * Write a span of PF_TRUEDITHER pixels to a pixmap.
2900 static void put_mono_row_TRUEDITHER_pixmap( PUT_MONO_ROW_ARGS
)
2902 const GLubyte
*color
= (const GLubyte
*) value
;
2904 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2905 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2906 XMesaDrawable buffer
= xrb
->drawable
;
2907 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2908 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2910 int yy
= YFLIP(xrb
, y
);
2911 for (i
=0;i
<n
;i
++,x
++) {
2912 if (!mask
|| mask
[i
]) {
2914 PACK_TRUEDITHER(p
, x
, yy
, r
, g
, b
);
2915 XMesaSetForeground( dpy
, gc
, p
);
2916 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2923 * Write a span of PF_DITHER pixels to a pixmap.
2925 static void put_mono_row_DITHER_pixmap( PUT_MONO_ROW_ARGS
)
2927 const GLubyte
*color
= (const GLubyte
*) value
;
2929 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2930 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2931 XMesaDrawable buffer
= xrb
->drawable
;
2932 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2933 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2935 int yy
= YFLIP(xrb
, y
);
2937 for (i
=0;i
<n
;i
++,x
++) {
2938 if (!mask
|| mask
[i
]) {
2939 XMesaSetForeground( dpy
, gc
, XDITHER( x
, r
, g
, b
) );
2940 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) yy
);
2947 * Write a span of PF_1BIT pixels to a pixmap.
2949 static void put_mono_row_1BIT_pixmap( PUT_MONO_ROW_ARGS
)
2951 const GLubyte
*color
= (const GLubyte
*) value
;
2953 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2954 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
2955 XMesaDrawable buffer
= xrb
->drawable
;
2956 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
2957 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
2961 for (i
=0;i
<n
;i
++,x
++) {
2962 if (!mask
|| mask
[i
]) {
2963 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
, y
, r
, g
, b
) );
2964 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
2971 * Write a span of identical pixels to an XImage.
2973 static void put_mono_row_ximage( PUT_MONO_ROW_ARGS
)
2975 const GLubyte
*color
= (const GLubyte
*) value
;
2977 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
2978 XMesaImage
*img
= xrb
->ximage
;
2980 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
2981 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
2983 for (i
=0;i
<n
;i
++,x
++) {
2984 if (!mask
|| mask
[i
]) {
2985 XMesaPutPixel( img
, x
, y
, pixel
);
2992 put_mono_row_ci_ximage( PUT_MONO_ROW_ARGS
)
2994 const GLuint colorIndex
= *((GLuint
*) value
);
2996 XMesaImage
*img
= xrb
->ximage
;
2999 for (i
=0;i
<n
;i
++,x
++) {
3000 if (!mask
|| mask
[i
]) {
3001 XMesaPutPixel( img
, x
, y
, colorIndex
);
3008 * Write a span of identical PF_TRUEDITHER pixels to an XImage.
3010 static void put_mono_row_TRUEDITHER_ximage( PUT_MONO_ROW_ARGS
)
3012 const GLubyte
*color
= (const GLubyte
*) value
;
3014 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3015 XMesaImage
*img
= xrb
->ximage
;
3016 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3020 if (!mask
|| mask
[i
]) {
3022 PACK_TRUEDITHER( p
, x
+i
, y
, r
, g
, b
);
3023 XMesaPutPixel( img
, x
+i
, y
, p
);
3030 * Write a span of identical 8A8B8G8R pixels to an XImage.
3032 static void put_mono_row_8A8B8G8R_ximage( PUT_MONO_ROW_ARGS
)
3034 const GLubyte
*color
= (const GLubyte
*) value
;
3036 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3038 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3039 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3040 ptr
= PIXEL_ADDR4(xrb
, x
, y
);
3042 if (!mask
|| mask
[i
]) {
3049 * Write a span of identical 8A8R8G8B pixels to an XImage.
3051 static void put_mono_row_8A8R8G8B_ximage( PUT_MONO_ROW_ARGS
)
3053 const GLubyte
*color
= (const GLubyte
*) value
;
3056 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3057 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3058 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3059 ptr
= PIXEL_ADDR4(xrb
, x
, y
);
3061 if (!mask
|| mask
[i
]) {
3069 * Write a span of identical 8R8G8B pixels to an XImage.
3071 static void put_mono_row_8R8G8B_ximage( PUT_MONO_ROW_ARGS
)
3073 const GLubyte
*color
= (const GLubyte
*) value
;
3075 const GLuint pixel
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3076 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
, y
);
3079 if (!mask
|| mask
[i
]) {
3087 * Write a span of identical 8R8G8B pixels to an XImage.
3089 static void put_mono_row_8R8G8B24_ximage( PUT_MONO_ROW_ARGS
)
3091 const GLubyte
*color
= (const GLubyte
*) value
;
3093 const GLubyte r
= color
[RCOMP
];
3094 const GLubyte g
= color
[GCOMP
];
3095 const GLubyte b
= color
[BCOMP
];
3097 bgr_t
*ptr
= PIXEL_ADDR3(xrb
, x
, y
);
3099 if (!mask
|| mask
[i
]) {
3109 * Write a span of identical DITHER pixels to an XImage.
3111 static void put_mono_row_DITHER_ximage( PUT_MONO_ROW_ARGS
)
3113 const GLubyte
*color
= (const GLubyte
*) value
;
3115 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3116 XMesaImage
*img
= xrb
->ximage
;
3117 int yy
= YFLIP(xrb
, y
);
3120 for (i
=0;i
<n
;i
++,x
++) {
3121 if (!mask
|| mask
[i
]) {
3122 XMesaPutPixel( img
, x
, yy
, XDITHER( x
, r
, g
, b
) );
3129 * Write a span of identical 8-bit DITHER pixels to an XImage.
3131 static void put_mono_row_DITHER8_ximage( PUT_MONO_ROW_ARGS
)
3133 const GLubyte
*color
= (const GLubyte
*) value
;
3135 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3136 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
3139 for (i
=0;i
<n
;i
++,x
++) {
3140 if (!mask
|| mask
[i
]) {
3141 ptr
[i
] = (GLubyte
) XDITHER( x
, r
, g
, b
);
3148 * Write a span of identical 8-bit LOOKUP pixels to an XImage.
3150 static void put_mono_row_LOOKUP8_ximage( PUT_MONO_ROW_ARGS
)
3152 const GLubyte
*color
= (const GLubyte
*) value
;
3155 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
3158 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3160 if (!mask
|| mask
[i
]) {
3168 * Write a span of identical PF_1BIT pixels to an XImage.
3170 static void put_mono_row_1BIT_ximage( PUT_MONO_ROW_ARGS
)
3172 const GLubyte
*color
= (const GLubyte
*) value
;
3173 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3175 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3176 XMesaImage
*img
= xrb
->ximage
;
3180 for (i
=0;i
<n
;i
++,x
++) {
3181 if (!mask
|| mask
[i
]) {
3182 XMesaPutPixel( img
, x
, y
, DITHER_1BIT( x
, y
, r
, g
, b
) );
3189 * Write a span of identical HPCR pixels to an XImage.
3191 static void put_mono_row_HPCR_ximage( PUT_MONO_ROW_ARGS
)
3193 const GLubyte
*color
= (const GLubyte
*) value
;
3195 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3196 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3197 register GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
, y
);
3199 for (i
=0;i
<n
;i
++,x
++) {
3200 if (!mask
|| mask
[i
]) {
3201 ptr
[i
] = DITHER_HPCR( x
, y
, r
, g
, b
);
3208 * Write a span of identical 8-bit GRAYSCALE pixels to an XImage.
3210 static void put_mono_row_GRAYSCALE8_ximage( PUT_MONO_ROW_ARGS
)
3212 const GLubyte
*color
= (const GLubyte
*) value
;
3214 const GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3215 GLubyte
*ptr
= (GLubyte
*) PIXEL_ADDR1(xrb
, x
, y
);
3218 if (!mask
|| mask
[i
]) {
3227 * Write a span of identical PF_DITHER_5R6G5B pixels to an XImage.
3229 static void put_mono_row_DITHER_5R6G5B_ximage( PUT_MONO_ROW_ARGS
)
3231 const GLubyte
*color
= (const GLubyte
*) value
;
3233 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3234 register GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
, y
);
3235 const GLint r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3239 if (!mask
|| mask
[i
]) {
3240 PACK_TRUEDITHER(ptr
[i
], x
+i
, y
, r
, g
, b
);
3247 /**********************************************************************/
3248 /*** Write MONO COLOR PIXELS functions ***/
3249 /**********************************************************************/
3251 #define PUT_MONO_VALUES_ARGS \
3252 GLcontext *ctx, struct gl_renderbuffer *rb, \
3253 GLuint n, const GLint x[], const GLint y[], \
3254 const void *value, const GLubyte mask[]
3259 * Write an array of identical pixels to a pixmap.
3261 static void put_mono_values_pixmap( PUT_MONO_VALUES_ARGS
)
3263 const GLubyte
*color
= (const GLubyte
*) value
;
3264 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3266 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3267 XMesaDrawable buffer
= xrb
->drawable
;
3268 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3270 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3271 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3272 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
3275 XMesaDrawPoint( dpy
, buffer
, gc
,
3276 (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3283 put_mono_values_ci_pixmap( PUT_MONO_VALUES_ARGS
)
3285 const GLuint colorIndex
= *((GLuint
*) value
);
3286 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3288 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3289 XMesaDrawable buffer
= xrb
->drawable
;
3290 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3292 XMesaSetForeground( xmesa
->display
, gc
, colorIndex
);
3295 XMesaDrawPoint( dpy
, buffer
, gc
,
3296 (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3303 * Write an array of PF_TRUEDITHER pixels to a pixmap.
3305 static void put_mono_values_TRUEDITHER_pixmap( PUT_MONO_VALUES_ARGS
)
3307 const GLubyte
*color
= (const GLubyte
*) value
;
3308 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3310 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3311 XMesaDrawable buffer
= xrb
->drawable
;
3312 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3314 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3318 PACK_TRUEDITHER(p
, x
[i
], y
[i
], r
, g
, b
);
3319 XMesaSetForeground( dpy
, gc
, p
);
3320 XMesaDrawPoint( dpy
, buffer
, gc
,
3321 (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3328 * Write an array of PF_DITHER pixels to a pixmap.
3330 static void put_mono_values_DITHER_pixmap( PUT_MONO_VALUES_ARGS
)
3332 const GLubyte
*color
= (const GLubyte
*) value
;
3333 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3335 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3336 XMesaDrawable buffer
= xrb
->drawable
;
3337 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3339 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3343 XMesaSetForeground( dpy
, gc
, DITHER( x
[i
], y
[i
], r
, g
, b
) );
3344 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3351 * Write an array of PF_1BIT pixels to a pixmap.
3353 static void put_mono_values_1BIT_pixmap( PUT_MONO_VALUES_ARGS
)
3355 const GLubyte
*color
= (const GLubyte
*) value
;
3356 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3358 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3359 XMesaDrawable buffer
= xrb
->drawable
;
3360 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3362 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3366 XMesaSetForeground( dpy
, gc
, DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
) );
3367 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3374 * Write an array of identical pixels to an XImage.
3376 static void put_mono_values_ximage( PUT_MONO_VALUES_ARGS
)
3378 const GLubyte
*color
= (const GLubyte
*) value
;
3379 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3381 XMesaImage
*img
= xrb
->ximage
;
3383 const unsigned long pixel
= xmesa_color_to_pixel(ctx
, color
[RCOMP
],
3384 color
[GCOMP
], color
[BCOMP
], color
[ACOMP
], xmesa
->pixelformat
);
3387 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), pixel
);
3394 put_mono_values_ci_ximage( PUT_MONO_VALUES_ARGS
)
3396 const GLuint colorIndex
= *((GLuint
*) value
);
3398 XMesaImage
*img
= xrb
->ximage
;
3402 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), colorIndex
);
3409 * Write an array of identical TRUEDITHER pixels to an XImage.
3411 static void put_mono_values_TRUEDITHER_ximage( PUT_MONO_VALUES_ARGS
)
3413 const GLubyte
*color
= (const GLubyte
*) value
;
3414 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3416 XMesaImage
*img
= xrb
->ximage
;
3418 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3422 PACK_TRUEDITHER(p
, x
[i
], YFLIP(xrb
, y
[i
]), r
, g
, b
);
3423 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), p
);
3431 * Write an array of identical 8A8B8G8R pixels to an XImage
3433 static void put_mono_values_8A8B8G8R_ximage( PUT_MONO_VALUES_ARGS
)
3435 const GLubyte
*color
= (const GLubyte
*) value
;
3437 const GLuint p
= PACK_8A8B8G8R(color
[RCOMP
], color
[GCOMP
],
3438 color
[BCOMP
], color
[ACOMP
]);
3442 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
3449 * Write an array of identical 8A8R8G8B pixels to an XImage
3451 static void put_mono_values_8A8R8G8B_ximage( PUT_MONO_VALUES_ARGS
)
3453 const GLubyte
*color
= (const GLubyte
*) value
;
3455 const GLuint p
= PACK_8A8R8G8B(color
[RCOMP
], color
[GCOMP
],
3456 color
[BCOMP
], color
[ACOMP
]);
3460 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
3467 * Write an array of identical 8R8G8B pixels to an XImage.
3469 static void put_mono_values_8R8G8B_ximage( PUT_MONO_VALUES_ARGS
)
3471 const GLubyte
*color
= (const GLubyte
*) value
;
3474 const GLuint p
= PACK_8R8G8B(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3477 GLuint
*ptr
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
] );
3485 * Write an array of identical 8R8G8B pixels to an XImage.
3487 static void put_mono_values_8R8G8B24_ximage( PUT_MONO_VALUES_ARGS
)
3489 const GLubyte
*color
= (const GLubyte
*) value
;
3491 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3495 bgr_t
*ptr
= PIXEL_ADDR3(xrb
, x
[i
], y
[i
] );
3505 * Write an array of identical PF_DITHER pixels to an XImage.
3507 static void put_mono_values_DITHER_ximage( PUT_MONO_VALUES_ARGS
)
3509 const GLubyte
*color
= (const GLubyte
*) value
;
3511 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3512 XMesaImage
*img
= xrb
->ximage
;
3517 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]), DITHER( x
[i
], y
[i
], r
, g
, b
) );
3524 * Write an array of identical 8-bit PF_DITHER pixels to an XImage.
3526 static void put_mono_values_DITHER8_ximage( PUT_MONO_VALUES_ARGS
)
3528 const GLubyte
*color
= (const GLubyte
*) value
;
3530 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3535 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3536 *ptr
= (GLubyte
) DITHER( x
[i
], y
[i
], r
, g
, b
);
3543 * Write an array of identical 8-bit PF_LOOKUP pixels to an XImage.
3545 static void put_mono_values_LOOKUP8_ximage( PUT_MONO_VALUES_ARGS
)
3547 const GLubyte
*color
= (const GLubyte
*) value
;
3552 pixel
= LOOKUP(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3555 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3564 * Write an array of identical PF_1BIT pixels to an XImage.
3566 static void put_mono_values_1BIT_ximage( PUT_MONO_VALUES_ARGS
)
3568 const GLubyte
*color
= (const GLubyte
*) value
;
3569 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3571 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3572 XMesaImage
*img
= xrb
->ximage
;
3577 XMesaPutPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]),
3578 DITHER_1BIT( x
[i
], y
[i
], r
, g
, b
));
3585 * Write an array of identical PF_HPCR pixels to an XImage.
3587 static void put_mono_values_HPCR_ximage( PUT_MONO_VALUES_ARGS
)
3589 const GLubyte
*color
= (const GLubyte
*) value
;
3591 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3592 const GLubyte r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3596 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3597 *ptr
= DITHER_HPCR( x
[i
], y
[i
], r
, g
, b
);
3604 * Write an array of identical 8-bit PF_GRAYSCALE pixels to an XImage.
3606 static void put_mono_values_GRAYSCALE8_ximage( PUT_MONO_VALUES_ARGS
)
3608 const GLubyte
*color
= (const GLubyte
*) value
;
3611 register GLubyte p
= GRAY_RGB(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
3614 GLubyte
*ptr
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
3622 * Write an array of identical PF_DITHER_5R6G5B pixels to an XImage.
3624 static void put_mono_values_DITHER_5R6G5B_ximage( PUT_MONO_VALUES_ARGS
)
3626 const GLubyte
*color
= (const GLubyte
*) value
;
3628 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3629 const int r
= color
[RCOMP
], g
= color
[GCOMP
], b
= color
[BCOMP
];
3633 GLushort
*ptr
= PIXEL_ADDR2(xrb
, x
[i
], y
[i
] );
3634 PACK_TRUEDITHER(*ptr
, x
[i
], y
[i
], r
, g
, b
);
3641 /**********************************************************************/
3642 /*** Write INDEX SPAN functions ***/
3643 /**********************************************************************/
3646 * Write a span of CI pixels to a Pixmap.
3648 static void put_row_ci_pixmap( PUT_ROW_ARGS
)
3650 const GLuint
*index
= (GLuint
*) values
;
3651 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3653 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3654 XMesaDrawable buffer
= xrb
->drawable
;
3655 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3659 for (i
=0;i
<n
;i
++,x
++) {
3661 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3662 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3667 for (i
=0;i
<n
;i
++,x
++) {
3668 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3669 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
, (int) y
);
3676 * Write a span of CI pixels to an XImage.
3678 static void put_row_ci_ximage( PUT_ROW_ARGS
)
3680 const GLuint
*index
= (const GLuint
*) values
;
3682 XMesaImage
*img
= xrb
->ximage
;
3686 for (i
=0;i
<n
;i
++,x
++) {
3688 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3693 for (i
=0;i
<n
;i
++,x
++) {
3694 XMesaPutPixel( img
, x
, y
, (unsigned long) index
[i
] );
3700 /**********************************************************************/
3701 /*** Write INDEX PIXELS functions ***/
3702 /**********************************************************************/
3705 * Write an array of CI pixels to a Pixmap.
3707 static void put_values_ci_pixmap( PUT_VALUES_ARGS
)
3709 const GLuint
*index
= (const GLuint
*) values
;
3710 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3712 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
3713 XMesaDrawable buffer
= xrb
->drawable
;
3714 XMesaGC gc
= XMESA_BUFFER(ctx
->DrawBuffer
)->gc
;
3718 XMesaSetForeground( dpy
, gc
, (unsigned long) index
[i
] );
3719 XMesaDrawPoint( dpy
, buffer
, gc
, (int) x
[i
], (int) YFLIP(xrb
, y
[i
]) );
3726 * Write an array of CI pixels to an XImage.
3728 static void put_values_ci_ximage( PUT_VALUES_ARGS
)
3730 const GLuint
*index
= (const GLuint
*) values
;
3732 XMesaImage
*img
= xrb
->ximage
;
3736 XMesaPutPixel(img
, x
[i
], YFLIP(xrb
, y
[i
]), (unsigned long) index
[i
]);
3744 /**********************************************************************/
3745 /***** Pixel reading *****/
3746 /**********************************************************************/
3748 #ifndef XFree86Server
3750 * Do clip testing prior to calling XGetImage. If any of the region lies
3751 * outside the screen's bounds, XGetImage will return NULL.
3752 * We use XTranslateCoordinates() to check if that's the case and
3753 * adjust the x, y and length parameters accordingly.
3754 * \return -1 if span is totally clipped away,
3755 * else return number of pixels to skip in the destination array.
3758 clip_for_xgetimage(GLcontext
*ctx
, GLuint
*n
, GLint
*x
, GLint
*y
)
3760 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3761 XMesaBuffer source
= XMESA_BUFFER(ctx
->DrawBuffer
);
3762 Window rootWin
= RootWindow(xmesa
->display
, 0);
3764 GLint screenWidth
= WidthOfScreen(DefaultScreenOfDisplay(xmesa
->display
));
3766 if (source
->type
== PBUFFER
|| source
->type
== PIXMAP
)
3768 XTranslateCoordinates(xmesa
->display
, source
->frontxrb
->pixmap
, rootWin
,
3769 *x
, *y
, &dx
, &dy
, &child
);
3770 if (dx
>= screenWidth
) {
3771 /* totally clipped on right */
3775 /* clipped on left */
3777 if (clip
>= (GLint
) *n
)
3778 return -1; /* totally clipped on left */
3784 if ((GLint
) (dx
+ *n
) > screenWidth
) {
3785 /* clipped on right */
3786 GLint clip
= dx
+ *n
- screenWidth
;
3795 * Read a horizontal span of color-index pixels.
3798 get_row_ci(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
3799 GLuint n
, GLint x
, GLint y
, void *values
)
3801 GLuint
*index
= (GLuint
*) values
;
3802 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3809 #ifndef XFree86Server
3810 XMesaImage
*span
= NULL
;
3812 int k
= clip_for_xgetimage(ctx
, &n
, &x
, &y
);
3817 catch_xgetimage_errors( xmesa
->display
);
3818 span
= XGetImage( xmesa
->display
, xrb
->pixmap
,
3819 x
, y
, n
, 1, AllPlanes
, ZPixmap
);
3820 error
= check_xgetimage_errors();
3821 if (span
&& !error
) {
3823 index
[i
] = (GLuint
) XMesaGetPixel( span
, i
, 0 );
3827 /* return 0 pixels */
3833 XMesaDestroyImage( span
);
3836 (*xmesa
->display
->GetImage
)(xrb
->drawable
,
3837 x
, y
, n
, 1, ZPixmap
,
3838 ~0L, (pointer
)index
);
3841 else if (xrb
->ximage
) {
3842 XMesaImage
*img
= xrb
->ximage
;
3843 for (i
=0;i
<n
;i
++,x
++) {
3844 index
[i
] = (GLuint
) XMesaGetPixel( img
, x
, y
);
3852 * Read a horizontal span of color pixels.
3855 get_row_rgba(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
3856 GLuint n
, GLint x
, GLint y
, void *values
)
3858 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
3859 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
3861 XMesaBuffer source
= XMESA_BUFFER(ctx
->DrawBuffer
);
3864 /* Read from Pixmap or Window */
3865 XMesaImage
*span
= NULL
;
3867 #ifdef XFree86Server
3868 span
= XMesaCreateImage(xmesa
->xm_visual
->BitsPerPixel
, n
, 1, NULL
);
3869 span
->data
= (char *)MALLOC(span
->height
* span
->bytes_per_line
);
3870 error
= (!span
->data
);
3871 (*xmesa
->display
->GetImage
)(xrb
->drawable
,
3872 x
, YFLIP(xrb
, y
), n
, 1, ZPixmap
,
3873 ~0L, (pointer
)span
->data
);
3877 k
= clip_for_xgetimage(ctx
, &n
, &x
, &y
);
3881 catch_xgetimage_errors( xmesa
->display
);
3882 span
= XGetImage( xmesa
->display
, xrb
->pixmap
,
3883 x
, y
, n
, 1, AllPlanes
, ZPixmap
);
3884 error
= check_xgetimage_errors();
3886 if (span
&& !error
) {
3887 switch (xmesa
->pixelformat
) {
3889 case PF_Dither_True
:
3891 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3892 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3893 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3894 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
3895 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
3896 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
3897 GLint rShift
= xmesa
->xm_visual
->rshift
;
3898 GLint gShift
= xmesa
->xm_visual
->gshift
;
3899 GLint bShift
= xmesa
->xm_visual
->bshift
;
3903 p
= XMesaGetPixel( span
, i
, 0 );
3904 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
3905 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
3906 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
3907 rgba
[i
][ACOMP
] = 255;
3912 case PF_Dither_5R6G5B
:
3914 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
3915 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
3916 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
3919 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
3920 /* fast, but not quite accurate
3921 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
3922 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
3923 rgba[i][BCOMP] = ((p << 3) & 0xff);
3925 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
3926 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
3927 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
3928 rgba
[i
][ACOMP
] = 255;
3934 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3937 GLuint p4
= *ptr4
++;
3938 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
3939 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3940 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3941 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
3947 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3950 GLuint p4
= *ptr4
++;
3951 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3952 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3953 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3954 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
3960 const GLuint
*ptr4
= (GLuint
*) span
->data
;
3963 GLuint p4
= *ptr4
++;
3964 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
3965 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
3966 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
3967 rgba
[i
][ACOMP
] = 255;
3973 const bgr_t
*ptr3
= (bgr_t
*) span
->data
;
3976 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
3977 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
3978 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
3979 rgba
[i
][ACOMP
] = 255;
3985 GLubyte
*ptr1
= (GLubyte
*) span
->data
;
3988 GLubyte p
= *ptr1
++;
3989 rgba
[i
][RCOMP
] = p
& 0xE0;
3990 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
3991 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
3992 rgba
[i
][ACOMP
] = 255;
4000 GLubyte
*rTable
= source
->pixel_to_r
;
4001 GLubyte
*gTable
= source
->pixel_to_g
;
4002 GLubyte
*bTable
= source
->pixel_to_b
;
4003 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
4004 const GLubyte
*ptr1
= (GLubyte
*) span
->data
;
4007 unsigned long p
= *ptr1
++;
4008 rgba
[i
][RCOMP
] = rTable
[p
];
4009 rgba
[i
][GCOMP
] = gTable
[p
];
4010 rgba
[i
][BCOMP
] = bTable
[p
];
4011 rgba
[i
][ACOMP
] = 255;
4017 unsigned long p
= XMesaGetPixel( span
, i
, 0 );
4018 rgba
[i
][RCOMP
] = rTable
[p
];
4019 rgba
[i
][GCOMP
] = gTable
[p
];
4020 rgba
[i
][BCOMP
] = bTable
[p
];
4021 rgba
[i
][ACOMP
] = 255;
4028 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4032 p
= XMesaGetPixel( span
, i
, 0 ) ^ bitFlip
;
4033 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4034 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4035 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4036 rgba
[i
][ACOMP
] = 255;
4041 _mesa_problem(NULL
,"Problem in DD.read_color_span (1)");
4046 /* return black pixels */
4049 rgba
[i
][RCOMP
] = rgba
[i
][GCOMP
] = rgba
[i
][BCOMP
] = rgba
[i
][ACOMP
] = 0;
4053 XMesaDestroyImage( span
);
4056 else if (xrb
->ximage
) {
4057 /* Read from XImage back buffer */
4058 switch (xmesa
->pixelformat
) {
4060 case PF_Dither_True
:
4062 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4063 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4064 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4065 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4066 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4067 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4068 GLint rShift
= xmesa
->xm_visual
->rshift
;
4069 GLint gShift
= xmesa
->xm_visual
->gshift
;
4070 GLint bShift
= xmesa
->xm_visual
->bshift
;
4071 XMesaImage
*img
= xrb
->ximage
;
4076 p
= XMesaGetPixel( img
, x
+i
, y
);
4077 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4078 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4079 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4080 rgba
[i
][ACOMP
] = 255;
4085 case PF_Dither_5R6G5B
:
4087 const GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4088 const GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4089 const GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4090 const GLushort
*ptr2
= PIXEL_ADDR2(xrb
, x
, y
);
4092 #if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
4093 const GLuint
*ptr4
= (const GLuint
*) ptr2
;
4094 GLuint extraPixel
= (n
& 1);
4096 for (i
= 0; i
< n
; i
+= 2) {
4097 const GLuint p
= *ptr4
++;
4098 const GLuint p0
= p
& 0xffff;
4099 const GLuint p1
= p
>> 16;
4100 /* fast, but not quite accurate
4101 rgba[i][RCOMP] = ((p >> 8) & 0xf8);
4102 rgba[i][GCOMP] = ((p >> 3) & 0xfc);
4103 rgba[i][BCOMP] = ((p << 3) & 0xff);
4105 rgba
[i
][RCOMP
] = pixelToR
[p0
>> 11];
4106 rgba
[i
][GCOMP
] = pixelToG
[(p0
>> 5) & 0x3f];
4107 rgba
[i
][BCOMP
] = pixelToB
[p0
& 0x1f];
4108 rgba
[i
][ACOMP
] = 255;
4109 rgba
[i
+1][RCOMP
] = pixelToR
[p1
>> 11];
4110 rgba
[i
+1][GCOMP
] = pixelToG
[(p1
>> 5) & 0x3f];
4111 rgba
[i
+1][BCOMP
] = pixelToB
[p1
& 0x1f];
4112 rgba
[i
+1][ACOMP
] = 255;
4115 GLushort p
= ptr2
[n
];
4116 rgba
[n
][RCOMP
] = pixelToR
[p
>> 11];
4117 rgba
[n
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
4118 rgba
[n
][BCOMP
] = pixelToB
[p
& 0x1f];
4119 rgba
[n
][ACOMP
] = 255;
4122 for (i
= 0; i
< n
; i
++) {
4123 const GLushort p
= ptr2
[i
];
4124 rgba
[i
][RCOMP
] = pixelToR
[p
>> 11];
4125 rgba
[i
][GCOMP
] = pixelToG
[(p
>> 5) & 0x3f];
4126 rgba
[i
][BCOMP
] = pixelToB
[p
& 0x1f];
4127 rgba
[i
][ACOMP
] = 255;
4134 const GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
, y
);
4137 GLuint p4
= *ptr4
++;
4138 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
4139 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4140 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4141 rgba
[i
][ACOMP
] = (GLint
) ((p4
>> 24) & 0xff);
4147 const GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
, y
);
4150 GLuint p4
= *ptr4
++;
4151 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4152 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4153 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4154 rgba
[i
][ACOMP
] = (GLint
) ((p4
>> 24) & 0xff);
4160 const GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
, y
);
4163 GLuint p4
= *ptr4
++;
4164 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4165 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4166 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4167 rgba
[i
][ACOMP
] = 255;
4173 const bgr_t
*ptr3
= PIXEL_ADDR3(xrb
, x
, y
);
4176 rgba
[i
][RCOMP
] = ptr3
[i
].r
;
4177 rgba
[i
][GCOMP
] = ptr3
[i
].g
;
4178 rgba
[i
][BCOMP
] = ptr3
[i
].b
;
4179 rgba
[i
][ACOMP
] = 255;
4185 const GLubyte
*ptr1
= PIXEL_ADDR1(xrb
, x
, y
);
4188 GLubyte p
= *ptr1
++;
4189 rgba
[i
][RCOMP
] = p
& 0xE0;
4190 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4191 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4192 rgba
[i
][ACOMP
] = 255;
4200 const GLubyte
*rTable
= source
->pixel_to_r
;
4201 const GLubyte
*gTable
= source
->pixel_to_g
;
4202 const GLubyte
*bTable
= source
->pixel_to_b
;
4203 if (GET_VISUAL_DEPTH(xmesa
->xm_visual
)==8) {
4204 GLubyte
*ptr1
= PIXEL_ADDR1(xrb
, x
, y
);
4207 unsigned long p
= *ptr1
++;
4208 rgba
[i
][RCOMP
] = rTable
[p
];
4209 rgba
[i
][GCOMP
] = gTable
[p
];
4210 rgba
[i
][BCOMP
] = bTable
[p
];
4211 rgba
[i
][ACOMP
] = 255;
4215 XMesaImage
*img
= xrb
->ximage
;
4218 for (i
=0;i
<n
;i
++,x
++) {
4219 unsigned long p
= XMesaGetPixel( img
, x
, y
);
4220 rgba
[i
][RCOMP
] = rTable
[p
];
4221 rgba
[i
][GCOMP
] = gTable
[p
];
4222 rgba
[i
][BCOMP
] = bTable
[p
];
4223 rgba
[i
][ACOMP
] = 255;
4230 XMesaImage
*img
= xrb
->ximage
;
4231 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4234 for (i
=0;i
<n
;i
++,x
++) {
4236 p
= XMesaGetPixel( img
, x
, y
) ^ bitFlip
;
4237 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4238 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4239 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4240 rgba
[i
][ACOMP
] = 255;
4245 _mesa_problem(NULL
,"Problem in DD.read_color_span (2)");
4254 * Read an array of color index pixels.
4257 get_values_ci(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
4258 GLuint n
, const GLint x
[], const GLint y
[], void *values
)
4260 GLuint
*indx
= (GLuint
*) values
;
4261 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
4266 indx
[i
] = (GLuint
) read_pixel( xmesa
->display
, xrb
->drawable
,
4267 x
[i
], YFLIP(xrb
, y
[i
]) );
4270 else if (xrb
->ximage
) {
4271 XMesaImage
*img
= xrb
->ximage
;
4273 indx
[i
] = (GLuint
) XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) );
4281 get_values_rgba(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
4282 GLuint n
, const GLint x
[], const GLint y
[], void *values
)
4284 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
4286 const XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
4287 XMesaDisplay
*dpy
= xmesa
->xm_visual
->display
;
4288 XMesaBuffer source
= XMESA_BUFFER(ctx
->DrawBuffer
);
4292 XMesaDrawable buffer
= xrb
->drawable
;
4293 switch (xmesa
->pixelformat
) {
4295 case PF_Dither_True
:
4297 case PF_Dither_5R6G5B
:
4299 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4300 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4301 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4302 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4303 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4304 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4305 GLint rShift
= xmesa
->xm_visual
->rshift
;
4306 GLint gShift
= xmesa
->xm_visual
->gshift
;
4307 GLint bShift
= xmesa
->xm_visual
->bshift
;
4309 unsigned long p
= read_pixel( dpy
, buffer
,
4310 x
[i
], YFLIP(xrb
, y
[i
]) );
4311 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4312 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4313 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4314 rgba
[i
][ACOMP
] = 255;
4320 unsigned long p
= read_pixel( dpy
, buffer
,
4321 x
[i
], YFLIP(xrb
, y
[i
]) );
4322 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xff);
4323 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4324 rgba
[i
][BCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4325 rgba
[i
][ACOMP
] = (GLubyte
) ((p
>> 24) & 0xff);
4330 unsigned long p
= read_pixel( dpy
, buffer
,
4331 x
[i
], YFLIP(xrb
, y
[i
]) );
4332 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4333 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4334 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4335 rgba
[i
][ACOMP
] = (GLubyte
) ((p
>> 24) & 0xff);
4340 unsigned long p
= read_pixel( dpy
, buffer
,
4341 x
[i
], YFLIP(xrb
, y
[i
]) );
4342 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4343 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4344 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4345 rgba
[i
][ACOMP
] = 255;
4350 unsigned long p
= read_pixel( dpy
, buffer
,
4351 x
[i
], YFLIP(xrb
, y
[i
]) );
4352 rgba
[i
][RCOMP
] = (GLubyte
) ((p
>> 16) & 0xff);
4353 rgba
[i
][GCOMP
] = (GLubyte
) ((p
>> 8) & 0xff);
4354 rgba
[i
][BCOMP
] = (GLubyte
) ( p
& 0xff);
4355 rgba
[i
][ACOMP
] = 255;
4360 unsigned long p
= read_pixel( dpy
, buffer
,
4361 x
[i
], YFLIP(xrb
, y
[i
]) );
4362 rgba
[i
][RCOMP
] = (GLubyte
) ( p
& 0xE0 );
4363 rgba
[i
][GCOMP
] = (GLubyte
) ((p
& 0x1C) << 3);
4364 rgba
[i
][BCOMP
] = (GLubyte
) ((p
& 0x03) << 6);
4365 rgba
[i
][ACOMP
] = (GLubyte
) 255;
4372 GLubyte
*rTable
= source
->pixel_to_r
;
4373 GLubyte
*gTable
= source
->pixel_to_g
;
4374 GLubyte
*bTable
= source
->pixel_to_b
;
4376 unsigned long p
= read_pixel( dpy
, buffer
,
4377 x
[i
], YFLIP(xrb
, y
[i
]) );
4378 rgba
[i
][RCOMP
] = rTable
[p
];
4379 rgba
[i
][GCOMP
] = gTable
[p
];
4380 rgba
[i
][BCOMP
] = bTable
[p
];
4381 rgba
[i
][ACOMP
] = 255;
4387 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4389 unsigned long p
= read_pixel( dpy
, buffer
,
4390 x
[i
], YFLIP(xrb
, y
[i
])) ^ bitFlip
;
4391 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4392 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4393 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4394 rgba
[i
][ACOMP
] = 255;
4399 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4403 else if (xrb
->ximage
) {
4404 /* Read from XImage back buffer */
4405 switch (xmesa
->pixelformat
) {
4407 case PF_Dither_True
:
4409 case PF_Dither_5R6G5B
:
4411 unsigned long rMask
= GET_REDMASK(xmesa
->xm_visual
);
4412 unsigned long gMask
= GET_GREENMASK(xmesa
->xm_visual
);
4413 unsigned long bMask
= GET_BLUEMASK(xmesa
->xm_visual
);
4414 GLubyte
*pixelToR
= xmesa
->xm_visual
->PixelToR
;
4415 GLubyte
*pixelToG
= xmesa
->xm_visual
->PixelToG
;
4416 GLubyte
*pixelToB
= xmesa
->xm_visual
->PixelToB
;
4417 GLint rShift
= xmesa
->xm_visual
->rshift
;
4418 GLint gShift
= xmesa
->xm_visual
->gshift
;
4419 GLint bShift
= xmesa
->xm_visual
->bshift
;
4420 XMesaImage
*img
= xrb
->ximage
;
4423 p
= XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) );
4424 rgba
[i
][RCOMP
] = pixelToR
[(p
& rMask
) >> rShift
];
4425 rgba
[i
][GCOMP
] = pixelToG
[(p
& gMask
) >> gShift
];
4426 rgba
[i
][BCOMP
] = pixelToB
[(p
& bMask
) >> bShift
];
4427 rgba
[i
][ACOMP
] = 255;
4433 GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
4435 rgba
[i
][RCOMP
] = (GLubyte
) ( p4
& 0xff);
4436 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4437 rgba
[i
][BCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4438 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
4443 GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
4445 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4446 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4447 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4448 rgba
[i
][ACOMP
] = (GLubyte
) ((p4
>> 24) & 0xff);
4453 GLuint
*ptr4
= PIXEL_ADDR4(xrb
, x
[i
], y
[i
]);
4455 rgba
[i
][RCOMP
] = (GLubyte
) ((p4
>> 16) & 0xff);
4456 rgba
[i
][GCOMP
] = (GLubyte
) ((p4
>> 8) & 0xff);
4457 rgba
[i
][BCOMP
] = (GLubyte
) ( p4
& 0xff);
4458 rgba
[i
][ACOMP
] = 255;
4463 bgr_t
*ptr3
= PIXEL_ADDR3(xrb
, x
[i
], y
[i
]);
4464 rgba
[i
][RCOMP
] = ptr3
->r
;
4465 rgba
[i
][GCOMP
] = ptr3
->g
;
4466 rgba
[i
][BCOMP
] = ptr3
->b
;
4467 rgba
[i
][ACOMP
] = 255;
4472 GLubyte
*ptr1
= PIXEL_ADDR1(xrb
, x
[i
], y
[i
]);
4474 rgba
[i
][RCOMP
] = p
& 0xE0;
4475 rgba
[i
][GCOMP
] = (p
& 0x1C) << 3;
4476 rgba
[i
][BCOMP
] = (p
& 0x03) << 6;
4477 rgba
[i
][ACOMP
] = 255;
4484 GLubyte
*rTable
= source
->pixel_to_r
;
4485 GLubyte
*gTable
= source
->pixel_to_g
;
4486 GLubyte
*bTable
= source
->pixel_to_b
;
4487 XMesaImage
*img
= xrb
->ximage
;
4490 p
= XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) );
4491 rgba
[i
][RCOMP
] = rTable
[p
];
4492 rgba
[i
][GCOMP
] = gTable
[p
];
4493 rgba
[i
][BCOMP
] = bTable
[p
];
4494 rgba
[i
][ACOMP
] = 255;
4500 XMesaImage
*img
= xrb
->ximage
;
4501 int bitFlip
= xmesa
->xm_visual
->bitFlip
;
4504 p
= XMesaGetPixel( img
, x
[i
], YFLIP(xrb
, y
[i
]) ) ^ bitFlip
;
4505 rgba
[i
][RCOMP
] = (GLubyte
) (p
* 255);
4506 rgba
[i
][GCOMP
] = (GLubyte
) (p
* 255);
4507 rgba
[i
][BCOMP
] = (GLubyte
) (p
* 255);
4508 rgba
[i
][ACOMP
] = 255;
4513 _mesa_problem(NULL
,"Problem in DD.read_color_pixels (1)");
4521 * Initialize the renderbuffer's PutRow, GetRow, etc. functions.
4522 * This would generally only need to be called once when the renderbuffer
4523 * is created. However, we can change pixel formats on the fly if dithering
4524 * is enabled/disabled. Therefore, we may call this more often than that.
4527 xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer
*xrb
,
4528 enum pixel_format pixelformat
, GLint depth
)
4530 const GLboolean pixmap
= xrb
->pixmap
? GL_TRUE
: GL_FALSE
;
4532 switch (pixelformat
) {
4534 ASSERT(xrb
->Base
.DataType
== GL_UNSIGNED_INT
);
4536 xrb
->Base
.PutRow
= put_row_ci_pixmap
;
4537 xrb
->Base
.PutRowRGB
= NULL
;
4538 xrb
->Base
.PutMonoRow
= put_mono_row_ci_pixmap
;
4539 xrb
->Base
.PutValues
= put_values_ci_pixmap
;
4540 xrb
->Base
.PutMonoValues
= put_mono_values_ci_pixmap
;
4543 xrb
->Base
.PutRow
= put_row_ci_ximage
;
4544 xrb
->Base
.PutRowRGB
= NULL
;
4545 xrb
->Base
.PutMonoRow
= put_mono_row_ci_ximage
;
4546 xrb
->Base
.PutValues
= put_values_ci_ximage
;
4547 xrb
->Base
.PutMonoValues
= put_mono_values_ci_ximage
;
4552 xrb
->Base
.PutRow
= put_row_TRUECOLOR_pixmap
;
4553 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUECOLOR_pixmap
;
4554 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4555 xrb
->Base
.PutValues
= put_values_TRUECOLOR_pixmap
;
4556 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4559 xrb
->Base
.PutRow
= put_row_TRUECOLOR_ximage
;
4560 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUECOLOR_ximage
;
4561 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4562 xrb
->Base
.PutValues
= put_values_TRUECOLOR_ximage
;
4563 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4566 case PF_Dither_True
:
4568 xrb
->Base
.PutRow
= put_row_TRUEDITHER_pixmap
;
4569 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUEDITHER_pixmap
;
4570 xrb
->Base
.PutMonoRow
= put_mono_row_TRUEDITHER_pixmap
;
4571 xrb
->Base
.PutValues
= put_values_TRUEDITHER_pixmap
;
4572 xrb
->Base
.PutMonoValues
= put_mono_values_TRUEDITHER_pixmap
;
4575 xrb
->Base
.PutRow
= put_row_TRUEDITHER_ximage
;
4576 xrb
->Base
.PutRowRGB
= put_row_rgb_TRUEDITHER_ximage
;
4577 xrb
->Base
.PutMonoRow
= put_mono_row_TRUEDITHER_ximage
;
4578 xrb
->Base
.PutValues
= put_values_TRUEDITHER_ximage
;
4579 xrb
->Base
.PutMonoValues
= put_mono_values_TRUEDITHER_ximage
;
4584 xrb
->Base
.PutRow
= put_row_8A8B8G8R_pixmap
;
4585 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8B8G8R_pixmap
;
4586 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4587 xrb
->Base
.PutValues
= put_values_8A8B8G8R_pixmap
;
4588 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4591 xrb
->Base
.PutRow
= put_row_8A8B8G8R_ximage
;
4592 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8B8G8R_ximage
;
4593 xrb
->Base
.PutMonoRow
= put_mono_row_8A8B8G8R_ximage
;
4594 xrb
->Base
.PutValues
= put_values_8A8B8G8R_ximage
;
4595 xrb
->Base
.PutMonoValues
= put_mono_values_8A8B8G8R_ximage
;
4600 xrb
->Base
.PutRow
= put_row_8A8R8G8B_pixmap
;
4601 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8R8G8B_pixmap
;
4602 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4603 xrb
->Base
.PutValues
= put_values_8A8R8G8B_pixmap
;
4604 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4607 xrb
->Base
.PutRow
= put_row_8A8R8G8B_ximage
;
4608 xrb
->Base
.PutRowRGB
= put_row_rgb_8A8R8G8B_ximage
;
4609 xrb
->Base
.PutMonoRow
= put_mono_row_8A8R8G8B_ximage
;
4610 xrb
->Base
.PutValues
= put_values_8A8R8G8B_ximage
;
4611 xrb
->Base
.PutMonoValues
= put_mono_values_8A8R8G8B_ximage
;
4616 xrb
->Base
.PutRow
= put_row_8R8G8B_pixmap
;
4617 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B_pixmap
;
4618 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4619 xrb
->Base
.PutValues
= put_values_8R8G8B_pixmap
;
4620 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4623 xrb
->Base
.PutRow
= put_row_8R8G8B_ximage
;
4624 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B_ximage
;
4625 xrb
->Base
.PutMonoRow
= put_mono_row_8R8G8B_ximage
;
4626 xrb
->Base
.PutValues
= put_values_8R8G8B_ximage
;
4627 xrb
->Base
.PutMonoValues
= put_mono_values_8R8G8B_ximage
;
4632 xrb
->Base
.PutRow
= put_row_8R8G8B24_pixmap
;
4633 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B24_pixmap
;
4634 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4635 xrb
->Base
.PutValues
= put_values_8R8G8B24_pixmap
;
4636 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4639 xrb
->Base
.PutRow
= put_row_8R8G8B24_ximage
;
4640 xrb
->Base
.PutRowRGB
= put_row_rgb_8R8G8B24_ximage
;
4641 xrb
->Base
.PutMonoRow
= put_mono_row_8R8G8B24_ximage
;
4642 xrb
->Base
.PutValues
= put_values_8R8G8B24_ximage
;
4643 xrb
->Base
.PutMonoValues
= put_mono_values_8R8G8B24_ximage
;
4648 xrb
->Base
.PutRow
= put_row_5R6G5B_pixmap
;
4649 xrb
->Base
.PutRowRGB
= put_row_rgb_5R6G5B_pixmap
;
4650 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4651 xrb
->Base
.PutValues
= put_values_5R6G5B_pixmap
;
4652 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4655 xrb
->Base
.PutRow
= put_row_5R6G5B_ximage
;
4656 xrb
->Base
.PutRowRGB
= put_row_rgb_5R6G5B_ximage
;
4657 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4658 xrb
->Base
.PutValues
= put_values_5R6G5B_ximage
;
4659 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4662 case PF_Dither_5R6G5B
:
4664 xrb
->Base
.PutRow
= put_row_DITHER_5R6G5B_pixmap
;
4665 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_5R6G5B_pixmap
;
4666 xrb
->Base
.PutMonoRow
= put_mono_row_TRUEDITHER_pixmap
;
4667 xrb
->Base
.PutValues
= put_values_DITHER_5R6G5B_pixmap
;
4668 xrb
->Base
.PutMonoValues
= put_mono_values_TRUEDITHER_pixmap
;
4671 xrb
->Base
.PutRow
= put_row_DITHER_5R6G5B_ximage
;
4672 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_5R6G5B_ximage
;
4673 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER_5R6G5B_ximage
;
4674 xrb
->Base
.PutValues
= put_values_DITHER_5R6G5B_ximage
;
4675 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER_5R6G5B_ximage
;
4680 xrb
->Base
.PutRow
= put_row_DITHER_pixmap
;
4681 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_pixmap
;
4682 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER_pixmap
;
4683 xrb
->Base
.PutValues
= put_values_DITHER_pixmap
;
4684 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER_pixmap
;
4688 xrb
->Base
.PutRow
= put_row_DITHER8_ximage
;
4689 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER8_ximage
;
4690 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER8_ximage
;
4691 xrb
->Base
.PutValues
= put_values_DITHER8_ximage
;
4692 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER8_ximage
;
4695 xrb
->Base
.PutRow
= put_row_DITHER_ximage
;
4696 xrb
->Base
.PutRowRGB
= put_row_rgb_DITHER_ximage
;
4697 xrb
->Base
.PutMonoRow
= put_mono_row_DITHER_ximage
;
4698 xrb
->Base
.PutValues
= put_values_DITHER_ximage
;
4699 xrb
->Base
.PutMonoValues
= put_mono_values_DITHER_ximage
;
4705 xrb
->Base
.PutRow
= put_row_1BIT_pixmap
;
4706 xrb
->Base
.PutRowRGB
= put_row_rgb_1BIT_pixmap
;
4707 xrb
->Base
.PutMonoRow
= put_mono_row_1BIT_pixmap
;
4708 xrb
->Base
.PutValues
= put_values_1BIT_pixmap
;
4709 xrb
->Base
.PutMonoValues
= put_mono_values_1BIT_pixmap
;
4712 xrb
->Base
.PutRow
= put_row_1BIT_ximage
;
4713 xrb
->Base
.PutRowRGB
= put_row_rgb_1BIT_ximage
;
4714 xrb
->Base
.PutMonoRow
= put_mono_row_1BIT_ximage
;
4715 xrb
->Base
.PutValues
= put_values_1BIT_ximage
;
4716 xrb
->Base
.PutMonoValues
= put_mono_values_1BIT_ximage
;
4721 xrb
->Base
.PutRow
= put_row_HPCR_pixmap
;
4722 xrb
->Base
.PutRowRGB
= put_row_rgb_HPCR_pixmap
;
4723 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4724 xrb
->Base
.PutValues
= put_values_HPCR_pixmap
;
4725 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4728 xrb
->Base
.PutRow
= put_row_HPCR_ximage
;
4729 xrb
->Base
.PutRowRGB
= put_row_rgb_HPCR_ximage
;
4730 xrb
->Base
.PutMonoRow
= put_mono_row_HPCR_ximage
;
4731 xrb
->Base
.PutValues
= put_values_HPCR_ximage
;
4732 xrb
->Base
.PutMonoValues
= put_mono_values_HPCR_ximage
;
4737 xrb
->Base
.PutRow
= put_row_LOOKUP_pixmap
;
4738 xrb
->Base
.PutRowRGB
= put_row_rgb_LOOKUP_pixmap
;
4739 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4740 xrb
->Base
.PutValues
= put_values_LOOKUP_pixmap
;
4741 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4745 xrb
->Base
.PutRow
= put_row_LOOKUP8_ximage
;
4746 xrb
->Base
.PutRowRGB
= put_row_rgb_LOOKUP8_ximage
;
4747 xrb
->Base
.PutMonoRow
= put_mono_row_LOOKUP8_ximage
;
4748 xrb
->Base
.PutValues
= put_values_LOOKUP8_ximage
;
4749 xrb
->Base
.PutMonoValues
= put_mono_values_LOOKUP8_ximage
;
4752 xrb
->Base
.PutRow
= put_row_LOOKUP_ximage
;
4753 xrb
->Base
.PutRowRGB
= put_row_rgb_LOOKUP_ximage
;
4754 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4755 xrb
->Base
.PutValues
= put_values_LOOKUP_ximage
;
4756 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4762 xrb
->Base
.PutRow
= put_row_GRAYSCALE_pixmap
;
4763 xrb
->Base
.PutRowRGB
= put_row_rgb_GRAYSCALE_pixmap
;
4764 xrb
->Base
.PutMonoRow
= put_mono_row_pixmap
;
4765 xrb
->Base
.PutValues
= put_values_GRAYSCALE_pixmap
;
4766 xrb
->Base
.PutMonoValues
= put_mono_values_pixmap
;
4770 xrb
->Base
.PutRow
= put_row_GRAYSCALE8_ximage
;
4771 xrb
->Base
.PutRowRGB
= put_row_rgb_GRAYSCALE8_ximage
;
4772 xrb
->Base
.PutMonoRow
= put_mono_row_GRAYSCALE8_ximage
;
4773 xrb
->Base
.PutValues
= put_values_GRAYSCALE8_ximage
;
4774 xrb
->Base
.PutMonoValues
= put_mono_values_GRAYSCALE8_ximage
;
4777 xrb
->Base
.PutRow
= put_row_GRAYSCALE_ximage
;
4778 xrb
->Base
.PutRowRGB
= put_row_rgb_GRAYSCALE_ximage
;
4779 xrb
->Base
.PutMonoRow
= put_mono_row_ximage
;
4780 xrb
->Base
.PutValues
= put_values_GRAYSCALE_ximage
;
4781 xrb
->Base
.PutMonoValues
= put_mono_values_ximage
;
4786 _mesa_problem(NULL
, "Bad pixel format in xmesa_update_state (1)");
4792 if (pixelformat
== PF_Index
) {
4793 xrb
->Base
.GetRow
= get_row_ci
;
4794 xrb
->Base
.GetValues
= get_values_ci
;
4797 xrb
->Base
.GetRow
= get_row_rgba
;
4798 xrb
->Base
.GetValues
= get_values_rgba
;