Commit 964ae8f4 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

wallpaper: Tweak cross fade animation a bit.

Users have reported a subtle flash during the overview animation. This
is because the current cross fade animation fades out the old layer
while fading in the new layer. This will cause the combined opacities
of the two layers to be 1 at the endpoints, but less than 1 in
between, resulting in the middle of the animation being slightly dimmer.

Discussed with UX in the bug, and make the only the old layer fade out.
This will result in the combined opacity always being 1.

Test: manual
Change-Id: Iacc7adcbc424f59656d7876bfecf32e3cb048b2d
Fixed: 1124947
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2481002
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818590}
parent 8d0409df
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/compositor/layer_tree_owner.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/compositor/test/layer_animator_test_controller.h" #include "ui/compositor/test/layer_animator_test_controller.h"
#include "ui/display/display.h" #include "ui/display/display.h"
...@@ -353,15 +354,18 @@ class WallpaperControllerTest : public AshTestBase { ...@@ -353,15 +354,18 @@ class WallpaperControllerTest : public AshTestBase {
} }
// Runs AnimatingWallpaperWidgetController's animation to completion. // Runs AnimatingWallpaperWidgetController's animation to completion.
// TODO(bshe): Don't require tests to run animations; it's slow.
void RunDesktopControllerAnimation() { void RunDesktopControllerAnimation() {
WallpaperWidgetController* controller = WallpaperWidgetController* controller =
Shell::Get() Shell::Get()
->GetPrimaryRootWindowController() ->GetPrimaryRootWindowController()
->wallpaper_widget_controller(); ->wallpaper_widget_controller();
ASSERT_TRUE(controller); ASSERT_TRUE(controller);
ASSERT_NO_FATAL_FAILURE(
RunAnimationForLayer(controller->wallpaper_view()->layer())); ui::LayerTreeOwner* owner = controller->old_layer_tree_owner_for_testing();
if (!owner)
return;
ASSERT_NO_FATAL_FAILURE(RunAnimationForLayer(owner->root()));
} }
// Convenience function to ensure ShouldCalculateColors() returns true. // Convenience function to ensure ShouldCalculateColors() returns true.
...@@ -684,8 +688,7 @@ TEST_F(WallpaperControllerTest, ChangeWallpaperQuick) { ...@@ -684,8 +688,7 @@ TEST_F(WallpaperControllerTest, ChangeWallpaperQuick) {
controller->CreateEmptyWallpaperForTesting(); controller->CreateEmptyWallpaperForTesting();
// Run wallpaper show animation to completion. // Run wallpaper show animation to completion.
ASSERT_NO_FATAL_FAILURE( RunDesktopControllerAnimation();
RunAnimationForLayer(widget_controller->wallpaper_view()->layer()));
EXPECT_FALSE(widget_controller->IsAnimating()); EXPECT_FALSE(widget_controller->IsAnimating());
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "ui/compositor/layer_animation_observer.h" #include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/layer_tree_owner.h" #include "ui/compositor/layer_tree_owner.h"
#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/animation/tween.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h" #include "ui/views/widget/widget_observer.h"
#include "ui/wm/core/window_util.h" #include "ui/wm/core/window_util.h"
...@@ -44,11 +45,11 @@ views::Widget* WallpaperWidgetController::GetWidget() { ...@@ -44,11 +45,11 @@ views::Widget* WallpaperWidgetController::GetWidget() {
} }
bool WallpaperWidgetController::IsAnimating() const { bool WallpaperWidgetController::IsAnimating() const {
return wallpaper_view_->layer()->GetAnimator()->is_animating(); return old_layer_tree_owner_ &&
old_layer_tree_owner_->root()->GetAnimator()->is_animating();
} }
void WallpaperWidgetController::StopAnimating() { void WallpaperWidgetController::StopAnimating() {
wallpaper_view_->layer()->GetAnimator()->StopAnimating();
if (old_layer_tree_owner_) { if (old_layer_tree_owner_) {
old_layer_tree_owner_->root()->GetAnimator()->StopAnimating(); old_layer_tree_owner_->root()->GetAnimator()->StopAnimating();
old_layer_tree_owner_.reset(); old_layer_tree_owner_.reset();
...@@ -116,25 +117,24 @@ void WallpaperWidgetController::ApplyCrossFadeAnimation( ...@@ -116,25 +117,24 @@ void WallpaperWidgetController::ApplyCrossFadeAnimation(
DCHECK(wallpaper_view_); DCHECK(wallpaper_view_);
old_layer_tree_owner_ = ::wm::RecreateLayers(wallpaper_view_); old_layer_tree_owner_ = ::wm::RecreateLayers(wallpaper_view_);
old_layer_tree_owner_->root()->parent()->StackAbove(
old_layer_tree_owner_->root(), wallpaper_view_->layer());
ui::Layer* old_layer = old_layer_tree_owner_->root(); ui::Layer* old_layer = old_layer_tree_owner_->root();
ui::Layer* new_layer = wallpaper_view_->layer(); ui::Layer* new_layer = wallpaper_view_->layer();
old_layer->SetOpacity(1.f); DCHECK_EQ(old_layer->parent(), new_layer->parent());
new_layer->SetOpacity(0.f); old_layer->parent()->StackAbove(old_layer, new_layer);
ui::ScopedLayerAnimationSettings original_settings(new_layer->GetAnimator());
ui::ScopedLayerAnimationSettings copy_settings(old_layer->GetAnimator());
original_settings.SetTransitionDuration(duration); old_layer->SetOpacity(1.f);
original_settings.SetTweenType(gfx::Tween::EASE_OUT); new_layer->SetOpacity(1.f);
original_settings.AddObserver(this);
copy_settings.SetTransitionDuration(duration); // Fade out the old layer. When clearing the blur, use the opposite tween so
copy_settings.SetTweenType(gfx::Tween::EASE_IN); // that the animations are mirrors of each other.
const bool clearing =
wallpaper_view_->property() == wallpaper_constants::kClear;
ui::ScopedLayerAnimationSettings settings(old_layer->GetAnimator());
settings.SetTransitionDuration(duration);
settings.SetTweenType(clearing ? gfx::Tween::EASE_IN : gfx::Tween::EASE_OUT);
settings.AddObserver(this);
new_layer->SetOpacity(1.f);
old_layer->SetOpacity(0.f); old_layer->SetOpacity(0.f);
} }
......
...@@ -71,15 +71,20 @@ class ASH_EXPORT WallpaperWidgetController ...@@ -71,15 +71,20 @@ class ASH_EXPORT WallpaperWidgetController
const base::TimeDelta& animation_duration = base::TimeDelta()); const base::TimeDelta& animation_duration = base::TimeDelta());
const WallpaperProperty& GetWallpaperProperty() const; const WallpaperProperty& GetWallpaperProperty() const;
WallpaperView* wallpaper_view() const { return wallpaper_view_; }
// ui::ImplicitAnimationObserver: // ui::ImplicitAnimationObserver:
void OnImplicitAnimationsCompleted() override; void OnImplicitAnimationsCompleted() override;
WallpaperView* wallpaper_view() { return wallpaper_view_; }
ui::LayerTreeOwner* old_layer_tree_owner_for_testing() {
return old_layer_tree_owner_.get();
}
private: private:
// Runs callbacks in |animation_end_callbacks_|. // Runs callbacks in |animation_end_callbacks_|.
void RunAnimationEndCallbacks(); void RunAnimationEndCallbacks();
// Copies and fades out the existing wallpaper.
void ApplyCrossFadeAnimation(base::TimeDelta duration); void ApplyCrossFadeAnimation(base::TimeDelta duration);
aura::Window* root_window_; aura::Window* root_window_;
...@@ -90,7 +95,8 @@ class ASH_EXPORT WallpaperWidgetController ...@@ -90,7 +95,8 @@ class ASH_EXPORT WallpaperWidgetController
// The current wallpaper widget. // The current wallpaper widget.
std::unique_ptr<views::Widget> widget_; std::unique_ptr<views::Widget> widget_;
// The animating layer which contains old content. // The animating layer which contains old content. This is the layer that is
// animated when changing wallpapers.
std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_; std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_;
// Pointer to the wallpaper view owned by |widget_|. // Pointer to the wallpaper view owned by |widget_|.
......
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