only store what we need to in the class
This commit is contained in:
parent
dd89811570
commit
7a2a461582
2 changed files with 14 additions and 28 deletions
|
@ -26,30 +26,26 @@ PseudoRenderControl::PseudoRenderControl(int screen)
|
||||||
const ScreenInfo *info = display->screenInfo(_screen);
|
const ScreenInfo *info = display->screenInfo(_screen);
|
||||||
int depth = info->depth();
|
int depth = info->depth();
|
||||||
|
|
||||||
_bpc = 2; // XXX THIS SHOULD BE A USER OPTION
|
// determine the number of colors and the bits-per-color
|
||||||
assert(_bpc >= 1);
|
int bpc = 2; // XXX THIS SHOULD BE A USER OPTION
|
||||||
_ncolors = 1 << (_bpc * 3);
|
assert(bpc >= 1);
|
||||||
|
_ncolors = 1 << (bpc * 3);
|
||||||
|
|
||||||
if (_ncolors > 1 << depth) {
|
if (_ncolors > 1 << depth) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
_("PseudoRenderControl: Invalid colormap size. Resizing.\n"));
|
_("PseudoRenderControl: Invalid colormap size. Resizing.\n"));
|
||||||
_bpc = 1 << (depth/3) >> 3;
|
bpc = 1 << (depth/3) >> 3;
|
||||||
_ncolors = 1 << (_bpc * 3);
|
_ncolors = 1 << (bpc * 3);
|
||||||
}
|
|
||||||
|
|
||||||
_cpc = 1 << _bpc;
|
|
||||||
|
|
||||||
if (!(_colors = new XColor[_ncolors])) {
|
|
||||||
fprintf(stderr,
|
|
||||||
_("PseudoRenderControl: error allocating colormap\n"));
|
|
||||||
::exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// build a color cube
|
// build a color cube
|
||||||
|
_colors = new XColor[_ncolors];
|
||||||
|
|
||||||
|
int cpc = 1 << bpc; // colors per channel
|
||||||
for (int n = _ncolors - 1,
|
for (int n = _ncolors - 1,
|
||||||
r = (1 << (_bpc + 1)) -1, i = 0; i < _cpc; r >>= 1, ++i)
|
r = (1 << (bpc + 1)) -1, i = 0; i < cpc; r >>= 1, ++i)
|
||||||
for (int g = (1 << (_bpc + 1)) -1, j = 0; j < _cpc; g >>= 1, ++j)
|
for (int g = (1 << (bpc + 1)) -1, j = 0; j < cpc; g >>= 1, ++j)
|
||||||
for (int b = (1 << (_bpc + 1)) -1, k = 0; k < _cpc; b >>= 1, ++k, --n) {
|
for (int b = (1 << (bpc + 1)) -1, k = 0; k < cpc; b >>= 1, ++k, --n) {
|
||||||
_colors[n].red = r | r << 8;
|
_colors[n].red = r | r << 8;
|
||||||
_colors[n].green = g | g << 8;
|
_colors[n].green = g | g << 8;
|
||||||
_colors[n].blue = b | b << 8;
|
_colors[n].blue = b | b << 8;
|
||||||
|
|
|
@ -8,18 +8,8 @@ namespace otk {
|
||||||
|
|
||||||
class PseudoRenderControl : public RenderControl {
|
class PseudoRenderControl : public RenderControl {
|
||||||
private:
|
private:
|
||||||
// color tables, meaning, 256 (possibly) different shades of each color,
|
int _ncolors; // number of allocated colors, size of the XColor array
|
||||||
// based on the number of bits there are available for each color in the
|
XColor *_colors; // the valid allocated colors
|
||||||
// visual
|
|
||||||
unsigned char _red_color_table[256];
|
|
||||||
unsigned char _green_color_table[256];
|
|
||||||
unsigned char _blue_color_table[256];
|
|
||||||
|
|
||||||
int _cpc; // colors-per-channel: must be a value between [2,6]
|
|
||||||
int _bpp; // bits-per-pixel
|
|
||||||
int _ncolors; // number of allocated colors, size of the XColor array
|
|
||||||
|
|
||||||
XColor *_colors;
|
|
||||||
|
|
||||||
virtual void reduceDepth(Surface &sf, XImage *im) const;
|
virtual void reduceDepth(Surface &sf, XImage *im) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue