support pseudocolor and greyscale displays by, using solid colors instead of gradients
This commit is contained in:
parent
e6bfddf849
commit
afb8a28120
5 changed files with 15 additions and 73 deletions
|
@ -24,22 +24,12 @@ namespace otk {
|
||||||
PseudoRenderControl::PseudoRenderControl(int screen)
|
PseudoRenderControl::PseudoRenderControl(int screen)
|
||||||
: RenderControl(screen)
|
: RenderControl(screen)
|
||||||
{
|
{
|
||||||
const ScreenInfo *info = display->screenInfo(_screen);
|
|
||||||
|
|
||||||
printf("Initializing PseudoColor RenderControl\n");
|
printf("Initializing PseudoColor RenderControl\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PseudoRenderControl::~PseudoRenderControl()
|
PseudoRenderControl::~PseudoRenderControl()
|
||||||
{
|
{
|
||||||
printf("Destroying PseudoColor RenderControl\n");
|
printf("Destroying PseudoColor RenderControl\n");
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void PseudoRenderControl::drawGradientBackground(
|
|
||||||
Surface &sf, const RenderTexture &texture) const
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PseudoRenderControl::drawBackground(Surface& sf,
|
void PseudoRenderControl::drawBackground(Surface& sf,
|
||||||
|
@ -48,11 +38,9 @@ void PseudoRenderControl::drawBackground(Surface& sf,
|
||||||
assert(_screen == sf._screen);
|
assert(_screen == sf._screen);
|
||||||
assert(_screen == texture.color().screen());
|
assert(_screen == texture.color().screen());
|
||||||
|
|
||||||
if (texture.gradient() == RenderTexture::Solid) {
|
// in psuedo color, gradients aren't even worth while! just draw a solid!
|
||||||
drawSolidBackground(sf, texture);
|
//if (texture.gradient() == RenderTexture::Solid) {
|
||||||
} else {
|
drawSolidBackground(sf, texture);
|
||||||
drawGradientBackground(sf, texture);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,6 @@ namespace otk {
|
||||||
class PseudoRenderControl : public RenderControl {
|
class PseudoRenderControl : public RenderControl {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
virtual void drawGradientBackground(Surface &sf,
|
|
||||||
const RenderTexture &texture) const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PseudoRenderControl(int screen);
|
PseudoRenderControl(int screen);
|
||||||
virtual ~PseudoRenderControl();
|
virtual ~PseudoRenderControl();
|
||||||
|
|
|
@ -38,7 +38,7 @@ RenderControl *RenderControl::getRenderControl(int screen)
|
||||||
return new PseudoRenderControl(screen);
|
return new PseudoRenderControl(screen);
|
||||||
case GrayScale:
|
case GrayScale:
|
||||||
case StaticGray:
|
case StaticGray:
|
||||||
// return new GrayRenderControl(screen);
|
return new PseudoRenderControl(screen);
|
||||||
default:
|
default:
|
||||||
printf(_("RenderControl: Unsupported visual %d specified. Aborting.\n"),
|
printf(_("RenderControl: Unsupported visual %d specified. Aborting.\n"),
|
||||||
vclass);
|
vclass);
|
||||||
|
|
|
@ -57,9 +57,11 @@ void Surface::createObjects()
|
||||||
|
|
||||||
_pixmap = XCreatePixmap(**display, info->rootWindow(),
|
_pixmap = XCreatePixmap(**display, info->rootWindow(),
|
||||||
_size.x(), _size.y(), info->depth());
|
_size.x(), _size.y(), info->depth());
|
||||||
|
assert(_pixmap != None);
|
||||||
|
|
||||||
_xftdraw = XftDrawCreate(**display, _pixmap,
|
_xftdraw = XftDrawCreate(**display, _pixmap,
|
||||||
info->visual(), info->colormap());
|
info->visual(), info->colormap());
|
||||||
|
assert(_xftdraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Surface::destroyObjects()
|
void Surface::destroyObjects()
|
||||||
|
|
|
@ -53,53 +53,6 @@ TrueRenderControl::TrueRenderControl(int screen)
|
||||||
TrueRenderControl::~TrueRenderControl()
|
TrueRenderControl::~TrueRenderControl()
|
||||||
{
|
{
|
||||||
printf("Destroying TrueColor RenderControl\n");
|
printf("Destroying TrueColor RenderControl\n");
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline void renderPixel(XImage *im, unsigned char *dp,
|
|
||||||
unsigned long pixel)
|
|
||||||
{
|
|
||||||
unsigned int bpp = im->bits_per_pixel + (im->byte_order == MSBFirst ? 1 : 0);
|
|
||||||
|
|
||||||
switch (bpp) {
|
|
||||||
case 8: // 8bpp
|
|
||||||
*dp++ = pixel;
|
|
||||||
break;
|
|
||||||
case 16: // 16bpp LSB
|
|
||||||
*dp++ = pixel;
|
|
||||||
*dp++ = pixel >> 8;
|
|
||||||
break;
|
|
||||||
case 17: // 16bpp MSB
|
|
||||||
*dp++ = pixel >> 8;
|
|
||||||
*dp++ = pixel;
|
|
||||||
break;
|
|
||||||
case 24: // 24bpp LSB
|
|
||||||
*dp++ = pixel;
|
|
||||||
*dp++ = pixel >> 8;
|
|
||||||
*dp++ = pixel >> 16;
|
|
||||||
break;
|
|
||||||
case 25: // 24bpp MSB
|
|
||||||
*dp++ = pixel >> 16;
|
|
||||||
*dp++ = pixel >> 8;
|
|
||||||
*dp++ = pixel;
|
|
||||||
break;
|
|
||||||
case 32: // 32bpp LSB
|
|
||||||
*dp++ = pixel;
|
|
||||||
*dp++ = pixel >> 8;
|
|
||||||
*dp++ = pixel >> 16;
|
|
||||||
*dp++ = pixel >> 24;
|
|
||||||
break;
|
|
||||||
case 33: // 32bpp MSB
|
|
||||||
*dp++ = pixel >> 24;
|
|
||||||
*dp++ = pixel >> 16;
|
|
||||||
*dp++ = pixel >> 8;
|
|
||||||
*dp++ = pixel;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(false); // wtf?
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrueRenderControl::drawGradientBackground(
|
void TrueRenderControl::drawGradientBackground(
|
||||||
|
@ -244,8 +197,8 @@ void TrueRenderControl::diagonalGradient(Surface &sf,
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrueRenderControl::crossDiagonalGradient(Surface &sf,
|
void TrueRenderControl::crossDiagonalGradient(Surface &sf,
|
||||||
const RenderTexture &texture,
|
const RenderTexture &texture,
|
||||||
pixel32 *data) const
|
pixel32 *data) const
|
||||||
{
|
{
|
||||||
pixel32 current;
|
pixel32 current;
|
||||||
float drx, dgx, dbx, dry, dgy, dby;
|
float drx, dgx, dbx, dry, dgy, dby;
|
||||||
|
@ -274,12 +227,13 @@ void TrueRenderControl::crossDiagonalGradient(Surface &sf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrueRenderControl::reduceDepth(XImage *im, pixel32 *data) const
|
void TrueRenderControl::reduceDepth(XImage *im, pixel32 *data) const
|
||||||
{
|
{
|
||||||
// since pixel32 is the largest possible pixel size, we can share the array
|
// since pixel32 is the largest possible pixel size, we can share the array
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
int x,y;
|
int x,y;
|
||||||
pixel16 *p = (pixel16 *)data;
|
pixel16 *p = (pixel16*) data;
|
||||||
switch (im->bits_per_pixel) {
|
switch (im->bits_per_pixel) {
|
||||||
case 32:
|
case 32:
|
||||||
if ((_red_offset != default_red_shift) ||
|
if ((_red_offset != default_red_shift) ||
|
||||||
|
@ -291,7 +245,8 @@ void TrueRenderControl::reduceDepth(XImage *im, pixel32 *data) const
|
||||||
r = (data[x] >> default_red_shift) & 0xFF;
|
r = (data[x] >> default_red_shift) & 0xFF;
|
||||||
g = (data[x] >> default_green_shift) & 0xFF;
|
g = (data[x] >> default_green_shift) & 0xFF;
|
||||||
b = (data[x] >> default_blue_shift) & 0xFF;
|
b = (data[x] >> default_blue_shift) & 0xFF;
|
||||||
data[x] = (r << _red_offset) + (g << _green_offset) + (b << _blue_offset);
|
data[x] = (r << _red_offset) + (g << _green_offset) +
|
||||||
|
(b << _blue_offset);
|
||||||
}
|
}
|
||||||
data += im->width;
|
data += im->width;
|
||||||
}
|
}
|
||||||
|
@ -350,17 +305,17 @@ void TrueRenderControl::highlight(pixel32 *x, pixel32 *y, bool raised) const
|
||||||
*down = (r << default_red_shift) + (g << default_green_shift)
|
*down = (r << default_red_shift) + (g << default_green_shift)
|
||||||
+ (b << default_blue_shift);
|
+ (b << default_blue_shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrueRenderControl::drawBackground(Surface& sf,
|
void TrueRenderControl::drawBackground(Surface& sf,
|
||||||
const RenderTexture &texture) const
|
const RenderTexture &texture) const
|
||||||
{
|
{
|
||||||
assert(_screen == sf._screen);
|
assert(_screen == sf._screen);
|
||||||
assert(_screen == texture.color().screen());
|
assert(_screen == texture.color().screen());
|
||||||
|
|
||||||
if (texture.gradient() == RenderTexture::Solid) {
|
if (texture.gradient() == RenderTexture::Solid)
|
||||||
drawSolidBackground(sf, texture);
|
drawSolidBackground(sf, texture);
|
||||||
} else {
|
else
|
||||||
drawGradientBackground(sf, texture);
|
drawGradientBackground(sf, texture);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue