#include "cc/animation/animation_host.h"
#include <algorithm>
#include <memory>
#include <utility>
#include "base/auto_reset.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/traced_value.h"
#include "cc/animation/animation.h"
#include "cc/animation/animation_delegate.h"
#include "cc/animation/animation_events.h"
#include "cc/animation/animation_id_provider.h"
#include "cc/animation/animation_timeline.h"
#include "cc/animation/element_animations.h"
#include "cc/animation/keyframe_effect.h"
#include "cc/animation/scroll_offset_animation_curve.h"
#include "cc/animation/scroll_offset_animations.h"
#include "cc/animation/scroll_offset_animations_impl.h"
#include "cc/animation/scroll_timeline.h"
#include "cc/animation/worklet_animation.h"
#include "ui/gfx/animation/keyframe/timing_function.h"
#include "ui/gfx/geometry/box_f.h"
#include "ui/gfx/geometry/vector2d_f.h"
namespace cc {
namespace {
AnimationWorkletMutationState ToAnimationWorkletMutationState(
MutateStatus status) { … }
}
std::unique_ptr<AnimationHost> AnimationHost::CreateMainInstance() { … }
std::unique_ptr<AnimationHost> AnimationHost::CreateForTesting(
ThreadInstance thread_instance) { … }
AnimationHost::AnimationHost(ThreadInstance thread_instance)
: … { … }
AnimationHost::~AnimationHost() { … }
std::unique_ptr<MutatorHost> AnimationHost::CreateImplInstance() const { … }
const AnimationTimeline* AnimationHost::GetTimelineById(int timeline_id) const { … }
AnimationTimeline* AnimationHost::GetTimelineById(int timeline_id) { … }
void AnimationHost::ClearMutators() { … }
base::TimeDelta AnimationHost::MinimumTickInterval() const { … }
void AnimationHost::EraseTimeline(scoped_refptr<AnimationTimeline> timeline) { … }
void AnimationHost::AddAnimationTimeline(
scoped_refptr<AnimationTimeline> timeline) { … }
void AnimationHost::RemoveAnimationTimeline(
scoped_refptr<AnimationTimeline> timeline) { … }
void AnimationHost::DetachAnimationTimeline(
scoped_refptr<AnimationTimeline> timeline) { … }
void AnimationHost::SetHasCanvasInvalidation(bool has_canvas_invalidation) { … }
bool AnimationHost::HasCanvasInvalidation() const { … }
bool AnimationHost::HasJSAnimation() const { … }
void AnimationHost::SetHasInlineStyleMutation(bool has_inline_style_mutation) { … }
bool AnimationHost::HasSmilAnimation() const { … }
void AnimationHost::SetHasSmilAnimation(bool has_smil_animation) { … }
bool AnimationHost::HasViewTransition() const { … }
void AnimationHost::SetHasViewTransition(bool has_view_transition) { … }
void AnimationHost::SetCurrentFrameHadRaf(bool current_frame_had_raf) { … }
bool AnimationHost::CurrentFrameHadRAF() const { … }
void AnimationHost::SetNextFrameHasPendingRaf(bool next_frame_has_pending_raf) { … }
bool AnimationHost::NextFrameHasPendingRAF() const { … }
void AnimationHost::InitClientAnimationState() { … }
void AnimationHost::RemoveElementId(ElementId element_id) { … }
void AnimationHost::RegisterAnimationForElement(ElementId element_id,
Animation* animation) { … }
void AnimationHost::UnregisterAnimationForElement(ElementId element_id,
Animation* animation) { … }
void AnimationHost::UpdateClientAnimationStateForElementAnimations(
ElementId element_id) { … }
void AnimationHost::SetMutatorHostClient(MutatorHostClient* client) { … }
bool AnimationHost::IsOwnerThread() const { … }
bool AnimationHost::InProtectedSequence() const { … }
void AnimationHost::WaitForProtectedSequenceCompletion() const { … }
void AnimationHost::SetNeedsCommit() { … }
void AnimationHost::SetNeedsPushProperties() { … }
void AnimationHost::PushPropertiesTo(MutatorHost* mutator_host_impl,
const PropertyTrees& property_trees) { … }
void AnimationHost::RemoveStaleTimelines() { … }
void AnimationHost::PushTimelinesToImplThread(AnimationHost* host_impl) const { … }
void AnimationHost::RemoveTimelinesFromImplThread(
AnimationHost* host_impl) const { … }
void AnimationHost::PushPropertiesToImplThread(AnimationHost* host_impl) { … }
const ElementAnimations* AnimationHost::GetElementAnimationsForElementId(
ElementId element_id) const { … }
scoped_refptr<ElementAnimations>
AnimationHost::GetElementAnimationsForElementId(ElementId element_id) { … }
scoped_refptr<const ElementAnimations>
AnimationHost::GetElementAnimationsForElementIdForTesting(
ElementId element_id) const { … }
gfx::PointF AnimationHost::GetScrollOffsetForAnimation(
ElementId element_id) const { … }
void AnimationHost::SetScrollAnimationDurationForTesting(
base::TimeDelta duration) { … }
bool AnimationHost::NeedsTickAnimations() const { … }
void AnimationHost::TickMutator(base::TimeTicks monotonic_time,
const ScrollTree& scroll_tree,
bool is_active_tree) { … }
bool AnimationHost::ActivateAnimations(MutatorEvents* mutator_events) { … }
bool AnimationHost::TickAnimations(base::TimeTicks monotonic_time,
const ScrollTree& scroll_tree,
bool is_active_tree) { … }
void AnimationHost::TickScrollAnimations(base::TimeTicks monotonic_time,
const ScrollTree& scroll_tree) { … }
void AnimationHost::TickWorkletAnimations() { … }
std::unique_ptr<MutatorInputState> AnimationHost::CollectWorkletAnimationsState(
base::TimeTicks monotonic_time,
const ScrollTree& scroll_tree,
bool is_active_tree) { … }
bool AnimationHost::UpdateAnimationState(bool start_ready_animations,
MutatorEvents* mutator_events) { … }
void AnimationHost::TakeTimeUpdatedEvents(MutatorEvents* events) { … }
void AnimationHost::PromoteScrollTimelinesPendingToActive() { … }
std::unique_ptr<MutatorEvents> AnimationHost::CreateEvents() { … }
void AnimationHost::SetAnimationEvents(
std::unique_ptr<MutatorEvents> mutator_events) { … }
bool AnimationHost::ScrollOffsetAnimationWasInterrupted(
ElementId element_id) const { … }
bool AnimationHost::IsAnimatingProperty(ElementId element_id,
ElementListType list_type,
TargetProperty::Type property) const { … }
bool AnimationHost::HasPotentiallyRunningAnimationForProperty(
ElementId element_id,
ElementListType list_type,
TargetProperty::Type property) const { … }
bool AnimationHost::HasAnyAnimationTargetingProperty(
ElementId element_id,
TargetProperty::Type property) const { … }
bool AnimationHost::AnimationsPreserveAxisAlignment(
ElementId element_id) const { … }
float AnimationHost::MaximumScale(ElementId element_id,
ElementListType list_type) const { … }
bool AnimationHost::IsElementAnimating(ElementId element_id) const { … }
bool AnimationHost::HasTickingKeyframeModelForTesting(
ElementId element_id) const { … }
void AnimationHost::ImplOnlyAutoScrollAnimationCreate(
ElementId element_id,
const gfx::PointF& target_offset,
const gfx::PointF& current_offset,
float autoscroll_velocity,
base::TimeDelta animation_start_offset) { … }
void AnimationHost::ImplOnlyScrollAnimationCreate(
ElementId element_id,
const gfx::PointF& target_offset,
const gfx::PointF& current_offset,
base::TimeDelta delayed_by,
base::TimeDelta animation_start_offset) { … }
std::optional<gfx::PointF> AnimationHost::ImplOnlyScrollAnimationUpdateTarget(
const gfx::Vector2dF& scroll_delta,
const gfx::PointF& max_scroll_offset,
base::TimeTicks frame_monotonic_time,
base::TimeDelta delayed_by) { … }
ScrollOffsetAnimations& AnimationHost::scroll_offset_animations() { … }
void AnimationHost::ScrollAnimationAbort() { … }
ElementId AnimationHost::ImplOnlyScrollAnimatingElement() const { … }
void AnimationHost::ImplOnlyScrollAnimatingElementRemoved() { … }
void AnimationHost::AddToTicking(scoped_refptr<Animation> animation) { … }
void AnimationHost::RemoveFromTicking(scoped_refptr<Animation> animation) { … }
const AnimationHost::AnimationsList&
AnimationHost::ticking_animations_for_testing() const { … }
const AnimationHost::ElementToAnimationsMap&
AnimationHost::element_animations_for_testing() const { … }
void AnimationHost::SetLayerTreeMutator(
std::unique_ptr<LayerTreeMutator> mutator) { … }
WorkletAnimation* AnimationHost::FindWorkletAnimation(WorkletAnimationId id) { … }
void AnimationHost::SetMutationUpdate(
std::unique_ptr<MutatorOutputState> output_state) { … }
void AnimationHost::SetAnimationCounts(size_t total_animations_count) { … }
size_t AnimationHost::MainThreadAnimationsCount() const { … }
bool AnimationHost::HasInvalidationAnimation() const { … }
bool AnimationHost::HasNativePropertyAnimation() const { … }
AnimationHost::PendingThroughputTrackerInfos
AnimationHost::TakePendingThroughputTrackerInfos() { … }
void AnimationHost::StartThroughputTracking(
TrackedAnimationSequenceId sequence_id) { … }
void AnimationHost::StopThroughputTracking(
TrackedAnimationSequenceId sequnece_id) { … }
bool AnimationHost::HasScrollLinkedAnimation(ElementId for_scroller) const { … }
bool AnimationHost::IsAutoScrolling() const { … }
}