Flutter Engine
The Flutter Engine
property_resolver.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_PROPERTY_RESOLVER_H_
6#define FLUTTER_IMPELLER_SCENE_ANIMATION_PROPERTY_RESOLVER_H_
7
8#include <memory>
9#include <vector>
10
16
17namespace impeller {
18namespace scene {
19
20class Node;
21class TranslationTimelineResolver;
22class RotationTimelineResolver;
23class ScaleTimelineResolver;
24
26 public:
27 static std::unique_ptr<TranslationTimelineResolver> MakeTranslationTimeline(
28 std::vector<Scalar> times,
29 std::vector<Vector3> values);
30
31 static std::unique_ptr<RotationTimelineResolver> MakeRotationTimeline(
32 std::vector<Scalar> times,
33 std::vector<Quaternion> values);
34
35 static std::unique_ptr<ScaleTimelineResolver> MakeScaleTimeline(
36 std::vector<Scalar> times,
37 std::vector<Vector3> values);
38
40
41 virtual SecondsF GetEndTime() = 0;
42
43 /// @brief Resolve and apply the property value to a target node. This
44 /// operation is additive; a given node property may be amended by
45 /// many different PropertyResolvers prior to rendering. For example,
46 /// an AnimationPlayer may blend multiple Animations together by
47 /// applying several AnimationClips.
50 Scalar weight) = 0;
51};
52
54 public:
56
57 // |Resolver|
59
60 protected:
61 struct TimelineKey {
62 /// The index of the closest previous keyframe.
63 size_t index = 0;
64 /// Used to interpolate between the resolved values for `timeline_index - 1`
65 /// and `timeline_index`. The range of this value should always be `0>N>=1`.
67 };
69
70 std::vector<Scalar> times_;
71};
72
74 public:
76
77 // |Resolver|
80 Scalar weight) override;
81
82 private:
84
85 std::vector<Vector3> values_;
86
88
90 delete;
91
92 friend PropertyResolver;
93};
94
96 public:
98
99 // |Resolver|
102 Scalar weight) override;
103
104 private:
106
107 std::vector<Quaternion> values_;
108
110
111 RotationTimelineResolver& operator=(const RotationTimelineResolver&) = delete;
112
113 friend PropertyResolver;
114};
115
117 public:
119
120 // |Resolver|
123 Scalar weight) override;
124
125 private:
127
128 std::vector<Vector3> values_;
129
131
132 ScaleTimelineResolver& operator=(const ScaleTimelineResolver&) = delete;
133
134 friend PropertyResolver;
135};
136
137} // namespace scene
138} // namespace impeller
139
140#endif // FLUTTER_IMPELLER_SCENE_ANIMATION_PROPERTY_RESOLVER_H_
static SkISize times(const SkISize &size, float factor)
static std::unique_ptr< RotationTimelineResolver > MakeRotationTimeline(std::vector< Scalar > times, std::vector< Quaternion > values)
static std::unique_ptr< ScaleTimelineResolver > MakeScaleTimeline(std::vector< Scalar > times, std::vector< Vector3 > values)
static std::unique_ptr< TranslationTimelineResolver > MakeTranslationTimeline(std::vector< Scalar > times, std::vector< Vector3 > values)
virtual SecondsF GetEndTime()=0
virtual void Apply(AnimationTransforms &target, SecondsF time, Scalar weight)=0
Resolve and apply the property value to a target node. This operation is additive; a given node prope...
void Apply(AnimationTransforms &target, SecondsF time, Scalar weight) override
Resolve and apply the property value to a target node. This operation is additive; a given node prope...
void Apply(AnimationTransforms &target, SecondsF time, Scalar weight) override
Resolve and apply the property value to a target node. This operation is additive; a given node prope...
TimelineKey GetTimelineKey(SecondsF time)
void Apply(AnimationTransforms &target, SecondsF time, Scalar weight) override
Resolve and apply the property value to a target node. This operation is additive; a given node prope...
uint32_t * target
Definition: dart.idl:29
float Scalar
Definition: scalar.h:18
std::chrono::duration< float > SecondsF
Definition: timing.h:13
static double time(int loops, Benchmark *bench, Target *target)
Definition: nanobench.cpp:394
size_t index
The index of the closest previous keyframe.