X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Frendercolor.hh;h=1f24b3c9106681705422f16c828ac70b3e482fd5;hb=1e58c863bbaddd2f2dbebfde740ca842e8837a1c;hp=1152e767d5259a6e43fb0291cc1117670addd234;hpb=75e8fc2705d9c606a702eb7057e9e503be90618b;p=chaz%2Fopenbox diff --git a/otk/rendercolor.hh b/otk/rendercolor.hh index 1152e767..1f24b3c9 100644 --- a/otk/rendercolor.hh +++ b/otk/rendercolor.hh @@ -10,25 +10,25 @@ extern "C" { namespace otk { -class RenderColor { -public: - 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) {} - }; +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; @@ -37,9 +37,13 @@ private: unsigned char _green; unsigned char _blue; - GC _gc; + mutable unsigned long _pixel; + mutable GC _gc; + + mutable bool _allocated; + mutable bool _created; - void create(); + void create() const; public: static void initialize(); @@ -54,7 +58,8 @@ public: inline unsigned char red() const { return _red; } inline unsigned char green() const { return _green; } inline unsigned char blue() const { return _blue; } - inline GC gc() const { return _gc; } + unsigned long pixel() const; + GC gc() const; }; }