]> Dogcows Code - chaz/openbox/blobdiff - otk/pseudorendercontrol.cc
more efficient/nicer way to get the XColor values
[chaz/openbox] / otk / pseudorendercontrol.cc
index 9759dc70938258671fa2d6d6a312767e4d6923ff..c30e77f9b32c0609caae6bd7abd9976978f35ca8 100644 (file)
@@ -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);
-  }
 }
 
 }
This page took 0.022014 seconds and 4 git commands to generate.