summaryrefslogtreecommitdiffstats
path: root/cc/test
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/test
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/test')
-rw-r--r--cc/test/animation_test_common.cc23
-rw-r--r--cc/test/animation_test_common.h21
-rw-r--r--cc/test/fake_proxy.h1
-rw-r--r--cc/test/layer_tree_test_common.cc30
-rw-r--r--cc/test/layer_tree_test_common.h3
5 files changed, 26 insertions, 52 deletions
diff --git a/cc/test/animation_test_common.cc b/cc/test/animation_test_common.cc
index 9920751..258a266 100644
--- a/cc/test/animation_test_common.cc
+++ b/cc/test/animation_test_common.cc
@@ -146,40 +146,25 @@ float FakeFloatTransition::getValue(double time) const
return (1 - time) * m_from + time * m_to;
}
-FakeLayerAnimationControllerClient::FakeLayerAnimationControllerClient()
+FakeLayerAnimationValueObserver::FakeLayerAnimationValueObserver()
: m_opacity(0)
{
}
-FakeLayerAnimationControllerClient::~FakeLayerAnimationControllerClient()
+FakeLayerAnimationValueObserver::~FakeLayerAnimationValueObserver()
{
}
-int FakeLayerAnimationControllerClient::id() const
-{
- return 0;
-}
-
-void FakeLayerAnimationControllerClient::setOpacityFromAnimation(float opacity)
+void FakeLayerAnimationValueObserver::OnOpacityAnimated(float opacity)
{
m_opacity = opacity;
}
-float FakeLayerAnimationControllerClient::opacity() const
-{
- return m_opacity;
-}
-
-void FakeLayerAnimationControllerClient::setTransformFromAnimation(const gfx::Transform& transform)
+void FakeLayerAnimationValueObserver::OnTransformAnimated(const gfx::Transform& transform)
{
m_transform = transform;
}
-const gfx::Transform& FakeLayerAnimationControllerClient::transform() const
-{
- return m_transform;
-}
-
scoped_ptr<cc::AnimationCurve> FakeFloatTransition::clone() const
{
return make_scoped_ptr(new FakeFloatTransition(*this)).PassAs<cc::AnimationCurve>();
diff --git a/cc/test/animation_test_common.h b/cc/test/animation_test_common.h
index 6ee0cdd..6df5db2 100644
--- a/cc/test/animation_test_common.h
+++ b/cc/test/animation_test_common.h
@@ -8,6 +8,7 @@
#include "cc/active_animation.h"
#include "cc/animation_curve.h"
#include "cc/layer_animation_controller.h"
+#include "cc/layer_animation_value_observer.h"
namespace cc {
class LayerImpl;
@@ -60,17 +61,17 @@ private:
float m_to;
};
-class FakeLayerAnimationControllerClient : public cc::LayerAnimationControllerClient {
+class FakeLayerAnimationValueObserver : public cc::LayerAnimationValueObserver {
public:
- FakeLayerAnimationControllerClient();
- virtual ~FakeLayerAnimationControllerClient();
-
- // LayerAnimationControllerClient implementation
- virtual int id() const OVERRIDE;
- virtual void setOpacityFromAnimation(float) OVERRIDE;
- virtual float opacity() const OVERRIDE;
- virtual void setTransformFromAnimation(const gfx::Transform&) OVERRIDE;
- virtual const gfx::Transform& transform() const OVERRIDE;
+ FakeLayerAnimationValueObserver();
+ virtual ~FakeLayerAnimationValueObserver();
+
+ // LayerAnimationValueObserver implementation
+ virtual void OnOpacityAnimated(float) OVERRIDE;
+ virtual void OnTransformAnimated(const gfx::Transform&) OVERRIDE;
+
+ float opacity() const { return m_opacity; }
+ const gfx::Transform& transform() const { return m_transform; }
private:
float m_opacity;
diff --git a/cc/test/fake_proxy.h b/cc/test/fake_proxy.h
index 280c1a4..ba0014f 100644
--- a/cc/test/fake_proxy.h
+++ b/cc/test/fake_proxy.h
@@ -30,7 +30,6 @@ public:
virtual void setNeedsCommit() OVERRIDE { }
virtual void setNeedsRedraw() OVERRIDE { }
virtual void setDeferCommits(bool) OVERRIDE { }
- virtual void didAddAnimation() OVERRIDE { }
virtual void mainThreadHasStoppedFlinging() OVERRIDE { }
virtual bool commitRequested() const OVERRIDE;
virtual void start() OVERRIDE { }
diff --git a/cc/test/layer_tree_test_common.cc b/cc/test/layer_tree_test_common.cc
index c5f0bde..57c52c7 100644
--- a/cc/test/layer_tree_test_common.cc
+++ b/cc/test/layer_tree_test_common.cc
@@ -5,6 +5,7 @@
#include "cc/test/layer_tree_test_common.h"
#include "cc/active_animation.h"
+#include "cc/animation_registrar.h"
#include "cc/content_layer.h"
#include "cc/font_atlas.h"
#include "cc/input_handler.h"
@@ -73,7 +74,15 @@ void MockLayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::T
{
m_testHooks->willAnimateLayers(this, monotonicTime);
LayerTreeHostImpl::animateLayers(monotonicTime, wallClockTime);
- m_testHooks->animateLayers(this, monotonicTime);
+ bool hasUnfinishedAnimation = false;
+ AnimationRegistrar::AnimationControllerMap::const_iterator iter = activeAnimationControllers().begin();
+ for (; iter != activeAnimationControllers().end(); ++iter) {
+ if (iter->second->hasActiveAnimation()) {
+ hasUnfinishedAnimation = true;
+ break;
+ }
+ }
+ m_testHooks->animateLayers(this, monotonicTime, hasUnfinishedAnimation);
}
base::TimeDelta MockLayerTreeHostImpl::lowFrequencyAnimationInterval() const
@@ -103,12 +112,6 @@ public:
return MockLayerTreeHostImpl::create(m_testHooks, settings(), client, proxy()).PassAs<cc::LayerTreeHostImpl>();
}
- virtual void didAddAnimation() OVERRIDE
- {
- LayerTreeHost::didAddAnimation();
- m_testHooks->didAddAnimation();
- }
-
virtual void setNeedsCommit() OVERRIDE
{
if (!m_testStarted)
@@ -279,11 +282,6 @@ void ThreadedTest::postSetVisibleToMainThread(bool visible)
m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSetVisible, base::Unretained(this), visible));
}
-void ThreadedTest::postDidAddAnimationToMainThread()
-{
- m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchDidAddAnimation, base::Unretained(this)));
-}
-
void ThreadedTest::doBeginTest()
{
m_client = ThreadedMockLayerTreeHostClient::create(this);
@@ -408,14 +406,6 @@ void ThreadedTest::dispatchComposite()
m_layerTreeHost->composite();
}
-void ThreadedTest::dispatchDidAddAnimation()
-{
- DCHECK(!proxy() || proxy()->isMainThread());
-
- if (m_layerTreeHost.get())
- m_layerTreeHost->didAddAnimation();
-}
-
void ThreadedTest::runTest(bool threaded)
{
if (threaded) {
diff --git a/cc/test/layer_tree_test_common.h b/cc/test/layer_tree_test_common.h
index ee86818..bdaac44 100644
--- a/cc/test/layer_tree_test_common.h
+++ b/cc/test/layer_tree_test_common.h
@@ -28,7 +28,7 @@ public:
virtual void commitCompleteOnThread(LayerTreeHostImpl*) { }
virtual bool prepareToDrawOnThread(LayerTreeHostImpl*);
virtual void drawLayersOnThread(LayerTreeHostImpl*) { }
- virtual void animateLayers(LayerTreeHostImpl*, base::TimeTicks monotonicTime) { }
+ virtual void animateLayers(LayerTreeHostImpl*, base::TimeTicks monotonicTime, bool hasUnfinishedAnimation) { }
virtual void willAnimateLayers(LayerTreeHostImpl*, base::TimeTicks monotonicTime) { }
virtual void applyScrollAndScale(gfx::Vector2d, float) { }
virtual void animate(base::TimeTicks monotonicTime) { }
@@ -81,7 +81,6 @@ public:
void postAcquireLayerTextures();
void postSetNeedsRedrawToMainThread();
void postSetVisibleToMainThread(bool visible);
- void postDidAddAnimationToMainThread();
void doBeginTest();
void timeout();