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

Unified Diff: ash/common/wallpaper/wallpaper_controller.h

Issue 2679133003: [ash-md] Wired in the Shelf color to be derived from the Wallpaper. (Closed)
Patch Set: Addressed nits. Created 3 years, 10 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
« no previous file with comments | « ash/common/system/tray/tray_background_view.cc ('k') | ash/common/wallpaper/wallpaper_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/wallpaper/wallpaper_controller.h
diff --git a/ash/common/wallpaper/wallpaper_controller.h b/ash/common/wallpaper/wallpaper_controller.h
index ac2000f055c68302810668b27999de9a02da0277..0cead11b420d6446c6b7907378e500fb3d062629 100644
--- a/ash/common/wallpaper/wallpaper_controller.h
+++ b/ash/common/wallpaper/wallpaper_controller.h
@@ -15,8 +15,11 @@
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
#include "base/timer/timer.h"
+#include "components/wallpaper/wallpaper_color_calculator_observer.h"
#include "components/wallpaper/wallpaper_layout.h"
+#include "components/wallpaper/wallpaper_resizer_observer.h"
#include "mojo/public/cpp/bindings/binding_set.h"
+#include "ui/gfx/color_analysis.h"
#include "ui/gfx/image/image_skia.h"
namespace base {
@@ -24,6 +27,7 @@ class TaskRunner;
}
namespace wallpaper {
+class WallpaperColorCalculator;
class WallpaperResizer;
}
@@ -35,7 +39,9 @@ class WallpaperControllerObserver;
class ASH_EXPORT WallpaperController
: public NON_EXPORTED_BASE(mojom::WallpaperController),
public WmDisplayObserver,
- public ShellObserver {
+ public ShellObserver,
+ public wallpaper::WallpaperResizerObserver,
+ public wallpaper::WallpaperColorCalculatorObserver {
public:
enum WallpaperMode { WALLPAPER_NONE, WALLPAPER_IMAGE };
@@ -50,6 +56,8 @@ class ASH_EXPORT WallpaperController
void AddObserver(WallpaperControllerObserver* observer);
void RemoveObserver(WallpaperControllerObserver* observer);
+ SkColor prominent_color() const { return prominent_color_; }
+
// Provides current image on the wallpaper, or empty gfx::ImageSkia if there
// is no image, e.g. wallpaper is none.
gfx::ImageSkia GetWallpaper() const;
@@ -107,7 +115,19 @@ class ASH_EXPORT WallpaperController
void SetWallpaper(const SkBitmap& wallpaper,
wallpaper::WallpaperLayout layout) override;
+ // WallpaperResizerObserver:
+ void OnWallpaperResized() override;
+
+ // WallpaperColorCalculatorObserver:
+ void OnColorCalculationComplete() override;
+
private:
+ // Returns true if the shelf should be colored based on the wallpaper's
+ // prominent color. |luma| and |saturation| are output parameters.
+ static bool GetProminentColorProfile(
+ color_utils::LumaRange* luma,
+ color_utils::SaturationRange* saturation);
+
// Creates a WallpaperWidgetController for |root_window|.
void InstallDesktopController(WmWindow* root_window);
@@ -125,6 +145,13 @@ 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);
+
+ // If enabled, will initiates an asynchronous task to extract colors from the
+ // wallpaper. If an existing calculation is in progress it is destroyed.
+ void CalculateWallpaperColors();
+
bool locked_;
WallpaperMode wallpaper_mode_;
@@ -139,6 +166,13 @@ class ASH_EXPORT WallpaperController
std::unique_ptr<wallpaper::WallpaperResizer> current_wallpaper_;
+ // Asynchronous task to extract colors from the wallpaper.
+ std::unique_ptr<wallpaper::WallpaperColorCalculator> color_calculator_;
+
+ // The prominent color extracted from the current wallpaper.
+ // SK_ColorTRANSPARENT is used by default or if extracting colors fails.
+ SkColor prominent_color_;
+
gfx::Size current_max_display_size_;
base::OneShotTimer timer_;
« no previous file with comments | « ash/common/system/tray/tray_background_view.cc ('k') | ash/common/wallpaper/wallpaper_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698