Chromium Code Reviews| Index: ui/gfx/color_analysis.cc |
| diff --git a/ui/gfx/color_analysis.cc b/ui/gfx/color_analysis.cc |
| index 4c8bfa2007b33ef8ec3caf92c6f359305d315420..08b1b8ed4cbca0f2ce318744dceded4ace4b1bb7 100644 |
| --- a/ui/gfx/color_analysis.cc |
| +++ b/ui/gfx/color_analysis.cc |
| @@ -382,7 +382,15 @@ SkColor CalculateKMeanColorOfPNG(scoped_refptr<base::RefCountedMemory> png, |
| return color; |
| } |
| -SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap) { |
| +SkColor CalculateKMeanColorOfPNG(scoped_refptr<base::RefCountedMemory> png) { |
| + GridSampler sampler; |
| + return CalculateKMeanColorOfPNG(png, kMinDarkness, kMaxBrightness, &sampler); |
| +} |
| + |
| +SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap, |
| + uint32_t darkness_limit, |
| + uint32_t brightness_limit, |
| + KMeanImageSampler* sampler) { |
| // SkBitmap uses pre-multiplied alpha but the KMean clustering function |
| // above uses non-pre-multiplied alpha. Transform the bitmap before we |
| // analyze it because the function reads each pixel multiple times. |
| @@ -390,17 +398,22 @@ SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap) { |
| scoped_ptr<uint32_t[]> image(new uint32_t[pixel_count]); |
| UnPreMultiply(bitmap, image.get(), pixel_count); |
| - GridSampler sampler; |
| - SkColor color = CalculateKMeanColorOfBuffer( |
| - reinterpret_cast<uint8_t*>(image.get()), |
| - bitmap.width(), |
| - bitmap.height(), |
| - kMinDarkness, |
| - kMaxBrightness, |
| - &sampler); |
| + SkColor color = |
| + CalculateKMeanColorOfBuffer(reinterpret_cast<uint8_t*>(image.get()), |
|
Alexei Svitkine (slow)
2014/05/26 18:20:49
Nit: Just return it directly.
calamity
2014/05/27 01:19:42
Done.
|
| + bitmap.width(), |
| + bitmap.height(), |
| + darkness_limit, |
| + brightness_limit, |
| + sampler); |
| return color; |
| } |
| +SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap) { |
| + GridSampler sampler; |
| + return CalculateKMeanColorOfBitmap( |
| + bitmap, kMinDarkness, kMaxBrightness, &sampler); |
| +} |
| + |
| gfx::Matrix3F ComputeColorCovariance(const SkBitmap& bitmap) { |
| // First need basic stats to normalize each channel separately. |
| SkAutoLockPixels bitmap_lock(bitmap); |