| Index: ui/gfx/color_analysis.cc
|
| diff --git a/ui/gfx/color_analysis.cc b/ui/gfx/color_analysis.cc
|
| index 4c8bfa2007b33ef8ec3caf92c6f359305d315420..f818403269103ab1651f8e0ecec5c67788c1ed99 100644
|
| --- a/ui/gfx/color_analysis.cc
|
| +++ b/ui/gfx/color_analysis.cc
|
| @@ -382,7 +382,10 @@ SkColor CalculateKMeanColorOfPNG(scoped_refptr<base::RefCountedMemory> png,
|
| return color;
|
| }
|
|
|
| -SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap) {
|
| +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 +393,27 @@ 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()),
|
| + bitmap.width(),
|
| + bitmap.height(),
|
| + darkness_limit,
|
| + brightness_limit,
|
| + sampler);
|
| return color;
|
| }
|
|
|
| +SkColor CalculateKMeanColorOfPNG(scoped_refptr<base::RefCountedMemory> png) {
|
| + GridSampler sampler;
|
| + return CalculateKMeanColorOfPNG(png, kMinDarkness, kMaxBrightness, &sampler);
|
| +}
|
| +
|
| +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);
|
|
|