| 1 |
/* |
| 2 |
* Mesa 3-D graphics library |
| 3 |
* Version: 6.3 |
| 4 |
* |
| 5 |
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved. |
| 6 |
* |
| 7 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 8 |
* copy of this software and associated documentation files (the "Software"), |
| 9 |
* to deal in the Software without restriction, including without limitation |
| 10 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 12 |
* Software is furnished to do so, subject to the following conditions: |
| 13 |
* |
| 14 |
* The above copyright notice and this permission notice shall be included |
| 15 |
* in all copies or substantial portions of the Software. |
| 16 |
* |
| 17 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 18 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 |
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 21 |
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 22 |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 |
*/ |
| 24 |
|
| 25 |
|
| 26 |
#ifndef XMESAP_H |
| 27 |
#define XMESAP_H |
| 28 |
|
| 29 |
|
| 30 |
#ifdef XFree86Server |
| 31 |
# include "GL/xf86glx.h" |
| 32 |
# include "xf86glx_util.h" |
| 33 |
#elif defined(USE_XSHM) |
| 34 |
# include <X11/extensions/XShm.h> |
| 35 |
#endif |
| 36 |
#include "GL/xmesa.h" |
| 37 |
#include "mtypes.h" |
| 38 |
#if defined(FX) |
| 39 |
#include "GL/fxmesa.h" |
| 40 |
#include "../glide/fxdrv.h" |
| 41 |
#endif |
| 42 |
|
| 43 |
|
| 44 |
extern _glthread_Mutex _xmesa_lock; |
| 45 |
|
| 46 |
|
| 47 |
/* for PF_8R8G8B24 pixel format */ |
| 48 |
typedef struct { |
| 49 |
GLubyte b; |
| 50 |
GLubyte g; |
| 51 |
GLubyte r; |
| 52 |
} bgr_t; |
| 53 |
|
| 54 |
|
| 55 |
struct xmesa_renderbuffer; |
| 56 |
|
| 57 |
|
| 58 |
/* Function pointer for clearing color buffers */ |
| 59 |
typedef void (*ClearFunc)( GLcontext *ctx, struct xmesa_renderbuffer *xrb, |
| 60 |
GLboolean all, GLint x, GLint y, |
| 61 |
GLint width, GLint height ); |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
/** Framebuffer pixel formats */ |
| 67 |
enum pixel_format { |
| 68 |
PF_Index, /**< Color Index mode */ |
| 69 |
PF_Truecolor, /**< TrueColor or DirectColor, any depth */ |
| 70 |
PF_Dither_True, /**< TrueColor with dithering */ |
| 71 |
PF_8A8B8G8R, /**< 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R */ |
| 72 |
PF_8R8G8B, /**< 32-bit TrueColor: 8-R, 8-G, 8-B bits */ |
| 73 |
PF_5R6G5B, /**< 16-bit TrueColor: 5-R, 6-G, 5-B bits */ |
| 74 |
PF_Dither, /**< Color-mapped RGB with dither */ |
| 75 |
PF_Lookup, /**< Color-mapped RGB without dither */ |
| 76 |
PF_HPCR, /**< HP Color Recovery ([email protected] 30/08/95) */ |
| 77 |
PF_1Bit, /**< monochrome dithering of RGB */ |
| 78 |
PF_Grayscale, /**< Grayscale or StaticGray */ |
| 79 |
PF_8R8G8B24, /**< 24-bit TrueColor: 8-R, 8-G, 8-B bits */ |
| 80 |
PF_Dither_5R6G5B, /**< 16-bit dithered TrueColor: 5-R, 6-G, 5-B */ |
| 81 |
PF_8A8R8G8B /**< 32-bit TrueColor: 8-A, 8-R, 8-G, 8-B */ |
| 82 |
}; |
| 83 |
|
| 84 |
|
| 85 |
/* |
| 86 |
* "Derived" from GLvisual. Basically corresponds to an XVisualInfo. |
| 87 |
*/ |
| 88 |
struct xmesa_visual { |
| 89 |
GLvisual mesa_visual; /* Device independent visual parameters */ |
| 90 |
XMesaDisplay *display; /* The X11 display */ |
| 91 |
#ifdef XFree86Server |
| 92 |
GLint ColormapEntries; |
| 93 |
GLint nplanes; |
| 94 |
#else |
| 95 |
XMesaVisualInfo visinfo; /* X's visual info (pointer to private copy) */ |
| 96 |
XVisualInfo *vishandle; /* Only used in fakeglx.c */ |
| 97 |
#endif |
| 98 |
GLint BitsPerPixel; /* True bits per pixel for XImages */ |
| 99 |
|
| 100 |
GLboolean ximage_flag; /* Use XImage for back buffer (not pixmap)? */ |
| 101 |
|
| 102 |
enum pixel_format dithered_pf; /* Pixel format when dithering */ |
| 103 |
enum pixel_format undithered_pf;/* Pixel format when not dithering */ |
| 104 |
|
| 105 |
GLfloat RedGamma; /* Gamma values, 1.0 is default */ |
| 106 |
GLfloat GreenGamma; |
| 107 |
GLfloat BlueGamma; |
| 108 |
|
| 109 |
/* For PF_TRUECOLOR */ |
| 110 |
GLint rshift, gshift, bshift;/* Pixel color component shifts */ |
| 111 |
GLubyte Kernel[16]; /* Dither kernel */ |
| 112 |
unsigned long RtoPixel[512]; /* RGB to pixel conversion */ |
| 113 |
unsigned long GtoPixel[512]; |
| 114 |
unsigned long BtoPixel[512]; |
| 115 |
GLubyte PixelToR[256]; /* Pixel to RGB conversion */ |
| 116 |
GLubyte PixelToG[256]; |
| 117 |
GLubyte PixelToB[256]; |
| 118 |
|
| 119 |
/* For PF_HPCR */ |
| 120 |
short hpcr_rgbTbl[3][256]; |
| 121 |
GLboolean hpcr_clear_flag; |
| 122 |
GLubyte hpcr_clear_ximage_pattern[2][16]; |
| 123 |
XMesaImage *hpcr_clear_ximage; |
| 124 |
XMesaPixmap hpcr_clear_pixmap; |
| 125 |
|
| 126 |
/* For PF_1BIT */ |
| 127 |
int bitFlip; |
| 128 |
}; |
| 129 |
|
| 130 |
|
| 131 |
/* |
| 132 |
* "Derived" from __GLcontextRec. Basically corresponds to a GLXContext. |
| 133 |
*/ |
| 134 |
struct xmesa_context { |
| 135 |
GLcontext mesa; /* the core library context (containment) */ |
| 136 |
XMesaVisual xm_visual; /* Describes the buffers */ |
| 137 |
XMesaBuffer xm_buffer; /* current span/point/line/triangle buffer */ |
| 138 |
|
| 139 |
XMesaDisplay *display; /* == xm_visual->display */ |
| 140 |
GLboolean swapbytes; /* Host byte order != display byte order? */ |
| 141 |
GLboolean direct; /* Direct rendering context? */ |
| 142 |
|
| 143 |
enum pixel_format pixelformat; |
| 144 |
|
| 145 |
GLubyte clearcolor[4]; /* current clearing color */ |
| 146 |
unsigned long clearpixel; /* current clearing pixel value */ |
| 147 |
}; |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
typedef enum { |
| 152 |
WINDOW, /* An X window */ |
| 153 |
GLXWINDOW, /* GLX window */ |
| 154 |
PIXMAP, /* GLX pixmap */ |
| 155 |
PBUFFER /* GLX Pbuffer */ |
| 156 |
} BufferType; |
| 157 |
|
| 158 |
|
| 159 |
/** |
| 160 |
* An xmesa_renderbuffer represents the back or front color buffer. |
| 161 |
* For the front color buffer: |
| 162 |
* <drawable> is the X window |
| 163 |
* For the back color buffer: |
| 164 |
* Either <ximage> or <pixmap> will be used, never both. |
| 165 |
* In any case, <drawable> always equals <pixmap>. |
| 166 |
* For stand-alone Mesa, we could merge <drawable> and <pixmap> into one |
| 167 |
* field. We don't do that for the server-side GLcore module because |
| 168 |
* pixmaps and drawables are different and we'd need a bunch of casts. |
| 169 |
*/ |
| 170 |
struct xmesa_renderbuffer |
| 171 |
{ |
| 172 |
struct gl_renderbuffer Base; /* Base class */ |
| 173 |
|
| 174 |
XMesaDrawable drawable; /* Usually the X window ID */ |
| 175 |
XMesaPixmap pixmap; /* Back color buffer */ |
| 176 |
XMesaImage *ximage; /* The back buffer, if not using a Pixmap */ |
| 177 |
|
| 178 |
GLubyte *origin1; /* used for PIXEL_ADDR1 macro */ |
| 179 |
GLint width1; |
| 180 |
GLushort *origin2; /* used for PIXEL_ADDR2 macro */ |
| 181 |
GLint width2; |
| 182 |
GLubyte *origin3; /* used for PIXEL_ADDR3 macro */ |
| 183 |
GLint width3; |
| 184 |
GLuint *origin4; /* used for PIXEL_ADDR4 macro */ |
| 185 |
GLint width4; |
| 186 |
|
| 187 |
GLint bottom; /* used for FLIP macro */ |
| 188 |
|
| 189 |
ClearFunc clearFunc; |
| 190 |
}; |
| 191 |
|
| 192 |
|
| 193 |
/* |
| 194 |
* "Derived" from GLframebuffer. Basically corresponds to a GLXDrawable. |
| 195 |
*/ |
| 196 |
struct xmesa_buffer { |
| 197 |
GLframebuffer mesa_buffer; /* depth, stencil, accum, etc buffers */ |
| 198 |
/* This MUST BE FIRST! */ |
| 199 |
GLboolean wasCurrent; /* was ever the current buffer? */ |
| 200 |
XMesaVisual xm_visual; /* the X/Mesa visual */ |
| 201 |
|
| 202 |
XMesaDisplay *display; |
| 203 |
BufferType type; /* window, pixmap, pbuffer or glxwindow */ |
| 204 |
|
| 205 |
struct xmesa_renderbuffer *frontxrb; /* front color renderbuffer */ |
| 206 |
struct xmesa_renderbuffer *backxrb; /* back color renderbuffer */ |
| 207 |
|
| 208 |
XMesaColormap cmap; /* the X colormap */ |
| 209 |
|
| 210 |
unsigned long selectedEvents;/* for pbuffers only */ |
| 211 |
|
| 212 |
GLint db_state; /* 0 = single buffered */ |
| 213 |
/* BACK_PIXMAP = use Pixmap for back buffer */ |
| 214 |
/* BACK_XIMAGE = use XImage for back buffer */ |
| 215 |
|
| 216 |
#ifndef XFree86Server |
| 217 |
GLuint shm; /* X Shared Memory extension status: */ |
| 218 |
/* 0 = not available */ |
| 219 |
/* 1 = XImage support available */ |
| 220 |
/* 2 = Pixmap support available too */ |
| 221 |
#ifdef USE_XSHM |
| 222 |
XShmSegmentInfo shminfo; |
| 223 |
#endif |
| 224 |
#endif |
| 225 |
|
| 226 |
XMesaImage *rowimage; /* Used for optimized span writing */ |
| 227 |
XMesaPixmap stipple_pixmap; /* For polygon stippling */ |
| 228 |
XMesaGC stipple_gc; /* For polygon stippling */ |
| 229 |
|
| 230 |
XMesaGC gc; /* scratch GC for span, line, tri drawing */ |
| 231 |
XMesaGC cleargc; /* GC for clearing the color buffer */ |
| 232 |
XMesaGC swapgc; /* GC for swapping the color buffers */ |
| 233 |
|
| 234 |
/* The following are here instead of in the XMesaVisual |
| 235 |
* because they depend on the window's colormap. |
| 236 |
*/ |
| 237 |
|
| 238 |
/* For PF_DITHER, PF_LOOKUP, PF_GRAYSCALE */ |
| 239 |
unsigned long color_table[576]; /* RGB -> pixel value */ |
| 240 |
|
| 241 |
/* For PF_DITHER, PF_LOOKUP, PF_GRAYSCALE */ |
| 242 |
GLubyte pixel_to_r[65536]; /* pixel value -> red */ |
| 243 |
GLubyte pixel_to_g[65536]; /* pixel value -> green */ |
| 244 |
GLubyte pixel_to_b[65536]; /* pixel value -> blue */ |
| 245 |
|
| 246 |
/* Used to do XAllocColor/XFreeColors accounting: */ |
| 247 |
int num_alloced; |
| 248 |
#if defined(XFree86Server) |
| 249 |
Pixel alloced_colors[256]; |
| 250 |
#else |
| 251 |
unsigned long alloced_colors[256]; |
| 252 |
#endif |
| 253 |
|
| 254 |
#if defined( FX ) |
| 255 |
/* For 3Dfx Glide only */ |
| 256 |
GLboolean FXisHackUsable; /* Can we render into window? */ |
| 257 |
GLboolean FXwindowHack; /* Are we rendering into a window? */ |
| 258 |
fxMesaContext FXctx; |
| 259 |
#endif |
| 260 |
|
| 261 |
struct xmesa_buffer *Next; /* Linked list pointer: */ |
| 262 |
}; |
| 263 |
|
| 264 |
|
| 265 |
/* Values for xmesa->db_state: */ |
| 266 |
#define FRONT_PIXMAP 1 |
| 267 |
#define BACK_PIXMAP 2 |
| 268 |
#define BACK_XIMAGE 4 |
| 269 |
|
| 270 |
|
| 271 |
/* |
| 272 |
* If pixelformat==PF_TRUECOLOR: |
| 273 |
*/ |
| 274 |
#define PACK_TRUECOLOR( PIXEL, R, G, B ) \ |
| 275 |
PIXEL = xmesa->xm_visual->RtoPixel[R] \ |
| 276 |
| xmesa->xm_visual->GtoPixel[G] \ |
| 277 |
| xmesa->xm_visual->BtoPixel[B]; \ |
| 278 |
|
| 279 |
|
| 280 |
/* |
| 281 |
* If pixelformat==PF_TRUEDITHER: |
| 282 |
*/ |
| 283 |
#define PACK_TRUEDITHER( PIXEL, X, Y, R, G, B ) \ |
| 284 |
{ \ |
| 285 |
int d = xmesa->xm_visual->Kernel[((X)&3) | (((Y)&3)<<2)]; \ |
| 286 |
PIXEL = xmesa->xm_visual->RtoPixel[(R)+d] \ |
| 287 |
| xmesa->xm_visual->GtoPixel[(G)+d] \ |
| 288 |
| xmesa->xm_visual->BtoPixel[(B)+d]; \ |
| 289 |
} |
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
/* |
| 294 |
* If pixelformat==PF_8A8B8G8R: |
| 295 |
*/ |
| 296 |
#define PACK_8A8B8G8R( R, G, B, A ) \ |
| 297 |
( ((A) << 24) | ((B) << 16) | ((G) << 8) | (R) ) |
| 298 |
|
| 299 |
|
| 300 |
/* |
| 301 |
* Like PACK_8A8B8G8R() but don't use alpha. This is usually an acceptable |
| 302 |
* shortcut. |
| 303 |
*/ |
| 304 |
#define PACK_8B8G8R( R, G, B ) ( ((B) << 16) | ((G) << 8) | (R) ) |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
/* |
| 309 |
* If pixelformat==PF_8R8G8B: |
| 310 |
*/ |
| 311 |
#define PACK_8R8G8B( R, G, B) ( ((R) << 16) | ((G) << 8) | (B) ) |
| 312 |
|
| 313 |
|
| 314 |
/* |
| 315 |
* If pixelformat==PF_5R6G5B: |
| 316 |
*/ |
| 317 |
#define PACK_5R6G5B( R, G, B) ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) ) |
| 318 |
|
| 319 |
|
| 320 |
/* |
| 321 |
* If pixelformat==PF_8A8R8G8B: |
| 322 |
*/ |
| 323 |
#define PACK_8A8R8G8B( R, G, B, A ) \ |
| 324 |
( ((A) << 24) | ((R) << 16) | ((G) << 8) | (B) ) |
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
/* |
| 329 |
* If pixelformat==PF_DITHER: |
| 330 |
* |
| 331 |
* Improved 8-bit RGB dithering code contributed by Bob Mercier |
| 332 |
* ([email protected]). Thanks Bob! |
| 333 |
*/ |
| 334 |
#ifdef DITHER666 |
| 335 |
# define DITH_R 6 |
| 336 |
# define DITH_G 6 |
| 337 |
# define DITH_B 6 |
| 338 |
# define DITH_MIX(r,g,b) (((r) * DITH_G + (g)) * DITH_B + (b)) |
| 339 |
#else |
| 340 |
# define DITH_R 5 |
| 341 |
# define DITH_G 9 |
| 342 |
# define DITH_B 5 |
| 343 |
# define DITH_MIX(r,g,b) (((g) << 6) | ((b) << 3) | (r)) |
| 344 |
#endif |
| 345 |
#define DITH_DX 4 |
| 346 |
#define DITH_DY 4 |
| 347 |
#define DITH_N (DITH_DX * DITH_DY) |
| 348 |
|
| 349 |
#define _dither(C, c, d) (((unsigned)((DITH_N * (C - 1) + 1) * c + d)) >> 12) |
| 350 |
|
| 351 |
#define MAXC 256 |
| 352 |
extern const int xmesa_kernel8[DITH_DY * DITH_DX]; |
| 353 |
|
| 354 |
/* Dither for random X,Y */ |
| 355 |
#define DITHER_SETUP \ |
| 356 |
int __d; \ |
| 357 |
unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table; |
| 358 |
|
| 359 |
#define DITHER( X, Y, R, G, B ) \ |
| 360 |
(__d = xmesa_kernel8[(((Y)&3)<<2) | ((X)&3)], \ |
| 361 |
ctable[DITH_MIX(_dither(DITH_R, (R), __d), \ |
| 362 |
_dither(DITH_G, (G), __d), \ |
| 363 |
_dither(DITH_B, (B), __d))]) |
| 364 |
|
| 365 |
/* Dither for random X, fixed Y */ |
| 366 |
#define XDITHER_SETUP(Y) \ |
| 367 |
int __d; \ |
| 368 |
unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table; \ |
| 369 |
const int *kernel = &xmesa_kernel8[ ((Y)&3) << 2 ]; |
| 370 |
|
| 371 |
#define XDITHER( X, R, G, B ) \ |
| 372 |
(__d = kernel[(X)&3], \ |
| 373 |
ctable[DITH_MIX(_dither(DITH_R, (R), __d), \ |
| 374 |
_dither(DITH_G, (G), __d), \ |
| 375 |
_dither(DITH_B, (B), __d))]) |
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
/* |
| 380 |
* Dithering for flat-shaded triangles. Precompute all 16 possible |
| 381 |
* pixel values given the triangle's RGB color. Contributed by Martin Shenk. |
| 382 |
*/ |
| 383 |
#define FLAT_DITHER_SETUP( R, G, B ) \ |
| 384 |
GLushort ditherValues[16]; \ |
| 385 |
{ \ |
| 386 |
unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table; \ |
| 387 |
int msdr = (DITH_N*((DITH_R)-1)+1) * (R); \ |
| 388 |
int msdg = (DITH_N*((DITH_G)-1)+1) * (G); \ |
| 389 |
int msdb = (DITH_N*((DITH_B)-1)+1) * (B); \ |
| 390 |
int i; \ |
| 391 |
for (i=0;i<16;i++) { \ |
| 392 |
int k = xmesa_kernel8[i]; \ |
| 393 |
int j = DITH_MIX( (msdr+k)>>12, (msdg+k)>>12, (msdb+k)>>12 );\ |
| 394 |
ditherValues[i] = (GLushort) ctable[j]; \ |
| 395 |
} \ |
| 396 |
} |
| 397 |
|
| 398 |
#define FLAT_DITHER_ROW_SETUP(Y) \ |
| 399 |
GLushort *ditherRow = ditherValues + ( ((Y)&3) << 2); |
| 400 |
|
| 401 |
#define FLAT_DITHER(X) ditherRow[(X)&3] |
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
/* |
| 406 |
* If pixelformat==PF_LOOKUP: |
| 407 |
*/ |
| 408 |
#define _dither_lookup(C, c) (((unsigned)((DITH_N * (C - 1) + 1) * c)) >> 12) |
| 409 |
|
| 410 |
#define LOOKUP_SETUP \ |
| 411 |
unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table |
| 412 |
|
| 413 |
#define LOOKUP( R, G, B ) \ |
| 414 |
ctable[DITH_MIX(_dither_lookup(DITH_R, (R)), \ |
| 415 |
_dither_lookup(DITH_G, (G)), \ |
| 416 |
_dither_lookup(DITH_B, (B)))] |
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
/* |
| 421 |
* If pixelformat==PF_HPCR: |
| 422 |
* |
| 423 |
* HP Color Recovery dithering ([email protected] 30/08/95) |
| 424 |
* HP has on it's 8-bit 700-series computers, a feature called |
| 425 |
* 'Color Recovery'. This allows near 24-bit output (so they say). |
| 426 |
* It is enabled by selecting the 8-bit TrueColor visual AND |
| 427 |
* corresponding colormap (see tkInitWindow) AND doing some special |
| 428 |
* dither. |
| 429 |
*/ |
| 430 |
extern const short xmesa_HPCR_DRGB[3][2][16]; |
| 431 |
|
| 432 |
#define DITHER_HPCR( X, Y, R, G, B ) \ |
| 433 |
( ((xmesa->xm_visual->hpcr_rgbTbl[0][R] + xmesa_HPCR_DRGB[0][(Y)&1][(X)&15]) & 0xE0) \ |
| 434 |
|(((xmesa->xm_visual->hpcr_rgbTbl[1][G] + xmesa_HPCR_DRGB[1][(Y)&1][(X)&15]) & 0xE0)>>3) \ |
| 435 |
| ((xmesa->xm_visual->hpcr_rgbTbl[2][B] + xmesa_HPCR_DRGB[2][(Y)&1][(X)&15])>>6) \ |
| 436 |
) |
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
/* |
| 441 |
* If pixelformat==PF_1BIT: |
| 442 |
*/ |
| 443 |
extern const int xmesa_kernel1[16]; |
| 444 |
|
| 445 |
#define SETUP_1BIT int bitFlip = xmesa->xm_visual->bitFlip |
| 446 |
#define DITHER_1BIT( X, Y, R, G, B ) \ |
| 447 |
(( ((int)(R)+(int)(G)+(int)(B)) > xmesa_kernel1[(((Y)&3) << 2) | ((X)&3)] ) ^ bitFlip) |
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
/* |
| 452 |
* If pixelformat==PF_GRAYSCALE: |
| 453 |
*/ |
| 454 |
#define GRAY_RGB( R, G, B ) XMESA_BUFFER(ctx->DrawBuffer)->color_table[((R) + (G) + (B))/3] |
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
/* |
| 459 |
* Converts a GL window Y coord to an X window Y coord: |
| 460 |
*/ |
| 461 |
#define YFLIP(XRB, Y) ((XRB)->bottom - (Y)) |
| 462 |
|
| 463 |
|
| 464 |
/* |
| 465 |
* Return the address of a 1, 2 or 4-byte pixel in the buffer's XImage: |
| 466 |
* X==0 is left, Y==0 is bottom. |
| 467 |
*/ |
| 468 |
#define PIXEL_ADDR1(XRB, X, Y) \ |
| 469 |
( (XRB)->origin1 - (Y) * (XRB)->width1 + (X) ) |
| 470 |
|
| 471 |
#define PIXEL_ADDR2(XRB, X, Y) \ |
| 472 |
( (XRB)->origin2 - (Y) * (XRB)->width2 + (X) ) |
| 473 |
|
| 474 |
#define PIXEL_ADDR3(XRB, X, Y) \ |
| 475 |
( (bgr_t *) ( (XRB)->origin3 - (Y) * (XRB)->width3 + 3 * (X) )) |
| 476 |
|
| 477 |
#define PIXEL_ADDR4(XRB, X, Y) \ |
| 478 |
( (XRB)->origin4 - (Y) * (XRB)->width4 + (X) ) |
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
/* |
| 484 |
* Return pointer to XMesaContext corresponding to a Mesa GLcontext. |
| 485 |
* Since we're using structure containment, it's just a cast!. |
| 486 |
*/ |
| 487 |
#define XMESA_CONTEXT(MESACTX) ((XMesaContext) (MESACTX)) |
| 488 |
|
| 489 |
/* |
| 490 |
* Return pointer to XMesaBuffer corresponding to a Mesa GLframebuffer. |
| 491 |
* Since we're using structure containment, it's just a cast!. |
| 492 |
*/ |
| 493 |
#define XMESA_BUFFER(MESABUFF) ((XMesaBuffer) (MESABUFF)) |
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
/* |
| 498 |
* External functions: |
| 499 |
*/ |
| 500 |
|
| 501 |
extern struct xmesa_renderbuffer * |
| 502 |
xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, GLboolean rgbMode); |
| 503 |
|
| 504 |
extern unsigned long |
| 505 |
xmesa_color_to_pixel( GLcontext *ctx, |
| 506 |
GLubyte r, GLubyte g, GLubyte b, GLubyte a, |
| 507 |
GLuint pixelFormat ); |
| 508 |
|
| 509 |
extern void |
| 510 |
xmesa_alloc_back_buffer(XMesaBuffer b, GLuint width, GLuint height); |
| 511 |
|
| 512 |
extern void xmesa_resize_buffers(GLcontext *ctx, GLframebuffer *buffer, |
| 513 |
GLuint width, GLuint height); |
| 514 |
|
| 515 |
extern void xmesa_init_driver_functions( XMesaVisual xmvisual, |
| 516 |
struct dd_function_table *driver ); |
| 517 |
|
| 518 |
extern void xmesa_update_state( GLcontext *ctx, GLuint new_state ); |
| 519 |
|
| 520 |
extern void |
| 521 |
xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb, |
| 522 |
enum pixel_format pixelformat, GLint depth); |
| 523 |
|
| 524 |
|
| 525 |
/* Plugged into the software rasterizer. Try to use internal |
| 526 |
* swrast-style point, line and triangle functions. |
| 527 |
*/ |
| 528 |
extern void xmesa_choose_point( GLcontext *ctx ); |
| 529 |
extern void xmesa_choose_line( GLcontext *ctx ); |
| 530 |
extern void xmesa_choose_triangle( GLcontext *ctx ); |
| 531 |
|
| 532 |
|
| 533 |
extern void xmesa_register_swrast_functions( GLcontext *ctx ); |
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
/* XXX this is a hack to implement shared display lists with 3Dfx */ |
| 538 |
extern XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, |
| 539 |
XMesaWindow w, |
| 540 |
XMesaContext c ); |
| 541 |
|
| 542 |
/* |
| 543 |
* These are the extra routines required for integration with XFree86. |
| 544 |
* None of these routines should be user visible. -KEM |
| 545 |
*/ |
| 546 |
extern void XMesaSetVisualDisplay( XMesaDisplay *dpy, XMesaVisual v ); |
| 547 |
extern GLboolean XMesaForceCurrent(XMesaContext c); |
| 548 |
extern GLboolean XMesaLoseCurrent(XMesaContext c); |
| 549 |
extern void XMesaReset( void ); |
| 550 |
|
| 551 |
|
| 552 |
#define SWTC 0 /* SW texture compression */ |
| 553 |
|
| 554 |
|
| 555 |
#endif |