| OLD | NEW |
| 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/scoped_layer_animation_settings.h" | 5 #include "ui/gfx/compositor/scoped_layer_animation_settings.h" |
| 6 | 6 |
| 7 #include "ui/gfx/compositor/layer_animation_observer.h" | 7 #include "ui/gfx/compositor/layer_animation_observer.h" |
| 8 #include "ui/gfx/compositor/layer_animator.h" | 8 #include "ui/gfx/compositor/layer_animator.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 static const base::TimeDelta kDefaultTransitionDuration = | 12 static const base::TimeDelta kDefaultTransitionDuration = |
| 13 base::TimeDelta::FromMilliseconds(200); | 13 base::TimeDelta::FromMilliseconds(200); |
| 14 | 14 |
| 15 } // namespace; | 15 } // namespace; |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 | 18 |
| 19 ScopedLayerAnimationSettings::ScopedLayerAnimationSettings( | 19 ScopedLayerAnimationSettings::ScopedLayerAnimationSettings( |
| 20 LayerAnimator* animator) | 20 LayerAnimator* animator) |
| 21 : animator_(animator), | 21 : animator_(animator), |
| 22 old_transition_duration_(animator->transition_duration_) { | 22 old_transition_duration_(animator->transition_duration_), |
| 23 old_preemption_strategy_(animator->preemption_strategy_) { |
| 23 SetTransitionDuration(kDefaultTransitionDuration); | 24 SetTransitionDuration(kDefaultTransitionDuration); |
| 24 } | 25 } |
| 25 | 26 |
| 26 ScopedLayerAnimationSettings::~ScopedLayerAnimationSettings() { | 27 ScopedLayerAnimationSettings::~ScopedLayerAnimationSettings() { |
| 27 animator_->transition_duration_ = old_transition_duration_; | 28 animator_->transition_duration_ = old_transition_duration_; |
| 29 animator_->preemption_strategy_ = old_preemption_strategy_; |
| 28 | 30 |
| 29 for (std::set<ImplicitAnimationObserver*>::const_iterator i = | 31 for (std::set<ImplicitAnimationObserver*>::const_iterator i = |
| 30 observers_.begin(); i != observers_.end(); ++i) { | 32 observers_.begin(); i != observers_.end(); ++i) { |
| 31 animator_->observers_.RemoveObserver(*i); | 33 animator_->observers_.RemoveObserver(*i); |
| 32 (*i)->SetActive(true); | 34 (*i)->SetActive(true); |
| 33 } | 35 } |
| 34 } | 36 } |
| 35 | 37 |
| 36 void ScopedLayerAnimationSettings::AddObserver( | 38 void ScopedLayerAnimationSettings::AddObserver( |
| 37 ImplicitAnimationObserver* observer) { | 39 ImplicitAnimationObserver* observer) { |
| 38 observers_.insert(observer); | 40 observers_.insert(observer); |
| 39 animator_->AddObserver(observer); | 41 animator_->AddObserver(observer); |
| 40 } | 42 } |
| 41 | 43 |
| 42 void ScopedLayerAnimationSettings::SetTransitionDuration( | 44 void ScopedLayerAnimationSettings::SetTransitionDuration( |
| 43 base::TimeDelta duration) { | 45 base::TimeDelta duration) { |
| 44 animator_->transition_duration_ = duration; | 46 animator_->transition_duration_ = duration; |
| 45 } | 47 } |
| 46 | 48 |
| 49 void ScopedLayerAnimationSettings::SetPreemptionStrategy( |
| 50 LayerAnimator::PreemptionStrategy strategy) { |
| 51 animator_->preemption_strategy_ = strategy; |
| 52 } |
| 53 |
| 47 } // namespace ui | 54 } // namespace ui |
| 48 | 55 |
| OLD | NEW |