all repos — openbox @ 58ff3f35c2b712ec92b093ffd8b96331615f546a

openbox fork - make it a bit more like ryudo

otk_c/gccache.h (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __gccache_h
#define __gccache_h

#include <X11/Xlib.h>

#include "display.h"
#include "color.h"

struct OtkGCCacheItem;

typedef struct OtkGCCacheContext {
  GC gc;
  unsigned long pixel;
  unsigned long fontid;
  int function;
  int subwindow;
  Bool used;
  int screen;
  int linewidth;
} OtkGCCacheContext;

OtkGCCacheContext *OtkGCCacheContext_New();
void OtkGCCacheContext_Destroy(OtkGCCacheContext *self);

void OtkGCCacheContext_Set(OtkGCCacheContext *self,
			   OtkColor *color, XFontStruct *font,
			   int function, int subwindow, int linewidth);
void OtkGCCacheContext_SetFont(OtkGCCacheContext *self,
			       XFontStruct *font);


typedef struct OtkGCCacheItem {
  OtkGCCacheContext *ctx;
  unsigned int count;
  unsigned int hits;
  Bool fault;
} OtkGCCacheItem;

OtkGCCacheItem *OtkGCCacheItem_New();


typedef struct OtkGCCache {
  // this is closely modelled after the Qt GC cache, but with some of the
  // complexity stripped out
  unsigned int context_count;
  unsigned int cache_size;
  unsigned int cache_buckets;
  unsigned int cache_total_size;
  OtkGCCacheContext **contexts;
  OtkGCCacheItem **cache;
} OtkGCCache;

void OtkGCCache_Initialize();
//void OtkGCCache_Destroy();

// cleans up the cache
void OtkGCCache_Purge();

OtkGCCacheItem *OtkGCCache_Find(OtkColor *color,
				XFontStruct *font, int function,
				int subwindow, int linewidth);
void OtkGCCache_Release(OtkGCCacheItem *item);


/*


class BPen {
public:
  inline BPen(const BColor &_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(OBDisplay::gcCache()), item(0) { }

  inline ~BPen(void) { if (item) cache->release(item); }

  inline const GC &gc(void) const {
    if (! item) item = cache->find(color, font, function, subwindow,
                                   linewidth);
    return item->gc();
  }

private:
  const BColor &color;
  const XFontStruct *font;
  int linewidth;
  int function;
  int subwindow;

  mutable BGCCache *cache;
  mutable BGCCacheItem *item;
};

}*/

#endif // __gccache_h