Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gfx/color_utils.h" | 5 #include "gfx/color_utils.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #if defined(OS_WIN) | 8 #if defined(OS_WIN) |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 #endif | 10 #endif |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 double temp2 = (lightness < 0.5) ? | 138 double temp2 = (lightness < 0.5) ? |
| 139 (lightness * (1.0 + saturation)) : | 139 (lightness * (1.0 + saturation)) : |
| 140 (lightness + saturation - (lightness * saturation)); | 140 (lightness + saturation - (lightness * saturation)); |
| 141 double temp1 = 2.0 * lightness - temp2; | 141 double temp1 = 2.0 * lightness - temp2; |
| 142 return SkColorSetARGB(alpha, | 142 return SkColorSetARGB(alpha, |
| 143 static_cast<int>(calcHue(temp1, temp2, hue + 1.0 / 3.0) * 255), | 143 static_cast<int>(calcHue(temp1, temp2, hue + 1.0 / 3.0) * 255), |
| 144 static_cast<int>(calcHue(temp1, temp2, hue) * 255), | 144 static_cast<int>(calcHue(temp1, temp2, hue) * 255), |
| 145 static_cast<int>(calcHue(temp1, temp2, hue - 1.0 / 3.0) * 255)); | 145 static_cast<int>(calcHue(temp1, temp2, hue - 1.0 / 3.0) * 255)); |
| 146 } | 146 } |
| 147 | 147 |
| 148 SkColor BrightenColor(const HSL& hsl, SkAlpha alpha, double lightness_amount) { | |
|
tony
2011/01/14 22:06:04
Can we just use HSLShift for this? It's a little
xiyuan
2011/01/18 21:30:49
Done. Moved it into native_theme_linux.
| |
| 149 HSL adjusted = hsl; | |
| 150 adjusted.l += lightness_amount; | |
| 151 if (adjusted.l > 1.0) | |
| 152 adjusted.l = 1.0; | |
| 153 if (adjusted.l < 0.0) | |
| 154 adjusted.l = 0.0; | |
| 155 | |
| 156 return HSLToSkColor(adjusted, alpha); | |
| 157 } | |
| 158 | |
| 148 SkColor HSLShift(SkColor color, const HSL& shift) { | 159 SkColor HSLShift(SkColor color, const HSL& shift) { |
| 149 HSL hsl; | 160 HSL hsl; |
| 150 int alpha = SkColorGetA(color); | 161 int alpha = SkColorGetA(color); |
| 151 SkColorToHSL(color, &hsl); | 162 SkColorToHSL(color, &hsl); |
| 152 | 163 |
| 153 // Replace the hue with the tint's hue. | 164 // Replace the hue with the tint's hue. |
| 154 if (shift.h >= 0) | 165 if (shift.h >= 0) |
| 155 hsl.h = shift.h; | 166 hsl.h = shift.h; |
| 156 | 167 |
| 157 // Change the saturation. | 168 // Change the saturation. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 SkColor GetSysSkColor(int which) { | 302 SkColor GetSysSkColor(int which) { |
| 292 #if defined(OS_WIN) | 303 #if defined(OS_WIN) |
| 293 return skia::COLORREFToSkColor(GetSysColor(which)); | 304 return skia::COLORREFToSkColor(GetSysColor(which)); |
| 294 #else | 305 #else |
| 295 NOTIMPLEMENTED(); | 306 NOTIMPLEMENTED(); |
| 296 return SK_ColorLTGRAY; | 307 return SK_ColorLTGRAY; |
| 297 #endif | 308 #endif |
| 298 } | 309 } |
| 299 | 310 |
| 300 } // namespace color_utils | 311 } // namespace color_utils |
| OLD | NEW |