| 1 |
#include "sgcf.h" |
| 2 |
#if defined(HAVE_X11) |
| 3 |
|
| 4 |
/* $Id: xmesa2.c,v 1.4 2000/12/31 16:32:58 mholst Exp $ */ |
| 5 |
|
| 6 |
/* |
| 7 |
* Mesa 3-D graphics library |
| 8 |
* Version: 2.0 |
| 9 |
* Copyright (C) 1995-1996 Brian Paul |
| 10 |
* |
| 11 |
* This library is free software; you can redistribute it and/or |
| 12 |
* modify it under the terms of the GNU Library General Public |
| 13 |
* License as published by the Free Software Foundation; either |
| 14 |
* version 2 of the License, or (at your option) any later version. |
| 15 |
* |
| 16 |
* This library is distributed in the hope that it will be useful, |
| 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 |
* Library General Public License for more details. |
| 20 |
* |
| 21 |
* You should have received a copy of the GNU Library General Public |
| 22 |
* License along with this library; if not, write to the Free |
| 23 |
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 24 |
*/ |
| 25 |
|
| 26 |
/* |
| 27 |
* Mesa/X11 interface, part 2. |
| 28 |
* |
| 29 |
* This file contains the implementations of all the device driver functions. |
| 30 |
*/ |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
#include <stdio.h> |
| 35 |
#include <stdlib.h> |
| 36 |
#include <string.h> |
| 37 |
#include <X11/Xlib.h> |
| 38 |
#include "GL/xmesa.h" |
| 39 |
#include "macros.h" |
| 40 |
#include "types.h" |
| 41 |
#include "xmesaP.h" |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
/* |
| 46 |
* Abort with an error message. |
| 47 |
*/ |
| 48 |
static void die( char *s ) |
| 49 |
{ |
| 50 |
fprintf( stderr, "%s\n", s ); |
| 51 |
abort(); |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
/* |
| 57 |
* The following functions are used to trap XGetImage() calls which |
| 58 |
* generate BadMatch errors if the drawable isn't mapped. |
| 59 |
*/ |
| 60 |
|
| 61 |
static int caught_xgetimage_error = 0; |
| 62 |
static int (*old_xerror_handler)( Display *dpy, XErrorEvent *ev ); |
| 63 |
static unsigned long xgetimage_serial; |
| 64 |
|
| 65 |
/* |
| 66 |
* This is the error handler which will be called if XGetImage fails. |
| 67 |
*/ |
| 68 |
static int xgetimage_error_handler( Display *dpy, XErrorEvent *ev ) |
| 69 |
{ |
| 70 |
if (ev->serial==xgetimage_serial && ev->error_code==BadMatch) { |
| 71 |
/* caught the expected error */ |
| 72 |
caught_xgetimage_error = 0; |
| 73 |
} |
| 74 |
else { |
| 75 |
/* call the original X error handler, if any. otherwise ignore */ |
| 76 |
if (old_xerror_handler) { |
| 77 |
(*old_xerror_handler)( dpy, ev ); |
| 78 |
} |
| 79 |
} |
| 80 |
return 0; |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
/* |
| 85 |
* Call this right before XGetImage to setup error trap. |
| 86 |
*/ |
| 87 |
static void catch_xgetimage_errors( Display *dpy ) |
| 88 |
{ |
| 89 |
xgetimage_serial = NextRequest( dpy ); |
| 90 |
old_xerror_handler = XSetErrorHandler( xgetimage_error_handler ); |
| 91 |
caught_xgetimage_error = 0; |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
/* |
| 96 |
* Call this right after XGetImage to check if an error occured. |
| 97 |
*/ |
| 98 |
static int check_xgetimage_errors( void ) |
| 99 |
{ |
| 100 |
/* restore old handler */ |
| 101 |
(void) XSetErrorHandler( old_xerror_handler ); |
| 102 |
/* return 0=no error, 1=error caught */ |
| 103 |
return caught_xgetimage_error; |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
/* |
| 108 |
* Read a pixel from an X drawable. |
| 109 |
*/ |
| 110 |
static unsigned long read_pixel( Display *dpy, Drawable d, int x, int y ) |
| 111 |
{ |
| 112 |
XImage *pixel; |
| 113 |
unsigned long p; |
| 114 |
int error; |
| 115 |
catch_xgetimage_errors( dpy ); |
| 116 |
pixel = XGetImage( dpy, d, x, y, 1, 1, AllPlanes, ZPixmap ); |
| 117 |
error = check_xgetimage_errors(); |
| 118 |
if (pixel && !error) { |
| 119 |
p = XGetPixel( pixel, 0, 0 ); |
| 120 |
} |
| 121 |
else { |
| 122 |
p = 0; |
| 123 |
} |
| 124 |
if (pixel) { |
| 125 |
XDestroyImage( pixel ); |
| 126 |
} |
| 127 |
return p; |
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
/* |
| 134 |
* Return the size (width,height of the current color buffer. |
| 135 |
* This function should be called by the glViewport function because |
| 136 |
* glViewport is often called when the window gets resized. We need to |
| 137 |
* update some X/Mesa stuff when that happens. |
| 138 |
* Output: width - width of buffer in pixels. |
| 139 |
* height - height of buffer in pixels. |
| 140 |
*/ |
| 141 |
static void get_buffer_size( GLcontext *ctx, GLuint *width, GLuint *height ) |
| 142 |
{ |
| 143 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 144 |
Window root; |
| 145 |
int winx, winy; |
| 146 |
unsigned int winwidth, winheight; |
| 147 |
unsigned int bw, d; |
| 148 |
|
| 149 |
XGetGeometry( xmesa->display, xmesa->xm_buffer->frontbuffer, &root, |
| 150 |
&winx, &winy, &winwidth, &winheight, &bw, &d ); |
| 151 |
|
| 152 |
*width = winwidth; |
| 153 |
*height = winheight; |
| 154 |
|
| 155 |
if ( winwidth!=xmesa->xm_buffer->width |
| 156 |
|| winheight!=xmesa->xm_buffer->height) { |
| 157 |
xmesa->xm_buffer->width = winwidth; |
| 158 |
xmesa->xm_buffer->height = winheight; |
| 159 |
xmesa_alloc_back_buffer( xmesa->xm_buffer ); |
| 160 |
} |
| 161 |
|
| 162 |
/* Needed by FLIP macro */ |
| 163 |
xmesa->xm_buffer->bottom = (int) winheight - 1; |
| 164 |
|
| 165 |
if (xmesa->xm_buffer->backimage) { |
| 166 |
/* Needed by PIXELADDR1 macro */ |
| 167 |
xmesa->xm_buffer->ximage_width1 |
| 168 |
= xmesa->xm_buffer->backimage->bytes_per_line; |
| 169 |
xmesa->xm_buffer->ximage_origin1 |
| 170 |
= (GLubyte *) xmesa->xm_buffer->backimage->data |
| 171 |
+ xmesa->xm_buffer->ximage_width1 * (winheight-1); |
| 172 |
|
| 173 |
/* Needed by PIXELADDR2 macro */ |
| 174 |
xmesa->xm_buffer->ximage_width2 |
| 175 |
= xmesa->xm_buffer->backimage->bytes_per_line / 2; |
| 176 |
xmesa->xm_buffer->ximage_origin2 |
| 177 |
= (GLushort *) xmesa->xm_buffer->backimage->data |
| 178 |
+ xmesa->xm_buffer->ximage_width2 * (winheight-1); |
| 179 |
|
| 180 |
/* Needed by PIXELADDR4 macro */ |
| 181 |
xmesa->xm_buffer->ximage_width4 = xmesa->xm_buffer->backimage->width; |
| 182 |
xmesa->xm_buffer->ximage_origin4 |
| 183 |
= (GLuint *) xmesa->xm_buffer->backimage->data |
| 184 |
+ xmesa->xm_buffer->ximage_width4 * (winheight-1); |
| 185 |
} |
| 186 |
} |
| 187 |
|
| 188 |
|
| 189 |
static void finish( GLcontext *ctx ) |
| 190 |
{ |
| 191 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 192 |
if (xmesa) { |
| 193 |
XSync( xmesa->display, False ); |
| 194 |
} |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
static void flush( GLcontext *ctx ) |
| 199 |
{ |
| 200 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 201 |
if (xmesa) { |
| 202 |
XFlush( xmesa->display ); |
| 203 |
} |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
static GLboolean set_buffer( GLcontext *ctx, GLenum mode ) |
| 209 |
{ |
| 210 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 211 |
if (mode==GL_FRONT) { |
| 212 |
/* read/write front buffer */ |
| 213 |
xmesa->xm_buffer->buffer = xmesa->xm_buffer->frontbuffer; |
| 214 |
xmesa_setup_DD_pointers( ctx ); |
| 215 |
return GL_TRUE; |
| 216 |
} |
| 217 |
else if (mode==GL_BACK && xmesa->xm_buffer->db_state) { |
| 218 |
/* read/write back buffer */ |
| 219 |
if (xmesa->xm_buffer->backpixmap) { |
| 220 |
xmesa->xm_buffer->buffer = xmesa->xm_buffer->backpixmap; |
| 221 |
} |
| 222 |
else if (xmesa->xm_buffer->backimage) { |
| 223 |
xmesa->xm_buffer->buffer = None; |
| 224 |
} |
| 225 |
else { |
| 226 |
/* just in case, probably a serious error? */ |
| 227 |
xmesa->xm_buffer->buffer = xmesa->xm_buffer->frontbuffer; |
| 228 |
} |
| 229 |
xmesa_setup_DD_pointers( ctx ); |
| 230 |
return GL_TRUE; |
| 231 |
} |
| 232 |
else { |
| 233 |
return GL_FALSE; |
| 234 |
} |
| 235 |
} |
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
static void clear_index( GLcontext *ctx, GLuint index ) |
| 240 |
{ |
| 241 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 242 |
xmesa->clearpixel = (unsigned long) index; |
| 243 |
XSetForeground( xmesa->display, xmesa->xm_buffer->cleargc, |
| 244 |
(unsigned long) index ); |
| 245 |
} |
| 246 |
|
| 247 |
|
| 248 |
static void clear_color( GLcontext *ctx, |
| 249 |
GLubyte r, GLubyte g, GLubyte b, GLubyte a ) |
| 250 |
{ |
| 251 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 252 |
xmesa->clearcolor[0] = r; |
| 253 |
xmesa->clearcolor[1] = g; |
| 254 |
xmesa->clearcolor[2] = b; |
| 255 |
xmesa->clearcolor[3] = a; |
| 256 |
xmesa->clearpixel = xmesa_color_to_pixel( xmesa, r, g, b, a ); |
| 257 |
XSetForeground( xmesa->display, xmesa->xm_buffer->cleargc, |
| 258 |
xmesa->clearpixel ); |
| 259 |
} |
| 260 |
|
| 261 |
|
| 262 |
/* Set current color index */ |
| 263 |
static void set_index( GLcontext *ctx, GLuint index ) |
| 264 |
{ |
| 265 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 266 |
unsigned long p = (unsigned long) index; |
| 267 |
xmesa->pixel = p; |
| 268 |
XSetForeground( xmesa->display, xmesa->xm_buffer->gc1, p ); |
| 269 |
} |
| 270 |
|
| 271 |
|
| 272 |
/* Set current drawing color */ |
| 273 |
static void set_color( GLcontext *ctx, |
| 274 |
GLubyte r, GLubyte g, GLubyte b, GLubyte a ) |
| 275 |
{ |
| 276 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 277 |
xmesa->red = r; |
| 278 |
xmesa->green = g; |
| 279 |
xmesa->blue = b; |
| 280 |
xmesa->alpha = a; |
| 281 |
xmesa->pixel = xmesa_color_to_pixel( xmesa, r, g, b, a );; |
| 282 |
XSetForeground( xmesa->display, xmesa->xm_buffer->gc1, xmesa->pixel ); |
| 283 |
} |
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
/* Set index mask ala glIndexMask */ |
| 288 |
static GLboolean index_mask( GLcontext *ctx, GLuint mask ) |
| 289 |
{ |
| 290 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 291 |
if (xmesa->xm_buffer->buffer==XIMAGE) { |
| 292 |
return GL_FALSE; |
| 293 |
} |
| 294 |
else { |
| 295 |
unsigned long m; |
| 296 |
if (mask==0xffffffff) { |
| 297 |
m = AllPlanes; |
| 298 |
} |
| 299 |
else { |
| 300 |
m = (unsigned long) mask; |
| 301 |
} |
| 302 |
XSetPlaneMask( xmesa->display, xmesa->xm_buffer->gc1, m ); |
| 303 |
XSetPlaneMask( xmesa->display, xmesa->xm_buffer->gc2, m ); |
| 304 |
XSetPlaneMask( xmesa->display, xmesa->xm_buffer->cleargc, m ); |
| 305 |
return GL_TRUE; |
| 306 |
} |
| 307 |
} |
| 308 |
|
| 309 |
|
| 310 |
/* Implements glColorMask() */ |
| 311 |
static GLboolean color_mask( GLcontext *ctx, |
| 312 |
GLboolean rmask, GLboolean gmask, |
| 313 |
GLboolean bmask, GLboolean amask ) |
| 314 |
{ |
| 315 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 316 |
#if defined(__cplusplus) || defined(c_plusplus) |
| 317 |
int xclass = xmesa->xm_visual->visinfo->c_class; |
| 318 |
#else |
| 319 |
int xclass = xmesa->xm_visual->visinfo->class; |
| 320 |
#endif |
| 321 |
|
| 322 |
if (xmesa->xm_buffer->buffer!=XIMAGE |
| 323 |
&& (xclass==TrueColor || xclass==DirectColor)) { |
| 324 |
unsigned long m; |
| 325 |
if (rmask && gmask && bmask) { |
| 326 |
m = AllPlanes; |
| 327 |
} |
| 328 |
else { |
| 329 |
m = 0; |
| 330 |
if (rmask) m |= xmesa->xm_visual->visinfo->red_mask; |
| 331 |
if (gmask) m |= xmesa->xm_visual->visinfo->green_mask; |
| 332 |
if (bmask) m |= xmesa->xm_visual->visinfo->blue_mask; |
| 333 |
} |
| 334 |
XSetPlaneMask( xmesa->display, xmesa->xm_buffer->gc1, m ); |
| 335 |
XSetPlaneMask( xmesa->display, xmesa->xm_buffer->gc2, m ); |
| 336 |
XSetPlaneMask( xmesa->display, xmesa->xm_buffer->cleargc, m ); |
| 337 |
return GL_TRUE; |
| 338 |
} |
| 339 |
else { |
| 340 |
return GL_FALSE; |
| 341 |
} |
| 342 |
} |
| 343 |
|
| 344 |
|
| 345 |
/* |
| 346 |
* Set the pixel logic operation. Return GL_TRUE if the device driver |
| 347 |
* can perform the operation, otherwise return GL_FALSE. GL_COPY _must_ |
| 348 |
* be operational, obviously. |
| 349 |
*/ |
| 350 |
static GLboolean logicop( GLcontext *ctx, GLenum op ) |
| 351 |
{ |
| 352 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 353 |
int func; |
| 354 |
if (!XMesa) return GL_FALSE; |
| 355 |
if ((xmesa->xm_buffer->buffer==XIMAGE) && op!=GL_COPY) { |
| 356 |
/* X can't do logic ops in Ximages, except for GL_COPY */ |
| 357 |
return GL_FALSE; |
| 358 |
} |
| 359 |
switch (op) { |
| 360 |
case GL_CLEAR: func = GXclear; break; |
| 361 |
case GL_SET: func = GXset; break; |
| 362 |
case GL_COPY: func = GXcopy; break; |
| 363 |
case GL_COPY_INVERTED: func = GXcopyInverted; break; |
| 364 |
case GL_NOOP: func = GXnoop; break; |
| 365 |
case GL_INVERT: func = GXinvert; break; |
| 366 |
case GL_AND: func = GXand; break; |
| 367 |
case GL_NAND: func = GXnand; break; |
| 368 |
case GL_OR: func = GXor; break; |
| 369 |
case GL_NOR: func = GXnor; break; |
| 370 |
case GL_XOR: func = GXxor; break; |
| 371 |
case GL_EQUIV: func = GXequiv; break; |
| 372 |
case GL_AND_REVERSE: func = GXandReverse; break; |
| 373 |
case GL_AND_INVERTED: func = GXandInverted; break; |
| 374 |
case GL_OR_REVERSE: func = GXorReverse; break; |
| 375 |
case GL_OR_INVERTED: func = GXorInverted; break; |
| 376 |
default: return GL_FALSE; |
| 377 |
} |
| 378 |
XSetFunction( xmesa->display, xmesa->xm_buffer->gc1, func ); |
| 379 |
XSetFunction( xmesa->display, xmesa->xm_buffer->gc2, func ); |
| 380 |
return GL_TRUE; |
| 381 |
} |
| 382 |
|
| 383 |
|
| 384 |
/* |
| 385 |
* Enable/disable dithering |
| 386 |
*/ |
| 387 |
static void dither( GLcontext *ctx, GLboolean enable ) |
| 388 |
{ |
| 389 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 390 |
if (enable) { |
| 391 |
xmesa->pixelformat = xmesa->xm_visual->dithered_pf; |
| 392 |
} |
| 393 |
else { |
| 394 |
xmesa->pixelformat = xmesa->xm_visual->undithered_pf; |
| 395 |
} |
| 396 |
xmesa_setup_DD_pointers( ctx ); |
| 397 |
} |
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
/**********************************************************************/ |
| 402 |
/*** glClear implementations ***/ |
| 403 |
/**********************************************************************/ |
| 404 |
|
| 405 |
static void clear_pixmap( GLcontext *ctx, GLboolean all, |
| 406 |
GLint x, GLint y, GLint width, GLint height ) |
| 407 |
{ |
| 408 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 409 |
if (all) { |
| 410 |
XFillRectangle( xmesa->display, xmesa->xm_buffer->buffer, |
| 411 |
xmesa->xm_buffer->cleargc, |
| 412 |
0, 0, |
| 413 |
xmesa->xm_buffer->width+1, xmesa->xm_buffer->height+1 ); |
| 414 |
} |
| 415 |
else { |
| 416 |
XFillRectangle( xmesa->display, xmesa->xm_buffer->buffer, |
| 417 |
xmesa->xm_buffer->cleargc, |
| 418 |
x, xmesa->xm_buffer->height - y - height, |
| 419 |
width, height ); |
| 420 |
} |
| 421 |
} |
| 422 |
|
| 423 |
|
| 424 |
static void clear_8bit_ximage( GLcontext *ctx, GLboolean all, |
| 425 |
GLint x, GLint y, GLint width, GLint height ) |
| 426 |
{ |
| 427 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 428 |
if (all) { |
| 429 |
size_t n = xmesa->xm_buffer->backimage->bytes_per_line |
| 430 |
* xmesa->xm_buffer->backimage->height; |
| 431 |
MEMSET( xmesa->xm_buffer->backimage->data, xmesa->clearpixel, n ); |
| 432 |
} |
| 433 |
else { |
| 434 |
GLint i; |
| 435 |
for (i=0;i<height;i++) { |
| 436 |
GLubyte *ptr = PIXELADDR1( x, y+i ); |
| 437 |
MEMSET( ptr, xmesa->clearpixel, width ); |
| 438 |
} |
| 439 |
} |
| 440 |
} |
| 441 |
|
| 442 |
|
| 443 |
static void clear_16bit_ximage( GLcontext *ctx, GLboolean all, |
| 444 |
GLint x, GLint y, GLint width, GLint height ) |
| 445 |
{ |
| 446 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 447 |
if (all) { |
| 448 |
register GLuint n; |
| 449 |
register GLushort *ptr2 =(GLushort *) xmesa->xm_buffer->backimage->data; |
| 450 |
register GLushort pixel = (GLushort) xmesa->clearpixel; |
| 451 |
if (xmesa->swapbytes) { |
| 452 |
pixel = ((pixel >> 8) & 0x00ff) |
| 453 |
| ((pixel << 8) & 0xff00); |
| 454 |
} |
| 455 |
if ((pixel & 0xff) == (pixel >> 8)) { |
| 456 |
/* low and high bytes are equal so use memset() */ |
| 457 |
n = xmesa->xm_buffer->backimage->bytes_per_line |
| 458 |
* xmesa->xm_buffer->height; |
| 459 |
MEMSET( ptr2, pixel & 0xff, n ); |
| 460 |
} |
| 461 |
else { |
| 462 |
n = xmesa->xm_buffer->backimage->bytes_per_line / 2 |
| 463 |
* xmesa->xm_buffer->height; |
| 464 |
do { |
| 465 |
*ptr2++ = pixel; |
| 466 |
n--; |
| 467 |
} while (n!=0); |
| 468 |
} |
| 469 |
} |
| 470 |
else { |
| 471 |
register int i, j; |
| 472 |
register GLushort pixel = (GLushort) xmesa->clearpixel; |
| 473 |
for (j=0;j<height;j++) { |
| 474 |
register GLushort *ptr2 = PIXELADDR2( x, y+j ); |
| 475 |
for (i=0;i<width;i++) { |
| 476 |
*ptr2++ = pixel; |
| 477 |
} |
| 478 |
} |
| 479 |
} |
| 480 |
} |
| 481 |
|
| 482 |
|
| 483 |
static void clear_32bit_ximage( GLcontext *ctx, GLboolean all, |
| 484 |
GLint x, GLint y, GLint width, GLint height ) |
| 485 |
{ |
| 486 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 487 |
if (all) { |
| 488 |
register GLint n = xmesa->xm_buffer->width * xmesa->xm_buffer->height; |
| 489 |
register GLuint *ptr4 = (GLuint *) xmesa->xm_buffer->backimage->data; |
| 490 |
register GLuint pixel = (GLuint) xmesa->clearpixel; |
| 491 |
if (xmesa->swapbytes) { |
| 492 |
pixel = ((pixel >> 24) & 0x000000ff) |
| 493 |
| ((pixel >> 8) & 0x0000ff00) |
| 494 |
| ((pixel << 8) & 0x00ff0000) |
| 495 |
| ((pixel << 24) & 0xff000000); |
| 496 |
} |
| 497 |
if (pixel==0) { |
| 498 |
MEMSET( ptr4, pixel, 4*n ); |
| 499 |
} |
| 500 |
else { |
| 501 |
do { |
| 502 |
*ptr4++ = pixel; |
| 503 |
n--; |
| 504 |
} while (n!=0); |
| 505 |
} |
| 506 |
} |
| 507 |
else { |
| 508 |
register int i, j; |
| 509 |
register GLuint pixel = (GLuint) xmesa->clearpixel; |
| 510 |
for (j=0;j<height;j++) { |
| 511 |
register GLuint *ptr4 = PIXELADDR4( x, y+j ); |
| 512 |
for (i=0;i<width;i++) { |
| 513 |
*ptr4++ = pixel; |
| 514 |
} |
| 515 |
} |
| 516 |
} |
| 517 |
} |
| 518 |
|
| 519 |
|
| 520 |
static void clear_nbit_ximage( GLcontext *ctx, GLboolean all, |
| 521 |
GLint x, GLint y, GLint width, GLint height ) |
| 522 |
{ |
| 523 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 524 |
XImage *img = xmesa->xm_buffer->backimage; |
| 525 |
if (all) { |
| 526 |
register int i, j; |
| 527 |
width = xmesa->xm_buffer->width; |
| 528 |
height = xmesa->xm_buffer->height; |
| 529 |
for (j=0;j<height;j++) { |
| 530 |
for (i=0;i<width;i++) { |
| 531 |
XPutPixel( img, i, j, xmesa->clearpixel ); |
| 532 |
} |
| 533 |
} |
| 534 |
} |
| 535 |
else { |
| 536 |
/* TODO: optimize this */ |
| 537 |
register int i, j; |
| 538 |
y = FLIP(y); |
| 539 |
for (j=0;j<height;j++) { |
| 540 |
for (i=0;i<width;i++) { |
| 541 |
XPutPixel( img, x+i, y-j, xmesa->clearpixel ); |
| 542 |
} |
| 543 |
} |
| 544 |
} |
| 545 |
} |
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
/* |
| 551 |
* The Mesa library needs to be able to draw pixels in a number of ways: |
| 552 |
* 1. RGB vs Color Index |
| 553 |
* 2. as horizontal spans (polygons, images) vs random locations (points, |
| 554 |
* lines) |
| 555 |
* 3. different color per-pixel or same color for all pixels |
| 556 |
* |
| 557 |
* Furthermore, the X driver needs to support rendering to 3 possible |
| 558 |
* "buffers", usually one, but sometimes two at a time: |
| 559 |
* 1. The front buffer as an X window |
| 560 |
* 2. The back buffer as a Pixmap |
| 561 |
* 3. The back buffer as an XImage |
| 562 |
* |
| 563 |
* Finally, if the back buffer is an XImage, we can avoid using XPutPixel and |
| 564 |
* optimize common cases such as 24-bit and 8-bit modes. |
| 565 |
* |
| 566 |
* By multiplication, there's at least 48 possible combinations of the above. |
| 567 |
* |
| 568 |
* Below are implementations of the most commonly used combinations. They are |
| 569 |
* accessed through function pointers which get initialized here and are used |
| 570 |
* directly from the Mesa library. The 8 function pointers directly correspond |
| 571 |
* to the first 3 cases listed above. |
| 572 |
* |
| 573 |
* |
| 574 |
* The function naming convention is: |
| 575 |
* |
| 576 |
* write_[span|pixels]_[mono]_[format]_[pixmap|ximage] |
| 577 |
* |
| 578 |
* New functions optimized for specific cases can be added without too much |
| 579 |
* trouble. An example might be the 24-bit TrueColor mode 8A8R8G8B which is |
| 580 |
* found on IBM RS/6000 X servers. |
| 581 |
*/ |
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
/**********************************************************************/ |
| 587 |
/*** Write COLOR SPAN functions ***/ |
| 588 |
/**********************************************************************/ |
| 589 |
|
| 590 |
|
| 591 |
#define COLOR_SPAN_ARGS GLcontext *ctx, \ |
| 592 |
GLuint n, GLint x, GLint y, \ |
| 593 |
const GLubyte red[], const GLubyte green[], \ |
| 594 |
const GLubyte blue[], const GLubyte alpha[], \ |
| 595 |
const GLubyte mask[] |
| 596 |
|
| 597 |
/* NOTE: if mask==NULL, draw all pixels */ |
| 598 |
|
| 599 |
|
| 600 |
/* |
| 601 |
* Write a span of PF_TRUECOLOR pixels to a pixmap. |
| 602 |
*/ |
| 603 |
static void write_span_TRUECOLOR_pixmap( COLOR_SPAN_ARGS ) |
| 604 |
{ |
| 605 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 606 |
Display *dpy = xmesa->xm_visual->display; |
| 607 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 608 |
GC gc = xmesa->xm_buffer->gc2; |
| 609 |
register GLuint i; |
| 610 |
y = FLIP(y); |
| 611 |
if (mask) { |
| 612 |
for (i=0;i<n;i++,x++) { |
| 613 |
if (mask[i]) { |
| 614 |
XSetForeground( dpy, gc, PACK_RGB( red[i], green[i], blue[i] ) ); |
| 615 |
XDrawPoint( dpy, buffer, gc, (int) x, (int) y ); |
| 616 |
} |
| 617 |
} |
| 618 |
} |
| 619 |
else { |
| 620 |
/* draw all pixels */ |
| 621 |
XImage *rowimg = xmesa->xm_buffer->rowimage; |
| 622 |
for (i=0;i<n;i++) { |
| 623 |
XPutPixel( rowimg, i, 0, PACK_RGB( red[i], green[i], blue[i] ) ); |
| 624 |
} |
| 625 |
XPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 ); |
| 626 |
} |
| 627 |
} |
| 628 |
|
| 629 |
|
| 630 |
/* |
| 631 |
* Write a span of PF_8A8B8G8R pixels to a pixmap. |
| 632 |
*/ |
| 633 |
static void write_span_8A8B8G8R_pixmap( COLOR_SPAN_ARGS ) |
| 634 |
{ |
| 635 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 636 |
Display *dpy = xmesa->xm_visual->display; |
| 637 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 638 |
GC gc = xmesa->xm_buffer->gc2; |
| 639 |
register GLuint i; |
| 640 |
y = FLIP( y ); |
| 641 |
if (mask) { |
| 642 |
for (i=0;i<n;i++,x++) { |
| 643 |
if (mask[i]) { |
| 644 |
XSetForeground( dpy, gc, |
| 645 |
PACK_8A8B8G8R(red[i], green[i], blue[i], alpha[i]) ); |
| 646 |
XDrawPoint( dpy, buffer, gc, (int) x, (int) y ); |
| 647 |
} |
| 648 |
} |
| 649 |
} |
| 650 |
else { |
| 651 |
/* draw all pixels */ |
| 652 |
XImage *rowimg = xmesa->xm_buffer->rowimage; |
| 653 |
register GLuint *ptr4 = (GLuint *) rowimg->data; |
| 654 |
for (i=0;i<n;i++) { |
| 655 |
*ptr4++ = PACK_8A8B8G8R( red[i], green[i], blue[i], alpha[i] ); |
| 656 |
} |
| 657 |
XPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 ); |
| 658 |
} |
| 659 |
} |
| 660 |
|
| 661 |
|
| 662 |
/* |
| 663 |
* Write a span of PF_8R8G8B pixels to a pixmap. |
| 664 |
*/ |
| 665 |
static void write_span_8R8G8B_pixmap( COLOR_SPAN_ARGS ) |
| 666 |
{ |
| 667 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 668 |
Display *dpy = xmesa->xm_visual->display; |
| 669 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 670 |
GC gc = xmesa->xm_buffer->gc2; |
| 671 |
register GLuint i; |
| 672 |
y = FLIP( y ); |
| 673 |
if (mask) { |
| 674 |
for (i=0;i<n;i++,x++) { |
| 675 |
if (mask[i]) { |
| 676 |
XSetForeground( dpy, gc, PACK_8R8G8B( red[i], green[i], blue[i] )); |
| 677 |
XDrawPoint( dpy, buffer, gc, (int) x, (int) y ); |
| 678 |
} |
| 679 |
} |
| 680 |
} |
| 681 |
else { |
| 682 |
/* draw all pixels */ |
| 683 |
XImage *rowimg = xmesa->xm_buffer->rowimage; |
| 684 |
register GLuint *ptr4 = (GLuint *) rowimg->data; |
| 685 |
for (i=0;i<n;i++) { |
| 686 |
*ptr4++ = PACK_8R8G8B( red[i], green[i], blue[i] ); |
| 687 |
} |
| 688 |
XPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 ); |
| 689 |
} |
| 690 |
} |
| 691 |
|
| 692 |
|
| 693 |
/* |
| 694 |
* Write a span of PF_5R6G5B pixels to a pixmap. |
| 695 |
*/ |
| 696 |
static void write_span_5R6G5B_pixmap( COLOR_SPAN_ARGS ) |
| 697 |
{ |
| 698 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 699 |
Display *dpy = xmesa->xm_visual->display; |
| 700 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 701 |
GC gc = xmesa->xm_buffer->gc2; |
| 702 |
register GLuint i; |
| 703 |
y = FLIP( y ); |
| 704 |
if (mask) { |
| 705 |
for (i=0;i<n;i++,x++) { |
| 706 |
if (mask[i]) { |
| 707 |
XSetForeground( dpy, gc, PACK_5R6G5B( red[i], green[i], blue[i] )); |
| 708 |
XDrawPoint( dpy, buffer, gc, (int) x, (int) y ); |
| 709 |
} |
| 710 |
} |
| 711 |
} |
| 712 |
else { |
| 713 |
/* draw all pixels */ |
| 714 |
XImage *rowimg = xmesa->xm_buffer->rowimage; |
| 715 |
register GLushort *ptr2 = (GLushort *) rowimg->data; |
| 716 |
for (i=0;i<n;i++) { |
| 717 |
ptr2[i] = PACK_5R6G5B( red[i], green[i], blue[i] ); |
| 718 |
} |
| 719 |
XPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 ); |
| 720 |
} |
| 721 |
} |
| 722 |
|
| 723 |
|
| 724 |
/* |
| 725 |
* Write a span of PF_DITHER pixels to a pixmap. |
| 726 |
*/ |
| 727 |
static void write_span_DITHER_pixmap( COLOR_SPAN_ARGS ) |
| 728 |
{ |
| 729 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 730 |
Display *dpy = xmesa->xm_visual->display; |
| 731 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 732 |
GC gc = xmesa->xm_buffer->gc2; |
| 733 |
register GLuint i; |
| 734 |
XDITHER_SETUP(y); |
| 735 |
y = FLIP( y ); |
| 736 |
if (mask) { |
| 737 |
for (i=0;i<n;i++,x++) { |
| 738 |
if (mask[i]) { |
| 739 |
XSetForeground( dpy, gc, XDITHER(x, red[i], green[i], blue[i]) ); |
| 740 |
XDrawPoint( dpy, buffer, gc, (int) x, (int) y ); |
| 741 |
} |
| 742 |
} |
| 743 |
} |
| 744 |
else { |
| 745 |
/* draw all pixels */ |
| 746 |
XImage *rowimg = xmesa->xm_buffer->rowimage; |
| 747 |
for (i=0;i<n;i++) { |
| 748 |
XPutPixel( rowimg, i, 0, XDITHER(x+i, red[i], green[i], blue[i]) ); |
| 749 |
} |
| 750 |
XPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 ); |
| 751 |
} |
| 752 |
} |
| 753 |
|
| 754 |
|
| 755 |
/* |
| 756 |
* Write a span of PF_1BIT pixels to a pixmap. |
| 757 |
*/ |
| 758 |
static void write_span_1BIT_pixmap( COLOR_SPAN_ARGS ) |
| 759 |
{ |
| 760 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 761 |
Display *dpy = xmesa->xm_visual->display; |
| 762 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 763 |
GC gc = xmesa->xm_buffer->gc2; |
| 764 |
register GLuint i; |
| 765 |
y = FLIP( y ); |
| 766 |
if (mask) { |
| 767 |
for (i=0;i<n;i++,x++) { |
| 768 |
if (mask[i]) { |
| 769 |
XSetForeground( dpy, gc, |
| 770 |
DITHER_1BIT( x, y, red[i], green[i], blue[i] ) ); |
| 771 |
XDrawPoint( dpy, buffer, gc, (int) x, (int) y ); |
| 772 |
} |
| 773 |
} |
| 774 |
} |
| 775 |
else { |
| 776 |
/* draw all pixels */ |
| 777 |
XImage *rowimg = xmesa->xm_buffer->rowimage; |
| 778 |
for (i=0;i<n;i++) { |
| 779 |
XPutPixel( rowimg, i, 0, |
| 780 |
DITHER_1BIT( x+i, y, red[i], green[i], blue[i] ) ); |
| 781 |
} |
| 782 |
XPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 ); |
| 783 |
} |
| 784 |
} |
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
/* |
| 789 |
* Write a span of PF_HPCR pixels to a pixmap. |
| 790 |
*/ |
| 791 |
static void write_span_HPCR_pixmap( COLOR_SPAN_ARGS ) |
| 792 |
{ |
| 793 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 794 |
Display *dpy = xmesa->xm_visual->display; |
| 795 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 796 |
GC gc = xmesa->xm_buffer->gc2; |
| 797 |
register GLuint i; |
| 798 |
y = FLIP( y ); |
| 799 |
if (mask) { |
| 800 |
for (i=0;i<n;i++,x++) { |
| 801 |
if (mask[i]) { |
| 802 |
XSetForeground( dpy, gc, |
| 803 |
DITHER_HPCR( x, y, red[i], green[i], blue[i] ) ); |
| 804 |
XDrawPoint( dpy, buffer, gc, (int) x, (int) y ); |
| 805 |
} |
| 806 |
} |
| 807 |
} |
| 808 |
else { |
| 809 |
XImage *rowimg = xmesa->xm_buffer->rowimage; |
| 810 |
register GLubyte *ptr = (GLubyte *) xmesa->xm_buffer->rowimage->data; |
| 811 |
for (i=0;i<n;i++) { |
| 812 |
ptr[i] = DITHER_HPCR( (x+i), y, red[i], green[i], blue[i] ); |
| 813 |
} |
| 814 |
XPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 ); |
| 815 |
} |
| 816 |
} |
| 817 |
|
| 818 |
|
| 819 |
/* |
| 820 |
* Write a span of PF_LOOKUP pixels to a pixmap. |
| 821 |
*/ |
| 822 |
static void write_span_LOOKUP_pixmap( COLOR_SPAN_ARGS ) |
| 823 |
{ |
| 824 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 825 |
Display *dpy = xmesa->xm_visual->display; |
| 826 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 827 |
GC gc = xmesa->xm_buffer->gc2; |
| 828 |
register GLuint i; |
| 829 |
LOOKUP_SETUP; |
| 830 |
y = FLIP( y ); |
| 831 |
if (mask) { |
| 832 |
for (i=0;i<n;i++,x++) { |
| 833 |
if (mask[i]) { |
| 834 |
XSetForeground( dpy, gc, LOOKUP( red[i], green[i], blue[i] ) ); |
| 835 |
XDrawPoint( dpy, buffer, gc, (int) x, (int) y ); |
| 836 |
} |
| 837 |
} |
| 838 |
} |
| 839 |
else { |
| 840 |
XImage *rowimg = xmesa->xm_buffer->rowimage; |
| 841 |
for (i=0;i<n;i++) { |
| 842 |
XPutPixel( rowimg, i, 0, LOOKUP(red[i],green[i],blue[i]) ); |
| 843 |
} |
| 844 |
XPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 ); |
| 845 |
} |
| 846 |
} |
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
/* |
| 851 |
* Write a span of PF_GRAYSCALE pixels to a pixmap. |
| 852 |
*/ |
| 853 |
static void write_span_GRAYSCALE_pixmap( COLOR_SPAN_ARGS ) |
| 854 |
{ |
| 855 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 856 |
Display *dpy = xmesa->xm_visual->display; |
| 857 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 858 |
GC gc = xmesa->xm_buffer->gc2; |
| 859 |
register GLuint i; |
| 860 |
y = FLIP( y ); |
| 861 |
if (mask) { |
| 862 |
for (i=0;i<n;i++,x++) { |
| 863 |
if (mask[i]) { |
| 864 |
XSetForeground( dpy, gc, GRAY_RGB( red[i], green[i], blue[i] ) ); |
| 865 |
XDrawPoint( dpy, buffer, gc, (int) x, (int) y ); |
| 866 |
} |
| 867 |
} |
| 868 |
} |
| 869 |
else { |
| 870 |
XImage *rowimg = xmesa->xm_buffer->rowimage; |
| 871 |
for (i=0;i<n;i++) { |
| 872 |
XPutPixel( rowimg, i, 0, GRAY_RGB(red[i],green[i],blue[i]) ); |
| 873 |
} |
| 874 |
XPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 ); |
| 875 |
} |
| 876 |
} |
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
/* |
| 881 |
* Write a span of PF_TRUECOLOR pixels to an XImage. |
| 882 |
*/ |
| 883 |
static void write_span_TRUECOLOR_ximage( COLOR_SPAN_ARGS ) |
| 884 |
{ |
| 885 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 886 |
XImage *img = xmesa->xm_buffer->backimage; |
| 887 |
register GLuint i; |
| 888 |
y = FLIP(y); |
| 889 |
if (mask) { |
| 890 |
for (i=0;i<n;i++,x++) { |
| 891 |
if (mask[i]) { |
| 892 |
XPutPixel( img, x, y, PACK_RGB( red[i], green[i], blue[i] ) ); |
| 893 |
} |
| 894 |
} |
| 895 |
} |
| 896 |
else { |
| 897 |
/* draw all pixels */ |
| 898 |
for (i=0;i<n;i++,x++) { |
| 899 |
XPutPixel( img, x, y, PACK_RGB( red[i], green[i], blue[i] ) ); |
| 900 |
} |
| 901 |
} |
| 902 |
} |
| 903 |
|
| 904 |
|
| 905 |
/* |
| 906 |
* Write a span of PF_8A8B8G8R-format pixels to an ximage. |
| 907 |
*/ |
| 908 |
static void write_span_8A8B8G8R_ximage( COLOR_SPAN_ARGS ) |
| 909 |
{ |
| 910 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 911 |
register GLuint i; |
| 912 |
register GLuint *ptr = PIXELADDR4( x, y ); |
| 913 |
if (mask) { |
| 914 |
for (i=0;i<n;i++) { |
| 915 |
if (mask[i]) { |
| 916 |
ptr[i] = PACK_8A8B8G8R( red[i], green[i], blue[i], alpha[i] ); |
| 917 |
} |
| 918 |
} |
| 919 |
} |
| 920 |
else { |
| 921 |
/* draw all pixels */ |
| 922 |
for (i=0;i<n;i++) { |
| 923 |
ptr[i] = PACK_8A8B8G8R( red[i], green[i], blue[i], alpha[i] ); |
| 924 |
} |
| 925 |
} |
| 926 |
} |
| 927 |
|
| 928 |
|
| 929 |
/* |
| 930 |
* Write a span of PF_8R8G8B-format pixels to an ximage. |
| 931 |
*/ |
| 932 |
static void write_span_8R8G8B_ximage( COLOR_SPAN_ARGS ) |
| 933 |
{ |
| 934 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 935 |
register GLuint i; |
| 936 |
register GLuint *ptr = PIXELADDR4( x, y ); |
| 937 |
if (mask) { |
| 938 |
for (i=0;i<n;i++) { |
| 939 |
if (mask[i]) { |
| 940 |
ptr[i] = PACK_8R8G8B( red[i], green[i], blue[i] ); |
| 941 |
} |
| 942 |
} |
| 943 |
} |
| 944 |
else { |
| 945 |
/* draw all pixels */ |
| 946 |
for (i=0;i<n;i++) { |
| 947 |
ptr[i] = PACK_8R8G8B( red[i], green[i], blue[i] ); |
| 948 |
} |
| 949 |
} |
| 950 |
} |
| 951 |
|
| 952 |
|
| 953 |
/* |
| 954 |
* Write a span of PF_5R6G5B-format pixels to an ximage. |
| 955 |
*/ |
| 956 |
static void write_span_5R6G5B_ximage( COLOR_SPAN_ARGS ) |
| 957 |
{ |
| 958 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 959 |
register GLuint i; |
| 960 |
register GLushort *ptr = PIXELADDR2( x, y ); |
| 961 |
if (mask) { |
| 962 |
for (i=0;i<n;i++) { |
| 963 |
if (mask[i]) { |
| 964 |
ptr[i] = PACK_5R6G5B( red[i], green[i], blue[i] ); |
| 965 |
} |
| 966 |
} |
| 967 |
} |
| 968 |
else { |
| 969 |
/* draw all pixels */ |
| 970 |
for (i=0;i<n;i++) { |
| 971 |
ptr[i] = PACK_5R6G5B( red[i], green[i], blue[i] ); |
| 972 |
} |
| 973 |
} |
| 974 |
} |
| 975 |
|
| 976 |
|
| 977 |
/* |
| 978 |
* Write a span of PF_DITHER pixels to an XImage. |
| 979 |
*/ |
| 980 |
static void write_span_DITHER_ximage( COLOR_SPAN_ARGS ) |
| 981 |
{ |
| 982 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 983 |
XImage *img = xmesa->xm_buffer->backimage; |
| 984 |
register GLuint i; |
| 985 |
int yy = FLIP(y); |
| 986 |
XDITHER_SETUP(yy); |
| 987 |
if (mask) { |
| 988 |
for (i=0;i<n;i++,x++) { |
| 989 |
if (mask[i]) { |
| 990 |
XPutPixel( img, x, yy, XDITHER( x, red[i], green[i], blue[i] ) ); |
| 991 |
} |
| 992 |
} |
| 993 |
} |
| 994 |
else { |
| 995 |
/* draw all pixels */ |
| 996 |
for (i=0;i<n;i++,x++) { |
| 997 |
XPutPixel( img, x, yy, XDITHER( x, red[i], green[i], blue[i] ) ); |
| 998 |
} |
| 999 |
} |
| 1000 |
} |
| 1001 |
|
| 1002 |
|
| 1003 |
|
| 1004 |
/* |
| 1005 |
* Write a span of 8-bit PF_DITHER pixels to an XImage. |
| 1006 |
*/ |
| 1007 |
static void write_span_DITHER8_ximage( COLOR_SPAN_ARGS ) |
| 1008 |
{ |
| 1009 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1010 |
register GLuint i; |
| 1011 |
register GLubyte *ptr = PIXELADDR1( x, y ); |
| 1012 |
XDITHER_SETUP(y); |
| 1013 |
if (mask) { |
| 1014 |
for (i=0;i<n;i++,x++) { |
| 1015 |
if (mask[i]) { |
| 1016 |
ptr[i] = XDITHER( x, red[i], green[i], blue[i] ); |
| 1017 |
} |
| 1018 |
} |
| 1019 |
} |
| 1020 |
else { |
| 1021 |
for (i=0;i<n;i++,x++) { |
| 1022 |
ptr[i] = XDITHER( x, red[i], green[i], blue[i] ); |
| 1023 |
} |
| 1024 |
} |
| 1025 |
} |
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
/* |
| 1030 |
* Write a span of PF_1BIT pixels to an XImage. |
| 1031 |
*/ |
| 1032 |
static void write_span_1BIT_ximage( COLOR_SPAN_ARGS ) |
| 1033 |
{ |
| 1034 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1035 |
XImage *img = xmesa->xm_buffer->backimage; |
| 1036 |
register GLuint i; |
| 1037 |
y = FLIP(y); |
| 1038 |
if (mask) { |
| 1039 |
for (i=0;i<n;i++,x++) { |
| 1040 |
if (mask[i]) { |
| 1041 |
XPutPixel(img, x, y, DITHER_1BIT(x, y, red[i], green[i], blue[i])); |
| 1042 |
} |
| 1043 |
} |
| 1044 |
} |
| 1045 |
else { |
| 1046 |
for (i=0;i<n;i++,x++) { |
| 1047 |
XPutPixel( img, x, y, DITHER_1BIT(x, y, red[i], green[i], blue[i]) ); |
| 1048 |
} |
| 1049 |
} |
| 1050 |
} |
| 1051 |
|
| 1052 |
|
| 1053 |
/* |
| 1054 |
* Write a span of PF_HPCR pixels to an XImage. |
| 1055 |
*/ |
| 1056 |
static void write_span_HPCR_ximage( COLOR_SPAN_ARGS ) |
| 1057 |
{ |
| 1058 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1059 |
register GLuint i; |
| 1060 |
register GLubyte *ptr = PIXELADDR1( x, y ); |
| 1061 |
if (mask) { |
| 1062 |
for (i=0;i<n;i++,x++) { |
| 1063 |
if (mask[i]) { |
| 1064 |
ptr[i] = DITHER_HPCR( x, y, red[i], green[i], blue[i] ); |
| 1065 |
} |
| 1066 |
} |
| 1067 |
} |
| 1068 |
else { |
| 1069 |
/* draw all pixels */ |
| 1070 |
for (i=0;i<n;i++,x++) { |
| 1071 |
ptr[i] = DITHER_HPCR( x, y, red[i], green[i], blue[i] ); |
| 1072 |
} |
| 1073 |
} |
| 1074 |
} |
| 1075 |
|
| 1076 |
|
| 1077 |
/* |
| 1078 |
* Write a span of PF_LOOKUP pixels to an XImage. |
| 1079 |
*/ |
| 1080 |
static void write_span_LOOKUP_ximage( COLOR_SPAN_ARGS ) |
| 1081 |
{ |
| 1082 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1083 |
XImage *img = xmesa->xm_buffer->backimage; |
| 1084 |
register GLuint i; |
| 1085 |
LOOKUP_SETUP; |
| 1086 |
y = FLIP(y); |
| 1087 |
if (mask) { |
| 1088 |
for (i=0;i<n;i++,x++) { |
| 1089 |
if (mask[i]) { |
| 1090 |
XPutPixel( img, x, y, LOOKUP( red[i], green[i], blue[i] ) ); |
| 1091 |
} |
| 1092 |
} |
| 1093 |
} |
| 1094 |
else { |
| 1095 |
/* draw all pixels */ |
| 1096 |
for (i=0;i<n;i++,x++) { |
| 1097 |
XPutPixel( img, x, y, LOOKUP( red[i], green[i], blue[i] ) ); |
| 1098 |
} |
| 1099 |
} |
| 1100 |
} |
| 1101 |
|
| 1102 |
|
| 1103 |
/* |
| 1104 |
* Write a span of 8-bit PF_LOOKUP pixels to an XImage. |
| 1105 |
*/ |
| 1106 |
static void write_span_LOOKUP8_ximage( COLOR_SPAN_ARGS ) |
| 1107 |
{ |
| 1108 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1109 |
register GLuint i; |
| 1110 |
register GLubyte *ptr = PIXELADDR1( x, y ); |
| 1111 |
LOOKUP_SETUP; |
| 1112 |
if (mask) { |
| 1113 |
for (i=0;i<n;i++,x++) { |
| 1114 |
if (mask[i]) { |
| 1115 |
ptr[i] = LOOKUP( red[i], green[i], blue[i] ); |
| 1116 |
} |
| 1117 |
} |
| 1118 |
} |
| 1119 |
else { |
| 1120 |
/* draw all pixels */ |
| 1121 |
for (i=0;i<n;i++,x++) { |
| 1122 |
ptr[i] = LOOKUP( red[i], green[i], blue[i] ); |
| 1123 |
} |
| 1124 |
} |
| 1125 |
} |
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
/* |
| 1131 |
* Write a span of PF_GRAYSCALE pixels to an XImage. |
| 1132 |
*/ |
| 1133 |
static void write_span_GRAYSCALE_ximage( COLOR_SPAN_ARGS ) |
| 1134 |
{ |
| 1135 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1136 |
XImage *img = xmesa->xm_buffer->backimage; |
| 1137 |
register GLuint i; |
| 1138 |
y = FLIP(y); |
| 1139 |
if (mask) { |
| 1140 |
for (i=0;i<n;i++,x++) { |
| 1141 |
if (mask[i]) { |
| 1142 |
XPutPixel( img, x, y, GRAY_RGB( red[i], green[i], blue[i] ) ); |
| 1143 |
} |
| 1144 |
} |
| 1145 |
} |
| 1146 |
else { |
| 1147 |
/* draw all pixels */ |
| 1148 |
for (i=0;i<n;i++,x++) { |
| 1149 |
XPutPixel( img, x, y, GRAY_RGB( red[i], green[i], blue[i] ) ); |
| 1150 |
} |
| 1151 |
} |
| 1152 |
} |
| 1153 |
|
| 1154 |
|
| 1155 |
/* |
| 1156 |
* Write a span of 8-bit PF_GRAYSCALE pixels to an XImage. |
| 1157 |
*/ |
| 1158 |
static void write_span_GRAYSCALE8_ximage( COLOR_SPAN_ARGS ) |
| 1159 |
{ |
| 1160 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1161 |
register GLuint i; |
| 1162 |
register GLubyte *ptr = PIXELADDR1( x, y ); |
| 1163 |
if (mask) { |
| 1164 |
for (i=0;i<n;i++) { |
| 1165 |
if (mask[i]) { |
| 1166 |
ptr[i] = GRAY_RGB( red[i], green[i], blue[i] ); |
| 1167 |
} |
| 1168 |
} |
| 1169 |
} |
| 1170 |
else { |
| 1171 |
/* draw all pixels */ |
| 1172 |
for (i=0;i<n;i++) { |
| 1173 |
ptr[i] = GRAY_RGB( red[i], green[i], blue[i] ); |
| 1174 |
} |
| 1175 |
} |
| 1176 |
} |
| 1177 |
|
| 1178 |
|
| 1179 |
|
| 1180 |
|
| 1181 |
/**********************************************************************/ |
| 1182 |
/*** Write COLOR PIXEL functions ***/ |
| 1183 |
/**********************************************************************/ |
| 1184 |
|
| 1185 |
|
| 1186 |
#define COLOR_PIXEL_ARGS GLcontext *ctx, \ |
| 1187 |
GLuint n, const GLint x[], const GLint y[], \ |
| 1188 |
const GLubyte red[], const GLubyte green[], \ |
| 1189 |
const GLubyte blue[], const GLubyte alpha[], \ |
| 1190 |
const GLubyte mask[] |
| 1191 |
|
| 1192 |
|
| 1193 |
/* |
| 1194 |
* Write an array of PF_TRUECOLOR pixels to a pixmap. |
| 1195 |
*/ |
| 1196 |
static void write_pixels_TRUECOLOR_pixmap( COLOR_PIXEL_ARGS ) |
| 1197 |
{ |
| 1198 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1199 |
Display *dpy = xmesa->xm_visual->display; |
| 1200 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1201 |
GC gc = xmesa->xm_buffer->gc2; |
| 1202 |
register GLuint i; |
| 1203 |
for (i=0;i<n;i++) { |
| 1204 |
if (mask[i]) { |
| 1205 |
XSetForeground( dpy, gc, PACK_RGB( red[i], green[i], blue[i] ) ); |
| 1206 |
XDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(y[i]) ); |
| 1207 |
} |
| 1208 |
} |
| 1209 |
} |
| 1210 |
|
| 1211 |
|
| 1212 |
/* |
| 1213 |
* Write an array of PF_8A8B8G8R pixels to a pixmap. |
| 1214 |
*/ |
| 1215 |
static void write_pixels_8A8B8G8R_pixmap( COLOR_PIXEL_ARGS ) |
| 1216 |
{ |
| 1217 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1218 |
Display *dpy = xmesa->xm_visual->display; |
| 1219 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1220 |
GC gc = xmesa->xm_buffer->gc2; |
| 1221 |
register GLuint i; |
| 1222 |
for (i=0;i<n;i++) { |
| 1223 |
if (mask[i]) { |
| 1224 |
XSetForeground( dpy, gc, |
| 1225 |
PACK_8A8B8G8R( red[i], green[i], blue[i], alpha[i] )); |
| 1226 |
XDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(y[i]) ); |
| 1227 |
} |
| 1228 |
} |
| 1229 |
} |
| 1230 |
|
| 1231 |
|
| 1232 |
/* |
| 1233 |
* Write an array of PF_8R8G8B pixels to a pixmap. |
| 1234 |
*/ |
| 1235 |
static void write_pixels_8R8G8B_pixmap( COLOR_PIXEL_ARGS ) |
| 1236 |
{ |
| 1237 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1238 |
Display *dpy = xmesa->xm_visual->display; |
| 1239 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1240 |
GC gc = xmesa->xm_buffer->gc2; |
| 1241 |
register GLuint i; |
| 1242 |
for (i=0;i<n;i++) { |
| 1243 |
if (mask[i]) { |
| 1244 |
XSetForeground( dpy, gc, PACK_8R8G8B( red[i], green[i], blue[i] ) ); |
| 1245 |
XDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(y[i]) ); |
| 1246 |
} |
| 1247 |
} |
| 1248 |
} |
| 1249 |
|
| 1250 |
|
| 1251 |
/* |
| 1252 |
* Write an array of PF_5R6G5B pixels to a pixmap. |
| 1253 |
*/ |
| 1254 |
static void write_pixels_5R6G5B_pixmap( COLOR_PIXEL_ARGS ) |
| 1255 |
{ |
| 1256 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1257 |
Display *dpy = xmesa->xm_visual->display; |
| 1258 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1259 |
GC gc = xmesa->xm_buffer->gc2; |
| 1260 |
register GLuint i; |
| 1261 |
for (i=0;i<n;i++) { |
| 1262 |
if (mask[i]) { |
| 1263 |
XSetForeground( dpy, gc, PACK_5R6G5B( red[i], green[i], blue[i] ) ); |
| 1264 |
XDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(y[i]) ); |
| 1265 |
} |
| 1266 |
} |
| 1267 |
} |
| 1268 |
|
| 1269 |
|
| 1270 |
/* |
| 1271 |
* Write an array of PF_DITHER pixels to a pixmap. |
| 1272 |
*/ |
| 1273 |
static void write_pixels_DITHER_pixmap( COLOR_PIXEL_ARGS ) |
| 1274 |
{ |
| 1275 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1276 |
Display *dpy = xmesa->xm_visual->display; |
| 1277 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1278 |
GC gc = xmesa->xm_buffer->gc2; |
| 1279 |
register GLuint i; |
| 1280 |
DITHER_SETUP; |
| 1281 |
for (i=0;i<n;i++) { |
| 1282 |
if (mask[i]) { |
| 1283 |
XSetForeground( dpy, gc, |
| 1284 |
DITHER(x[i], y[i], red[i], green[i], blue[i]) ); |
| 1285 |
XDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(y[i]) ); |
| 1286 |
} |
| 1287 |
} |
| 1288 |
} |
| 1289 |
|
| 1290 |
|
| 1291 |
/* |
| 1292 |
* Write an array of PF_1BIT pixels to a pixmap. |
| 1293 |
*/ |
| 1294 |
static void write_pixels_1BIT_pixmap( COLOR_PIXEL_ARGS ) |
| 1295 |
{ |
| 1296 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1297 |
Display *dpy = xmesa->xm_visual->display; |
| 1298 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1299 |
GC gc = xmesa->xm_buffer->gc2; |
| 1300 |
register GLuint i; |
| 1301 |
for (i=0;i<n;i++) { |
| 1302 |
if (mask[i]) { |
| 1303 |
XSetForeground( dpy, gc, |
| 1304 |
DITHER_1BIT( x[i], y[i], red[i], green[i], blue[i] )); |
| 1305 |
XDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(y[i]) ); |
| 1306 |
} |
| 1307 |
} |
| 1308 |
} |
| 1309 |
|
| 1310 |
|
| 1311 |
/* |
| 1312 |
* Write an array of PF_HPCR pixels to a pixmap. |
| 1313 |
*/ |
| 1314 |
static void write_pixels_HPCR_pixmap( COLOR_PIXEL_ARGS ) |
| 1315 |
{ |
| 1316 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1317 |
Display *dpy = xmesa->xm_visual->display; |
| 1318 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1319 |
GC gc = xmesa->xm_buffer->gc2; |
| 1320 |
register GLuint i; |
| 1321 |
for (i=0;i<n;i++) { |
| 1322 |
if (mask[i]) { |
| 1323 |
XSetForeground( dpy, gc, |
| 1324 |
DITHER_HPCR( x[i], y[i], red[i], green[i], blue[i] )); |
| 1325 |
XDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(y[i]) ); |
| 1326 |
} |
| 1327 |
} |
| 1328 |
} |
| 1329 |
|
| 1330 |
|
| 1331 |
/* |
| 1332 |
* Write an array of PF_LOOKUP pixels to a pixmap. |
| 1333 |
*/ |
| 1334 |
static void write_pixels_LOOKUP_pixmap( COLOR_PIXEL_ARGS ) |
| 1335 |
{ |
| 1336 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1337 |
Display *dpy = xmesa->xm_visual->display; |
| 1338 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1339 |
GC gc = xmesa->xm_buffer->gc2; |
| 1340 |
register GLuint i; |
| 1341 |
LOOKUP_SETUP; |
| 1342 |
for (i=0;i<n;i++) { |
| 1343 |
if (mask[i]) { |
| 1344 |
XSetForeground( dpy, gc, LOOKUP( red[i], green[i], blue[i] ) ); |
| 1345 |
XDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(y[i]) ); |
| 1346 |
} |
| 1347 |
} |
| 1348 |
} |
| 1349 |
|
| 1350 |
|
| 1351 |
/* |
| 1352 |
* Write an array of PF_GRAYSCALE pixels to a pixmap. |
| 1353 |
*/ |
| 1354 |
static void write_pixels_GRAYSCALE_pixmap( COLOR_PIXEL_ARGS ) |
| 1355 |
{ |
| 1356 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1357 |
Display *dpy = xmesa->xm_visual->display; |
| 1358 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1359 |
GC gc = xmesa->xm_buffer->gc2; |
| 1360 |
register GLuint i; |
| 1361 |
for (i=0;i<n;i++) { |
| 1362 |
if (mask[i]) { |
| 1363 |
XSetForeground( dpy, gc, GRAY_RGB( red[i], green[i], blue[i] ) ); |
| 1364 |
XDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(y[i]) ); |
| 1365 |
} |
| 1366 |
} |
| 1367 |
} |
| 1368 |
|
| 1369 |
|
| 1370 |
/* |
| 1371 |
* Write an array of PF_TRUECOLOR pixels to an ximage. |
| 1372 |
*/ |
| 1373 |
static void write_pixels_TRUECOLOR_ximage( COLOR_PIXEL_ARGS ) |
| 1374 |
{ |
| 1375 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1376 |
XImage *img = xmesa->xm_buffer->backimage; |
| 1377 |
register GLuint i; |
| 1378 |
for (i=0;i<n;i++) { |
| 1379 |
if (mask[i]) { |
| 1380 |
XPutPixel( img, x[i], FLIP(y[i]), |
| 1381 |
PACK_RGB( red[i], green[i], blue[i] ) ); |
| 1382 |
} |
| 1383 |
} |
| 1384 |
} |
| 1385 |
|
| 1386 |
|
| 1387 |
/* |
| 1388 |
* Write an array of PF_8A8B8G8R pixels to an ximage. |
| 1389 |
*/ |
| 1390 |
static void write_pixels_8A8B8G8R_ximage( COLOR_PIXEL_ARGS ) |
| 1391 |
{ |
| 1392 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1393 |
register GLuint i; |
| 1394 |
for (i=0;i<n;i++) { |
| 1395 |
if (mask[i]) { |
| 1396 |
GLuint *ptr = PIXELADDR4( x[i], y[i] ); |
| 1397 |
*ptr = PACK_8A8B8G8R( red[i], green[i], blue[i], alpha[i] ); |
| 1398 |
} |
| 1399 |
} |
| 1400 |
} |
| 1401 |
|
| 1402 |
|
| 1403 |
/* |
| 1404 |
* Write an array of PF_8R8G8B pixels to an ximage. |
| 1405 |
*/ |
| 1406 |
static void write_pixels_8R8G8B_ximage( COLOR_PIXEL_ARGS ) |
| 1407 |
{ |
| 1408 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1409 |
register GLuint i; |
| 1410 |
for (i=0;i<n;i++) { |
| 1411 |
if (mask[i]) { |
| 1412 |
GLuint *ptr = PIXELADDR4( x[i], y[i] ); |
| 1413 |
*ptr = PACK_8R8G8B( red[i], green[i], blue[i] ); |
| 1414 |
} |
| 1415 |
} |
| 1416 |
} |
| 1417 |
|
| 1418 |
|
| 1419 |
/* |
| 1420 |
* Write an array of PF_5R6G5B pixels to an ximage. |
| 1421 |
*/ |
| 1422 |
static void write_pixels_5R6G5B_ximage( COLOR_PIXEL_ARGS ) |
| 1423 |
{ |
| 1424 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1425 |
register GLuint i; |
| 1426 |
for (i=0;i<n;i++) { |
| 1427 |
if (mask[i]) { |
| 1428 |
GLushort *ptr = PIXELADDR2( x[i], y[i] ); |
| 1429 |
*ptr = PACK_5R6G5B( red[i], green[i], blue[i] ); |
| 1430 |
} |
| 1431 |
} |
| 1432 |
} |
| 1433 |
|
| 1434 |
|
| 1435 |
/* |
| 1436 |
* Write an array of PF_DITHER pixels to an XImage. |
| 1437 |
*/ |
| 1438 |
static void write_pixels_DITHER_ximage( COLOR_PIXEL_ARGS ) |
| 1439 |
{ |
| 1440 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1441 |
XImage *img = xmesa->xm_buffer->backimage; |
| 1442 |
register GLuint i; |
| 1443 |
DITHER_SETUP; |
| 1444 |
for (i=0;i<n;i++) { |
| 1445 |
if (mask[i]) { |
| 1446 |
XPutPixel( img, x[i], FLIP(y[i]), |
| 1447 |
DITHER( x[i], y[i], red[i], green[i], blue[i] ) ); |
| 1448 |
} |
| 1449 |
} |
| 1450 |
} |
| 1451 |
|
| 1452 |
|
| 1453 |
/* |
| 1454 |
* Write an array of 8-bit PF_DITHER pixels to an XImage. |
| 1455 |
*/ |
| 1456 |
static void write_pixels_DITHER8_ximage( COLOR_PIXEL_ARGS ) |
| 1457 |
{ |
| 1458 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1459 |
register GLuint i; |
| 1460 |
DITHER_SETUP; |
| 1461 |
for (i=0;i<n;i++) { |
| 1462 |
if (mask[i]) { |
| 1463 |
GLubyte *ptr = PIXELADDR1(x[i],y[i]); |
| 1464 |
*ptr = DITHER( x[i], y[i], red[i], green[i], blue[i] ); |
| 1465 |
} |
| 1466 |
} |
| 1467 |
} |
| 1468 |
|
| 1469 |
|
| 1470 |
/* |
| 1471 |
* Write an array of PF_1BIT pixels to an XImage. |
| 1472 |
*/ |
| 1473 |
static void write_pixels_1BIT_ximage( COLOR_PIXEL_ARGS ) |
| 1474 |
{ |
| 1475 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1476 |
XImage *img = xmesa->xm_buffer->backimage; |
| 1477 |
register GLuint i; |
| 1478 |
for (i=0;i<n;i++) { |
| 1479 |
if (mask[i]) { |
| 1480 |
XPutPixel( img, x[i], FLIP(y[i]), |
| 1481 |
DITHER_1BIT( x[i], y[i], red[i], green[i], blue[i] )); |
| 1482 |
} |
| 1483 |
} |
| 1484 |
} |
| 1485 |
|
| 1486 |
|
| 1487 |
/* |
| 1488 |
* Write an array of PF_HPCR pixels to an XImage. |
| 1489 |
*/ |
| 1490 |
static void write_pixels_HPCR_ximage( COLOR_PIXEL_ARGS ) |
| 1491 |
{ |
| 1492 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1493 |
register GLuint i; |
| 1494 |
for (i=0;i<n;i++) { |
| 1495 |
if (mask[i]) { |
| 1496 |
GLubyte *ptr = PIXELADDR1(x[i],y[i]); |
| 1497 |
*ptr = DITHER_HPCR( x[i], y[i], red[i], green[i], blue[i] ); |
| 1498 |
} |
| 1499 |
} |
| 1500 |
} |
| 1501 |
|
| 1502 |
|
| 1503 |
/* |
| 1504 |
* Write an array of PF_LOOKUP pixels to an XImage. |
| 1505 |
*/ |
| 1506 |
static void write_pixels_LOOKUP_ximage( COLOR_PIXEL_ARGS ) |
| 1507 |
{ |
| 1508 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1509 |
XImage *img = xmesa->xm_buffer->backimage; |
| 1510 |
register GLuint i; |
| 1511 |
LOOKUP_SETUP; |
| 1512 |
for (i=0;i<n;i++) { |
| 1513 |
if (mask[i]) { |
| 1514 |
XPutPixel( img, x[i], FLIP(y[i]), LOOKUP(red[i], green[i], blue[i]) ); |
| 1515 |
} |
| 1516 |
} |
| 1517 |
} |
| 1518 |
|
| 1519 |
|
| 1520 |
/* |
| 1521 |
* Write an array of 8-bit PF_LOOKUP pixels to an XImage. |
| 1522 |
*/ |
| 1523 |
static void write_pixels_LOOKUP8_ximage( COLOR_PIXEL_ARGS ) |
| 1524 |
{ |
| 1525 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1526 |
register GLuint i; |
| 1527 |
LOOKUP_SETUP; |
| 1528 |
for (i=0;i<n;i++) { |
| 1529 |
if (mask[i]) { |
| 1530 |
GLubyte *ptr = PIXELADDR1(x[i],y[i]); |
| 1531 |
*ptr = LOOKUP( red[i], green[i], blue[i] ); |
| 1532 |
} |
| 1533 |
} |
| 1534 |
} |
| 1535 |
|
| 1536 |
|
| 1537 |
/* |
| 1538 |
* Write an array of PF_GRAYSCALE pixels to an XImage. |
| 1539 |
*/ |
| 1540 |
static void write_pixels_GRAYSCALE_ximage( COLOR_PIXEL_ARGS ) |
| 1541 |
{ |
| 1542 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1543 |
XImage *img = xmesa->xm_buffer->backimage; |
| 1544 |
register GLuint i; |
| 1545 |
for (i=0;i<n;i++) { |
| 1546 |
if (mask[i]) { |
| 1547 |
XPutPixel( img, x[i], FLIP(y[i]), |
| 1548 |
GRAY_RGB( red[i], green[i], blue[i] ) ); |
| 1549 |
} |
| 1550 |
} |
| 1551 |
} |
| 1552 |
|
| 1553 |
|
| 1554 |
/* |
| 1555 |
* Write an array of 8-bit PF_GRAYSCALE pixels to an XImage. |
| 1556 |
*/ |
| 1557 |
static void write_pixels_GRAYSCALE8_ximage( COLOR_PIXEL_ARGS ) |
| 1558 |
{ |
| 1559 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1560 |
register GLuint i; |
| 1561 |
for (i=0;i<n;i++) { |
| 1562 |
if (mask[i]) { |
| 1563 |
GLubyte *ptr = PIXELADDR1( x[i], y[i] ); |
| 1564 |
*ptr = GRAY_RGB( red[i], green[i], blue[i] ); |
| 1565 |
} |
| 1566 |
} |
| 1567 |
} |
| 1568 |
|
| 1569 |
|
| 1570 |
|
| 1571 |
|
| 1572 |
/**********************************************************************/ |
| 1573 |
/*** Write MONO COLOR SPAN functions ***/ |
| 1574 |
/**********************************************************************/ |
| 1575 |
|
| 1576 |
#define MONO_SPAN_ARGS GLcontext *ctx, \ |
| 1577 |
GLuint n, GLint x, GLint y, const GLubyte mask[] |
| 1578 |
|
| 1579 |
|
| 1580 |
/* |
| 1581 |
* Write a span of identical pixels to a pixmap. The pixel value is |
| 1582 |
* the one set by DD.color() or DD.index(). |
| 1583 |
*/ |
| 1584 |
static void write_span_mono_pixmap( MONO_SPAN_ARGS ) |
| 1585 |
{ |
| 1586 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1587 |
Display *dpy = xmesa->xm_visual->display; |
| 1588 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1589 |
GC gc = xmesa->xm_buffer->gc1; |
| 1590 |
register GLuint i; |
| 1591 |
register GLboolean write_all; |
| 1592 |
y = FLIP( y ); |
| 1593 |
write_all = GL_TRUE; |
| 1594 |
for (i=0;i<n;i++) { |
| 1595 |
if (!mask[i]) { |
| 1596 |
write_all = GL_FALSE; |
| 1597 |
break; |
| 1598 |
} |
| 1599 |
} |
| 1600 |
if (write_all) { |
| 1601 |
XFillRectangle( dpy, buffer, gc, (int) x, (int) y, n, 1 ); |
| 1602 |
} |
| 1603 |
else { |
| 1604 |
for (i=0;i<n;i++,x++) { |
| 1605 |
if (mask[i]) { |
| 1606 |
XDrawPoint( dpy, buffer, gc, (int) x, (int) y ); |
| 1607 |
} |
| 1608 |
} |
| 1609 |
} |
| 1610 |
} |
| 1611 |
|
| 1612 |
|
| 1613 |
/* |
| 1614 |
* Write a span of PF_DITHER pixels to a pixmap. The pixel value is |
| 1615 |
* the one set by DD.color() or DD.index(). |
| 1616 |
*/ |
| 1617 |
static void write_span_mono_DITHER_pixmap( MONO_SPAN_ARGS ) |
| 1618 |
{ |
| 1619 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1620 |
Display *dpy = xmesa->xm_visual->display; |
| 1621 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1622 |
GC gc = xmesa->xm_buffer->gc2; |
| 1623 |
register GLuint i; |
| 1624 |
register GLubyte r, g, b; |
| 1625 |
int yy = FLIP( y ); |
| 1626 |
XDITHER_SETUP(yy); |
| 1627 |
r = xmesa->red; |
| 1628 |
g = xmesa->green; |
| 1629 |
b = xmesa->blue; |
| 1630 |
for (i=0;i<n;i++,x++) { |
| 1631 |
if (mask[i]) { |
| 1632 |
XSetForeground( dpy, gc, XDITHER( x, r, g, b ) ); |
| 1633 |
XDrawPoint( dpy, buffer, gc, (int) x, (int) yy ); |
| 1634 |
} |
| 1635 |
} |
| 1636 |
} |
| 1637 |
|
| 1638 |
|
| 1639 |
/* |
| 1640 |
* Write a span of PF_1BIT pixels to a pixmap. The pixel value is |
| 1641 |
* the one set by DD.color() or DD.index(). |
| 1642 |
*/ |
| 1643 |
static void write_span_mono_1BIT_pixmap( MONO_SPAN_ARGS ) |
| 1644 |
{ |
| 1645 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1646 |
Display *dpy = xmesa->xm_visual->display; |
| 1647 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1648 |
GC gc = xmesa->xm_buffer->gc2; |
| 1649 |
register GLuint i; |
| 1650 |
register GLubyte r, g, b; |
| 1651 |
r = xmesa->red; |
| 1652 |
g = xmesa->green; |
| 1653 |
b = xmesa->blue; |
| 1654 |
y = FLIP( y ); |
| 1655 |
for (i=0;i<n;i++,x++) { |
| 1656 |
if (mask[i]) { |
| 1657 |
XSetForeground( dpy, gc, DITHER_1BIT( x, y, r, g, b ) ); |
| 1658 |
XDrawPoint( dpy, buffer, gc, (int) x, (int) y ); |
| 1659 |
} |
| 1660 |
} |
| 1661 |
} |
| 1662 |
|
| 1663 |
|
| 1664 |
/* |
| 1665 |
* Write a span of identical pixels to an XImage. The pixel value is |
| 1666 |
* the one set by DD.color() or DD.index(). |
| 1667 |
*/ |
| 1668 |
static void write_span_mono_ximage( MONO_SPAN_ARGS ) |
| 1669 |
{ |
| 1670 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1671 |
XImage *img = xmesa->xm_buffer->backimage; |
| 1672 |
register GLuint i; |
| 1673 |
register unsigned long p = xmesa->pixel; |
| 1674 |
y = FLIP( y ); |
| 1675 |
for (i=0;i<n;i++,x++) { |
| 1676 |
if (mask[i]) { |
| 1677 |
XPutPixel( img, x, y, p ); |
| 1678 |
} |
| 1679 |
} |
| 1680 |
} |
| 1681 |
|
| 1682 |
|
| 1683 |
/* |
| 1684 |
* Write a span of identical 8A8B8G8R pixels to an XImage. The pixel |
| 1685 |
* value is the one set by DD.color(). |
| 1686 |
*/ |
| 1687 |
static void write_span_mono_8A8B8G8R_ximage( MONO_SPAN_ARGS ) |
| 1688 |
{ |
| 1689 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1690 |
GLuint i, p, *ptr; |
| 1691 |
p = (GLuint) xmesa->pixel; |
| 1692 |
ptr = PIXELADDR4( x, y ); |
| 1693 |
for (i=0;i<n;i++) { |
| 1694 |
if (mask[i]) { |
| 1695 |
ptr[i] = p; |
| 1696 |
} |
| 1697 |
} |
| 1698 |
} |
| 1699 |
|
| 1700 |
|
| 1701 |
/* |
| 1702 |
* Write a span of identical 8R8G8B pixels to an XImage. The pixel |
| 1703 |
* value is the one set by DD.color(). |
| 1704 |
*/ |
| 1705 |
static void write_span_mono_8R8G8B_ximage( MONO_SPAN_ARGS ) |
| 1706 |
{ |
| 1707 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1708 |
GLuint i, p, *ptr; |
| 1709 |
p = (GLuint) xmesa->pixel; |
| 1710 |
ptr = PIXELADDR4( x, y ); |
| 1711 |
for (i=0;i<n;i++) { |
| 1712 |
if (mask[i]) { |
| 1713 |
ptr[i] = p; |
| 1714 |
} |
| 1715 |
} |
| 1716 |
} |
| 1717 |
|
| 1718 |
|
| 1719 |
/* |
| 1720 |
* Write a span of identical DITHER pixels to an XImage. The pixel |
| 1721 |
* value is the one set by DD.color(). |
| 1722 |
*/ |
| 1723 |
static void write_span_mono_DITHER_ximage( MONO_SPAN_ARGS ) |
| 1724 |
{ |
| 1725 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1726 |
XImage *img = xmesa->xm_buffer->backimage; |
| 1727 |
register GLuint i; |
| 1728 |
register GLubyte r, g, b; |
| 1729 |
int yy = FLIP(y); |
| 1730 |
XDITHER_SETUP(yy); |
| 1731 |
r = xmesa->red; |
| 1732 |
g = xmesa->green; |
| 1733 |
b = xmesa->blue; |
| 1734 |
for (i=0;i<n;i++,x++) { |
| 1735 |
if (mask[i]) { |
| 1736 |
XPutPixel( img, x, yy, XDITHER( x, r, g, b ) ); |
| 1737 |
} |
| 1738 |
} |
| 1739 |
} |
| 1740 |
|
| 1741 |
|
| 1742 |
/* |
| 1743 |
* Write a span of identical 8-bit DITHER pixels to an XImage. The pixel |
| 1744 |
* value is the one set by DD.color(). |
| 1745 |
*/ |
| 1746 |
static void write_span_mono_DITHER8_ximage( MONO_SPAN_ARGS ) |
| 1747 |
{ |
| 1748 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1749 |
register GLuint i; |
| 1750 |
register GLubyte *ptr = PIXELADDR1(x,y); |
| 1751 |
register GLubyte r, g, b; |
| 1752 |
XDITHER_SETUP(y); |
| 1753 |
r = xmesa->red; |
| 1754 |
g = xmesa->green; |
| 1755 |
b = xmesa->blue; |
| 1756 |
for (i=0;i<n;i++,x++) { |
| 1757 |
if (mask[i]) { |
| 1758 |
ptr[i] = XDITHER( x, r, g, b ); |
| 1759 |
} |
| 1760 |
} |
| 1761 |
} |
| 1762 |
|
| 1763 |
|
| 1764 |
/* |
| 1765 |
* Write a span of identical 8-bit LOOKUP pixels to an XImage. The pixel |
| 1766 |
* value is the one set by DD.color(). |
| 1767 |
*/ |
| 1768 |
static void write_span_mono_LOOKUP8_ximage( MONO_SPAN_ARGS ) |
| 1769 |
{ |
| 1770 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1771 |
register GLuint i; |
| 1772 |
register GLubyte *ptr = PIXELADDR1(x,y); |
| 1773 |
register GLubyte pixel = xmesa->pixel; |
| 1774 |
for (i=0;i<n;i++) { |
| 1775 |
if (mask[i]) { |
| 1776 |
ptr[i] = pixel; |
| 1777 |
} |
| 1778 |
} |
| 1779 |
} |
| 1780 |
|
| 1781 |
|
| 1782 |
/* |
| 1783 |
* Write a span of identical PF_1BIT pixels to an XImage. The pixel |
| 1784 |
* value is the one set by DD.color(). |
| 1785 |
*/ |
| 1786 |
static void write_span_mono_1BIT_ximage( MONO_SPAN_ARGS ) |
| 1787 |
{ |
| 1788 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1789 |
XImage *img = xmesa->xm_buffer->backimage; |
| 1790 |
register GLuint i; |
| 1791 |
register GLubyte r, g, b; |
| 1792 |
r = xmesa->red; |
| 1793 |
g = xmesa->green; |
| 1794 |
b = xmesa->blue; |
| 1795 |
y = FLIP(y); |
| 1796 |
for (i=0;i<n;i++,x++) { |
| 1797 |
if (mask[i]) { |
| 1798 |
XPutPixel( img, x, y, DITHER_1BIT( x, y, r, g, b ) ); |
| 1799 |
} |
| 1800 |
} |
| 1801 |
} |
| 1802 |
|
| 1803 |
|
| 1804 |
/* |
| 1805 |
* Write a span of identical HPCR pixels to an XImage. The pixel |
| 1806 |
* value is the one set by DD.color(). |
| 1807 |
*/ |
| 1808 |
static void write_span_mono_HPCR_ximage( MONO_SPAN_ARGS ) |
| 1809 |
{ |
| 1810 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1811 |
register GLuint i; |
| 1812 |
register GLubyte *ptr = PIXELADDR1(x,y); |
| 1813 |
register GLubyte r, g, b; |
| 1814 |
r = xmesa->red; |
| 1815 |
g = xmesa->green; |
| 1816 |
b = xmesa->blue; |
| 1817 |
for (i=0;i<n;i++,x++) { |
| 1818 |
if (mask[i]) { |
| 1819 |
ptr[i] = DITHER_HPCR( x, y, r, g, b ); |
| 1820 |
} |
| 1821 |
} |
| 1822 |
} |
| 1823 |
|
| 1824 |
|
| 1825 |
|
| 1826 |
/* |
| 1827 |
* Write a span of identical 8-bit GRAYSCALE pixels to an XImage. The pixel |
| 1828 |
* value is the one set by DD.color(). |
| 1829 |
*/ |
| 1830 |
static void write_span_mono_GRAYSCALE8_ximage( MONO_SPAN_ARGS ) |
| 1831 |
{ |
| 1832 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1833 |
GLuint i; |
| 1834 |
unsigned long p = xmesa->pixel; |
| 1835 |
GLubyte *ptr = PIXELADDR1(x,y); |
| 1836 |
for (i=0;i<n;i++) { |
| 1837 |
if (mask[i]) { |
| 1838 |
ptr[i] = p; |
| 1839 |
} |
| 1840 |
} |
| 1841 |
} |
| 1842 |
|
| 1843 |
|
| 1844 |
|
| 1845 |
|
| 1846 |
/**********************************************************************/ |
| 1847 |
/*** Write MONO COLOR PIXELS functions ***/ |
| 1848 |
/**********************************************************************/ |
| 1849 |
|
| 1850 |
#define MONO_PIXEL_ARGS GLcontext *ctx, \ |
| 1851 |
GLuint n, const GLint x[], const GLint y[], \ |
| 1852 |
const GLubyte mask[] |
| 1853 |
|
| 1854 |
/* |
| 1855 |
* Write an array of identical pixels to a pixmap. The pixel value is |
| 1856 |
* the one set by DD.color() or DD.index. |
| 1857 |
*/ |
| 1858 |
static void write_pixels_mono_pixmap( MONO_PIXEL_ARGS ) |
| 1859 |
{ |
| 1860 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1861 |
Display *dpy = xmesa->xm_visual->display; |
| 1862 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1863 |
GC gc = xmesa->xm_buffer->gc1; |
| 1864 |
register GLuint i; |
| 1865 |
for (i=0;i<n;i++) { |
| 1866 |
if (mask[i]) { |
| 1867 |
XDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(y[i]) ); |
| 1868 |
} |
| 1869 |
} |
| 1870 |
} |
| 1871 |
|
| 1872 |
|
| 1873 |
/* |
| 1874 |
* Write an array of PF_DITHER pixels to a pixmap. The pixel value is |
| 1875 |
* the one set by DD.color() or DD.index. |
| 1876 |
*/ |
| 1877 |
static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS ) |
| 1878 |
{ |
| 1879 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1880 |
Display *dpy = xmesa->xm_visual->display; |
| 1881 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1882 |
GC gc = xmesa->xm_buffer->gc2; |
| 1883 |
register GLuint i; |
| 1884 |
register GLubyte r, g, b; |
| 1885 |
DITHER_SETUP; |
| 1886 |
r = xmesa->red; |
| 1887 |
g = xmesa->green; |
| 1888 |
b = xmesa->blue; |
| 1889 |
for (i=0;i<n;i++) { |
| 1890 |
if (mask[i]) { |
| 1891 |
XSetForeground( dpy, gc, DITHER( x[i], y[i], r, g, b ) ); |
| 1892 |
XDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(y[i]) ); |
| 1893 |
} |
| 1894 |
} |
| 1895 |
} |
| 1896 |
|
| 1897 |
|
| 1898 |
/* |
| 1899 |
* Write an array of PF_1BIT pixels to a pixmap. The pixel value is |
| 1900 |
* the one set by DD.color() or DD.index. |
| 1901 |
*/ |
| 1902 |
static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS ) |
| 1903 |
{ |
| 1904 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1905 |
Display *dpy = xmesa->xm_visual->display; |
| 1906 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 1907 |
GC gc = xmesa->xm_buffer->gc2; |
| 1908 |
register GLuint i; |
| 1909 |
register GLubyte r, g, b; |
| 1910 |
r = xmesa->red; |
| 1911 |
g = xmesa->green; |
| 1912 |
b = xmesa->blue; |
| 1913 |
for (i=0;i<n;i++) { |
| 1914 |
if (mask[i]) { |
| 1915 |
XSetForeground( dpy, gc, DITHER_1BIT( x[i], y[i], r, g, b ) ); |
| 1916 |
XDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(y[i]) ); |
| 1917 |
} |
| 1918 |
} |
| 1919 |
} |
| 1920 |
|
| 1921 |
|
| 1922 |
/* |
| 1923 |
* Write an array of identical pixels to an XImage. The pixel value is |
| 1924 |
* the one set by DD.color() or DD.index. |
| 1925 |
*/ |
| 1926 |
static void write_pixels_mono_ximage( MONO_PIXEL_ARGS ) |
| 1927 |
{ |
| 1928 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1929 |
XImage *img = xmesa->xm_buffer->backimage; |
| 1930 |
register GLuint i; |
| 1931 |
register unsigned long p = xmesa->pixel; |
| 1932 |
for (i=0;i<n;i++) { |
| 1933 |
if (mask[i]) { |
| 1934 |
XPutPixel( img, x[i], FLIP(y[i]), p ); |
| 1935 |
} |
| 1936 |
} |
| 1937 |
} |
| 1938 |
|
| 1939 |
|
| 1940 |
|
| 1941 |
/* |
| 1942 |
* Write an array of identical 8A8B8G8R pixels to an XImage. The pixel value |
| 1943 |
* is the one set by DD.color(). |
| 1944 |
*/ |
| 1945 |
static void write_pixels_mono_8A8B8G8R_ximage( MONO_PIXEL_ARGS ) |
| 1946 |
{ |
| 1947 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1948 |
register GLuint i; |
| 1949 |
register GLuint p = (GLuint) xmesa->pixel; |
| 1950 |
for (i=0;i<n;i++) { |
| 1951 |
if (mask[i]) { |
| 1952 |
GLuint *ptr = PIXELADDR4( x[i], y[i] ); |
| 1953 |
*ptr = p; |
| 1954 |
} |
| 1955 |
} |
| 1956 |
} |
| 1957 |
|
| 1958 |
|
| 1959 |
/* |
| 1960 |
* Write an array of identical 8R8G8B pixels to an XImage. The pixel value |
| 1961 |
* is the one set by DD.color(). |
| 1962 |
*/ |
| 1963 |
static void write_pixels_mono_8R8G8B_ximage( MONO_PIXEL_ARGS ) |
| 1964 |
{ |
| 1965 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1966 |
register GLuint i; |
| 1967 |
register GLuint p = (GLuint) xmesa->pixel; |
| 1968 |
for (i=0;i<n;i++) { |
| 1969 |
if (mask[i]) { |
| 1970 |
GLuint *ptr = PIXELADDR4( x[i], y[i] ); |
| 1971 |
*ptr = p; |
| 1972 |
} |
| 1973 |
} |
| 1974 |
} |
| 1975 |
|
| 1976 |
|
| 1977 |
/* |
| 1978 |
* Write an array of identical PF_DITHER pixels to an XImage. The pixel |
| 1979 |
* value is the one set by DD.color(). |
| 1980 |
*/ |
| 1981 |
static void write_pixels_mono_DITHER_ximage( MONO_PIXEL_ARGS ) |
| 1982 |
{ |
| 1983 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 1984 |
XImage *img = xmesa->xm_buffer->backimage; |
| 1985 |
register GLuint i; |
| 1986 |
register GLubyte r, g, b; |
| 1987 |
DITHER_SETUP; |
| 1988 |
r = xmesa->red; |
| 1989 |
g = xmesa->green; |
| 1990 |
b = xmesa->blue; |
| 1991 |
for (i=0;i<n;i++) { |
| 1992 |
if (mask[i]) { |
| 1993 |
XPutPixel( img, x[i], FLIP(y[i]), DITHER( x[i], y[i], r, g, b ) ); |
| 1994 |
} |
| 1995 |
} |
| 1996 |
} |
| 1997 |
|
| 1998 |
|
| 1999 |
/* |
| 2000 |
* Write an array of identical 8-bit PF_DITHER pixels to an XImage. The |
| 2001 |
* pixel value is the one set by DD.color(). |
| 2002 |
*/ |
| 2003 |
static void write_pixels_mono_DITHER8_ximage( MONO_PIXEL_ARGS ) |
| 2004 |
{ |
| 2005 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 2006 |
register GLuint i; |
| 2007 |
register GLubyte r, g, b; |
| 2008 |
DITHER_SETUP; |
| 2009 |
r = xmesa->red; |
| 2010 |
g = xmesa->green; |
| 2011 |
b = xmesa->blue; |
| 2012 |
for (i=0;i<n;i++) { |
| 2013 |
if (mask[i]) { |
| 2014 |
GLubyte *ptr = PIXELADDR1(x[i],y[i]); |
| 2015 |
*ptr = DITHER( x[i], y[i], r, g, b ); |
| 2016 |
} |
| 2017 |
} |
| 2018 |
} |
| 2019 |
|
| 2020 |
|
| 2021 |
/* |
| 2022 |
* Write an array of identical 8-bit PF_LOOKUP pixels to an XImage. The |
| 2023 |
* pixel value is the one set by DD.color(). |
| 2024 |
*/ |
| 2025 |
static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS ) |
| 2026 |
{ |
| 2027 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 2028 |
register GLuint i; |
| 2029 |
register GLubyte pixel = xmesa->pixel; |
| 2030 |
for (i=0;i<n;i++) { |
| 2031 |
if (mask[i]) { |
| 2032 |
GLubyte *ptr = PIXELADDR1(x[i],y[i]); |
| 2033 |
*ptr = pixel; |
| 2034 |
} |
| 2035 |
} |
| 2036 |
} |
| 2037 |
|
| 2038 |
|
| 2039 |
|
| 2040 |
/* |
| 2041 |
* Write an array of identical PF_1BIT pixels to an XImage. The pixel |
| 2042 |
* value is the one set by DD.color(). |
| 2043 |
*/ |
| 2044 |
static void write_pixels_mono_1BIT_ximage( MONO_PIXEL_ARGS ) |
| 2045 |
{ |
| 2046 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 2047 |
XImage *img = xmesa->xm_buffer->backimage; |
| 2048 |
register GLuint i; |
| 2049 |
register GLubyte r, g, b; |
| 2050 |
r = xmesa->red; |
| 2051 |
g = xmesa->green; |
| 2052 |
b = xmesa->blue; |
| 2053 |
for (i=0;i<n;i++) { |
| 2054 |
if (mask[i]) { |
| 2055 |
XPutPixel( img, x[i], FLIP(y[i]), DITHER_1BIT( x[i], y[i], r, g, b )); |
| 2056 |
} |
| 2057 |
} |
| 2058 |
} |
| 2059 |
|
| 2060 |
|
| 2061 |
/* |
| 2062 |
* Write an array of identical PF_HPCR pixels to an XImage. The |
| 2063 |
* pixel value is the one set by DD.color(). |
| 2064 |
*/ |
| 2065 |
static void write_pixels_mono_HPCR_ximage( MONO_PIXEL_ARGS ) |
| 2066 |
{ |
| 2067 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 2068 |
register GLuint i; |
| 2069 |
register GLubyte r, g, b; |
| 2070 |
r = xmesa->red; |
| 2071 |
g = xmesa->green; |
| 2072 |
b = xmesa->blue; |
| 2073 |
for (i=0;i<n;i++) { |
| 2074 |
if (mask[i]) { |
| 2075 |
GLubyte *ptr = PIXELADDR1(x[i],y[i]); |
| 2076 |
*ptr = DITHER_HPCR( x[i], y[i], r, g, b ); |
| 2077 |
} |
| 2078 |
} |
| 2079 |
} |
| 2080 |
|
| 2081 |
|
| 2082 |
/* |
| 2083 |
* Write an array of identical 8-bit PF_GRAYSCALE pixels to an XImage. The |
| 2084 |
* pixel value is the one set by DD.color(). |
| 2085 |
*/ |
| 2086 |
static void write_pixels_mono_GRAYSCALE8_ximage( MONO_PIXEL_ARGS ) |
| 2087 |
{ |
| 2088 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 2089 |
register GLuint i; |
| 2090 |
register unsigned long p = xmesa->pixel; |
| 2091 |
for (i=0;i<n;i++) { |
| 2092 |
if (mask[i]) { |
| 2093 |
GLubyte *ptr = PIXELADDR1(x[i],y[i]); |
| 2094 |
*ptr = p; |
| 2095 |
} |
| 2096 |
} |
| 2097 |
} |
| 2098 |
|
| 2099 |
|
| 2100 |
|
| 2101 |
|
| 2102 |
/**********************************************************************/ |
| 2103 |
/*** Write INDEX SPAN functions ***/ |
| 2104 |
/**********************************************************************/ |
| 2105 |
|
| 2106 |
#define INDEX_SPAN_ARGS GLcontext *ctx, \ |
| 2107 |
GLuint n, GLint x, GLint y, const GLuint index[], \ |
| 2108 |
const GLubyte mask[] |
| 2109 |
|
| 2110 |
|
| 2111 |
/* |
| 2112 |
* Write a span of CI pixels to a Pixmap. |
| 2113 |
*/ |
| 2114 |
static void write_span_index_pixmap( INDEX_SPAN_ARGS ) |
| 2115 |
{ |
| 2116 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 2117 |
Display *dpy = xmesa->xm_visual->display; |
| 2118 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 2119 |
GC gc = xmesa->xm_buffer->gc2; |
| 2120 |
register GLuint i; |
| 2121 |
y = FLIP(y); |
| 2122 |
for (i=0;i<n;i++,x++) { |
| 2123 |
if (mask[i]) { |
| 2124 |
XSetForeground( dpy, gc, (unsigned long) index[i] ); |
| 2125 |
XDrawPoint( dpy, buffer, gc, (int) x, (int) y ); |
| 2126 |
} |
| 2127 |
} |
| 2128 |
} |
| 2129 |
|
| 2130 |
|
| 2131 |
/* |
| 2132 |
* Write a span of CI pixels to an XImage. |
| 2133 |
*/ |
| 2134 |
static void write_span_index_ximage( INDEX_SPAN_ARGS ) |
| 2135 |
{ |
| 2136 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 2137 |
XImage *img = xmesa->xm_buffer->backimage; |
| 2138 |
register GLuint i; |
| 2139 |
y = FLIP(y); |
| 2140 |
for (i=0;i<n;i++,x++) { |
| 2141 |
if (mask[i]) { |
| 2142 |
XPutPixel( img, x, y, (unsigned long) index[i] ); |
| 2143 |
} |
| 2144 |
} |
| 2145 |
} |
| 2146 |
|
| 2147 |
|
| 2148 |
|
| 2149 |
/**********************************************************************/ |
| 2150 |
/*** Write INDEX PIXELS functions ***/ |
| 2151 |
/**********************************************************************/ |
| 2152 |
|
| 2153 |
#define INDEX_PIXELS_ARGS GLcontext *ctx, \ |
| 2154 |
GLuint n, const GLint x[], const GLint y[], \ |
| 2155 |
const GLuint index[], const GLubyte mask[] |
| 2156 |
|
| 2157 |
|
| 2158 |
/* |
| 2159 |
* Write an array of CI pixels to a Pixmap. |
| 2160 |
*/ |
| 2161 |
static void write_pixels_index_pixmap( INDEX_PIXELS_ARGS ) |
| 2162 |
{ |
| 2163 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 2164 |
Display *dpy = xmesa->xm_visual->display; |
| 2165 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 2166 |
GC gc = xmesa->xm_buffer->gc2; |
| 2167 |
register GLuint i; |
| 2168 |
for (i=0;i<n;i++) { |
| 2169 |
if (mask[i]) { |
| 2170 |
XSetForeground( dpy, gc, (unsigned long) index[i] ); |
| 2171 |
XDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(y[i]) ); |
| 2172 |
} |
| 2173 |
} |
| 2174 |
} |
| 2175 |
|
| 2176 |
|
| 2177 |
/* |
| 2178 |
* Write an array of CI pixels to an XImage. |
| 2179 |
*/ |
| 2180 |
static void write_pixels_index_ximage( INDEX_PIXELS_ARGS ) |
| 2181 |
{ |
| 2182 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 2183 |
XImage *img = xmesa->xm_buffer->backimage; |
| 2184 |
register GLuint i; |
| 2185 |
for (i=0;i<n;i++) { |
| 2186 |
if (mask[i]) { |
| 2187 |
XPutPixel( img, x[i], FLIP(y[i]), (unsigned long) index[i] ); |
| 2188 |
} |
| 2189 |
} |
| 2190 |
} |
| 2191 |
|
| 2192 |
|
| 2193 |
|
| 2194 |
|
| 2195 |
/**********************************************************************/ |
| 2196 |
/***** Pixel reading *****/ |
| 2197 |
/**********************************************************************/ |
| 2198 |
|
| 2199 |
|
| 2200 |
|
| 2201 |
/* |
| 2202 |
* Read a horizontal span of color-index pixels. |
| 2203 |
*/ |
| 2204 |
static void read_index_span( GLcontext *ctx, |
| 2205 |
GLuint n, GLint x, GLint y, GLuint index[] ) |
| 2206 |
{ |
| 2207 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 2208 |
int i; |
| 2209 |
|
| 2210 |
y = FLIP(y); |
| 2211 |
|
| 2212 |
if (xmesa->xm_buffer->buffer) { |
| 2213 |
XImage *span; |
| 2214 |
int error; |
| 2215 |
catch_xgetimage_errors( xmesa->display ); |
| 2216 |
span = XGetImage( xmesa->display, xmesa->xm_buffer->buffer, |
| 2217 |
x, y, n, 1, AllPlanes, ZPixmap ); |
| 2218 |
error = check_xgetimage_errors(); |
| 2219 |
if (span && !error) { |
| 2220 |
for (i=0;i<n;i++) { |
| 2221 |
index[i] = (GLuint) XGetPixel( span, i, 0 ); |
| 2222 |
} |
| 2223 |
} |
| 2224 |
else { |
| 2225 |
/* return 0 pixels */ |
| 2226 |
for (i=0;i<n;i++) { |
| 2227 |
index[i] = 0; |
| 2228 |
} |
| 2229 |
} |
| 2230 |
if (span) { |
| 2231 |
XDestroyImage( span ); |
| 2232 |
} |
| 2233 |
} |
| 2234 |
else if (xmesa->xm_buffer->backimage) { |
| 2235 |
XImage *img = xmesa->xm_buffer->backimage; |
| 2236 |
for (i=0;i<n;i++,x++) { |
| 2237 |
index[i] = (GLuint) XGetPixel( img, x, y ); |
| 2238 |
} |
| 2239 |
} |
| 2240 |
} |
| 2241 |
|
| 2242 |
|
| 2243 |
|
| 2244 |
/* |
| 2245 |
* Read a horizontal span of color pixels. |
| 2246 |
*/ |
| 2247 |
static void read_color_span( GLcontext *ctx, |
| 2248 |
GLuint n, GLint x, GLint y, |
| 2249 |
GLubyte red[], GLubyte green[], |
| 2250 |
GLubyte blue[], GLubyte alpha[] ) |
| 2251 |
{ |
| 2252 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 2253 |
register GLuint i; |
| 2254 |
|
| 2255 |
if (xmesa->xm_buffer->buffer) { |
| 2256 |
XImage *span; |
| 2257 |
int error; |
| 2258 |
catch_xgetimage_errors( xmesa->display ); |
| 2259 |
span = XGetImage( xmesa->display, xmesa->xm_buffer->buffer, |
| 2260 |
x, FLIP(y), n, 1, AllPlanes, ZPixmap ); |
| 2261 |
error = check_xgetimage_errors(); |
| 2262 |
if (span && !error) { |
| 2263 |
switch (xmesa->pixelformat) { |
| 2264 |
case PF_TRUECOLOR: |
| 2265 |
{ |
| 2266 |
GLint rshift = xmesa->xm_visual->rshift, rmult = xmesa->xm_visual->rmult; |
| 2267 |
GLint gshift = xmesa->xm_visual->gshift, gmult = xmesa->xm_visual->gmult; |
| 2268 |
GLint bshift = xmesa->xm_visual->bshift, bmult = xmesa->xm_visual->bmult; |
| 2269 |
for (i=0;i<n;i++) { |
| 2270 |
unsigned long p = XGetPixel( span, i, 0 ); |
| 2271 |
red[i] = (GLubyte) ((p >> rshift) & rmult); |
| 2272 |
green[i] = (GLubyte) ((p >> gshift) & gmult); |
| 2273 |
blue[i] = (GLubyte) ((p >> bshift) & bmult); |
| 2274 |
alpha[i] = 255; |
| 2275 |
} |
| 2276 |
} |
| 2277 |
break; |
| 2278 |
case PF_8A8B8G8R: |
| 2279 |
{ |
| 2280 |
GLuint *ptr4 = (GLuint *) span->data; |
| 2281 |
for (i=0;i<n;i++) { |
| 2282 |
GLuint p4 = *ptr4++; |
| 2283 |
red[i] = (GLubyte) ( p4 & 0xff); |
| 2284 |
green[i] = (GLubyte) ((p4 >> 8) & 0xff); |
| 2285 |
blue[i] = (GLubyte) ((p4 >> 16) & 0xff); |
| 2286 |
alpha[i] = (GLubyte) ((p4 >> 24) & 0xff); |
| 2287 |
} |
| 2288 |
} |
| 2289 |
break; |
| 2290 |
case PF_8R8G8B: |
| 2291 |
{ |
| 2292 |
GLuint *ptr4 = (GLuint *) span->data; |
| 2293 |
for (i=0;i<n;i++) { |
| 2294 |
GLuint p4 = *ptr4++; |
| 2295 |
red[i] = (GLubyte) ((p4 >> 16) & 0xff); |
| 2296 |
green[i] = (GLubyte) ((p4 >> 8) & 0xff); |
| 2297 |
blue[i] = (GLubyte) ( p4 & 0xff); |
| 2298 |
alpha[i] = 255; |
| 2299 |
} |
| 2300 |
} |
| 2301 |
break; |
| 2302 |
case PF_5R6G5B: |
| 2303 |
{ |
| 2304 |
GLushort *ptr2 = (GLushort *) span->data; |
| 2305 |
for (i=0;i<n;i++) { |
| 2306 |
GLushort p2 = *ptr2++; |
| 2307 |
red[i] = (GLubyte) ((p2 >> 11) & 0x1f); |
| 2308 |
green[i] = (GLubyte) ((p2 >> 5) & 0x3f); |
| 2309 |
blue[i] = (GLubyte) ( p2 & 0x1f); |
| 2310 |
alpha[i] = 255; |
| 2311 |
} |
| 2312 |
} |
| 2313 |
break; |
| 2314 |
case PF_HPCR: |
| 2315 |
{ |
| 2316 |
GLubyte *ptr1 = (GLubyte *) span->data; |
| 2317 |
for (i=0;i<n;i++) { |
| 2318 |
GLubyte p = *ptr1++; |
| 2319 |
red[i] = p & 0xE0; |
| 2320 |
green[i] = (p & 0x1C) << 3; |
| 2321 |
blue[i] = (p & 0x03) << 6; |
| 2322 |
alpha[i] = 255; |
| 2323 |
} |
| 2324 |
} |
| 2325 |
break; |
| 2326 |
case PF_DITHER: |
| 2327 |
case PF_LOOKUP: |
| 2328 |
case PF_GRAYSCALE: |
| 2329 |
{ |
| 2330 |
GLubyte *red_table = xmesa->xm_buffer->pixel_to_r; |
| 2331 |
GLubyte *green_table = xmesa->xm_buffer->pixel_to_g; |
| 2332 |
GLubyte *blue_table = xmesa->xm_buffer->pixel_to_b; |
| 2333 |
if (xmesa->xm_visual->visinfo->depth==8) { |
| 2334 |
GLubyte *ptr1 = (GLubyte *) span->data; |
| 2335 |
for (i=0;i<n;i++) { |
| 2336 |
unsigned long p = *ptr1++; |
| 2337 |
red[i] = red_table[p]; |
| 2338 |
green[i] = green_table[p]; |
| 2339 |
blue[i] = blue_table[p]; |
| 2340 |
alpha[i] = 255; |
| 2341 |
} |
| 2342 |
} |
| 2343 |
else { |
| 2344 |
for (i=0;i<n;i++) { |
| 2345 |
unsigned long p = XGetPixel( span, i, 0 ); |
| 2346 |
red[i] = red_table[p]; |
| 2347 |
green[i] = green_table[p]; |
| 2348 |
blue[i] = blue_table[p]; |
| 2349 |
alpha[i] = 255; |
| 2350 |
} |
| 2351 |
} |
| 2352 |
} |
| 2353 |
break; |
| 2354 |
case PF_1BIT: |
| 2355 |
for (i=0;i<n;i++) { |
| 2356 |
unsigned long p = XGetPixel( span, i, 0 ); |
| 2357 |
red[i] = (GLubyte) (p * 255); |
| 2358 |
green[i] = (GLubyte) (p * 255); |
| 2359 |
blue[i] = (GLubyte) (p * 255); |
| 2360 |
alpha[i] = 255; |
| 2361 |
} |
| 2362 |
break; |
| 2363 |
default: |
| 2364 |
die("Problem in DD.read_color_span (1)"); |
| 2365 |
} |
| 2366 |
} |
| 2367 |
else { |
| 2368 |
/* return black pixels */ |
| 2369 |
for (i=0;i<n;i++) { |
| 2370 |
red[i] = green[i] = blue[i] = alpha[i] = 0; |
| 2371 |
} |
| 2372 |
} |
| 2373 |
if (span) { |
| 2374 |
XDestroyImage( span ); |
| 2375 |
} |
| 2376 |
} |
| 2377 |
else if (xmesa->xm_buffer->backimage) { |
| 2378 |
switch (xmesa->pixelformat) { |
| 2379 |
case PF_TRUECOLOR: |
| 2380 |
{ |
| 2381 |
GLint rshift = xmesa->xm_visual->rshift, rmult = xmesa->xm_visual->rmult; |
| 2382 |
GLint gshift = xmesa->xm_visual->gshift, gmult = xmesa->xm_visual->gmult; |
| 2383 |
GLint bshift = xmesa->xm_visual->bshift, bmult = xmesa->xm_visual->bmult; |
| 2384 |
XImage *img = xmesa->xm_buffer->backimage; |
| 2385 |
y = FLIP(y); |
| 2386 |
for (i=0;i<n;i++,x++) { |
| 2387 |
unsigned long p = XGetPixel( img, x, y ); |
| 2388 |
red[i] = (GLubyte) ((p >> rshift) & rmult); |
| 2389 |
green[i] = (GLubyte) ((p >> gshift) & gmult); |
| 2390 |
blue[i] = (GLubyte) ((p >> bshift) & bmult); |
| 2391 |
alpha[i] = 255; |
| 2392 |
} |
| 2393 |
} |
| 2394 |
break; |
| 2395 |
case PF_8A8B8G8R: |
| 2396 |
{ |
| 2397 |
GLuint *ptr4 = PIXELADDR4( x, y ); |
| 2398 |
for (i=0;i<n;i++) { |
| 2399 |
GLuint p4 = *ptr4++; |
| 2400 |
red[i] = (GLubyte) ( p4 & 0xff); |
| 2401 |
green[i] = (GLubyte) ((p4 >> 8) & 0xff); |
| 2402 |
blue[i] = (GLubyte) ((p4 >> 16) & 0xff); |
| 2403 |
alpha[i] = (GLint) ((p4 >> 24) & 0xff); |
| 2404 |
} |
| 2405 |
} |
| 2406 |
break; |
| 2407 |
case PF_8R8G8B: |
| 2408 |
{ |
| 2409 |
GLuint *ptr4 = PIXELADDR4( x, y ); |
| 2410 |
for (i=0;i<n;i++) { |
| 2411 |
GLuint p4 = *ptr4++; |
| 2412 |
red[i] = (GLubyte) ((p4 >> 16) & 0xff); |
| 2413 |
green[i] = (GLubyte) ((p4 >> 8) & 0xff); |
| 2414 |
blue[i] = (GLubyte) ( p4 & 0xff); |
| 2415 |
alpha[i] = 255; |
| 2416 |
} |
| 2417 |
} |
| 2418 |
break; |
| 2419 |
case PF_5R6G5B: |
| 2420 |
{ |
| 2421 |
GLushort *ptr2 = PIXELADDR2( x, y ); |
| 2422 |
for (i=0;i<n;i++) { |
| 2423 |
GLushort p2 = *ptr2++; |
| 2424 |
red[i] = (GLubyte) ((p2 >> 11) & 0x1f); |
| 2425 |
green[i] = (GLubyte) ((p2 >> 5) & 0x3f); |
| 2426 |
blue[i] = (GLubyte) ( p2 & 0x1f); |
| 2427 |
alpha[i] = 255; |
| 2428 |
} |
| 2429 |
} |
| 2430 |
break; |
| 2431 |
case PF_HPCR: |
| 2432 |
{ |
| 2433 |
GLubyte *ptr1 = PIXELADDR1( x, y ); |
| 2434 |
for (i=0;i<n;i++) { |
| 2435 |
GLubyte p = *ptr1++; |
| 2436 |
red[i] = p & 0xE0; |
| 2437 |
green[i] = (p & 0x1C) << 3; |
| 2438 |
blue[i] = (p & 0x03) << 6; |
| 2439 |
alpha[i] = 255; |
| 2440 |
} |
| 2441 |
} |
| 2442 |
break; |
| 2443 |
case PF_DITHER: |
| 2444 |
case PF_LOOKUP: |
| 2445 |
case PF_GRAYSCALE: |
| 2446 |
{ |
| 2447 |
GLubyte *red_table = xmesa->xm_buffer->pixel_to_r; |
| 2448 |
GLubyte *green_table = xmesa->xm_buffer->pixel_to_g; |
| 2449 |
GLubyte *blue_table = xmesa->xm_buffer->pixel_to_b; |
| 2450 |
if (xmesa->xm_visual->visinfo->depth==8) { |
| 2451 |
GLubyte *ptr1 = PIXELADDR1(x,y); |
| 2452 |
for (i=0;i<n;i++) { |
| 2453 |
unsigned long p = *ptr1++; |
| 2454 |
red[i] = red_table[p]; |
| 2455 |
green[i] = green_table[p]; |
| 2456 |
blue[i] = blue_table[p]; |
| 2457 |
alpha[i] = 255; |
| 2458 |
} |
| 2459 |
} |
| 2460 |
else { |
| 2461 |
XImage *img = xmesa->xm_buffer->backimage; |
| 2462 |
y = FLIP(y); |
| 2463 |
for (i=0;i<n;i++,x++) { |
| 2464 |
unsigned long p = XGetPixel( img, x, y ); |
| 2465 |
red[i] = red_table[p]; |
| 2466 |
green[i] = green_table[p]; |
| 2467 |
blue[i] = blue_table[p]; |
| 2468 |
alpha[i] = 255; |
| 2469 |
} |
| 2470 |
} |
| 2471 |
} |
| 2472 |
break; |
| 2473 |
case PF_1BIT: |
| 2474 |
{ |
| 2475 |
XImage *img = xmesa->xm_buffer->backimage; |
| 2476 |
y = FLIP(y); |
| 2477 |
for (i=0;i<n;i++,x++) { |
| 2478 |
unsigned long p = XGetPixel( img, x, y ); |
| 2479 |
red[i] = (GLubyte) (p * 255); |
| 2480 |
green[i] = (GLubyte) (p * 255); |
| 2481 |
blue[i] = (GLubyte) (p * 255); |
| 2482 |
alpha[i] = 255; |
| 2483 |
} |
| 2484 |
} |
| 2485 |
break; |
| 2486 |
default: |
| 2487 |
die("Problem in DD.read_color_span (2)"); |
| 2488 |
} |
| 2489 |
} |
| 2490 |
} |
| 2491 |
|
| 2492 |
|
| 2493 |
|
| 2494 |
/* |
| 2495 |
* Read an array of color index pixels. |
| 2496 |
*/ |
| 2497 |
static void read_index_pixels( GLcontext *ctx, |
| 2498 |
GLuint n, const GLint x[], const GLint y[], |
| 2499 |
GLuint indx[], const GLubyte mask[] ) |
| 2500 |
{ |
| 2501 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 2502 |
register GLuint i; |
| 2503 |
if (xmesa->xm_buffer->buffer) { |
| 2504 |
for (i=0;i<n;i++) { |
| 2505 |
if (mask[i]) { |
| 2506 |
indx[i] = (GLuint) read_pixel( xmesa->display, |
| 2507 |
xmesa->xm_buffer->buffer, |
| 2508 |
x[i], FLIP(y[i]) ); |
| 2509 |
} |
| 2510 |
} |
| 2511 |
} |
| 2512 |
else if (xmesa->xm_buffer->backimage) { |
| 2513 |
XImage *img = xmesa->xm_buffer->backimage; |
| 2514 |
for (i=0;i<n;i++) { |
| 2515 |
if (mask[i]) { |
| 2516 |
indx[i] = (GLuint) XGetPixel( img, x[i], FLIP(y[i]) ); |
| 2517 |
} |
| 2518 |
} |
| 2519 |
} |
| 2520 |
} |
| 2521 |
|
| 2522 |
|
| 2523 |
|
| 2524 |
static void read_color_pixels( GLcontext *ctx, |
| 2525 |
GLuint n, const GLint x[], const GLint y[], |
| 2526 |
GLubyte red[], GLubyte green[], |
| 2527 |
GLubyte blue[], GLubyte alpha[], |
| 2528 |
const GLubyte mask[] ) |
| 2529 |
{ |
| 2530 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 2531 |
Display *dpy = xmesa->xm_visual->display; |
| 2532 |
Drawable buffer = xmesa->xm_buffer->buffer; |
| 2533 |
register GLuint i; |
| 2534 |
|
| 2535 |
if (xmesa->xm_buffer->buffer) { |
| 2536 |
switch (xmesa->pixelformat) { |
| 2537 |
case PF_TRUECOLOR: |
| 2538 |
{ |
| 2539 |
GLint rshift = xmesa->xm_visual->rshift, rmult = xmesa->xm_visual->rmult; |
| 2540 |
GLint gshift = xmesa->xm_visual->gshift, gmult = xmesa->xm_visual->gmult; |
| 2541 |
GLint bshift = xmesa->xm_visual->bshift, bmult = xmesa->xm_visual->bmult; |
| 2542 |
for (i=0;i<n;i++) { |
| 2543 |
if (mask[i] ) { |
| 2544 |
unsigned long p = read_pixel( dpy, buffer, |
| 2545 |
x[i], FLIP(y[i]) ); |
| 2546 |
red[i] = (GLubyte) ((p >> rshift) & rmult); |
| 2547 |
green[i] = (GLubyte) ((p >> gshift) & gmult); |
| 2548 |
blue[i] = (GLubyte) ((p >> bshift) & bmult); |
| 2549 |
alpha[i] = 255; |
| 2550 |
} |
| 2551 |
} |
| 2552 |
} |
| 2553 |
break; |
| 2554 |
case PF_8A8B8G8R: |
| 2555 |
for (i=0;i<n;i++) { |
| 2556 |
if (mask[i]) { |
| 2557 |
unsigned long p = read_pixel( dpy, buffer, |
| 2558 |
x[i], FLIP(y[i]) ); |
| 2559 |
red[i] = (GLubyte) ( p & 0xff); |
| 2560 |
green[i] = (GLubyte) ((p >> 8) & 0xff); |
| 2561 |
blue[i] = (GLubyte) ((p >> 16) & 0xff); |
| 2562 |
alpha[i] = (GLubyte) ((p >> 24) & 0xff); |
| 2563 |
} |
| 2564 |
} |
| 2565 |
break; |
| 2566 |
case PF_8R8G8B: |
| 2567 |
for (i=0;i<n;i++) { |
| 2568 |
if (mask[i]) { |
| 2569 |
unsigned long p = read_pixel( dpy, buffer, |
| 2570 |
x[i], FLIP(y[i]) ); |
| 2571 |
red[i] = (GLubyte) ((p >> 16) & 0xff); |
| 2572 |
green[i] = (GLubyte) ((p >> 8) & 0xff); |
| 2573 |
blue[i] = (GLubyte) ( p & 0xff); |
| 2574 |
alpha[i] = 255; |
| 2575 |
} |
| 2576 |
} |
| 2577 |
break; |
| 2578 |
case PF_5R6G5B: |
| 2579 |
for (i=0;i<n;i++) { |
| 2580 |
if (mask[i]) { |
| 2581 |
unsigned long p = read_pixel( dpy, buffer, |
| 2582 |
x[i], FLIP(y[i]) ); |
| 2583 |
red[i] = (GLubyte) ((p >> 11) & 0x1f); |
| 2584 |
green[i] = (GLubyte) ((p >> 5) & 0x3f); |
| 2585 |
blue[i] = (GLubyte) ( p & 0x1f); |
| 2586 |
alpha[i] = 255; |
| 2587 |
} |
| 2588 |
} |
| 2589 |
break; |
| 2590 |
case PF_HPCR: |
| 2591 |
{ |
| 2592 |
for (i=0;i<n;i++) { |
| 2593 |
if (mask[i]) { |
| 2594 |
unsigned long p = read_pixel( dpy, buffer, |
| 2595 |
x[i], FLIP(y[i]) ); |
| 2596 |
red[i] = p & 0xE0; |
| 2597 |
green[i] = (p & 0x1C) << 3; |
| 2598 |
blue[i] = (p & 0x03) << 6; |
| 2599 |
alpha[i] = 255; |
| 2600 |
} |
| 2601 |
} |
| 2602 |
} |
| 2603 |
break; |
| 2604 |
case PF_DITHER: |
| 2605 |
case PF_LOOKUP: |
| 2606 |
case PF_GRAYSCALE: |
| 2607 |
{ |
| 2608 |
GLubyte *red_table = xmesa->xm_buffer->pixel_to_r; |
| 2609 |
GLubyte *green_table = xmesa->xm_buffer->pixel_to_g; |
| 2610 |
GLubyte *blue_table = xmesa->xm_buffer->pixel_to_b; |
| 2611 |
for (i=0;i<n;i++) { |
| 2612 |
if (mask[i]) { |
| 2613 |
unsigned long p = read_pixel( dpy, buffer, |
| 2614 |
x[i], FLIP(y[i]) ); |
| 2615 |
red[i] = red_table[p]; |
| 2616 |
green[i] = green_table[p]; |
| 2617 |
blue[i] = blue_table[p]; |
| 2618 |
alpha[i] = 255; |
| 2619 |
} |
| 2620 |
} |
| 2621 |
} |
| 2622 |
break; |
| 2623 |
case PF_1BIT: |
| 2624 |
for (i=0;i<n;i++) { |
| 2625 |
if (mask[i]) { |
| 2626 |
unsigned long p = read_pixel( dpy, buffer, |
| 2627 |
x[i], FLIP(y[i]) ); |
| 2628 |
red[i] = (GLubyte) (p * 255); |
| 2629 |
green[i] = (GLubyte) (p * 255); |
| 2630 |
blue[i] = (GLubyte) (p * 255); |
| 2631 |
alpha[i] = 255; |
| 2632 |
} |
| 2633 |
} |
| 2634 |
break; |
| 2635 |
default: |
| 2636 |
die("Problem in DD.read_color_pixels (1)"); |
| 2637 |
} |
| 2638 |
} |
| 2639 |
else if (xmesa->xm_buffer->backimage) { |
| 2640 |
switch (xmesa->pixelformat) { |
| 2641 |
case PF_TRUECOLOR: |
| 2642 |
{ |
| 2643 |
GLint rshift = xmesa->xm_visual->rshift, rmult = xmesa->xm_visual->rmult; |
| 2644 |
GLint gshift = xmesa->xm_visual->gshift, gmult = xmesa->xm_visual->gmult; |
| 2645 |
GLint bshift = xmesa->xm_visual->bshift, bmult = xmesa->xm_visual->bmult; |
| 2646 |
XImage *img = xmesa->xm_buffer->backimage; |
| 2647 |
for (i=0;i<n;i++) { |
| 2648 |
if (mask[i]) { |
| 2649 |
unsigned long p; |
| 2650 |
p = XGetPixel( img, x[i], FLIP(y[i]) ); |
| 2651 |
red[i] = (GLubyte) ((p >> rshift) & rmult); |
| 2652 |
green[i] = (GLubyte) ((p >> gshift) & gmult); |
| 2653 |
blue[i] = (GLubyte) ((p >> bshift) & bmult); |
| 2654 |
alpha[i] = 255; |
| 2655 |
} |
| 2656 |
} |
| 2657 |
} |
| 2658 |
break; |
| 2659 |
case PF_8A8B8G8R: |
| 2660 |
for (i=0;i<n;i++) { |
| 2661 |
if (mask[i]) { |
| 2662 |
GLuint *ptr4 = PIXELADDR4( x[i], y[i] ); |
| 2663 |
GLuint p4 = *ptr4; |
| 2664 |
red[i] = (GLubyte) ( p4 & 0xff); |
| 2665 |
green[i] = (GLubyte) ((p4 >> 8) & 0xff); |
| 2666 |
blue[i] = (GLubyte) ((p4 >> 16) & 0xff); |
| 2667 |
alpha[i] = (GLubyte) ((p4 >> 24) & 0xff); |
| 2668 |
} |
| 2669 |
} |
| 2670 |
break; |
| 2671 |
case PF_8R8G8B: |
| 2672 |
for (i=0;i<n;i++) { |
| 2673 |
if (mask[i]) { |
| 2674 |
GLuint *ptr4 = PIXELADDR4( x[i], y[i] ); |
| 2675 |
GLuint p4 = *ptr4; |
| 2676 |
red[i] = (GLubyte) ((p4 >> 16) & 0xff); |
| 2677 |
green[i] = (GLubyte) ((p4 >> 8) & 0xff); |
| 2678 |
blue[i] = (GLubyte) ( p4 & 0xff); |
| 2679 |
alpha[i] = 255; |
| 2680 |
} |
| 2681 |
} |
| 2682 |
break; |
| 2683 |
case PF_5R6G5B: |
| 2684 |
for (i=0;i<n;i++) { |
| 2685 |
if (mask[i]) { |
| 2686 |
GLushort *ptr2 = PIXELADDR2( x[i], y[i] ); |
| 2687 |
GLushort p2 = *ptr2; |
| 2688 |
red[i] = (GLubyte) ((p2 >> 11) & 0x1f); |
| 2689 |
green[i] = (GLubyte) ((p2 >> 5) & 0x3f); |
| 2690 |
blue[i] = (GLubyte) ( p2 & 0x1f); |
| 2691 |
alpha[i] = 255; |
| 2692 |
} |
| 2693 |
} |
| 2694 |
break; |
| 2695 |
case PF_HPCR: |
| 2696 |
for (i=0;i<n;i++) { |
| 2697 |
if (mask[i]) { |
| 2698 |
GLubyte *ptr1 = PIXELADDR1( x[i], y[i] ); |
| 2699 |
GLubyte p = *ptr1; |
| 2700 |
red[i] = p & 0xE0; |
| 2701 |
green[i] = (p & 0x1C) << 3; |
| 2702 |
blue[i] = (p & 0x03) << 6; |
| 2703 |
alpha[i] = 255; |
| 2704 |
} |
| 2705 |
} |
| 2706 |
break; |
| 2707 |
case PF_DITHER: |
| 2708 |
case PF_LOOKUP: |
| 2709 |
case PF_GRAYSCALE: |
| 2710 |
{ |
| 2711 |
GLubyte *red_table = xmesa->xm_buffer->pixel_to_r; |
| 2712 |
GLubyte *green_table = xmesa->xm_buffer->pixel_to_g; |
| 2713 |
GLubyte *blue_table = xmesa->xm_buffer->pixel_to_b; |
| 2714 |
XImage *img = xmesa->xm_buffer->backimage; |
| 2715 |
for (i=0;i<n;i++) { |
| 2716 |
if (mask[i]) { |
| 2717 |
unsigned long p; |
| 2718 |
p = XGetPixel( img, x[i], FLIP(y[i]) ); |
| 2719 |
red[i] = red_table[p]; |
| 2720 |
green[i] = green_table[p]; |
| 2721 |
blue[i] = blue_table[p]; |
| 2722 |
alpha[i] = 255; |
| 2723 |
} |
| 2724 |
} |
| 2725 |
} |
| 2726 |
break; |
| 2727 |
case PF_1BIT: |
| 2728 |
{ |
| 2729 |
XImage *img = xmesa->xm_buffer->backimage; |
| 2730 |
for (i=0;i<n;i++) { |
| 2731 |
if (mask[i]) { |
| 2732 |
unsigned long p; |
| 2733 |
p = XGetPixel( img, x[i], FLIP(y[i]) ); |
| 2734 |
red[i] = (GLubyte) (p * 255); |
| 2735 |
green[i] = (GLubyte) (p * 255); |
| 2736 |
blue[i] = (GLubyte) (p * 255); |
| 2737 |
alpha[i] = 255; |
| 2738 |
} |
| 2739 |
} |
| 2740 |
} |
| 2741 |
break; |
| 2742 |
default: |
| 2743 |
die("Problem in DD.read_color_pixels (1)"); |
| 2744 |
} |
| 2745 |
} |
| 2746 |
} |
| 2747 |
|
| 2748 |
|
| 2749 |
|
| 2750 |
|
| 2751 |
/* |
| 2752 |
* Initialize all the DD.* function pointers depending on the color |
| 2753 |
* buffer configuration. This is mainly called by XMesaMakeCurrent. |
| 2754 |
*/ |
| 2755 |
void xmesa_setup_DD_pointers( GLcontext *ctx ) |
| 2756 |
{ |
| 2757 |
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; |
| 2758 |
/* |
| 2759 |
* Always the same: |
| 2760 |
*/ |
| 2761 |
ctx->Driver.UpdateState = xmesa_setup_DD_pointers; |
| 2762 |
ctx->Driver.GetBufferSize = get_buffer_size; |
| 2763 |
ctx->Driver.Flush = flush; |
| 2764 |
ctx->Driver.Finish = finish; |
| 2765 |
|
| 2766 |
ctx->Driver.SetBuffer = set_buffer; |
| 2767 |
|
| 2768 |
ctx->Driver.Index = set_index; |
| 2769 |
ctx->Driver.Color = set_color; |
| 2770 |
ctx->Driver.ClearIndex = clear_index; |
| 2771 |
ctx->Driver.ClearColor = clear_color; |
| 2772 |
ctx->Driver.IndexMask = index_mask; |
| 2773 |
ctx->Driver.ColorMask = color_mask; |
| 2774 |
ctx->Driver.LogicOp = logicop; |
| 2775 |
ctx->Driver.Dither = dither; |
| 2776 |
|
| 2777 |
ctx->Driver.PointsFunc = xmesa_get_points_func( ctx ); |
| 2778 |
ctx->Driver.LineFunc = xmesa_get_line_func( ctx ); |
| 2779 |
ctx->Driver.TriangleFunc = xmesa_get_triangle_func( ctx ); |
| 2780 |
|
| 2781 |
/* |
| 2782 |
* These drawing functions depend on color buffer config: |
| 2783 |
*/ |
| 2784 |
if (xmesa->xm_buffer->buffer!=XIMAGE) { |
| 2785 |
/* Writing to window or back pixmap */ |
| 2786 |
ctx->Driver.Clear = clear_pixmap; |
| 2787 |
switch (xmesa->pixelformat) { |
| 2788 |
case PF_INDEX: |
| 2789 |
ctx->Driver.WriteIndexSpan = write_span_index_pixmap; |
| 2790 |
ctx->Driver.WriteMonoindexSpan = write_span_mono_pixmap; |
| 2791 |
ctx->Driver.WriteIndexPixels = write_pixels_index_pixmap; |
| 2792 |
ctx->Driver.WriteMonoindexPixels = write_pixels_mono_pixmap; |
| 2793 |
break; |
| 2794 |
case PF_TRUECOLOR: |
| 2795 |
ctx->Driver.WriteColorSpan = write_span_TRUECOLOR_pixmap; |
| 2796 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_pixmap; |
| 2797 |
ctx->Driver.WriteColorPixels = write_pixels_TRUECOLOR_pixmap; |
| 2798 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_pixmap; |
| 2799 |
break; |
| 2800 |
case PF_8A8B8G8R: |
| 2801 |
ctx->Driver.WriteColorSpan = write_span_8A8B8G8R_pixmap; |
| 2802 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_pixmap; |
| 2803 |
ctx->Driver.WriteColorPixels = write_pixels_8A8B8G8R_pixmap; |
| 2804 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_pixmap; |
| 2805 |
break; |
| 2806 |
case PF_8R8G8B: |
| 2807 |
ctx->Driver.WriteColorSpan = write_span_8R8G8B_pixmap; |
| 2808 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_pixmap; |
| 2809 |
ctx->Driver.WriteColorPixels = write_pixels_8R8G8B_pixmap; |
| 2810 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_pixmap; |
| 2811 |
break; |
| 2812 |
case PF_5R6G5B: |
| 2813 |
ctx->Driver.WriteColorSpan = write_span_5R6G5B_pixmap; |
| 2814 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_pixmap; |
| 2815 |
ctx->Driver.WriteColorPixels = write_pixels_5R6G5B_pixmap; |
| 2816 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_pixmap; |
| 2817 |
break; |
| 2818 |
case PF_DITHER: |
| 2819 |
ctx->Driver.WriteColorSpan = write_span_DITHER_pixmap; |
| 2820 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_DITHER_pixmap; |
| 2821 |
ctx->Driver.WriteColorPixels = write_pixels_DITHER_pixmap; |
| 2822 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_DITHER_pixmap; |
| 2823 |
break; |
| 2824 |
case PF_1BIT: |
| 2825 |
ctx->Driver.WriteColorSpan = write_span_1BIT_pixmap; |
| 2826 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_1BIT_pixmap; |
| 2827 |
ctx->Driver.WriteColorPixels = write_pixels_1BIT_pixmap; |
| 2828 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_1BIT_pixmap; |
| 2829 |
break; |
| 2830 |
case PF_HPCR: |
| 2831 |
ctx->Driver.WriteColorSpan = write_span_HPCR_pixmap; |
| 2832 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_pixmap; |
| 2833 |
ctx->Driver.WriteColorPixels = write_pixels_HPCR_pixmap; |
| 2834 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_pixmap; |
| 2835 |
break; |
| 2836 |
case PF_LOOKUP: |
| 2837 |
ctx->Driver.WriteColorSpan = write_span_LOOKUP_pixmap; |
| 2838 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_pixmap; |
| 2839 |
ctx->Driver.WriteColorPixels = write_pixels_LOOKUP_pixmap; |
| 2840 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_pixmap; |
| 2841 |
break; |
| 2842 |
case PF_GRAYSCALE: |
| 2843 |
ctx->Driver.WriteColorSpan = write_span_GRAYSCALE_pixmap; |
| 2844 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_pixmap; |
| 2845 |
ctx->Driver.WriteColorPixels = write_pixels_GRAYSCALE_pixmap; |
| 2846 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_pixmap; |
| 2847 |
break; |
| 2848 |
default: |
| 2849 |
die("Bad pixel format in xmesa_setup_DD_pointers (1)"); |
| 2850 |
} |
| 2851 |
} |
| 2852 |
else if (xmesa->xm_buffer->buffer==XIMAGE) { |
| 2853 |
/* Writing to back XImage */ |
| 2854 |
if (sizeof(GLushort)!=2 || sizeof(GLuint)!=4) { |
| 2855 |
/* Do this on Crays */ |
| 2856 |
ctx->Driver.Clear = clear_nbit_ximage; |
| 2857 |
} |
| 2858 |
else { |
| 2859 |
/* Do this on most machines */ |
| 2860 |
switch (xmesa->xm_buffer->backimage->bits_per_pixel) { |
| 2861 |
case 8: |
| 2862 |
ctx->Driver.Clear = clear_8bit_ximage; |
| 2863 |
break; |
| 2864 |
case 16: |
| 2865 |
ctx->Driver.Clear = clear_16bit_ximage; |
| 2866 |
break; |
| 2867 |
case 32: |
| 2868 |
ctx->Driver.Clear = clear_32bit_ximage; |
| 2869 |
break; |
| 2870 |
default: |
| 2871 |
ctx->Driver.Clear = clear_nbit_ximage; |
| 2872 |
break; |
| 2873 |
} |
| 2874 |
} |
| 2875 |
switch (xmesa->pixelformat) { |
| 2876 |
case PF_INDEX: |
| 2877 |
ctx->Driver.WriteIndexSpan = write_span_index_ximage; |
| 2878 |
ctx->Driver.WriteMonoindexSpan = write_span_mono_ximage; |
| 2879 |
ctx->Driver.WriteIndexPixels = write_pixels_index_ximage; |
| 2880 |
ctx->Driver.WriteMonoindexPixels = write_pixels_mono_ximage; |
| 2881 |
break; |
| 2882 |
case PF_TRUECOLOR: |
| 2883 |
/* Generic RGB */ |
| 2884 |
ctx->Driver.WriteColorSpan = write_span_TRUECOLOR_ximage; |
| 2885 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_ximage; |
| 2886 |
ctx->Driver.WriteColorPixels = write_pixels_TRUECOLOR_ximage; |
| 2887 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_ximage; |
| 2888 |
break; |
| 2889 |
case PF_8A8B8G8R: |
| 2890 |
ctx->Driver.WriteColorSpan = write_span_8A8B8G8R_ximage; |
| 2891 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_8A8B8G8R_ximage; |
| 2892 |
ctx->Driver.WriteColorPixels = write_pixels_8A8B8G8R_ximage; |
| 2893 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_8A8B8G8R_ximage; |
| 2894 |
break; |
| 2895 |
case PF_8R8G8B: |
| 2896 |
ctx->Driver.WriteColorSpan = write_span_8R8G8B_ximage; |
| 2897 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_8R8G8B_ximage; |
| 2898 |
ctx->Driver.WriteColorPixels = write_pixels_8R8G8B_ximage; |
| 2899 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_8R8G8B_ximage; |
| 2900 |
break; |
| 2901 |
case PF_5R6G5B: |
| 2902 |
ctx->Driver.WriteColorSpan = write_span_5R6G5B_ximage; |
| 2903 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_ximage; |
| 2904 |
ctx->Driver.WriteColorPixels = write_pixels_5R6G5B_ximage; |
| 2905 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_ximage; |
| 2906 |
break; |
| 2907 |
case PF_DITHER: |
| 2908 |
if (xmesa->xm_visual->visinfo->depth==8) { |
| 2909 |
ctx->Driver.WriteColorSpan = write_span_DITHER8_ximage; |
| 2910 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_DITHER8_ximage; |
| 2911 |
ctx->Driver.WriteColorPixels = write_pixels_DITHER8_ximage; |
| 2912 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_DITHER8_ximage; |
| 2913 |
} |
| 2914 |
else { |
| 2915 |
ctx->Driver.WriteColorSpan = write_span_DITHER_ximage; |
| 2916 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_DITHER_ximage; |
| 2917 |
ctx->Driver.WriteColorPixels = write_pixels_DITHER_ximage; |
| 2918 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_DITHER_ximage; |
| 2919 |
} |
| 2920 |
break; |
| 2921 |
case PF_1BIT: |
| 2922 |
ctx->Driver.WriteColorSpan = write_span_1BIT_ximage; |
| 2923 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_1BIT_ximage; |
| 2924 |
ctx->Driver.WriteColorPixels = write_pixels_1BIT_ximage; |
| 2925 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_1BIT_ximage; |
| 2926 |
break; |
| 2927 |
case PF_HPCR: |
| 2928 |
ctx->Driver.WriteColorSpan = write_span_HPCR_ximage; |
| 2929 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_HPCR_ximage; |
| 2930 |
ctx->Driver.WriteColorPixels = write_pixels_HPCR_ximage; |
| 2931 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_HPCR_ximage; |
| 2932 |
break; |
| 2933 |
case PF_LOOKUP: |
| 2934 |
if (xmesa->xm_visual->visinfo->depth==8) { |
| 2935 |
ctx->Driver.WriteColorSpan = write_span_LOOKUP8_ximage; |
| 2936 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_LOOKUP8_ximage; |
| 2937 |
ctx->Driver.WriteColorPixels = write_pixels_LOOKUP8_ximage; |
| 2938 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_LOOKUP8_ximage; |
| 2939 |
} |
| 2940 |
else { |
| 2941 |
ctx->Driver.WriteColorSpan = write_span_LOOKUP_ximage; |
| 2942 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_ximage; |
| 2943 |
ctx->Driver.WriteColorPixels = write_pixels_LOOKUP_ximage; |
| 2944 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_ximage; |
| 2945 |
} |
| 2946 |
break; |
| 2947 |
case PF_GRAYSCALE: |
| 2948 |
if (xmesa->xm_visual->visinfo->depth==8) { |
| 2949 |
ctx->Driver.WriteColorSpan = write_span_GRAYSCALE8_ximage; |
| 2950 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_GRAYSCALE8_ximage; |
| 2951 |
ctx->Driver.WriteColorPixels = write_pixels_GRAYSCALE8_ximage; |
| 2952 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_GRAYSCALE8_ximage; |
| 2953 |
} |
| 2954 |
else { |
| 2955 |
ctx->Driver.WriteColorSpan = write_span_GRAYSCALE_ximage; |
| 2956 |
ctx->Driver.WriteMonocolorSpan = write_span_mono_ximage; |
| 2957 |
ctx->Driver.WriteColorPixels = write_pixels_GRAYSCALE_ximage; |
| 2958 |
ctx->Driver.WriteMonocolorPixels = write_pixels_mono_ximage; |
| 2959 |
} |
| 2960 |
break; |
| 2961 |
default: |
| 2962 |
die("Bad pixel format in xmesa_setup_DD_pointers (2)"); |
| 2963 |
} |
| 2964 |
} |
| 2965 |
|
| 2966 |
/* Pixel/span reading functions: */ |
| 2967 |
ctx->Driver.ReadIndexSpan = read_index_span; |
| 2968 |
ctx->Driver.ReadColorSpan = read_color_span; |
| 2969 |
ctx->Driver.ReadIndexPixels = read_index_pixels; |
| 2970 |
ctx->Driver.ReadColorPixels = read_color_pixels; |
| 2971 |
} |
| 2972 |
|
| 2973 |
#endif |