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

Unified Diff: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc

Issue 2931063004: Extract colors from wallpaper and dynamically update login screen overlay (Closed)
Patch Set: Move unrelated style changes to a separate CL 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: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc
diff --git a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc
index 675f657833b61b87a09e1b6a674d56bc97d0d1ac..9dfc3b9855fa07dbcf458d15c6381e21567643ec 100644
--- a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc
+++ b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc
@@ -204,6 +204,7 @@ void SetKnownUserWallpaperFilesId(
// A helper to set the wallpaper image for Classic Ash and Mash.
void SetWallpaper(const gfx::ImageSkia& image,
wallpaper::WallpaperLayout layout) {
+ WallpaperManager::Get()->CalculateProminentColor(image);
if (ash_util::IsRunningInMash()) {
// In mash, connect to the WallpaperController interface via mojo.
service_manager::Connector* connector =
@@ -427,6 +428,24 @@ bool WallpaperManager::IsPendingWallpaper(uint32_t image_id) {
return false;
}
+void WallpaperManager::CalculateProminentColor(const gfx::ImageSkia& image) {
+ // Cancel in-flight color calculations, if any.
+ if (color_calculator_) {
+ color_calculator_->RemoveObserver(this);
+ color_calculator_.reset();
+ }
+
+ color_calculator_ = base::MakeUnique<wallpaper::WallpaperColorCalculator>(
+ image, color_utils::LumaRange::DARK, color_utils::SaturationRange::MUTED,
xdai1 2017/06/13 23:04:24 Is the color scheme for the login screen fixed? Ca
Wenzhao (Colin) Zang 2017/06/14 00:44:50 The color scheme for the shelf is derived from the
xdai1 2017/06/14 18:23:40 The code logic of WallpaperColorCalculator here is
xiyuan 2017/06/14 18:28:26 WallpaperController is part of ash. If we do that,
Wenzhao (Colin) Zang 2017/06/15 05:02:08 I understand the concerns. Before writing this CL
+ task_runner_);
+ color_calculator_->AddObserver(this);
+ if (!color_calculator_->StartCalculation()) {
xdai1 2017/06/13 23:04:24 If the calculation fails to be initiated, why do w
Wenzhao (Colin) Zang 2017/06/14 00:44:50 Because the front end needs to be notified of the
+ prominent_color_.reset();
+ for (auto& observer : observers_)
+ observer.OnColorCalculationComplete();
+ }
+}
+
WallpaperManager::WallpaperResolution
WallpaperManager::GetAppropriateResolution() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -911,6 +930,15 @@ void WallpaperManager::OnWindowDestroying(aura::Window* window) {
user_manager::UserManager::Get()->GetActiveUser()->username_hash());
}
+void WallpaperManager::OnColorCalculationComplete() {
+ if (color_calculator_->prominent_color() == prominent_color_)
+ return;
xiyuan 2017/06/13 23:23:48 |color_calculator_|.reset() is skipped when this h
Wenzhao (Colin) Zang 2017/06/14 00:44:50 Done. Thanks for pointing it out.
+ prominent_color_ = color_calculator_->prominent_color();
+ color_calculator_.reset();
+ for (auto& observer : observers_)
+ observer.OnColorCalculationComplete();
+}
+
// WallpaperManager, private: --------------------------------------------------
WallpaperManager::WallpaperManager()

Powered by Google App Engine
This is Rietveld 408576698