]> Dogcows Code - chaz/openbox/commitdiff
support pseudocolor and greyscale displays by, using solid colors instead of gradients
authorDana Jansens <danakj@orodu.net>
Mon, 3 Feb 2003 07:41:25 +0000 (07:41 +0000)
committerDana Jansens <danakj@orodu.net>
Mon, 3 Feb 2003 07:41:25 +0000 (07:41 +0000)
otk/pseudorendercontrol.cc
otk/pseudorendercontrol.hh
otk/rendercontrol.cc
otk/surface.cc
otk/truerendercontrol.cc

index 9759dc70938258671fa2d6d6a312767e4d6923ff..813eb4d18b750a44627a8c3f344d90cc35e31899 100644 (file)
@@ -24,22 +24,12 @@ namespace otk {
 PseudoRenderControl::PseudoRenderControl(int screen)
   : RenderControl(screen)
 {
-  const ScreenInfo *info = display->screenInfo(_screen);
-
   printf("Initializing PseudoColor RenderControl\n");
-
 }
 
 PseudoRenderControl::~PseudoRenderControl()
 {
   printf("Destroying PseudoColor RenderControl\n");
-
-
-}
-
-void PseudoRenderControl::drawGradientBackground(
-     Surface &sf, const RenderTexture &texture) const
-{
 }
 
 void PseudoRenderControl::drawBackground(Surface& sf,
@@ -48,11 +38,9 @@ void PseudoRenderControl::drawBackground(Surface& sf,
   assert(_screen == sf._screen);
   assert(_screen == texture.color().screen());
 
-  if (texture.gradient() == RenderTexture::Solid) {
-    drawSolidBackground(sf, texture);
-  } else {
-    drawGradientBackground(sf, texture);
-  }
+  // in psuedo color, gradients aren't even worth while! just draw a solid!
+  //if (texture.gradient() == RenderTexture::Solid) {
+  drawSolidBackground(sf, texture);
 }
 
 }
index 6d3255ee4c28439e92e1293bc60f4fd4bcfadad4..a1a12a811c56d0078e703946bb54e9e136a11e04 100644 (file)
@@ -23,9 +23,6 @@ namespace otk {
 class PseudoRenderControl : public RenderControl {
 private:
 
-  virtual void drawGradientBackground(Surface &sf,
-                                      const RenderTexture &texture) const;
 public:
   PseudoRenderControl(int screen);
   virtual ~PseudoRenderControl();
index ebd2cfc84b12711b8fbde0fcd21fbfccef9c3401..aae6c76bfa3a01f02b3c82f06c3f15f74de8c6e3 100644 (file)
@@ -38,7 +38,7 @@ RenderControl *RenderControl::getRenderControl(int screen)
     return new PseudoRenderControl(screen);
   case GrayScale:
   case StaticGray:
-//    return new GrayRenderControl(screen);
+    return new PseudoRenderControl(screen);
   default:
     printf(_("RenderControl: Unsupported visual %d specified. Aborting.\n"),
           vclass);
index 70acf70ac5f16289897bcdad0be7c99f94c94928..9dfb88898043faaac22541e4060c4bbb03e63649 100644 (file)
@@ -57,9 +57,11 @@ void Surface::createObjects()
   
   _pixmap = XCreatePixmap(**display, info->rootWindow(),
                           _size.x(), _size.y(), info->depth());
+  assert(_pixmap != None);
     
   _xftdraw = XftDrawCreate(**display, _pixmap,
                            info->visual(), info->colormap());
+  assert(_xftdraw);
 }
 
 void Surface::destroyObjects()
index ec64be24672a4ee760d28cc77d4a79b343168e42..5e9f318817de214fdbf659b6b9ff3d098932c9a5 100644 (file)
@@ -53,53 +53,6 @@ TrueRenderControl::TrueRenderControl(int screen)
 TrueRenderControl::~TrueRenderControl()
 {
   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(
@@ -244,8 +197,8 @@ void TrueRenderControl::diagonalGradient(Surface &sf,
 }
 
 void TrueRenderControl::crossDiagonalGradient(Surface &sf,
-                                         const RenderTexture &texture,
-                                         pixel32 *data) const
+                                              const RenderTexture &texture,
+                                              pixel32 *data) const
 {
   pixel32 current;
   float drx, dgx, dbx, dry, dgy, dby;
@@ -274,12 +227,13 @@ void TrueRenderControl::crossDiagonalGradient(Surface &sf,
     }
   }
 }
+
 void TrueRenderControl::reduceDepth(XImage *im, pixel32 *data) const
 {
 // since pixel32 is the largest possible pixel size, we can share the array
   int r, g, b;
   int x,y;
-  pixel16 *p = (pixel16 *)data;
+  pixel16 *p = (pixel16*) data;
   switch (im->bits_per_pixel) {
   case 32:
     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;
           g = (data[x] >> default_green_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;
       } 
@@ -350,17 +305,17 @@ void TrueRenderControl::highlight(pixel32 *x, pixel32 *y, bool raised) const
   *down = (r << default_red_shift) + (g << default_green_shift)
         + (b << default_blue_shift);
 }
+
 void TrueRenderControl::drawBackground(Surface& sf,
                                       const RenderTexture &texture) const
 {
   assert(_screen == sf._screen);
   assert(_screen == texture.color().screen());
 
-  if (texture.gradient() == RenderTexture::Solid) {
+  if (texture.gradient() == RenderTexture::Solid)
     drawSolidBackground(sf, texture);
-  } else {
+  else
     drawGradientBackground(sf, texture);
-  }
 }
 
 }
This page took 0.032981 seconds and 4 git commands to generate.