| 772 | }; |
| 773 | |
| 774 | void Layer::processAnimations(Duration delta) { |
| 775 | _enqueuedFrame = std::nullopt; |
| 776 | |
| 777 | if (_animations.empty()) { |
| 778 | return; |
| 779 | } |
| 780 | |
| 781 | Valdi::SmallVector<AnimationToProcess, 4> collectedAnimations; |
| 782 | |
| 783 | // Collect all the animations to process |
| 784 | { |
| 785 | auto animations = _animations.readAccess(); |
| 786 | for (const auto& it : animations) { |
| 787 | collectedAnimations.emplace_back(it.first, it.second); |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | // Process all our animations with the delta. |
| 792 | // We remove the ones that have completed |
| 793 | for (const auto& animationToProcess : collectedAnimations) { |
| 794 | auto completed = animationToProcess.animation->run(*this, delta); |
| 795 | if (completed) { |
| 796 | { |
| 797 | auto animations = _animations.writeAccess(); |
| 798 | const auto& it = animations->find(animationToProcess.key); |
| 799 | if (it != animations->end() && it->second == animationToProcess.animation) { |
| 800 | animations->erase(it); |
| 801 | } |
| 802 | } |
| 803 | animationToProcess.animation->complete(*this); |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | scheduleProcessAnimationsIfNeeded(); |
| 808 | } |
| 809 | |
| 810 | std::optional<Point> Layer::convertPointToLayer(Point point, const Valdi::Ref<Layer>& childLayer) const { |
| 811 | thread_local std::vector<Ref<Layer>> kDescendants; |
no test coverage detected