Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2804)

Unified Diff: ash/wm/session_state_animator.cc

Issue 11453012: Fix black background when locking with fullscreen window: (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove stuff for testing and disable some tests" Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/session_state_animator.h ('k') | ash/wm/session_state_controller_impl2.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/session_state_animator.cc
diff --git a/ash/wm/session_state_animator.cc b/ash/wm/session_state_animator.cc
index 6f55b90a6b5f965c84df2702587cad6fe5f375b1..593091e517979a7d3e8769b6f849937f27996378 100644
--- a/ash/wm/session_state_animator.cc
+++ b/ash/wm/session_state_animator.cc
@@ -120,15 +120,16 @@ void StartPartialFadeAnimation(aura::Window* window,
sequence->AddObserver(observer);
}
-// Fades |window| in to full opacity over |duration|.
-void FadeInWindow(aura::Window* window,
- base::TimeDelta duration,
- ui::LayerAnimationObserver* observer) {
+// Fades |window| to |opacity| over |duration|.
+void StartOpacityAnimationForWindow(aura::Window* window,
+ float opacity,
+ base::TimeDelta duration,
+ ui::LayerAnimationObserver* observer) {
ui::LayerAnimator* animator = window->layer()->GetAnimator();
animator->set_preemption_strategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence(
- ui::LayerAnimationElement::CreateOpacityElement(1.0, duration));
+ ui::LayerAnimationElement::CreateOpacityElement(opacity, duration));
animator->StartAnimation(sequence);
if (observer)
sequence->AddObserver(observer);
@@ -158,6 +159,8 @@ void HideWindow(aura::Window* window,
ui::Layer* layer = window->layer();
ui::ScopedLayerAnimationSettings settings(layer->GetAnimator());
+ settings.SetPreemptionStrategy(
+ ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
settings.SetTransitionDuration(duration);
settings.SetTweenType(ui::Tween::EASE_OUT);
@@ -188,19 +191,16 @@ void HideWindow(aura::Window* window,
}
}
-void ShowWindow(aura::Window* window,
- base::TimeDelta duration,
- bool above,
- ui::LayerAnimationObserver* observer) {
+// Animates |window| to identity transform and full opacity over |duration|.
+void TransformWindowToBaseState(aura::Window* window,
+ base::TimeDelta duration,
+ ui::LayerAnimationObserver* observer) {
ui::Layer* layer = window->layer();
ui::ScopedLayerAnimationSettings settings(layer->GetAnimator());
- // Set initial state of animation
- settings.SetTransitionDuration(base::TimeDelta());
- SetTransformForScaleAnimation(layer,
- above ? LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW);
-
// Animate to target values.
+ settings.SetPreemptionStrategy(
+ ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
settings.SetTransitionDuration(duration);
settings.SetTweenType(ui::Tween::EASE_OUT);
@@ -223,6 +223,23 @@ void ShowWindow(aura::Window* window,
}
}
+void ShowWindow(aura::Window* window,
+ base::TimeDelta duration,
+ bool above,
+ ui::LayerAnimationObserver* observer) {
+ ui::Layer* layer = window->layer();
+ ui::ScopedLayerAnimationSettings settings(layer->GetAnimator());
+
+ // Set initial state of animation
+ settings.SetPreemptionStrategy(
+ ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
+ settings.SetTransitionDuration(base::TimeDelta());
+ SetTransformForScaleAnimation(layer,
+ above ? LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW);
+
+ TransformWindowToBaseState(window, duration, observer);
+}
+
// Starts grayscale/brightness animation for |window| over |duration|. Target
// value for both grayscale and brightness are specified by |target|.
void StartGrayscaleBrightnessAnimationForWindow(
@@ -232,8 +249,26 @@ void StartGrayscaleBrightnessAnimationForWindow(
ui::LayerAnimationObserver* observer) {
ui::LayerAnimator* animator = window->layer()->GetAnimator();
- std::vector<ui::LayerAnimationSequence*> animations =
- CreateBrightnessGrayscaleAnimationSequence(target, duration);
+ scoped_ptr<ui::LayerAnimationSequence> brightness_sequence(
+ new ui::LayerAnimationSequence());
+ scoped_ptr<ui::LayerAnimationSequence> grayscale_sequence(
+ new ui::LayerAnimationSequence());
+
+ scoped_ptr<ui::LayerAnimationElement> brightness_element(
+ ui::LayerAnimationElement::CreateBrightnessElement(
+ target, duration));
+ brightness_element->set_tween_type(ui::Tween::EASE_IN);
+ brightness_sequence->AddElement(brightness_element.release());
+
+ scoped_ptr<ui::LayerAnimationElement> grayscale_element(
+ ui::LayerAnimationElement::CreateGrayscaleElement(
+ target, duration));
+ grayscale_element->set_tween_type(ui::Tween::EASE_IN);
+ grayscale_sequence->AddElement(grayscale_element.release());
+
+ std::vector<ui::LayerAnimationSequence*> animations;
+ animations.push_back(brightness_sequence.release());
+ animations.push_back(grayscale_sequence.release());
if (observer)
animations[0]->AddObserver(observer);
@@ -299,6 +334,10 @@ bool IsLayerAnimated(ui::Layer* layer,
if (layer->GetTargetOpacity() < 0.9999)
return false;
break;
+ case SessionStateAnimator::ANIMATION_FADE_OUT:
+ if (layer->GetTargetOpacity() > 0.0001)
+ return false;
+ break;
case SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY:
if (layer->GetTargetOpacity() > 0.0001)
return false;
@@ -318,6 +357,7 @@ bool IsLayerAnimated(ui::Layer* layer,
return false;
break;
case SessionStateAnimator::ANIMATION_DROP:
+ case SessionStateAnimator::ANIMATION_UNDO_LIFT:
//ToDo(antim) : check other effects
if (layer->GetTargetOpacity() < 0.9999)
return false;
@@ -391,15 +431,15 @@ base::TimeDelta SessionStateAnimator::GetDuration(AnimationSpeed speed) {
case ANIMATION_SPEED_UNDOABLE:
return base::TimeDelta::FromMilliseconds(400);
case ANIMATION_SPEED_REVERT:
- return base::TimeDelta::FromMilliseconds(100);
+ return base::TimeDelta::FromMilliseconds(150);
case ANIMATION_SPEED_FAST:
return base::TimeDelta::FromMilliseconds(150);
case ANIMATION_SPEED_SHOW_LOCK_SCREEN:
return base::TimeDelta::FromMilliseconds(200);
case ANIMATION_SPEED_MOVE_WINDOWS:
- return base::TimeDelta::FromMilliseconds(400);
+ return base::TimeDelta::FromMilliseconds(350);
case ANIMATION_SPEED_UNDO_MOVE_WINDOWS:
- return base::TimeDelta::FromMilliseconds(600);
+ return base::TimeDelta::FromMilliseconds(500);
case ANIMATION_SPEED_SHUTDOWN:
return base::TimeDelta::FromMilliseconds(1000);
case ANIMATION_SPEED_REVERT_SHUTDOWN:
@@ -458,11 +498,6 @@ void SessionStateAnimator::GetContainers(int container_mask,
root_window,
internal::kShellWindowId_LockScreenRelatedContainersContainer));
}
- if (container_mask & LOCK_SCREEN_SYSTEM_FOREGROUND) {
- containers->push_back(Shell::GetContainer(
- root_window,
- internal::kShellWindowId_PowerButtonAnimationContainer));
- }
}
void SessionStateAnimator::StartAnimation(int container_mask,
@@ -476,7 +511,6 @@ void SessionStateAnimator::StartAnimation(int container_mask,
}
}
-// Apply animation |type| to all containers described by |container_mask|.
void SessionStateAnimator::StartAnimationWithCallback(
int container_mask,
AnimationType type,
@@ -492,6 +526,19 @@ void SessionStateAnimator::StartAnimationWithCallback(
}
}
+void SessionStateAnimator::StartAnimationWithObserver(
+ int container_mask,
+ AnimationType type,
+ AnimationSpeed speed,
+ ui::LayerAnimationObserver* observer) {
+ aura::Window::Windows containers;
+ GetContainers(container_mask, &containers);
+ for (aura::Window::Windows::const_iterator it = containers.begin();
+ it != containers.end(); ++it) {
+ RunAnimationForWindow(*it, type, speed, observer);
+ }
+}
+
void SessionStateAnimator::StartGlobalAnimation(AnimationType type,
AnimationSpeed speed) {
aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
@@ -516,7 +563,10 @@ void SessionStateAnimator::RunAnimationForWindow(
StartFastCloseAnimationForWindow(window, duration, observer);
break;
case ANIMATION_FADE_IN:
- FadeInWindow(window, duration, observer);
+ StartOpacityAnimationForWindow(window, 1.0, duration, observer);
+ break;
+ case ANIMATION_FADE_OUT:
+ StartOpacityAnimationForWindow(window, 0.0, duration, observer);
break;
case ANIMATION_HIDE_IMMEDIATELY:
DCHECK_EQ(speed, ANIMATION_SPEED_IMMEDIATE);
@@ -532,6 +582,9 @@ void SessionStateAnimator::RunAnimationForWindow(
case ANIMATION_DROP:
ShowWindow(window, duration, true, observer);
break;
+ case ANIMATION_UNDO_LIFT:
+ TransformWindowToBaseState(window, duration, observer);
+ break;
case ANIMATION_RAISE_TO_SCREEN:
ShowWindow(window, duration, false, observer);
break;
« no previous file with comments | « ash/wm/session_state_animator.h ('k') | ash/wm/session_state_controller_impl2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698