From 71d78523776db03819e9b6a6b3e44851895ad76a Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 22 Jan 2011 20:50:36 +0000 Subject: Trivial optimisation of HSL->RGB conversion svn path=/trunk/libcss/; revision=11456 --- src/parse/properties/utils.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c index 1ecc37c..35882ee 100644 --- a/src/parse/properties/utils.c +++ b/src/parse/properties/utils.c @@ -303,17 +303,18 @@ static void HSL_to_RGB(css_fixed hue, css_fixed sat, css_fixed lit, uint8_t *r, * 4 b g * 5 r g * - * Thus, we must only compute the value of the third component + * Thus, we need only compute the value of the third component */ /* Chroma is the difference between min and max */ chroma = FSUB(max_rgb, min_rgb); /* Compute which sextant the hue lies in (truncates result) */ - sextant = FIXTOINT(FDIVI(FMULI(hue, 6), 360)); + hue = FDIVI(FMULI(hue, 6), 360); + sextant = FIXTOINT(hue); /* Compute offset of hue from start of sextant */ - relative_hue = FDIVI(FSUBI(FMULI(hue, 6), sextant * 360), 360); + relative_hue = FSUBI(hue, sextant); /* Scale offset by chroma */ scaled_hue = FMUL(relative_hue, chroma); -- cgit v1.2.3