X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Frendercolor.hh;h=8ed8ce5802e24eda0dd1031b5e7fd66d96a1d04a;hb=5face4c6f35172761367f63ac0b6eaf62d84e532;hp=fbfe2aef6e69a3eba6cc0768a1a6032091018cfa;hpb=0348a2f3abd2334f5f5812c5fb45c1b4fffb46a5;p=chaz%2Fopenbox diff --git a/otk/rendercolor.hh b/otk/rendercolor.hh index fbfe2aef..8ed8ce58 100644 --- a/otk/rendercolor.hh +++ b/otk/rendercolor.hh @@ -10,11 +10,25 @@ extern "C" { namespace otk { +struct RGB { + int r; + int g; + int b; + RGB(int red, int green, int blue) : r(red), g(green), b(blue) {} + // color is in ARGB format + RGB(unsigned long color) + : r((color >> 16) & 0xff), + g((color >> 8) & 0xff), + b((color) & 0xff) {} +}; + class RenderColor { +private: struct CacheItem { GC gc; + unsigned long pixel; int count; - CacheItem(GC g) : gc(g), count(0) {} + CacheItem(GC g, unsigned long p) : gc(g), pixel(p), count(0) {} }; static std::map *_cache; @@ -22,21 +36,26 @@ class RenderColor { unsigned char _red; unsigned char _green; unsigned char _blue; + unsigned long _pixel; GC _gc; + void create(); + public: static void initialize(); static void destroy(); RenderColor(int screen, unsigned char red, unsigned char green, unsigned char blue); + RenderColor(int screen, RGB rgb); virtual ~RenderColor(); inline int screen() const { return _screen; } inline unsigned char red() const { return _red; } inline unsigned char green() const { return _green; } inline unsigned char blue() const { return _blue; } + inline unsigned long pixel() const { return _pixel; } inline GC gc() const { return _gc; } };