Index: cc/layer.cc |
diff --git a/cc/layer.cc b/cc/layer.cc |
index 3519f144f605e870e8cb58da4056116333aa8142..87f50ecfc09cfc5fc6f3ef5e72baa15cf3b1e1f8 100644 |
--- a/cc/layer.cc |
+++ b/cc/layer.cc |
@@ -32,7 +32,6 @@ Layer::Layer() |
, m_layerId(s_nextLayerId++) |
, m_parent(0) |
, m_layerTreeHost(0) |
- , m_layerAnimationController(LayerAnimationController::create(this)) |
, m_scrollable(false) |
, m_shouldScrollOnMainThread(false) |
, m_haveWheelEventHandlers(false) |
@@ -63,6 +62,8 @@ Layer::Layer() |
s_nextLayerId = 1; |
m_layerId = s_nextLayerId++; |
} |
+ m_layerAnimationController = LayerAnimationController::create(m_layerId); |
+ m_layerAnimationController->addObserver(this); |
} |
Layer::~Layer() |
@@ -71,6 +72,8 @@ Layer::~Layer() |
// way for us to be destroyed while we still have a parent. |
DCHECK(!parent()); |
+ m_layerAnimationController->removeObserver(this); |
+ |
// Remove the parent reference from all children. |
removeAllChildren(); |
} |
@@ -90,9 +93,7 @@ void Layer::setLayerTreeHost(LayerTreeHost* host) |
if (m_replicaLayer) |
m_replicaLayer->setLayerTreeHost(host); |
- // If this layer already has active animations, the host needs to be notified. |
- if (host && m_layerAnimationController->hasActiveAnimation()) |
- host->didAddAnimation(); |
+ m_layerAnimationController->setAnimationRegistrar(host); |
} |
void Layer::setNeedsCommit() |
@@ -371,6 +372,11 @@ void Layer::setOpacity(float opacity) |
setNeedsCommit(); |
} |
+float Layer::opacity() const |
+{ |
+ return m_opacity; |
+} |
+ |
bool Layer::opacityIsAnimating() const |
{ |
return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opacity); |
@@ -408,6 +414,11 @@ void Layer::setTransform(const gfx::Transform& transform) |
setNeedsCommit(); |
} |
+const gfx::Transform& Layer::transform() const |
+{ |
+ return m_transform; |
+} |
+ |
bool Layer::transformIsAnimating() const |
{ |
return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Transform); |
@@ -701,12 +712,7 @@ int Layer::id() const |
return m_layerId; |
} |
-float Layer::opacity() const |
-{ |
- return m_opacity; |
-} |
- |
-void Layer::setOpacityFromAnimation(float opacity) |
+void Layer::OnOpacityAnimated(float opacity) |
{ |
// This is called due to an ongoing accelerated animation. Since this animation is |
// also being run on the impl thread, there is no need to request a commit to push |
@@ -714,12 +720,7 @@ void Layer::setOpacityFromAnimation(float opacity) |
m_opacity = opacity; |
} |
-const gfx::Transform& Layer::transform() const |
-{ |
- return m_transform; |
-} |
- |
-void Layer::setTransformFromAnimation(const gfx::Transform& transform) |
+void Layer::OnTransformAnimated(const gfx::Transform& transform) |
{ |
// This is called due to an ongoing accelerated animation. Since this animation is |
// also being run on the impl thread, there is no need to request a commit to push |
@@ -746,10 +747,7 @@ bool Layer::addAnimation(scoped_ptr <ActiveAnimation> animation) |
#endif |
m_layerAnimationController->addAnimation(animation.Pass()); |
- if (m_layerTreeHost) { |
- m_layerTreeHost->didAddAnimation(); |
- setNeedsCommit(); |
- } |
+ setNeedsCommit(); |
return true; |
} |
@@ -777,21 +775,22 @@ void Layer::resumeAnimations(double monotonicTime) |
setNeedsCommit(); |
} |
-void Layer::setLayerAnimationController(scoped_ptr<LayerAnimationController> layerAnimationController) |
+void Layer::setLayerAnimationController(scoped_refptr<LayerAnimationController> layerAnimationController) |
{ |
- m_layerAnimationController = layerAnimationController.Pass(); |
- if (m_layerAnimationController) { |
- m_layerAnimationController->setClient(this); |
- m_layerAnimationController->setForceSync(); |
- } |
+ m_layerAnimationController->removeObserver(this); |
+ m_layerAnimationController = layerAnimationController; |
+ m_layerAnimationController->setForceSync(); |
+ m_layerAnimationController->addObserver(this); |
setNeedsCommit(); |
} |
-scoped_ptr<LayerAnimationController> Layer::releaseLayerAnimationController() |
+scoped_refptr<LayerAnimationController> Layer::releaseLayerAnimationController() |
{ |
- scoped_ptr<LayerAnimationController> toReturn = m_layerAnimationController.Pass(); |
- m_layerAnimationController = LayerAnimationController::create(this); |
- return toReturn.Pass(); |
+ m_layerAnimationController->removeObserver(this); |
+ scoped_refptr<LayerAnimationController> toReturn = m_layerAnimationController; |
+ m_layerAnimationController = LayerAnimationController::create(id()); |
+ m_layerAnimationController->addObserver(this); |
+ return toReturn; |
} |
bool Layer::hasActiveAnimation() const |