diff options
author | fluxgen <fluxgen> | 2002-11-30 20:07:06 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-11-30 20:07:06 (GMT) |
commit | 49491d32b6385634227f779828bb6de97449f273 (patch) | |
tree | 30cb55b4e121be4ba421247ce91c7199bb16fb39 /src/ImageControl.hh | |
parent | da452116d38cc8854914e90d384042f703742d52 (diff) | |
download | fluxbox-49491d32b6385634227f779828bb6de97449f273.zip fluxbox-49491d32b6385634227f779828bb6de97449f273.tar.bz2 |
moved from Image.hh/cc
Diffstat (limited to 'src/ImageControl.hh')
-rw-r--r-- | src/ImageControl.hh | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/src/ImageControl.hh b/src/ImageControl.hh new file mode 100644 index 0000000..ec89c8d --- /dev/null +++ b/src/ImageControl.hh | |||
@@ -0,0 +1,125 @@ | |||
1 | // ImageControl.hh for Fluxbox Window Manager | ||
2 | // Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxbox at linuxmail.org) | ||
3 | // | ||
4 | // Image.hh for Blackbox - an X11 Window manager | ||
5 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net) | ||
6 | // | ||
7 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
8 | // copy of this software and associated documentation files (the "Software"), | ||
9 | // to deal in the Software without restriction, including without limitation | ||
10 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
11 | // and/or sell copies of the Software, and to permit persons to whom the | ||
12 | // Software is furnished to do so, subject to the following conditions: | ||
13 | // | ||
14 | // The above copyright notice and this permission notice shall be included in | ||
15 | // all copies or substantial portions of the Software. | ||
16 | // | ||
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
20 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
23 | // DEALINGS IN THE SOFTWARE. | ||
24 | |||
25 | // $Id: ImageControl.hh,v 1.1 2002/11/30 20:07:06 fluxgen Exp $ | ||
26 | |||
27 | #ifndef IMAGECONTROL_HH | ||
28 | #define IMAGECONTROL_HH | ||
29 | |||
30 | #include "Texture.hh" | ||
31 | #include "Timer.hh" | ||
32 | |||
33 | #include <X11/Xlib.h> | ||
34 | #include <X11/Xutil.h> | ||
35 | #include <list> | ||
36 | |||
37 | /** | ||
38 | Holds screen info and color tables | ||
39 | */ | ||
40 | class BImageControl : public TimeoutHandler { | ||
41 | public: | ||
42 | BImageControl(int screen_num, bool dither = false, int colors_per_channel = 4, | ||
43 | unsigned long cache_timeout = 300000l, unsigned long cache_max = 200l); | ||
44 | virtual ~BImageControl(); | ||
45 | |||
46 | inline bool doDither() const { return m_dither; } | ||
47 | inline int bitsPerPixel() const { return bits_per_pixel; } | ||
48 | inline int depth() const { return m_screen_depth; } | ||
49 | inline int colorsPerChannel() const { return m_colors_per_channel; } | ||
50 | int screenNum() const { return m_screen_num; } | ||
51 | Visual *visual() const { return m_visual; } | ||
52 | unsigned long getSqrt(unsigned int val) const; | ||
53 | |||
54 | /** | ||
55 | Render to pixmap | ||
56 | @param width width of pixmap | ||
57 | @param height height of pixmap | ||
58 | @param src_texture texture type to render | ||
59 | @return pixmap of the rendered image, on failure None | ||
60 | */ | ||
61 | Pixmap renderImage(unsigned int width, unsigned int height, | ||
62 | const FbTk::Texture &src_texture); | ||
63 | |||
64 | void installRootColormap(); | ||
65 | void removeImage(Pixmap thepix); | ||
66 | void colorTables(const unsigned char **, const unsigned char **, const unsigned char **, | ||
67 | int *, int *, int *, int *, int *, int *) const; | ||
68 | void getXColorTable(XColor **, int *); | ||
69 | void getGradientBuffers(unsigned int, unsigned int, | ||
70 | unsigned int **, unsigned int **); | ||
71 | void setDither(bool d) { m_dither = d; } | ||
72 | void setColorsPerChannel(int cpc); | ||
73 | |||
74 | virtual void timeout(); | ||
75 | |||
76 | private: | ||
77 | /** | ||
78 | Search cache for a specific pixmap | ||
79 | @return None if no cache was found | ||
80 | */ | ||
81 | Pixmap searchCache(unsigned int width, unsigned int height, unsigned long texture_type, | ||
82 | const FbTk::Color &color, const FbTk::Color &color_to) const; | ||
83 | |||
84 | void createColorTable(); | ||
85 | bool m_dither; | ||
86 | |||
87 | BTimer m_timer; | ||
88 | |||
89 | Colormap m_colormap; | ||
90 | |||
91 | Window m_root_window; | ||
92 | |||
93 | XColor *m_colors; ///< color table | ||
94 | unsigned int m_num_colors; ///< number of colors in color table | ||
95 | |||
96 | Visual *m_visual; | ||
97 | |||
98 | int bits_per_pixel, red_offset, green_offset, blue_offset, | ||
99 | red_bits, green_bits, blue_bits; | ||
100 | int m_colors_per_channel; ///< number of colors per channel | ||
101 | int m_screen_depth; ///< bit depth of screen | ||
102 | int m_screen_num; ///< screen number | ||
103 | unsigned char red_color_table[256], green_color_table[256], | ||
104 | blue_color_table[256]; | ||
105 | unsigned int *grad_xbuffer, *grad_ybuffer, grad_buffer_width, | ||
106 | grad_buffer_height; | ||
107 | |||
108 | static unsigned long *sqrt_table; /// sqrt lookup table | ||
109 | |||
110 | typedef struct Cache { | ||
111 | Pixmap pixmap; | ||
112 | |||
113 | unsigned int count, width, height; | ||
114 | unsigned long pixel1, pixel2, texture; | ||
115 | } Cache; | ||
116 | |||
117 | unsigned long cache_max; | ||
118 | typedef std::list<Cache *> CacheList; | ||
119 | |||
120 | mutable CacheList cache; | ||
121 | }; | ||
122 | |||
123 | |||
124 | #endif // IMAGECONTROL_HH | ||
125 | |||