X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Fgccache.hh;h=ff72497b3569f27e1ae2e4caf6ef84dfb3836c98;hb=2c977ae7ffe1e287264989669d2cfd2eb499d4ee;hp=499ed8a4007f264c72b5158373494fc0ff2d86a4;hpb=85c41a1aec90b8daefc425596ea34b6f9d0e643c;p=chaz%2Fopenbox diff --git a/otk/gccache.hh b/otk/gccache.hh index 499ed8a4..ff72497b 100644 --- a/otk/gccache.hh +++ b/otk/gccache.hh @@ -1,30 +1,31 @@ // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- -#ifndef GCCACHE_HH -#define GCCACHE_HH +#ifndef __gccache_hh +#define __gccache_hh extern "C" { #include } -#include "basedisplay.hh" +#include "display.hh" #include "color.hh" -class BGCCacheItem; +namespace otk { -class BGCCacheContext { +class GCCacheItem; + +class GCCacheContext { public: - void set(const BColor &_color, const XFontStruct * const _font, + void set(const Color &_color, const XFontStruct * const _font, const int _function, const int _subwindow, const int _linewidth); void set(const XFontStruct * const _font); - ~BGCCacheContext(void); + ~GCCacheContext(void); private: - BGCCacheContext(const BaseDisplay * const _display) - : display(_display), gc(0), pixel(0ul), fontid(0ul), + GCCacheContext() + : gc(0), pixel(0ul), fontid(0ul), function(0), subwindow(0), used(false), screen(~(0u)), linewidth(0) {} - const BaseDisplay *display; GC gc; unsigned long pixel; unsigned long fontid; @@ -34,69 +35,67 @@ private: unsigned int screen; int linewidth; - BGCCacheContext(const BGCCacheContext &_nocopy); - BGCCacheContext &operator=(const BGCCacheContext &_nocopy); + GCCacheContext(const GCCacheContext &_nocopy); + GCCacheContext &operator=(const GCCacheContext &_nocopy); - friend class BGCCache; - friend class BGCCacheItem; + friend class GCCache; + friend class GCCacheItem; }; -class BGCCacheItem { +class GCCacheItem { public: inline const GC &gc(void) const { return ctx->gc; } private: - BGCCacheItem(void) : ctx(0), count(0), hits(0), fault(false) { } + GCCacheItem(void) : ctx(0), count(0), hits(0), fault(false) { } - BGCCacheContext *ctx; + GCCacheContext *ctx; unsigned int count; unsigned int hits; bool fault; - BGCCacheItem(const BGCCacheItem &_nocopy); - BGCCacheItem &operator=(const BGCCacheItem &_nocopy); + GCCacheItem(const GCCacheItem &_nocopy); + GCCacheItem &operator=(const GCCacheItem &_nocopy); - friend class BGCCache; + friend class GCCache; }; -class BGCCache { +class GCCache { public: - BGCCache(const BaseDisplay * const _display, unsigned int screen_count); - ~BGCCache(void); + GCCache(unsigned int screen_count); + ~GCCache(void); // cleans up the cache void purge(void); - BGCCacheItem *find(const BColor &_color, const XFontStruct * const _font = 0, + GCCacheItem *find(const Color &_color, const XFontStruct * const _font = 0, int _function = GXcopy, int _subwindow = ClipByChildren, int _linewidth = 0); - void release(BGCCacheItem *_item); + void release(GCCacheItem *_item); private: - BGCCacheContext *nextContext(unsigned int _screen); - void release(BGCCacheContext *ctx); + 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 BaseDisplay *display; - const unsigned int context_count; const unsigned int cache_size; const unsigned int cache_buckets; const unsigned int cache_total_size; - BGCCacheContext **contexts; - BGCCacheItem **cache; + GCCacheContext **contexts; + GCCacheItem **cache; }; -class BPen { +class Pen { public: - inline BPen(const BColor &_color, const XFontStruct * const _font = 0, + 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(_color.display()->gcCache()), item(0) { } + subwindow(_subwindow), cache(display->gcCache()), item(0) { } - inline ~BPen(void) { if (item) cache->release(item); } + inline ~Pen(void) { if (item) cache->release(item); } inline const GC &gc(void) const { if (! item) item = cache->find(color, font, function, subwindow, @@ -105,15 +104,16 @@ public: } private: - const BColor &color; + const Color &color; const XFontStruct *font; int linewidth; int function; int subwindow; - mutable BGCCache *cache; - mutable BGCCacheItem *item; + mutable GCCache *cache; + mutable GCCacheItem *item; }; +} -#endif // GCCACHE_HH +#endif // __gccache_hh