summaryrefslogtreecommitdiff
path: root/otk/rendercolor.hh
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-01-20 07:07:13 +0000
committerDana Jansens <danakj@orodu.net>2003-01-20 07:07:13 +0000
commit0348a2f3abd2334f5f5812c5fb45c1b4fffb46a5 (patch)
treef19e07f899a3e390dbc8f2484d6b1426defcbb47 /otk/rendercolor.hh
parentcfd8f9a65848c5e7b0514999581512069a4f98f6 (diff)
add rendercolor class, with a cache of gcs for the colors
Diffstat (limited to 'otk/rendercolor.hh')
-rw-r--r--otk/rendercolor.hh45
1 files changed, 45 insertions, 0 deletions
diff --git a/otk/rendercolor.hh b/otk/rendercolor.hh
new file mode 100644
index 00000000..fbfe2aef
--- /dev/null
+++ b/otk/rendercolor.hh
@@ -0,0 +1,45 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+#ifndef __rendercolor_hh
+#define __rendercolor_hh
+
+extern "C" {
+#include <X11/Xlib.h>
+}
+
+#include <map>
+
+namespace otk {
+
+class RenderColor {
+ struct CacheItem {
+ GC gc;
+ int count;
+ CacheItem(GC g) : gc(g), count(0) {}
+ };
+ static std::map<unsigned long, CacheItem*> *_cache;
+
+ int _screen;
+ unsigned char _red;
+ unsigned char _green;
+ unsigned char _blue;
+
+ GC _gc;
+
+public:
+ static void initialize();
+ static void destroy();
+
+ RenderColor(int screen, unsigned char red,
+ unsigned char green, unsigned char blue);
+ 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 GC gc() const { return _gc; }
+};
+
+}
+
+#endif // __rendercolor_hh