| Index: ui/gfx/color_analysis.h
|
| diff --git a/ui/gfx/color_analysis.h b/ui/gfx/color_analysis.h
|
| index 55ba3a4502fe5084f8c675d47313d56326836e64..3e01643598e594148d6bab37f83ebb0d060d5616 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
|
| @@ -57,10 +59,9 @@ GFX_EXPORT SkColor FindClosestColor(const uint8_t* image, int width, int height,
|
| // 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
|
| @@ -83,25 +84,22 @@ 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);
|
| 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|.
|
| +// Computes a dominant color for using the above algorithm and reasonable
|
| +// defaults for |lower_bound|, |upper_bound| and |sampler|.
|
| GFX_EXPORT SkColor
|
| CalculateKMeanColorOfPNG(scoped_refptr<base::RefCountedMemory> png);
|
| GFX_EXPORT SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap);
|
|
|