Revert 151393 - Fix white flash when user signs out and fix wallpaper animation regression


When user signs out and transit to the login screen, the wallpaper fade in from a white screen. Described in 141563, this Cl fixed it.
Also, after user login, or switch users at login screen. when wallpaper change, the new wallpaper should fade in nicely. There is a regression in recent builds. This fix fixed the regression as well. 

BUG=141563, 141676, 142042

Review URL: https://chromiumcodereview.appspot.com/10827284

TBR=bshe@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10854136

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151398 0039d316-1c4b-4281-b951-d872f2087c98
parent b0d85bf7
......@@ -106,6 +106,7 @@ DesktopBackgroundController::DesktopBackgroundController()
desktop_background_mode_(BACKGROUND_SOLID_COLOR),
background_color_(kTransparentColor),
weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
InstallComponentForAllWindows();
}
DesktopBackgroundController::~DesktopBackgroundController() {
......@@ -212,9 +213,22 @@ void DesktopBackgroundController::CancelPendingWallpaperOperation() {
void DesktopBackgroundController::SetDesktopBackgroundSolidColorMode(
SkColor color) {
background_color_ = color;
desktop_background_mode_ = BACKGROUND_SOLID_COLOR;
if (desktop_background_mode_ != BACKGROUND_SOLID_COLOR) {
desktop_background_mode_ = BACKGROUND_SOLID_COLOR;
InstallComponentForAllWindows();
return;
}
InstallComponentForAllWindows();
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
for (Shell::RootWindowList::iterator iter = root_windows.begin();
iter != root_windows.end(); ++iter) {
aura::RootWindow* root_window = *iter;
internal::DesktopBackgroundWidgetController* component = root_window->
GetProperty(internal::kWindowDesktopComponent);
DCHECK(component);
DCHECK(component->layer());
component->layer()->SetColor(background_color_ );
}
}
void DesktopBackgroundController::CreateEmptyWallpaper() {
......@@ -241,13 +255,28 @@ void DesktopBackgroundController::MoveDesktopToUnlockedContainer() {
void DesktopBackgroundController::OnWindowDestroying(aura::Window* window) {
window->SetProperty(internal::kWindowDesktopComponent,
static_cast<internal::DesktopBackgroundWidgetController*>(NULL));
window->SetProperty(internal::kComponentWrapper,
static_cast<internal::ComponentWrapper*>(NULL));
}
void DesktopBackgroundController::SetDesktopBackgroundImageMode() {
desktop_background_mode_ = BACKGROUND_IMAGE;
InstallComponentForAllWindows();
if (desktop_background_mode_ != BACKGROUND_IMAGE) {
desktop_background_mode_ = BACKGROUND_IMAGE;
InstallComponentForAllWindows();
return;
}
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
for (Shell::RootWindowList::iterator iter = root_windows.begin();
iter != root_windows.end(); ++iter) {
aura::RootWindow* root_window = *iter;
internal::DesktopBackgroundWidgetController* component = root_window->
GetProperty(internal::kWindowDesktopComponent);
DCHECK(component);
DCHECK(component->widget());
aura::Window* window = component->widget()->GetNativeView();
gfx::Rect bounds = window->bounds();
window->SchedulePaintInRect(gfx::Rect(0, 0,
bounds.width(), bounds.height()));
}
}
void DesktopBackgroundController::OnWallpaperLoadCompleted(
......@@ -299,8 +328,7 @@ void DesktopBackgroundController::InstallComponent(
// First time for this root window
root_window->AddObserver(this);
}
root_window->SetProperty(internal::kComponentWrapper,
new internal::ComponentWrapper(component));
root_window->SetProperty(internal::kWindowDesktopComponent, component);
}
void DesktopBackgroundController::InstallComponentForAllWindows() {
......
......@@ -8,7 +8,6 @@
#include "ash/ash_export.h"
#include "ash/desktop_background/desktop_background_controller.h"
#include "ash/desktop_background/desktop_background_widget_controller.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/window_animations.h"
......@@ -44,14 +43,8 @@ class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver {
private:
// Overridden from ui::ImplicitAnimationObserver:
virtual void OnImplicitAnimationsCompleted() OVERRIDE {
ash::Shell* shell = ash::Shell::GetInstance();
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
// animation.
internal::DesktopBackgroundWidgetController* component =
root_window_->GetProperty(kComponentWrapper)->component();
root_window_->SetProperty(kWindowDesktopComponent, component);
ash::Shell::GetInstance()->
user_wallpaper_delegate()->OnWallpaperAnimationFinished();
MessageLoop::current()->DeleteSoon(FROM_HERE, this);
}
......@@ -160,17 +153,8 @@ views::Widget* CreateDesktopBackground(aura::RootWindow* root_window,
ash::Shell::GetInstance()->user_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(internal::kWindowDesktopComponent)) {
ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(),
ash::ANIMATE_NONE);
} else {
ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(),
ash::ANIMATE_SHOW);
}
ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(),
ash::ANIMATE_SHOW);
desktop_widget->SetBounds(params.parent->bounds());
ui::ScopedLayerAnimationSettings settings(
desktop_widget->GetNativeView()->layer()->GetAnimator());
......
......@@ -8,14 +8,12 @@
#include "ui/views/widget/widget.h"
DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::DesktopBackgroundWidgetController*);
DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::ComponentWrapper*);
namespace ash {
namespace internal {
DEFINE_OWNED_WINDOW_PROPERTY_KEY(DesktopBackgroundWidgetController,
kWindowDesktopComponent, NULL);
DEFINE_OWNED_WINDOW_PROPERTY_KEY(ComponentWrapper, kComponentWrapper, NULL);
DesktopBackgroundWidgetController::DesktopBackgroundWidgetController(
views::Widget* widget) : widget_(widget) {
......@@ -41,6 +39,7 @@ void DesktopBackgroundWidgetController::SetBounds(gfx::Rect bounds) {
layer_->SetBounds(bounds);
}
void DesktopBackgroundWidgetController::Reparent(aura::RootWindow* root_window,
int src_container,
int dest_container) {
......@@ -54,9 +53,5 @@ void DesktopBackgroundWidgetController::Reparent(aura::RootWindow* root_window,
}
}
ComponentWrapper::ComponentWrapper(
DesktopBackgroundWidgetController* component) : component_(component) {
}
} // namespace internal
} // namespace ash
......@@ -15,11 +15,6 @@ namespace internal {
// This class hides difference between two possible background implementations:
// effective Layer-based for solid color, and Widget-based for images.
// DesktopBackgroundWidgetController is installed as an owned property on the
// RootWindow. To avoid a white flash during wallpaper changes the old
// DesktopBackgroundWidgetController is moved to a secondary property
// (kComponentWrapper). When the animation completes the old
// DesktopBackgroundWidgetController is destroyed.
class DesktopBackgroundWidgetController {
public:
// Create
......@@ -48,31 +43,11 @@ class DesktopBackgroundWidgetController {
DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundWidgetController);
};
// This class wraps a DesktopBackgroundWidgetController pointer. It is installed
// as an owned property on the RootWindow. DesktopBackgroundWidgetController is
// moved to this property before animation completes. After animation completes,
// the kWindowDesktopComponent property on RootWindow is set to the
// DesktopBackgroundWidgetController in this class.
class ComponentWrapper {
public:
explicit ComponentWrapper(
DesktopBackgroundWidgetController* component);
~ComponentWrapper() {}
DesktopBackgroundWidgetController* component() { return component_; }
private:
DesktopBackgroundWidgetController* component_;
DISALLOW_COPY_AND_ASSIGN(ComponentWrapper);
};
// Window property key, that binds instance of DesktopBackgroundWidgetController
// to root windows.
extern const aura::WindowProperty<DesktopBackgroundWidgetController*>* const
kWindowDesktopComponent;
extern const aura::WindowProperty<ComponentWrapper*>* const kComponentWrapper;
} // namespace internal
} // namespace ash
......
......@@ -287,8 +287,6 @@ void RootWindowController::CloseChildWindows() {
// Close background widget first as it depends on tooltip.
root_window_->SetProperty(kWindowDesktopComponent,
static_cast<DesktopBackgroundWidgetController*>(NULL));
root_window_->SetProperty(kComponentWrapper,
static_cast<ComponentWrapper*>(NULL));
workspace_controller_.reset();
aura::client::SetTooltipClient(root_window_.get(), NULL);
......
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