X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=otk%2Fpseudorendercontrol.cc;h=c30e77f9b32c0609caae6bd7abd9976978f35ca8;hb=a0738a0197b23d1bb2b2a58ae8d82a998fbf2d99;hp=9759dc70938258671fa2d6d6a312767e4d6923ff;hpb=e6bfddf849009bef7bbb75be5147b4a533fa1ad2;p=chaz%2Fopenbox diff --git a/otk/pseudorendercontrol.cc b/otk/pseudorendercontrol.cc index 9759dc70..c30e77f9 100644 --- a/otk/pseudorendercontrol.cc +++ b/otk/pseudorendercontrol.cc @@ -1,8 +1,6 @@ // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- -#ifdef HAVE_CONFIG_H -# include "../config.h" -#endif // HAVE_CONFIG_H +#include "config.h" #include "pseudorendercontrol.hh" #include "display.hh" @@ -24,35 +22,39 @@ namespace otk { PseudoRenderControl::PseudoRenderControl(int screen) : RenderControl(screen) { + printf("Initializing PseudoColor RenderControl\n"); const ScreenInfo *info = display->screenInfo(_screen); + int depth = info->depth(); - printf("Initializing PseudoColor RenderControl\n"); + _cpc = 4; // XXX THIS SHOULD BE A USER OPTION + _ncolors = _cpc * _cpc * _cpc; + + if (_cpc < 2 || _ncolors > 1 << depth) { + 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); + } + } PseudoRenderControl::~PseudoRenderControl() { printf("Destroying PseudoColor RenderControl\n"); - -} - -void PseudoRenderControl::drawGradientBackground( - Surface &sf, const RenderTexture &texture) const -{ + delete _colors; } -void PseudoRenderControl::drawBackground(Surface& sf, - const RenderTexture &texture) const +void PseudoRenderControl::reduceDepth(Surface &sf, XImage *im) const { - assert(_screen == sf._screen); - assert(_screen == texture.color().screen()); - - if (texture.gradient() == RenderTexture::Solid) { - drawSolidBackground(sf, texture); - } else { - drawGradientBackground(sf, texture); - } } }