all repos — openbox @ 0dcbf985c11c850b30b2983e1e20cd8cf033f054

openbox fork - make it a bit more like ryudo

otk/truerendercontrol.cc (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-

#ifdef    HAVE_CONFIG_H
#  include "../config.h"
#endif // HAVE_CONFIG_H

#include "truerendercontrol.hh"
#include "display.hh"
#include "screeninfo.hh"

extern "C" {
#ifdef    HAVE_STDLIB_H
#  include <stdlib.h>
#endif // HAVE_STDLIB_H

#include "gettext.h"
#define _(str) gettext(str)
}

namespace otk {

TrueRenderControl::TrueRenderControl(const ScreenInfo *screen)
  : RenderControl(screen)
{
  printf("Initializing TrueColor RenderControl\n");

  unsigned long red_mask, green_mask, blue_mask;

  // find the offsets for each color in the visual's masks
  red_mask = screen->visual()->red_mask;
  green_mask = screen->visual()->green_mask;
  blue_mask = screen->visual()->blue_mask;

  while (! (red_mask & 1)) { _red_offset++; red_mask >>= 1; }
  while (! (green_mask & 1)) { _green_offset++; green_mask >>= 1; }
  while (! (blue_mask & 1)) { _blue_offset++; blue_mask >>= 1; }

  // use the mask to determine the number of bits for each shade of color
  // so, best case, red_mask == 0xff (255), with each bit as a different
  // shade!
  _red_bits = 255 / red_mask;
  _green_bits = 255 / green_mask;
  _blue_bits = 255 / blue_mask;

  // compute color tables, based on the number of bits for each shade
  for (int i = 0; i < 256; i++) {
    _red_color_table[i] = i / _red_bits;
    _green_color_table[i] = i / _green_bits;
    _blue_color_table[i] = i / _blue_bits;
  }
}

TrueRenderControl::~TrueRenderControl()
{
  printf("Destroying TrueColor RenderControl\n");


}

void TrueRenderControl::render(::Drawable d)
{
}

}