Index: cc/layer.cc |
diff --git a/cc/layer.cc b/cc/layer.cc |
index 82b797c591b3c838abf22fa5bcc95ce9a62eb635..9fff8b934effa9e177ac2df1214eb29a4e2e6bb2 100644 |
--- a/cc/layer.cc |
+++ b/cc/layer.cc |
@@ -6,6 +6,7 @@ |
#include "cc/active_animation.h" |
#include "cc/animation_events.h" |
+#include "cc/animation_registrar.h" |
#include "cc/layer_animation_controller.h" |
#include "cc/layer_impl.h" |
#include "cc/layer_tree_host.h" |
@@ -32,7 +33,7 @@ Layer::Layer() |
, m_layerId(s_nextLayerId++) |
, m_parent(0) |
, m_layerTreeHost(0) |
- , m_layerAnimationController(LayerAnimationController::create(this)) |
+ , m_layerAnimationController(LayerAnimationController::create(AnimationRegistrar::MainThread)) |
, m_scrollable(false) |
, m_shouldScrollOnMainThread(false) |
, m_haveWheelEventHandlers(false) |
@@ -40,7 +41,6 @@ Layer::Layer() |
, m_touchEventHandlerRegionChanged(false) |
, m_anchorPoint(0.5, 0.5) |
, m_backgroundColor(0) |
- , m_opacity(1.0) |
, m_anchorPointZ(0) |
, m_isContainerForFixedPositionLayers(false) |
, m_fixedToContainerLayer(false) |
@@ -70,6 +70,7 @@ Layer::Layer() |
s_nextLayerId = 1; |
m_layerId = s_nextLayerId++; |
} |
+ m_layerAnimationController->setId(m_layerId); |
} |
Layer::~Layer() |
@@ -102,7 +103,6 @@ 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(); |
} |
@@ -359,12 +359,16 @@ bool Layer::needsDisplay() const |
void Layer::setOpacity(float opacity) |
{ |
- if (m_opacity == opacity) |
+ if (!m_layerAnimationController->setOpacity(opacity)) |
return; |
- m_opacity = opacity; |
setNeedsCommit(); |
} |
+float Layer::opacity() const |
+{ |
+ return m_layerAnimationController->opacity(); |
+} |
+ |
bool Layer::opacityIsAnimating() const |
{ |
return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opacity); |
@@ -396,12 +400,16 @@ void Layer::setSublayerTransform(const gfx::Transform& sublayerTransform) |
void Layer::setTransform(const gfx::Transform& transform) |
{ |
- if (m_transform == transform) |
+ if (!m_layerAnimationController->setTransform(transform)) |
return; |
- m_transform = transform; |
setNeedsCommit(); |
} |
+const gfx::Transform& Layer::transform() const |
+{ |
+ return m_layerAnimationController->transform(); |
+} |
+ |
bool Layer::transformIsAnimating() const |
{ |
return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Transform); |
@@ -584,8 +592,6 @@ void Layer::pushPropertiesTo(LayerImpl* layer) |
m_touchEventHandlerRegionChanged = false; |
} |
layer->setContentsOpaque(m_contentsOpaque); |
- if (!opacityIsAnimating()) |
- layer->setOpacity(m_opacity); |
layer->setPosition(m_position); |
layer->setIsContainerForFixedPositionLayers(m_isContainerForFixedPositionLayers); |
layer->setFixedToContainerLayer(m_fixedToContainerLayer); |
@@ -594,8 +600,6 @@ void Layer::pushPropertiesTo(LayerImpl* layer) |
layer->setScrollOffset(m_scrollOffset); |
layer->setMaxScrollOffset(m_maxScrollOffset); |
layer->setSublayerTransform(m_sublayerTransform); |
- if (!transformIsAnimating()) |
- layer->setTransform(m_transform); |
// If the main thread commits multiple times before the impl thread actually draws, then damage tracking |
// will become incorrect if we simply clobber the updateRect here. The LayerImpl's updateRect needs to |
@@ -719,32 +723,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 |
@@ -764,10 +742,9 @@ bool Layer::addAnimation(scoped_ptr <ActiveAnimation> animation) |
#endif |
m_layerAnimationController->addAnimation(animation.Pass()); |
- if (m_layerTreeHost) { |
- m_layerTreeHost->didAddAnimation(); |
- setNeedsCommit(); |
- } |
+ |
+ m_layerTreeHost->didAddAnimation(); |
+ setNeedsCommit(); |
return true; |
} |
@@ -795,21 +772,24 @@ 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(AnimationRegistrar::MainThread); |
+ m_layerAnimationController->setId(id()); |
+ m_layerAnimationController->setTransform(toReturn->transform()); |
+ m_layerAnimationController->setOpacity(toReturn->opacity()); |
+ return toReturn; |
} |
bool Layer::hasActiveAnimation() const |