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

Side by Side Diff: ash/shelf/shelf_background_animator.cc

Issue 2943333003: Extracting more than one wallpaper prominent color (Closed)
Patch Set: possible uninitialized local value 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 unified diff | Download patch
« no previous file with comments | « no previous file | ash/wallpaper/wallpaper_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/shelf/shelf_background_animator.h" 5 #include "ash/shelf/shelf_background_animator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/animation/animation_change_type.h" 9 #include "ash/animation/animation_change_type.h"
10 #include "ash/ash_switches.h"
10 #include "ash/shelf/shelf.h" 11 #include "ash/shelf/shelf.h"
11 #include "ash/shelf/shelf_background_animator_observer.h" 12 #include "ash/shelf/shelf_background_animator_observer.h"
12 #include "ash/shelf/shelf_constants.h" 13 #include "ash/shelf/shelf_constants.h"
13 #include "ash/wallpaper/wallpaper_controller.h" 14 #include "ash/wallpaper/wallpaper_controller.h"
15 #include "base/command_line.h"
14 #include "ui/gfx/animation/slide_animation.h" 16 #include "ui/gfx/animation/slide_animation.h"
17 #include "ui/gfx/color_analysis.h"
15 #include "ui/gfx/color_utils.h" 18 #include "ui/gfx/color_utils.h"
16 19
20 using ColorProfile = color_utils::ColorProfile;
21 using LumaRange = color_utils::LumaRange;
22 using SaturationRange = color_utils::SaturationRange;
23
17 namespace ash { 24 namespace ash {
18 25
26 namespace {
27
28 // Returns color profile used for shelf based on the kAshShelfColorScheme
29 // command line arg.
30 ColorProfile GetShelfColorProfile() {
31 const std::string switch_value =
32 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
33 switches::kAshShelfColorScheme);
34
35 ColorProfile color_profile(LumaRange::DARK, SaturationRange::MUTED);
36
37 if (switch_value.find("light") != std::string::npos)
38 color_profile.luma = LumaRange::LIGHT;
39 else if (switch_value.find("normal") != std::string::npos)
40 color_profile.luma = LumaRange::NORMAL;
41 else if (switch_value.find("dark") != std::string::npos)
42 color_profile.luma = LumaRange::DARK;
43
44 if (switch_value.find("vibrant") != std::string::npos)
45 color_profile.saturation = SaturationRange::VIBRANT;
46 else if (switch_value.find("muted") != std::string::npos)
47 color_profile.saturation = SaturationRange::MUTED;
48
49 return color_profile;
50 }
51
52 } // namespace
53
19 ShelfBackgroundAnimator::AnimationValues::AnimationValues() {} 54 ShelfBackgroundAnimator::AnimationValues::AnimationValues() {}
20 55
21 ShelfBackgroundAnimator::AnimationValues::~AnimationValues() {} 56 ShelfBackgroundAnimator::AnimationValues::~AnimationValues() {}
22 57
23 void ShelfBackgroundAnimator::AnimationValues::UpdateCurrentValues(double t) { 58 void ShelfBackgroundAnimator::AnimationValues::UpdateCurrentValues(double t) {
24 current_color_ = 59 current_color_ =
25 gfx::Tween::ColorValueBetween(t, initial_color_, target_color_); 60 gfx::Tween::ColorValueBetween(t, initial_color_, target_color_);
26 } 61 }
27 62
28 void ShelfBackgroundAnimator::AnimationValues::SetTargetValues( 63 void ShelfBackgroundAnimator::AnimationValues::SetTargetValues(
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 case SHELF_BACKGROUND_OVERLAP: 241 case SHELF_BACKGROUND_OVERLAP:
207 target_shelf_color_alpha = kShelfTranslucentAlpha; 242 target_shelf_color_alpha = kShelfTranslucentAlpha;
208 target_item_color_alpha = 0; 243 target_item_color_alpha = 0;
209 break; 244 break;
210 case SHELF_BACKGROUND_MAXIMIZED: 245 case SHELF_BACKGROUND_MAXIMIZED:
211 target_shelf_color_alpha = kMaxAlpha; 246 target_shelf_color_alpha = kMaxAlpha;
212 target_item_color_alpha = 0; 247 target_item_color_alpha = 0;
213 break; 248 break;
214 } 249 }
215 250
216 SkColor target_color = wallpaper_controller_ 251 SkColor target_color =
217 ? wallpaper_controller_->prominent_color() 252 wallpaper_controller_
218 : kShelfDefaultBaseColor; 253 ? wallpaper_controller_->GetProminentColor(GetShelfColorProfile())
254 : kShelfDefaultBaseColor;
219 if (target_color == WallpaperController::kInvalidColor) { 255 if (target_color == WallpaperController::kInvalidColor) {
220 target_color = kShelfDefaultBaseColor; 256 target_color = kShelfDefaultBaseColor;
221 } else { 257 } else {
222 int darkening_alpha = 0; 258 int darkening_alpha = 0;
223 259
224 switch (background_type) { 260 switch (background_type) {
225 case SHELF_BACKGROUND_DEFAULT: 261 case SHELF_BACKGROUND_DEFAULT:
226 case SHELF_BACKGROUND_OVERLAP: 262 case SHELF_BACKGROUND_OVERLAP:
227 darkening_alpha = kShelfTranslucentColorDarkenAlpha; 263 darkening_alpha = kShelfTranslucentColorDarkenAlpha;
228 break; 264 break;
(...skipping 13 matching lines...) Expand all
242 278
243 void ShelfBackgroundAnimator::SetAnimationValues(double t) { 279 void ShelfBackgroundAnimator::SetAnimationValues(double t) {
244 DCHECK_GE(t, 0.0); 280 DCHECK_GE(t, 0.0);
245 DCHECK_LE(t, 1.0); 281 DCHECK_LE(t, 1.0);
246 shelf_background_values_.UpdateCurrentValues(t); 282 shelf_background_values_.UpdateCurrentValues(t);
247 item_background_values_.UpdateCurrentValues(t); 283 item_background_values_.UpdateCurrentValues(t);
248 NotifyObservers(); 284 NotifyObservers();
249 } 285 }
250 286
251 } // namespace ash 287 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wallpaper/wallpaper_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698