| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 229 } |
| 230 return SkColorSetARGB(alpha, | 230 return SkColorSetARGB(alpha, |
| 231 static_cast<int>(std::round(r)), | 231 static_cast<int>(std::round(r)), |
| 232 static_cast<int>(std::round(g)), | 232 static_cast<int>(std::round(g)), |
| 233 static_cast<int>(std::round(b))); | 233 static_cast<int>(std::round(b))); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void BuildLumaHistogram(const SkBitmap& bitmap, int histogram[256]) { | 236 void BuildLumaHistogram(const SkBitmap& bitmap, int histogram[256]) { |
| 237 DCHECK_EQ(kN32_SkColorType, bitmap.colorType()); | 237 DCHECK_EQ(kN32_SkColorType, bitmap.colorType()); |
| 238 | 238 |
| 239 SkAutoLockPixels bitmap_lock(bitmap); | |
| 240 | |
| 241 int pixel_width = bitmap.width(); | 239 int pixel_width = bitmap.width(); |
| 242 int pixel_height = bitmap.height(); | 240 int pixel_height = bitmap.height(); |
| 243 for (int y = 0; y < pixel_height; ++y) { | 241 for (int y = 0; y < pixel_height; ++y) { |
| 244 for (int x = 0; x < pixel_width; ++x) | 242 for (int x = 0; x < pixel_width; ++x) |
| 245 ++histogram[GetLuma(bitmap.getColor(x, y))]; | 243 ++histogram[GetLuma(bitmap.getColor(x, y))]; |
| 246 } | 244 } |
| 247 } | 245 } |
| 248 | 246 |
| 249 double CalculateBoringScore(const SkBitmap& bitmap) { | 247 double CalculateBoringScore(const SkBitmap& bitmap) { |
| 250 if (bitmap.isNull() || bitmap.empty()) | 248 if (bitmap.isNull() || bitmap.empty()) |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 "rgba(%s,%s)", SkColorToRgbString(color).c_str(), | 354 "rgba(%s,%s)", SkColorToRgbString(color).c_str(), |
| 357 base::DoubleToString(SkColorGetA(color) / 255.0).c_str()); | 355 base::DoubleToString(SkColorGetA(color) / 255.0).c_str()); |
| 358 } | 356 } |
| 359 | 357 |
| 360 std::string SkColorToRgbString(SkColor color) { | 358 std::string SkColorToRgbString(SkColor color) { |
| 361 return base::StringPrintf("%d,%d,%d", SkColorGetR(color), SkColorGetG(color), | 359 return base::StringPrintf("%d,%d,%d", SkColorGetR(color), SkColorGetG(color), |
| 362 SkColorGetB(color)); | 360 SkColorGetB(color)); |
| 363 } | 361 } |
| 364 | 362 |
| 365 } // namespace color_utils | 363 } // namespace color_utils |
| OLD | NEW |