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

Side by Side Diff: ash/wallpaper/wallpaper_controller.cc

Issue 2872123002: Wallpaper resize extents compositor lock timeout. (Closed)
Patch Set: Add NON_EXPORTED_BASE back. Created 3 years, 7 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 | « ash/wallpaper/wallpaper_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ash/wallpaper/wallpaper_controller.h" 5 #include "ash/wallpaper/wallpaper_controller.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
11 #include "ash/display/window_tree_host_manager.h"
11 #include "ash/public/cpp/shell_window_ids.h" 12 #include "ash/public/cpp/shell_window_ids.h"
12 #include "ash/root_window_controller.h" 13 #include "ash/root_window_controller.h"
13 #include "ash/session/session_controller.h" 14 #include "ash/session/session_controller.h"
14 #include "ash/shell.h" 15 #include "ash/shell.h"
15 #include "ash/shell_port.h" 16 #include "ash/shell_port.h"
16 #include "ash/wallpaper/wallpaper_controller_observer.h" 17 #include "ash/wallpaper/wallpaper_controller_observer.h"
17 #include "ash/wallpaper/wallpaper_delegate.h" 18 #include "ash/wallpaper/wallpaper_delegate.h"
18 #include "ash/wallpaper/wallpaper_view.h" 19 #include "ash/wallpaper/wallpaper_view.h"
19 #include "ash/wallpaper/wallpaper_widget_controller.h" 20 #include "ash/wallpaper/wallpaper_widget_controller.h"
20 #include "ash/wm_window.h" 21 #include "ash/wm_window.h"
21 #include "base/bind.h" 22 #include "base/bind.h"
22 #include "base/command_line.h" 23 #include "base/command_line.h"
23 #include "base/logging.h" 24 #include "base/logging.h"
24 #include "base/task_runner.h" 25 #include "base/task_runner.h"
25 #include "components/wallpaper/wallpaper_color_calculator.h" 26 #include "components/wallpaper/wallpaper_color_calculator.h"
26 #include "components/wallpaper/wallpaper_resizer.h" 27 #include "components/wallpaper/wallpaper_resizer.h"
27 #include "ui/display/manager/managed_display_info.h" 28 #include "ui/display/manager/managed_display_info.h"
28 #include "ui/display/screen.h" 29 #include "ui/display/screen.h"
29 #include "ui/gfx/color_analysis.h" 30 #include "ui/gfx/color_analysis.h"
30 #include "ui/views/widget/widget.h" 31 #include "ui/views/widget/widget.h"
31 32
32 namespace ash { 33 namespace ash {
33 34
34 namespace { 35 namespace {
35 36
36 // How long to wait reloading the wallpaper after the display size has changed. 37 // How long to wait reloading the wallpaper after the display size has changed.
37 const int kWallpaperReloadDelayMs = 100; 38 constexpr int kWallpaperReloadDelayMs = 100;
39
40 // How long to wait for resizing of the the wallpaper.
41 constexpr int kCompositorLockTimeoutMs = 750;
38 42
39 // Returns true if a color should be extracted from the wallpaper based on the 43 // Returns true if a color should be extracted from the wallpaper based on the
40 // command kAshShelfColor line arg. 44 // command kAshShelfColor line arg.
41 bool IsShelfColoringEnabled() { 45 bool IsShelfColoringEnabled() {
42 const bool kDefaultValue = true; 46 const bool kDefaultValue = true;
43 47
44 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 48 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
45 switches::kAshShelfColor)) { 49 switches::kAshShelfColor)) {
46 return kDefaultValue; 50 return kDefaultValue;
47 } 51 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 wallpaper_mode_ = WALLPAPER_IMAGE; 171 wallpaper_mode_ = WALLPAPER_IMAGE;
168 InstallDesktopControllerForAllWindows(); 172 InstallDesktopControllerForAllWindows();
169 } 173 }
170 174
171 void WallpaperController::OnDisplayConfigurationChanged() { 175 void WallpaperController::OnDisplayConfigurationChanged() {
172 gfx::Size max_display_size = GetMaxDisplaySizeInNative(); 176 gfx::Size max_display_size = GetMaxDisplaySizeInNative();
173 if (current_max_display_size_ != max_display_size) { 177 if (current_max_display_size_ != max_display_size) {
174 current_max_display_size_ = max_display_size; 178 current_max_display_size_ = max_display_size;
175 if (wallpaper_mode_ == WALLPAPER_IMAGE && current_wallpaper_) { 179 if (wallpaper_mode_ == WALLPAPER_IMAGE && current_wallpaper_) {
176 timer_.Stop(); 180 timer_.Stop();
181 GetInternalDisplayCompositorLock();
177 timer_.Start(FROM_HERE, 182 timer_.Start(FROM_HERE,
178 base::TimeDelta::FromMilliseconds(wallpaper_reload_delay_), 183 base::TimeDelta::FromMilliseconds(wallpaper_reload_delay_),
179 base::Bind(&WallpaperController::UpdateWallpaper, 184 base::Bind(&WallpaperController::UpdateWallpaper,
180 base::Unretained(this), false /* clear cache */)); 185 base::Unretained(this), false /* clear cache */));
181 } 186 }
182 } 187 }
183 } 188 }
184 189
185 void WallpaperController::OnRootWindowAdded(WmWindow* root_window) { 190 void WallpaperController::OnRootWindowAdded(WmWindow* root_window) {
186 // The wallpaper hasn't been set yet. 191 // The wallpaper hasn't been set yet.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 void WallpaperController::SetWallpaper(const SkBitmap& wallpaper, 275 void WallpaperController::SetWallpaper(const SkBitmap& wallpaper,
271 wallpaper::WallpaperLayout layout) { 276 wallpaper::WallpaperLayout layout) {
272 if (wallpaper.isNull()) 277 if (wallpaper.isNull())
273 return; 278 return;
274 279
275 SetWallpaperImage(gfx::ImageSkia::CreateFrom1xBitmap(wallpaper), layout); 280 SetWallpaperImage(gfx::ImageSkia::CreateFrom1xBitmap(wallpaper), layout);
276 } 281 }
277 282
278 void WallpaperController::OnWallpaperResized() { 283 void WallpaperController::OnWallpaperResized() {
279 CalculateWallpaperColors(); 284 CalculateWallpaperColors();
285 compositor_lock_.reset();
280 } 286 }
281 287
282 void WallpaperController::OnColorCalculationComplete() { 288 void WallpaperController::OnColorCalculationComplete() {
283 const SkColor color = color_calculator_->prominent_color(); 289 const SkColor color = color_calculator_->prominent_color();
284 color_calculator_.reset(); 290 color_calculator_.reset();
285 SetProminentColor(color); 291 SetProminentColor(color);
286 } 292 }
287 293
288 void WallpaperController::InstallDesktopController(WmWindow* root_window) { 294 void WallpaperController::InstallDesktopController(WmWindow* root_window) {
289 WallpaperWidgetController* component = nullptr; 295 WallpaperWidgetController* component = nullptr;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 407 }
402 408
403 bool WallpaperController::MoveToUnlockedContainer() { 409 bool WallpaperController::MoveToUnlockedContainer() {
404 if (!locked_) 410 if (!locked_)
405 return false; 411 return false;
406 412
407 locked_ = false; 413 locked_ = false;
408 return ReparentWallpaper(GetWallpaperContainerId(false)); 414 return ReparentWallpaper(GetWallpaperContainerId(false));
409 } 415 }
410 416
417 void WallpaperController::GetInternalDisplayCompositorLock() {
418 if (display::Display::HasInternalDisplay()) {
419 compositor_lock_ =
420 Shell::Get()
421 ->window_tree_host_manager()
422 ->GetRootWindowForDisplayId(display::Display::InternalDisplayId())
423 ->layer()
424 ->GetCompositor()
425 ->GetCompositorLock(this, base::TimeDelta::FromMilliseconds(
426 kCompositorLockTimeoutMs));
427 }
428 }
429
430 void WallpaperController::CompositorLockTimedOut() {
431 compositor_lock_.reset();
432 }
433
411 } // namespace ash 434 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wallpaper/wallpaper_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698