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

Side by Side 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: Merge with ToT 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/session_state_animator.h" 5 #include "ash/wm/session_state_animator.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/wm/window_animations.h" 9 #include "ash/wm/window_animations.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 animator->set_preemption_strategy( 113 animator->set_preemption_strategy(
114 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 114 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
115 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( 115 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence(
116 ui::LayerAnimationElement::CreateOpacityElement( 116 ui::LayerAnimationElement::CreateOpacityElement(
117 target_opacity, duration)); 117 target_opacity, duration));
118 animator->StartAnimation(sequence); 118 animator->StartAnimation(sequence);
119 if (observer) 119 if (observer)
120 sequence->AddObserver(observer); 120 sequence->AddObserver(observer);
121 } 121 }
122 122
123 // Fades |window| in to full opacity over |duration|. 123 // Fades |window| in to |opacity| over |duration|.
124 void FadeInWindow(aura::Window* window, 124 void StartOpacityAnimationForWindow(aura::Window* window,
125 base::TimeDelta duration, 125 float opacity,
126 ui::LayerAnimationObserver* observer) { 126 base::TimeDelta duration,
127 ui::LayerAnimationObserver* observer) {
127 ui::LayerAnimator* animator = window->layer()->GetAnimator(); 128 ui::LayerAnimator* animator = window->layer()->GetAnimator();
128 animator->set_preemption_strategy( 129 animator->set_preemption_strategy(
129 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 130 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
130 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( 131 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence(
131 ui::LayerAnimationElement::CreateOpacityElement(1.0, duration)); 132 ui::LayerAnimationElement::CreateOpacityElement(opacity, duration));
132 animator->StartAnimation(sequence); 133 animator->StartAnimation(sequence);
133 if (observer) 134 if (observer)
134 sequence->AddObserver(observer); 135 sequence->AddObserver(observer);
135 } 136 }
136 137
137 // Makes |window| fully transparent instantaneously. 138 // Makes |window| fully transparent instantaneously.
138 void HideWindowImmediately(aura::Window* window, 139 void HideWindowImmediately(aura::Window* window,
139 ui::LayerAnimationObserver* observer) { 140 ui::LayerAnimationObserver* observer) {
140 window->layer()->SetOpacity(0.0); 141 window->layer()->SetOpacity(0.0);
141 if (observer) 142 if (observer)
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 break; 293 break;
293 case SessionStateAnimator::ANIMATION_FULL_CLOSE: 294 case SessionStateAnimator::ANIMATION_FULL_CLOSE:
294 if (layer->GetTargetTransform() != GetFastCloseTransform() || 295 if (layer->GetTargetTransform() != GetFastCloseTransform() ||
295 layer->GetTargetOpacity() > 0.0001) 296 layer->GetTargetOpacity() > 0.0001)
296 return false; 297 return false;
297 break; 298 break;
298 case SessionStateAnimator::ANIMATION_FADE_IN: 299 case SessionStateAnimator::ANIMATION_FADE_IN:
299 if (layer->GetTargetOpacity() < 0.9999) 300 if (layer->GetTargetOpacity() < 0.9999)
300 return false; 301 return false;
301 break; 302 break;
303 case SessionStateAnimator::ANIMATION_FADE_OUT:
304 if (layer->GetTargetOpacity() > 0.0001)
305 return false;
306 break;
302 case SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY: 307 case SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY:
303 if (layer->GetTargetOpacity() > 0.0001) 308 if (layer->GetTargetOpacity() > 0.0001)
304 return false; 309 return false;
305 break; 310 break;
306 case SessionStateAnimator::ANIMATION_RESTORE: 311 case SessionStateAnimator::ANIMATION_RESTORE:
307 if (layer->opacity() < 0.9999 || layer->transform() != gfx::Transform()) 312 if (layer->opacity() < 0.9999 || layer->transform() != gfx::Transform())
308 return false; 313 return false;
309 break; 314 break;
310 case SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS: 315 case SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS:
311 if ((layer->GetTargetBrightness() < 0.9999) || 316 if ((layer->GetTargetBrightness() < 0.9999) ||
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 if (container_mask & LOCK_SCREEN_CONTAINERS) { 456 if (container_mask & LOCK_SCREEN_CONTAINERS) {
452 containers->push_back(Shell::GetContainer( 457 containers->push_back(Shell::GetContainer(
453 root_window, 458 root_window,
454 internal::kShellWindowId_LockScreenContainersContainer)); 459 internal::kShellWindowId_LockScreenContainersContainer));
455 } 460 }
456 if (container_mask & LOCK_SCREEN_RELATED_CONTAINERS) { 461 if (container_mask & LOCK_SCREEN_RELATED_CONTAINERS) {
457 containers->push_back(Shell::GetContainer( 462 containers->push_back(Shell::GetContainer(
458 root_window, 463 root_window,
459 internal::kShellWindowId_LockScreenRelatedContainersContainer)); 464 internal::kShellWindowId_LockScreenRelatedContainersContainer));
460 } 465 }
461 if (container_mask & LOCK_SCREEN_SYSTEM_FOREGROUND) {
462 containers->push_back(Shell::GetContainer(
463 root_window,
464 internal::kShellWindowId_PowerButtonAnimationContainer));
465 }
466 } 466 }
467 467
468 void SessionStateAnimator::StartAnimation(int container_mask, 468 void SessionStateAnimator::StartAnimation(int container_mask,
469 AnimationType type, 469 AnimationType type,
470 AnimationSpeed speed) { 470 AnimationSpeed speed) {
471 aura::Window::Windows containers; 471 aura::Window::Windows containers;
472 GetContainers(container_mask, &containers); 472 GetContainers(container_mask, &containers);
473 for (aura::Window::Windows::const_iterator it = containers.begin(); 473 for (aura::Window::Windows::const_iterator it = containers.begin();
474 it != containers.end(); ++it) { 474 it != containers.end(); ++it) {
475 RunAnimationForWindow(*it, type, speed, NULL); 475 RunAnimationForWindow(*it, type, speed, NULL);
476 } 476 }
477 } 477 }
478 478
479 // Apply animation |type| to all containers described by |container_mask|. 479 // Apply animation |type| to all containers described by |container_mask|.
480 void SessionStateAnimator::StartAnimationWithCallback( 480 void SessionStateAnimator::StartAnimationWithCallback(
481 int container_mask, 481 int container_mask,
482 AnimationType type, 482 AnimationType type,
483 AnimationSpeed speed, 483 AnimationSpeed speed,
484 base::Callback<void(void)>& callback) { 484 base::Callback<void(void)>& callback) {
485 aura::Window::Windows containers; 485 aura::Window::Windows containers;
486 GetContainers(container_mask, &containers); 486 GetContainers(container_mask, &containers);
487 for (aura::Window::Windows::const_iterator it = containers.begin(); 487 for (aura::Window::Windows::const_iterator it = containers.begin();
488 it != containers.end(); ++it) { 488 it != containers.end(); ++it) {
489 ui::LayerAnimationObserver* observer = 489 ui::LayerAnimationObserver* observer =
490 new CallbackAnimationObserver(callback); 490 new CallbackAnimationObserver(callback);
491 RunAnimationForWindow(*it, type, speed, observer); 491 RunAnimationForWindow(*it, type, speed, observer);
492 } 492 }
493 } 493 }
494 494
495 void SessionStateAnimator::StartAnimationWithObserver(
496 int container_mask,
497 AnimationType type,
498 AnimationSpeed speed,
499 ui::LayerAnimationObserver* observer) {
500 aura::Window::Windows containers;
501 GetContainers(container_mask, &containers);
502 for (aura::Window::Windows::const_iterator it = containers.begin();
503 it != containers.end(); ++it) {
504 RunAnimationForWindow(*it, type, speed, observer);
505 }
506 }
507
495 void SessionStateAnimator::StartGlobalAnimation(AnimationType type, 508 void SessionStateAnimator::StartGlobalAnimation(AnimationType type,
496 AnimationSpeed speed) { 509 AnimationSpeed speed) {
497 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); 510 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
498 RunAnimationForWindow(root_window, type, speed, NULL); 511 RunAnimationForWindow(root_window, type, speed, NULL);
499 } 512 }
500 513
501 void SessionStateAnimator::RunAnimationForWindow( 514 void SessionStateAnimator::RunAnimationForWindow(
502 aura::Window* window, 515 aura::Window* window,
503 AnimationType type, 516 AnimationType type,
504 AnimationSpeed speed, 517 AnimationSpeed speed,
505 ui::LayerAnimationObserver* observer) { 518 ui::LayerAnimationObserver* observer) {
506 base::TimeDelta duration = GetDuration(speed); 519 base::TimeDelta duration = GetDuration(speed);
507 520
508 switch (type) { 521 switch (type) {
509 case ANIMATION_PARTIAL_CLOSE: 522 case ANIMATION_PARTIAL_CLOSE:
510 StartSlowCloseAnimationForWindow(window, duration, observer); 523 StartSlowCloseAnimationForWindow(window, duration, observer);
511 break; 524 break;
512 case ANIMATION_UNDO_PARTIAL_CLOSE: 525 case ANIMATION_UNDO_PARTIAL_CLOSE:
513 StartUndoSlowCloseAnimationForWindow(window, duration, observer); 526 StartUndoSlowCloseAnimationForWindow(window, duration, observer);
514 break; 527 break;
515 case ANIMATION_FULL_CLOSE: 528 case ANIMATION_FULL_CLOSE:
516 StartFastCloseAnimationForWindow(window, duration, observer); 529 StartFastCloseAnimationForWindow(window, duration, observer);
517 break; 530 break;
518 case ANIMATION_FADE_IN: 531 case ANIMATION_FADE_IN:
519 FadeInWindow(window, duration, observer); 532 StartOpacityAnimationForWindow(window, 1.0, duration, observer);
533 break;
534 case ANIMATION_FADE_OUT:
535 StartOpacityAnimationForWindow(window, 0.0, duration, observer);
520 break; 536 break;
521 case ANIMATION_HIDE_IMMEDIATELY: 537 case ANIMATION_HIDE_IMMEDIATELY:
522 DCHECK_EQ(speed, ANIMATION_SPEED_IMMEDIATE); 538 DCHECK_EQ(speed, ANIMATION_SPEED_IMMEDIATE);
523 HideWindowImmediately(window, observer); 539 HideWindowImmediately(window, observer);
524 break; 540 break;
525 case ANIMATION_RESTORE: 541 case ANIMATION_RESTORE:
526 DCHECK_EQ(speed, ANIMATION_SPEED_IMMEDIATE); 542 DCHECK_EQ(speed, ANIMATION_SPEED_IMMEDIATE);
527 RestoreWindow(window, observer); 543 RestoreWindow(window, observer);
528 break; 544 break;
529 case ANIMATION_LIFT: 545 case ANIMATION_LIFT:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 foreground_->SetColor(SK_ColorWHITE); 587 foreground_->SetColor(SK_ColorWHITE);
572 foreground_->GetWidget()->Show(); 588 foreground_->GetWidget()->Show();
573 } 589 }
574 590
575 void SessionStateAnimator::DropForeground() { 591 void SessionStateAnimator::DropForeground() {
576 foreground_.reset(); 592 foreground_.reset();
577 } 593 }
578 594
579 } // namespace internal 595 } // namespace internal
580 } // namespace ash 596 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698