1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_ANIMATION_WORKLET_MUTATOR_DISPATCHER_H_
6 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_ANIMATION_WORKLET_MUTATOR_DISPATCHER_H_
7 
8 #include "base/bind.h"
9 #include "third_party/blink/renderer/platform/graphics/animation_worklet_mutators_state.h"
10 #include "third_party/blink/renderer/platform/platform_export.h"
11 #include "third_party/blink/renderer/platform/wtf/functional.h"
12 
13 namespace blink {
14 
15 class PLATFORM_EXPORT AnimationWorkletMutatorDispatcher {
16  public:
17   virtual ~AnimationWorkletMutatorDispatcher() = default;
18 
19   using AsyncMutationCompleteCallback =
20       WTF::CrossThreadOnceFunction<void(MutateStatus)>;
21 
22   // Run the animation frame callbacks from all connected AnimationWorklets.
23   virtual void MutateSynchronously(
24       std::unique_ptr<AnimationWorkletDispatcherInput>) = 0;
25 
26   // Queues the animation frame callbacks from all connected AnimationWorklets.
27   // The queuing strategy determines what action to take when busy servicing
28   // another request. The callback is triggered on completion or canceling of
29   // the mutation cycle. Returns true if mutations results are expected.
30   virtual bool MutateAsynchronously(
31       std::unique_ptr<AnimationWorkletDispatcherInput>,
32       MutateQueuingStrategy,
33       AsyncMutationCompleteCallback) = 0;
34 
35   // Returns true if Mutate may do something if called 'now'.
36   virtual bool HasMutators() = 0;
37 };
38 
39 }  // namespace blink
40 
41 #endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_ANIMATION_WORKLET_MUTATOR_DISPATCHER_H_
42