void CCLayerTreeHostImpl::animateLayersRecursive(CCLayerImpl* current, double frameBeginTimeSecs, CCAnimationEventsVector& events, bool& didAnimate, bool& needsAnimateLayers) { bool subtreeNeedsAnimateLayers = false; CCLayerAnimationControllerImpl* currentController = current->layerAnimationController(); bool hadActiveAnimation = currentController->hasActiveAnimation(); currentController->animate(frameBeginTimeSecs, events); bool startedAnimation = events.size() > 0; // We animated if we either ticked a running animation, or started a new animation. if (hadActiveAnimation || startedAnimation) didAnimate = true; // If the current controller still has an active animation, we must continue animating layers. if (currentController->hasActiveAnimation()) subtreeNeedsAnimateLayers = true; for (size_t i = 0; i < current->children().size(); ++i) { bool childNeedsAnimateLayers = false; animateLayersRecursive(current->children()[i].get(), frameBeginTimeSecs, events, didAnimate, childNeedsAnimateLayers); if (childNeedsAnimateLayers) subtreeNeedsAnimateLayers = true; } needsAnimateLayers = subtreeNeedsAnimateLayers; }
void CCLayerTreeHost::setAnimationEventsRecursive(const CCAnimationEventsVector& events, LayerChromium* layer, double wallClockTime) { if (!layer) return; for (size_t eventIndex = 0; eventIndex < events.size(); ++eventIndex) { if (layer->id() == events[eventIndex].layerId) { if (events[eventIndex].type == CCAnimationEvent::Started) layer->notifyAnimationStarted(events[eventIndex], wallClockTime); else layer->notifyAnimationFinished(wallClockTime); } } for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIndex) setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); }