From d737ad52720f2c6b10ea02cef1e3c046e52bee15 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 24 Jan 2003 15:33:22 +0000 Subject: [PATCH] renamed dither-related preprocessor symbols (bug 536406) --- src/mesa/drivers/x11/xm_api.c | 28 +++++++------- src/mesa/drivers/x11/xmesaP.h | 69 ++++++++++++++++------------------- 2 files changed, 46 insertions(+), 51 deletions(-) diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 4a2bd72527e..a8ce2f9c678 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1,10 +1,10 @@ -/* $Id: xm_api.c,v 1.51 2002/11/10 17:07:06 brianp Exp $ */ +/* $Id: xm_api.c,v 1.52 2003/01/24 15:33:22 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 5.0 + * Version: 5.0.1 * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -908,14 +908,14 @@ static GLboolean setup_dithered_color( int client, XMesaVisual v, /* Allocate X colors and initialize color_table[], red_table[], etc */ int r, g, b, i; int colorsfailed = 0; - for (r = 0; r < _R; r++) { - for (g = 0; g < _G; g++) { - for (b = 0; b < _B; b++) { + for (r = 0; r < DITH_R; r++) { + for (g = 0; g < DITH_G; g++) { + for (b = 0; b < DITH_B; b++) { XMesaColor xcol; int exact, alloced; - xcol.red =gamma_adjust(v->RedGamma, r*65535/(_R-1),65535); - xcol.green=gamma_adjust(v->GreenGamma, g*65535/(_G-1),65535); - xcol.blue =gamma_adjust(v->BlueGamma, b*65535/(_B-1),65535); + xcol.red =gamma_adjust(v->RedGamma, r*65535/(DITH_R-1),65535); + xcol.green=gamma_adjust(v->GreenGamma, g*65535/(DITH_G-1),65535); + xcol.blue =gamma_adjust(v->BlueGamma, b*65535/(DITH_B-1),65535); noFaultXAllocColor( client, v->display, cmap, GET_COLORMAP_SIZE(v), &xcol, &exact, &alloced ); @@ -927,13 +927,13 @@ static GLboolean setup_dithered_color( int client, XMesaVisual v, buffer->alloced_colors[buffer->num_alloced] = xcol.pixel; buffer->num_alloced++; } - i = _MIX( r, g, b ); + i = DITH_MIX( r, g, b ); assert(i < 576); buffer->color_table[i] = xcol.pixel; assert(xcol.pixel < 65536); - buffer->pixel_to_r[xcol.pixel] = r * 255 / (_R-1); - buffer->pixel_to_g[xcol.pixel] = g * 255 / (_G-1); - buffer->pixel_to_b[xcol.pixel] = b * 255 / (_B-1); + buffer->pixel_to_r[xcol.pixel] = r * 255 / (DITH_R-1); + buffer->pixel_to_g[xcol.pixel] = g * 255 / (DITH_G-1); + buffer->pixel_to_b[xcol.pixel] = b * 255 / (DITH_B-1); } } } @@ -941,7 +941,7 @@ static GLboolean setup_dithered_color( int client, XMesaVisual v, if (colorsfailed && _mesa_getenv("MESA_DEBUG")) { _mesa_warning(NULL, "Note: %d out of %d needed colors do not match exactly.\n", - colorsfailed, _R*_G*_B ); + colorsfailed, DITH_R * DITH_G * DITH_B ); } } } diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 9df063539da..8afcba69be3 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -1,10 +1,10 @@ -/* $Id: xmesaP.h,v 1.32 2002/11/10 17:07:06 brianp Exp $ */ +/* $Id: xmesaP.h,v 1.33 2003/01/24 15:33:22 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 5.0 + * Version: 5.0.1 * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -316,36 +316,31 @@ struct xmesa_buffer { * Improved 8-bit RGB dithering code contributed by Bob Mercier * (mercier@hollywood.cinenet.net). Thanks Bob! */ -#undef _R -#undef _G -#undef _B -#undef _D #ifdef DITHER666 -# define _R 6 -# define _G 6 -# define _B 6 -# define _MIX(r,g,b) (((r)*_G+(g))*_B+(b)) +# define DITH_R 6 +# define DITH_G 6 +# define DITH_B 6 +# define DITH_MIX(r,g,b) (((r) * DITH_G + (g)) * DITH_B + (b)) #else -# define _R 5 -# define _G 9 -# define _B 5 -# define _MIX(r,g,b) ( ((g)<<6) | ((b)<<3) | (r) ) +# define DITH_R 5 +# define DITH_G 9 +# define DITH_B 5 +# define DITH_MIX(r,g,b) (((g) << 6) | ((b) << 3) | (r)) #endif -#define _DX 4 -#define _DY 4 -#define _D (_DX*_DY) +#define DITH_DX 4 +#define DITH_DY 4 +#define DITH_N (DITH_DX * DITH_DY) -/*#define _DITH(C,c,d) (((unsigned)((_D*(C-1)+1)*c+d))/(_D*256))*/ -#define _DITH(C,c,d) (((unsigned)((_D*(C-1)+1)*c+d)) >> 12) +/*#define _dither(C,c,d) (((unsigned)((DITH_N*(C-1)+1)*c+d))/(DITH_N*256))*/ +#define _dither(C, c, d) (((unsigned)((DITH_N * (C - 1) + 1) * c + d)) >> 12) #define MAXC 256 -static int kernel8[_DY*_DX] = { +static int kernel8[DITH_DY * DITH_DX] = { 0 * MAXC, 8 * MAXC, 2 * MAXC, 10 * MAXC, 12 * MAXC, 4 * MAXC, 14 * MAXC, 6 * MAXC, 3 * MAXC, 11 * MAXC, 1 * MAXC, 9 * MAXC, 15 * MAXC, 7 * MAXC, 13 * MAXC, 5 * MAXC, }; -/*static int __d;*/ /* Dither for random X,Y */ #define DITHER_SETUP \ @@ -354,9 +349,9 @@ static int kernel8[_DY*_DX] = { #define DITHER( X, Y, R, G, B ) \ (__d = kernel8[(((Y)&3)<<2) | ((X)&3)], \ - ctable[_MIX(_DITH(_R, (R), __d), \ - _DITH(_G, (G), __d), \ - _DITH(_B, (B), __d))]) + ctable[DITH_MIX(_dither(DITH_R, (R), __d), \ + _dither(DITH_G, (G), __d), \ + _dither(DITH_B, (B), __d))]) /* Dither for random X, fixed Y */ #define XDITHER_SETUP(Y) \ @@ -366,9 +361,9 @@ static int kernel8[_DY*_DX] = { #define XDITHER( X, R, G, B ) \ (__d = kernel[(X)&3], \ - ctable[_MIX(_DITH(_R, (R), __d), \ - _DITH(_G, (G), __d), \ - _DITH(_B, (B), __d))]) + ctable[DITH_MIX(_dither(DITH_R, (R), __d), \ + _dither(DITH_G, (G), __d), \ + _dither(DITH_B, (B), __d))]) @@ -381,13 +376,13 @@ static GLushort DitherValues[16]; /* array of (up to) 16-bit pixel values */ #define FLAT_DITHER_SETUP( R, G, B ) \ { \ unsigned long *ctable = xmesa->xm_buffer->color_table; \ - int msdr = (_D*((_R)-1)+1) * (R); \ - int msdg = (_D*((_G)-1)+1) * (G); \ - int msdb = (_D*((_B)-1)+1) * (B); \ + int msdr = (DITH_N*((DITH_R)-1)+1) * (R); \ + int msdg = (DITH_N*((DITH_G)-1)+1) * (G); \ + int msdb = (DITH_N*((DITH_B)-1)+1) * (B); \ int i; \ for (i=0;i<16;i++) { \ int k = kernel8[i]; \ - int j = _MIX( (msdr+k)>>12, (msdg+k)>>12, (msdb+k)>>12 ); \ + int j = DITH_MIX( (msdr+k)>>12, (msdg+k)>>12, (msdb+k)>>12 ); \ DitherValues[i] = (GLushort) ctable[j]; \ } \ } @@ -402,15 +397,15 @@ static GLushort DitherValues[16]; /* array of (up to) 16-bit pixel values */ /* * If pixelformat==PF_LOOKUP: */ -#define _DITH0(C,c) (((unsigned)((_D*(C-1)+1)*c)) >> 12) +#define _dither_lookup(C, c) (((unsigned)((DITH_N * (C - 1) + 1) * c)) >> 12) #define LOOKUP_SETUP \ unsigned long *ctable = xmesa->xm_buffer->color_table -#define LOOKUP( R, G, B ) \ - ctable[_MIX(_DITH0(_R, (R)), \ - _DITH0(_G, (G)), \ - _DITH0(_B, (B)))] +#define LOOKUP( R, G, B ) \ + ctable[DITH_MIX(_dither_lookup(DITH_R, (R)), \ + _dither_lookup(DITH_G, (G)), \ + _dither_lookup(DITH_B, (B)))] -- 2.30.2