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

Side by Side Diff: ui/gfx/compositor/layer_animator.cc

Issue 9222018: reland -- Disable animations during aura tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 months 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 | Annotate | Revision Log
« no previous file with comments | « ui/gfx/compositor/layer_animator.h ('k') | ui/gfx/compositor/layer_animator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/gfx/compositor/layer_animator.h" 5 #include "ui/gfx/compositor/layer_animator.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "ui/base/animation/animation_container.h" 10 #include "ui/base/animation/animation_container.h"
(...skipping 27 matching lines...) Expand all
38 disable_timer_for_test_(false) { 38 disable_timer_for_test_(false) {
39 } 39 }
40 40
41 LayerAnimator::~LayerAnimator() { 41 LayerAnimator::~LayerAnimator() {
42 for (size_t i = 0; i < running_animations_.size(); ++i) 42 for (size_t i = 0; i < running_animations_.size(); ++i)
43 running_animations_[i].sequence->OnAnimatorDestroyed(); 43 running_animations_[i].sequence->OnAnimatorDestroyed();
44 ClearAnimations(); 44 ClearAnimations();
45 } 45 }
46 46
47 // static 47 // static
48 bool LayerAnimator::disable_animations_for_test_ = false;
49
50 // static
48 LayerAnimator* LayerAnimator::CreateDefaultAnimator() { 51 LayerAnimator* LayerAnimator::CreateDefaultAnimator() {
49 return new LayerAnimator(base::TimeDelta::FromMilliseconds(0)); 52 return new LayerAnimator(base::TimeDelta::FromMilliseconds(0));
50 } 53 }
51 54
52 // static 55 // static
53 LayerAnimator* LayerAnimator::CreateImplicitAnimator() { 56 LayerAnimator* LayerAnimator::CreateImplicitAnimator() {
54 return new LayerAnimator(kDefaultTransitionDuration); 57 return new LayerAnimator(kDefaultTransitionDuration);
55 } 58 }
56 59
57 void LayerAnimator::SetTransform(const Transform& transform) { 60 void LayerAnimator::SetTransform(const Transform& transform) {
61 base::TimeDelta duration = transition_duration_;
62 if (disable_animations_for_test_)
63 duration = base::TimeDelta();
58 StartAnimation(new LayerAnimationSequence( 64 StartAnimation(new LayerAnimationSequence(
59 LayerAnimationElement::CreateTransformElement( 65 LayerAnimationElement::CreateTransformElement(
60 transform, transition_duration_))); 66 transform, duration)));
61 } 67 }
62 68
63 Transform LayerAnimator::GetTargetTransform() const { 69 Transform LayerAnimator::GetTargetTransform() const {
64 LayerAnimationElement::TargetValue target(delegate()); 70 LayerAnimationElement::TargetValue target(delegate());
65 GetTargetValue(&target); 71 GetTargetValue(&target);
66 return target.transform; 72 return target.transform;
67 } 73 }
68 74
69 void LayerAnimator::SetBounds(const gfx::Rect& bounds) { 75 void LayerAnimator::SetBounds(const gfx::Rect& bounds) {
76 base::TimeDelta duration = transition_duration_;
77 if (disable_animations_for_test_)
78 duration = base::TimeDelta();
70 StartAnimation(new LayerAnimationSequence( 79 StartAnimation(new LayerAnimationSequence(
71 LayerAnimationElement::CreateBoundsElement( 80 LayerAnimationElement::CreateBoundsElement(
72 bounds, transition_duration_))); 81 bounds, duration)));
73 } 82 }
74 83
75 gfx::Rect LayerAnimator::GetTargetBounds() const { 84 gfx::Rect LayerAnimator::GetTargetBounds() const {
76 LayerAnimationElement::TargetValue target(delegate()); 85 LayerAnimationElement::TargetValue target(delegate());
77 GetTargetValue(&target); 86 GetTargetValue(&target);
78 return target.bounds; 87 return target.bounds;
79 } 88 }
80 89
81 void LayerAnimator::SetOpacity(float opacity) { 90 void LayerAnimator::SetOpacity(float opacity) {
91 base::TimeDelta duration = transition_duration_;
92 if (disable_animations_for_test_)
93 duration = base::TimeDelta();
82 StartAnimation(new LayerAnimationSequence( 94 StartAnimation(new LayerAnimationSequence(
83 LayerAnimationElement::CreateOpacityElement( 95 LayerAnimationElement::CreateOpacityElement(
84 opacity, transition_duration_))); 96 opacity, duration)));
85 } 97 }
86 98
87 float LayerAnimator::GetTargetOpacity() const { 99 float LayerAnimator::GetTargetOpacity() const {
88 LayerAnimationElement::TargetValue target(delegate()); 100 LayerAnimationElement::TargetValue target(delegate());
89 GetTargetValue(&target); 101 GetTargetValue(&target);
90 return target.opacity; 102 return target.opacity;
91 } 103 }
92 104
93 void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) { 105 void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) {
94 DCHECK(delegate); 106 DCHECK(delegate);
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 ObserverListBase<LayerAnimationObserver>::Iterator it(observers_); 523 ObserverListBase<LayerAnimationObserver>::Iterator it(observers_);
512 LayerAnimationObserver* obs; 524 LayerAnimationObserver* obs;
513 while ((obs = it.GetNext()) != NULL) { 525 while ((obs = it.GetNext()) != NULL) {
514 sequence->AddObserver(obs); 526 sequence->AddObserver(obs);
515 } 527 }
516 } 528 }
517 sequence->OnScheduled(); 529 sequence->OnScheduled();
518 } 530 }
519 531
520 } // namespace ui 532 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/compositor/layer_animator.h ('k') | ui/gfx/compositor/layer_animator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698