summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-10 06:25:49 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-10 06:25:49 +0000
commitbca9a7ee39bf817edd4976ef2bf314d26feea11f (patch)
treea6b260a3c1d420878528469d49f4a9764bcee6bc /ash
parent9badbe63637a07eb23112f30fda959f849fe923f (diff)
downloadchromium_src-bca9a7ee39bf817edd4976ef2bf314d26feea11f.zip
chromium_src-bca9a7ee39bf817edd4976ef2bf314d26feea11f.tar.gz
chromium_src-bca9a7ee39bf817edd4976ef2bf314d26feea11f.tar.bz2
ash: Add flag to animate transition from boot splash screen.
This adds an --ash-animate-from-boot-splash-screen flag that can be set to tell Ash to grab the Chrome OS boot splash screen and fade from it into the login screen's brightness/grayscale desktop background animation. I'm also making SystemBackgroundController just control a solid-color layer and moving its host-window-grabbing code into a new BootSplashScreen class. BUG=152309 TEST=add --ash-animate-from-boot-splash-screen to /sbin/session_manager_setup.sh, reboot, and see the animation Review URL: https://chromiumcodereview.appspot.com/11362067 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167068 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/ash_switches.cc8
-rw-r--r--ash/ash_switches.h1
-rw-r--r--ash/desktop_background/desktop_background_controller.h8
-rw-r--r--ash/desktop_background/desktop_background_view.cc42
-rw-r--r--ash/root_window_controller.cc54
-rw-r--r--ash/root_window_controller.h14
-rw-r--r--ash/shell.cc8
-rw-r--r--ash/wm/boot_splash_screen.cc72
-rw-r--r--ash/wm/boot_splash_screen.h53
-rw-r--r--ash/wm/system_background_controller.cc104
-rw-r--r--ash/wm/system_background_controller.h46
12 files changed, 247 insertions, 165 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index f190980..a766593 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -266,6 +266,8 @@
'wm/always_on_top_controller.h',
'wm/base_layout_manager.cc',
'wm/base_layout_manager.h',
+ 'wm/boot_splash_screen.cc',
+ 'wm/boot_splash_screen.h',
'wm/capture_controller.cc',
'wm/capture_controller.h',
'wm/coordinate_conversion.cc',
diff --git a/ash/ash_switches.cc b/ash/ash_switches.cc
index 368eb9f..9f500b2 100644
--- a/ash/ash_switches.cc
+++ b/ash/ash_switches.cc
@@ -7,6 +7,14 @@
namespace ash {
namespace switches {
+// Enables an animated transition from the boot splash screen (Chrome logo on a
+// white background) to the login screen. Implies
+// |kAshCopyHostBackgroundAtBoot| and doesn't make much sense if used in
+// conjunction with |kDisableBootAnimation| (since the transition begins at the
+// same time as the white/grayscale login screen animation).
+const char kAshAnimateFromBootSplashScreen[] =
+ "ash-animate-from-boot-splash-screen";
+
// Variation of boot animation that uses Tween::EASE_OUT_2.
const char kAshBootAnimationFunction2[] = "ash-boot-animation-function2";
diff --git a/ash/ash_switches.h b/ash/ash_switches.h
index a30d9fb..2355015 100644
--- a/ash/ash_switches.h
+++ b/ash/ash_switches.h
@@ -17,6 +17,7 @@ namespace switches {
// see chromeos::LoginUtil::GetOffTheRecordCommandLine().)
// Please keep alphabetized.
+ASH_EXPORT extern const char kAshAnimateFromBootSplashScreen[];
ASH_EXPORT extern const char kAshBootAnimationFunction2[];
ASH_EXPORT extern const char kAshBootAnimationFunction3[];
ASH_EXPORT extern const char kAshConstrainPointerToRoot[];
diff --git a/ash/desktop_background/desktop_background_controller.h b/ash/desktop_background/desktop_background_controller.h
index 605dffd..39cbbc5 100644
--- a/ash/desktop_background/desktop_background_controller.h
+++ b/ash/desktop_background/desktop_background_controller.h
@@ -40,9 +40,15 @@ class UserWallpaperDelegate {
public:
virtual ~UserWallpaperDelegate() {}
- // Returns type of window animation that should be used when showin wallpaper.
+ // Returns the type of window animation that should be used when showing the
+ // wallpaper.
virtual ash::WindowVisibilityAnimationType GetAnimationType() = 0;
+ // Should the slower initial animation be shown (as opposed to the faster
+ // animation that's used e.g. when switching from one user's wallpaper to
+ // another's on the login screen)?
+ virtual bool ShouldShowInitialAnimation() = 0;
+
// Updates current wallpaper. It may switch the size of wallpaper based on the
// current display's resolution.
virtual void UpdateWallpaper() = 0;
diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc
index 3b15075..de371d5 100644
--- a/ash/desktop_background/desktop_background_view.cc
+++ b/ash/desktop_background/desktop_background_view.cc
@@ -12,6 +12,7 @@
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
+#include "ash/wm/property_util.h"
#include "ash/wm/window_animations.h"
#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
@@ -33,9 +34,11 @@ class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver,
public views::WidgetObserver {
public:
ShowWallpaperAnimationObserver(aura::RootWindow* root_window,
- views::Widget* desktop_widget)
+ views::Widget* desktop_widget,
+ bool is_initial_animation)
: root_window_(root_window),
- desktop_widget_(desktop_widget) {
+ desktop_widget_(desktop_widget),
+ is_initial_animation_(is_initial_animation) {
DCHECK(desktop_widget_);
desktop_widget_->AddObserver(this);
}
@@ -48,12 +51,18 @@ class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver,
private:
// Overridden from ui::ImplicitAnimationObserver:
+ virtual void OnImplicitAnimationsScheduled() OVERRIDE {
+ if (is_initial_animation_) {
+ GetRootWindowController(root_window_)->
+ HandleInitialDesktopBackgroundAnimationStarted();
+ }
+ }
+
virtual void OnImplicitAnimationsCompleted() OVERRIDE {
DCHECK(desktop_widget_);
- ash::Shell* shell = ash::Shell::GetInstance();
- // TODO(oshima): fix this for extended desktop.
- shell->GetPrimaryRootWindowController()->HandleDesktopBackgroundVisible();
- shell->user_wallpaper_delegate()->OnWallpaperAnimationFinished();
+ GetRootWindowController(root_window_)->HandleDesktopBackgroundVisible();
+ ash::Shell::GetInstance()->user_wallpaper_delegate()->
+ OnWallpaperAnimationFinished();
// Only removes old component when wallpaper animation finished. If we
// remove the old one before the new wallpaper is done fading in there will
// be a white flash during the animation.
@@ -80,16 +89,19 @@ class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver,
aura::RootWindow* root_window_;
views::Widget* desktop_widget_;
+ // Is this object observing the initial brightness/grayscale animation?
+ const bool is_initial_animation_;
+
DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver);
};
-} // namespace
-
// For our scaling ratios we need to round positive numbers.
-static int RoundPositive(double x) {
+int RoundPositive(double x) {
return static_cast<int>(floor(x + 0.5));
}
+} // namespace
+
////////////////////////////////////////////////////////////////////////////////
// DesktopBackgroundView, public:
@@ -167,6 +179,9 @@ views::Widget* CreateDesktopBackground(aura::RootWindow* root_window,
int container_id) {
DesktopBackgroundController* controller =
ash::Shell::GetInstance()->desktop_background_controller();
+ ash::UserWallpaperDelegate* wallpaper_delegate =
+ ash::Shell::GetInstance()->user_wallpaper_delegate();
+
views::Widget* desktop_widget = new views::Widget;
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
@@ -176,14 +191,14 @@ views::Widget* CreateDesktopBackground(aura::RootWindow* root_window,
desktop_widget->Init(params);
desktop_widget->SetContentsView(new DesktopBackgroundView());
ash::WindowVisibilityAnimationType animation_type =
- ash::Shell::GetInstance()->user_wallpaper_delegate()->GetAnimationType();
+ wallpaper_delegate->GetAnimationType();
ash::SetWindowVisibilityAnimationType(desktop_widget->GetNativeView(),
animation_type);
// Disable animation when creating the first widget. Otherwise, wallpaper
// will animate from a white screen. Note that boot animation is different.
// It animates from a white background.
if (animation_type == ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE &&
- NULL == root_window->GetProperty(kAnimatingDesktopController)) {
+ root_window->GetProperty(kAnimatingDesktopController) == NULL) {
ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(),
ash::ANIMATE_NONE);
} else {
@@ -194,8 +209,9 @@ views::Widget* CreateDesktopBackground(aura::RootWindow* root_window,
ui::ScopedLayerAnimationSettings settings(
desktop_widget->GetNativeView()->layer()->GetAnimator());
settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
- settings.AddObserver(new ShowWallpaperAnimationObserver(root_window,
- desktop_widget));
+ settings.AddObserver(new ShowWallpaperAnimationObserver(
+ root_window, desktop_widget,
+ wallpaper_delegate->ShouldShowInitialAnimation()));
desktop_widget->Show();
desktop_widget->GetNativeView()->SetName("DesktopBackgroundView");
return desktop_widget;
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index fae9a4b..81b619a 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -18,6 +18,7 @@
#include "ash/system/status_area_widget.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/wm/base_layout_manager.h"
+#include "ash/wm/boot_splash_screen.h"
#include "ash/wm/panel_layout_manager.h"
#include "ash/wm/panel_window_event_filter.h"
#include "ash/wm/property_util.h"
@@ -33,6 +34,7 @@
#include "ash/wm/window_properties.h"
#include "ash/wm/workspace_controller.h"
#include "base/command_line.h"
+#include "base/time.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/capture_client.h"
@@ -53,6 +55,17 @@
namespace ash {
namespace {
+#if defined(OS_CHROMEOS)
+// Background color used for the Chrome OS boot splash screen.
+const SkColor kChromeOsBootColor = SkColorSetARGB(0xff, 0xfe, 0xfe, 0xfe);
+#endif
+
+// Duration for the animation that hides the boot splash screen, in
+// milliseconds. This should be short enough in relation to
+// wm/window_animation.cc's brightness/grayscale fade animation that the login
+// background image animation isn't hidden by the splash screen animation.
+const int kBootSplashScreenHideDurationMs = 500;
+
// Creates a new window for use as a container.
aura::Window* CreateContainer(int window_id,
const char* name,
@@ -293,21 +306,24 @@ void RootWindowController::CreateContainers() {
void RootWindowController::CreateSystemBackground(
bool is_first_run_after_boot) {
- SystemBackgroundController::Content initial_content =
- SystemBackgroundController::CONTENT_BLACK;
+ SkColor color = SK_ColorBLACK;
#if defined(OS_CHROMEOS)
- if (is_first_run_after_boot) {
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAshCopyHostBackgroundAtBoot)) {
- initial_content = SystemBackgroundController::CONTENT_COPY_FROM_HOST;
- } else {
- initial_content =
- SystemBackgroundController::CONTENT_CHROME_OS_BOOT_COLOR;
- }
- }
+ if (is_first_run_after_boot)
+ color = kChromeOsBootColor;
#endif
system_background_.reset(
- new SystemBackgroundController(root_window_.get(), initial_content));
+ new SystemBackgroundController(root_window_.get(), color));
+
+#if defined(OS_CHROMEOS)
+ // Make a copy of the system's boot splash screen so we can composite it
+ // onscreen until the desktop background is ready.
+ if (is_first_run_after_boot &&
+ (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAshCopyHostBackgroundAtBoot) ||
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAshAnimateFromBootSplashScreen)))
+ boot_splash_screen_.reset(new BootSplashScreen(root_window_.get()));
+#endif
}
void RootWindowController::CreateLauncher() {
@@ -350,8 +366,20 @@ void RootWindowController::UpdateAfterLoginStatusChange(
status_area_widget_->UpdateAfterLoginStatusChange(status);
}
+void RootWindowController::HandleInitialDesktopBackgroundAnimationStarted() {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAshAnimateFromBootSplashScreen) &&
+ boot_splash_screen_.get()) {
+ // Make the splash screen fade out so it doesn't obscure the desktop
+ // wallpaper's brightness/grayscale animation.
+ boot_splash_screen_->StartHideAnimation(
+ base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs));
+ }
+}
+
void RootWindowController::HandleDesktopBackgroundVisible() {
- system_background_->SetContent(SystemBackgroundController::CONTENT_BLACK);
+ system_background_->SetColor(SK_ColorBLACK);
+ boot_splash_screen_.reset();
}
void RootWindowController::CloseChildWindows() {
diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h
index 50f4351..4d9cc8d 100644
--- a/ash/root_window_controller.h
+++ b/ash/root_window_controller.h
@@ -33,6 +33,7 @@ class ToplevelWindowEventHandler;
namespace internal {
+class BootSplashScreen;
class PanelLayoutManager;
class RootWindowLayoutManager;
class ScreenDimmer;
@@ -99,8 +100,8 @@ class ASH_EXPORT RootWindowController {
// creates
void InitForPrimaryDisplay();
- // Initializes |system_background_|. |is_first_run_after_boot| determines the
- // background's initial content.
+ // Initializes |system_background_| and possibly also |boot_splash_screen_|.
+ // |is_first_run_after_boot| determines the background's initial color.
void CreateSystemBackground(bool is_first_run_after_boot);
// Initializes |launcher_|. Does nothing if it's already initialized.
@@ -116,7 +117,13 @@ class ASH_EXPORT RootWindowController {
// TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
void UpdateAfterLoginStatusChange(user::LoginStatus status);
- // Updates |background_| to be black after the desktop background is visible.
+ // Called when the brightness/grayscale animation from white to the login
+ // desktop background image has started. Starts |boot_splash_screen_|'s
+ // hiding animation (if the screen is non-NULL).
+ void HandleInitialDesktopBackgroundAnimationStarted();
+
+ // Called when the login background is fully visible. Updates |background_|
+ // to be black and drops |boot_splash_screen_|.
void HandleDesktopBackgroundVisible();
// Deletes associated objects and clears the state, but doesn't delete
@@ -168,6 +175,7 @@ class ASH_EXPORT RootWindowController {
scoped_ptr<Launcher> launcher_;
scoped_ptr<SystemBackgroundController> system_background_;
+ scoped_ptr<BootSplashScreen> boot_splash_screen_;
scoped_ptr<ScreenDimmer> screen_dimmer_;
scoped_ptr<WorkspaceController> workspace_controller_;
diff --git a/ash/shell.cc b/ash/shell.cc
index 97f3c8f..feb1c99 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -120,6 +120,10 @@ class DummyUserWallpaperDelegate : public UserWallpaperDelegate {
return WINDOW_VISIBILITY_ANIMATION_TYPE_FADE;
}
+ virtual bool ShouldShowInitialAnimation() OVERRIDE {
+ return false;
+ }
+
virtual void UpdateWallpaper() OVERRIDE {
}
@@ -747,6 +751,10 @@ void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) {
internal::RootWindowController* controller =
new internal::RootWindowController(root);
controller->CreateContainers();
+ // Pass false for the |is_first_run_after_boot| parameter so we'll show a
+ // black background on this display instead of trying to mimic the boot splash
+ // screen.
+ controller->CreateSystemBackground(false);
InitRootWindowController(controller);
if (IsLauncherPerDisplayEnabled())
controller->InitForPrimaryDisplay();
diff --git a/ash/wm/boot_splash_screen.cc b/ash/wm/boot_splash_screen.cc
new file mode 100644
index 0000000..2aa1f7c
--- /dev/null
+++ b/ash/wm/boot_splash_screen.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/wm/boot_splash_screen.h"
+
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/aura/root_window.h"
+#include "ui/compositor/layer.h"
+#include "ui/compositor/layer_type.h"
+#include "ui/compositor/scoped_layer_animation_settings.h"
+#include "ui/gfx/canvas.h"
+
+namespace ash {
+namespace internal {
+
+// ui::LayerDelegate that copies the aura host window's content to a ui::Layer.
+class BootSplashScreen::CopyHostContentLayerDelegate
+ : public ui::LayerDelegate {
+ public:
+ explicit CopyHostContentLayerDelegate(aura::RootWindow* root_window)
+ : root_window_(root_window) {
+ }
+
+ virtual ~CopyHostContentLayerDelegate() {}
+
+ // ui::LayerDelegate overrides:
+ virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE {
+ // It'd be safer to copy the area to a canvas in the constructor and then
+ // copy from that canvas to this one here, but this appears to work (i.e. we
+ // only call this before we draw our first frame) and it saves us an extra
+ // copy.
+ root_window_->CopyAreaToSkCanvas(
+ gfx::Rect(root_window_->GetHostOrigin(), root_window_->GetHostSize()),
+ gfx::Point(), canvas->sk_canvas());
+ }
+
+ virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE {}
+
+ virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE {
+ return base::Closure();
+ }
+
+ private:
+ aura::RootWindow* root_window_; // not owned
+
+ DISALLOW_COPY_AND_ASSIGN(CopyHostContentLayerDelegate);
+};
+
+BootSplashScreen::BootSplashScreen(aura::RootWindow* root_window)
+ : layer_delegate_(new CopyHostContentLayerDelegate(root_window)),
+ layer_(new ui::Layer(ui::LAYER_TEXTURED)) {
+ layer_->set_delegate(layer_delegate_.get());
+
+ ui::Layer* root_layer = root_window->layer();
+ layer_->SetBounds(gfx::Rect(root_layer->bounds().size()));
+ root_layer->Add(layer_.get());
+ root_layer->StackAtTop(layer_.get());
+}
+
+BootSplashScreen::~BootSplashScreen() {
+}
+
+void BootSplashScreen::StartHideAnimation(base::TimeDelta duration) {
+ ui::ScopedLayerAnimationSettings settings(layer_->GetAnimator());
+ settings.SetTransitionDuration(duration);
+ settings.SetPreemptionStrategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
+ layer_->SetOpacity(0.0f);
+}
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/wm/boot_splash_screen.h b/ash/wm/boot_splash_screen.h
new file mode 100644
index 0000000..dc4538b
--- /dev/null
+++ b/ash/wm/boot_splash_screen.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_WM_BOOT_SPLASH_SCREEN_H_
+#define ASH_WM_BOOT_SPLASH_SCREEN_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/time.h"
+
+namespace aura {
+class RootWindow;
+}
+
+namespace ui {
+class Layer;
+class LayerDelegate;
+}
+
+namespace ash {
+namespace internal {
+
+// BootSplashScreen manages a ui::Layer, stacked at the top of the root layer's
+// children, that displays a copy of the initial contents of the host window.
+// This allows us to continue displaying the Chrome OS boot splash screen (which
+// is displayed before Ash starts) after the compositor has taken over so we can
+// animate the transition between the splash screen and the login screen.
+class BootSplashScreen {
+ public:
+ explicit BootSplashScreen(aura::RootWindow* root_window);
+ ~BootSplashScreen();
+
+ // Begins animating |layer_|'s opacity to 0 over |duration|.
+ void StartHideAnimation(base::TimeDelta duration);
+
+ private:
+ class CopyHostContentLayerDelegate;
+
+ // Copies the host window's content to |layer_|.
+ scoped_ptr<CopyHostContentLayerDelegate> layer_delegate_;
+
+ scoped_ptr<ui::Layer> layer_;
+
+ DISALLOW_COPY_AND_ASSIGN(BootSplashScreen);
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_WM_BOOT_SPLASH_SCREEN_H_
diff --git a/ash/wm/system_background_controller.cc b/ash/wm/system_background_controller.cc
index f01642c..8f06f02 100644
--- a/ash/wm/system_background_controller.cc
+++ b/ash/wm/system_background_controller.cc
@@ -3,15 +3,10 @@
// found in the LICENSE file.
#include "ash/wm/system_background_controller.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "third_party/skia/include/core/SkColor.h"
+
#include "ui/aura/root_window.h"
-#include "ui/base/layout.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_type.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/image/image_skia.h"
-#include "ui/gfx/image/image_skia_rep.h"
namespace ash {
namespace internal {
@@ -25,108 +20,33 @@ const SkColor kChromeOsBootColor = SkColorSetARGB(0xff, 0xfe, 0xfe, 0xfe);
} // namespace
-// ui::LayerDelegate that copies the aura host window's content to a ui::Layer.
-class SystemBackgroundController::HostContentLayerDelegate
- : public ui::LayerDelegate {
- public:
- explicit HostContentLayerDelegate(aura::RootWindow* root_window)
- : root_window_(root_window) {
- }
-
- virtual ~HostContentLayerDelegate() {}
-
- // ui::LayerDelegate overrides:
- virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE {
- // It'd be safer to copy the area to a canvas in the constructor and then
- // copy from that canvas to this one here, but this appears to work (i.e. we
- // only call this before we draw our first frame) and it saves us an extra
- // copy.
- root_window_->CopyAreaToSkCanvas(
- gfx::Rect(root_window_->GetHostOrigin(), root_window_->GetHostSize()),
- gfx::Point(), canvas->sk_canvas());
- }
-
- virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE {}
-
- virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE {
- return base::Closure();
- }
-
- private:
- aura::RootWindow* root_window_; // not owned
-
- DISALLOW_COPY_AND_ASSIGN(HostContentLayerDelegate);
-};
-
SystemBackgroundController::SystemBackgroundController(
aura::RootWindow* root_window,
- Content initial_content)
+ SkColor color)
: root_window_(root_window),
- content_(CONTENT_INVALID) {
+ layer_(new ui::Layer(ui::LAYER_SOLID_COLOR)) {
root_window_->AddRootWindowObserver(this);
- SetContent(initial_content);
+ layer_->SetColor(color);
+
+ ui::Layer* root_layer = root_window_->layer();
+ layer_->SetBounds(gfx::Rect(root_layer->bounds().size()));
+ root_layer->Add(layer_.get());
+ root_layer->StackAtBottom(layer_.get());
}
SystemBackgroundController::~SystemBackgroundController() {
root_window_->RemoveRootWindowObserver(this);
}
-void SystemBackgroundController::SetContent(Content new_content) {
- if (new_content == content_)
- return;
-
- content_ = new_content;
- switch (new_content) {
- case CONTENT_COPY_FROM_HOST:
- CreateTexturedLayerWithHostContent();
- break;
- case CONTENT_BLACK:
- CreateColoredLayer(SK_ColorBLACK);
- break;
-#if defined(OS_CHROMEOS)
- case CONTENT_CHROME_OS_BOOT_COLOR:
- CreateColoredLayer(kChromeOsBootColor);
- break;
-#endif
- case CONTENT_INVALID:
- DCHECK(false) << "Invalid background layer content";
- }
+void SystemBackgroundController::SetColor(SkColor color) {
+ layer_->SetColor(color);
}
void SystemBackgroundController::OnRootWindowResized(
const aura::RootWindow* root,
const gfx::Size& old_size) {
DCHECK_EQ(root_window_, root);
- if (layer_.get())
- UpdateLayerBounds(layer_.get());
-}
-
-void SystemBackgroundController::CreateTexturedLayerWithHostContent() {
- layer_.reset();
- layer_delegate_.reset(new HostContentLayerDelegate(root_window_));
- layer_.reset(new ui::Layer(ui::LAYER_TEXTURED));
- layer_->set_delegate(layer_delegate_.get());
- UpdateLayerBounds(layer_.get());
- AddLayerToRootLayer(layer_.get());
-}
-
-void SystemBackgroundController::CreateColoredLayer(SkColor color) {
- layer_.reset();
- layer_delegate_.reset();
- layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
- layer_->SetColor(color);
- UpdateLayerBounds(layer_.get());
- AddLayerToRootLayer(layer_.get());
-}
-
-void SystemBackgroundController::UpdateLayerBounds(ui::Layer* layer) {
- layer->SetBounds(gfx::Rect(root_window_->layer()->bounds().size()));
-}
-
-void SystemBackgroundController::AddLayerToRootLayer(ui::Layer* layer) {
- ui::Layer* root_layer = root_window_->layer();
- root_layer->Add(layer);
- root_layer->StackAtBottom(layer);
+ layer_->SetBounds(gfx::Rect(root_window_->layer()->bounds().size()));
}
} // namespace internal
diff --git a/ash/wm/system_background_controller.h b/ash/wm/system_background_controller.h
index 8534b56..6da6563 100644
--- a/ash/wm/system_background_controller.h
+++ b/ash/wm/system_background_controller.h
@@ -30,32 +30,12 @@ namespace internal {
// desktop background image is loaded at startup, or when we scale down all of
// the other layers as part of a power-button or window-management animation).
// It should never be transformed or restacked.
-class ASH_EXPORT SystemBackgroundController : public aura::RootWindowObserver {
+class SystemBackgroundController : public aura::RootWindowObserver {
public:
- enum Content {
- CONTENT_INVALID,
-
- // Copy the contents of the host window. Useful when starting on X, where
- // the host window can inherit content from the X root window -- with this,
- // the compositor can continue drawing whatever was previously onscreen even
- // while we're e.g. waiting for images to be loaded from disk.
- CONTENT_COPY_FROM_HOST,
-
- // Display a black screen.
- CONTENT_BLACK,
-
-#if defined(OS_CHROMEOS)
- // Display a solid-color screen matching the background color used for the
- // Chrome OS boot splash screen.
- CONTENT_CHROME_OS_BOOT_COLOR,
-#endif
- };
-
- SystemBackgroundController(aura::RootWindow* root_window,
- Content initial_content);
+ SystemBackgroundController(aura::RootWindow* root_window, SkColor color);
virtual ~SystemBackgroundController();
- void SetContent(Content new_content);
+ void SetColor(SkColor color);
// aura::RootWindowObserver overrides:
virtual void OnRootWindowResized(const aura::RootWindow* root,
@@ -64,28 +44,8 @@ class ASH_EXPORT SystemBackgroundController : public aura::RootWindowObserver {
private:
class HostContentLayerDelegate;
- // Initializes |layer_| as a textured layer containing a copy of the host
- // window's content.
- void CreateTexturedLayerWithHostContent();
-
- // Initializes |layer_| as a solid-color layer containing |color|.
- void CreateColoredLayer(SkColor color);
-
- // Updates |layer|'s bounds to match those of |root_window_|'s layer.
- void UpdateLayerBounds(ui::Layer* layer);
-
- // Adds |layer| to |root_window_|'s layer and stacks it at the bottom of all
- // its children.
- void AddLayerToRootLayer(ui::Layer* layer);
-
aura::RootWindow* root_window_; // not owned
- // Type of content currently displayed in |layer_|.
- Content content_;
-
- // Paints |layer_| when |content_| is CONTENT_COPY_FROM_HOST.
- scoped_ptr<HostContentLayerDelegate> layer_delegate_;
-
scoped_ptr<ui::Layer> layer_;
DISALLOW_COPY_AND_ASSIGN(SystemBackgroundController);