Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Unified Diff: ash/wallpaper/wallpaper_controller.h

Issue 2943333003: Extracting more than one wallpaper prominent color (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/wallpaper/wallpaper_controller.h
diff --git a/ash/wallpaper/wallpaper_controller.h b/ash/wallpaper/wallpaper_controller.h
index 82d80fe3ac9dab22004751494426f14a377a72a7..7354d2cdf01c14cd6374fb212b1c2e92361c3301 100644
--- a/ash/wallpaper/wallpaper_controller.h
+++ b/ash/wallpaper/wallpaper_controller.h
@@ -39,7 +39,7 @@ class WallpaperControllerObserver;
// Controls the desktop background wallpaper:
// - Sets a wallpaper image and layout;
// - Handles display change (add/remove display, configuration change etc);
-// - Calculates prominent color for shelf;
+// - Calculates prominent colors.
// - Move wallpaper to locked container(s) when session state is not ACTIVE to
// hide the user desktop and move it to unlocked container when session
// state is ACTIVE;
@@ -54,9 +54,20 @@ class ASH_EXPORT WallpaperController
public:
enum WallpaperMode { WALLPAPER_NONE, WALLPAPER_IMAGE };
- // The value assigned to |prominent_color_| if extraction fails or the feature
- // is disabled (e.g. command line, lock/login screens).
- static constexpr SkColor kInvalidColor = SK_ColorTRANSPARENT;
+ // This enum is used to get the corresponding prominent color from the results
+ // of wallpaper color calculator.
+ enum ColorProfileIndex {
+ COLOR_PROFILE_INDEX_DARK_VIBRANT = 0,
+ COLOR_PROFILE_INDEX_NORMAL_VIBRANT,
+ COLOR_PROFILE_INDEX_LIGHT_VIBRANT,
+ COLOR_PROFILE_INDEX_DARK_MUTED,
+ COLOR_PROFILE_INDEX_NORMAL_MUTED,
+ COLOR_PROFILE_INDEX_LIGHT_MUTED,
+ };
+
+ // The value assigned if extraction fails or the feature is disabled (e.g.
+ // command line, lock/login screens).
+ static const SkColor kInvalidColor;
WallpaperController();
~WallpaperController() override;
@@ -68,7 +79,13 @@ class ASH_EXPORT WallpaperController
void AddObserver(WallpaperControllerObserver* observer);
void RemoveObserver(WallpaperControllerObserver* observer);
- SkColor prominent_color() const { return prominent_color_; }
+ // Returns the prominent color based on the given |color_profile|.
+ SkColor prominent_color(ColorProfileIndex color_profile_index) const {
+ return prominent_colors_[color_profile_index];
+ }
+
+ // Returns the color profile index used for shelf.
+ WallpaperController::ColorProfileIndex GetShelfColorProfileIndex() const;
// Provides current image on the wallpaper, or empty gfx::ImageSkia if there
// is no image, e.g. wallpaper is none.
@@ -152,10 +169,14 @@ class ASH_EXPORT WallpaperController
// wallpaper cahce or not.
void UpdateWallpaper(bool clear_cache);
- // Sets |prominent_color_| and notifies the observers if there is a change.
- void SetProminentColor(SkColor color);
+ // Sets |prominent_colors_| and notifies the observers if there is a change.
+ void SetProminentColors(const std::vector<SkColor>& prominent_colors);
- // Calculates a prominent color based on the wallpaper image and notifies
+ // Returns color profile index based on |color_profile|.
+ WallpaperController::ColorProfileIndex GetColorProfileIndex(
+ color_utils::ColorProfile color_profile) const;
+
+ // Calculates prominent colors based on the wallpaper image and notifies
// |observers_| of the value, either synchronously or asynchronously. In some
// cases the wallpaper image will not actually be processed (e.g. user isn't
// logged in, feature isn't enabled).
@@ -197,9 +218,12 @@ class ASH_EXPORT WallpaperController
// Asynchronous task to extract colors from the wallpaper.
std::unique_ptr<wallpaper::WallpaperColorCalculator> color_calculator_;
- // The prominent color extracted from the current wallpaper.
+ // The prominent colors extracted from the current wallpaper.
// kInvalidColor is used by default or if extracting colors fails.
- SkColor prominent_color_;
+ std::vector<SkColor> prominent_colors_;
+
+ // Caches the color profiles that need to do wallpaper color extracting.
+ const color_utils::ColorProfiles color_profiles_;
gfx::Size current_max_display_size_;

Powered by Google App Engine
This is Rietveld 408576698