| Index: cc/layer_animation_controller.cc
|
| diff --git a/cc/layer_animation_controller.cc b/cc/layer_animation_controller.cc
|
| index 2dbdde8249eb3b734cfed1cadda16e8559b000d7..b4f4ffb6a268a8748e790030d52fdfd172bc6046 100644
|
| --- a/cc/layer_animation_controller.cc
|
| +++ b/cc/layer_animation_controller.cc
|
| @@ -4,6 +4,8 @@
|
|
|
| #include "cc/layer_animation_controller.h"
|
|
|
| +#include <algorithm>
|
| +
|
| #include "cc/active_animation.h"
|
| #include "cc/keyframed_animation_curve.h"
|
| #include <public/WebTransformationMatrix.h>
|
| @@ -35,24 +37,31 @@ void LayerAnimationController::pauseAnimation(int animationId, double timeOffset
|
| }
|
| }
|
|
|
| +struct HasAnimationId {
|
| + HasAnimationId(int id) : m_id(id) { }
|
| + bool operator()(ActiveAnimation* animation) const { return animation->id() == m_id; }
|
| +private:
|
| + int m_id;
|
| +};
|
| +
|
| void LayerAnimationController::removeAnimation(int animationId)
|
| {
|
| - for (size_t i = 0; i < m_activeAnimations.size();) {
|
| - if (m_activeAnimations[i]->id() == animationId)
|
| - m_activeAnimations.remove(i);
|
| - else
|
| - i++;
|
| - }
|
| + ScopedPtrVector<ActiveAnimation>& animations = m_activeAnimations;
|
| + animations.erase(std::remove_if(animations.begin(), animations.end(), HasAnimationId(animationId)), animations.end());
|
| }
|
|
|
| +struct HasAnimationIdAndProperty {
|
| + HasAnimationIdAndProperty(int id, ActiveAnimation::TargetProperty targetProperty) : m_id(id), m_targetProperty(targetProperty) { }
|
| + bool operator()(ActiveAnimation* animation) const { return animation->id() == m_id && animation->targetProperty() == m_targetProperty; }
|
| +private:
|
| + int m_id;
|
| + ActiveAnimation::TargetProperty m_targetProperty;
|
| +};
|
| +
|
| void LayerAnimationController::removeAnimation(int animationId, ActiveAnimation::TargetProperty targetProperty)
|
| {
|
| - for (size_t i = 0; i < m_activeAnimations.size();) {
|
| - if (m_activeAnimations[i]->id() == animationId && m_activeAnimations[i]->targetProperty() == targetProperty)
|
| - m_activeAnimations.remove(i);
|
| - else
|
| - i++;
|
| - }
|
| + ScopedPtrVector<ActiveAnimation>& animations = m_activeAnimations;
|
| + animations.erase(std::remove_if(animations.begin(), animations.end(), HasAnimationIdAndProperty(animationId, targetProperty)), animations.end());
|
| }
|
|
|
| // According to render layer backing, these are for testing only.
|
| @@ -106,7 +115,7 @@ void LayerAnimationController::animate(double monotonicTime, AnimationEventsVect
|
|
|
| void LayerAnimationController::addAnimation(scoped_ptr<ActiveAnimation> animation)
|
| {
|
| - m_activeAnimations.append(animation.Pass());
|
| + m_activeAnimations.push_back(animation.Pass());
|
| }
|
|
|
| ActiveAnimation* LayerAnimationController::getActiveAnimation(int groupId, ActiveAnimation::TargetProperty targetProperty) const
|
| @@ -185,18 +194,20 @@ void LayerAnimationController::pushNewAnimationsToImplThread(LayerAnimationContr
|
| }
|
| }
|
|
|
| +struct IsCompleted {
|
| + IsCompleted(const LayerAnimationController& mainThreadController) : m_mainThreadController(mainThreadController) { }
|
| + bool operator()(ActiveAnimation* animation) const { return !m_mainThreadController.getActiveAnimation(animation->group(), animation->targetProperty()); }
|
| +private:
|
| + const LayerAnimationController& m_mainThreadController;
|
| +};
|
| +
|
| void LayerAnimationController::removeAnimationsCompletedOnMainThread(LayerAnimationController* controllerImpl) const
|
| {
|
| // Delete all impl thread animations for which there is no corresponding main thread animation.
|
| // Each iteration, controller->m_activeAnimations.size() is decremented or i is incremented
|
| // guaranteeing progress towards loop termination.
|
| - for (size_t i = 0; i < controllerImpl->m_activeAnimations.size();) {
|
| - ActiveAnimation* current = getActiveAnimation(controllerImpl->m_activeAnimations[i]->group(), controllerImpl->m_activeAnimations[i]->targetProperty());
|
| - if (!current)
|
| - controllerImpl->m_activeAnimations.remove(i);
|
| - else
|
| - i++;
|
| - }
|
| + ScopedPtrVector<ActiveAnimation>& animations = controllerImpl->m_activeAnimations;
|
| + animations.erase(std::remove_if(animations.begin(), animations.end(), IsCompleted(*this)), animations.end());
|
| }
|
|
|
| void LayerAnimationController::pushPropertiesToImplThread(LayerAnimationController* controllerImpl) const
|
| @@ -330,14 +341,12 @@ void LayerAnimationController::markAnimationsForDeletion(double monotonicTime, A
|
| }
|
| }
|
|
|
| +static bool isWaitingForDeletion(ActiveAnimation* animation) { return animation->runState() == ActiveAnimation::WaitingForDeletion; }
|
| +
|
| void LayerAnimationController::purgeAnimationsMarkedForDeletion()
|
| {
|
| - for (size_t i = 0; i < m_activeAnimations.size();) {
|
| - if (m_activeAnimations[i]->runState() == ActiveAnimation::WaitingForDeletion)
|
| - m_activeAnimations.remove(i);
|
| - else
|
| - i++;
|
| - }
|
| + ScopedPtrVector<ActiveAnimation>& animations = m_activeAnimations;
|
| + animations.erase(std::remove_if(animations.begin(), animations.end(), isWaitingForDeletion), animations.end());
|
| }
|
|
|
| void LayerAnimationController::replaceImplThreadAnimations(LayerAnimationController* controllerImpl) const
|
|
|