mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-09-30 05:59:07 +00:00
16-bit color adjustments: save 6 divisions per graph by using precalculated values
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@247 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
6ff47b6101
commit
4ee616c528
10
src/conky.c
10
src/conky.c
@ -527,6 +527,10 @@ inline void graph_append(struct special_t *graph, double f)
|
|||||||
short colour_depth = 0;
|
short colour_depth = 0;
|
||||||
void set_up_gradient();
|
void set_up_gradient();
|
||||||
|
|
||||||
|
/* precalculated: 31/255, and 63/255 */
|
||||||
|
#define CONST_8_TO_5_BITS 0.12156862745098
|
||||||
|
#define CONST_8_TO_6_BITS 0.247058823529412
|
||||||
|
|
||||||
/* adjust color values depending on color depth*/
|
/* adjust color values depending on color depth*/
|
||||||
static unsigned int adjust_colors(unsigned int color)
|
static unsigned int adjust_colors(unsigned int color)
|
||||||
{
|
{
|
||||||
@ -538,9 +542,9 @@ static unsigned int adjust_colors(unsigned int color)
|
|||||||
r = (color & 0xff0000) >> 16;
|
r = (color & 0xff0000) >> 16;
|
||||||
g = (color & 0xff00) >> 8;
|
g = (color & 0xff00) >> 8;
|
||||||
b = color & 0xff;
|
b = color & 0xff;
|
||||||
color = (int)(r / 0xff * 0x1f) << 11;
|
color = (int)(r * CONST_8_TO_5_BITS) << 11;
|
||||||
color |= (int)(g / 0xff * 0x3f) << 5;
|
color |= (int)(g * CONST_8_TO_6_BITS) << 5;
|
||||||
color |= (int)(b / 0xff * 0x1f);
|
color |= (int)(b * CONST_8_TO_5_BITS);
|
||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user