Commit 7a1ba5ff authored by afakhry's avatar afakhry Committed by Commit bot

Get rid of the huge delay in background resize during rotation

The delay to start updating the wallpaper after rotating the screen used
to be 2 seconds which was also accompanied by unnecessary clearing of
the wallpaper cache resulting in an ugly visual effect.

Now we reduced the delay to only 100 ms and we only clear the cache when
we add another display.

BUG=359654
TEST=manual

Review URL: https://codereview.chromium.org/1131243006

Cr-Commit-Position: refs/heads/master@{#329507}
parent 355e3f19
...@@ -45,7 +45,7 @@ namespace { ...@@ -45,7 +45,7 @@ namespace {
// How long to wait reloading the wallpaper after the max display has // How long to wait reloading the wallpaper after the max display has
// changed? // changed?
const int kWallpaperReloadDelayMs = 2000; const int kWallpaperReloadDelayMs = 100;
} // namespace } // namespace
...@@ -136,8 +136,8 @@ void DesktopBackgroundController::OnDisplayConfigurationChanged() { ...@@ -136,8 +136,8 @@ void DesktopBackgroundController::OnDisplayConfigurationChanged() {
timer_.Stop(); timer_.Stop();
timer_.Start(FROM_HERE, timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(wallpaper_reload_delay_), base::TimeDelta::FromMilliseconds(wallpaper_reload_delay_),
this, base::Bind(&DesktopBackgroundController::UpdateWallpaper,
&DesktopBackgroundController::UpdateWallpaper); base::Unretained(this), false /* clear cache */));
} }
} }
} }
...@@ -153,7 +153,7 @@ void DesktopBackgroundController::OnRootWindowAdded(aura::Window* root_window) { ...@@ -153,7 +153,7 @@ void DesktopBackgroundController::OnRootWindowAdded(aura::Window* root_window) {
current_max_display_size_ = max_display_size; current_max_display_size_ = max_display_size;
if (desktop_background_mode_ == BACKGROUND_IMAGE && if (desktop_background_mode_ == BACKGROUND_IMAGE &&
current_wallpaper_.get()) current_wallpaper_.get())
UpdateWallpaper(); UpdateWallpaper(true /* clear cache */);
} }
InstallDesktopController(root_window); InstallDesktopController(root_window);
...@@ -275,10 +275,10 @@ int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { ...@@ -275,10 +275,10 @@ int DesktopBackgroundController::GetBackgroundContainerId(bool locked) {
: kShellWindowId_DesktopBackgroundContainer; : kShellWindowId_DesktopBackgroundContainer;
} }
void DesktopBackgroundController::UpdateWallpaper() { void DesktopBackgroundController::UpdateWallpaper(bool clear_cache) {
current_wallpaper_.reset(NULL); current_wallpaper_.reset(NULL);
ash::Shell::GetInstance()->user_wallpaper_delegate()-> ash::Shell::GetInstance()->user_wallpaper_delegate()->UpdateWallpaper(
UpdateWallpaper(true /* clear cache */); clear_cache);
} }
} // namespace ash } // namespace ash
...@@ -133,8 +133,9 @@ class ASH_EXPORT DesktopBackgroundController ...@@ -133,8 +133,9 @@ class ASH_EXPORT DesktopBackgroundController
// Send notification that background animation finished. // Send notification that background animation finished.
void NotifyAnimationFinished(); void NotifyAnimationFinished();
// Reload the wallpaper. // Reload the wallpaper. |clear_cache| specifies whether to clear the
void UpdateWallpaper(); // wallpaper cahce or not.
void UpdateWallpaper(bool clear_cache);
void set_wallpaper_reload_delay_for_test(bool value) { void set_wallpaper_reload_delay_for_test(bool value) {
wallpaper_reload_delay_ = value; wallpaper_reload_delay_ = value;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment