Index: cc/layer_animation_controller.cc |
diff --git a/cc/layer_animation_controller.cc b/cc/layer_animation_controller.cc |
index e3373951abdcc8b12e3892ccbdbed9277fcbca6b..805f8fc264d5fbf7fae71609a0a77241a662caeb 100644 |
--- a/cc/layer_animation_controller.cc |
+++ b/cc/layer_animation_controller.cc |
@@ -5,29 +5,24 @@ |
#include "cc/layer_animation_controller.h" |
#include "cc/active_animation.h" |
-#include "cc/animation_registrar.h" |
#include "cc/keyframed_animation_curve.h" |
#include "ui/gfx/transform.h" |
namespace cc { |
-LayerAnimationController::LayerAnimationController() |
+LayerAnimationController::LayerAnimationController(LayerAnimationControllerClient* client) |
: m_forceSync(false) |
- , m_id(-1) |
- , m_opacity(1.0) |
- , m_registrar(0) |
+ , m_client(client) |
{ |
} |
LayerAnimationController::~LayerAnimationController() |
{ |
- if (m_registrar) |
- m_registrar->DidDeactivateAnimationController(this); |
} |
-scoped_refptr<LayerAnimationController> LayerAnimationController::create() |
+scoped_ptr<LayerAnimationController> LayerAnimationController::create(LayerAnimationControllerClient* client) |
{ |
- return make_scoped_refptr(new LayerAnimationController()); |
+ return make_scoped_ptr(new LayerAnimationController(client)); |
} |
void LayerAnimationController::pauseAnimation(int animationId, double timeOffset) |
@@ -46,7 +41,6 @@ void LayerAnimationController::removeAnimation(int animationId) |
else |
i++; |
} |
- updateRegistration(); |
} |
void LayerAnimationController::removeAnimation(int animationId, ActiveAnimation::TargetProperty targetProperty) |
@@ -57,7 +51,6 @@ void LayerAnimationController::removeAnimation(int animationId, ActiveAnimation: |
else |
i++; |
} |
- updateRegistration(); |
} |
// According to render layer backing, these are for testing only. |
@@ -82,12 +75,6 @@ void LayerAnimationController::resumeAnimations(double monotonicTime) |
// are kept in sync. |
void LayerAnimationController::pushAnimationUpdatesTo(LayerAnimationController* controllerImpl) |
{ |
- if (!isAnimatingProperty(ActiveAnimation::Opacity)) |
- controllerImpl->m_opacity = m_opacity; |
- |
- if (!isAnimatingProperty(ActiveAnimation::Transform)) |
- controllerImpl->m_transform = m_transform; |
- |
if (m_forceSync) { |
replaceImplThreadAnimations(controllerImpl); |
m_forceSync = false; |
@@ -113,14 +100,11 @@ void LayerAnimationController::animate(double monotonicTime, AnimationEventsVect |
tickAnimations(monotonicTime); |
markAnimationsForDeletion(monotonicTime, events); |
startAnimationsWaitingForTargetAvailability(monotonicTime, events); |
- |
- updateRegistration(); |
} |
void LayerAnimationController::addAnimation(scoped_ptr<ActiveAnimation> animation) |
{ |
m_activeAnimations.append(animation.Pass()); |
- updateRegistration(); |
} |
ActiveAnimation* LayerAnimationController::getActiveAnimation(int groupId, ActiveAnimation::TargetProperty targetProperty) const |
@@ -170,40 +154,9 @@ void LayerAnimationController::notifyAnimationStarted(const AnimationEvent& even |
} |
} |
-void LayerAnimationController::setAnimationRegistrar(AnimationRegistrar* registrar) |
-{ |
- if (m_registrar == registrar) |
- return; |
- |
- if (m_registrar) |
- m_registrar->UnregisterAnimationController(this); |
- |
- m_registrar = registrar; |
- if (m_registrar) |
- m_registrar->RegisterAnimationController(this); |
- |
- updateRegistration(); |
-} |
- |
-void LayerAnimationController::setId(int id) |
-{ |
- m_id = id; |
-} |
- |
-bool LayerAnimationController::setOpacity(float opacity) |
+void LayerAnimationController::setClient(LayerAnimationControllerClient* client) |
{ |
- if (m_opacity == opacity || isAnimatingProperty(ActiveAnimation::Opacity)) |
- return false; |
- m_opacity = opacity; |
- return true; |
-} |
- |
-bool LayerAnimationController::setTransform(const gfx::Transform& transform) |
-{ |
- if (m_transform == transform || isAnimatingProperty(ActiveAnimation::Transform)) |
- return false; |
- m_transform = transform; |
- return true; |
+ m_client = client; |
} |
void LayerAnimationController::pushNewAnimationsToImplThread(LayerAnimationController* controllerImpl) const |
@@ -261,7 +214,7 @@ void LayerAnimationController::startAnimationsWaitingForNextTick(double monotoni |
if (!m_activeAnimations[i]->hasSetStartTime()) |
m_activeAnimations[i]->setStartTime(monotonicTime); |
if (events) |
- events->push_back(AnimationEvent(AnimationEvent::Started, m_id, m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(), monotonicTime)); |
+ events->push_back(AnimationEvent(AnimationEvent::Started, m_client->id(), m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(), monotonicTime)); |
} |
} |
} |
@@ -272,7 +225,7 @@ void LayerAnimationController::startAnimationsWaitingForStartTime(double monoton |
if (m_activeAnimations[i]->runState() == ActiveAnimation::WaitingForStartTime && m_activeAnimations[i]->startTime() <= monotonicTime) { |
m_activeAnimations[i]->setRunState(ActiveAnimation::Running, monotonicTime); |
if (events) |
- events->push_back(AnimationEvent(AnimationEvent::Started, m_id, m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(), monotonicTime)); |
+ events->push_back(AnimationEvent(AnimationEvent::Started, m_client->id(), m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(), monotonicTime)); |
} |
} |
} |
@@ -311,7 +264,7 @@ void LayerAnimationController::startAnimationsWaitingForTargetAvailability(doubl |
if (!m_activeAnimations[i]->hasSetStartTime()) |
m_activeAnimations[i]->setStartTime(monotonicTime); |
if (events) |
- events->push_back(AnimationEvent(AnimationEvent::Started, m_id, m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(), monotonicTime)); |
+ events->push_back(AnimationEvent(AnimationEvent::Started, m_client->id(), m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(), monotonicTime)); |
for (size_t j = i + 1; j < m_activeAnimations.size(); ++j) { |
if (m_activeAnimations[i]->group() == m_activeAnimations[j]->group()) { |
m_activeAnimations[j]->setRunState(ActiveAnimation::Running, monotonicTime); |
@@ -367,7 +320,7 @@ void LayerAnimationController::markAnimationsForDeletion(double monotonicTime, A |
for (size_t j = i; j < m_activeAnimations.size(); j++) { |
if (groupId == m_activeAnimations[j]->group()) { |
if (events) |
- events->push_back(AnimationEvent(AnimationEvent::Finished, m_id, m_activeAnimations[j]->group(), m_activeAnimations[j]->targetProperty(), monotonicTime)); |
+ events->push_back(AnimationEvent(AnimationEvent::Finished, m_client->id(), m_activeAnimations[j]->group(), m_activeAnimations[j]->targetProperty(), monotonicTime)); |
m_activeAnimations[j]->setRunState(ActiveAnimation::WaitingForDeletion, monotonicTime); |
} |
} |
@@ -405,7 +358,7 @@ void LayerAnimationController::replaceImplThreadAnimations(LayerAnimationControl |
void LayerAnimationController::tickAnimations(double monotonicTime) |
{ |
- for (size_t i = 0; i < m_activeAnimations.size(); ++i) { |
+ for (size_t i = 0; i < m_activeAnimations.size(); ++i) { |
if (m_activeAnimations[i]->runState() == ActiveAnimation::Running || m_activeAnimations[i]->runState() == ActiveAnimation::Paused) { |
double trimmed = m_activeAnimations[i]->trimTimeToCurrentIteration(monotonicTime); |
@@ -418,17 +371,21 @@ void LayerAnimationController::tickAnimations(double monotonicTime) |
case ActiveAnimation::Transform: { |
const TransformAnimationCurve* transformAnimationCurve = m_activeAnimations[i]->curve()->toTransformAnimationCurve(); |
- m_transform = transformAnimationCurve->getValue(trimmed).toTransform(); |
+ const gfx::Transform matrix = transformAnimationCurve->getValue(trimmed).toTransform(); |
if (m_activeAnimations[i]->isFinishedAt(monotonicTime)) |
m_activeAnimations[i]->setRunState(ActiveAnimation::Finished, monotonicTime); |
+ |
+ m_client->setTransformFromAnimation(matrix); |
break; |
} |
case ActiveAnimation::Opacity: { |
const FloatAnimationCurve* floatAnimationCurve = m_activeAnimations[i]->curve()->toFloatAnimationCurve(); |
- m_opacity = floatAnimationCurve->getValue(trimmed); |
+ const float opacity = floatAnimationCurve->getValue(trimmed); |
if (m_activeAnimations[i]->isFinishedAt(monotonicTime)) |
m_activeAnimations[i]->setRunState(ActiveAnimation::Finished, monotonicTime); |
+ |
+ m_client->setOpacityFromAnimation(opacity); |
break; |
} |
@@ -440,14 +397,4 @@ void LayerAnimationController::tickAnimations(double monotonicTime) |
} |
} |
-void LayerAnimationController::updateRegistration() |
-{ |
- if (m_registrar) { |
- if (hasActiveAnimation()) |
- m_registrar->DidActivateAnimationController(this); |
- else |
- m_registrar->DidDeactivateAnimationController(this); |
- } |
-} |
- |
} // namespace cc |