remove dithering code
This commit is contained in:
parent
05feaec548
commit
c492daf2d9
8 changed files with 11 additions and 338 deletions
|
@ -1,5 +1,8 @@
|
|||
(Format: Year/Month/Day)
|
||||
Changes for 1.1
|
||||
*08/06/26:
|
||||
* Remove antiquated dithering code (Mark)
|
||||
FbTk/ImageControl.cc/hh FbTk/TextureRender.cc Screen.cc/hh
|
||||
*08/06/20:
|
||||
* Move default window menu to ~/.fluxbox/windowmenu (Mark)
|
||||
configure.in data/Makefile.am data/windowmenu Screen.cc
|
||||
|
|
6
INSTALL
6
INSTALL
|
@ -75,12 +75,6 @@ every other line in rendered images. This support works only for gradient
|
|||
images. It is compiled in by default, but may be overridden by specifying
|
||||
`--disable-interlace' on the configure script's command line.
|
||||
|
||||
Fluxbox provides an alternative rendering algorithm for dithering on
|
||||
pseudocolor (8 bit) displays. A noticeable pattern is visible when using
|
||||
this; it's a matter of taste whether this looks better than the default
|
||||
algorithm. It is disabled by default, but may be overridden by specifying
|
||||
'--enable-ordered-pseudo' on the configure script's command line.
|
||||
|
||||
Fluxbox uses a timer which allows it to periodically flush its pixmap
|
||||
cache. It is enabled by default, but may be overridden by specifying
|
||||
'--disable-timed-cache' on the configure script's command line.
|
||||
|
|
14
configure.in
14
configure.in
|
@ -290,20 +290,6 @@ AC_ARG_ENABLE(
|
|||
)
|
||||
AM_CONDITIONAL(NEWWMSPEC, test x$NEWWMSPEC = xtrue)
|
||||
|
||||
dnl Check for ordered 8bpp dithering
|
||||
AC_MSG_CHECKING([whether to include Pseudocolor ordered dithering code])
|
||||
AC_ARG_ENABLE(ordered-pseudo,
|
||||
[ --enable-ordered-pseudo include code for ordered pseudocolor (8bpp)
|
||||
dithering ([default=no])],
|
||||
if test x$enableval = "xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE(ORDEREDPSEUDO, 1, "ordered dithering code")
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi,
|
||||
AC_MSG_RESULT([no])
|
||||
)
|
||||
|
||||
dnl Check whether to include debugging code
|
||||
DEBUG=""
|
||||
AC_MSG_CHECKING([whether to include verbose debugging code])
|
||||
|
|
|
@ -104,9 +104,8 @@ struct ImageControl::Cache {
|
|||
unsigned long pixel1, pixel2, texture;
|
||||
};
|
||||
|
||||
ImageControl::ImageControl(int screen_num, bool dither,
|
||||
ImageControl::ImageControl(int screen_num,
|
||||
int cpc, unsigned long cache_timeout, unsigned long cmax):
|
||||
m_dither(dither),
|
||||
m_colors(0),
|
||||
m_num_colors(0),
|
||||
m_colors_per_channel(cpc) {
|
||||
|
@ -318,13 +317,6 @@ void ImageControl::colorTables(const unsigned char **rmt, const unsigned char **
|
|||
if (bbit) *bbit = blue_bits;
|
||||
}
|
||||
|
||||
#ifdef NOT_USED
|
||||
void ImageControl::getXColorTable(XColor **c, int *n) {
|
||||
if (c) *c = m_colors;
|
||||
if (n) *n = m_num_colors;
|
||||
}
|
||||
#endif
|
||||
|
||||
void ImageControl::getGradientBuffers(unsigned int w,
|
||||
unsigned int h,
|
||||
unsigned int **xbuf,
|
||||
|
@ -380,15 +372,6 @@ void ImageControl::installRootColormap() {
|
|||
XUngrabServer(disp);
|
||||
}
|
||||
|
||||
#ifdef NOT_USED
|
||||
void ImageControl::setColorsPerChannel(int cpc) {
|
||||
if (cpc < 2) cpc = 2;
|
||||
if (cpc > 6) cpc = 6;
|
||||
|
||||
m_colors_per_channel = cpc;
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned long ImageControl::getSqrt(unsigned int x) const {
|
||||
if (! sqrt_table) {
|
||||
// build sqrt table for use with elliptic gradient
|
||||
|
@ -449,8 +432,6 @@ void ImageControl::createColorTable() {
|
|||
|
||||
if (bits_per_pixel == 0)
|
||||
bits_per_pixel = m_screen_depth;
|
||||
if (bits_per_pixel >= 24)
|
||||
setDither(false);
|
||||
|
||||
red_offset = green_offset = blue_offset = 0;
|
||||
|
||||
|
@ -501,12 +482,7 @@ void ImageControl::createColorTable() {
|
|||
|
||||
m_colors = new XColor[m_num_colors];
|
||||
|
||||
int bits = 256 / m_colors_per_channel;
|
||||
|
||||
#ifndef ORDEREDPSEUDO
|
||||
bits = 255 / (m_colors_per_channel - 1);
|
||||
#endif // ORDEREDPSEUDO
|
||||
|
||||
int bits = 255 / (m_colors_per_channel - 1);
|
||||
red_bits = green_bits = blue_bits = bits;
|
||||
|
||||
for (unsigned int i = 0; i < 256; i++) {
|
||||
|
|
|
@ -39,14 +39,10 @@ class Texture;
|
|||
/// Holds screen info, color tables and caches textures
|
||||
class ImageControl: private NotCopyable {
|
||||
public:
|
||||
ImageControl(int screen_num, bool dither = false, int colors_per_channel = 4,
|
||||
ImageControl(int screen_num, int colors_per_channel = 4,
|
||||
unsigned long cache_timeout = 300000l, unsigned long cache_max = 200l);
|
||||
virtual ~ImageControl();
|
||||
|
||||
bool doDither() const { return m_dither; }
|
||||
#ifdef NOT_USED
|
||||
int bitsPerPixel() const { return bits_per_pixel; }
|
||||
#endif
|
||||
int depth() const { return m_screen_depth; }
|
||||
int colorsPerChannel() const { return m_colors_per_channel; }
|
||||
int screenNumber() const { return m_screen_num; }
|
||||
|
@ -68,15 +64,8 @@ public:
|
|||
void removeImage(Pixmap thepix);
|
||||
void colorTables(const unsigned char **, const unsigned char **, const unsigned char **,
|
||||
int *, int *, int *, int *, int *, int *) const;
|
||||
#ifdef NOT_USED
|
||||
void getXColorTable(XColor **, int *);
|
||||
#endif
|
||||
void getGradientBuffers(unsigned int, unsigned int,
|
||||
unsigned int **, unsigned int **);
|
||||
void setDither(bool d) { m_dither = d; }
|
||||
#ifdef NOT_USED
|
||||
void setColorsPerChannel(int cpc);
|
||||
#endif
|
||||
|
||||
void cleanCache();
|
||||
private:
|
||||
|
|
|
@ -340,280 +340,13 @@ XImage *TextureRender::renderXImage() {
|
|||
image->data = 0;
|
||||
|
||||
unsigned char *d = new unsigned char[image->bytes_per_line * (height + 1)];
|
||||
register unsigned int x, y, dithx, dithy, r, g, b, o, er, eg, eb, offset;
|
||||
register unsigned int x, y, r, g, b, o, offset;
|
||||
|
||||
unsigned char *pixel_data = d, *ppixel_data = d;
|
||||
unsigned long pixel;
|
||||
|
||||
o = image->bits_per_pixel + ((image->byte_order == MSBFirst) ? 1 : 0);
|
||||
|
||||
if (control.doDither()) {
|
||||
unsigned char dither4[4][4] = {
|
||||
{0, 4, 1, 5},
|
||||
{6, 2, 7, 3},
|
||||
{1, 5, 0, 4},
|
||||
{7, 3, 6, 2} };
|
||||
|
||||
#ifdef ORDEREDPSEUDO
|
||||
unsigned char dither8[8][8] = {
|
||||
{ 0, 32, 8, 40, 2, 34, 10, 42 },
|
||||
{ 48, 16, 56, 24, 50, 18, 58, 26 },
|
||||
{ 12, 44, 4, 36, 14, 46, 6, 38 },
|
||||
{ 60, 28, 52, 20, 62, 30, 54, 22 },
|
||||
{ 3, 35, 11, 43, 1, 33, 9, 41 },
|
||||
{ 51, 19, 59, 27, 49, 17, 57, 25 },
|
||||
{ 15, 47, 7, 39, 13, 45, 5, 37 },
|
||||
{ 63, 31, 55, 23, 61, 29, 53, 21 } };
|
||||
#endif // ORDEREDPSEUDO
|
||||
|
||||
switch (control.visual()->c_class) {
|
||||
case TrueColor:
|
||||
// algorithm: ordered dithering... many many thanks to rasterman
|
||||
// (raster@rasterman.com) for telling me about this... portions of this
|
||||
// code is based off of his code in Imlib
|
||||
for (y = 0, offset = 0; y < height; y++) {
|
||||
dithy = y & 0x3;
|
||||
|
||||
for (x = 0; x < width; x++, offset++) {
|
||||
dithx = x & 0x3;
|
||||
r = red[offset];
|
||||
g = green[offset];
|
||||
b = blue[offset];
|
||||
|
||||
er = r & (red_bits - 1);
|
||||
eg = g & (green_bits - 1);
|
||||
eb = b & (blue_bits - 1);
|
||||
|
||||
r = red_table[r];
|
||||
g = green_table[g];
|
||||
b = blue_table[b];
|
||||
|
||||
if ((dither4[dithy][dithx] < er) && (r < red_table[255])) r++;
|
||||
if ((dither4[dithy][dithx] < eg) && (g < green_table[255])) g++;
|
||||
if ((dither4[dithy][dithx] < eb) && (b < blue_table[255])) b++;
|
||||
|
||||
pixel = (r << red_offset) | (g << green_offset) | (b << blue_offset);
|
||||
|
||||
switch (o) {
|
||||
case 8: // 8bpp
|
||||
*pixel_data++ = pixel;
|
||||
break;
|
||||
|
||||
case 16: // 16bpp LSB
|
||||
*pixel_data++ = pixel;
|
||||
*pixel_data++ = pixel >> 8;
|
||||
break;
|
||||
|
||||
case 17: // 16bpp MSB
|
||||
*pixel_data++ = pixel >> 8;
|
||||
*pixel_data++ = pixel;
|
||||
break;
|
||||
|
||||
case 24: // 24bpp LSB
|
||||
*pixel_data++ = pixel;
|
||||
*pixel_data++ = pixel >> 8;
|
||||
*pixel_data++ = pixel >> 16;
|
||||
break;
|
||||
|
||||
case 25: // 24bpp MSB
|
||||
*pixel_data++ = pixel >> 16;
|
||||
*pixel_data++ = pixel >> 8;
|
||||
*pixel_data++ = pixel;
|
||||
break;
|
||||
|
||||
case 32: // 32bpp LSB
|
||||
*pixel_data++ = pixel;
|
||||
*pixel_data++ = pixel >> 8;
|
||||
*pixel_data++ = pixel >> 16;
|
||||
*pixel_data++ = pixel >> 24;
|
||||
break;
|
||||
|
||||
case 33: // 32bpp MSB
|
||||
*pixel_data++ = pixel >> 24;
|
||||
*pixel_data++ = pixel >> 16;
|
||||
*pixel_data++ = pixel >> 8;
|
||||
*pixel_data++ = pixel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pixel_data = (ppixel_data += image->bytes_per_line);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case StaticColor:
|
||||
case PseudoColor: {
|
||||
#ifndef ORDEREDPSEUDO
|
||||
short *terr,
|
||||
*rerr = new short[width + 2],
|
||||
*gerr = new short[width + 2],
|
||||
*berr = new short[width + 2],
|
||||
*nrerr = new short[width + 2],
|
||||
*ngerr = new short[width + 2],
|
||||
*nberr = new short[width + 2];
|
||||
int rr, gg, bb, rer, ger, ber;
|
||||
int dd = 255 / control.colorsPerChannel();
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
*(rerr + x) = *(red + x);
|
||||
*(gerr + x) = *(green + x);
|
||||
*(berr + x) = *(blue + x);
|
||||
}
|
||||
|
||||
*(rerr + x) = *(gerr + x) = *(berr + x) = 0;
|
||||
#endif // ORDEREDPSEUDO
|
||||
|
||||
for (y = 0, offset = 0; y < height; y++) {
|
||||
#ifdef ORDEREDPSEUDO
|
||||
dithy = y & 7;
|
||||
|
||||
for (x = 0; x < width; x++, offset++) {
|
||||
dithx = x & 7;
|
||||
|
||||
r = red[offset];
|
||||
g = green[offset];
|
||||
b = blue[offset];
|
||||
|
||||
er = r & (red_bits - 1);
|
||||
eg = g & (green_bits - 1);
|
||||
eb = b & (blue_bits - 1);
|
||||
|
||||
r = red_table[r];
|
||||
g = green_table[g];
|
||||
b = blue_table[b];
|
||||
|
||||
if ((dither8[dithy][dithx] < er) && (r < red_table[255])) r++;
|
||||
if ((dither8[dithy][dithx] < eg) && (g < green_table[255])) g++;
|
||||
if ((dither8[dithy][dithx] < eb) && (b < blue_table[255])) b++;
|
||||
|
||||
pixel = (r * cpccpc) + (g * cpc) + b;
|
||||
*(pixel_data++) = colors[pixel].pixel;
|
||||
}
|
||||
|
||||
pixel_data = (ppixel_data += image->bytes_per_line);
|
||||
}
|
||||
#else // !ORDEREDPSEUDO
|
||||
if (y < (height - 1)) {
|
||||
int i = offset + width;
|
||||
for (x = 0; x < width; x++, i++) {
|
||||
*(nrerr + x) = *(red + i);
|
||||
*(ngerr + x) = *(green + i);
|
||||
*(nberr + x) = *(blue + i);
|
||||
}
|
||||
|
||||
*(nrerr + x) = *(red + (--i));
|
||||
*(ngerr + x) = *(green + i);
|
||||
*(nberr + x) = *(blue + i);
|
||||
}
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
rr = rerr[x];
|
||||
gg = gerr[x];
|
||||
bb = berr[x];
|
||||
|
||||
if (rr > 255) rr = 255; else if (rr < 0) rr = 0;
|
||||
if (gg > 255) gg = 255; else if (gg < 0) gg = 0;
|
||||
if (bb > 255) bb = 255; else if (bb < 0) bb = 0;
|
||||
|
||||
r = red_table[rr];
|
||||
g = green_table[gg];
|
||||
b = blue_table[bb];
|
||||
|
||||
rer = rerr[x] - r*dd;
|
||||
ger = gerr[x] - g*dd;
|
||||
ber = berr[x] - b*dd;
|
||||
|
||||
pixel = (r * cpccpc) + (g * cpc) + b;
|
||||
*pixel_data++ = colors[pixel].pixel;
|
||||
|
||||
r = rer >> 1;
|
||||
g = ger >> 1;
|
||||
b = ber >> 1;
|
||||
rerr[x+1] += r;
|
||||
gerr[x+1] += g;
|
||||
berr[x+1] += b;
|
||||
nrerr[x] += r;
|
||||
ngerr[x] += g;
|
||||
nberr[x] += b;
|
||||
}
|
||||
|
||||
offset += width;
|
||||
|
||||
pixel_data = (ppixel_data += image->bytes_per_line);
|
||||
|
||||
terr = rerr;
|
||||
rerr = nrerr;
|
||||
nrerr = terr;
|
||||
|
||||
terr = gerr;
|
||||
gerr = ngerr;
|
||||
ngerr = terr;
|
||||
|
||||
terr = berr;
|
||||
berr = nberr;
|
||||
nberr = terr;
|
||||
}
|
||||
|
||||
delete [] rerr;
|
||||
delete [] gerr;
|
||||
delete [] berr;
|
||||
delete [] nrerr;
|
||||
delete [] ngerr;
|
||||
delete [] nberr;
|
||||
#endif // ORDEREDPSUEDO
|
||||
|
||||
} break;
|
||||
|
||||
/*
|
||||
case StaticGray:
|
||||
case GrayScale:
|
||||
for (y = 0, offset = 0; y < height; y++) {
|
||||
dithy = y & 0x3;
|
||||
|
||||
for (x = 0; x < width; x++, offset++) {
|
||||
dithx = x & 0x3;
|
||||
|
||||
r = *(red + offset);
|
||||
g = *(green + offset);
|
||||
b = *(blue + offset);
|
||||
|
||||
er = r & 0x7;
|
||||
eg = g & 0x7;
|
||||
eb = b & 0x7;
|
||||
|
||||
if ((dither[dithy][dithx] < er) && (r < (256 - 8)))
|
||||
r += 8;
|
||||
if ((dither[dithy][dithx] < (eg << 1)) && (g < (256 - 4)))
|
||||
g += 4;
|
||||
if ((dither[dithy][dithx] < eb) && (b < (256 - 8)))
|
||||
b += 8;
|
||||
|
||||
r = *(red_table + r);
|
||||
g = *(green_table + g);
|
||||
b = *(blue_table + b);
|
||||
|
||||
g = ((r * 30) + (g * 59) + (b * 11)) / 100;
|
||||
*pixel_data++ = colors[g].pixel;
|
||||
}
|
||||
|
||||
pixel_data = (ppixel_data += image->bytes_per_line);
|
||||
}
|
||||
|
||||
break;
|
||||
*/
|
||||
|
||||
default:
|
||||
_FB_USES_NLS;
|
||||
cerr << "TextureRender::renderXImage(): " <<
|
||||
_FBTK_CONSOLETEXT(Error, UnsupportedVisual, "Unsupported visual", "A visual is a technical term in X") << endl;
|
||||
delete [] d;
|
||||
XDestroyImage(image);
|
||||
return (XImage *) 0;
|
||||
}
|
||||
} else { // end do dither
|
||||
|
||||
// no dither:
|
||||
switch (control.visual()->c_class) {
|
||||
case StaticColor:
|
||||
case PseudoColor:
|
||||
|
@ -714,10 +447,9 @@ XImage *TextureRender::renderXImage() {
|
|||
XDestroyImage(image);
|
||||
return (XImage *) 0;
|
||||
}
|
||||
}
|
||||
|
||||
image->data = (char *) d;
|
||||
return image;
|
||||
image->data = (char *) d;
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -264,7 +264,6 @@ getString() const {
|
|||
BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm,
|
||||
const string &scrname,
|
||||
const string &altscrname):
|
||||
image_dither(rm, false, scrname+".imageDither", altscrname+".ImageDither"),
|
||||
opaque_move(rm, false, scrname + ".opaqueMove", altscrname+".OpaqueMove"),
|
||||
full_max(rm, false, scrname+".fullMaximization", altscrname+".FullMaximization"),
|
||||
max_ignore_inc(rm, true, scrname+".maxIgnoreIncrement", altscrname+".MaxIgnoreIncrement"),
|
||||
|
@ -446,7 +445,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
|
|||
fluxbox->load_rc(*this);
|
||||
|
||||
// setup image cache engine
|
||||
m_image_control.reset(new FbTk::ImageControl(scrn, true,
|
||||
m_image_control.reset(new FbTk::ImageControl(scrn,
|
||||
fluxbox->colorsPerChannel(),
|
||||
fluxbox->getCacheLife(), fluxbox->getCacheMax()));
|
||||
imageControl().installRootColormap();
|
||||
|
@ -479,8 +478,6 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
|
|||
m_menutheme->setDelayOpen(*resource.menu_delay);
|
||||
m_menutheme->setDelayClose(*resource.menu_delay_close);
|
||||
|
||||
imageControl().setDither(*resource.image_dither);
|
||||
|
||||
focusedWinFrameTheme()->reconfigSig().attach(this);// for geom window
|
||||
|
||||
|
||||
|
@ -1775,9 +1772,6 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
|
|||
for (; it != it_end; ++it)
|
||||
menu.insert(it->first, it->second);
|
||||
|
||||
_BOOLITEM(menu, Configmenu, ImageDithering,
|
||||
"Image Dithering", "Image Dithering",
|
||||
resource.image_dither, save_and_reconfigure);
|
||||
_BOOLITEM(menu, Configmenu, OpaqueMove,
|
||||
"Opaque Window Moving",
|
||||
"Window Moving with whole window visible (as opposed to outline moving)",
|
||||
|
|
|
@ -550,7 +550,7 @@ private:
|
|||
ScreenResource(FbTk::ResourceManager &rm, const std::string &scrname,
|
||||
const std::string &altscrname);
|
||||
|
||||
FbTk::Resource<bool> image_dither, opaque_move, full_max,
|
||||
FbTk::Resource<bool> opaque_move, full_max,
|
||||
max_ignore_inc, max_disable_move, max_disable_resize,
|
||||
workspace_warping, show_window_pos, auto_raise, click_raises,
|
||||
decorate_transient;
|
||||
|
@ -560,7 +560,6 @@ private:
|
|||
FbTk::Resource<std::string> windowmenufile;
|
||||
FbTk::Resource<unsigned int> typing_delay;
|
||||
FbTk::Resource<FollowModel> follow_model, user_follow_model;
|
||||
bool ordered_dither;
|
||||
FbTk::Resource<int> workspaces, edge_snap_threshold, focused_alpha,
|
||||
unfocused_alpha, menu_alpha, menu_delay, menu_delay_close,
|
||||
tab_width, tooltip_delay;
|
||||
|
|
Loading…
Reference in a new issue