openbox/otk/pseudorendercontrol.cc

61 lines
1.2 KiB
C++
Raw Normal View History

2003-02-03 07:06:45 +00:00
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2003-02-09 23:07:54 +00:00
#include "config.h"
2003-02-03 07:06:45 +00:00
#include "pseudorendercontrol.hh"
#include "display.hh"
#include "screeninfo.hh"
#include "surface.hh"
#include "rendertexture.hh"
extern "C" {
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif // HAVE_STDLIB_H
#include "../src/gettext.h"
#define _(str) gettext(str)
}
namespace otk {
PseudoRenderControl::PseudoRenderControl(int screen)
: RenderControl(screen)
{
printf("Initializing PseudoColor RenderControl\n");
2003-02-12 00:42:19 +00:00
const ScreenInfo *info = display->screenInfo(_screen);
2003-02-12 01:12:34 +00:00
int depth = info->depth();
_cpc = 4; // XXX THIS SHOULD BE A USER OPTION
_ncolors = _cpc * _cpc * _cpc;
2003-02-12 01:14:02 +00:00
if (_cpc < 2 || _ncolors > 1 << depth) {
2003-02-12 01:12:34 +00:00
fprintf(stderr,
_("PseudoRenderControl: Invalid colormap size. Using maximum size
available.\n"));
_cpc = 1 << (depth/3);
_ncolors = 1 << depth; // _cpc * _cpc * _cpc
}
if (!(_colors = new XColor[_ncolors])) {
fprintf(stderr,
_("PseudoRenderControl: error allocating colormap\n"));
::exit(1);
}
2003-02-03 07:06:45 +00:00
}
PseudoRenderControl::~PseudoRenderControl()
{
printf("Destroying PseudoColor RenderControl\n");
2003-02-12 01:12:34 +00:00
delete _colors;
2003-02-03 07:06:45 +00:00
}
void PseudoRenderControl::reduceDepth(Surface &sf, XImage *im) const
2003-02-11 23:58:33 +00:00
{
}
2003-02-03 07:06:45 +00:00
}