]>
Dogcows Code - chaz/openbox/blob - src/gccache.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
9 #include "basedisplay.hh"
14 class BGCCacheContext
{
16 void set(const BColor
&_color
, const XFontStruct
* const _font
,
17 const int _function
, const int _subwindow
, const int _linewidth
);
18 void set(const XFontStruct
* const _font
);
20 ~BGCCacheContext(void);
23 BGCCacheContext(const BaseDisplay
* const _display
)
24 : display(_display
), gc(0), pixel(0ul), fontid(0ul),
25 function(0), subwindow(0), used(false), screen(~(0u)), linewidth(0) {}
27 const BaseDisplay
*display
;
37 BGCCacheContext(const BGCCacheContext
&_nocopy
);
38 BGCCacheContext
&operator=(const BGCCacheContext
&_nocopy
);
40 friend class BGCCache
;
41 friend class BGCCacheItem
;
46 inline const GC
&gc(void) const { return ctx
->gc
; }
49 BGCCacheItem(void) : ctx(0), count(0), hits(0), fault(false) { }
56 BGCCacheItem(const BGCCacheItem
&_nocopy
);
57 BGCCacheItem
&operator=(const BGCCacheItem
&_nocopy
);
59 friend class BGCCache
;
64 BGCCache(const BaseDisplay
* const _display
, unsigned int screen_count
);
67 // cleans up the cache
70 BGCCacheItem
*find(const BColor
&_color
, const XFontStruct
* const _font
= 0,
71 int _function
= GXcopy
, int _subwindow
= ClipByChildren
,
73 void release(BGCCacheItem
*_item
);
76 BGCCacheContext
*nextContext(unsigned int _screen
);
77 void release(BGCCacheContext
*ctx
);
79 // this is closely modelled after the Qt GC cache, but with some of the
80 // complexity stripped out
81 const BaseDisplay
*display
;
83 const unsigned int context_count
;
84 const unsigned int cache_size
;
85 const unsigned int cache_buckets
;
86 const unsigned int cache_total_size
;
87 BGCCacheContext
**contexts
;
93 inline BPen(const BColor
&_color
, const XFontStruct
* const _font
= 0,
94 int _linewidth
= 0, int _function
= GXcopy
,
95 int _subwindow
= ClipByChildren
)
96 : color(_color
), font(_font
), linewidth(_linewidth
), function(_function
),
97 subwindow(_subwindow
), cache(_color
.display()->gcCache()), item(0) { }
99 inline ~BPen(void) { if (item
) cache
->release(item
); }
101 inline const GC
&gc(void) const {
102 if (! item
) item
= cache
->find(color
, font
, function
, subwindow
,
109 const XFontStruct
*font
;
114 mutable BGCCache
*cache
;
115 mutable BGCCacheItem
*item
;
This page took 0.039342 seconds and 5 git commands to generate.