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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_ 5 #ifndef ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_
6 #define ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_ 6 #define ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
(...skipping 21 matching lines...) Expand all
32 class WallpaperResizer; 32 class WallpaperResizer;
33 } 33 }
34 34
35 namespace ash { 35 namespace ash {
36 36
37 class WallpaperControllerObserver; 37 class WallpaperControllerObserver;
38 38
39 // Controls the desktop background wallpaper: 39 // Controls the desktop background wallpaper:
40 // - Sets a wallpaper image and layout; 40 // - Sets a wallpaper image and layout;
41 // - Handles display change (add/remove display, configuration change etc); 41 // - Handles display change (add/remove display, configuration change etc);
42 // - Calculates prominent color for shelf; 42 // - Calculates prominent colors.
43 // - Move wallpaper to locked container(s) when session state is not ACTIVE to 43 // - Move wallpaper to locked container(s) when session state is not ACTIVE to
44 // hide the user desktop and move it to unlocked container when session 44 // hide the user desktop and move it to unlocked container when session
45 // state is ACTIVE; 45 // state is ACTIVE;
46 class ASH_EXPORT WallpaperController 46 class ASH_EXPORT WallpaperController
47 : public NON_EXPORTED_BASE(mojom::WallpaperController), 47 : public NON_EXPORTED_BASE(mojom::WallpaperController),
48 public WmDisplayObserver, 48 public WmDisplayObserver,
49 public ShellObserver, 49 public ShellObserver,
50 public wallpaper::WallpaperResizerObserver, 50 public wallpaper::WallpaperResizerObserver,
51 public wallpaper::WallpaperColorCalculatorObserver, 51 public wallpaper::WallpaperColorCalculatorObserver,
52 public SessionObserver, 52 public SessionObserver,
53 public NON_EXPORTED_BASE(ui::CompositorLockClient) { 53 public NON_EXPORTED_BASE(ui::CompositorLockClient) {
54 public: 54 public:
55 enum WallpaperMode { WALLPAPER_NONE, WALLPAPER_IMAGE }; 55 enum WallpaperMode { WALLPAPER_NONE, WALLPAPER_IMAGE };
56 56
57 // The value assigned to |prominent_color_| if extraction fails or the feature 57 // This enum is used to get the corresponding prominent color from the results
58 // is disabled (e.g. command line, lock/login screens). 58 // of wallpaper color calculator.
59 static constexpr SkColor kInvalidColor = SK_ColorTRANSPARENT; 59 enum ColorProfileIndex {
60 COLOR_PROFILE_INDEX_DARK_VIBRANT = 0,
61 COLOR_PROFILE_INDEX_NORMAL_VIBRANT,
62 COLOR_PROFILE_INDEX_LIGHT_VIBRANT,
63 COLOR_PROFILE_INDEX_DARK_MUTED,
64 COLOR_PROFILE_INDEX_NORMAL_MUTED,
65 COLOR_PROFILE_INDEX_LIGHT_MUTED,
66 };
67
68 // The value assigned if extraction fails or the feature is disabled (e.g.
69 // command line, lock/login screens).
70 static const SkColor kInvalidColor;
60 71
61 WallpaperController(); 72 WallpaperController();
62 ~WallpaperController() override; 73 ~WallpaperController() override;
63 74
64 // Binds the mojom::WallpaperController interface request to this object. 75 // Binds the mojom::WallpaperController interface request to this object.
65 void BindRequest(mojom::WallpaperControllerRequest request); 76 void BindRequest(mojom::WallpaperControllerRequest request);
66 77
67 // Add/Remove observers. 78 // Add/Remove observers.
68 void AddObserver(WallpaperControllerObserver* observer); 79 void AddObserver(WallpaperControllerObserver* observer);
69 void RemoveObserver(WallpaperControllerObserver* observer); 80 void RemoveObserver(WallpaperControllerObserver* observer);
70 81
71 SkColor prominent_color() const { return prominent_color_; } 82 // Returns the prominent color based on the given |color_profile|.
83 SkColor prominent_color(ColorProfileIndex color_profile_index) const {
84 return prominent_colors_[color_profile_index];
85 }
86
87 // Returns the color profile index used for shelf.
88 WallpaperController::ColorProfileIndex GetShelfColorProfileIndex() const;
72 89
73 // Provides current image on the wallpaper, or empty gfx::ImageSkia if there 90 // Provides current image on the wallpaper, or empty gfx::ImageSkia if there
74 // is no image, e.g. wallpaper is none. 91 // is no image, e.g. wallpaper is none.
75 gfx::ImageSkia GetWallpaper() const; 92 gfx::ImageSkia GetWallpaper() const;
76 uint32_t GetWallpaperOriginalImageId() const; 93 uint32_t GetWallpaperOriginalImageId() const;
77 94
78 wallpaper::WallpaperLayout GetWallpaperLayout() const; 95 wallpaper::WallpaperLayout GetWallpaperLayout() const;
79 96
80 // Sets the wallpaper and alerts observers of changes. 97 // Sets the wallpaper and alerts observers of changes.
81 void SetWallpaperImage(const gfx::ImageSkia& image, 98 void SetWallpaperImage(const gfx::ImageSkia& image,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Returns true if a wallpaper moved. 162 // Returns true if a wallpaper moved.
146 bool ReparentWallpaper(int container); 163 bool ReparentWallpaper(int container);
147 164
148 // Returns the wallpaper container id for unlocked and locked states. 165 // Returns the wallpaper container id for unlocked and locked states.
149 int GetWallpaperContainerId(bool locked); 166 int GetWallpaperContainerId(bool locked);
150 167
151 // Reload the wallpaper. |clear_cache| specifies whether to clear the 168 // Reload the wallpaper. |clear_cache| specifies whether to clear the
152 // wallpaper cahce or not. 169 // wallpaper cahce or not.
153 void UpdateWallpaper(bool clear_cache); 170 void UpdateWallpaper(bool clear_cache);
154 171
155 // Sets |prominent_color_| and notifies the observers if there is a change. 172 // Sets |prominent_colors_| and notifies the observers if there is a change.
156 void SetProminentColor(SkColor color); 173 void SetProminentColors(const std::vector<SkColor>& prominent_colors);
157 174
158 // Calculates a prominent color based on the wallpaper image and notifies 175 // Returns color profile index based on |color_profile|.
176 WallpaperController::ColorProfileIndex GetColorProfileIndex(
177 color_utils::ColorProfile color_profile) const;
178
179 // Calculates prominent colors based on the wallpaper image and notifies
159 // |observers_| of the value, either synchronously or asynchronously. In some 180 // |observers_| of the value, either synchronously or asynchronously. In some
160 // cases the wallpaper image will not actually be processed (e.g. user isn't 181 // cases the wallpaper image will not actually be processed (e.g. user isn't
161 // logged in, feature isn't enabled). 182 // logged in, feature isn't enabled).
162 // If an existing calculation is in progress it is destroyed. 183 // If an existing calculation is in progress it is destroyed.
163 void CalculateWallpaperColors(); 184 void CalculateWallpaperColors();
164 185
165 // Returns false when the color extraction algorithm shouldn't be run based on 186 // Returns false when the color extraction algorithm shouldn't be run based on
166 // system state (e.g. wallpaper image, SessionState, etc.). 187 // system state (e.g. wallpaper image, SessionState, etc.).
167 bool ShouldCalculateColors() const; 188 bool ShouldCalculateColors() const;
168 189
(...skipping 21 matching lines...) Expand all
190 // Bindings for the WallpaperController interface. 211 // Bindings for the WallpaperController interface.
191 mojo::BindingSet<mojom::WallpaperController> bindings_; 212 mojo::BindingSet<mojom::WallpaperController> bindings_;
192 213
193 base::ObserverList<WallpaperControllerObserver> observers_; 214 base::ObserverList<WallpaperControllerObserver> observers_;
194 215
195 std::unique_ptr<wallpaper::WallpaperResizer> current_wallpaper_; 216 std::unique_ptr<wallpaper::WallpaperResizer> current_wallpaper_;
196 217
197 // Asynchronous task to extract colors from the wallpaper. 218 // Asynchronous task to extract colors from the wallpaper.
198 std::unique_ptr<wallpaper::WallpaperColorCalculator> color_calculator_; 219 std::unique_ptr<wallpaper::WallpaperColorCalculator> color_calculator_;
199 220
200 // The prominent color extracted from the current wallpaper. 221 // The prominent colors extracted from the current wallpaper.
201 // kInvalidColor is used by default or if extracting colors fails. 222 // kInvalidColor is used by default or if extracting colors fails.
202 SkColor prominent_color_; 223 std::vector<SkColor> prominent_colors_;
224
225 // Caches the color profiles that need to do wallpaper color extracting.
226 const color_utils::ColorProfiles color_profiles_;
203 227
204 gfx::Size current_max_display_size_; 228 gfx::Size current_max_display_size_;
205 229
206 base::OneShotTimer timer_; 230 base::OneShotTimer timer_;
207 231
208 int wallpaper_reload_delay_; 232 int wallpaper_reload_delay_;
209 233
210 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_; 234 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_;
211 235
212 ScopedSessionObserver scoped_session_observer_; 236 ScopedSessionObserver scoped_session_observer_;
213 237
214 std::unique_ptr<ui::CompositorLock> compositor_lock_; 238 std::unique_ptr<ui::CompositorLock> compositor_lock_;
215 239
216 DISALLOW_COPY_AND_ASSIGN(WallpaperController); 240 DISALLOW_COPY_AND_ASSIGN(WallpaperController);
217 }; 241 };
218 242
219 } // namespace ash 243 } // namespace ash
220 244
221 #endif // ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_ 245 #endif // ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698