diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-11 19:25:02 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-11 19:25:02 +0000 |
commit | c6bd178914f5692f9bc59994d656a3d571c494fb (patch) | |
tree | 1a7563970f4fe43a2e689838981fa6b0293b614d /app/gfx/color_utils.cc | |
parent | bc104572de180e30823b9f828ed19d032bedfe1d (diff) | |
download | chromium_src-c6bd178914f5692f9bc59994d656a3d571c494fb.zip chromium_src-c6bd178914f5692f9bc59994d656a3d571c494fb.tar.gz chromium_src-c6bd178914f5692f9bc59994d656a3d571c494fb.tar.bz2 |
Fix a bug where some bitmaps were being tinted wrong. It turns out
that when converting from RGB to HSL we were comparing doubles and
in on some CPUs, a register spill would cause us to do the conversion
wrong.
BUG=28243
Review URL: http://codereview.chromium.org/491036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/gfx/color_utils.cc')
-rw-r--r-- | app/gfx/color_utils.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/gfx/color_utils.cc b/app/gfx/color_utils.cc index 483e857..05b8bfa 100644 --- a/app/gfx/color_utils.cc +++ b/app/gfx/color_utils.cc @@ -95,11 +95,13 @@ void SkColorToHSL(SkColor c, HSL* hsl) { double dr = (((vmax - r) / 6.0) + (delta / 2.0)) / delta; double dg = (((vmax - g) / 6.0) + (delta / 2.0)) / delta; double db = (((vmax - b) / 6.0) + (delta / 2.0)) / delta; - if (r == vmax) + // We need to compare for the max value because comparing vmax to r, + // g or b can sometimes result in values overflowing registers. + if (r >= g && r >= b) hsl->h = db - dg; - else if (g == vmax) + else if (g >= r && g >= b) hsl->h = (1.0 / 3.0) + dr - db; - else // (b == vmax) + else // (b >= r && b >= g) hsl->h = (2.0 / 3.0) + dg - dr; if (hsl->h < 0.0) |