Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
animation_clip.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter 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 FLUTTER_IMPELLER_SCENE_ANIMATION_ANIMATION_CLIP_H_
6#define FLUTTER_IMPELLER_SCENE_ANIMATION_ANIMATION_CLIP_H_
7
8#include <memory>
9#include <unordered_map>
10#include <vector>
11
12#include "flutter/fml/macros.h"
15
16namespace impeller {
17namespace scene {
18
19class Node;
20class AnimationPlayer;
21
22class AnimationClip final {
23 public:
24 AnimationClip(std::shared_ptr<Animation> animation, Node* bind_target);
26
29
30 bool IsPlaying() const;
31
32 void SetPlaying(bool playing);
33
34 void Play();
35
36 void Pause();
37
38 void Stop();
39
40 bool GetLoop() const;
41
42 void SetLoop(bool looping);
43
45
46 /// @brief Sets the animation playback speed. Negative values make the clip
47 /// play in reverse.
48 void SetPlaybackTimeScale(Scalar playback_speed);
49
50 Scalar GetWeight() const;
51
52 void SetWeight(Scalar weight);
53
54 /// @brief Get the current playback time of the animation.
56
57 /// @brief Move the animation to the specified time. The given `time` is
58 /// clamped to the animation's playback range.
59 void Seek(SecondsF time);
60
61 /// @brief Advance the animation by `delta_time` seconds. Negative
62 /// `delta_time` values do nothing.
63 void Advance(SecondsF delta_time);
64
65 /// @brief Applies the animation to all binded properties in the scene.
66 void ApplyToBindings(
67 std::unordered_map<Node*, AnimationTransforms>& transform_decomps,
68 Scalar weight_multiplier) const;
69
70 private:
71 void BindToTarget(Node* node);
72
73 struct ChannelBinding {
74 const Animation::Channel& channel;
75 Node* node;
76 };
77
78 std::shared_ptr<Animation> animation_;
79 std::vector<ChannelBinding> bindings_;
80
81 SecondsF playback_time_;
82 Scalar playback_time_scale_ = 1; // Seconds multiplier, can be negative.
83 Scalar weight_ = 1;
84 bool playing_ = false;
85 bool loop_ = false;
86
87 AnimationClip(const AnimationClip&) = delete;
88
89 AnimationClip& operator=(const AnimationClip&) = delete;
90
91 friend AnimationPlayer;
92};
93
94} // namespace scene
95} // namespace impeller
96
97#endif // FLUTTER_IMPELLER_SCENE_ANIMATION_ANIMATION_CLIP_H_
void SetPlaybackTimeScale(Scalar playback_speed)
Sets the animation playback speed. Negative values make the clip play in reverse.
void ApplyToBindings(std::unordered_map< Node *, AnimationTransforms > &transform_decomps, Scalar weight_multiplier) const
Applies the animation to all binded properties in the scene.
SecondsF GetPlaybackTime() const
Get the current playback time of the animation.
void Advance(SecondsF delta_time)
Advance the animation by delta_time seconds. Negative delta_time values do nothing.
AnimationClip & operator=(AnimationClip &&)
AnimationClip(AnimationClip &&)
void Seek(SecondsF time)
Move the animation to the specified time. The given time is clamped to the animation's playback range...
Definition dart.idl:29
float Scalar
Definition scalar.h:18
std::chrono::duration< float > SecondsF
Definition timing.h:13