]> Dogcows Code - chaz/openbox/blob - otk_c/gccache.h
fix indenting
[chaz/openbox] / otk_c / gccache.h
1 // -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __gccache_h
3 #define __gccache_h
4
5 #include <X11/Xlib.h>
6
7 #include "display.h"
8 #include "color.h"
9
10 struct OtkGCCacheItem;
11
12 typedef struct OtkGCCacheContext {
13 GC gc;
14 unsigned long pixel;
15 unsigned long fontid;
16 int function;
17 int subwindow;
18 Bool used;
19 int screen;
20 int linewidth;
21 } OtkGCCacheContext;
22
23 OtkGCCacheContext *OtkGCCacheContext_New();
24 void OtkGCCacheContext_Destroy(OtkGCCacheContext *self);
25
26 void OtkGCCacheContext_Set(OtkGCCacheContext *self,
27 OtkColor *color, XFontStruct *font,
28 int function, int subwindow, int linewidth);
29 void OtkGCCacheContext_SetFont(OtkGCCacheContext *self,
30 XFontStruct *font);
31
32
33 typedef struct OtkGCCacheItem {
34 OtkGCCacheContext *ctx;
35 unsigned int count;
36 unsigned int hits;
37 Bool fault;
38 } OtkGCCacheItem;
39
40 OtkGCCacheItem *OtkGCCacheItem_New();
41
42
43 typedef struct OtkGCCache {
44 // this is closely modelled after the Qt GC cache, but with some of the
45 // complexity stripped out
46 unsigned int context_count;
47 unsigned int cache_size;
48 unsigned int cache_buckets;
49 unsigned int cache_total_size;
50 OtkGCCacheContext **contexts;
51 OtkGCCacheItem **cache;
52 } OtkGCCache;
53
54 void OtkGCCache_Initialize();
55 //void OtkGCCache_Destroy();
56
57 // cleans up the cache
58 void OtkGCCache_Purge();
59
60 OtkGCCacheItem *OtkGCCache_Find(OtkColor *color,
61 XFontStruct *font, int function,
62 int subwindow, int linewidth);
63 void OtkGCCache_Release(OtkGCCacheItem *item);
64
65
66 /*
67
68
69 class BPen {
70 public:
71 inline BPen(const BColor &_color, const XFontStruct * const _font = 0,
72 int _linewidth = 0, int _function = GXcopy,
73 int _subwindow = ClipByChildren)
74 : color(_color), font(_font), linewidth(_linewidth), function(_function),
75 subwindow(_subwindow), cache(OBDisplay::gcCache()), item(0) { }
76
77 inline ~BPen(void) { if (item) cache->release(item); }
78
79 inline const GC &gc(void) const {
80 if (! item) item = cache->find(color, font, function, subwindow,
81 linewidth);
82 return item->gc();
83 }
84
85 private:
86 const BColor &color;
87 const XFontStruct *font;
88 int linewidth;
89 int function;
90 int subwindow;
91
92 mutable BGCCache *cache;
93 mutable BGCCacheItem *item;
94 };
95
96 }*/
97
98 #endif // __gccache_h
This page took 0.03733 seconds and 4 git commands to generate.