]>
Dogcows Code - chaz/openbox/blob - otk/gccache.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
16 class BGCCacheContext
{
18 void set(const BColor
&_color
, const XFontStruct
* const _font
,
19 const int _function
, const int _subwindow
, const int _linewidth
);
20 void set(const XFontStruct
* const _font
);
22 ~BGCCacheContext(void);
26 : gc(0), pixel(0ul), fontid(0ul),
27 function(0), subwindow(0), used(false), screen(~(0u)), linewidth(0) {}
38 BGCCacheContext(const BGCCacheContext
&_nocopy
);
39 BGCCacheContext
&operator=(const BGCCacheContext
&_nocopy
);
41 friend class BGCCache
;
42 friend class BGCCacheItem
;
47 inline const GC
&gc(void) const { return ctx
->gc
; }
50 BGCCacheItem(void) : ctx(0), count(0), hits(0), fault(false) { }
57 BGCCacheItem(const BGCCacheItem
&_nocopy
);
58 BGCCacheItem
&operator=(const BGCCacheItem
&_nocopy
);
60 friend class BGCCache
;
65 BGCCache(unsigned int screen_count
);
68 // cleans up the cache
71 BGCCacheItem
*find(const BColor
&_color
, const XFontStruct
* const _font
= 0,
72 int _function
= GXcopy
, int _subwindow
= ClipByChildren
,
74 void release(BGCCacheItem
*_item
);
77 BGCCacheContext
*nextContext(unsigned int _screen
);
78 void release(BGCCacheContext
*ctx
);
80 // this is closely modelled after the Qt GC cache, but with some of the
81 // complexity stripped out
82 const unsigned int context_count
;
83 const unsigned int cache_size
;
84 const unsigned int cache_buckets
;
85 const unsigned int cache_total_size
;
86 BGCCacheContext
**contexts
;
92 inline BPen(const BColor
&_color
, const XFontStruct
* const _font
= 0,
93 int _linewidth
= 0, int _function
= GXcopy
,
94 int _subwindow
= ClipByChildren
)
95 : color(_color
), font(_font
), linewidth(_linewidth
), function(_function
),
96 subwindow(_subwindow
), cache(OBDisplay::gcCache()), item(0) { }
98 inline ~BPen(void) { if (item
) cache
->release(item
); }
100 inline const GC
&gc(void) const {
101 if (! item
) item
= cache
->find(color
, font
, function
, subwindow
,
108 const XFontStruct
*font
;
113 mutable BGCCache
*cache
;
114 mutable BGCCacheItem
*item
;
This page took 0.043274 seconds and 4 git commands to generate.