summaryrefslogtreecommitdiffstats
path: root/ash/desktop_background
diff options
context:
space:
mode:
authorbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-14 20:05:56 +0000
committerbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-14 20:05:56 +0000
commitf262a9e3cf6726c8f01c06300b4d1555c5afcec8 (patch)
tree3c3368fa7a0818894eab0da41802a958af3b4aa3 /ash/desktop_background
parenta88f87ece75b6b4888aee98693186f900e006130 (diff)
downloadchromium_src-f262a9e3cf6726c8f01c06300b4d1555c5afcec8.zip
chromium_src-f262a9e3cf6726c8f01c06300b4d1555c5afcec8.tar.gz
chromium_src-f262a9e3cf6726c8f01c06300b4d1555c5afcec8.tar.bz2
Reland "Fix white flash when user signs out and fix wallpaper animation regression"
This CL reland CL http://codereview.chromium.org/10827284/. Previous CL was failed on some interactive ui tests. " 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 TBR=nkostylev, sky Review URL: https://chromiumcodereview.appspot.com/10834308 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151548 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/desktop_background')
-rw-r--r--ash/desktop_background/desktop_background_controller.cc60
-rw-r--r--ash/desktop_background/desktop_background_view.cc26
-rw-r--r--ash/desktop_background/desktop_background_widget_controller.cc7
-rw-r--r--ash/desktop_background/desktop_background_widget_controller.h25
4 files changed, 70 insertions, 48 deletions
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc
index 2d49b4d..917e0ab 100644
--- a/ash/desktop_background/desktop_background_controller.cc
+++ b/ash/desktop_background/desktop_background_controller.cc
@@ -106,7 +106,6 @@ DesktopBackgroundController::DesktopBackgroundController()
desktop_background_mode_(BACKGROUND_SOLID_COLOR),
background_color_(kTransparentColor),
weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
- InstallComponentForAllWindows();
}
DesktopBackgroundController::~DesktopBackgroundController() {
@@ -213,22 +212,9 @@ void DesktopBackgroundController::CancelPendingWallpaperOperation() {
void DesktopBackgroundController::SetDesktopBackgroundSolidColorMode(
SkColor color) {
background_color_ = color;
- if (desktop_background_mode_ != BACKGROUND_SOLID_COLOR) {
- desktop_background_mode_ = BACKGROUND_SOLID_COLOR;
- InstallComponentForAllWindows();
- return;
- }
+ desktop_background_mode_ = BACKGROUND_SOLID_COLOR;
- 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_ );
- }
+ InstallComponentForAllWindows();
}
void DesktopBackgroundController::CreateEmptyWallpaper() {
@@ -255,28 +241,13 @@ 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() {
- 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()));
- }
+ desktop_background_mode_ = BACKGROUND_IMAGE;
+ InstallComponentForAllWindows();
}
void DesktopBackgroundController::OnWallpaperLoadCompleted(
@@ -324,11 +295,12 @@ void DesktopBackgroundController::InstallComponent(
NOTREACHED();
}
}
- if (NULL == root_window->GetProperty(internal::kWindowDesktopComponent)) {
+ if (NULL == root_window->GetProperty(internal::kComponentWrapper)) {
// First time for this root window
root_window->AddObserver(this);
}
- root_window->SetProperty(internal::kWindowDesktopComponent, component);
+ root_window->SetProperty(internal::kComponentWrapper,
+ new internal::ComponentWrapper(component));
}
void DesktopBackgroundController::InstallComponentForAllWindows() {
@@ -345,12 +317,14 @@ void DesktopBackgroundController::ReparentBackgroundWidgets(int src_container,
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);
- component->Reparent(root_window,
- src_container,
- dst_container);
+ if (root_window->GetProperty(internal::kComponentWrapper)) {
+ internal::DesktopBackgroundWidgetController* component = root_window->
+ GetProperty(internal::kComponentWrapper)->component();
+ DCHECK(component);
+ component->Reparent(root_window,
+ src_container,
+ dst_container);
+ }
}
}
diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc
index ea324e9..fcbd935 100644
--- a/ash/desktop_background/desktop_background_view.cc
+++ b/ash/desktop_background/desktop_background_view.cc
@@ -8,6 +8,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/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/window_animations.h"
@@ -43,8 +44,16 @@ class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver {
private:
// Overridden from ui::ImplicitAnimationObserver:
virtual void OnImplicitAnimationsCompleted() OVERRIDE {
- ash::Shell::GetInstance()->
- user_wallpaper_delegate()->OnWallpaperAnimationFinished();
+ 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.
+ if (root_window_->GetProperty(kComponentWrapper)) {
+ internal::DesktopBackgroundWidgetController* component =
+ root_window_->GetProperty(kComponentWrapper)->component();
+ root_window_->SetProperty(kWindowDesktopComponent, component);
+ }
MessageLoop::current()->DeleteSoon(FROM_HERE, this);
}
@@ -153,8 +162,17 @@ views::Widget* CreateDesktopBackground(aura::RootWindow* root_window,
ash::Shell::GetInstance()->user_wallpaper_delegate()->GetAnimationType();
ash::SetWindowVisibilityAnimationType(desktop_widget->GetNativeView(),
animation_type);
- ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(),
- ash::ANIMATE_SHOW);
+ // 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::kComponentWrapper)) {
+ ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(),
+ ash::ANIMATE_NONE);
+ } else {
+ ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(),
+ ash::ANIMATE_SHOW);
+ }
desktop_widget->SetBounds(params.parent->bounds());
ui::ScopedLayerAnimationSettings settings(
desktop_widget->GetNativeView()->layer()->GetAnimator());
diff --git a/ash/desktop_background/desktop_background_widget_controller.cc b/ash/desktop_background/desktop_background_widget_controller.cc
index 6e6d799..1d0f5fa 100644
--- a/ash/desktop_background/desktop_background_widget_controller.cc
+++ b/ash/desktop_background/desktop_background_widget_controller.cc
@@ -8,12 +8,14 @@
#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) {
@@ -39,7 +41,6 @@ void DesktopBackgroundWidgetController::SetBounds(gfx::Rect bounds) {
layer_->SetBounds(bounds);
}
-
void DesktopBackgroundWidgetController::Reparent(aura::RootWindow* root_window,
int src_container,
int dest_container) {
@@ -53,5 +54,9 @@ void DesktopBackgroundWidgetController::Reparent(aura::RootWindow* root_window,
}
}
+ComponentWrapper::ComponentWrapper(
+ DesktopBackgroundWidgetController* component) : component_(component) {
+}
+
} // namespace internal
} // namespace ash
diff --git a/ash/desktop_background/desktop_background_widget_controller.h b/ash/desktop_background/desktop_background_widget_controller.h
index fe07ef3..c50c4fa 100644
--- a/ash/desktop_background/desktop_background_widget_controller.h
+++ b/ash/desktop_background/desktop_background_widget_controller.h
@@ -15,6 +15,11 @@ 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
@@ -43,11 +48,31 @@ 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