Fix lighten_colour and double_lighten_colour to prevent alpha bleeding into red channel. Make macros clearer.

svn path=/trunk/netsurf/; revision=13742
This commit is contained in:
Michael Drake 2012-03-27 11:55:57 +00:00
parent fba2ebeee6
commit fc8cf634d5
1 changed files with 10 additions and 10 deletions

View File

@ -32,29 +32,29 @@
/* Darken a colour by taking three quarters of each channel's intensity */
#define darken_colour(c1) \
((((3 * ((c1 >> 16) & 0xff)) >> 2) << 16) | \
(((3 * ((c1 >> 8) & 0xff)) >> 2) << 8) | \
(((3 * (c1 & 0xff)) >> 2) << 0))
(((3 * ((c1 >> 8) & 0xff)) >> 2) << 8) | \
(((3 * ( c1 & 0xff)) >> 2) << 0))
/* Darken a colour by taking nine sixteenths of each channel's intensity */
#define double_darken_colour(c1) \
((((9 * ((c1 >> 16) & 0xff)) >> 4) << 16) | \
(((9 * ((c1 >> 8) & 0xff)) >> 4) << 8) | \
(((9 * (c1 & 0xff)) >> 4) << 0))
(((9 * ((c1 >> 8) & 0xff)) >> 4) << 8) | \
(((9 * ( c1 & 0xff)) >> 4) << 0))
/* Lighten a colour by taking three quarters of each channel's intensity
* and adding a full quarter
*/
#define lighten_colour(c1) \
(((((3 * (c1 >> 16)) >> 2) + 64) << 16) | \
((((3 * ((c1 >> 8) & 0xff)) >> 2) + 64) << 8) | \
((((3 * (c1 & 0xff)) >> 2) + 64) << 0))
(((((3 * ((c1 >> 16) & 0xff)) >> 2) + 64) << 16) | \
((((3 * ((c1 >> 8) & 0xff)) >> 2) + 64) << 8) | \
((((3 * ( c1 & 0xff)) >> 2) + 64) << 0))
/* Lighten a colour by taking nine sixteenths of each channel's intensity and
* adding a full intensity 7/16ths */
#define double_lighten_colour(c1) \
(((((9 * (c1 >> 16)) >> 4) + 112) << 16) | \
((((9 * ((c1 >> 8) & 0xff)) >> 4) + 112) << 8) | \
((((9 * (c1 & 0xff)) >> 4) + 112) << 0))
(((((9 * ((c1 >> 16) & 0xff)) >> 4) + 112) << 16) | \
((((9 * ((c1 >> 8) & 0xff)) >> 4) + 112) << 8) | \
((((9 * ( c1 & 0xff)) >> 4) + 112) << 0))
/* Blend two colours by taking half the intensity of each channel in the first
* colour and adding them to half the intensity of each channel in the second