| Index: ui/gfx/color_analysis.h
|
| diff --git a/ui/gfx/color_analysis.h b/ui/gfx/color_analysis.h
|
| index 3b5ebe85f398d47ef1fe1ffe026d9b890878a49f..dd273bc11e4299770eaff08836e97ba5130713f6 100644
|
| --- a/ui/gfx/color_analysis.h
|
| +++ b/ui/gfx/color_analysis.h
|
| @@ -17,6 +17,8 @@ class SkBitmap;
|
|
|
| namespace color_utils {
|
|
|
| +struct HSL;
|
| +
|
| // This class exposes the sampling method to the caller, which allows
|
| // stubbing out for things like unit tests. Might be useful to pass more
|
| // arguments into the GetSample method in the future (such as which
|
| @@ -56,10 +58,9 @@ GFX_EXPORT SkColor FindClosestColor(const uint8_t* image, int width, int height,
|
| // image. This uses a KMean clustering algorithm to find clusters of pixel
|
| // colors in RGB space.
|
| // |png|/|bitmap| represents the data of a png/bitmap encoded image.
|
| -// |darkness_limit| represents the minimum sum of the RGB components that is
|
| -// acceptable as a color choice. This can be from 0 to 765.
|
| -// |brightness_limit| represents the maximum sum of the RGB components that is
|
| -// acceptable as a color choice. This can be from 0 to 765.
|
| +// |lower_bound| represents the minimum bound of HSL values to allow.
|
| +// |upper_bound| represents the maximum bound of HSL values to allow.
|
| +// See color_utils::IsWithinHSLRange() for description of these bounds.
|
| //
|
| // RGB KMean Algorithm (N clusters, M iterations):
|
| // 1.Pick N starting colors by randomly sampling the pixels. If you see a
|
| @@ -82,31 +83,28 @@ GFX_EXPORT SkColor FindClosestColor(const uint8_t* image, int width, int height,
|
| // the clusters by weight (where weight is the number of pixels that make up
|
| // this cluster).
|
| // 6.Going through the sorted list of clusters, pick the first cluster with the
|
| -// largest weight that's centroid fulfills the equation
|
| -// |darkness_limit| < SUM(R, G, B) < |brightness_limit|. Return that color.
|
| +// largest weight that's centroid falls between |lower_bound| and
|
| +// |upper_bound|. Return that color.
|
| // If no color fulfills that requirement return the color with the largest
|
| // weight regardless of whether or not it fulfills the equation above.
|
| -//
|
| -// Note: Switching to HSV space did not improve the results of this algorithm
|
| -// for typical favicon images.
|
| -GFX_EXPORT SkColor CalculateKMeanColorOfPNG(
|
| - scoped_refptr<base::RefCountedMemory> png,
|
| - uint32_t darkness_limit,
|
| - uint32_t brightness_limit,
|
| - KMeanImageSampler* sampler);
|
| +GFX_EXPORT SkColor
|
| + CalculateKMeanColorOfPNG(scoped_refptr<base::RefCountedMemory> png,
|
| + const HSL& lower_bound,
|
| + const HSL& upper_bound,
|
| + KMeanImageSampler* sampler);
|
| // Computes a dominant color using the above algorithm and reasonable defaults
|
| -// for |darkness_limit|, |brightness_limit| and |sampler|.
|
| +// for |lower_bound|, |upper_bound| and |sampler|.
|
| GFX_EXPORT SkColor CalculateKMeanColorOfPNG(
|
| scoped_refptr<base::RefCountedMemory> png);
|
|
|
| // Returns an SkColor that represents the calculated dominant color in the
|
| // image. See CalculateKMeanColorOfPNG() for details.
|
| GFX_EXPORT SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap,
|
| - uint32_t darkness_limit,
|
| - uint32_t brightness_limit,
|
| + const HSL& lower_bound,
|
| + const HSL& upper_bound,
|
| KMeanImageSampler* sampler);
|
| // Computes a dominant color using the above algorithm and reasonable defaults
|
| -// for |darkness_limit|, |brightness_limit| and |sampler|.
|
| +// for |lower_bound|, |upper_bound| and |sampler|.
|
| GFX_EXPORT SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap);
|
|
|
| // Compute color covariance matrix for the input bitmap.
|
|
|