Chromium Code Reviews| Index: ui/gfx/color_analysis.cc |
| diff --git a/ui/gfx/color_analysis.cc b/ui/gfx/color_analysis.cc |
| index 6a2e87850f69ddbdfc9b2656616dcf5409b0310a..568adbaf3e5bfe3c005e108020e88c6eb7e90c3c 100644 |
| --- a/ui/gfx/color_analysis.cc |
| +++ b/ui/gfx/color_analysis.cc |
| @@ -455,6 +455,57 @@ SkColor CalculateProminentColor(const SkBitmap& bitmap, |
| return best_color; |
| } |
| +SkColor CalculateProminentColorOfBitmap(const SkBitmap& bitmap, |
| + LumaRange luma, |
| + SaturationRange saturation) { |
| + if (bitmap.empty() || bitmap.isNull()) |
| + return SK_ColorTRANSPARENT; |
| + |
| + // The hue is not relevant to our bounds or goal colors. |
| + HSL lower_bound = { |
| + -1, |
| + }; |
| + HSL upper_bound = { |
| + -1, |
| + }; |
| + HSL goal = { |
| + -1, |
| + }; |
| + |
| + switch (luma) { |
| + case LumaRange::LIGHT: |
| + lower_bound.l = 0.55f; |
| + upper_bound.l = 1; |
| + goal.l = 0.74f; |
| + break; |
| + case LumaRange::NORMAL: |
| + lower_bound.l = 0.3f; |
| + upper_bound.l = 0.7f; |
| + goal.l = 0.5f; |
| + break; |
| + case LumaRange::DARK: |
| + lower_bound.l = 0; |
| + upper_bound.l = 0.45f; |
| + goal.l = 0.26f; |
| + break; |
| + } |
| + |
| + switch (saturation) { |
| + case SaturationRange::VIBRANT: |
| + lower_bound.s = 0.35f; |
| + upper_bound.s = 1; |
| + goal.s = 1; |
| + break; |
| + case SaturationRange::MUTED: |
| + lower_bound.s = 0; |
| + upper_bound.s = 0.4f; |
| + goal.s = 0.3f; |
| + break; |
| + } |
| + |
| + return CalculateProminentColor(bitmap, lower_bound, upper_bound, goal); |
|
bruthig
2017/06/20 15:32:14
estade@ will be able to better advise but IIUC Cal
Evan Stade
2017/06/20 17:11:08
yes, as explained in the email, we only want to re
Qiang(Joe) Xu
2017/06/20 22:48:55
done, thanks for explaining!
|
| +} |
| + |
| } // namespace |
| KMeanImageSampler::KMeanImageSampler() { |
| @@ -723,55 +774,15 @@ SkColor CalculateKMeanColorOfBitmap(const SkBitmap& bitmap) { |
| bitmap, kDefaultLowerHSLBound, kDefaultUpperHSLBound, &sampler); |
| } |
| -SkColor CalculateProminentColorOfBitmap(const SkBitmap& bitmap, |
| - LumaRange luma, |
| - SaturationRange saturation) { |
| - if (bitmap.empty() || bitmap.isNull()) |
| - return SK_ColorTRANSPARENT; |
| - |
| - // The hue is not relevant to our bounds or goal colors. |
| - HSL lower_bound = { |
| - -1, |
| - }; |
| - HSL upper_bound = { |
| - -1, |
| - }; |
| - HSL goal = { |
| - -1, |
| - }; |
| - |
| - switch (luma) { |
| - case LumaRange::LIGHT: |
| - lower_bound.l = 0.55f; |
| - upper_bound.l = 1; |
| - goal.l = 0.74f; |
| - break; |
| - case LumaRange::NORMAL: |
| - lower_bound.l = 0.3f; |
| - upper_bound.l = 0.7f; |
| - goal.l = 0.5f; |
| - break; |
| - case LumaRange::DARK: |
| - lower_bound.l = 0; |
| - upper_bound.l = 0.45f; |
| - goal.l = 0.26f; |
| - break; |
| - } |
| - |
| - switch (saturation) { |
| - case SaturationRange::VIBRANT: |
| - lower_bound.s = 0.35f; |
| - upper_bound.s = 1; |
| - goal.s = 1; |
| - break; |
| - case SaturationRange::MUTED: |
| - lower_bound.s = 0; |
| - upper_bound.s = 0.4f; |
| - goal.s = 0.3f; |
| - break; |
| +std::vector<SkColor> CalculateProminentColorsOfBitmap( |
| + const SkBitmap& bitmap, |
| + const ColorProfiles& color_profiles) { |
| + std::vector<SkColor> colors; |
| + for (auto profile : color_profiles) { |
| + colors.push_back(CalculateProminentColorOfBitmap(bitmap, profile.luma, |
| + profile.saturation)); |
| } |
| - |
| - return CalculateProminentColor(bitmap, lower_bound, upper_bound, goal); |
| + return colors; |
| } |
| gfx::Matrix3F ComputeColorCovariance(const SkBitmap& bitmap) { |