#include <rendercolor.hh>
Public Methods | |
| RenderColor (int screen, unsigned char red, unsigned char green, unsigned char blue) | |
| RenderColor (int screen, RGB rgb) | |
| virtual | ~RenderColor () |
| int | screen () const |
| unsigned char | red () const |
| unsigned char | green () const |
| unsigned char | blue () const |
| unsigned long | pixel () const |
| GC | gc () const |
Static Public Methods | |
| void | initialize () |
| void | destroy () |
Private Methods | |
| void | create () |
Private Attributes | |
| int | _screen |
| unsigned char | _red |
| unsigned char | _green |
| unsigned char | _blue |
| unsigned long | _pixel |
| GC | _gc |
Static Private Attributes | |
| std::map< unsigned long, CacheItem * > * | _cache = 0 |
|
||||||||||||||||||||
|
Definition at line 31 of file rendercolor.cc. References create().
|
|
||||||||||||
|
Definition at line 42 of file rendercolor.cc. References create().
|
|
|
Definition at line 95 of file rendercolor.cc. References _blue, _cache, _green, _red, _screen, and otk::RenderColor::CacheItem::count.
00096 {
00097 unsigned long color = _blue | _green << 8 | _red << 16;
00098
00099 CacheItem *item = _cache[_screen][color];
00100 assert(item); // it better be in the cache ...
00101
00102 if (--item->count <= 0) {
00103 // remove from the cache
00104 XFreeGC(**display, _gc);
00105 _cache[_screen][color] = 0;
00106 delete item;
00107 }
00108 }
|
|
|
Definition at line 57 of file rendercolor.hh. Referenced by otk::TrueRenderControl::crossDiagonalGradient(), otk::TrueRenderControl::diagonalGradient(), otk::TrueRenderControl::drawGradientBackground(), otk::RenderControl::drawString(), otk::RenderTexture::RenderTexture(), and otk::TrueRenderControl::verticalGradient().
00057 { return _blue; }
|
|
|
Definition at line 52 of file rendercolor.cc. References _blue, _cache, _gc, _green, _pixel, _red, _screen, otk::ScreenInfo::colormap(), otk::RenderColor::CacheItem::count, otk::display, otk::RenderColor::CacheItem::gc, otk::RenderColor::CacheItem::pixel, otk::ScreenInfo::rootWindow(), and otk::Display::screenInfo(). Referenced by RenderColor().
00053 {
00054 unsigned long color = _blue | _green << 8 | _red << 16;
00055
00056 // try get a gc from the cache
00057 CacheItem *item = _cache[_screen][color];
00058
00059 if (item) {
00060 _gc = item->gc;
00061 _pixel = item->pixel;
00062 ++item->count;
00063 } else {
00064 XGCValues gcv;
00065
00066 // allocate a color and GC from the server
00067 const ScreenInfo *info = display->screenInfo(_screen);
00068
00069 XColor xcol; // convert from 0-0xff to 0-0xffff
00070 xcol.red = _red; xcol.red |= xcol.red << 8;
00071 xcol.green = _green; xcol.green |= xcol.green << 8;
00072 xcol.blue = _blue; xcol.blue |= xcol.blue << 8;
00073 xcol.pixel = 0;
00074
00075 if (! XAllocColor(**display, info->colormap(), &xcol)) {
00076 fprintf(stderr, "RenderColor: color alloc error: rgb:%x/%x/%x\n",
00077 _red, _green, _blue);
00078 xcol.pixel = 0;
00079 }
00080
00081 _pixel = xcol.pixel;
00082 gcv.foreground = _pixel;
00083 gcv.cap_style = CapProjecting;
00084 _gc = XCreateGC(**display, info->rootWindow(),
00085 GCForeground | GCCapStyle, &gcv);
00086 assert(_gc);
00087
00088 // insert into the cache
00089 item = new CacheItem(_gc, _pixel);
00090 _cache[_screen][color] = item;
00091 ++item->count;
00092 }
00093 }
|
|
|
Definition at line 26 of file rendercolor.cc. References _cache. Referenced by ob::Openbox::~Openbox().
00027 {
00028 delete [] _cache;
00029 }
|
|
|
Definition at line 59 of file rendercolor.hh. Referenced by otk::RenderControl::drawSolidBackground(), ob::ButtonWidget::renderForeground(), and otk::Surface::setPixmap().
00059 { return _gc; }
|
|
|
Definition at line 56 of file rendercolor.hh. Referenced by otk::TrueRenderControl::crossDiagonalGradient(), otk::TrueRenderControl::diagonalGradient(), otk::TrueRenderControl::drawGradientBackground(), otk::RenderControl::drawString(), otk::RenderTexture::RenderTexture(), and otk::TrueRenderControl::verticalGradient().
00056 { return _green; }
|
|
|
Definition at line 21 of file rendercolor.cc. References _cache. Referenced by ob::Openbox::Openbox().
00022 {
00023 _cache = new std::map<unsigned long, CacheItem*>[ScreenCount(**display)];
00024 }
|
|
|
Definition at line 58 of file rendercolor.hh. Referenced by otk::RenderControl::drawRoot(), and otk::RenderControl::drawString().
00058 { return _pixel; }
|
|
|
Definition at line 55 of file rendercolor.hh. Referenced by otk::TrueRenderControl::crossDiagonalGradient(), otk::TrueRenderControl::diagonalGradient(), otk::TrueRenderControl::drawGradientBackground(), otk::RenderControl::drawString(), otk::RenderTexture::RenderTexture(), and otk::TrueRenderControl::verticalGradient().
00055 { return _red; }
|
|
|
Definition at line 54 of file rendercolor.hh. Referenced by otk::TrueRenderControl::drawBackground(), otk::PseudoRenderControl::drawBackground(), and otk::RenderControl::drawSolidBackground().
00054 { return _screen; }
|
|
|
Definition at line 38 of file rendercolor.hh. Referenced by create(), and ~RenderColor(). |
|
|
Definition at line 19 of file rendercolor.cc. Referenced by create(), destroy(), initialize(), and ~RenderColor(). |
|
|
Definition at line 41 of file rendercolor.hh. Referenced by create(). |
|
|
Definition at line 37 of file rendercolor.hh. Referenced by create(), and ~RenderColor(). |
|
|
Definition at line 39 of file rendercolor.hh. Referenced by create(). |
|
|
Definition at line 36 of file rendercolor.hh. Referenced by create(), and ~RenderColor(). |
|
|
Definition at line 35 of file rendercolor.hh. Referenced by create(), and ~RenderColor(). |
1.3-rc2