| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/color_utils.h" | 5 #include "ui/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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 g += (255.0 - g) * ((shift.l - 0.5) * 2.0); | 217 g += (255.0 - g) * ((shift.l - 0.5) * 2.0); |
| 218 b += (255.0 - b) * ((shift.l - 0.5) * 2.0); | 218 b += (255.0 - b) * ((shift.l - 0.5) * 2.0); |
| 219 } | 219 } |
| 220 return SkColorSetARGB(alpha, | 220 return SkColorSetARGB(alpha, |
| 221 static_cast<int>(r), | 221 static_cast<int>(r), |
| 222 static_cast<int>(g), | 222 static_cast<int>(g), |
| 223 static_cast<int>(b)); | 223 static_cast<int>(b)); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void BuildLumaHistogram(const SkBitmap& bitmap, int histogram[256]) { | 226 void BuildLumaHistogram(const SkBitmap& bitmap, int histogram[256]) { |
| 227 DCHECK_EQ(kPMColor_SkColorType, bitmap.colorType()); | 227 DCHECK_EQ(kN32_SkColorType, bitmap.colorType()); |
| 228 | 228 |
| 229 SkAutoLockPixels bitmap_lock(bitmap); | 229 SkAutoLockPixels bitmap_lock(bitmap); |
| 230 | 230 |
| 231 int pixel_width = bitmap.width(); | 231 int pixel_width = bitmap.width(); |
| 232 int pixel_height = bitmap.height(); | 232 int pixel_height = bitmap.height(); |
| 233 for (int y = 0; y < pixel_height; ++y) { | 233 for (int y = 0; y < pixel_height; ++y) { |
| 234 for (int x = 0; x < pixel_width; ++x) | 234 for (int x = 0; x < pixel_width; ++x) |
| 235 ++histogram[GetLuminanceForColor(bitmap.getColor(x, y))]; | 235 ++histogram[GetLuminanceForColor(bitmap.getColor(x, y))]; |
| 236 } | 236 } |
| 237 } | 237 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 SkColor GetSysSkColor(int which) { | 292 SkColor GetSysSkColor(int which) { |
| 293 #if defined(OS_WIN) | 293 #if defined(OS_WIN) |
| 294 return skia::COLORREFToSkColor(GetSysColor(which)); | 294 return skia::COLORREFToSkColor(GetSysColor(which)); |
| 295 #else | 295 #else |
| 296 NOTIMPLEMENTED(); | 296 NOTIMPLEMENTED(); |
| 297 return SK_ColorLTGRAY; | 297 return SK_ColorLTGRAY; |
| 298 #endif | 298 #endif |
| 299 } | 299 } |
| 300 | 300 |
| 301 } // namespace color_utils | 301 } // namespace color_utils |
| OLD | NEW |