| 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/compositor/scoped_layer_animation_settings.h" | 5 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 6 | 6 |
| 7 #include "ui/compositor/layer.h" | 7 #include "ui/compositor/layer.h" |
| 8 #include "ui/compositor/layer_animation_observer.h" | 8 #include "ui/compositor/layer_animation_observer.h" |
| 9 #include "ui/compositor/layer_animation_sequence.h" | 9 #include "ui/compositor/layer_animation_sequence.h" |
| 10 #include "ui/compositor/layer_animator.h" | 10 #include "ui/compositor/layer_animator.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 const int kDefaultTransitionDurationMs = 200; | 14 const int kDefaultTransitionDurationMs = 200; |
| 15 | 15 |
| 16 } // namespace | 16 } // namespace |
| 17 | 17 |
| 18 namespace ui { | 18 namespace ui { |
| 19 | 19 |
| 20 // InvertingObserver ----------------------------------------------------------- | 20 // InvertingObserver ----------------------------------------------------------- |
| 21 class InvertingObserver : public ImplicitAnimationObserver { | 21 class InvertingObserver : public ImplicitAnimationObserver { |
| 22 public: | 22 public: |
| 23 InvertingObserver() | 23 InvertingObserver() |
| 24 : base_layer_(NULL) { | 24 : base_layer_(NULL) { |
| 25 } | 25 } |
| 26 | 26 |
| 27 virtual ~InvertingObserver() {} | 27 ~InvertingObserver() override {} |
| 28 | 28 |
| 29 void SetLayer(Layer* base_layer) { base_layer_ = base_layer; } | 29 void SetLayer(Layer* base_layer) { base_layer_ = base_layer; } |
| 30 | 30 |
| 31 Layer* layer() { return base_layer_; } | 31 Layer* layer() { return base_layer_; } |
| 32 | 32 |
| 33 void AddInverselyAnimatedLayer(Layer* inverse_layer) { | 33 void AddInverselyAnimatedLayer(Layer* inverse_layer) { |
| 34 inverse_layers_.push_back(inverse_layer); | 34 inverse_layers_.push_back(inverse_layer); |
| 35 } | 35 } |
| 36 | 36 |
| 37 virtual void OnImplicitAnimationsCompleted() override {} | 37 void OnImplicitAnimationsCompleted() override {} |
| 38 | 38 |
| 39 virtual void OnLayerAnimationScheduled( | 39 void OnLayerAnimationScheduled(LayerAnimationSequence* sequence) override { |
| 40 LayerAnimationSequence* sequence) override { | |
| 41 DCHECK(base_layer_ != NULL) | 40 DCHECK(base_layer_ != NULL) |
| 42 << "Must set base layer with ScopedLayerAnimationSettings::" | 41 << "Must set base layer with ScopedLayerAnimationSettings::" |
| 43 << "SetInverslyAnimatedBaseLayer"; | 42 << "SetInverslyAnimatedBaseLayer"; |
| 44 gfx::Transform base_transform = base_layer_->transform(); | 43 gfx::Transform base_transform = base_layer_->transform(); |
| 45 scoped_ptr<LayerAnimationElement> inverse = GetInverseElement(sequence, | 44 scoped_ptr<LayerAnimationElement> inverse = GetInverseElement(sequence, |
| 46 base_transform); | 45 base_transform); |
| 47 | 46 |
| 48 for (std::vector<Layer*>::const_iterator i = | 47 for (std::vector<Layer*>::const_iterator i = |
| 49 inverse_layers_.begin(); i != inverse_layers_.end(); ++i) { | 48 inverse_layers_.begin(); i != inverse_layers_.end(); ++i) { |
| 50 (*i)->GetAnimator()->StartAnimation(new LayerAnimationSequence( | 49 (*i)->GetAnimator()->StartAnimation(new LayerAnimationSequence( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 153 } |
| 155 inverse_observer_->SetLayer(base); | 154 inverse_observer_->SetLayer(base); |
| 156 } | 155 } |
| 157 | 156 |
| 158 void ScopedLayerAnimationSettings::AddInverselyAnimatedLayer( | 157 void ScopedLayerAnimationSettings::AddInverselyAnimatedLayer( |
| 159 Layer* inverse_layer) { | 158 Layer* inverse_layer) { |
| 160 inverse_observer_->AddInverselyAnimatedLayer(inverse_layer); | 159 inverse_observer_->AddInverselyAnimatedLayer(inverse_layer); |
| 161 } | 160 } |
| 162 | 161 |
| 163 } // namespace ui | 162 } // namespace ui |
| OLD | NEW |