Chromium Code Reviews| Index: cc/layer.cc |
| diff --git a/cc/layer.cc b/cc/layer.cc |
| index c7b7ebc503b02e3e7190777985bf67d880a685e7..4cc0a066668e256bba4aba5a3579877d7d17effb 100644 |
| --- a/cc/layer.cc |
| +++ b/cc/layer.cc |
| @@ -32,7 +32,7 @@ Layer::Layer() |
| , m_layerId(s_nextLayerId++) |
| , m_parent(0) |
| , m_layerTreeHost(0) |
| - , m_layerAnimationController(LayerAnimationController::create(this)) |
| + , m_layerAnimationController(LayerAnimationController::create()) |
| , m_scrollable(false) |
| , m_shouldScrollOnMainThread(false) |
| , m_haveWheelEventHandlers(false) |
| @@ -71,6 +71,7 @@ Layer::Layer() |
| s_nextLayerId = 1; |
| m_layerId = s_nextLayerId++; |
| } |
| + m_layerAnimationController->setId(m_layerId); |
| } |
| Layer::~Layer() |
| @@ -105,9 +106,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() |
| @@ -359,9 +358,17 @@ void Layer::setOpacity(float opacity) |
| if (m_opacity == opacity) |
| return; |
| m_opacity = opacity; |
| + m_opacityLastUpdateTime = base::TimeTicks::Now(); |
| setNeedsCommit(); |
| } |
| +float Layer::opacity() const |
| +{ |
| + if (m_layerAnimationController->opacityLastUpdateTime() > m_opacityLastUpdateTime) |
|
jamesr
2012/12/03 04:40:15
could you explain what this logic is for? anything
Ian Vollick
2012/12/03 14:47:03
Sure. Animation controllers used to push new value
enne (OOO)
2012/12/04 01:32:16
This is really strange to my eyes too. If the opa
Ian Vollick
2012/12/04 19:49:06
Yes, it should. In fact, in my latest patch we exp
|
| + return m_layerAnimationController->opacity(); |
| + return m_opacity; |
| +} |
| + |
| bool Layer::opacityIsAnimating() const |
| { |
| return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opacity); |
| @@ -396,9 +403,17 @@ void Layer::setTransform(const gfx::Transform& transform) |
| if (m_transform == transform) |
| return; |
| m_transform = transform; |
| + m_transformLastUpdateTime = base::TimeTicks::Now(); |
| setNeedsCommit(); |
| } |
| +const gfx::Transform& Layer::transform() const |
| +{ |
| + if (m_layerAnimationController->transformLastUpdateTime() > m_transformLastUpdateTime) |
| + return m_layerAnimationController->transform(); |
| + return m_transform; |
| +} |
| + |
| bool Layer::transformIsAnimating() const |
| { |
| return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Transform); |
| @@ -712,32 +727,6 @@ int Layer::id() const |
| return m_layerId; |
| } |
| -float Layer::opacity() const |
| -{ |
| - return m_opacity; |
| -} |
| - |
| -void Layer::setOpacityFromAnimation(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 |
| - // this value over, so set the value directly rather than calling setOpacity. |
| - m_opacity = opacity; |
| -} |
| - |
| -const gfx::Transform& Layer::transform() const |
| -{ |
| - return m_transform; |
| -} |
| - |
| -void Layer::setTransformFromAnimation(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 |
| - // this value over, so set this value directly rather than calling setTransform. |
| - m_transform = transform; |
| -} |
| - |
| bool Layer::addAnimation(scoped_ptr <ActiveAnimation> animation) |
| { |
| // WebCore currently assumes that accelerated animations will start soon |
| @@ -757,10 +746,7 @@ bool Layer::addAnimation(scoped_ptr <ActiveAnimation> animation) |
| #endif |
| m_layerAnimationController->addAnimation(animation.Pass()); |
| - if (m_layerTreeHost) { |
| - m_layerTreeHost->didAddAnimation(); |
| setNeedsCommit(); |
| - } |
| return true; |
| } |
| @@ -788,21 +774,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(); |
| + m_layerAnimationController = layerAnimationController; |
| if (m_layerAnimationController) { |
| - m_layerAnimationController->setClient(this); |
| + m_layerAnimationController->setId(id()); |
| m_layerAnimationController->setForceSync(); |
| } |
| 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(); |
| + scoped_refptr<LayerAnimationController> toReturn = m_layerAnimationController; |
| + m_layerAnimationController = LayerAnimationController::create(); |
| + m_layerAnimationController->setId(id()); |
| + return toReturn; |
| } |
| bool Layer::hasActiveAnimation() const |