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

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: Address comments 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..5b75149a36ef66592d037aec74c1cb808c93f116 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,22 @@ bool WallpaperManager::IsPendingWallpaper(uint32_t image_id) {
return false;
}
+void WallpaperManager::CalculateProminentColor(const gfx::ImageSkia& image) {
+ if (color_calculator_) {
+ color_calculator_->RemoveObserver(this);
jdufault 2017/06/12 21:37:28 Add a comment along the lines of // Cancel any
Wenzhao (Colin) Zang 2017/06/12 23:40:34 Done.
+ color_calculator_.reset();
+ }
+
+ color_utils::LumaRange luma = color_utils::LumaRange::DARK;
jdufault 2017/06/12 21:37:28 Eliminate the |luma| and |saturation| temporaries.
Wenzhao (Colin) Zang 2017/06/12 23:40:34 Done.
+ color_utils::SaturationRange saturation = color_utils::SaturationRange::MUTED;
+
+ color_calculator_ = base::MakeUnique<wallpaper::WallpaperColorCalculator>(
+ image, luma, saturation, task_runner_);
+ color_calculator_->AddObserver(this);
+ if (!color_calculator_->StartCalculation())
+ SetProminentColor(SK_ColorTRANSPARENT);
+}
+
WallpaperManager::WallpaperResolution
WallpaperManager::GetAppropriateResolution() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -911,6 +928,12 @@ void WallpaperManager::OnWindowDestroying(aura::Window* window) {
user_manager::UserManager::Get()->GetActiveUser()->username_hash());
}
+void WallpaperManager::OnColorCalculationComplete() {
+ const SkColor color = color_calculator_->prominent_color();
+ color_calculator_.reset();
jdufault 2017/06/12 21:37:28 Add a comment explaining why you cache color inste
Wenzhao (Colin) Zang 2017/06/12 23:40:34 Changed to using the color directly.
+ SetProminentColor(color);
+}
+
// WallpaperManager, private: --------------------------------------------------
WallpaperManager::WallpaperManager()
@@ -1105,6 +1128,15 @@ void WallpaperManager::OnDeviceWallpaperDecoded(
->ResetSetWallpaperImage(user_image->image(), wallpaper_info);
}
+void WallpaperManager::SetProminentColor(SkColor color) {
+ if (prominent_color_ == color)
+ return;
+
+ prominent_color_ = color;
+ for (auto& observer : observers_)
+ observer.OnColorCalculationComplete();
+}
+
void WallpaperManager::InitializeRegisteredDeviceWallpaper() {
if (user_manager::UserManager::Get()->IsUserLoggedIn())
return;

Powered by Google App Engine
This is Rietveld 408576698