diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-03 01:15:10 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-03 01:15:10 +0000 |
commit | 697f04c0a9168dfb3b85f8764ad9e4fb32e369e3 (patch) | |
tree | 2a06773998e72c5ea2d06869aab03567f9463bf5 /ash | |
parent | abd82e6cf2b284bc839acf9984d90111787a9065 (diff) | |
download | chromium_src-697f04c0a9168dfb3b85f8764ad9e4fb32e369e3.zip chromium_src-697f04c0a9168dfb3b85f8764ad9e4fb32e369e3.tar.gz chromium_src-697f04c0a9168dfb3b85f8764ad9e4fb32e369e3.tar.bz2 |
ash: Display system background while loading wallpaper.
When the wallpaper takes a long time to load, areas of the
screen that aren't covered by other layers are painted
white. This looks okay when we first boot, but not when
we're displaying the login after logging out or while we're
starting a guest session.
This makes us instead initialize SystemBackgroundController
immediately with either a #fefefe or black color depending
on whether this is the first Chrome run after boot or not.
Its color is updated to black after the login wallpaper
animation is finished.
BUG=151111,152751
Review URL: https://chromiumcodereview.appspot.com/11054005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159822 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/desktop_background/desktop_background_controller.cc | 2 | ||||
-rw-r--r-- | ash/desktop_background/desktop_background_view.cc | 2 | ||||
-rw-r--r-- | ash/root_window_controller.cc | 22 | ||||
-rw-r--r-- | ash/root_window_controller.h | 16 | ||||
-rw-r--r-- | ash/shell.cc | 2 | ||||
-rw-r--r-- | ash/shell/shell_delegate_impl.cc | 4 | ||||
-rw-r--r-- | ash/shell/shell_delegate_impl.h | 1 | ||||
-rw-r--r-- | ash/shell_delegate.h | 5 | ||||
-rw-r--r-- | ash/shell_window_ids.h | 7 | ||||
-rw-r--r-- | ash/test/test_shell_delegate.cc | 4 | ||||
-rw-r--r-- | ash/test/test_shell_delegate.h | 1 | ||||
-rw-r--r-- | ash/wm/workspace/system_background_controller.cc | 13 | ||||
-rw-r--r-- | ash/wm/workspace/system_background_controller.h | 7 | ||||
-rw-r--r-- | ash/wm/workspace/workspace_manager2.cc | 20 | ||||
-rw-r--r-- | ash/wm/workspace/workspace_manager2.h | 12 |
15 files changed, 79 insertions, 39 deletions
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc index 6f4d11b..4d084df 100644 --- a/ash/desktop_background/desktop_background_controller.cc +++ b/ash/desktop_background/desktop_background_controller.cc @@ -6,6 +6,7 @@ #include "ash/desktop_background/desktop_background_view.h" #include "ash/desktop_background/desktop_background_widget_controller.h" +#include "ash/root_window_controller.h" #include "ash/shell.h" #include "ash/shell_factory.h" #include "ash/shell_window_ids.h" @@ -277,6 +278,7 @@ void DesktopBackgroundController::OnWallpaperLoadCompleted( void DesktopBackgroundController::NotifyAnimationFinished() { Shell* shell = Shell::GetInstance(); + shell->GetPrimaryRootWindowController()->HandleDesktopBackgroundVisible(); shell->user_wallpaper_delegate()->OnWallpaperAnimationFinished(); } diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc index 74dbb72..a787882 100644 --- a/ash/desktop_background/desktop_background_view.cc +++ b/ash/desktop_background/desktop_background_view.cc @@ -9,6 +9,7 @@ #include "ash/ash_export.h" #include "ash/desktop_background/desktop_background_controller.h" #include "ash/desktop_background/desktop_background_widget_controller.h" +#include "ash/root_window_controller.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/window_animations.h" @@ -47,6 +48,7 @@ class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver, // Overridden from ui::ImplicitAnimationObserver: virtual void OnImplicitAnimationsCompleted() OVERRIDE { ash::Shell* shell = ash::Shell::GetInstance(); + shell->GetPrimaryRootWindowController()->HandleDesktopBackgroundVisible(); shell->user_wallpaper_delegate()->OnWallpaperAnimationFinished(); // Only removes old component when wallpaper animation finished. If we // remove the old one too early, there will be a white flash during diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc index ee56378bf..532d60a 100644 --- a/ash/root_window_controller.cc +++ b/ash/root_window_controller.cc @@ -21,6 +21,7 @@ #include "ash/wm/toplevel_window_event_handler.h" #include "ash/wm/visibility_controller.h" #include "ash/wm/window_properties.h" +#include "ash/wm/workspace/system_background_controller.h" #include "ash/wm/workspace_controller.h" #include "ui/aura/client/activation_client.h" #include "ui/aura/client/aura_constants.h" @@ -37,6 +38,12 @@ namespace ash { namespace { +#if defined(OS_CHROMEOS) +// Color initially used for the system background after the system has first +// booted. +const SkColor kBootSystemBackgroundColor = 0xFFFEFEFE; +#endif + // Creates a new window for use as a container. aura::Window* CreateContainer(int window_id, const char* name, @@ -189,6 +196,21 @@ void RootWindowController::CreateContainers() { CreateContainersInRootWindow(root_window_.get()); } +void RootWindowController::CreateSystemBackground( + bool is_first_run_after_boot) { + SkColor color = SK_ColorBLACK; +#if defined(OS_CHROMEOS) + if (is_first_run_after_boot) + color = kBootSystemBackgroundColor; +#endif + background_.reset(new SystemBackgroundController(root_window_.get(), color)); +} + +void RootWindowController::HandleDesktopBackgroundVisible() { + if (background_.get()) + background_->SetColor(SK_ColorBLACK); +} + void RootWindowController::CloseChildWindows() { // Close background widget first as it depends on tooltip. root_window_->SetProperty(kWindowDesktopComponent, diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h index 27f396d..29f9c04 100644 --- a/ash/root_window_controller.h +++ b/ash/root_window_controller.h @@ -27,6 +27,7 @@ namespace internal { class EventClientImpl; class RootWindowLayoutManager; class ScreenDimmer; +class SystemBackgroundController; class WorkspaceController; // This class maintains the per root window state for ash. This class @@ -57,8 +58,15 @@ class RootWindowController { aura::Window* GetContainer(int container_id); - void CreateContainers(); void InitLayoutManagers(); + void CreateContainers(); + + // Initializes |background_|. |is_first_run_after_boot| determines the + // background's initial color. + void CreateSystemBackground(bool is_first_run_after_boot); + + // Updates |background_| to be black after the desktop background is visible. + void HandleDesktopBackgroundVisible(); // Deletes associated objects and clears the state, but doesn't delete // the root window yet. This is used to delete a secondary displays' @@ -83,6 +91,12 @@ class RootWindowController { scoped_ptr<aura::RootWindow> root_window_; internal::RootWindowLayoutManager* root_window_layout_; + // A background layer that's displayed beneath all other layers. Without + // this, portions of the root window that aren't covered by layers will be + // painted white; this can show up if e.g. it takes a long time to decode the + // desktop background image when displaying the login screen. + scoped_ptr<SystemBackgroundController> background_; + // An event filter that pre-handles all key events to send them to an IME. scoped_ptr<internal::EventClientImpl> event_client_; scoped_ptr<internal::ScreenDimmer> screen_dimmer_; diff --git a/ash/shell.cc b/ash/shell.cc index bca3358..560e5e8 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -411,6 +411,8 @@ void Shell::Init() { internal::RootWindowController* root_window_controller = new internal::RootWindowController(root_window); root_window_controller->CreateContainers(); + root_window_controller->CreateSystemBackground( + delegate_.get() ? delegate_->IsFirstRunAfterBoot() : false); CommandLine* command_line = CommandLine::ForCurrentProcess(); diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc index 948528e..ca2696d 100644 --- a/ash/shell/shell_delegate_impl.cc +++ b/ash/shell/shell_delegate_impl.cc @@ -39,6 +39,10 @@ bool ShellDelegateImpl::IsSessionStarted() { return true; } +bool ShellDelegateImpl::IsFirstRunAfterBoot() { + return false; +} + void ShellDelegateImpl::LockScreen() { ash::shell::CreateLockScreen(); locked_ = true; diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h index 82e5347..a8a8944 100644 --- a/ash/shell/shell_delegate_impl.h +++ b/ash/shell/shell_delegate_impl.h @@ -23,6 +23,7 @@ class ShellDelegateImpl : public ash::ShellDelegate { virtual bool IsUserLoggedIn() OVERRIDE; virtual bool IsSessionStarted() OVERRIDE; + virtual bool IsFirstRunAfterBoot() OVERRIDE; virtual void LockScreen() OVERRIDE; virtual void UnlockScreen() OVERRIDE; virtual bool IsScreenLocked() const OVERRIDE; diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h index c095013..92ec386 100644 --- a/ash/shell_delegate.h +++ b/ash/shell_delegate.h @@ -64,6 +64,11 @@ class ASH_EXPORT ShellDelegate { // Returns true if we're logged in and browser has been started virtual bool IsSessionStarted() = 0; + // Returns true if this is the first time that the shell has been run after + // the system has booted. false is returned after the shell has been + // restarted, typically due to logging in as a guest or logging out. + virtual bool IsFirstRunAfterBoot() = 0; + // Invoked when a user locks the screen. virtual void LockScreen() = 0; diff --git a/ash/shell_window_ids.h b/ash/shell_window_ids.h index 347f3d8..f4aca62 100644 --- a/ash/shell_window_ids.h +++ b/ash/shell_window_ids.h @@ -34,9 +34,10 @@ const int kShellWindowId_LockScreenRelatedContainersContainer = 2; const int kShellWindowId_UnparentedControlContainer = 3; // System level background. Sits beneach the desktop background and is only -// visible when in a workspace other than the desktop. When switching from the -// desktop workspace to to another workspace the desktop background scales -// slightly. This exposes the system level background beneath it. +// visible when the desktop background has not yet been loaded or a workspace +// other than the desktop is being displayed. When switching from the desktop +// workspace to to another workspace the desktop background scales slightly. +// This exposes the system level background beneath it. const int kShellWindowId_SystemBackgroundContainer = 4; // The desktop background window. diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc index e690c16..0526b85 100644 --- a/ash/test/test_shell_delegate.cc +++ b/ash/test/test_shell_delegate.cc @@ -32,6 +32,10 @@ bool TestShellDelegate::IsSessionStarted() { return true; } +bool TestShellDelegate::IsFirstRunAfterBoot() { + return false; +} + void TestShellDelegate::LockScreen() { locked_ = true; } diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h index bd41219..f815d18 100644 --- a/ash/test/test_shell_delegate.h +++ b/ash/test/test_shell_delegate.h @@ -20,6 +20,7 @@ class TestShellDelegate : public ShellDelegate { // Overridden from ShellDelegate: virtual bool IsUserLoggedIn() OVERRIDE; virtual bool IsSessionStarted() OVERRIDE; + virtual bool IsFirstRunAfterBoot() OVERRIDE; virtual void LockScreen() OVERRIDE; virtual void UnlockScreen() OVERRIDE; virtual bool IsScreenLocked() const OVERRIDE; diff --git a/ash/wm/workspace/system_background_controller.cc b/ash/wm/workspace/system_background_controller.cc index 728e3e1..363a305 100644 --- a/ash/wm/workspace/system_background_controller.cc +++ b/ash/wm/workspace/system_background_controller.cc @@ -5,6 +5,7 @@ #include "ash/wm/workspace/system_background_controller.h" #include "ash/shell_window_ids.h" +#include "ui/aura/client/aura_constants.h" #include "ui/aura/root_window.h" #include "ui/gfx/canvas.h" #include "ui/views/widget/widget.h" @@ -49,7 +50,8 @@ views::View* SystemBackgroundController::View::GetContentsView() { return this; } -SystemBackgroundController::SystemBackgroundController(aura::RootWindow* root) +SystemBackgroundController::SystemBackgroundController(aura::RootWindow* root, + SkColor color) : ALLOW_THIS_IN_INITIALIZER_LIST(view_(new View(this))) { views::Widget* widget = new views::Widget; views::Widget::InitParams params( @@ -62,7 +64,9 @@ SystemBackgroundController::SystemBackgroundController(aura::RootWindow* root) // flicker. params.layer_type = ui::LAYER_SOLID_COLOR; widget->Init(params); - widget->GetNativeView()->layer()->SetColor(SK_ColorBLACK); + widget->GetNativeView()->SetProperty(aura::client::kAnimationsDisabledKey, + true); + widget->GetNativeView()->layer()->SetColor(color); widget->SetBounds(params.parent->bounds()); widget->Show(); widget->GetNativeView()->SetName("SystemBackground"); @@ -73,5 +77,10 @@ SystemBackgroundController::~SystemBackgroundController() { view_->Close(); } +void SystemBackgroundController::SetColor(SkColor color) { + if (view_) + view_->GetWidget()->GetNativeView()->layer()->SetColor(color); +} + } // namespace internal } // namespace ash diff --git a/ash/wm/workspace/system_background_controller.h b/ash/wm/workspace/system_background_controller.h index ca78ab8..4b84fc0 100644 --- a/ash/wm/workspace/system_background_controller.h +++ b/ash/wm/workspace/system_background_controller.h @@ -8,6 +8,8 @@ #include "ash/ash_export.h" #include "base/basictypes.h" +typedef unsigned int SkColor; + namespace aura { class RootWindow; }; @@ -20,9 +22,12 @@ namespace internal { // level background. class ASH_EXPORT SystemBackgroundController { public: - explicit SystemBackgroundController(aura::RootWindow* root); + SystemBackgroundController(aura::RootWindow* root, SkColor color); ~SystemBackgroundController(); + // Changes the background color. + void SetColor(SkColor color); + private: class View; diff --git a/ash/wm/workspace/workspace_manager2.cc b/ash/wm/workspace/workspace_manager2.cc index 075815d..805dd18 100644 --- a/ash/wm/workspace/workspace_manager2.cc +++ b/ash/wm/workspace/workspace_manager2.cc @@ -16,7 +16,6 @@ #include "ash/wm/window_animations.h" #include "ash/wm/window_properties.h" #include "ash/wm/window_util.h" -#include "ash/wm/workspace/system_background_controller.h" #include "ash/wm/workspace/workspace_layout_manager2.h" #include "ash/wm/workspace/workspace2.h" #include "base/auto_reset.h" @@ -331,21 +330,6 @@ void WorkspaceManager2::SetActiveWorkspace(Workspace2* workspace, contents_view_->StackChildAtTop(last_active->window()); } - destroy_background_timer_.Stop(); - if (active_workspace_ == desktop_workspace()) { - base::TimeDelta delay(GetSystemBackgroundDestroyDuration()); - if (ui::LayerAnimator::slow_animation_mode()) - delay *= ui::LayerAnimator::slow_animation_scale_factor(); - // Delay an extra 100ms to make sure everything settles down before - // destroying the background. - delay += base::TimeDelta::FromMilliseconds(100); - destroy_background_timer_.Start( - FROM_HERE, delay, this, &WorkspaceManager2::DestroySystemBackground); - } else if (!background_controller_.get()) { - background_controller_.reset(new SystemBackgroundController( - contents_view_->GetRootWindow())); - } - UpdateShelfVisibility(); if (animate_type != ANIMATE_NONE) { @@ -456,10 +440,6 @@ void WorkspaceManager2::ScheduleDelete(Workspace2* workspace) { &WorkspaceManager2::ProcessDeletion); } -void WorkspaceManager2::DestroySystemBackground() { - background_controller_.reset(); -} - void WorkspaceManager2::SetUnminimizingWorkspace(Workspace2* workspace) { // The normal sequence of unminimizing a window is: Show() the window, which // triggers changing the kShowStateKey to NORMAL and lastly the window is made diff --git a/ash/wm/workspace/workspace_manager2.h b/ash/wm/workspace/workspace_manager2.h index 8a9b9db..1cd1b0c 100644 --- a/ash/wm/workspace/workspace_manager2.h +++ b/ash/wm/workspace/workspace_manager2.h @@ -36,7 +36,6 @@ namespace ash { namespace internal { class ShelfLayoutManager; -class SystemBackgroundController; class WorkspaceLayoutManager2; class WorkspaceManagerTest2; class Workspace2; @@ -139,9 +138,6 @@ class ASH_EXPORT WorkspaceManager2 // any layers. void ProcessDeletion(); - // Deletes |background_controller_|. Called from |destroy_background_timer_|. - void DestroySystemBackground(); - // Sets |unminimizing_workspace_| to |workspace|. void SetUnminimizingWorkspace(Workspace2* workspace); @@ -198,14 +194,6 @@ class ASH_EXPORT WorkspaceManager2 // See comments in SetUnminimizingWorkspace() for details. base::WeakPtrFactory<WorkspaceManager2> clear_unminimizing_workspace_factory_; - // Used to show the system level background. Non-null when the background is - // visible. - scoped_ptr<SystemBackgroundController> background_controller_; - - // Timer used to destroy the background. We wait to destroy until animations - // complete. - base::OneShotTimer<WorkspaceManager2> destroy_background_timer_; - // See comments in SetUnminimizingWorkspace() for details. Workspace2* unminimizing_workspace_; |