summaryrefslogtreecommitdiffstats
path: root/cc/layer_tree_host_unittest_animation.cc
diff options
context:
space:
mode:
authorvollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-20 00:11:34 +0000
committervollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-20 00:11:34 +0000
commitde4afb5eaff3e756cc13d915532402c651302a32 (patch)
treed7517e1363c8cf3698dc1fd08af4623705a4263d /cc/layer_tree_host_unittest_animation.cc
parent8f95c562479b3be9776e77b597d72b464bb447a5 (diff)
downloadchromium_src-de4afb5eaff3e756cc13d915532402c651302a32.zip
chromium_src-de4afb5eaff3e756cc13d915532402c651302a32.tar.gz
chromium_src-de4afb5eaff3e756cc13d915532402c651302a32.tar.bz2
Ref count layer animation controllers.
With this patch we accomplish the following: 1. layer animation controllers are ref counted (so they can be shared by the two impl trees) 2. the layer tree hosts now own a list of active animation controllers. This allows for a couple of nice things __a. Ticking the animation controllers no longer requires a tree walk __b. We will be able to support ticking of animation controllers for layers that are not yet added to the layer tree. (Support coming in a future patch). 3. animation controllers register and unregister themselves from their respective layer tree host's list when they have an animation to tick. R=nduca@chromium.org,enne@chromium.org BUG=162111 Review URL: https://chromiumcodereview.appspot.com/11598005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174043 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layer_tree_host_unittest_animation.cc')
-rw-r--r--cc/layer_tree_host_unittest_animation.cc60
1 files changed, 32 insertions, 28 deletions
diff --git a/cc/layer_tree_host_unittest_animation.cc b/cc/layer_tree_host_unittest_animation.cc
index 8900c93..485a25f 100644
--- a/cc/layer_tree_host_unittest_animation.cc
+++ b/cc/layer_tree_host_unittest_animation.cc
@@ -124,11 +124,12 @@ class LayerTreeHostAnimationTestAddAnimation :
virtual void animateLayers(
LayerTreeHostImpl* impl_host,
- base::TimeTicks monotonic_time) OVERRIDE {
+ base::TimeTicks monotonic_time,
+ bool hasUnfinishedAnimation) OVERRIDE {
if (!num_animates_) {
// The animation had zero duration so layerTreeHostImpl should no
// longer need to animate its layers.
- EXPECT_FALSE(impl_host->needsAnimateLayers());
+ EXPECT_FALSE(hasUnfinishedAnimation);
num_animates_++;
first_monotonic_time_ = monotonic_time;
return;
@@ -169,7 +170,8 @@ class LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws :
virtual void animateLayers(
LayerTreeHostImpl* host_impl,
- base::TimeTicks monotonicTime) OVERRIDE {
+ base::TimeTicks monotonicTime,
+ bool hasUnfinishedAnimation) OVERRIDE {
started_animating_ = true;
}
@@ -242,7 +244,8 @@ public:
virtual void animateLayers(
LayerTreeHostImpl* host_impl,
- base::TimeTicks monotonicTime) OVERRIDE {
+ base::TimeTicks monotonicTime,
+ bool hasUnfinishedAnimation) OVERRIDE {
LayerAnimationController* controller =
m_layerTreeHost->rootLayer()->layerAnimationController();
ActiveAnimation* animation =
@@ -306,7 +309,8 @@ class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes :
virtual void animateLayers(
LayerTreeHostImpl* impl_host,
- base::TimeTicks monotonicTime) OVERRIDE {
+ base::TimeTicks monotonicTime,
+ bool hasUnfinishedAnimation) OVERRIDE {
LayerAnimationController* controller =
impl_host->rootLayer()->layerAnimationController();
ActiveAnimation* animation =
@@ -402,37 +406,37 @@ MULTI_THREAD_TEST_F(
class LayerTreeHostAnimationTestLayerAddedWithAnimation :
public LayerTreeHostAnimationTest {
public:
- LayerTreeHostAnimationTestLayerAddedWithAnimation()
- : added_animation_(false) {
- }
+ LayerTreeHostAnimationTestLayerAddedWithAnimation() { }
virtual void beginTest() OVERRIDE {
- EXPECT_FALSE(added_animation_);
-
- scoped_refptr<Layer> layer = Layer::create();
- layer->setLayerAnimationDelegate(this);
-
- // Any valid AnimationCurve will do here.
- scoped_ptr<AnimationCurve> curve(EaseTimingFunction::create());
- scoped_ptr<ActiveAnimation> animation(
- ActiveAnimation::create(curve.Pass(), 1, 1, ActiveAnimation::Opacity));
- layer->layerAnimationController()->addAnimation(animation.Pass());
-
- // We add the animation *before* attaching the layer to the tree.
- m_layerTreeHost->rootLayer()->addChild(layer);
- EXPECT_TRUE(added_animation_);
+ postSetNeedsCommitToMainThread();
+ }
- endTest();
+ virtual void didCommit() OVERRIDE {
+ if (m_layerTreeHost->commitNumber() == 1) {
+ scoped_refptr<Layer> layer = Layer::create();
+ layer->setLayerAnimationDelegate(this);
+
+ // Any valid AnimationCurve will do here.
+ scoped_ptr<AnimationCurve> curve(EaseTimingFunction::create());
+ scoped_ptr<ActiveAnimation> animation(
+ ActiveAnimation::create(curve.Pass(), 1, 1,
+ ActiveAnimation::Opacity));
+ layer->layerAnimationController()->addAnimation(animation.Pass());
+
+ // We add the animation *before* attaching the layer to the tree.
+ m_layerTreeHost->rootLayer()->addChild(layer);
+ }
}
- virtual void didAddAnimation() OVERRIDE {
- added_animation_ = true;
+ virtual void animateLayers(
+ LayerTreeHostImpl* impl_host,
+ base::TimeTicks monotonic_time,
+ bool hasUnfinishedAnimation) OVERRIDE {
+ endTest();
}
virtual void afterTest() OVERRIDE {}
-
-private:
- bool added_animation_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(