aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Texture.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2013-01-13 11:34:30 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2013-01-13 11:34:30 (GMT)
commiteb725c5c2dad513d12c08bba9a68ea640af5e355 (patch)
treed82147bc991a13ac816d6293b3dedcd9083b66e8 /src/FbTk/Texture.cc
parent8143b86fece2d9be45113db8a1781231ac67c2a2 (diff)
downloadfluxbox-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.cc34
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
37namespace {
38
39unsigned short inline brighten(unsigned short c) {
40 return 0x101 * FbTk::ColorLUT::PRE_MULTIPLY_1_5[c];
41}
42
43unsigned short inline darken(unsigned short c) {
44 return 0x101 * FbTk::ColorLUT::PRE_MULTIPLY_0_75[c];
45}
46
47}
48
35namespace FbTk { 49namespace FbTk {
36 50
37void Texture::setFromString(const char * const texture_str) { 51void Texture::setFromString(const char * const texture_str) {
@@ -100,27 +114,21 @@ void Texture::setFromString(const char * const texture_str) {
100 114
101void Texture::calcHiLoColors(int screen_num) { 115void 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;