diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2013-01-13 11:34:30 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2013-01-13 11:34:30 (GMT) |
commit | eb725c5c2dad513d12c08bba9a68ea640af5e355 (patch) | |
tree | d82147bc991a13ac816d6293b3dedcd9083b66e8 /src/FbTk/Texture.cc | |
parent | 8143b86fece2d9be45113db8a1781231ac67c2a2 (diff) | |
download | fluxbox-eb725c5c2dad513d12c08bba9a68ea640af5e355.zip fluxbox-eb725c5c2dad513d12c08bba9a68ea640af5e355.tar.bz2 |
Use the same lookup-tables for solid and gradient textures
Diffstat (limited to 'src/FbTk/Texture.cc')
-rw-r--r-- | src/FbTk/Texture.cc | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/FbTk/Texture.cc b/src/FbTk/Texture.cc index 408ff5b..da45bc4 100644 --- a/src/FbTk/Texture.cc +++ b/src/FbTk/Texture.cc | |||
@@ -32,6 +32,20 @@ | |||
32 | #include <string.h> | 32 | #include <string.h> |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | #include "ColorLUT.hh" | ||
36 | |||
37 | namespace { | ||
38 | |||
39 | unsigned short inline brighten(unsigned short c) { | ||
40 | return 0x101 * FbTk::ColorLUT::PRE_MULTIPLY_1_5[c]; | ||
41 | } | ||
42 | |||
43 | unsigned short inline darken(unsigned short c) { | ||
44 | return 0x101 * FbTk::ColorLUT::PRE_MULTIPLY_0_75[c]; | ||
45 | } | ||
46 | |||
47 | } | ||
48 | |||
35 | namespace FbTk { | 49 | namespace FbTk { |
36 | 50 | ||
37 | void Texture::setFromString(const char * const texture_str) { | 51 | void Texture::setFromString(const char * const texture_str) { |
@@ -100,27 +114,21 @@ void Texture::setFromString(const char * const texture_str) { | |||
100 | 114 | ||
101 | void Texture::calcHiLoColors(int screen_num) { | 115 | void Texture::calcHiLoColors(int screen_num) { |
102 | Display *disp = FbTk::App::instance()->display(); | 116 | Display *disp = FbTk::App::instance()->display(); |
103 | XColor xcol; | ||
104 | Colormap colm = DefaultColormap(disp, screen_num); | 117 | Colormap colm = DefaultColormap(disp, screen_num); |
118 | XColor xcol; | ||
105 | 119 | ||
106 | xcol.red = (unsigned int) (m_color.red() + (m_color.red() >> 1)); | 120 | xcol.red = ::brighten(m_color.red()); |
107 | if (xcol.red >= 0xff) xcol.red = 0xffff; | 121 | xcol.green = ::brighten(m_color.green()); |
108 | else xcol.red *= 0x101; | 122 | xcol.blue = ::brighten(m_color.blue()); |
109 | xcol.green = (unsigned int) (m_color.green() + (m_color.green() >> 1)); | ||
110 | if (xcol.green >= 0xff) xcol.green = 0xffff; | ||
111 | else xcol.green *= 0x101; | ||
112 | xcol.blue = (unsigned int) (m_color.blue() + (m_color.blue() >> 1)); | ||
113 | if (xcol.blue >= 0xff) xcol.blue = 0xffff; | ||
114 | else xcol.blue *= 0x101; | ||
115 | 123 | ||
116 | if (! XAllocColor(disp, colm, &xcol)) | 124 | if (! XAllocColor(disp, colm, &xcol)) |
117 | xcol.pixel = 0; | 125 | xcol.pixel = 0; |
118 | 126 | ||
119 | m_hicolor.setPixel(xcol.pixel); | 127 | m_hicolor.setPixel(xcol.pixel); |
120 | 128 | ||
121 | xcol.red = (unsigned int) ((m_color.red() >> 2) + (m_color.red() >> 1)) * 0x101; | 129 | xcol.red = ::darken(m_color.red()); |
122 | xcol.green = (unsigned int) ((m_color.green() >> 2) + (m_color.green() >> 1)) * 0x101; | 130 | xcol.green = ::darken(m_color.green()); |
123 | xcol.blue = (unsigned int) ((m_color.blue() >> 2) + (m_color.blue() >> 1)) * 0x101; | 131 | xcol.blue = ::darken(m_color.blue()); |
124 | 132 | ||
125 | if (! XAllocColor(disp, colm, &xcol)) | 133 | if (! XAllocColor(disp, colm, &xcol)) |
126 | xcol.pixel = 0; | 134 | xcol.pixel = 0; |