Removing unused functionality from ScopedLayerAnimationSettings: inverse animations.
BUG=NONE
Review-Url: https://codereview.chromium.org/2215043002
Cr-Commit-Position: refs/heads/master@{#410461}
diff --git a/ui/compositor/layer_animator_unittest.cc b/ui/compositor/layer_animator_unittest.cc
index 6367b58..724ac67 100644
--- a/ui/compositor/layer_animator_unittest.cc
+++ b/ui/compositor/layer_animator_unittest.cc
@@ -2376,35 +2376,6 @@
EXPECT_EQ(start_opacity, delegate.GetOpacityForAnimation());
}
-TEST(LayerAnimatorTest, TestScopedCounterAnimation) {
- Layer parent, child;
- parent.Add(&child);
-
- gfx::Transform parent_begin, parent_end;
-
- parent_end.Scale3d(2.0, 0.5, 1.0);
-
- // Parent animates from identity to the end value. The counter animation will
- // start at the end value and animate back to identity.
- gfx::Transform child_begin(parent_end);
-
- child.SetTransform(child_begin);
- parent.SetTransform(parent_begin);
-
- EXPECT_FALSE(child.GetAnimator()->is_animating());
-
- ScopedLayerAnimationSettings settings(parent.GetAnimator());
- settings.SetInverselyAnimatedBaseLayer(&parent);
- settings.AddInverselyAnimatedLayer(&child);
-
- parent.SetTransform(parent_end);
-
- EXPECT_TRUE(child.GetAnimator()->is_animating());
- EXPECT_TRUE(child.GetTargetTransform().IsIdentity())
- << child.GetTargetTransform().ToString();
-
-}
-
class CollectionLayerAnimationDelegate : public TestLayerAnimationDelegate {
public:
CollectionLayerAnimationDelegate() : collection(NULL) {}
diff --git a/ui/compositor/scoped_layer_animation_settings.cc b/ui/compositor/scoped_layer_animation_settings.cc
index 912d8bd..5688d3c 100644
--- a/ui/compositor/scoped_layer_animation_settings.cc
+++ b/ui/compositor/scoped_layer_animation_settings.cc
@@ -19,65 +19,6 @@
namespace ui {
-// InvertingObserver -----------------------------------------------------------
-class InvertingObserver : public ImplicitAnimationObserver {
- public:
- InvertingObserver()
- : base_layer_(NULL) {
- }
-
- ~InvertingObserver() override {}
-
- void SetLayer(Layer* base_layer) { base_layer_ = base_layer; }
-
- Layer* layer() { return base_layer_; }
-
- void AddInverselyAnimatedLayer(Layer* inverse_layer) {
- inverse_layers_.push_back(inverse_layer);
- }
-
- void OnImplicitAnimationsCompleted() override {}
-
- void OnLayerAnimationScheduled(LayerAnimationSequence* sequence) override {
- DCHECK(base_layer_ != NULL)
- << "Must set base layer with ScopedLayerAnimationSettings::"
- << "SetInverslyAnimatedBaseLayer";
- gfx::Transform base_transform = base_layer_->transform();
- std::unique_ptr<LayerAnimationElement> inverse =
- GetInverseElement(sequence, base_transform);
-
- for (std::vector<Layer*>::const_iterator i =
- inverse_layers_.begin(); i != inverse_layers_.end(); ++i) {
- (*i)->GetAnimator()->StartAnimation(new LayerAnimationSequence(
- LayerAnimationElement::CloneInverseTransformElement(
- inverse.get())));
- }
- }
- private:
- std::unique_ptr<LayerAnimationElement> GetInverseElement(
- LayerAnimationSequence* sequence,
- gfx::Transform base) const {
- const size_t expected_size = 1;
- DCHECK_EQ(expected_size, sequence->size())
- << "Inverse supported only for single element sequences.";
-
- LayerAnimationElement* element = sequence->FirstElement();
- DCHECK_EQ(static_cast<LayerAnimationElement::AnimatableProperties>(
- LayerAnimationElement::TRANSFORM),
- element->properties())
- << "Only transform animations are currently invertible.";
-
- std::unique_ptr<LayerAnimationElement> to_return(
- LayerAnimationElement::CreateInverseTransformElement(base, element));
- return to_return;
- }
-
- Layer* base_layer_;
- // child layers
- std::vector<Layer*> inverse_layers_;
-};
-
-
// ScopedLayerAnimationSettings ------------------------------------------------
ScopedLayerAnimationSettings::ScopedLayerAnimationSettings(
scoped_refptr<LayerAnimator> animator)
@@ -86,8 +27,7 @@
animator->is_transition_duration_locked_),
old_transition_duration_(animator->GetTransitionDuration()),
old_tween_type_(animator->tween_type()),
- old_preemption_strategy_(animator->preemption_strategy()),
- inverse_observer_(new InvertingObserver()) {
+ old_preemption_strategy_(animator->preemption_strategy()) {
SetTransitionDuration(
base::TimeDelta::FromMilliseconds(kDefaultTransitionDurationMs));
}
@@ -104,10 +44,6 @@
animator_->observers_.RemoveObserver(*i);
(*i)->SetActive(true);
}
-
- if (inverse_observer_->layer()) {
- animator_->observers_.RemoveObserver(inverse_observer_.get());
- }
}
void ScopedLayerAnimationSettings::AddObserver(
@@ -147,18 +83,4 @@
return animator_->preemption_strategy();
}
-void ScopedLayerAnimationSettings::SetInverselyAnimatedBaseLayer(Layer* base) {
- if (inverse_observer_->layer() && !base) {
- animator_->RemoveObserver(inverse_observer_.get());
- } else if (base && !(inverse_observer_->layer())) {
- animator_->AddObserver(inverse_observer_.get());
- }
- inverse_observer_->SetLayer(base);
-}
-
-void ScopedLayerAnimationSettings::AddInverselyAnimatedLayer(
- Layer* inverse_layer) {
- inverse_observer_->AddInverselyAnimatedLayer(inverse_layer);
-}
-
} // namespace ui
diff --git a/ui/compositor/scoped_layer_animation_settings.h b/ui/compositor/scoped_layer_animation_settings.h
index 9cb84641..2b99c63 100644
--- a/ui/compositor/scoped_layer_animation_settings.h
+++ b/ui/compositor/scoped_layer_animation_settings.h
@@ -17,7 +17,6 @@
class ImplicitAnimationObserver;
class LayerAnimationObserver;
-class InvertingObserver;
// Scoped settings allow you to temporarily change the animator's settings and
// these changes are reverted when the object is destroyed. NOTE: when the
@@ -45,14 +44,6 @@
void SetPreemptionStrategy(LayerAnimator::PreemptionStrategy strategy);
LayerAnimator::PreemptionStrategy GetPreemptionStrategy() const;
- // Sets the base layer whose animation will be countered.
- void SetInverselyAnimatedBaseLayer(Layer* base);
-
- // Adds the layer to be counter-animated when a transform animation is
- // scheduled on the animator_. Must call SetInverselyAnimatedBaseLayer with
- // the layer associated with animator_ before animating.
- void AddInverselyAnimatedLayer(Layer* inverse_layer);
-
private:
scoped_refptr<LayerAnimator> animator_;
bool old_is_transition_duration_locked_;
@@ -60,7 +51,6 @@
gfx::Tween::Type old_tween_type_;
LayerAnimator::PreemptionStrategy old_preemption_strategy_;
std::set<ImplicitAnimationObserver*> observers_;
- std::unique_ptr<InvertingObserver> inverse_observer_;
DISALLOW_COPY_AND_ASSIGN(ScopedLayerAnimationSettings);
};