Adds LayerAnimator::SchedulePauseForProperties().
BUG=none
TEST=covered by unit tests
[email protected]
Review URL: https://chromiumcodereview.appspot.com/10910074
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154843 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc
index a0d904c..fbb298ad 100644
--- a/ui/compositor/layer_animator.cc
+++ b/ui/compositor/layer_animator.cc
@@ -217,6 +217,23 @@
UpdateAnimationState();
}
+void LayerAnimator::SchedulePauseForProperties(
+ base::TimeDelta duration,
+ LayerAnimationElement::AnimatableProperty property,
+ ...) {
+ ui::LayerAnimationElement::AnimatableProperties properties_to_pause;
+ va_list marker;
+ va_start(marker, property);
+ for (int p = static_cast<int>(property); p != -1; p = va_arg(marker, int)) {
+ properties_to_pause.insert(
+ static_cast<LayerAnimationElement::AnimatableProperty>(p));
+ }
+ va_end(marker);
+ ScheduleAnimation(new ui::LayerAnimationSequence(
+ ui::LayerAnimationElement::CreatePauseElement(
+ properties_to_pause, duration)));
+}
+
bool LayerAnimator::IsAnimatingProperty(
LayerAnimationElement::AnimatableProperty property) const {
for (AnimationQueue::const_iterator queue_iter = animation_queue_.begin();
diff --git a/ui/compositor/layer_animator.h b/ui/compositor/layer_animator.h
index 65ec27a..3c9a087 100644
--- a/ui/compositor/layer_animator.h
+++ b/ui/compositor/layer_animator.h
@@ -106,6 +106,13 @@
// animation sequences.
void ScheduleTogether(const std::vector<LayerAnimationSequence*>& animations);
+ // Schedules a pause for length |duration| of all the specified properties.
+ // End the list with -1.
+ void SchedulePauseForProperties(
+ base::TimeDelta duration,
+ LayerAnimationElement::AnimatableProperty property,
+ ...);
+
// Returns true if there is an animation in the queue (animations remain in
// the queue until they complete, so this includes running animations).
bool is_animating() const { return !animation_queue_.empty(); }
diff --git a/ui/compositor/layer_animator_unittest.cc b/ui/compositor/layer_animator_unittest.cc
index beea4ba3..b01256be 100644
--- a/ui/compositor/layer_animator_unittest.cc
+++ b/ui/compositor/layer_animator_unittest.cc
@@ -1160,4 +1160,16 @@
}
}
+// Verifies SchedulePauseForProperties().
+TEST(LayerAnimatorTest, SchedulePauseForProperties) {
+ scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
+ animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION);
+ animator->SchedulePauseForProperties(base::TimeDelta::FromMilliseconds(100),
+ LayerAnimationElement::TRANSFORM,
+ LayerAnimationElement::BOUNDS, -1);
+ EXPECT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::TRANSFORM));
+ EXPECT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS));
+ EXPECT_FALSE(animator->IsAnimatingProperty(LayerAnimationElement::OPACITY));
+}
+
} // namespace ui