]> Dogcows Code - chaz/openbox/blob - src/image.hh
big fat commit..
[chaz/openbox] / src / image.hh
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 #ifndef __Image_hh
3 #define __Image_hh
4
5 extern "C" {
6 #include <X11/Xlib.h>
7 #include <X11/Xutil.h>
8 }
9
10 #include <list>
11
12 #include "timer.hh"
13 #include "basedisplay.hh"
14 #include "color.hh"
15
16 class BImageControl;
17 class BTexture;
18
19 class BImage {
20 private:
21 BImageControl *control;
22 bool interlaced;
23 XColor *colors;
24
25 BColor from, to;
26 int red_offset, green_offset, blue_offset, red_bits, green_bits, blue_bits,
27 ncolors, cpc, cpccpc;
28 unsigned char *red, *green, *blue, *red_table, *green_table, *blue_table;
29 unsigned int width, height, *xtable, *ytable;
30
31 void TrueColorDither(unsigned int bit_depth, int bytes_per_line,
32 unsigned char *pixel_data);
33 void PseudoColorDither(int bytes_per_line, unsigned char *pixel_data);
34 #ifdef ORDEREDPSEUDO
35 void OrderedPseudoColorDither(int bytes_per_line, unsigned char *pixel_data);
36 #endif
37
38 Pixmap renderPixmap(void);
39 Pixmap render_solid(const BTexture &texture);
40 Pixmap render_gradient(const BTexture &texture);
41
42 XImage *renderXImage(void);
43
44 void invert(void);
45 void bevel1(void);
46 void bevel2(void);
47 void border(const BTexture &texture);
48 void dgradient(void);
49 void egradient(void);
50 void hgradient(void);
51 void pgradient(void);
52 void rgradient(void);
53 void vgradient(void);
54 void cdgradient(void);
55 void pcgradient(void);
56
57
58 public:
59 BImage(BImageControl *c, int w, int h);
60 ~BImage(void);
61
62 Pixmap render(const BTexture &texture);
63 };
64
65
66 class BImageControl : public TimeoutHandler {
67 public:
68 struct CachedImage {
69 Pixmap pixmap;
70
71 unsigned int count, width, height;
72 unsigned long pixel1, pixel2, texture;
73 };
74
75 BImageControl(BaseDisplay *dpy, const ScreenInfo *scrn,
76 bool _dither= False, int _cpc = 4,
77 unsigned long cache_timeout = 300000l,
78 unsigned long cmax = 200l);
79 virtual ~BImageControl(void);
80
81 inline BaseDisplay *getBaseDisplay(void) const { return basedisplay; }
82
83 inline bool doDither(void) { return dither; }
84
85 inline const ScreenInfo *getScreenInfo(void) { return screeninfo; }
86
87 inline Window getDrawable(void) const { return window; }
88
89 inline Visual *getVisual(void) { return screeninfo->getVisual(); }
90
91 inline int getBitsPerPixel(void) const { return bits_per_pixel; }
92 inline int getDepth(void) const { return screen_depth; }
93 inline int getColorsPerChannel(void) const
94 { return colors_per_channel; }
95
96 unsigned long getSqrt(unsigned int x);
97
98 Pixmap renderImage(unsigned int width, unsigned int height,
99 const BTexture &texture);
100
101 void installRootColormap(void);
102 void removeImage(Pixmap pixmap);
103 void getColorTables(unsigned char **rmt, unsigned char **gmt,
104 unsigned char **bmt,
105 int *roff, int *goff, int *boff,
106 int *rbit, int *gbit, int *bbit);
107 void getXColorTable(XColor **c, int *n);
108 void getGradientBuffers(unsigned int w, unsigned int h,
109 unsigned int **xbuf, unsigned int **ybuf);
110 void setDither(bool d) { dither = d; }
111 void setColorsPerChannel(int cpc);
112
113 virtual void timeout(void);
114
115 private:
116 bool dither;
117 BaseDisplay *basedisplay;
118 const ScreenInfo *screeninfo;
119 BTimer *timer;
120
121 Colormap colormap;
122
123 Window window;
124 XColor *colors;
125 int colors_per_channel, ncolors, screen_number, screen_depth,
126 bits_per_pixel, red_offset, green_offset, blue_offset,
127 red_bits, green_bits, blue_bits;
128 unsigned char red_color_table[256], green_color_table[256],
129 blue_color_table[256];
130 unsigned int *grad_xbuffer, *grad_ybuffer, grad_buffer_width,
131 grad_buffer_height;
132 unsigned long *sqrt_table, cache_max;
133
134 typedef std::list<CachedImage> CacheContainer;
135 CacheContainer cache;
136
137 Pixmap searchCache(const unsigned int width, const unsigned int height,
138 const unsigned long texture,
139 const BColor &c1, const BColor &c2);
140 };
141
142
143 #endif // __Image_hh
144
This page took 0.037043 seconds and 4 git commands to generate.