]>
Dogcows Code - chaz/openbox/blob - otk/gccache.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
16 class GCCacheContext
{
18 void set(const Color
&_color
, const XFontStruct
* const _font
,
19 const int _function
, const int _subwindow
, const int _linewidth
);
20 void set(const XFontStruct
* const _font
);
22 ~GCCacheContext(void);
26 : gc(0), pixel(0ul), fontid(0ul),
27 function(0), subwindow(0), used(false), screen(~(0u)), linewidth(0) {}
38 GCCacheContext(const GCCacheContext
&_nocopy
);
39 GCCacheContext
&operator=(const GCCacheContext
&_nocopy
);
42 friend class GCCacheItem
;
47 inline const GC
&gc(void) const { return ctx
->gc
; }
50 GCCacheItem(void) : ctx(0), count(0), hits(0), fault(false) { }
57 GCCacheItem(const GCCacheItem
&_nocopy
);
58 GCCacheItem
&operator=(const GCCacheItem
&_nocopy
);
65 GCCache(unsigned int screen_count
);
68 // cleans up the cache
71 GCCacheItem
*find(const Color
&_color
, const XFontStruct
* const _font
= 0,
72 int _function
= GXcopy
, int _subwindow
= ClipByChildren
,
74 void release(GCCacheItem
*_item
);
77 GCCacheContext
*nextContext(unsigned int _screen
);
78 void release(GCCacheContext
*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 GCCacheContext
**contexts
;
92 inline Pen(const Color
&_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(display
->gcCache()), item(0) { }
98 inline ~Pen(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 GCCache
*cache
;
114 mutable GCCacheItem
*item
;
119 #endif // __gccache_hh
This page took 0.036936 seconds and 4 git commands to generate.