diff options
| author | Dana Jansens <danakj@orodu.net> | 2003-01-23 23:42:46 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2003-01-23 23:42:46 +0000 |
| commit | f2e005f4d99c069431f27a102cef2ee26991ca97 (patch) | |
| tree | c92797fa7057f880ff12d9c0332ba0f239224784 /otk/gccache.hh | |
| parent | 104c1a164b1e4e881e141d14263895401779d453 (diff) | |
remove the old blackbox bullshit
Diffstat (limited to 'otk/gccache.hh')
| -rw-r--r-- | otk/gccache.hh | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/otk/gccache.hh b/otk/gccache.hh deleted file mode 100644 index ff72497b..00000000 --- a/otk/gccache.hh +++ /dev/null @@ -1,119 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- -#ifndef __gccache_hh -#define __gccache_hh - -extern "C" { -#include <X11/Xlib.h> -} - -#include "display.hh" -#include "color.hh" - -namespace otk { - -class GCCacheItem; - -class GCCacheContext { -public: - void set(const Color &_color, const XFontStruct * const _font, - const int _function, const int _subwindow, const int _linewidth); - void set(const XFontStruct * const _font); - - ~GCCacheContext(void); - -private: - GCCacheContext() - : gc(0), pixel(0ul), fontid(0ul), - function(0), subwindow(0), used(false), screen(~(0u)), linewidth(0) {} - - GC gc; - unsigned long pixel; - unsigned long fontid; - int function; - int subwindow; - bool used; - unsigned int screen; - int linewidth; - - GCCacheContext(const GCCacheContext &_nocopy); - GCCacheContext &operator=(const GCCacheContext &_nocopy); - - friend class GCCache; - friend class GCCacheItem; -}; - -class GCCacheItem { -public: - inline const GC &gc(void) const { return ctx->gc; } - -private: - GCCacheItem(void) : ctx(0), count(0), hits(0), fault(false) { } - - GCCacheContext *ctx; - unsigned int count; - unsigned int hits; - bool fault; - - GCCacheItem(const GCCacheItem &_nocopy); - GCCacheItem &operator=(const GCCacheItem &_nocopy); - - friend class GCCache; -}; - -class GCCache { -public: - GCCache(unsigned int screen_count); - ~GCCache(void); - - // cleans up the cache - void purge(void); - - GCCacheItem *find(const Color &_color, const XFontStruct * const _font = 0, - int _function = GXcopy, int _subwindow = ClipByChildren, - int _linewidth = 0); - void release(GCCacheItem *_item); - -private: - GCCacheContext *nextContext(unsigned int _screen); - void release(GCCacheContext *ctx); - - // this is closely modelled after the Qt GC cache, but with some of the - // complexity stripped out - const unsigned int context_count; - const unsigned int cache_size; - const unsigned int cache_buckets; - const unsigned int cache_total_size; - GCCacheContext **contexts; - GCCacheItem **cache; -}; - -class Pen { -public: - inline Pen(const Color &_color, const XFontStruct * const _font = 0, - int _linewidth = 0, int _function = GXcopy, - int _subwindow = ClipByChildren) - : color(_color), font(_font), linewidth(_linewidth), function(_function), - subwindow(_subwindow), cache(display->gcCache()), item(0) { } - - inline ~Pen(void) { if (item) cache->release(item); } - - inline const GC &gc(void) const { - if (! item) item = cache->find(color, font, function, subwindow, - linewidth); - return item->gc(); - } - -private: - const Color &color; - const XFontStruct *font; - int linewidth; - int function; - int subwindow; - - mutable GCCache *cache; - mutable GCCacheItem *item; -}; - -} - -#endif // __gccache_hh |
