#include "third_party/blink/renderer/platform/graphics/animation_worklet_mutator_dispatcher_impl.h"
#include <utility>
#include "base/barrier_closure.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_macros.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/default_tick_clock.h"
#include "base/time/time.h"
#include "base/timer/elapsed_timer.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/graphics/animation_worklet_mutator.h"
#include "third_party/blink/renderer/platform/graphics/compositor_mutator_client.h"
#include "third_party/blink/renderer/platform/graphics/main_thread_mutator_client.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_base.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_std.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/wtf.h"
namespace blink {
namespace {
int g_next_async_mutation_id = …;
int GetNextAsyncMutationId() { … }
}
class AnimationWorkletMutatorDispatcherImpl::OutputVectorRef
: public ThreadSafeRefCounted<OutputVectorRef> { … };
struct AnimationWorkletMutatorDispatcherImpl::AsyncMutationRequest { … };
AnimationWorkletMutatorDispatcherImpl::AnimationWorkletMutatorDispatcherImpl(
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: … { … }
AnimationWorkletMutatorDispatcherImpl::
~AnimationWorkletMutatorDispatcherImpl() { … }
template <typename ClientType>
std::unique_ptr<ClientType> AnimationWorkletMutatorDispatcherImpl::CreateClient(
base::WeakPtr<AnimationWorkletMutatorDispatcherImpl>& weak_interface,
scoped_refptr<base::SingleThreadTaskRunner> queue) { … }
std::unique_ptr<CompositorMutatorClient>
AnimationWorkletMutatorDispatcherImpl::CreateCompositorThreadClient(
base::WeakPtr<AnimationWorkletMutatorDispatcherImpl>& weak_interface,
scoped_refptr<base::SingleThreadTaskRunner> queue) { … }
std::unique_ptr<MainThreadMutatorClient>
AnimationWorkletMutatorDispatcherImpl::CreateMainThreadClient(
base::WeakPtr<AnimationWorkletMutatorDispatcherImpl>& weak_interface,
scoped_refptr<base::SingleThreadTaskRunner> queue) { … }
void AnimationWorkletMutatorDispatcherImpl::MutateSynchronously(
std::unique_ptr<AnimationWorkletDispatcherInput> mutator_input) { … }
base::TimeTicks AnimationWorkletMutatorDispatcherImpl::NowTicks() const { … }
bool AnimationWorkletMutatorDispatcherImpl::MutateAsynchronously(
std::unique_ptr<AnimationWorkletDispatcherInput> mutator_input,
MutateQueuingStrategy queuing_strategy,
AsyncMutationCompleteCallback done_callback) { … }
void AnimationWorkletMutatorDispatcherImpl::MutateAsynchronouslyInternal(
base::TimeTicks request_time,
AsyncMutationCompleteCallback done_callback) { … }
void AnimationWorkletMutatorDispatcherImpl::AsyncMutationsDone(
int async_mutation_id,
base::TimeTicks request_time) { … }
void AnimationWorkletMutatorDispatcherImpl::RegisterAnimationWorkletMutator(
CrossThreadPersistent<AnimationWorkletMutator> mutator,
scoped_refptr<base::SingleThreadTaskRunner> mutator_runner) { … }
void AnimationWorkletMutatorDispatcherImpl::UnregisterAnimationWorkletMutator(
CrossThreadPersistent<AnimationWorkletMutator> mutator) { … }
void AnimationWorkletMutatorDispatcherImpl::SynchronizeAnimatorName(
const String& animator_name) { … }
bool AnimationWorkletMutatorDispatcherImpl::HasMutators() { … }
AnimationWorkletMutatorDispatcherImpl::InputMap
AnimationWorkletMutatorDispatcherImpl::CreateInputMap(
AnimationWorkletDispatcherInput& mutator_input) const { … }
void AnimationWorkletMutatorDispatcherImpl::RequestMutations(
CrossThreadOnceClosure done_callback) { … }
bool AnimationWorkletMutatorDispatcherImpl::ApplyMutationsOnHostThread() { … }
}