summaryrefslogtreecommitdiffstats
path: root/ui/compositor
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-04 23:15:02 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-04 23:15:02 +0000
commit2a88c706cf02e2f794708a7853010b177bf7d6b2 (patch)
treeaa72d909e65624516c4bbcc3966fcd3527d53e93 /ui/compositor
parent61fcb16bb5045057ab1bf9b87cf48a41ad0b0073 (diff)
downloadchromium_src-2a88c706cf02e2f794708a7853010b177bf7d6b2.zip
chromium_src-2a88c706cf02e2f794708a7853010b177bf7d6b2.tar.gz
chromium_src-2a88c706cf02e2f794708a7853010b177bf7d6b2.tar.bz2
Adds LayerAnimator::SchedulePauseForProperties().
BUG=none TEST=covered by unit tests R=vollick@chromium.org Review URL: https://chromiumcodereview.appspot.com/10910074 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154843 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/compositor')
-rw-r--r--ui/compositor/layer_animator.cc17
-rw-r--r--ui/compositor/layer_animator.h7
-rw-r--r--ui/compositor/layer_animator_unittest.cc12
3 files changed, 36 insertions, 0 deletions
diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc
index a0d904c..fbb298a 100644
--- a/ui/compositor/layer_animator.cc
+++ b/ui/compositor/layer_animator.cc
@@ -217,6 +217,23 @@ void LayerAnimator::ScheduleTogether(
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 @@ class COMPOSITOR_EXPORT LayerAnimator : public AnimationContainerElement {
// 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 beea4ba..b01256b 100644
--- a/ui/compositor/layer_animator_unittest.cc
+++ b/ui/compositor/layer_animator_unittest.cc
@@ -1160,4 +1160,16 @@ TEST(LayerAnimatorTest, GetTargetGrayscale) {
}
}
+// 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